vhall-mini-sdk 0.2.0 → 0.2.1
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/README.md +106 -11
- package/lib/sdk/main/index.js +1 -1
- package/package.json +1 -1
package/lib/sdk/main/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* vhall-mini-sdk v0.2.
|
|
1
|
+
/* vhall-mini-sdk v0.2.1 | built at 2026-08-05T09:43:41.880Z */
|
|
2
2
|
"use strict";function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,e||[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof i?i:i+""}function _wrapNativeSuper(t){var r="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(t){if(null===t||!function _isNativeFunction(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(n){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,Wrapper)}function Wrapper(){return function _construct(t,e,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_setPrototypeOf(p,r.prototype),p}(t,arguments,_getPrototypeOf(this).constructor)}return Wrapper.prototype=Object.create(t.prototype,{constructor:{value:Wrapper,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(Wrapper,t)},_wrapNativeSuper(t)}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromNamespaceIfNotNamed(n){return n&&Object.prototype.hasOwnProperty.call(n,"default")&&1===Object.keys(n).length?n.default:n}var hasRequiredBonreeSDK_MP_Wechat_min,bonreeSDK_MP_Wechat_min={};class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}const EVENT$1={SDK_READY:"sdkStateReady",INITBEFORE_SUCCESS:"initBeforeSuccess",INITBEFORE_FAILED:"initBeforeFailed",INIT_FAILED:"init_failed",NET_STATE_CHANGE:"net_state_change",ERROR:"error",ROOM_MSG:"room_msg",JOIN_MSG:"join_msg",LEAVE_MSG:"leave_msg",CHAT_MSG:"chat_msg",CUSTOM_MSG:"custom_msg",LIVE_START:"live_start",LIVE_END:"live_end",LIKE_MSG:"like_msg",KICKOUT:"room_kickout",RECORD_WATCH_EXPIRE_SET:"record_watch_expire_set",RECORD_WATCH_EXPIRE_ALERT:"record_watch_expire_alert",GIFT_MSG:"gift_msg",MALL_REWARD_PUSH:"mall_reward_push",MALL_REWARD_END:"mall_reward_end",DELETE_MSG:"chat_delete",FOREGROUND_REFRESH:"foreground_refresh"},ERR_CODE_OK=0,ERR_CODE_LOGIN_FAILD=5e3,ERR_CODE_INIT_BEFORE_FAILD=5001,ERR_CODE_INIT_ROOM_FAILD=5002,ERR_CODE_INIT_IM_FAILD=5003,ERR_CODE_INIT_PERMISSIONS_FAILD=5004,ERR_CODE_INIT_COMMON_CONFIG_FAILD=5005,ERR_CODE_INIT_INVATOOL_STATUS_FAILD=5006,ERR_CODE_INIT_EXCEPTION=5020,SUPPORTED_PLUGINS={RoomServer:1,UserServer:1,LogReportServer:1,CustomMenuServer:1,InviteCardServer:1,ChatServer:1,ProductServer:1,InteractServer:1,LotteryServer:1,MallRewardServer:1},envConfig={production:{BASE_URL:"https://open-api.vhall.com",VHALLYUN_API_BASE:"https://api.vhallyun.com",LOG_REPORT_BASE_URL:"https://dc.e.vhall.com/login",PUBLIC_KEY:"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0eUJFtW3vryA2NXx4M4f\n1w7dg3PHwOCA6Kx7JVfD/9eBGfqLhqsp+pg4AXG4PhuQx8EsV+sncQIiQO5J2//T\n3pO8LftDtCQztLnxnhq+BjhbFeswgfez2CwV2YKLTX2zyZ69T1Vu/M4H4gWSLeiV\n1FcH6xycA2+jG+EvOxSSItCKYT9EkB9BZSKf5RU7gM+qPtzdPtJP5vlsMCa0WnpY\nI6Qrmu/w9CZkL0397gUek9nBpPHkyPYg7ZijF3Gj8EqCMCVVTYpX96k4dd/Rz1em\ns4OSPF5jDsYZi58p+LmTcc3g7W9bD3QWWxzn47ie/Dh9LbnWfCqpGjUaHd3d42vR\ncQIDAQAB\n-----END PUBLIC KEY-----"},test:{BASE_URL:"https://test01-open-api.vhou.tv",VHALLYUN_API_BASE:"https://test01-api.vhallyun.com",LOG_REPORT_BASE_URL:"https://t-dc.e.vhall.com/login",PUBLIC_KEY:"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxWGCgHz2NLdVNa91CsNX\nFfCsxfgkTx738t3yMpuPYLL/5wwuWRrX7hBfNsfC+R5BW5b13ISzD001NNt+BWGK\np3V5fdWO18j9M/AhaTV2Ao/IpdP5huvVoNFVWPUQvX70FHu0sPVTev8ycAZHUpKx\n+mm83wxOpWBN5vAMJYx75pRCQfidb73XbOm6JXLJlxN91TUTrTiblxBhRwH0AQyr\ns9dUr+IJUZ1ea2uU3fkB4uYh7V/cHuNDMsJowfLtEU2+9IqEuJY4OwqX0qdfPF72\nsGMjCgghgL0z/7kv7Qe1+tOkJTBQTzODXBheGTVbF7hH2+5XuZsK2TfgBIew0I4k\n1wIDAQAB\n-----END PUBLIC KEY-----"}};function isString(str){return"string"==typeof str}function isObj(obj){return"[object Object]"===Object.prototype.toString.call(obj)}function deepCopy(data){if("object"!=typeof data||null===data)return data;if(Array.isArray(data))return data.map(item=>deepCopy(item));if(data instanceof Set)return new Set(Array.from(data).map(item=>deepCopy(item)));if(data instanceof Map)return new Map(Array.from(data).map(([key,value])=>[key,deepCopy(value)]));if(data instanceof Date)return new Date(data.getTime());if(data instanceof RegExp)return new RegExp(data.source,data.flags);const result={};for(const key in data)data.hasOwnProperty(key)&&(result[key]=deepCopy(data[key]));return result}const safeJsonParse$1=function(val){const type=Object.prototype.toString.call(val);if(["[object Array]","[object Object]","[object Null]"].includes(type))return val;try{return JSON.parse(val)}catch(ex){return null}},truncateString=function(str,maxLen=30){return str&&"string"==typeof str?str.length>maxLen?str.substring(0,30):str:""};function isEmpty(value){return null==value||("string"==typeof value||Array.isArray(value)?0===value.length:"object"==typeof value&&0===Object.keys(value).length)}class RequestUtil{constructor(options={}){this.baseUrl=options?.baseUrl,this.headers=Object.assign({Accept:"*/*","Content-Type":"application/json","Accept-Language":"zh-CN,zh;q=0.8",platform:options?.platform},options?.headers),this._intercept={config:(p={})=>(p.url=function safeUrlJoin$1(baseUrl,path){return!baseUrl||path.startsWith("http")?path:`${baseUrl.replace(/\/$/,"")}/${path.replace(/^\//,"")}`}(this.baseUrl,p.url),p),success:res=>res,fail:res=>res,complete:res=>{}}}setCommonHeaders=function(key,value){this.headers[key]=value};request=function(options){const _that=this,params=_that._intercept.config(options),header=Object.assign({},_that.headers,params.headers);return new Promise(function(resolve,reject){wx.request({url:params.url,data:params.data,header:header,method:params.method||"GET",timeout:params.timeout,success:res=>{const p=_that._intercept.success(res);resolve(p.data)},fail:res=>{const p=_that._intercept.fail(res);reject(p)},complete:res=>{_that._intercept.complete(res)}})})};sendGet=function(url,data,options){return this.request({url:url,method:"GET",data:data,...options})};sendPost=function(url,data,options){return this.request({url:url,method:"POST",data:data,...options})}}const accountInfo=wx.getAccountInfoSync(),envVersion=accountInfo?.miniProgram?.envVersion||"";function _parseKey(key){return envVersion?`${envVersion}_${key}`:`${key}`}var cacheUtil={setStorageSync(key,data){try{return wx.setStorageSync(_parseKey(key),data),!0}catch(e){return!1}},getStorageSync:key=>wx.getStorageSync(_parseKey(key)),removeStorageSync(key){try{return wx.removeStorageSync(_parseKey(key)),!0}catch(e){return!1}},setStorage:kvObj=>(kvObj.key=_parseKey(kvObj.key),wx.setStorage(kvObj)),removeStorageIfMatch(key,value){return this.getStorageSync(key)!=value||this.removeStorageSync(key)},checkAndRemoveToken(){const tokenExpired=this.getStorageSync("token_expired"),userInfo=this.getStorageSync("userInfo");return!(!(tokenExpired&&userInfo&&userInfo.user_id)||Date.now()>Number(tokenExpired))||(this.removeStorageSync("token"),this.removeStorageSync("token_expired"),!1)}};const initDefaultData={webinarId:"",user:{},watchInitData:{},liveInfo:{},webinarStatus:0,kickMark:"",query_invite_code:"",permissions:{},permissionValue:{},webinarTag:{},screenPosterInfo:{},officicalInfo:{},interactToolStatus:{},productList:[],advDefault:{},inviteCardStatus:{},inviteCardInfo:{},invite_code:"",keywords:{},redPacket:{},pwdRedPacket:{},likeCount:0,noticeInfo:{},signinInfo:{},timerInfo:{},examInfo:{},pushCardInfo:{},customMenu:{},customMenuDetail:{},mallRewardInfo:null,memberLevel:{}};let Store=_createClass(function Store(){_classCallCheck(this,Store),this.state={...initDefaultData},this.callbacks={},this._getByStr=key=>{if(!key)return this.state;const arr=key.split(".");return arr.reduce((prev,cur,index)=>!prev[cur]&&index<arr.length-1?{}:prev[cur],this.state)},this.get=key=>{if(isString(key))return this._getByStr(key);if(isObj(key)){const obj={...key};return Object.keys(obj).forEach(item=>{const func=obj[item];this.callbacks[item]||(this.callbacks[item]=[]),this.callbacks[item].indexOf(func)<0&&this.callbacks[item].push(func),func(this._getByStr(item))}),()=>{Object.keys(obj).forEach(item=>{const func=obj[item],i=this.callbacks[item].indexOf(func);this.callbacks[item].splice(i,1)})}}},this._setByStr=(key,value)=>{try{const arr=key.split(".");arr.reduce((prev,cur,index)=>(index===arr.length-1&&(prev[cur]=value),prev[cur]=void 0===prev[cur]?{}:prev[cur],prev[cur]),this.state)}catch(error){console.error("error",error)}},this._setItem=(key,value)=>{try{if(value!==this._getByStr(key)){const prev=deepCopy(this._getByStr(key));this._setByStr(key,value),(this.callbacks[key]||[]).forEach(func=>{func(this._getByStr(key),prev)})}}catch(error){console.error("error",error)}},this.set=(key,value)=>{if(isString(key)&&this._setItem(key,value),isObj(key)){const obj={...key};Object.keys(obj).forEach(item=>{const value=obj[item];this._setItem(item,value)})}},this.reset=()=>{this.state={}}});class SerializableMap{constructor(entries=[]){this._data={},this._size=0;for(const[key,value]of entries)this.set(key,value)}set(key,value,immediate=!1){const stringKey=String(key);return this._data.hasOwnProperty(stringKey)||this._size++,this._data[stringKey]=value,"function"==typeof value&&immediate&&value(),this}get(key){const stringKey=String(key);return this._data[stringKey]}has(key){const stringKey=String(key);return this._data.hasOwnProperty(stringKey)}delete(key){const stringKey=String(key);return!!this._data.hasOwnProperty(stringKey)&&(delete this._data[stringKey],this._size--,!0)}clear(){this._data={},this._size=0}get size(){return this._size}toJSON(){return this._data}*[Symbol.iterator](){for(const key in this._data)this._data.hasOwnProperty(key)&&(yield[key,this._data[key]])}}let EventEmitter=function(){return _createClass(function EventEmitter(){_classCallCheck(this,EventEmitter),this._events={}},[{key:"on",value:function on(event,listener){return this._events[event]||(this._events[event]=[]),this._events[event].push(listener),this}},{key:"once",value:function once(event,listener){const onceListener=(...args)=>{listener.apply(this,args),this.off(event,onceListener)};return this.on(event,onceListener)}},{key:"off",value:function off(event,listenerToRemove){return this._events[event]?(listenerToRemove?this._events[event]=this._events[event].filter(listener=>listener!==listenerToRemove):delete this._events[event],this):this}},{key:"emit",value:function emit(event,...args){return this._events[event]&&this._events[event].forEach(listener=>{listener.apply(this,args)}),this}},{key:"clearEvents",value:function clearEvents(){this._events={}}}])}();const VHALLYUN_API_LIST_INIT="/sdk/v1/init/start",VHALLYUN_API_LIST_SEND_MESSAGE="/sdk/v2/message/s-send",Type={TYPE_TEXT:"text",TYPE_DISABLE:"disable",TYPE_DISABLE_ALL:"disable_all",TYPE_PERMIT:"permit",TYPE_PERMIT_ALL:"permit_all"},EVENT_TIM_JOIN_GROUP_SUCCESS="onTimJoinGroupSuccess",EVENT_TIM_JOIN_GROUP_FAILED="onTimJoinGroupFailed",EVENT_TIM_KICKED_OUT="onTimKickedOut",EVENT_TIM_NET_STATE_CHANGE="onTimNetStateChange",EVENT_TIM_ERROR="onTimError";var hasRequiredPako_inflate_min,pako_inflate_min$1={exports:{}};const _hasBuffer="function"==typeof Buffer,_TD="function"==typeof TextDecoder?new TextDecoder:void 0,_TE="function"==typeof TextEncoder?new TextEncoder:void 0,b64chs=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),b64tab=(()=>{let tab={};return b64chs.forEach((c,i)=>tab[c]=i),tab})(),b64re=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,_fromCC=String.fromCharCode.bind(String),_U8Afrom="function"==typeof Uint8Array.from?Uint8Array.from.bind(Uint8Array):it=>new Uint8Array(Array.prototype.slice.call(it,0)),_mkUriSafe=src=>src.replace(/=/g,"").replace(/[+\/]/g,m0=>"+"==m0?"-":"_"),_tidyB64=s=>s.replace(/[^A-Za-z0-9\+\/]/g,""),btoaPolyfill=bin=>{let u32,c0,c1,c2,asc="";const pad=bin.length%3;for(let i=0;i<bin.length;){if((c0=bin.charCodeAt(i++))>255||(c1=bin.charCodeAt(i++))>255||(c2=bin.charCodeAt(i++))>255)throw new TypeError("invalid character found");u32=c0<<16|c1<<8|c2,asc+=b64chs[u32>>18&63]+b64chs[u32>>12&63]+b64chs[u32>>6&63]+b64chs[63&u32]}return pad?asc.slice(0,pad-3)+"===".substring(pad):asc},_btoa="function"==typeof btoa?bin=>btoa(bin):_hasBuffer?bin=>Buffer.from(bin,"binary").toString("base64"):btoaPolyfill,_fromUint8Array=_hasBuffer?u8a=>Buffer.from(u8a).toString("base64"):u8a=>{let strs=[];for(let i=0,l=u8a.length;i<l;i+=4096)strs.push(_fromCC.apply(null,u8a.subarray(i,i+4096)));return _btoa(strs.join(""))},cb_utob=c=>{if(c.length<2)return(cc=c.charCodeAt(0))<128?c:cc<2048?_fromCC(192|cc>>>6)+_fromCC(128|63&cc):_fromCC(224|cc>>>12&15)+_fromCC(128|cc>>>6&63)+_fromCC(128|63&cc);var cc=65536+1024*(c.charCodeAt(0)-55296)+(c.charCodeAt(1)-56320);return _fromCC(240|cc>>>18&7)+_fromCC(128|cc>>>12&63)+_fromCC(128|cc>>>6&63)+_fromCC(128|63&cc)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=u=>u.replace(re_utob,cb_utob),_encode=_hasBuffer?s=>Buffer.from(s,"utf8").toString("base64"):_TE?s=>_fromUint8Array(_TE.encode(s)):s=>_btoa(utob(s)),encode=(src,urlsafe=!1)=>urlsafe?_mkUriSafe(_encode(src)):_encode(src),re_btou=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,cb_btou=cccc=>{switch(cccc.length){case 4:var offset=((7&cccc.charCodeAt(0))<<18|(63&cccc.charCodeAt(1))<<12|(63&cccc.charCodeAt(2))<<6|63&cccc.charCodeAt(3))-65536;return _fromCC((offset>>>10)+55296)+_fromCC(56320+(1023&offset));case 3:return _fromCC((15&cccc.charCodeAt(0))<<12|(63&cccc.charCodeAt(1))<<6|63&cccc.charCodeAt(2));default:return _fromCC((31&cccc.charCodeAt(0))<<6|63&cccc.charCodeAt(1))}},btou=b=>b.replace(re_btou,cb_btou),atobPolyfill=asc=>{if(asc=asc.replace(/\s+/g,""),!b64re.test(asc))throw new TypeError("malformed base64.");asc+="==".slice(2-(3&asc.length));let u24,r1,r2,bin="";for(let i=0;i<asc.length;)u24=b64tab[asc.charAt(i++)]<<18|b64tab[asc.charAt(i++)]<<12|(r1=b64tab[asc.charAt(i++)])<<6|(r2=b64tab[asc.charAt(i++)]),bin+=64===r1?_fromCC(u24>>16&255):64===r2?_fromCC(u24>>16&255,u24>>8&255):_fromCC(u24>>16&255,u24>>8&255,255&u24);return bin},_atob="function"==typeof atob?asc=>atob(_tidyB64(asc)):_hasBuffer?asc=>Buffer.from(asc,"base64").toString("binary"):atobPolyfill,_toUint8Array=_hasBuffer?a=>_U8Afrom(Buffer.from(a,"base64")):a=>_U8Afrom(_atob(a).split("").map(c=>c.charCodeAt(0))),toUint8Array=a=>_toUint8Array(_unURI(a)),_decode=_hasBuffer?a=>Buffer.from(a,"base64").toString("utf8"):_TD?a=>_TD.decode(_toUint8Array(a)):a=>btou(_atob(a)),_unURI=a=>_tidyB64(a.replace(/[-_]/g,m0=>"-"==m0?"+":"/")),decode=src=>_decode(_unURI(src)),gBase64_encode=encode,pako_inflate=function requirePako_inflate_min(){return hasRequiredPako_inflate_min||(hasRequiredPako_inflate_min=1,function(e){var t=(e,t,i,n)=>{let a=65535&e,r=e>>>16&65535,o=0;for(;0!==i;){o=i>2e3?2e3:i,i-=o;do{a=a+t[n++]|0,r=r+a|0}while(--o);a%=65521,r%=65521}return a|r<<16};const i=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var n=(e,t,n,a)=>{const r=i,o=a+n;e^=-1;for(let i=a;i<o;i++)e=e>>>8^r[255&(e^t[i])];return-1^e};const a=16209;var r=function(e,t){let i,n,r,o,s,l,d,f,c,h,u,w,b,m,k,_,g,p,v,x,y,E,R,A;const Z=e.state;i=e.next_in,R=e.input,n=i+(e.avail_in-5),r=e.next_out,A=e.output,o=r-(t-e.avail_out),s=r+(e.avail_out-257),l=Z.dmax,d=Z.wsize,f=Z.whave,c=Z.wnext,h=Z.window,u=Z.hold,w=Z.bits,b=Z.lencode,m=Z.distcode,k=(1<<Z.lenbits)-1,_=(1<<Z.distbits)-1;e:do{w<15&&(u+=R[i++]<<w,w+=8,u+=R[i++]<<w,w+=8),g=b[u&k];t:for(;;){if(p=g>>>24,u>>>=p,w-=p,p=g>>>16&255,0===p)A[r++]=65535&g;else{if(!(16&p)){if(!(64&p)){g=b[(65535&g)+(u&(1<<p)-1)];continue t}if(32&p){Z.mode=16191;break e}e.msg="invalid literal/length code",Z.mode=a;break e}v=65535&g,p&=15,p&&(w<p&&(u+=R[i++]<<w,w+=8),v+=u&(1<<p)-1,u>>>=p,w-=p),w<15&&(u+=R[i++]<<w,w+=8,u+=R[i++]<<w,w+=8),g=m[u&_];i:for(;;){if(p=g>>>24,u>>>=p,w-=p,p=g>>>16&255,!(16&p)){if(!(64&p)){g=m[(65535&g)+(u&(1<<p)-1)];continue i}e.msg="invalid distance code",Z.mode=a;break e}if(x=65535&g,p&=15,w<p&&(u+=R[i++]<<w,w+=8,w<p&&(u+=R[i++]<<w,w+=8)),x+=u&(1<<p)-1,x>l){e.msg="invalid distance too far back",Z.mode=a;break e}if(u>>>=p,w-=p,p=r-o,x>p){if(p=x-p,p>f&&Z.sane){e.msg="invalid distance too far back",Z.mode=a;break e}if(y=0,E=h,0===c){if(y+=d-p,p<v){v-=p;do{A[r++]=h[y++]}while(--p);y=r-x,E=A}}else if(c<p){if(y+=d+c-p,p-=c,p<v){v-=p;do{A[r++]=h[y++]}while(--p);if(y=0,c<v){p=c,v-=p;do{A[r++]=h[y++]}while(--p);y=r-x,E=A}}}else if(y+=c-p,p<v){v-=p;do{A[r++]=h[y++]}while(--p);y=r-x,E=A}for(;v>2;)A[r++]=E[y++],A[r++]=E[y++],A[r++]=E[y++],v-=3;v&&(A[r++]=E[y++],v>1&&(A[r++]=E[y++]))}else{y=r-x;do{A[r++]=A[y++],A[r++]=A[y++],A[r++]=A[y++],v-=3}while(v>2);v&&(A[r++]=A[y++],v>1&&(A[r++]=A[y++]))}break}}break}}while(i<n&&r<s);v=w>>3,i-=v,w-=v<<3,u&=(1<<w)-1,e.next_in=i,e.next_out=r,e.avail_in=i<n?n-i+5:5-(i-n),e.avail_out=r<s?s-r+257:257-(r-s),Z.hold=u,Z.bits=w};const o=15,s=new Uint16Array([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]),l=new Uint8Array([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]),d=new Uint16Array([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=new Uint8Array([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]);var c=(e,t,i,n,a,r,c,h)=>{const u=h.bits;let w,b,m,k,_,g,p=0,v=0,x=0,y=0,E=0,R=0,A=0,Z=0,S=0,T=0,O=null;const U=new Uint16Array(16),D=new Uint16Array(16);let I,B,N,C=null;for(p=0;p<=o;p++)U[p]=0;for(v=0;v<n;v++)U[t[i+v]]++;for(E=u,y=o;y>=1&&0===U[y];y--);if(E>y&&(E=y),0===y)return a[r++]=20971520,a[r++]=20971520,h.bits=1,0;for(x=1;x<y&&0===U[x];x++);for(E<x&&(E=x),Z=1,p=1;p<=o;p++)if(Z<<=1,Z-=U[p],Z<0)return-1;if(Z>0&&(0===e||1!==y))return-1;for(D[1]=0,p=1;p<o;p++)D[p+1]=D[p]+U[p];for(v=0;v<n;v++)0!==t[i+v]&&(c[D[t[i+v]]++]=v);if(0===e?(O=C=c,g=20):1===e?(O=s,C=l,g=257):(O=d,C=f,g=0),T=0,v=0,p=x,_=r,R=E,A=0,m=-1,S=1<<E,k=S-1,1===e&&S>852||2===e&&S>592)return 1;for(;;){I=p-A,c[v]+1<g?(B=0,N=c[v]):c[v]>=g?(B=C[c[v]-g],N=O[c[v]-g]):(B=96,N=0),w=1<<p-A,b=1<<R,x=b;do{b-=w,a[_+(T>>A)+b]=I<<24|B<<16|N}while(0!==b);for(w=1<<p-1;T&w;)w>>=1;if(0!==w?(T&=w-1,T+=w):T=0,v++,0==--U[p]){if(p===y)break;p=t[i+c[v]]}if(p>E&&(T&k)!==m){for(0===A&&(A=E),_+=x,R=p-A,Z=1<<R;R+A<y&&(Z-=U[R+A],!(Z<=0));)R++,Z<<=1;if(S+=1<<R,1===e&&S>852||2===e&&S>592)return 1;m=T&k,a[m]=E<<24|R<<16|_-r}}return 0!==T&&(a[_+T]=p-A<<24|64<<16),h.bits=E,0},h={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_MEM_ERROR:-4,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};const{Z_FINISH:u,Z_BLOCK:w,Z_TREES:b,Z_OK:m,Z_STREAM_END:k,Z_NEED_DICT:_,Z_STREAM_ERROR:g,Z_DATA_ERROR:p,Z_MEM_ERROR:v,Z_BUF_ERROR:x,Z_DEFLATED:y}=h,E=16180,R=16190,A=16191,Z=16192,S=16194,T=16199,O=16200,U=16206,D=16209,I=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function B(){this.strm=null,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 Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const N=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<E||t.mode>16211?1:0},C=e=>{if(N(e))return g;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=E,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,m},z=e=>{if(N(e))return g;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,C(e)},F=(e,t)=>{let i;if(N(e))return g;const n=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?g:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,z(e))},L=(e,t)=>{if(!e)return g;const i=new B;e.state=i,i.strm=e,i.window=null,i.mode=E;const n=F(e,t);return n!==m&&(e.state=null),n};let M,H,j=!0;const K=e=>{if(j){M=new Int32Array(512),H=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(c(1,e.lens,0,288,M,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;c(2,e.lens,0,32,H,0,e.work,{bits:5}),j=!1}e.lencode=M,e.lenbits=9,e.distcode=H,e.distbits=5},P=(e,t,i,n)=>{let a;const r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),n>=r.wsize?(r.window.set(t.subarray(i-r.wsize,i),0),r.wnext=0,r.whave=r.wsize):(a=r.wsize-r.wnext,a>n&&(a=n),r.window.set(t.subarray(i-n,i-n+a),r.wnext),(n-=a)?(r.window.set(t.subarray(i-n,i),0),r.wnext=n,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=a))),0};var Y={inflateReset:z,inflateReset2:F,inflateResetKeep:C,inflateInit:e=>L(e,15),inflateInit2:L,inflate:(e,i)=>{let a,o,s,l,d,f,h,B,C,z,F,L,M,H,j,Y,G,X,W,q,J,Q,V=0;const $=new Uint8Array(4);let ee,te;const ie=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(N(e)||!e.output||!e.input&&0!==e.avail_in)return g;a=e.state,a.mode===A&&(a.mode=Z),d=e.next_out,s=e.output,h=e.avail_out,l=e.next_in,o=e.input,f=e.avail_in,B=a.hold,C=a.bits,z=f,F=h,Q=m;e:for(;;)switch(a.mode){case E:if(0===a.wrap){a.mode=Z;break}for(;C<16;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(2&a.wrap&&35615===B){0===a.wbits&&(a.wbits=15),a.check=0,$[0]=255&B,$[1]=B>>>8&255,a.check=n(a.check,$,2,0),B=0,C=0,a.mode=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&B)<<8)+(B>>8))%31){e.msg="incorrect header check",a.mode=D;break}if((15&B)!==y){e.msg="unknown compression method",a.mode=D;break}if(B>>>=4,C-=4,J=8+(15&B),0===a.wbits&&(a.wbits=J),J>15||J>a.wbits){e.msg="invalid window size",a.mode=D;break}a.dmax=1<<a.wbits,a.flags=0,e.adler=a.check=1,a.mode=512&B?16189:A,B=0,C=0;break;case 16181:for(;C<16;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(a.flags=B,(255&a.flags)!==y){e.msg="unknown compression method",a.mode=D;break}if(57344&a.flags){e.msg="unknown header flags set",a.mode=D;break}a.head&&(a.head.text=B>>8&1),512&a.flags&&4&a.wrap&&($[0]=255&B,$[1]=B>>>8&255,a.check=n(a.check,$,2,0)),B=0,C=0,a.mode=16182;case 16182:for(;C<32;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}a.head&&(a.head.time=B),512&a.flags&&4&a.wrap&&($[0]=255&B,$[1]=B>>>8&255,$[2]=B>>>16&255,$[3]=B>>>24&255,a.check=n(a.check,$,4,0)),B=0,C=0,a.mode=16183;case 16183:for(;C<16;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}a.head&&(a.head.xflags=255&B,a.head.os=B>>8),512&a.flags&&4&a.wrap&&($[0]=255&B,$[1]=B>>>8&255,a.check=n(a.check,$,2,0)),B=0,C=0,a.mode=16184;case 16184:if(1024&a.flags){for(;C<16;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}a.length=B,a.head&&(a.head.extra_len=B),512&a.flags&&4&a.wrap&&($[0]=255&B,$[1]=B>>>8&255,a.check=n(a.check,$,2,0)),B=0,C=0}else a.head&&(a.head.extra=null);a.mode=16185;case 16185:if(1024&a.flags&&(L=a.length,L>f&&(L=f),L&&(a.head&&(J=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(o.subarray(l,l+L),J)),512&a.flags&&4&a.wrap&&(a.check=n(a.check,o,L,l)),f-=L,l+=L,a.length-=L),a.length))break e;a.length=0,a.mode=16186;case 16186:if(2048&a.flags){if(0===f)break e;L=0;do{J=o[l+L++],a.head&&J&&a.length<65536&&(a.head.name+=String.fromCharCode(J))}while(J&&L<f);if(512&a.flags&&4&a.wrap&&(a.check=n(a.check,o,L,l)),f-=L,l+=L,J)break e}else a.head&&(a.head.name=null);a.length=0,a.mode=16187;case 16187:if(4096&a.flags){if(0===f)break e;L=0;do{J=o[l+L++],a.head&&J&&a.length<65536&&(a.head.comment+=String.fromCharCode(J))}while(J&&L<f);if(512&a.flags&&4&a.wrap&&(a.check=n(a.check,o,L,l)),f-=L,l+=L,J)break e}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;C<16;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(4&a.wrap&&B!==(65535&a.check)){e.msg="header crc mismatch",a.mode=D;break}B=0,C=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),e.adler=a.check=0,a.mode=A;break;case 16189:for(;C<32;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}e.adler=a.check=I(B),B=0,C=0,a.mode=R;case R:if(0===a.havedict)return e.next_out=d,e.avail_out=h,e.next_in=l,e.avail_in=f,a.hold=B,a.bits=C,_;e.adler=a.check=1,a.mode=A;case A:if(i===w||i===b)break e;case Z:if(a.last){B>>>=7&C,C-=7&C,a.mode=U;break}for(;C<3;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}switch(a.last=1&B,B>>>=1,C-=1,3&B){case 0:a.mode=16193;break;case 1:if(K(a),a.mode=T,i===b){B>>>=2,C-=2;break e}break;case 2:a.mode=16196;break;case 3:e.msg="invalid block type",a.mode=D}B>>>=2,C-=2;break;case 16193:for(B>>>=7&C,C-=7&C;C<32;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if((65535&B)!=(B>>>16^65535)){e.msg="invalid stored block lengths",a.mode=D;break}if(a.length=65535&B,B=0,C=0,a.mode=S,i===b)break e;case S:a.mode=16195;case 16195:if(L=a.length,L){if(L>f&&(L=f),L>h&&(L=h),0===L)break e;s.set(o.subarray(l,l+L),d),f-=L,l+=L,h-=L,d+=L,a.length-=L;break}a.mode=A;break;case 16196:for(;C<14;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(a.nlen=257+(31&B),B>>>=5,C-=5,a.ndist=1+(31&B),B>>>=5,C-=5,a.ncode=4+(15&B),B>>>=4,C-=4,a.nlen>286||a.ndist>30){e.msg="too many length or distance symbols",a.mode=D;break}a.have=0,a.mode=16197;case 16197:for(;a.have<a.ncode;){for(;C<3;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}a.lens[ie[a.have++]]=7&B,B>>>=3,C-=3}for(;a.have<19;)a.lens[ie[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,ee={bits:a.lenbits},Q=c(0,a.lens,0,19,a.lencode,0,a.work,ee),a.lenbits=ee.bits,Q){e.msg="invalid code lengths set",a.mode=D;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;V=a.lencode[B&(1<<a.lenbits)-1],j=V>>>24,Y=V>>>16&255,G=65535&V,!(j<=C);){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(G<16)B>>>=j,C-=j,a.lens[a.have++]=G;else{if(16===G){for(te=j+2;C<te;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(B>>>=j,C-=j,0===a.have){e.msg="invalid bit length repeat",a.mode=D;break}J=a.lens[a.have-1],L=3+(3&B),B>>>=2,C-=2}else if(17===G){for(te=j+3;C<te;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}B>>>=j,C-=j,J=0,L=3+(7&B),B>>>=3,C-=3}else{for(te=j+7;C<te;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}B>>>=j,C-=j,J=0,L=11+(127&B),B>>>=7,C-=7}if(a.have+L>a.nlen+a.ndist){e.msg="invalid bit length repeat",a.mode=D;break}for(;L--;)a.lens[a.have++]=J}}if(a.mode===D)break;if(0===a.lens[256]){e.msg="invalid code -- missing end-of-block",a.mode=D;break}if(a.lenbits=9,ee={bits:a.lenbits},Q=c(1,a.lens,0,a.nlen,a.lencode,0,a.work,ee),a.lenbits=ee.bits,Q){e.msg="invalid literal/lengths set",a.mode=D;break}if(a.distbits=6,a.distcode=a.distdyn,ee={bits:a.distbits},Q=c(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,ee),a.distbits=ee.bits,Q){e.msg="invalid distances set",a.mode=D;break}if(a.mode=T,i===b)break e;case T:a.mode=O;case O:if(f>=6&&h>=258){e.next_out=d,e.avail_out=h,e.next_in=l,e.avail_in=f,a.hold=B,a.bits=C,r(e,F),d=e.next_out,s=e.output,h=e.avail_out,l=e.next_in,o=e.input,f=e.avail_in,B=a.hold,C=a.bits,a.mode===A&&(a.back=-1);break}for(a.back=0;V=a.lencode[B&(1<<a.lenbits)-1],j=V>>>24,Y=V>>>16&255,G=65535&V,!(j<=C);){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(Y&&!(240&Y)){for(X=j,W=Y,q=G;V=a.lencode[q+((B&(1<<X+W)-1)>>X)],j=V>>>24,Y=V>>>16&255,G=65535&V,!(X+j<=C);){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}B>>>=X,C-=X,a.back+=X}if(B>>>=j,C-=j,a.back+=j,a.length=G,0===Y){a.mode=16205;break}if(32&Y){a.back=-1,a.mode=A;break}if(64&Y){e.msg="invalid literal/length code",a.mode=D;break}a.extra=15&Y,a.mode=16201;case 16201:if(a.extra){for(te=a.extra;C<te;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}a.length+=B&(1<<a.extra)-1,B>>>=a.extra,C-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=16202;case 16202:for(;V=a.distcode[B&(1<<a.distbits)-1],j=V>>>24,Y=V>>>16&255,G=65535&V,!(j<=C);){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(!(240&Y)){for(X=j,W=Y,q=G;V=a.distcode[q+((B&(1<<X+W)-1)>>X)],j=V>>>24,Y=V>>>16&255,G=65535&V,!(X+j<=C);){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}B>>>=X,C-=X,a.back+=X}if(B>>>=j,C-=j,a.back+=j,64&Y){e.msg="invalid distance code",a.mode=D;break}a.offset=G,a.extra=15&Y,a.mode=16203;case 16203:if(a.extra){for(te=a.extra;C<te;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}a.offset+=B&(1<<a.extra)-1,B>>>=a.extra,C-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){e.msg="invalid distance too far back",a.mode=D;break}a.mode=16204;case 16204:if(0===h)break e;if(L=F-h,a.offset>L){if(L=a.offset-L,L>a.whave&&a.sane){e.msg="invalid distance too far back",a.mode=D;break}L>a.wnext?(L-=a.wnext,M=a.wsize-L):M=a.wnext-L,L>a.length&&(L=a.length),H=a.window}else H=s,M=d-a.offset,L=a.length;L>h&&(L=h),h-=L,a.length-=L;do{s[d++]=H[M++]}while(--L);0===a.length&&(a.mode=O);break;case 16205:if(0===h)break e;s[d++]=a.length,h--,a.mode=O;break;case U:if(a.wrap){for(;C<32;){if(0===f)break e;f--,B|=o[l++]<<C,C+=8}if(F-=h,e.total_out+=F,a.total+=F,4&a.wrap&&F&&(e.adler=a.check=a.flags?n(a.check,s,F,d-F):t(a.check,s,F,d-F)),F=h,4&a.wrap&&(a.flags?B:I(B))!==a.check){e.msg="incorrect data check",a.mode=D;break}B=0,C=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;C<32;){if(0===f)break e;f--,B+=o[l++]<<C,C+=8}if(4&a.wrap&&B!==(4294967295&a.total)){e.msg="incorrect length check",a.mode=D;break}B=0,C=0}a.mode=16208;case 16208:Q=k;break e;case D:Q=p;break e;case 16210:return v;default:return g}return e.next_out=d,e.avail_out=h,e.next_in=l,e.avail_in=f,a.hold=B,a.bits=C,(a.wsize||F!==e.avail_out&&a.mode<D&&(a.mode<U||i!==u))&&P(e,e.output,e.next_out,F-e.avail_out),z-=e.avail_in,F-=e.avail_out,e.total_in+=z,e.total_out+=F,a.total+=F,4&a.wrap&&F&&(e.adler=a.check=a.flags?n(a.check,s,F,e.next_out-F):t(a.check,s,F,e.next_out-F)),e.data_type=a.bits+(a.last?64:0)+(a.mode===A?128:0)+(a.mode===T||a.mode===S?256:0),(0===z&&0===F||i===u)&&Q===m&&(Q=x),Q},inflateEnd:e=>{if(N(e))return g;let t=e.state;return t.window&&(t.window=null),e.state=null,m},inflateGetHeader:(e,t)=>{if(N(e))return g;const i=e.state;return 2&i.wrap?(i.head=t,t.done=!1,m):g},inflateSetDictionary:(e,i)=>{const n=i.length;let a,r,o;return N(e)?g:(a=e.state,0!==a.wrap&&a.mode!==R?g:a.mode===R&&(r=1,r=t(r,i,n,0),r!==a.check)?p:(o=P(e,i,n,n),o?(a.mode=16210,v):(a.havedict=1,m)))},inflateInfo:"pako inflate (from Nodeca project)"};const G=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var X=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)G(i,t)&&(e[t]=i[t])}}return e},W=e=>{let t=0;for(let i=0,n=e.length;i<n;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,n=0,a=e.length;t<a;t++){let a=e[t];i.set(a,n),n+=a.length}return i};let q=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){q=!1}const J=new Uint8Array(256);for(let e=0;e<256;e++)J[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;J[254]=J[254]=1;var Q=e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,n,a,r,o=e.length,s=0;for(a=0;a<o;a++)i=e.charCodeAt(a),55296==(64512&i)&&a+1<o&&(n=e.charCodeAt(a+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),a++)),s+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(s),r=0,a=0;r<s;a++)i=e.charCodeAt(a),55296==(64512&i)&&a+1<o&&(n=e.charCodeAt(a+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),a++)),i<128?t[r++]=i:i<2048?(t[r++]=192|i>>>6,t[r++]=128|63&i):i<65536?(t[r++]=224|i>>>12,t[r++]=128|i>>>6&63,t[r++]=128|63&i):(t[r++]=240|i>>>18,t[r++]=128|i>>>12&63,t[r++]=128|i>>>6&63,t[r++]=128|63&i);return t},V=(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let n,a;const r=new Array(2*i);for(a=0,n=0;n<i;){let t=e[n++];if(t<128){r[a++]=t;continue}let o=J[t];if(o>4)r[a++]=65533,n+=o-1;else{for(t&=2===o?31:3===o?15:7;o>1&&n<i;)t=t<<6|63&e[n++],o--;o>1?r[a++]=65533:t<65536?r[a++]=t:(t-=65536,r[a++]=55296|t>>10&1023,r[a++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&q)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let n=0;n<t;n++)i+=String.fromCharCode(e[n]);return i})(r,a)},$=(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+J[e[i]]>t?i:t},ee={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"},te=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},ie=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};const ne=Object.prototype.toString,{Z_NO_FLUSH:ae,Z_FINISH:re,Z_OK:oe,Z_STREAM_END:se,Z_NEED_DICT:le,Z_STREAM_ERROR:de,Z_DATA_ERROR:fe,Z_MEM_ERROR:ce}=h;function he(e){this.options=X({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&!(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new te,this.strm.avail_out=0;let i=Y.inflateInit2(this.strm,t.windowBits);if(i!==oe)throw new Error(ee[i]);if(this.header=new ie,Y.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Q(t.dictionary):"[object ArrayBuffer]"===ne.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Y.inflateSetDictionary(this.strm,t.dictionary),i!==oe)))throw new Error(ee[i])}function ue(e,t){const i=new he(t);if(i.push(e),i.err)throw i.msg||ee[i.err];return i.result}he.prototype.push=function(e,t){const i=this.strm,n=this.options.chunkSize,a=this.options.dictionary;let r,o,s;if(this.ended)return!1;for(o=t===~~t?t:!0===t?re:ae,"[object ArrayBuffer]"===ne.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),r=Y.inflate(i,o),r===le&&a&&(r=Y.inflateSetDictionary(i,a),r===oe?r=Y.inflate(i,o):r===fe&&(r=le));i.avail_in>0&&r===se&&i.state.wrap>0&&0!==e[i.next_in];)Y.inflateReset(i),r=Y.inflate(i,o);switch(r){case de:case fe:case le:case ce:return this.onEnd(r),this.ended=!0,!1}if(s=i.avail_out,i.next_out&&(0===i.avail_out||r===se))if("string"===this.options.to){let e=$(i.output,i.next_out),t=i.next_out-e,a=V(i.output,e);i.next_out=t,i.avail_out=n-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(a)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(r!==oe||0!==s){if(r===se)return r=Y.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},he.prototype.onData=function(e){this.chunks.push(e)},he.prototype.onEnd=function(e){e===oe&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=W(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var we=he,be=ue,me=function(e,t){return(t=t||{}).raw=!0,ue(e,t)},ke=ue,_e=h,ge={Inflate:we,inflate:be,inflateRaw:me,ungzip:ke,constants:_e};e.Inflate=we,e.constants=_e,e.default=ge,e.inflate=be,e.inflateRaw=me,e.ungzip=ke,Object.defineProperty(e,"__esModule",{value:!0})}(pako_inflate_min$1.exports)),pako_inflate_min$1.exports}();const pageSession=function nanoid(size=20){let id="",i=size;for(;i--;)id+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return id}(20);const safeJsonParse=function(val){const type=Object.prototype.toString.call(val);if(["[object Array]","[object Object]","[object Null]"].includes(type))return val;try{return JSON.parse(val)}catch(ex){return null}};function safeUrlJoin(baseUrl,path){return`${baseUrl.replace(/\/$/,"")}/${path.replace(/^\//,"")}`}var hasRequiredJsencrypt_min,jsencrypt_min={exports:{}};var hasRequiredCryptoJs4_1_1_min,cryptoJs4_1_1_min$1={exports:{}},require$$0=getDefaultExportFromNamespaceIfNotNamed(Object.freeze({__proto__:null,default:{}}));var hasRequiredJsbn,hasRequiredMiniprogram_dist,miniprogram_dist={exports:{}},jsbn$1={exports:{}},jsbn=jsbn$1.exports;function requireJsbn(){return hasRequiredJsbn||(hasRequiredJsbn=1,function(module){(function(){var dbits;function BigInteger(a,b,c){null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function nbi(){return new BigInteger(null)}var inBrowser="undefined"!=typeof navigator;inBrowser&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=function am2(i,x,w,j,c,n){for(var xl=32767&x,xh=x>>15;--n>=0;){var l=32767&this[i],h=this[i++]>>15,m=xh*l+h*xl;c=((l=xl*l+((32767&m)<<15)+w[j]+(1073741823&c))>>>30)+(m>>>15)+xh*h+(c>>>30),w[j++]=1073741823&l}return c},dbits=30):inBrowser&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=function am1(i,x,w,j,c,n){for(;--n>=0;){var v=x*this[i++]+w[j]+c;c=Math.floor(v/67108864),w[j++]=67108863&v}return c},dbits=26):(BigInteger.prototype.am=function am3(i,x,w,j,c,n){for(var xl=16383&x,xh=x>>14;--n>=0;){var l=16383&this[i],h=this[i++]>>14,m=xh*l+h*xl;c=((l=xl*l+((16383&m)<<14)+w[j]+c)>>28)+(m>>14)+xh*h,w[j++]=268435455&l}return c},dbits=28),BigInteger.prototype.DB=dbits,BigInteger.prototype.DM=(1<<dbits)-1,BigInteger.prototype.DV=1<<dbits;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=52-dbits,BigInteger.prototype.F2=2*dbits-52;var rr,vv,BI_RC=new Array;for(rr="0".charCodeAt(0),vv=0;vv<=9;++vv)BI_RC[rr++]=vv;for(rr="a".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;for(rr="A".charCodeAt(0),vv=10;vv<36;++vv)BI_RC[rr++]=vv;function int2char(n){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(n)}function intAt(s,i){var c=BI_RC[s.charCodeAt(i)];return null==c?-1:c}function nbv(i){var r=nbi();return r.fromInt(i),r}function nbits(x){var t,r=1;return 0!=(t=x>>>16)&&(x=t,r+=16),0!=(t=x>>8)&&(x=t,r+=8),0!=(t=x>>4)&&(x=t,r+=4),0!=(t=x>>2)&&(x=t,r+=2),0!=(t=x>>1)&&(x=t,r+=1),r}function Classic(m){this.m=m}function Montgomery(m){this.m=m,this.mp=m.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<m.DB-15)-1,this.mt2=2*m.t}function op_and(x,y){return x&y}function op_or(x,y){return x|y}function op_xor(x,y){return x^y}function op_andnot(x,y){return x&~y}function lbit(x){if(0==x)return-1;var r=0;return 65535&x||(x>>=16,r+=16),255&x||(x>>=8,r+=8),15&x||(x>>=4,r+=4),3&x||(x>>=2,r+=2),1&x||++r,r}function cbit(x){for(var r=0;0!=x;)x&=x-1,++r;return r}function NullExp(){}function nNop(x){return x}function Barrett(m){this.r2=nbi(),this.q3=nbi(),BigInteger.ONE.dlShiftTo(2*m.t,this.r2),this.mu=this.r2.divide(m),this.m=m}Classic.prototype.convert=function cConvert(x){return x.s<0||x.compareTo(this.m)>=0?x.mod(this.m):x},Classic.prototype.revert=function cRevert(x){return x},Classic.prototype.reduce=function cReduce(x){x.divRemTo(this.m,null,x)},Classic.prototype.mulTo=function cMulTo(x,y,r){x.multiplyTo(y,r),this.reduce(r)},Classic.prototype.sqrTo=function cSqrTo(x,r){x.squareTo(r),this.reduce(r)},Montgomery.prototype.convert=function montConvert(x){var r=nbi();return x.abs().dlShiftTo(this.m.t,r),r.divRemTo(this.m,null,r),x.s<0&&r.compareTo(BigInteger.ZERO)>0&&this.m.subTo(r,r),r},Montgomery.prototype.revert=function montRevert(x){var r=nbi();return x.copyTo(r),this.reduce(r),r},Montgomery.prototype.reduce=function montReduce(x){for(;x.t<=this.mt2;)x[x.t++]=0;for(var i=0;i<this.m.t;++i){var j=32767&x[i],u0=j*this.mpl+((j*this.mph+(x[i]>>15)*this.mpl&this.um)<<15)&x.DM;for(x[j=i+this.m.t]+=this.m.am(0,u0,x,i,0,this.m.t);x[j]>=x.DV;)x[j]-=x.DV,x[++j]++}x.clamp(),x.drShiftTo(this.m.t,x),x.compareTo(this.m)>=0&&x.subTo(this.m,x)},Montgomery.prototype.mulTo=function montMulTo(x,y,r){x.multiplyTo(y,r),this.reduce(r)},Montgomery.prototype.sqrTo=function montSqrTo(x,r){x.squareTo(r),this.reduce(r)},BigInteger.prototype.copyTo=function bnpCopyTo(r){for(var i=this.t-1;i>=0;--i)r[i]=this[i];r.t=this.t,r.s=this.s},BigInteger.prototype.fromInt=function bnpFromInt(x){this.t=1,this.s=x<0?-1:0,x>0?this[0]=x:x<-1?this[0]=x+this.DV:this.t=0},BigInteger.prototype.fromString=function bnpFromString(s,b){var k;if(16==b)k=4;else if(8==b)k=3;else if(256==b)k=8;else if(2==b)k=1;else if(32==b)k=5;else{if(4!=b)return void this.fromRadix(s,b);k=2}this.t=0,this.s=0;for(var i=s.length,mi=!1,sh=0;--i>=0;){var x=8==k?255&s[i]:intAt(s,i);x<0?"-"==s.charAt(i)&&(mi=!0):(mi=!1,0==sh?this[this.t++]=x:sh+k>this.DB?(this[this.t-1]|=(x&(1<<this.DB-sh)-1)<<sh,this[this.t++]=x>>this.DB-sh):this[this.t-1]|=x<<sh,(sh+=k)>=this.DB&&(sh-=this.DB))}8==k&&128&s[0]&&(this.s=-1,sh>0&&(this[this.t-1]|=(1<<this.DB-sh)-1<<sh)),this.clamp(),mi&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.clamp=function bnpClamp(){for(var c=this.s&this.DM;this.t>0&&this[this.t-1]==c;)--this.t},BigInteger.prototype.dlShiftTo=function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i)r[i+n]=this[i];for(i=n-1;i>=0;--i)r[i]=0;r.t=this.t+n,r.s=this.s},BigInteger.prototype.drShiftTo=function bnpDRShiftTo(n,r){for(var i=n;i<this.t;++i)r[i-n]=this[i];r.t=Math.max(this.t-n,0),r.s=this.s},BigInteger.prototype.lShiftTo=function bnpLShiftTo(n,r){var i,bs=n%this.DB,cbs=this.DB-bs,bm=(1<<cbs)-1,ds=Math.floor(n/this.DB),c=this.s<<bs&this.DM;for(i=this.t-1;i>=0;--i)r[i+ds+1]=this[i]>>cbs|c,c=(this[i]&bm)<<bs;for(i=ds-1;i>=0;--i)r[i]=0;r[ds]=c,r.t=this.t+ds+1,r.s=this.s,r.clamp()},BigInteger.prototype.rShiftTo=function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t)r.t=0;else{var bs=n%this.DB,cbs=this.DB-bs,bm=(1<<bs)-1;r[0]=this[ds]>>bs;for(var i=ds+1;i<this.t;++i)r[i-ds-1]|=(this[i]&bm)<<cbs,r[i-ds]=this[i]>>bs;bs>0&&(r[this.t-ds-1]|=(this.s&bm)<<cbs),r.t=this.t-ds,r.clamp()}},BigInteger.prototype.subTo=function bnpSubTo(a,r){for(var i=0,c=0,m=Math.min(a.t,this.t);i<m;)c+=this[i]-a[i],r[i++]=c&this.DM,c>>=this.DB;if(a.t<this.t){for(c-=a.s;i<this.t;)c+=this[i],r[i++]=c&this.DM,c>>=this.DB;c+=this.s}else{for(c+=this.s;i<a.t;)c-=a[i],r[i++]=c&this.DM,c>>=this.DB;c-=a.s}r.s=c<0?-1:0,c<-1?r[i++]=this.DV+c:c>0&&(r[i++]=c),r.t=i,r.clamp()},BigInteger.prototype.multiplyTo=function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs(),i=x.t;for(r.t=i+y.t;--i>=0;)r[i]=0;for(i=0;i<y.t;++i)r[i+x.t]=x.am(0,y[i],r,i,0,x.t);r.s=0,r.clamp(),this.s!=a.s&&BigInteger.ZERO.subTo(r,r)},BigInteger.prototype.squareTo=function bnpSquareTo(r){for(var x=this.abs(),i=r.t=2*x.t;--i>=0;)r[i]=0;for(i=0;i<x.t-1;++i){var c=x.am(i,x[i],r,2*i,0,1);(r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1))>=x.DV&&(r[i+x.t]-=x.DV,r[i+x.t+1]=1)}r.t>0&&(r[r.t-1]+=x.am(i,x[i],r,2*i,0,1)),r.s=0,r.clamp()},BigInteger.prototype.divRemTo=function bnpDivRemTo(m,q,r){var pm=m.abs();if(!(pm.t<=0)){var pt=this.abs();if(pt.t<pm.t)return null!=q&&q.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=nbi());var y=nbi(),ts=this.s,ms=m.s,nsh=this.DB-nbits(pm[pm.t-1]);nsh>0?(pm.lShiftTo(nsh,y),pt.lShiftTo(nsh,r)):(pm.copyTo(y),pt.copyTo(r));var ys=y.t,y0=y[ys-1];if(0!=y0){var yt=y0*(1<<this.F1)+(ys>1?y[ys-2]>>this.F2:0),d1=this.FV/yt,d2=(1<<this.F1)/yt,e=1<<this.F2,i=r.t,j=i-ys,t=null==q?nbi():q;for(y.dlShiftTo(j,t),r.compareTo(t)>=0&&(r[r.t++]=1,r.subTo(t,r)),BigInteger.ONE.dlShiftTo(ys,t),t.subTo(y,y);y.t<ys;)y[y.t++]=0;for(;--j>=0;){var qd=r[--i]==y0?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);if((r[i]+=y.am(0,qd,r,j,0,ys))<qd)for(y.dlShiftTo(j,t),r.subTo(t,r);r[i]<--qd;)r.subTo(t,r)}null!=q&&(r.drShiftTo(ys,q),ts!=ms&&BigInteger.ZERO.subTo(q,q)),r.t=ys,r.clamp(),nsh>0&&r.rShiftTo(nsh,r),ts<0&&BigInteger.ZERO.subTo(r,r)}}},BigInteger.prototype.invDigit=function bnpInvDigit(){if(this.t<1)return 0;var x=this[0];if(!(1&x))return 0;var y=3&x;return(y=(y=(y=(y=y*(2-(15&x)*y)&15)*(2-(255&x)*y)&255)*(2-((65535&x)*y&65535))&65535)*(2-x*y%this.DV)%this.DV)>0?this.DV-y:-y},BigInteger.prototype.isEven=function bnpIsEven(){return 0==(this.t>0?1&this[0]:this.s)},BigInteger.prototype.exp=function bnpExp(e,z){if(e>4294967295||e<1)return BigInteger.ONE;var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;for(g.copyTo(r);--i>=0;)if(z.sqrTo(r,r2),(e&1<<i)>0)z.mulTo(r2,g,r);else{var t=r;r=r2,r2=t}return z.revert(r)},BigInteger.prototype.toString=function bnToString(b){if(this.s<0)return"-"+this.negate().toString(b);var k;if(16==b)k=4;else if(8==b)k=3;else if(2==b)k=1;else if(32==b)k=5;else{if(4!=b)return this.toRadix(b);k=2}var d,km=(1<<k)-1,m=!1,r="",i=this.t,p=this.DB-i*this.DB%k;if(i-- >0)for(p<this.DB&&(d=this[i]>>p)>0&&(m=!0,r=int2char(d));i>=0;)p<k?(d=(this[i]&(1<<p)-1)<<k-p,d|=this[--i]>>(p+=this.DB-k)):(d=this[i]>>(p-=k)&km,p<=0&&(p+=this.DB,--i)),d>0&&(m=!0),m&&(r+=int2char(d));return m?r:"0"},BigInteger.prototype.negate=function bnNegate(){var r=nbi();return BigInteger.ZERO.subTo(this,r),r},BigInteger.prototype.abs=function bnAbs(){return this.s<0?this.negate():this},BigInteger.prototype.compareTo=function bnCompareTo(a){var r=this.s-a.s;if(0!=r)return r;var i=this.t;if(0!=(r=i-a.t))return this.s<0?-r:r;for(;--i>=0;)if(0!=(r=this[i]-a[i]))return r;return 0},BigInteger.prototype.bitLength=function bnBitLength(){return this.t<=0?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)},BigInteger.prototype.mod=function bnMod(a){var r=nbi();return this.abs().divRemTo(a,null,r),this.s<0&&r.compareTo(BigInteger.ZERO)>0&&a.subTo(r,r),r},BigInteger.prototype.modPowInt=function bnModPowInt(e,m){var z;return z=e<256||m.isEven()?new Classic(m):new Montgomery(m),this.exp(e,z)},BigInteger.ZERO=nbv(0),BigInteger.ONE=nbv(1),NullExp.prototype.convert=nNop,NullExp.prototype.revert=nNop,NullExp.prototype.mulTo=function nMulTo(x,y,r){x.multiplyTo(y,r)},NullExp.prototype.sqrTo=function nSqrTo(x,r){x.squareTo(r)},Barrett.prototype.convert=function barrettConvert(x){if(x.s<0||x.t>2*this.m.t)return x.mod(this.m);if(x.compareTo(this.m)<0)return x;var r=nbi();return x.copyTo(r),this.reduce(r),r},Barrett.prototype.revert=function barrettRevert(x){return x},Barrett.prototype.reduce=function barrettReduce(x){for(x.drShiftTo(this.m.t-1,this.r2),x.t>this.m.t+1&&(x.t=this.m.t+1,x.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);x.compareTo(this.r2)<0;)x.dAddOffset(1,this.m.t+1);for(x.subTo(this.r2,x);x.compareTo(this.m)>=0;)x.subTo(this.m,x)},Barrett.prototype.mulTo=function barrettMulTo(x,y,r){x.multiplyTo(y,r),this.reduce(r)},Barrett.prototype.sqrTo=function barrettSqrTo(x,r){x.squareTo(r),this.reduce(r)};var rng_state,rng_pool,rng_pptr,lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=(1<<26)/lowprimes[lowprimes.length-1];function rng_seed_time(){!function rng_seed_int(x){rng_pool[rng_pptr++]^=255&x,rng_pool[rng_pptr++]^=x>>8&255,rng_pool[rng_pptr++]^=x>>16&255,rng_pool[rng_pptr++]^=x>>24&255,rng_pptr>=rng_psize&&(rng_pptr-=rng_psize)}((new Date).getTime())}if(BigInteger.prototype.chunkSize=function bnpChunkSize(r){return Math.floor(Math.LN2*this.DB/Math.log(r))},BigInteger.prototype.toRadix=function bnpToRadix(b){if(null==b&&(b=10),0==this.signum()||b<2||b>36)return"0";var cs=this.chunkSize(b),a=Math.pow(b,cs),d=nbv(a),y=nbi(),z=nbi(),r="";for(this.divRemTo(d,y,z);y.signum()>0;)r=(a+z.intValue()).toString(b).substr(1)+r,y.divRemTo(d,y,z);return z.intValue().toString(b)+r},BigInteger.prototype.fromRadix=function bnpFromRadix(s,b){this.fromInt(0),null==b&&(b=10);for(var cs=this.chunkSize(b),d=Math.pow(b,cs),mi=!1,j=0,w=0,i=0;i<s.length;++i){var x=intAt(s,i);x<0?"-"==s.charAt(i)&&0==this.signum()&&(mi=!0):(w=b*w+x,++j>=cs&&(this.dMultiply(d),this.dAddOffset(w,0),j=0,w=0))}j>0&&(this.dMultiply(Math.pow(b,j)),this.dAddOffset(w,0)),mi&&BigInteger.ZERO.subTo(this,this)},BigInteger.prototype.fromNumber=function bnpFromNumber(a,b,c){if("number"==typeof b)if(a<2)this.fromInt(1);else for(this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this);else{var x=new Array,t=7&a;x.length=1+(a>>3),b.nextBytes(x),t>0?x[0]&=(1<<t)-1:x[0]=0,this.fromString(x,256)}},BigInteger.prototype.bitwiseTo=function bnpBitwiseTo(a,op,r){var i,f,m=Math.min(a.t,this.t);for(i=0;i<m;++i)r[i]=op(this[i],a[i]);if(a.t<this.t){for(f=a.s&this.DM,i=m;i<this.t;++i)r[i]=op(this[i],f);r.t=this.t}else{for(f=this.s&this.DM,i=m;i<a.t;++i)r[i]=op(f,a[i]);r.t=a.t}r.s=op(this.s,a.s),r.clamp()},BigInteger.prototype.changeBit=function bnpChangeBit(n,op){var r=BigInteger.ONE.shiftLeft(n);return this.bitwiseTo(r,op,r),r},BigInteger.prototype.addTo=function bnpAddTo(a,r){for(var i=0,c=0,m=Math.min(a.t,this.t);i<m;)c+=this[i]+a[i],r[i++]=c&this.DM,c>>=this.DB;if(a.t<this.t){for(c+=a.s;i<this.t;)c+=this[i],r[i++]=c&this.DM,c>>=this.DB;c+=this.s}else{for(c+=this.s;i<a.t;)c+=a[i],r[i++]=c&this.DM,c>>=this.DB;c+=a.s}r.s=c<0?-1:0,c>0?r[i++]=c:c<-1&&(r[i++]=this.DV+c),r.t=i,r.clamp()},BigInteger.prototype.dMultiply=function bnpDMultiply(n){this[this.t]=this.am(0,n-1,this,0,0,this.t),++this.t,this.clamp()},BigInteger.prototype.dAddOffset=function bnpDAddOffset(n,w){if(0!=n){for(;this.t<=w;)this[this.t++]=0;for(this[w]+=n;this[w]>=this.DV;)this[w]-=this.DV,++w>=this.t&&(this[this.t++]=0),++this[w]}},BigInteger.prototype.multiplyLowerTo=function bnpMultiplyLowerTo(a,n,r){var j,i=Math.min(this.t+a.t,n);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(j=r.t-this.t;i<j;++i)r[i+this.t]=this.am(0,a[i],r,i,0,this.t);for(j=Math.min(a.t,n);i<j;++i)this.am(0,a[i],r,i,0,n-i);r.clamp()},BigInteger.prototype.multiplyUpperTo=function bnpMultiplyUpperTo(a,n,r){--n;var i=r.t=this.t+a.t-n;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(n-this.t,0);i<a.t;++i)r[this.t+i-n]=this.am(n-i,a[i],r,0,0,this.t+i-n);r.clamp(),r.drShiftTo(1,r)},BigInteger.prototype.modInt=function bnpModInt(n){if(n<=0)return 0;var d=this.DV%n,r=this.s<0?n-1:0;if(this.t>0)if(0==d)r=this[0]%n;else for(var i=this.t-1;i>=0;--i)r=(d*r+this[i])%n;return r},BigInteger.prototype.millerRabin=function bnpMillerRabin(t){var n1=this.subtract(BigInteger.ONE),k=n1.getLowestSetBit();if(k<=0)return!1;var r=n1.shiftRight(k);(t=t+1>>1)>lowprimes.length&&(t=lowprimes.length);for(var a=nbi(),i=0;i<t;++i){a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);var y=a.modPow(r,this);if(0!=y.compareTo(BigInteger.ONE)&&0!=y.compareTo(n1)){for(var j=1;j++<k&&0!=y.compareTo(n1);)if(0==(y=y.modPowInt(2,this)).compareTo(BigInteger.ONE))return!1;if(0!=y.compareTo(n1))return!1}}return!0},BigInteger.prototype.clone=function bnClone(){var r=nbi();return this.copyTo(r),r},BigInteger.prototype.intValue=function bnIntValue(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},BigInteger.prototype.byteValue=function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>24},BigInteger.prototype.shortValue=function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16},BigInteger.prototype.signum=function bnSigNum(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},BigInteger.prototype.toByteArray=function bnToByteArray(){var i=this.t,r=new Array;r[0]=this.s;var d,p=this.DB-i*this.DB%8,k=0;if(i-- >0)for(p<this.DB&&(d=this[i]>>p)!=(this.s&this.DM)>>p&&(r[k++]=d|this.s<<this.DB-p);i>=0;)p<8?(d=(this[i]&(1<<p)-1)<<8-p,d|=this[--i]>>(p+=this.DB-8)):(d=this[i]>>(p-=8)&255,p<=0&&(p+=this.DB,--i)),128&d&&(d|=-256),0==k&&(128&this.s)!=(128&d)&&++k,(k>0||d!=this.s)&&(r[k++]=d);return r},BigInteger.prototype.equals=function bnEquals(a){return 0==this.compareTo(a)},BigInteger.prototype.min=function bnMin(a){return this.compareTo(a)<0?this:a},BigInteger.prototype.max=function bnMax(a){return this.compareTo(a)>0?this:a},BigInteger.prototype.and=function bnAnd(a){var r=nbi();return this.bitwiseTo(a,op_and,r),r},BigInteger.prototype.or=function bnOr(a){var r=nbi();return this.bitwiseTo(a,op_or,r),r},BigInteger.prototype.xor=function bnXor(a){var r=nbi();return this.bitwiseTo(a,op_xor,r),r},BigInteger.prototype.andNot=function bnAndNot(a){var r=nbi();return this.bitwiseTo(a,op_andnot,r),r},BigInteger.prototype.not=function bnNot(){for(var r=nbi(),i=0;i<this.t;++i)r[i]=this.DM&~this[i];return r.t=this.t,r.s=~this.s,r},BigInteger.prototype.shiftLeft=function bnShiftLeft(n){var r=nbi();return n<0?this.rShiftTo(-n,r):this.lShiftTo(n,r),r},BigInteger.prototype.shiftRight=function bnShiftRight(n){var r=nbi();return n<0?this.lShiftTo(-n,r):this.rShiftTo(n,r),r},BigInteger.prototype.getLowestSetBit=function bnGetLowestSetBit(){for(var i=0;i<this.t;++i)if(0!=this[i])return i*this.DB+lbit(this[i]);return this.s<0?this.t*this.DB:-1},BigInteger.prototype.bitCount=function bnBitCount(){for(var r=0,x=this.s&this.DM,i=0;i<this.t;++i)r+=cbit(this[i]^x);return r},BigInteger.prototype.testBit=function bnTestBit(n){var j=Math.floor(n/this.DB);return j>=this.t?0!=this.s:!!(this[j]&1<<n%this.DB)},BigInteger.prototype.setBit=function bnSetBit(n){return this.changeBit(n,op_or)},BigInteger.prototype.clearBit=function bnClearBit(n){return this.changeBit(n,op_andnot)},BigInteger.prototype.flipBit=function bnFlipBit(n){return this.changeBit(n,op_xor)},BigInteger.prototype.add=function bnAdd(a){var r=nbi();return this.addTo(a,r),r},BigInteger.prototype.subtract=function bnSubtract(a){var r=nbi();return this.subTo(a,r),r},BigInteger.prototype.multiply=function bnMultiply(a){var r=nbi();return this.multiplyTo(a,r),r},BigInteger.prototype.divide=function bnDivide(a){var r=nbi();return this.divRemTo(a,r,null),r},BigInteger.prototype.remainder=function bnRemainder(a){var r=nbi();return this.divRemTo(a,null,r),r},BigInteger.prototype.divideAndRemainder=function bnDivideAndRemainder(a){var q=nbi(),r=nbi();return this.divRemTo(a,q,r),new Array(q,r)},BigInteger.prototype.modPow=function bnModPow(e,m){var k,z,i=e.bitLength(),r=nbv(1);if(i<=0)return r;k=i<18?1:i<48?3:i<144?4:i<768?5:6,z=i<8?new Classic(m):m.isEven()?new Barrett(m):new Montgomery(m);var g=new Array,n=3,k1=k-1,km=(1<<k)-1;if(g[1]=z.convert(this),k>1){var g2=nbi();for(z.sqrTo(g[1],g2);n<=km;)g[n]=nbi(),z.mulTo(g2,g[n-2],g[n]),n+=2}var w,t,j=e.t-1,is1=!0,r2=nbi();for(i=nbits(e[j])-1;j>=0;){for(i>=k1?w=e[j]>>i-k1&km:(w=(e[j]&(1<<i+1)-1)<<k1-i,j>0&&(w|=e[j-1]>>this.DB+i-k1)),n=k;!(1&w);)w>>=1,--n;if((i-=n)<0&&(i+=this.DB,--j),is1)g[w].copyTo(r),is1=!1;else{for(;n>1;)z.sqrTo(r,r2),z.sqrTo(r2,r),n-=2;n>0?z.sqrTo(r,r2):(t=r,r=r2,r2=t),z.mulTo(r2,g[w],r)}for(;j>=0&&!(e[j]&1<<i);)z.sqrTo(r,r2),t=r,r=r2,r2=t,--i<0&&(i=this.DB-1,--j)}return z.revert(r)},BigInteger.prototype.modInverse=function bnModInverse(m){var ac=m.isEven();if(this.isEven()&&ac||0==m.signum())return BigInteger.ZERO;for(var u=m.clone(),v=this.clone(),a=nbv(1),b=nbv(0),c=nbv(0),d=nbv(1);0!=u.signum();){for(;u.isEven();)u.rShiftTo(1,u),ac?(a.isEven()&&b.isEven()||(a.addTo(this,a),b.subTo(m,b)),a.rShiftTo(1,a)):b.isEven()||b.subTo(m,b),b.rShiftTo(1,b);for(;v.isEven();)v.rShiftTo(1,v),ac?(c.isEven()&&d.isEven()||(c.addTo(this,c),d.subTo(m,d)),c.rShiftTo(1,c)):d.isEven()||d.subTo(m,d),d.rShiftTo(1,d);u.compareTo(v)>=0?(u.subTo(v,u),ac&&a.subTo(c,a),b.subTo(d,b)):(v.subTo(u,v),ac&&c.subTo(a,c),d.subTo(b,d))}return 0!=v.compareTo(BigInteger.ONE)?BigInteger.ZERO:d.compareTo(m)>=0?d.subtract(m):d.signum()<0?(d.addTo(m,d),d.signum()<0?d.add(m):d):d},BigInteger.prototype.pow=function bnPow(e){return this.exp(e,new NullExp)},BigInteger.prototype.gcd=function bnGCD(a){var x=this.s<0?this.negate():this.clone(),y=a.s<0?a.negate():a.clone();if(x.compareTo(y)<0){var t=x;x=y,y=t}var i=x.getLowestSetBit(),g=y.getLowestSetBit();if(g<0)return x;for(i<g&&(g=i),g>0&&(x.rShiftTo(g,x),y.rShiftTo(g,y));x.signum()>0;)(i=x.getLowestSetBit())>0&&x.rShiftTo(i,x),(i=y.getLowestSetBit())>0&&y.rShiftTo(i,y),x.compareTo(y)>=0?(x.subTo(y,x),x.rShiftTo(1,x)):(y.subTo(x,y),y.rShiftTo(1,y));return g>0&&y.lShiftTo(g,y),y},BigInteger.prototype.isProbablePrime=function bnIsProbablePrime(t){var i,x=this.abs();if(1==x.t&&x[0]<=lowprimes[lowprimes.length-1]){for(i=0;i<lowprimes.length;++i)if(x[0]==lowprimes[i])return!0;return!1}if(x.isEven())return!1;for(i=1;i<lowprimes.length;){for(var m=lowprimes[i],j=i+1;j<lowprimes.length&&m<lplim;)m*=lowprimes[j++];for(m=x.modInt(m);i<j;)if(m%lowprimes[i++]==0)return!1}return x.millerRabin(t)},BigInteger.prototype.square=function bnSquare(){var r=nbi();return this.squareTo(r),r},BigInteger.prototype.Barrett=Barrett,null==rng_pool){var t;if(rng_pool=new Array,rng_pptr=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var ua=new Uint8Array(32);for(window.crypto.getRandomValues(ua),t=0;t<32;++t)rng_pool[rng_pptr++]=ua[t]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var z=window.crypto.random(32);for(t=0;t<z.length;++t)rng_pool[rng_pptr++]=255&z.charCodeAt(t)}for(;rng_pptr<rng_psize;)t=Math.floor(65536*Math.random()),rng_pool[rng_pptr++]=t>>>8,rng_pool[rng_pptr++]=255&t;rng_pptr=0,rng_seed_time()}function rng_get_byte(){if(null==rng_state){for(rng_seed_time(),(rng_state=function prng_newstate(){return new Arcfour}()).init(rng_pool),rng_pptr=0;rng_pptr<rng_pool.length;++rng_pptr)rng_pool[rng_pptr]=0;rng_pptr=0}return rng_state.next()}function SecureRandom(){}function Arcfour(){this.i=0,this.j=0,this.S=new Array}SecureRandom.prototype.nextBytes=function rng_get_bytes(ba){var i;for(i=0;i<ba.length;++i)ba[i]=rng_get_byte()},Arcfour.prototype.init=function ARC4init(key){var i,j,t;for(i=0;i<256;++i)this.S[i]=i;for(j=0,i=0;i<256;++i)j=j+this.S[i]+key[i%key.length]&255,t=this.S[i],this.S[i]=this.S[j],this.S[j]=t;this.i=0,this.j=0},Arcfour.prototype.next=function ARC4next(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var rng_psize=256;module.exports={default:BigInteger,BigInteger:BigInteger,SecureRandom:SecureRandom}}).call(jsbn)}(jsbn$1)),jsbn$1.exports}const JSEncrypt=function requireJsencrypt_min(){return hasRequiredJsencrypt_min||(hasRequiredJsencrypt_min=1,function(module){!function(t,e){module.exports=e()}(window,()=>(()=>{var t={155:t=>{var e,i,r=t.exports={};function n(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(t){if(e===setTimeout)return setTimeout(t,0);if((e===n||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(i){try{return e.call(null,t,0)}catch(i){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:n}catch(t){e=n}try{i="function"==typeof clearTimeout?clearTimeout:s}catch(t){i=s}}();var h,a=[],u=!1,c=-1;function f(){u&&h&&(u=!1,h.length?a=h.concat(a):c=-1,a.length&&l())}function l(){if(!u){var t=o(f);u=!0;for(var e=a.length;e;){for(h=a,a=[];++c<e;)h&&h[c].run();c=-1,e=a.length}h=null,u=!1,function(t){if(i===clearTimeout)return clearTimeout(t);if((i===s||!i)&&clearTimeout)return i=clearTimeout,clearTimeout(t);try{return i(t)}catch(e){try{return i.call(null,t)}catch(e){return i.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function g(){}r.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)e[i-1]=arguments[i];a.push(new p(t,e)),1!==a.length||u||o(l)},p.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=g,r.addListener=g,r.once=g,r.off=g,r.removeListener=g,r.removeAllListeners=g,r.emit=g,r.prependListener=g,r.prependOnceListener=g,r.listeners=function(t){return[]},r.binding=function(t){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(t){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}}},e={};function i(r){var n=e[r];if(void 0!==n)return n.exports;var s=e[r]={exports:{}};return t[r](s,s.exports,i),s.exports}i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var r={};return(()=>{i.d(r,{default:()=>ct});function e(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function n(t,e){return t&e}function s(t,e){return t|e}function o(t,e){return t^e}function h(t,e){return t&~e}function a(t){if(0==t)return-1;var e=0;return!(65535&t)&&(t>>=16,e+=16),!(255&t)&&(t>>=8,e+=8),!(15&t)&&(t>>=4,e+=4),!(3&t)&&(t>>=2,e+=2),!(1&t)&&++e,e}function u(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var c,f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function p(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=f.charAt(i>>6)+f.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=f.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=f.charAt(i>>2)+f.charAt((3&i)<<4));(3&r.length)>0;)r+="=";return r}function g(t){var i,r="",n=0,s=0;for(i=0;i<t.length&&"="!=t.charAt(i);++i){var o=f.indexOf(t.charAt(i));o<0||(0==n?(r+=e(o>>2),s=3&o,n=1):1==n?(r+=e(s<<2|o>>4),s=15&o,n=2):2==n?(r+=e(s),r+=e(o>>2),s=3&o,n=3):(r+=e(s<<2|o>>4),r+=e(15&o),n=0))}return 1==n&&(r+=e(s<<2)),r}var d,v={decode:function(t){var e;if(void 0===d){var i="= \f\n\r\t \u2028\u2029";for(d=Object.create(null),e=0;e<64;++e)d["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(d["-"]=62,d._=63,e=0;e<9;++e)d[i.charAt(e)]=-1}var r=[],n=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=d[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);n|=o,++s>=4?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,n=0,s=0):n<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=v.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return v.decode(t)}},m=1e13,y=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var i,r,n=this.buf,s=n.length;for(i=0;i<s;++i)(r=n[i]*t+e)<m?e=0:r-=(e=0|r/m)*m,n[i]=r;e>0&&(n[i]=e)},t.prototype.sub=function(t){var e,i,r=this.buf,n=r.length;for(e=0;e<n;++e)(i=r[e]-t)<0?(i+=m,t=1):t=0,r[e]=i;for(;0===r[r.length-1];)r.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,i=e[e.length-1].toString(),r=e.length-2;r>=0;--r)i+=(m+e[r]).toString().substring(1);return i},t.prototype.valueOf=function(){for(var t=this.buf,e=0,i=t.length-1;i>=0;--i)e=e*m+t[i];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),T=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,S=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function E(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}var w,D=function(){function t(e,i){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=i)}return t.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset ".concat(t," on a stream of length ").concat(this.enc.length));return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},t.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},t.prototype.hexDump=function(t,e,i){for(var r="",n=t;n<e;++n)if(r+=this.hexByte(this.get(n)),!0!==i)switch(15&n){case 7:r+=" ";break;case 15:r+="\n";break;default:r+=" "}return r},t.prototype.isASCII=function(t,e){for(var i=t;i<e;++i){var r=this.get(i);if(r<32||r>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var i="",r=t;r<e;++r)i+=String.fromCharCode(this.get(r));return i},t.prototype.parseStringUTF=function(t,e){for(var i="",r=t;r<e;){var n=this.get(r++);i+=n<128?String.fromCharCode(n):n>191&&n<224?String.fromCharCode((31&n)<<6|63&this.get(r++)):String.fromCharCode((15&n)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},t.prototype.parseStringBMP=function(t,e){for(var i,r,n="",s=t;s<e;)i=this.get(s++),r=this.get(s++),n+=String.fromCharCode(i<<8|r);return n},t.prototype.parseTime=function(t,e,i){var r=this.parseStringISO(t,e),n=(i?T:S).exec(r);return n?(i&&(n[1]=+n[1],n[1]+=+n[1]<70?2e3:1900),r=n[1]+"-"+n[2]+"-"+n[3]+" "+n[4],n[5]&&(r+=":"+n[5],n[6]&&(r+=":"+n[6],n[7]&&(r+="."+n[7]))),n[8]&&(r+=" UTC","Z"!=n[8]&&(r+=n[8],n[9]&&(r+=":"+n[9]))),r):"Unrecognized time: "+r},t.prototype.parseInteger=function(t,e){for(var i,r=this.get(t),n=r>127,s=n?255:0,o="";r==s&&++t<e;)r=this.get(t);if(0==(i=e-t))return n?-1:0;if(i>4){for(o=r,i<<=3;!(128&(+o^s));)o=+o<<1,--i;o="("+i+" bit)\n"}n&&(r-=256);for(var h=new y(r),a=t+1;a<e;++a)h.mulAdd(256,this.get(a));return o+h.toString()},t.prototype.parseBitString=function(t,e,i){for(var r=this.get(t),n="("+((e-t-1<<3)-r)+" bit)\n",s="",o=t+1;o<e;++o){for(var h=this.get(o),a=o==e-1?r:0,u=7;u>=a;--u)s+=h>>u&1?"1":"0";if(s.length>i)return n+E(s,i)}return n+s},t.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return E(this.parseStringISO(t,e),i);var r=e-t,n="("+r+" byte)\n";r>(i/=2)&&(e=t+i);for(var s=t;s<e;++s)n+=this.hexByte(this.get(s));return r>i&&(n+="…"),n},t.prototype.parseOID=function(t,e,i){for(var r="",n=new y,s=0,o=t;o<e;++o){var h=this.get(o);if(n.mulAdd(128,127&h),s+=7,!(128&h)){if(""===r)if((n=n.simplify())instanceof y)n.sub(80),r="2."+n.toString();else{var a=n<80?n<40?0:1:2;r=a+"."+(n-40*a)}else r+="."+n.toString();if(r.length>i)return E(r,i);n=new y,s=0}}return s>0&&(r+=".incomplete"),r},t}(),x=function(){function t(t,e,i,r,n){if(!(r instanceof R))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=n}return t.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},t.prototype.content=function(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),i=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+i);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+i,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);case 6:return this.stream.parseOID(e,e+i,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return E(this.stream.parseStringUTF(e,e+i),t);case 18:case 19:case 20:case 21:case 22:case 26:return E(this.stream.parseStringISO(e,e+i),t);case 30:return E(this.stream.parseStringBMP(e,e+i),t);case 23:case 24:return this.stream.parseTime(e,e+i,23==this.tag.tagNumber)}return null},t.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},t.prototype.toPrettyString=function(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var i=0,r=this.sub.length;i<r;++i)e+=this.sub[i].toPrettyString(t)}return e},t.prototype.posStart=function(){return this.stream.pos},t.prototype.posContent=function(){return this.stream.pos+this.header},t.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},t.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},t.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(i>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===i)return null;e=0;for(var r=0;r<i;++r)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},t.decode=function(e){var i;i=e instanceof D?e:new D(e,0);var r=new D(i),n=new R(i),s=t.decodeLength(i),o=i.pos,h=o-r.pos,a=null,u=function(){var e=[];if(null!==s){for(var r=o+s;i.pos<r;)e[e.length]=t.decode(i);if(i.pos!=r)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=t.decode(i);if(n.tag.isEOC())break;e[e.length]=n}s=o-i.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=i.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);i.pos=o+Math.abs(s)}return new t(r,h,s,n,a)},t}(),R=function(){function t(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=!!(32&e),this.tagNumber=31&e,31==this.tagNumber){var i=new y;do{e=t.get(),i.mulAdd(128,127&e)}while(128&e);this.tagNumber=i.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],O=(1<<26)/B[B.length-1],A=function(){function t(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return t.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var i;if(16==t)i=4;else if(8==t)i=3;else if(2==t)i=1;else if(32==t)i=5;else{if(4!=t)return this.toRadix(t);i=2}var r,n=(1<<i)-1,s=!1,o="",h=this.t,a=this.DB-h*this.DB%i;if(h-- >0)for(a<this.DB&&(r=this[h]>>a)>0&&(s=!0,o=e(r));h>=0;)a<i?(r=(this[h]&(1<<a)-1)<<i-a,r|=this[--h]>>(a+=this.DB-i)):(r=this[h]>>(a-=i)&n,a<=0&&(a+=this.DB,--h)),r>0&&(s=!0),s&&(o+=e(r));return s?o:"0"},t.prototype.negate=function(){var e=M();return t.ZERO.subTo(this,e),e},t.prototype.abs=function(){return this.s<0?this.negate():this},t.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;--i>=0;)if(0!=(e=this[i]-t[i]))return e;return 0},t.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+K(this[this.t-1]^this.s&this.DM)},t.prototype.mod=function(e){var i=M();return this.abs().divRemTo(e,null,i),this.s<0&&i.compareTo(t.ZERO)>0&&e.subTo(i,i),i},t.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new I(e):new N(e),this.exp(t,i)},t.prototype.clone=function(){var t=M();return this.copyTo(t),t},t.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},t.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},t.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},t.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},t.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var i,r=this.DB-t*this.DB%8,n=0;if(t-- >0)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<<this.DB-r);t>=0;)r<8?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),!!(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(n>0||i!=this.s)&&(e[n++]=i);return e},t.prototype.equals=function(t){return 0==this.compareTo(t)},t.prototype.min=function(t){return this.compareTo(t)<0?this:t},t.prototype.max=function(t){return this.compareTo(t)>0?this:t},t.prototype.and=function(t){var e=M();return this.bitwiseTo(t,n,e),e},t.prototype.or=function(t){var e=M();return this.bitwiseTo(t,s,e),e},t.prototype.xor=function(t){var e=M();return this.bitwiseTo(t,o,e),e},t.prototype.andNot=function(t){var e=M();return this.bitwiseTo(t,h,e),e},t.prototype.not=function(){for(var t=M(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},t.prototype.shiftLeft=function(t){var e=M();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},t.prototype.shiftRight=function(t){var e=M();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},t.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+a(this[t]);return this.s<0?this.t*this.DB:-1},t.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=u(this[i]^e);return t},t.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},t.prototype.setBit=function(t){return this.changeBit(t,s)},t.prototype.clearBit=function(t){return this.changeBit(t,h)},t.prototype.flipBit=function(t){return this.changeBit(t,o)},t.prototype.add=function(t){var e=M();return this.addTo(t,e),e},t.prototype.subtract=function(t){var e=M();return this.subTo(t,e),e},t.prototype.multiply=function(t){var e=M();return this.multiplyTo(t,e),e},t.prototype.divide=function(t){var e=M();return this.divRemTo(t,e,null),e},t.prototype.remainder=function(t){var e=M();return this.divRemTo(t,null,e),e},t.prototype.divideAndRemainder=function(t){var e=M(),i=M();return this.divRemTo(t,e,i),[e,i]},t.prototype.modPow=function(t,e){var i,r,n=t.bitLength(),s=U(1);if(n<=0)return s;i=n<18?1:n<48?3:n<144?4:n<768?5:6,r=n<8?new I(e):e.isEven()?new P(e):new N(e);var o=[],h=3,a=i-1,u=(1<<i)-1;if(o[1]=r.convert(this),i>1){var c=M();for(r.sqrTo(o[1],c);h<=u;)o[h]=M(),r.mulTo(c,o[h-2],o[h]),h+=2}var f,l,p=t.t-1,g=!0,d=M();for(n=K(t[p])-1;p>=0;){for(n>=a?f=t[p]>>n-a&u:(f=(t[p]&(1<<n+1)-1)<<a-n,p>0&&(f|=t[p-1]>>this.DB+n-a)),h=i;!(1&f);)f>>=1,--h;if((n-=h)<0&&(n+=this.DB,--p),g)o[f].copyTo(s),g=!1;else{for(;h>1;)r.sqrTo(s,d),r.sqrTo(d,s),h-=2;h>0?r.sqrTo(s,d):(l=s,s=d,d=l),r.mulTo(d,o[f],s)}for(;p>=0&&!(t[p]&1<<n);)r.sqrTo(s,d),l=s,s=d,d=l,--n<0&&(n=this.DB-1,--p)}return r.revert(s)},t.prototype.modInverse=function(e){var i=e.isEven();if(this.isEven()&&i||0==e.signum())return t.ZERO;for(var r=e.clone(),n=this.clone(),s=U(1),o=U(0),h=U(0),a=U(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),i?(s.isEven()&&o.isEven()||(s.addTo(this,s),o.subTo(e,o)),s.rShiftTo(1,s)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),i?(h.isEven()&&a.isEven()||(h.addTo(this,h),a.subTo(e,a)),h.rShiftTo(1,h)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);r.compareTo(n)>=0?(r.subTo(n,r),i&&s.subTo(h,s),o.subTo(a,o)):(n.subTo(r,n),i&&h.subTo(s,h),a.subTo(o,a))}return 0!=n.compareTo(t.ONE)?t.ZERO:a.compareTo(e)>=0?a.subtract(e):a.signum()<0?(a.addTo(e,a),a.signum()<0?a.add(e):a):a},t.prototype.pow=function(t){return this.exp(t,new V)},t.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var n=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),s>0&&(e.rShiftTo(s,e),i.rShiftTo(s,i));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=i.getLowestSetBit())>0&&i.rShiftTo(n,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},t.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=B[B.length-1]){for(e=0;e<B.length;++e)if(i[0]==B[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<B.length;){for(var r=B[e],n=e+1;n<B.length&&r<O;)r*=B[n++];for(r=i.modInt(r);e<n;)if(r%B[e++]==0)return!1}return i.millerRabin(t)},t.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},t.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},t.prototype.fromString=function(e,i){var r;if(16==i)r=4;else if(8==i)r=3;else if(256==i)r=8;else if(2==i)r=1;else if(32==i)r=5;else{if(4!=i)return void this.fromRadix(e,i);r=2}this.t=0,this.s=0;for(var n=e.length,s=!1,o=0;--n>=0;){var h=8==r?255&+e[n]:F(e,n);h<0?"-"==e.charAt(n)&&(s=!0):(s=!1,0==o?this[this.t++]=h:o+r>this.DB?(this[this.t-1]|=(h&(1<<this.DB-o)-1)<<o,this[this.t++]=h>>this.DB-o):this[this.t-1]|=h<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&!!(128&+e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),s&&t.ZERO.subTo(this,this)},t.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},t.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},t.prototype.drShiftTo=function(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s},t.prototype.lShiftTo=function(t,e){for(var i=t%this.DB,r=this.DB-i,n=(1<<r)-1,s=Math.floor(t/this.DB),o=this.s<<i&this.DM,h=this.t-1;h>=0;--h)e[h+s+1]=this[h]>>r|o,o=(this[h]&n)<<i;for(h=s-1;h>=0;--h)e[h]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},t.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var r=t%this.DB,n=this.DB-r,s=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&s)<<n,e[o-i]=this[o]>>r;r>0&&(e[this.t-i-1]|=(this.s&s)<<n),e.t=this.t-i,e.clamp()}},t.prototype.subTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()},t.prototype.multiplyTo=function(e,i){var r=this.abs(),n=e.abs(),s=r.t;for(i.t=s+n.t;--s>=0;)i[s]=0;for(s=0;s<n.t;++s)i[s+r.t]=r.am(0,n[s],i,s,0,r.t);i.s=0,i.clamp(),this.s!=e.s&&t.ZERO.subTo(i,i)},t.prototype.squareTo=function(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},t.prototype.divRemTo=function(e,i,r){var n=e.abs();if(!(n.t<=0)){var s=this.abs();if(s.t<n.t)return null!=i&&i.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=M());var o=M(),h=this.s,a=e.s,u=this.DB-K(n[n.t-1]);u>0?(n.lShiftTo(u,o),s.lShiftTo(u,r)):(n.copyTo(o),s.copyTo(r));var c=o.t,f=o[c-1];if(0!=f){var l=f*(1<<this.F1)+(c>1?o[c-2]>>this.F2:0),p=this.FV/l,g=(1<<this.F1)/l,d=1<<this.F2,v=r.t,m=v-c,y=null==i?M():i;for(o.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),t.ONE.dlShiftTo(c,y),y.subTo(o,o);o.t<c;)o[o.t++]=0;for(;--m>=0;){var b=r[--v]==f?this.DM:Math.floor(r[v]*p+(r[v-1]+d)*g);if((r[v]+=o.am(0,b,r,m,0,c))<b)for(o.dlShiftTo(m,y),r.subTo(y,r);r[v]<--b;)r.subTo(y,r)}null!=i&&(r.drShiftTo(c,i),h!=a&&t.ZERO.subTo(i,i)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),h<0&&t.ZERO.subTo(r,r)}}},t.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},t.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},t.prototype.exp=function(e,i){if(e>4294967295||e<1)return t.ONE;var r=M(),n=M(),s=i.convert(this),o=K(e)-1;for(s.copyTo(r);--o>=0;)if(i.sqrTo(r,n),(e&1<<o)>0)i.mulTo(n,s,r);else{var h=r;r=n,n=h}return i.revert(r)},t.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},t.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=U(i),n=M(),s=M(),o="";for(this.divRemTo(r,n,s);n.signum()>0;)o=(i+s.intValue()).toString(t).substr(1)+o,n.divRemTo(r,n,s);return s.intValue().toString(t)+o},t.prototype.fromRadix=function(e,i){this.fromInt(0),null==i&&(i=10);for(var r=this.chunkSize(i),n=Math.pow(i,r),s=!1,o=0,h=0,a=0;a<e.length;++a){var u=F(e,a);u<0?"-"==e.charAt(a)&&0==this.signum()&&(s=!0):(h=i*h+u,++o>=r&&(this.dMultiply(n),this.dAddOffset(h,0),o=0,h=0))}o>0&&(this.dMultiply(Math.pow(i,o)),this.dAddOffset(h,0)),s&&t.ZERO.subTo(this,this)},t.prototype.fromNumber=function(e,i,r){if("number"==typeof i)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),s,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(i);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(t.ONE.shiftLeft(e-1),this);else{var n=[],o=7&e;n.length=1+(e>>3),i.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},t.prototype.bitwiseTo=function(t,e,i){var r,n,s=Math.min(t.t,this.t);for(r=0;r<s;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(n=t.s&this.DM,r=s;r<this.t;++r)i[r]=e(this[r],n);i.t=this.t}else{for(n=this.s&this.DM,r=s;r<t.t;++r)i[r]=e(n,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},t.prototype.changeBit=function(e,i){var r=t.ONE.shiftLeft(e);return this.bitwiseTo(r,i,r),r},t.prototype.addTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()},t.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},t.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},t.prototype.multiplyLowerTo=function(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(var n=i.t-this.t;r<n;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(n=Math.min(t.t,e);r<n;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()},t.prototype.multiplyUpperTo=function(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)},t.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(0==e)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i},t.prototype.millerRabin=function(e){var i=this.subtract(t.ONE),r=i.getLowestSetBit();if(r<=0)return!1;var n=i.shiftRight(r);(e=e+1>>1)>B.length&&(e=B.length);for(var s=M(),o=0;o<e;++o){s.fromInt(B[Math.floor(Math.random()*B.length)]);var h=s.modPow(n,this);if(0!=h.compareTo(t.ONE)&&0!=h.compareTo(i)){for(var a=1;a++<r&&0!=h.compareTo(i);)if(0==(h=h.modPowInt(2,this)).compareTo(t.ONE))return!1;if(0!=h.compareTo(i))return!1}}return!0},t.prototype.square=function(){var t=M();return this.squareTo(t),t},t.prototype.gcda=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var n=i;i=r,r=n}var s=i.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)e(i);else{s<o&&(o=s),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(h,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)}},t.prototype.fromNumberAsync=function(e,i,r,n){if("number"==typeof i)if(e<2)this.fromInt(1);else{this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),s,this),this.isEven()&&this.dAddOffset(1,0);var o=this,h=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(t.ONE.shiftLeft(e-1),o),o.isProbablePrime(i)?setTimeout(function(){n()},0):setTimeout(h,0)};setTimeout(h,0)}else{var a=[],u=7&e;a.length=1+(e>>3),i.nextBytes(a),u>0?a[0]&=(1<<u)-1:a[0]=0,this.fromString(a,256)}},t}(),V=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),I=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),N=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=M();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(A.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=M();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),P=function(){function t(t){this.m=t,this.r2=M(),this.q3=M(),A.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=M();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function M(){return new A(null)}function L(t,e){return new A(t,e)}var j="undefined"!=typeof navigator;j&&"Microsoft Internet Explorer"==navigator.appName?(A.prototype.am=function(t,e,i,r,n,s){for(var o=32767&e,h=e>>15;--s>=0;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;n=((a=o*a+((32767&c)<<15)+i[r]+(1073741823&n))>>>30)+(c>>>15)+h*u+(n>>>30),i[r++]=1073741823&a}return n},w=30):j&&"Netscape"!=navigator.appName?(A.prototype.am=function(t,e,i,r,n,s){for(;--s>=0;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n},w=26):(A.prototype.am=function(t,e,i,r,n,s){for(var o=16383&e,h=e>>14;--s>=0;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;n=((a=o*a+((16383&c)<<14)+i[r]+n)>>28)+(c>>14)+h*u,i[r++]=268435455&a}return n},w=28),A.prototype.DB=w,A.prototype.DM=(1<<w)-1,A.prototype.DV=1<<w,A.prototype.FV=Math.pow(2,52),A.prototype.F1=52-w,A.prototype.F2=2*w-52;var q,H,C=[];for(q="0".charCodeAt(0),H=0;H<=9;++H)C[q++]=H;for(q="a".charCodeAt(0),H=10;H<36;++H)C[q++]=H;for(q="A".charCodeAt(0),H=10;H<36;++H)C[q++]=H;function F(t,e){var i=C[t.charCodeAt(e)];return null==i?-1:i}function U(t){var e=M();return e.fromInt(t),e}function K(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}A.ZERO=U(0),A.ONE=U(1);var k,_,z=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,i,r;for(e=0;e<256;++e)this.S[e]=e;for(i=0,e=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0},t.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},t}(),G=null;if(null==G){G=[],_=0;var $=void 0;if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues){var Y=new Uint32Array(256);for(window.crypto.getRandomValues(Y),$=0;$<Y.length;++$)G[_++]=255&Y[$]}var J=0,X=function(t){if((J=J||0)>=256||_>=256)window.removeEventListener?window.removeEventListener("mousemove",X,!1):window.detachEvent&&window.detachEvent("onmousemove",X);else try{var e=t.x+t.y;G[_++]=255&e,J+=1}catch(t){}};"undefined"!=typeof window&&(window.addEventListener?window.addEventListener("mousemove",X,!1):window.attachEvent&&window.attachEvent("onmousemove",X))}function Q(){if(null==k){for(k=new z;_<256;){var t=Math.floor(65536*Math.random());G[_++]=255&t}for(k.init(G),_=0;_<G.length;++_)G[_]=0;_=0}return k.next()}var W=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=Q()},t}(),tt=function(){function t(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return t.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},t.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=L(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=this.n.bitLength()+7>>3,i=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var i=[],r=t.length-1;r>=0&&e>0;){var n=t.charCodeAt(r--);n<128?i[--e]=n:n>127&&n<2048?(i[--e]=63&n|128,i[--e]=n>>6|192):(i[--e]=63&n|128,i[--e]=n>>6&63|128,i[--e]=n>>12|224)}i[--e]=0;for(var s=new W,o=[];e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new A(i)}(t,e);if(null==i)return null;var r=this.doPublic(i);if(null==r)return null;for(var n=r.toString(16),s=n.length,o=0;o<2*e-s;o++)n="0"+n;return n},t.prototype.setPrivate=function(t,e,i){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=L(t,16),this.e=parseInt(e,16),this.d=L(i,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,i,r,n,s,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=L(t,16),this.e=parseInt(e,16),this.d=L(i,16),this.p=L(r,16),this.q=L(n,16),this.dmp1=L(s,16),this.dmq1=L(o,16),this.coeff=L(h,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var i=new W,r=t>>1;this.e=parseInt(e,16);for(var n=new A(e,16);;){for(;this.p=new A(t-r,1,i),0!=this.p.subtract(A.ONE).gcd(n).compareTo(A.ONE)||!this.p.isProbablePrime(10););for(;this.q=new A(r,1,i),0!=this.q.subtract(A.ONE).gcd(n).compareTo(A.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(A.ONE),h=this.q.subtract(A.ONE),a=o.multiply(h);if(0==a.gcd(n).compareTo(A.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(a),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(h),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=L(t,16),i=this.doPrivate(e);return null==i?null:function(t,e){for(var i=t.toByteArray(),r=0;r<i.length&&0==i[r];)++r;if(i.length-r!=e-1||2!=i[r])return null;for(++r;0!=i[r];)if(++r>=i.length)return null;for(var n="";++r<i.length;){var s=255&i[r];s<128?n+=String.fromCharCode(s):s>191&&s<224?(n+=String.fromCharCode((31&s)<<6|63&i[r+1]),++r):(n+=String.fromCharCode((15&s)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return n}(i,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,i){var r=new W,n=t>>1;this.e=parseInt(e,16);var s=new A(e,16),o=this,h=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(A.ONE),r=o.q.subtract(A.ONE),n=e.multiply(r);0==n.gcd(s).compareTo(A.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(n),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(r),o.coeff=o.q.modInverse(o.p),setTimeout(function(){i()},0)):setTimeout(h,0)},a=function(){o.q=M(),o.q.fromNumberAsync(n,1,r,function(){o.q.subtract(A.ONE).gcda(s,function(t){0==t.compareTo(A.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(a,0)})})},u=function(){o.p=M(),o.p.fromNumberAsync(t-n,1,r,function(){o.p.subtract(A.ONE).gcda(s,function(t){0==t.compareTo(A.ONE)&&o.p.isProbablePrime(10)?setTimeout(a,0):setTimeout(u,0)})})};setTimeout(u,0)};setTimeout(h,0)},t.prototype.sign=function(t,e,i){var r=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var i=e-t.length-6,r="",n=0;n<i;n+=2)r+="ff";return L("0001"+r+"00"+t,16)}((et[i]||"")+e(t).toString(),this.n.bitLength()/4);if(null==r)return null;var n=this.doPrivate(r);if(null==n)return null;var s=n.toString(16);return 1&s.length?"0"+s:s},t.prototype.verify=function(t,e,i){var r=L(e,16),n=this.doPublic(r);return null==n?null:function(t){for(var e in et)if(et.hasOwnProperty(e)){var i=et[e],r=i.length;if(t.substr(0,r)==i)return t.substr(r)}return t}(n.toString(16).replace(/^1f+00/,""))==i(t).toString()},t}(),et={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"},it={};it.lang={extend:function(t,e,i){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),i){var n;for(n in i)t.prototype[n]=i[n];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(n=0;n<o.length;n+=1){var i=o[n],r=e[i];"function"==typeof r&&r!=Object.prototype[i]&&(t[i]=r)}})}catch(t){}s(t.prototype,i)}}};var rt={};void 0!==rt.asn1&&rt.asn1||(rt.asn1={}),rt.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var r="",n=0;n<i;n++)r+="f";e=new A(r,16).xor(t).add(A.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=rt.asn1,i=e.DERBoolean,r=e.DERInteger,n=e.DERBitString,s=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,a=e.DEREnumerated,u=e.DERUTF8String,c=e.DERNumericString,f=e.DERPrintableString,l=e.DERTeletexString,p=e.DERIA5String,g=e.DERUTCTime,d=e.DERGeneralizedTime,v=e.DERSequence,m=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,T=Object.keys(t);if(1!=T.length)throw"key of param shall be only one.";var S=T[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new i(t[S]);if("int"==S)return new r(t[S]);if("bitstr"==S)return new n(t[S]);if("octstr"==S)return new s(t[S]);if("null"==S)return new o(t[S]);if("oid"==S)return new h(t[S]);if("enum"==S)return new a(t[S]);if("utf8str"==S)return new u(t[S]);if("numstr"==S)return new c(t[S]);if("prnstr"==S)return new f(t[S]);if("telstr"==S)return new l(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new g(t[S]);if("gentime"==S)return new d(t[S]);if("seq"==S){for(var E=t[S],w=[],D=0;D<E.length;D++){var x=b(E[D]);w.push(x)}return new v({array:w})}if("set"==S){for(E=t[S],w=[],D=0;D<E.length;D++)x=b(E[D]),w.push(x);return new m({array:w})}if("tag"==S){var R=t[S];if("[object Array]"===Object.prototype.toString.call(R)&&3==R.length){var B=b(R[2]);return new y({tag:R[0],explicit:R[1],obj:B})}var O={};if(void 0!==R.explicit&&(O.explicit=R.explicit),void 0!==R.tag&&(O.tag=R.tag),void 0===R.obj)throw"obj shall be specified for 'tag'.";return O.obj=b(R.obj),new y(O)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},rt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",i=parseInt(t.substr(0,2),16),r=(e=Math.floor(i/40)+"."+i%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);r+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new A(r,2).toString(10),r="")}return e},rt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},i=function(t){var i="",r=new A(t,10).toString(2),n=7-r.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(r=s+r,o=0;o<r.length-1;o+=7){var h=r.substr(o,7);o!=r.length-7&&(h="1"+h),i+=e(parseInt(h,2))}return i};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);r+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)r+=i(n[o]);return r},rt.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n=0,v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var i=e.length/2;if(i>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},rt.asn1.DERAbstractString=function(t){rt.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},it.lang.extend(rt.asn1.DERAbstractString,rt.asn1.ASN1Object),rt.asn1.DERAbstractTime=function(t){rt.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var r=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+r(String(n.getMonth()+1),2)+r(String(n.getDate()),2)+r(String(n.getHours()),2)+r(String(n.getMinutes()),2)+r(String(n.getSeconds()),2);if(!0===i){var h=n.getMilliseconds();if(0!=h){var a=r(String(h),3);o=o+"."+(a=a.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,i,r,n,s){var o=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},it.lang.extend(rt.asn1.DERAbstractTime,rt.asn1.ASN1Object),rt.asn1.DERAbstractStructured=function(t){rt.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},it.lang.extend(rt.asn1.DERAbstractStructured,rt.asn1.ASN1Object),rt.asn1.DERBoolean=function(){rt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},it.lang.extend(rt.asn1.DERBoolean,rt.asn1.ASN1Object),rt.asn1.DERInteger=function(t){rt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=rt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new A(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},it.lang.extend(rt.asn1.DERInteger,rt.asn1.ASN1Object),rt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=rt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}rt.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var i=0;i<=e;i++)t+="0";var r="";for(i=0;i<t.length-1;i+=8){var n=t.substr(i,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),r+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)1==t[i]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},it.lang.extend(rt.asn1.DERBitString,rt.asn1.ASN1Object),rt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=rt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}rt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},it.lang.extend(rt.asn1.DEROctetString,rt.asn1.DERAbstractString),rt.asn1.DERNull=function(){rt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},it.lang.extend(rt.asn1.DERNull,rt.asn1.ASN1Object),rt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},i=function(t){var i="",r=new A(t,10).toString(2),n=7-r.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(r=s+r,o=0;o<r.length-1;o+=7){var h=r.substr(o,7);o!=r.length-7&&(h="1"+h),i+=e(parseInt(h,2))}return i};rt.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var r="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);r+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)r+=i(n[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(t){var e=rt.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},it.lang.extend(rt.asn1.DERObjectIdentifier,rt.asn1.ASN1Object),rt.asn1.DEREnumerated=function(t){rt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=rt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new A(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},it.lang.extend(rt.asn1.DEREnumerated,rt.asn1.ASN1Object),rt.asn1.DERUTF8String=function(t){rt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},it.lang.extend(rt.asn1.DERUTF8String,rt.asn1.DERAbstractString),rt.asn1.DERNumericString=function(t){rt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},it.lang.extend(rt.asn1.DERNumericString,rt.asn1.DERAbstractString),rt.asn1.DERPrintableString=function(t){rt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},it.lang.extend(rt.asn1.DERPrintableString,rt.asn1.DERAbstractString),rt.asn1.DERTeletexString=function(t){rt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},it.lang.extend(rt.asn1.DERTeletexString,rt.asn1.DERAbstractString),rt.asn1.DERIA5String=function(t){rt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},it.lang.extend(rt.asn1.DERIA5String,rt.asn1.DERAbstractString),rt.asn1.DERUTCTime=function(t){rt.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},it.lang.extend(rt.asn1.DERUTCTime,rt.asn1.DERAbstractTime),rt.asn1.DERGeneralizedTime=function(t){rt.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},it.lang.extend(rt.asn1.DERGeneralizedTime,rt.asn1.DERAbstractTime),rt.asn1.DERSequence=function(t){rt.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},it.lang.extend(rt.asn1.DERSequence,rt.asn1.DERAbstractStructured),rt.asn1.DERSet=function(t){rt.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},it.lang.extend(rt.asn1.DERSet,rt.asn1.DERAbstractStructured),rt.asn1.DERTaggedObject=function(t){rt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},it.lang.extend(rt.asn1.DERTaggedObject,rt.asn1.ASN1Object);var nt,st,ot=(nt=function(t,e){return nt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},nt(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}nt(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),ht=function(t){function e(i){var r=t.call(this)||this;return i&&("string"==typeof i?r.parseKey(i):(e.hasPrivateKeyProperty(i)||e.hasPublicKeyProperty(i))&&r.parsePropertiesFrom(i)),r}return ot(e,t),e.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?function(t){var e;if(void 0===c){var i="0123456789ABCDEF",r=" \f\n\r\t \u2028\u2029";for(c={},e=0;e<16;++e)c[i.charAt(e)]=e;for(i=i.toLowerCase(),e=10;e<16;++e)c[i.charAt(e)]=e;for(e=0;e<8;++e)c[r.charAt(e)]=-1}var n=[],s=0,o=0;for(e=0;e<t.length;++e){var h=t.charAt(e);if("="==h)break;if(-1!=(h=c[h])){if(void 0===h)throw new Error("Illegal character at offset "+e);s|=h,++o>=2?(n[n.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}(t):v.unarmor(t),n=x.decode(r);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=L(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var s=n.sub[3].getHexStringValue();this.d=L(s,16);var o=n.sub[4].getHexStringValue();this.p=L(o,16);var h=n.sub[5].getHexStringValue();this.q=L(h,16);var a=n.sub[6].getHexStringValue();this.dmp1=L(a,16);var u=n.sub[7].getHexStringValue();this.dmq1=L(u,16);var f=n.sub[8].getHexStringValue();this.coeff=L(f,16)}else{if(2!==n.sub.length)return!1;if(n.sub[0].sub){var l=n.sub[1].sub[0];e=l.sub[0].getHexStringValue(),this.n=L(e,16),i=l.sub[1].getHexStringValue(),this.e=parseInt(i,16)}else e=n.sub[0].getHexStringValue(),this.n=L(e,16),i=n.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new rt.asn1.DERInteger({int:0}),new rt.asn1.DERInteger({bigint:this.n}),new rt.asn1.DERInteger({int:this.e}),new rt.asn1.DERInteger({bigint:this.d}),new rt.asn1.DERInteger({bigint:this.p}),new rt.asn1.DERInteger({bigint:this.q}),new rt.asn1.DERInteger({bigint:this.dmp1}),new rt.asn1.DERInteger({bigint:this.dmq1}),new rt.asn1.DERInteger({bigint:this.coeff})]};return new rt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return p(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new rt.asn1.DERSequence({array:[new rt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new rt.asn1.DERNull]}),e=new rt.asn1.DERSequence({array:[new rt.asn1.DERInteger({bigint:this.n}),new rt.asn1.DERInteger({int:this.e})]}),i=new rt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new rt.asn1.DERSequence({array:[t,i]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return p(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var i="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return(t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n")+"-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return(t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n")+"-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(tt),at=i(155),ut=void 0!==at?null===(st=at.env)||void 0===st?void 0:"3.3.2":void 0;const ct=function(){function t(t){void 0===t&&(t={}),t=t||{},this.default_key_size=t.default_key_size?parseInt(t.default_key_size,10):1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new ht(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(g(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return p(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,i){try{return p(this.getKey().sign(t,e,i))}catch(t){return!1}},t.prototype.verify=function(t,e,i){try{return this.getKey().verify(t,g(e),i)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new ht,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version=ut,t}()})(),r.default})())}(jsencrypt_min)),jsencrypt_min.exports}(),CryptoJS=function requireCryptoJs4_1_1_min(){return hasRequiredCryptoJs4_1_1_min||(hasRequiredCryptoJs4_1_1_min=1,cryptoJs4_1_1_min$1.exports=function(){var n,o,s,a,h,t,e,l,r,i,c,f,d,u,p,S,x,b,A,H,z,_,v,g,y,B,w,k,m,C,D,E,R,M,F,P,W,O,I,U=U||function(h){var i;if("undefined"!=typeof window&&window.crypto&&(i=window.crypto),"undefined"!=typeof self&&self.crypto&&(i=self.crypto),!(i=!(i=!(i="undefined"!=typeof globalThis&&globalThis.crypto?globalThis.crypto:i)&&"undefined"!=typeof window&&window.msCrypto?window.msCrypto:i)&&void 0!==commonjsGlobal&&commonjsGlobal.crypto?commonjsGlobal.crypto:i))try{i=require$$0}catch(t){}var r=Object.create||function(t){return e.prototype=t,t=new e,e.prototype=null,t};function e(){}var t={},n=t.lib={},o=n.Base={extend:function(t){var e=r(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),(e.init.prototype=e).$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},l=n.WordArray=o.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||c).stringify(this)},concat:function(t){var e=this.words,r=t.words,i=this.sigBytes,n=t.sigBytes;if(this.clamp(),i%4)for(var o=0;o<n;o++){var s=r[o>>>2]>>>24-o%4*8&255;e[i+o>>>2]|=s<<24-(i+o)%4*8}else for(var c=0;c<n;c+=4)e[i+c>>>2]=r[c>>>2];return this.sigBytes+=n,this},clamp:function(){var t=this.words,e=this.sigBytes;t[e>>>2]&=4294967295<<32-e%4*8,t.length=h.ceil(e/4)},clone:function(){var t=o.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r<t;r+=4)e.push(function(){if(i){if("function"==typeof i.getRandomValues)try{return i.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof i.randomBytes)try{return i.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")}());return new l.init(e,t)}}),s=t.enc={},c=s.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var o=e[n>>>2]>>>24-n%4*8&255;i.push((o>>>4).toString(16)),i.push((15&o).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new l.init(r,e/2)}},a=s.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var o=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new l.init(r,e)}},f=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(a.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return a.parse(unescape(encodeURIComponent(t)))}},d=n.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new l.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=f.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(t){var e,r=this._data,i=r.words,n=r.sigBytes,o=this.blockSize,s=n/(4*o),c=(s=t?h.ceil(s):h.max((0|s)-this._minBufferSize,0))*o;if(n=h.min(4*c,n),c){for(var a=0;a<c;a+=o)this._doProcessBlock(i,a);e=i.splice(0,c),r.sigBytes-=n}return new l.init(e,n)},clone:function(){var t=o.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0}),u=(n.Hasher=d.extend({cfg:o.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){d.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(r){return function(t,e){return new r.init(e).finalize(t)}},_createHmacHelper:function(r){return function(t,e){return new u.HMAC.init(r,e).finalize(t)}}}),t.algo={});return t}(Math);function K(t,e,r){return t&e|~t&r}function X(t,e,r){return t&r|e&~r}function L(t,e){return t<<e|t>>>32-e}function j(t,e,r,i){var n,o=this._iv;o?(n=o.slice(0),this._iv=void 0):n=this._prevBlock,i.encryptBlock(n,0);for(var s=0;s<r;s++)t[e+s]^=n[s]}function T(t){var e,r,i;return 255&~(t>>24)?t+=1<<24:(r=t>>8&255,i=255&t,255==(e=t>>16&255)?(e=0,255===r?(r=0,255===i?i=0:++i):++r):++e,t=0,t+=e<<16,t+=r<<8,t+=i),t}function N(){for(var t=this._X,e=this._C,r=0;r<8;r++)E[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<E[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<E[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<E[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<E[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<E[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<E[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<E[6]>>>0?1:0)|0,this._b=e[7]>>>0<E[7]>>>0?1:0,r=0;r<8;r++){var i=t[r]+e[r],n=65535&i,o=i>>>16;R[r]=((n*n>>>17)+n*o>>>15)+o*o^((4294901760&i)*i|0)+((65535&i)*i|0)}t[0]=R[0]+(R[7]<<16|R[7]>>>16)+(R[6]<<16|R[6]>>>16)|0,t[1]=R[1]+(R[0]<<8|R[0]>>>24)+R[7]|0,t[2]=R[2]+(R[1]<<16|R[1]>>>16)+(R[0]<<16|R[0]>>>16)|0,t[3]=R[3]+(R[2]<<8|R[2]>>>24)+R[1]|0,t[4]=R[4]+(R[3]<<16|R[3]>>>16)+(R[2]<<16|R[2]>>>16)|0,t[5]=R[5]+(R[4]<<8|R[4]>>>24)+R[3]|0,t[6]=R[6]+(R[5]<<16|R[5]>>>16)+(R[4]<<16|R[4]>>>16)|0,t[7]=R[7]+(R[6]<<8|R[6]>>>24)+R[5]|0}function q(){for(var t=this._X,e=this._C,r=0;r<8;r++)O[r]=e[r];for(e[0]=e[0]+1295307597+this._b|0,e[1]=e[1]+3545052371+(e[0]>>>0<O[0]>>>0?1:0)|0,e[2]=e[2]+886263092+(e[1]>>>0<O[1]>>>0?1:0)|0,e[3]=e[3]+1295307597+(e[2]>>>0<O[2]>>>0?1:0)|0,e[4]=e[4]+3545052371+(e[3]>>>0<O[3]>>>0?1:0)|0,e[5]=e[5]+886263092+(e[4]>>>0<O[4]>>>0?1:0)|0,e[6]=e[6]+1295307597+(e[5]>>>0<O[5]>>>0?1:0)|0,e[7]=e[7]+3545052371+(e[6]>>>0<O[6]>>>0?1:0)|0,this._b=e[7]>>>0<O[7]>>>0?1:0,r=0;r<8;r++){var i=t[r]+e[r],n=65535&i,o=i>>>16;I[r]=((n*n>>>17)+n*o>>>15)+o*o^((4294901760&i)*i|0)+((65535&i)*i|0)}t[0]=I[0]+(I[7]<<16|I[7]>>>16)+(I[6]<<16|I[6]>>>16)|0,t[1]=I[1]+(I[0]<<8|I[0]>>>24)+I[7]|0,t[2]=I[2]+(I[1]<<16|I[1]>>>16)+(I[0]<<16|I[0]>>>16)|0,t[3]=I[3]+(I[2]<<8|I[2]>>>24)+I[1]|0,t[4]=I[4]+(I[3]<<16|I[3]>>>16)+(I[2]<<16|I[2]>>>16)|0,t[5]=I[5]+(I[4]<<8|I[4]>>>24)+I[3]|0,t[6]=I[6]+(I[5]<<16|I[5]>>>16)+(I[4]<<16|I[4]>>>16)|0,t[7]=I[7]+(I[6]<<8|I[6]>>>24)+I[5]|0}return F=(M=U).lib,n=F.Base,o=F.WordArray,(M=M.x64={}).Word=n.extend({init:function(t,e){this.high=t,this.low=e}}),M.WordArray=n.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,r=[],i=0;i<e;i++){var n=t[i];r.push(n.high),r.push(n.low)}return o.create(r,this.sigBytes)},clone:function(){for(var t=n.clone.call(this),e=t.words=this.words.slice(0),r=e.length,i=0;i<r;i++)e[i]=e[i].clone();return t}}),"function"==typeof ArrayBuffer&&(P=U.lib.WordArray,s=P.init,(P.init=function(t){if((t=(t=t instanceof ArrayBuffer?new Uint8Array(t):t)instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t)instanceof Uint8Array){for(var e=t.byteLength,r=[],i=0;i<e;i++)r[i>>>2]|=t[i]<<24-i%4*8;s.call(this,r,e)}else s.apply(this,arguments)}).prototype=P),function(){var t,n=(t=U).lib.WordArray;function s(t){return t<<8&4278255360|t>>>8&16711935}(t=t.enc).Utf16=t.Utf16BE={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n+=2){var o=e[n>>>2]>>>16-n%4*8&65535;i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>1]|=t.charCodeAt(i)<<16-i%2*16;return n.create(r,2*e)}},t.Utf16LE={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n+=2){var o=s(e[n>>>2]>>>16-n%4*8&65535);i.push(String.fromCharCode(o))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>1]|=s(t.charCodeAt(i)<<16-i%2*16);return n.create(r,2*e)}}}(),a=(w=U).lib.WordArray,w.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp();for(var n=[],o=0;o<r;o+=3)for(var s=(e[o>>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c<r;c++)n.push(i.charAt(s>>>6*(3-c)&63));var a=i.charAt(64);if(a)for(;n.length%4;)n.push(a);return n.join("")},parse:function(t){var e=t.length,r=this._map;if(!(i=this._reverseMap))for(var i=this._reverseMap=[],n=0;n<r.length;n++)i[r.charCodeAt(n)]=n;var o=r.charAt(64);return!o||-1!==(o=t.indexOf(o))&&(e=o),function(t,e,r){for(var i=[],n=0,o=0;o<e;o++){var s,c;o%4&&(s=r[t.charCodeAt(o-1)]<<o%4*2,c=r[t.charCodeAt(o)]>>>6-o%4*2,c|=s,i[n>>>2]|=c<<24-n%4*8,n++)}return a.create(i,n)}(t,e,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},h=(F=U).lib.WordArray,F.enc.Base64url={stringify:function(t,e=!0){var r=t.words,i=t.sigBytes,n=e?this._safe_map:this._map;t.clamp();for(var o=[],s=0;s<i;s+=3)for(var c=(r[s>>>2]>>>24-s%4*8&255)<<16|(r[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|r[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<i;a++)o.push(n.charAt(c>>>6*(3-a)&63));var h=n.charAt(64);if(h)for(;o.length%4;)o.push(h);return o.join("")},parse:function(t,e=!0){var r=t.length,i=e?this._safe_map:this._map;if(!(n=this._reverseMap))for(var n=this._reverseMap=[],o=0;o<i.length;o++)n[i.charCodeAt(o)]=o;return!(e=i.charAt(64))||-1!==(e=t.indexOf(e))&&(r=e),function(t,e,r){for(var i=[],n=0,o=0;o<e;o++){var s,c;o%4&&(s=r[t.charCodeAt(o-1)]<<o%4*2,c=r[t.charCodeAt(o)]>>>6-o%4*2,c|=s,i[n>>>2]|=c<<24-n%4*8,n++)}return h.create(i,n)}(t,r,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_safe_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"},function(a){var t=U,r=(e=t.lib).WordArray,i=e.Hasher,e=t.algo,A=[];function H(t,e,r,i,n,o,s){return((s=t+(e&r|~e&i)+n+s)<<o|s>>>32-o)+e}function z(t,e,r,i,n,o,s){return((s=t+(e&i|r&~i)+n+s)<<o|s>>>32-o)+e}function C(t,e,r,i,n,o,s){return((s=t+(e^r^i)+n+s)<<o|s>>>32-o)+e}function D(t,e,r,i,n,o,s){return((s=t+(r^(e|~i))+n+s)<<o|s>>>32-o)+e}!function(){for(var t=0;t<64;t++)A[t]=4294967296*a.abs(a.sin(t+1))|0}(),e=e.MD5=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var i=e+r,n=t[i];t[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o=this._hash.words,s=t[e+0],c=t[e+1],a=t[e+2],h=t[e+3],l=t[e+4],f=t[e+5],d=t[e+6],u=t[e+7],p=t[e+8],_=t[e+9],y=t[e+10],v=t[e+11],g=t[e+12],B=t[e+13],w=t[e+14],k=t[e+15],m=H(m=o[0],b=o[1],x=o[2],S=o[3],s,7,A[0]),S=H(S,m,b,x,c,12,A[1]),x=H(x,S,m,b,a,17,A[2]),b=H(b,x,S,m,h,22,A[3]);m=H(m,b,x,S,l,7,A[4]),S=H(S,m,b,x,f,12,A[5]),x=H(x,S,m,b,d,17,A[6]),b=H(b,x,S,m,u,22,A[7]),m=H(m,b,x,S,p,7,A[8]),S=H(S,m,b,x,_,12,A[9]),x=H(x,S,m,b,y,17,A[10]),b=H(b,x,S,m,v,22,A[11]),m=H(m,b,x,S,g,7,A[12]),S=H(S,m,b,x,B,12,A[13]),x=H(x,S,m,b,w,17,A[14]),m=z(m,b=H(b,x,S,m,k,22,A[15]),x,S,c,5,A[16]),S=z(S,m,b,x,d,9,A[17]),x=z(x,S,m,b,v,14,A[18]),b=z(b,x,S,m,s,20,A[19]),m=z(m,b,x,S,f,5,A[20]),S=z(S,m,b,x,y,9,A[21]),x=z(x,S,m,b,k,14,A[22]),b=z(b,x,S,m,l,20,A[23]),m=z(m,b,x,S,_,5,A[24]),S=z(S,m,b,x,w,9,A[25]),x=z(x,S,m,b,h,14,A[26]),b=z(b,x,S,m,p,20,A[27]),m=z(m,b,x,S,B,5,A[28]),S=z(S,m,b,x,a,9,A[29]),x=z(x,S,m,b,u,14,A[30]),m=C(m,b=z(b,x,S,m,g,20,A[31]),x,S,f,4,A[32]),S=C(S,m,b,x,p,11,A[33]),x=C(x,S,m,b,v,16,A[34]),b=C(b,x,S,m,w,23,A[35]),m=C(m,b,x,S,c,4,A[36]),S=C(S,m,b,x,l,11,A[37]),x=C(x,S,m,b,u,16,A[38]),b=C(b,x,S,m,y,23,A[39]),m=C(m,b,x,S,B,4,A[40]),S=C(S,m,b,x,s,11,A[41]),x=C(x,S,m,b,h,16,A[42]),b=C(b,x,S,m,d,23,A[43]),m=C(m,b,x,S,_,4,A[44]),S=C(S,m,b,x,g,11,A[45]),x=C(x,S,m,b,k,16,A[46]),m=D(m,b=C(b,x,S,m,a,23,A[47]),x,S,s,6,A[48]),S=D(S,m,b,x,u,10,A[49]),x=D(x,S,m,b,w,15,A[50]),b=D(b,x,S,m,f,21,A[51]),m=D(m,b,x,S,g,6,A[52]),S=D(S,m,b,x,h,10,A[53]),x=D(x,S,m,b,y,15,A[54]),b=D(b,x,S,m,c,21,A[55]),m=D(m,b,x,S,p,6,A[56]),S=D(S,m,b,x,k,10,A[57]),x=D(x,S,m,b,d,15,A[58]),b=D(b,x,S,m,B,21,A[59]),m=D(m,b,x,S,l,6,A[60]),S=D(S,m,b,x,v,10,A[61]),x=D(x,S,m,b,a,15,A[62]),b=D(b,x,S,m,_,21,A[63]),o[0]=o[0]+m|0,o[1]=o[1]+b|0,o[2]=o[2]+x|0,o[3]=o[3]+S|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;e[i>>>5]|=128<<24-i%32;var n=a.floor(r/4294967296);e[15+(64+i>>>9<<4)]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8),e[14+(64+i>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var o=(e=this._hash).words,s=0;s<4;s++){var c=o[s];o[s]=16711935&(c<<8|c>>>24)|4278255360&(c<<24|c>>>8)}return e},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),t.MD5=i._createHelper(e),t.HmacMD5=i._createHmacHelper(e)}(Math),P=(M=U).lib,t=P.WordArray,e=P.Hasher,P=M.algo,l=[],P=P.SHA1=e.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],c=r[4],a=0;a<80;a++){a<16?l[a]=0|t[e+a]:(h=l[a-3]^l[a-8]^l[a-14]^l[a-16],l[a]=h<<1|h>>>31);var h=(i<<5|i>>>27)+c+l[a];h+=a<20?1518500249+(n&o|~n&s):a<40?1859775393+(n^o^s):a<60?(n&o|n&s|o&s)-1894007588:(n^o^s)-899497514,c=s,s=o,o=n<<30|n>>>2,n=i,i=h}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+c|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(64+i>>>9<<4)]=Math.floor(r/4294967296),e[15+(64+i>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=e.clone.call(this);return t._hash=this._hash.clone(),t}}),M.SHA1=e._createHelper(P),M.HmacSHA1=e._createHmacHelper(P),function(n){var t=U,r=(e=t.lib).WordArray,i=e.Hasher,e=t.algo,o=[],p=[];!function(){function t(t){return 4294967296*(t-(0|t))|0}for(var e=2,r=0;r<64;)!function(t){for(var e=n.sqrt(t),r=2;r<=e;r++)if(!(t%r))return;return 1}(e)||(r<8&&(o[r]=t(n.pow(e,.5))),p[r]=t(n.pow(e,1/3)),r++),e++}();var _=[];e=e.SHA256=i.extend({_doReset:function(){this._hash=new r.init(o.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],o=r[2],s=r[3],c=r[4],a=r[5],h=r[6],l=r[7],f=0;f<64;f++){f<16?_[f]=0|t[e+f]:(d=_[f-15],u=_[f-2],_[f]=((d<<25|d>>>7)^(d<<14|d>>>18)^d>>>3)+_[f-7]+((u<<15|u>>>17)^(u<<13|u>>>19)^u>>>10)+_[f-16]);var d=i&n^i&o^n&o,u=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&a^~c&h)+p[f]+_[f];l=h,h=a,a=c,c=s+u|0,s=o,o=n,n=i,i=u+(((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+d)|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+o|0,r[3]=r[3]+s|0,r[4]=r[4]+c|0,r[5]=r[5]+a|0,r[6]=r[6]+h|0,r[7]=r[7]+l|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(64+i>>>9<<4)]=n.floor(r/4294967296),e[15+(64+i>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}}),t.SHA256=i._createHelper(e),t.HmacSHA256=i._createHmacHelper(e)}(Math),r=(w=U).lib.WordArray,F=w.algo,i=F.SHA256,F=F.SHA224=i.extend({_doReset:function(){this._hash=new r.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=4,t}}),w.SHA224=i._createHelper(F),w.HmacSHA224=i._createHmacHelper(F),function(){var t=U,e=t.lib.Hasher,i=(r=t.x64).Word,n=r.WordArray,r=t.algo;function o(){return i.create.apply(i,arguments)}var t1=[o(1116352408,3609767458),o(1899447441,602891725),o(3049323471,3964484399),o(3921009573,2173295548),o(961987163,4081628472),o(1508970993,3053834265),o(2453635748,2937671579),o(2870763221,3664609560),o(3624381080,2734883394),o(310598401,1164996542),o(607225278,1323610764),o(1426881987,3590304994),o(1925078388,4068182383),o(2162078206,991336113),o(2614888103,633803317),o(3248222580,3479774868),o(3835390401,2666613458),o(4022224774,944711139),o(264347078,2341262773),o(604807628,2007800933),o(770255983,1495990901),o(1249150122,1856431235),o(1555081692,3175218132),o(1996064986,2198950837),o(2554220882,3999719339),o(2821834349,766784016),o(2952996808,2566594879),o(3210313671,3203337956),o(3336571891,1034457026),o(3584528711,2466948901),o(113926993,3758326383),o(338241895,168717936),o(666307205,1188179964),o(773529912,1546045734),o(1294757372,1522805485),o(1396182291,2643833823),o(1695183700,2343527390),o(1986661051,1014477480),o(2177026350,1206759142),o(2456956037,344077627),o(2730485921,1290863460),o(2820302411,3158454273),o(3259730800,3505952657),o(3345764771,106217008),o(3516065817,3606008344),o(3600352804,1432725776),o(4094571909,1467031594),o(275423344,851169720),o(430227734,3100823752),o(506948616,1363258195),o(659060556,3750685593),o(883997877,3785050280),o(958139571,3318307427),o(1322822218,3812723403),o(1537002063,2003034995),o(1747873779,3602036899),o(1955562222,1575990012),o(2024104815,1125592928),o(2227730452,2716904306),o(2361852424,442776044),o(2428436474,593698344),o(2756734187,3733110249),o(3204031479,2999351573),o(3329325298,3815920427),o(3391569614,3928383900),o(3515267271,566280711),o(3940187606,3454069534),o(4118630271,4000239992),o(116418474,1914138554),o(174292421,2731055270),o(289380356,3203993006),o(460393269,320620315),o(685471733,587496836),o(852142971,1086792851),o(1017036298,365543100),o(1126000580,2618297676),o(1288033470,3409855158),o(1501505948,4234509866),o(1607167915,987167468),o(1816402316,1246189591)],e1=[];!function(){for(var t=0;t<80;t++)e1[t]=o()}(),r=r.SHA512=e.extend({_doReset:function(){this._hash=new n.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r,i=(r=this._hash.words)[0],n=r[1],o=r[2],s=r[3],c=r[4],a=r[5],h=r[6],l=r[7],f=i.high,d=i.low,u=n.high,p=n.low,_=o.high,y=o.low,v=s.high,g=s.low,B=c.high,w=c.low,k=a.high,m=a.low,S=h.high,x=h.low,b=l.high,A=f,H=d,z=u,C=p,D=_,E=y,R=v,M=g,F=B,P=w,W=k,O=m,I=S,U=x,K=b,X=r=l.low,L=0;L<80;L++){var j,T,N=e1[L];L<16?(T=N.high=0|t[e+2*L],j=N.low=0|t[e+2*L+1]):($=(q=e1[L-15]).high,J=q.low,G=(Q=e1[L-2]).high,V=Q.low,Z=(Y=e1[L-7]).high,q=Y.low,Y=(Q=e1[L-16]).high,T=(T=(($>>>1|J<<31)^($>>>8|J<<24)^$>>>7)+Z+((j=(Z=(J>>>1|$<<31)^(J>>>8|$<<24)^(J>>>7|$<<25))+q)>>>0<Z>>>0?1:0))+((G>>>19|V<<13)^(G<<3|V>>>29)^G>>>6)+((j+=J=(V>>>19|G<<13)^(V<<3|G>>>29)^(V>>>6|G<<26))>>>0<J>>>0?1:0),j+=$=Q.low,N.high=T=T+Y+(j>>>0<$>>>0?1:0),N.low=j);var q=F&W^~F&I,Z=P&O^~P&U,V=A&z^A&D^z&D,G=(H>>>28|A<<4)^(H<<30|A>>>2)^(H<<25|A>>>7),Q=(J=t1[L]).high,Y=J.low,$=X+((P>>>14|F<<18)^(P>>>18|F<<14)^(P<<23|F>>>9)),J=(N=K+((F>>>14|P<<18)^(F>>>18|P<<14)^(F<<23|P>>>9))+($>>>0<X>>>0?1:0),G+(H&C^H&E^C&E));K=I,X=U,I=W,U=O,W=F,O=P,F=R+(N=(N=(N=N+q+(($+=Z)>>>0<Z>>>0?1:0))+Q+(($+=Y)>>>0<Y>>>0?1:0))+T+(($+=j)>>>0<j>>>0?1:0))+((P=M+$|0)>>>0<M>>>0?1:0)|0,R=D,M=E,D=z,E=C,z=A,C=H,A=N+(((A>>>28|H<<4)^(A<<30|H>>>2)^(A<<25|H>>>7))+V+(J>>>0<G>>>0?1:0))+((H=$+J|0)>>>0<$>>>0?1:0)|0}d=i.low=d+H,i.high=f+A+(d>>>0<H>>>0?1:0),p=n.low=p+C,n.high=u+z+(p>>>0<C>>>0?1:0),y=o.low=y+E,o.high=_+D+(y>>>0<E>>>0?1:0),g=s.low=g+M,s.high=v+R+(g>>>0<M>>>0?1:0),w=c.low=w+P,c.high=B+F+(w>>>0<P>>>0?1:0),m=a.low=m+O,a.high=k+W+(m>>>0<O>>>0?1:0),x=h.low=x+U,h.high=S+I+(x>>>0<U>>>0?1:0),r=l.low=r+X,l.high=b+K+(r>>>0<X>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(128+i>>>10<<5)]=Math.floor(r/4294967296),e[31+(128+i>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=e.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),t.SHA512=e._createHelper(r),t.HmacSHA512=e._createHmacHelper(r)}(),P=(M=U).x64,c=P.Word,f=P.WordArray,P=M.algo,d=P.SHA512,P=P.SHA384=d.extend({_doReset:function(){this._hash=new f.init([new c.init(3418070365,3238371032),new c.init(1654270250,914150663),new c.init(2438529370,812702999),new c.init(355462360,4144912697),new c.init(1731405415,4290775857),new c.init(2394180231,1750603025),new c.init(3675008525,1694076839),new c.init(1203062813,3204075428)])},_doFinalize:function(){var t=d._doFinalize.call(this);return t.sigBytes-=16,t}}),M.SHA384=d._createHelper(P),M.HmacSHA384=d._createHmacHelper(P),function(l){var t=U,f=(e=t.lib).WordArray,i=e.Hasher,d=t.x64.Word,e=t.algo,A=[],H=[],z=[];!function(){for(var t=1,e=0,r=0;r<24;r++){A[t+5*e]=(r+1)*(r+2)/2%64;var i=(2*t+3*e)%5;t=e%5,e=i}for(t=0;t<5;t++)for(e=0;e<5;e++)H[t+5*e]=e+(2*t+3*e)%5*5;for(var n=1,o=0;o<24;o++){for(var s,c=0,a=0,h=0;h<7;h++)1&n&&((s=(1<<h)-1)<32?a^=1<<s:c^=1<<s-32),128&n?n=n<<1^113:n<<=1;z[o]=d.create(c,a)}}();var C=[];!function(){for(var t=0;t<25;t++)C[t]=d.create()}(),e=e.SHA3=i.extend({cfg:i.cfg.extend({outputLength:512}),_doReset:function(){for(var t=this._state=[],e=0;e<25;e++)t[e]=new d.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(t,e){for(var r=this._state,i=this.blockSize/2,n=0;n<i;n++){var o=t[e+2*n],s=t[e+2*n+1];o=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),(m=r[n]).high^=s=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),m.low^=o}for(var c=0;c<24;c++){for(var a=0;a<5;a++){for(var h=0,l=0,f=0;f<5;f++)h^=(m=r[a+5*f]).high,l^=m.low;var d=C[a];d.high=h,d.low=l}for(a=0;a<5;a++){var u=C[(a+4)%5],_=(p=C[(a+1)%5]).high,p=p.low;for(h=u.high^(_<<1|p>>>31),l=u.low^(p<<1|_>>>31),f=0;f<5;f++)(m=r[a+5*f]).high^=h,m.low^=l}for(var y=1;y<25;y++){var v=(m=r[y]).high,g=m.low,B=A[y];l=B<32?(h=v<<B|g>>>32-B,g<<B|v>>>32-B):(h=g<<B-32|v>>>64-B,v<<B-32|g>>>64-B),(B=C[H[y]]).high=h,B.low=l}var w=C[0],k=r[0];for(w.high=k.high,w.low=k.low,a=0;a<5;a++)for(f=0;f<5;f++){var m=r[y=a+5*f],S=C[y],x=C[(a+1)%5+5*f],b=C[(a+2)%5+5*f];m.high=S.high^~x.high&b.high,m.low=S.low^~x.low&b.low}m=r[0],k=z[c],m.high^=k.high,m.low^=k.low}},_doFinalize:function(){var t=this._data,e=t.words,r=(this._nDataBytes,8*t.sigBytes),i=32*this.blockSize;e[r>>>5]|=1<<24-r%32,e[(l.ceil((1+r)/i)*i>>>5)-1]|=128,t.sigBytes=4*e.length,this._process();for(var n=this._state,o=(e=this.cfg.outputLength/8)/8,s=[],c=0;c<o;c++){var h=(a=n[c]).high,a=a.low;h=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8),s.push(a=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8)),s.push(h)}return new f.init(s,e)},clone:function(){for(var t=i.clone.call(this),e=t._state=this._state.slice(0),r=0;r<25;r++)e[r]=e[r].clone();return t}}),t.SHA3=i._createHelper(e),t.HmacSHA3=i._createHmacHelper(e)}(Math),F=(w=U).lib,u=F.WordArray,p=F.Hasher,F=w.algo,S=u.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),x=u.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),b=u.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),A=u.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),H=u.create([0,1518500249,1859775393,2400959708,2840853838]),z=u.create([1352829926,1548603684,1836072691,2053994217,0]),F=F.RIPEMD160=p.extend({_doReset:function(){this._hash=u.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;r<16;r++){var i=e+r,n=t[i];t[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8)}var o,s,c,a,h,l,f=this._hash.words,d=H.words,u=z.words,p=S.words,_=x.words,y=b.words,v=A.words,g=o=f[0],B=s=f[1],w=c=f[2],k=a=f[3],m=h=f[4];for(r=0;r<80;r+=1)l=o+t[e+p[r]]|0,l+=r<16?(s^c^a)+d[0]:r<32?K(s,c,a)+d[1]:r<48?((s|~c)^a)+d[2]:r<64?X(s,c,a)+d[3]:(s^(c|~a))+d[4],l=(l=L(l|=0,y[r]))+h|0,o=h,h=a,a=L(c,10),c=s,s=l,l=g+t[e+_[r]]|0,l+=r<16?(B^(w|~k))+u[0]:r<32?X(B,w,k)+u[1]:r<48?((B|~w)^k)+u[2]:r<64?K(B,w,k)+u[3]:(B^w^k)+u[4],l=(l=L(l|=0,v[r]))+m|0,g=m,m=k,k=L(w,10),w=B,B=l;l=f[1]+c+k|0,f[1]=f[2]+a+m|0,f[2]=f[3]+h+g|0,f[3]=f[4]+o+B|0,f[4]=f[0]+s+w|0,f[0]=l},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;e[i>>>5]|=128<<24-i%32,e[14+(64+i>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process();for(var n=(e=this._hash).words,o=0;o<5;o++){var s=n[o];n[o]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8)}return e},clone:function(){var t=p.clone.call(this);return t._hash=this._hash.clone(),t}}),w.RIPEMD160=p._createHelper(F),w.HmacRIPEMD160=p._createHmacHelper(F),P=(M=U).lib.Base,_=M.enc.Utf8,M.algo.HMAC=P.extend({init:function(t,e){t=this._hasher=new t.init,"string"==typeof e&&(e=_.parse(e));var r=t.blockSize,i=4*r;(e=e.sigBytes>i?t.finalize(e):e).clamp(),t=this._oKey=e.clone(),e=this._iKey=e.clone();for(var n=t.words,o=e.words,s=0;s<r;s++)n[s]^=1549556828,o[s]^=909522486;t.sigBytes=e.sigBytes=i,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}}),F=(w=U).lib,M=F.Base,v=F.WordArray,P=w.algo,F=P.SHA1,g=P.HMAC,y=P.PBKDF2=M.extend({cfg:M.extend({keySize:4,hasher:F,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r=this.cfg,i=g.create(r.hasher,t),n=v.create(),o=v.create([1]),s=n.words,c=o.words,a=r.keySize,h=r.iterations;s.length<a;){var l=i.update(e).finalize(o);i.reset();for(var f=l.words,d=f.length,u=l,p=1;p<h;p++){u=i.finalize(u),i.reset();for(var _=u.words,y=0;y<d;y++)f[y]^=_[y]}n.concat(l),c[0]++}return n.sigBytes=4*a,n}}),w.PBKDF2=function(t,e,r){return y.create(r).compute(t,e)},M=(P=U).lib,F=M.Base,B=M.WordArray,w=P.algo,M=w.MD5,k=w.EvpKDF=F.extend({cfg:F.extend({keySize:4,hasher:M,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,n=i.hasher.create(),o=B.create(),s=o.words,c=i.keySize,a=i.iterations;s.length<c;){r&&n.update(r),r=n.update(t).finalize(e),n.reset();for(var h=1;h<a;h++)r=n.finalize(r),n.reset();o.concat(r)}return o.sigBytes=4*c,o}}),P.EvpKDF=function(t,e,r){return k.create(r).compute(t,e)},U.lib.Cipher||function(){var e=(t=U).lib,r=e.Base,s=e.WordArray,i=e.BufferedBlockAlgorithm,o=((n=t.enc).Utf8,n.Base64),c=t.algo.EvpKDF,a=e.Cipher=i.extend({cfg:r.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(i){return{encrypt:function(t,e,r){return h(e).encrypt(i,t,e,r)},decrypt:function(t,e,r){return h(e).decrypt(i,t,e,r)}}}});function h(t){return"string"==typeof t?p:u}e.StreamCipher=a.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var l=t.mode={},n=e.BlockCipherMode=r.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}});function f(t,e,r){var i,n=this._iv;n?(i=n,this._iv=void 0):i=this._prevBlock;for(var o=0;o<r;o++)t[e+o]^=i[o]}n=l.CBC=((l=n.extend()).Encryptor=l.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;f.call(this,t,e,i),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),l.Decryptor=l.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=t.slice(e,e+i);r.decryptBlock(t,e),f.call(this,t,e,i),this._prevBlock=n}}),l),l=(t.pad={}).Pkcs7={pad:function(t,e){for(var r=(e*=4)-t.sigBytes%e,i=r<<24|r<<16|r<<8|r,n=[],o=0;o<r;o+=4)n.push(i);e=s.create(n,r),t.concat(e)},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}};var d=(e.BlockCipher=a.extend({cfg:a.cfg.extend({mode:n,padding:l}),reset:function(){var t;a.reset.call(this);var r=(e=this.cfg).iv,e=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=e.createEncryptor:(t=e.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(e,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),e.CipherParams=r.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),u=(l=(t.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return(e=(t=t.salt)?s.create([1398893684,1701076831]).concat(t).concat(e):e).toString(o)},parse:function(t){var e,r=o.parse(t);return 1398893684==(t=r.words)[0]&&1701076831==t[1]&&(e=s.create(t.slice(2,4)),t.splice(0,4),r.sigBytes-=16),d.create({ciphertext:r,salt:e})}},e.SerializableCipher=r.extend({cfg:r.extend({format:l}),encrypt:function(t,e,r,i){i=this.cfg.extend(i),e=(n=t.createEncryptor(r,i)).finalize(e);var n=n.cfg;return d.create({ciphertext:e,key:r,iv:n.iv,algorithm:t,mode:n.mode,padding:n.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(r,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),t=(t.kdf={}).OpenSSL={execute:function(t,e,r,i){return i=i||s.random(8),t=c.create({keySize:e+r}).compute(t,i),r=s.create(t.words.slice(e),4*r),t.sigBytes=4*e,d.create({key:t,iv:r,salt:i})}},p=e.PasswordBasedCipher=u.extend({cfg:u.cfg.extend({kdf:t}),encrypt:function(t,e,r,i){return r=(i=this.cfg.extend(i)).kdf.execute(r,t.keySize,t.ivSize),i.iv=r.iv,(i=u.encrypt.call(this,t,e,r.key,i)).mixIn(r),i},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),r=i.kdf.execute(r,t.keySize,t.ivSize,e.salt),i.iv=r.iv,u.decrypt.call(this,t,e,r.key,i)}})}(),U.mode.CFB=((F=U.lib.BlockCipherMode.extend()).Encryptor=F.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;j.call(this,t,e,i,r),this._prevBlock=t.slice(e,e+i)}}),F.Decryptor=F.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=t.slice(e,e+i);j.call(this,t,e,i,r),this._prevBlock=n}}),F),U.mode.CTR=(M=U.lib.BlockCipherMode.extend(),P=M.Encryptor=M.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0);var s=o.slice(0);r.encryptBlock(s,0),o[i-1]=o[i-1]+1|0;for(var c=0;c<i;c++)t[e+c]^=s[c]}}),M.Decryptor=P,M),U.mode.CTRGladman=(F=U.lib.BlockCipherMode.extend(),P=F.Encryptor=F.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._counter;n&&(o=this._counter=n.slice(0),this._iv=void 0),0===((n=o)[0]=T(n[0]))&&(n[1]=T(n[1]));var s=o.slice(0);r.encryptBlock(s,0);for(var c=0;c<i;c++)t[e+c]^=s[c]}}),F.Decryptor=P,F),U.mode.OFB=(M=U.lib.BlockCipherMode.extend(),P=M.Encryptor=M.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=this._iv,o=this._keystream;n&&(o=this._keystream=n.slice(0),this._iv=void 0),r.encryptBlock(o,0);for(var s=0;s<i;s++)t[e+s]^=o[s]}}),M.Decryptor=P,M),U.mode.ECB=((F=U.lib.BlockCipherMode.extend()).Encryptor=F.extend({processBlock:function(t,e){this._cipher.encryptBlock(t,e)}}),F.Decryptor=F.extend({processBlock:function(t,e){this._cipher.decryptBlock(t,e)}}),F),U.pad.AnsiX923={pad:function(t,e){var r=(r=t.sigBytes)+(e=(e*=4)-r%e)-1;t.clamp(),t.words[r>>>2]|=e<<24-r%4*8,t.sigBytes+=e},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},U.pad.Iso10126={pad:function(t,e){e*=4,e-=t.sigBytes%e,t.concat(U.lib.WordArray.random(e-1)).concat(U.lib.WordArray.create([e<<24],1))},unpad:function(t){var e=255&t.words[t.sigBytes-1>>>2];t.sigBytes-=e}},U.pad.Iso97971={pad:function(t,e){t.concat(U.lib.WordArray.create([2147483648],1)),U.pad.ZeroPadding.pad(t,e)},unpad:function(t){U.pad.ZeroPadding.unpad(t),t.sigBytes--}},U.pad.ZeroPadding={pad:function(t,e){e*=4,t.clamp(),t.sigBytes+=e-(t.sigBytes%e||e)},unpad:function(t){var e=t.words,r=t.sigBytes-1;for(r=t.sigBytes-1;0<=r;r--)if(e[r>>>2]>>>24-r%4*8&255){t.sigBytes=r+1;break}}},U.pad.NoPadding={pad:function(){},unpad:function(){}},m=(P=U).lib.CipherParams,C=P.enc.Hex,P.format.Hex={stringify:function(t){return t.ciphertext.toString(C)},parse:function(t){return t=C.parse(t),m.create({ciphertext:t})}},function(){var t=U,e=t.lib.BlockCipher,r=t.algo,h=[],l=[],f=[],d=[],u=[],p=[],_=[],y=[],v=[],g=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,i=0;for(e=0;e<256;e++){var n=i^i<<1^i<<2^i<<3^i<<4;h[r]=n=n>>>8^255&n^99;var o=t[l[n]=r],s=t[o],c=t[s],a=257*t[n]^16843008*n;f[r]=a<<24|a>>>8,d[r]=a<<16|a>>>16,u[r]=a<<8|a>>>24,p[r]=a,_[n]=(a=16843009*c^65537*s^257*o^16843008*r)<<24|a>>>8,y[n]=a<<16|a>>>16,v[n]=a<<8|a>>>24,g[n]=a,r?(r=o^t[t[t[c^o]]],i^=t[t[i]]):r=i=1}}();var B=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*(1+(this._nRounds=6+r)),n=this._keySchedule=[],o=0;o<i;o++)o<r?n[o]=e[o]:(a=n[o-1],o%r?6<r&&o%r==4&&(a=h[a>>>24]<<24|h[a>>>16&255]<<16|h[a>>>8&255]<<8|h[255&a]):(a=h[(a=a<<8|a>>>24)>>>24]<<24|h[a>>>16&255]<<16|h[a>>>8&255]<<8|h[255&a],a^=B[o/r|0]<<24),n[o]=n[o-r]^a);for(var s=this._invKeySchedule=[],c=0;c<i;c++){var a;o=i-c,a=c%4?n[o]:n[o-4],s[c]=c<4||o<=4?a:_[h[a>>>24]]^y[h[a>>>16&255]]^v[h[a>>>8&255]]^g[h[255&a]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,f,d,u,p,h)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,_,y,v,g,l),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,n,o,s,c){for(var a=this._nRounds,h=t[e]^r[0],l=t[e+1]^r[1],f=t[e+2]^r[2],d=t[e+3]^r[3],u=4,p=1;p<a;p++){var _=i[h>>>24]^n[l>>>16&255]^o[f>>>8&255]^s[255&d]^r[u++],y=i[l>>>24]^n[f>>>16&255]^o[d>>>8&255]^s[255&h]^r[u++],v=i[f>>>24]^n[d>>>16&255]^o[h>>>8&255]^s[255&l]^r[u++],g=i[d>>>24]^n[h>>>16&255]^o[l>>>8&255]^s[255&f]^r[u++];h=_,l=y,f=v,d=g}_=(c[h>>>24]<<24|c[l>>>16&255]<<16|c[f>>>8&255]<<8|c[255&d])^r[u++],y=(c[l>>>24]<<24|c[f>>>16&255]<<16|c[d>>>8&255]<<8|c[255&h])^r[u++],v=(c[f>>>24]<<24|c[d>>>16&255]<<16|c[h>>>8&255]<<8|c[255&l])^r[u++],g=(c[d>>>24]<<24|c[h>>>16&255]<<16|c[l>>>8&255]<<8|c[255&f])^r[u++],t[e]=_,t[e+1]=y,t[e+2]=v,t[e+3]=g},keySize:8}),t.AES=e._createHelper(r)}(),function(){var t=U,i=(e=t.lib).WordArray,r=e.BlockCipher,e=t.algo,h=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],l=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],f=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],d=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],u=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],n=e.DES=r.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;r<56;r++){var i=h[r]-1;e[r]=t[i>>>5]>>>31-i%32&1}for(var n=this._subKeys=[],o=0;o<16;o++){var s=n[o]=[],c=f[o];for(r=0;r<24;r++)s[r/6|0]|=e[(l[r]-1+c)%28]<<31-r%6,s[4+(r/6|0)]|=e[28+(l[r+24]-1+c)%28]<<31-r%6;for(s[0]=s[0]<<1|s[0]>>>31,r=1;r<7;r++)s[r]=s[r]>>>4*(r-1)+3;s[7]=s[7]<<5|s[7]>>>27}var a=this._invSubKeys=[];for(r=0;r<16;r++)a[r]=n[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(t,e,r){this._lBlock=t[e],this._rBlock=t[e+1],p.call(this,4,252645135),p.call(this,16,65535),_.call(this,2,858993459),_.call(this,8,16711935),p.call(this,1,1431655765);for(var i=0;i<16;i++){for(var n=r[i],o=this._lBlock,s=this._rBlock,c=0,a=0;a<8;a++)c|=d[a][((s^n[a])&u[a])>>>0];this._lBlock=s,this._rBlock=o^c}var h=this._lBlock;this._lBlock=this._rBlock,this._rBlock=h,p.call(this,1,1431655765),_.call(this,8,16711935),_.call(this,2,858993459),p.call(this,16,65535),p.call(this,4,252645135),t[e]=this._lBlock,t[e+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});function p(t,e){e=(this._lBlock>>>t^this._rBlock)&e,this._rBlock^=e,this._lBlock^=e<<t}function _(t,e){e=(this._rBlock>>>t^this._lBlock)&e,this._lBlock^=e,this._rBlock^=e<<t}t.DES=r._createHelper(n),e=e.TripleDES=r.extend({_doReset:function(){if(2!==(t=this._key.words).length&&4!==t.length&&t.length<6)throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");var e=t.slice(0,2),r=t.length<4?t.slice(0,2):t.slice(2,4),t=t.length<6?t.slice(0,2):t.slice(4,6);this._des1=n.createEncryptor(i.create(e)),this._des2=n.createEncryptor(i.create(r)),this._des3=n.createEncryptor(i.create(t))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),t.TripleDES=r._createHelper(e)}(),function(){var t=U,e=t.lib.StreamCipher,r=t.algo,i=r.RC4=e.extend({_doReset:function(){for(var t=this._key,e=t.words,r=t.sigBytes,i=this._S=[],n=0;n<256;n++)i[n]=n;n=0;for(var o=0;n<256;n++){var s=e[(s=n%r)>>>2]>>>24-s%4*8&255;o=(o+i[n]+s)%256,s=i[n],i[n]=i[o],i[o]=s}this._i=this._j=0},_doProcessBlock:function(t,e){t[e]^=n.call(this)},keySize:8,ivSize:0});function n(){for(var t=this._S,e=this._i,r=this._j,i=0,n=0;n<4;n++){r=(r+t[e=(e+1)%256])%256;var o=t[e];t[e]=t[r],t[r]=o,i|=t[(t[e]+t[r])%256]<<24-8*n}return this._i=e,this._j=r,i}t.RC4=e._createHelper(i),r=r.RC4Drop=i.extend({cfg:i.cfg.extend({drop:192}),_doReset:function(){i._doReset.call(this);for(var t=this.cfg.drop;0<t;t--)n.call(this)}}),t.RC4Drop=e._createHelper(r)}(),F=(M=U).lib.StreamCipher,P=M.algo,D=[],E=[],R=[],P=P.Rabbit=F.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=0;r<4;r++)t[r]=16711935&(t[r]<<8|t[r]>>>24)|4278255360&(t[r]<<24|t[r]>>>8);var i=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],n=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]];for(r=this._b=0;r<4;r++)N.call(this);for(r=0;r<8;r++)n[r]^=i[r+4&7];if(e){var o,s=(e=16711935&((s=(o=e.words)[0])<<8|s>>>24)|4278255360&(s<<24|s>>>8))>>>16|4294901760&(o=16711935&((c=o[1])<<8|c>>>24)|4278255360&(c<<24|c>>>8)),c=o<<16|65535&e;for(n[0]^=e,n[1]^=s,n[2]^=o,n[3]^=c,n[4]^=e,n[5]^=s,n[6]^=o,n[7]^=c,r=0;r<4;r++)N.call(this)}},_doProcessBlock:function(t,e){var r=this._X;N.call(this),D[0]=r[0]^r[5]>>>16^r[3]<<16,D[1]=r[2]^r[7]>>>16^r[5]<<16,D[2]=r[4]^r[1]>>>16^r[7]<<16,D[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)D[i]=16711935&(D[i]<<8|D[i]>>>24)|4278255360&(D[i]<<24|D[i]>>>8),t[e+i]^=D[i]},blockSize:4,ivSize:2}),M.Rabbit=F._createHelper(P),F=(M=U).lib.StreamCipher,P=M.algo,W=[],O=[],I=[],P=P.RabbitLegacy=F.extend({_doReset:function(){for(var t=this._key.words,e=this.cfg.iv,r=this._X=[t[0],t[3]<<16|t[2]>>>16,t[1],t[0]<<16|t[3]>>>16,t[2],t[1]<<16|t[0]>>>16,t[3],t[2]<<16|t[1]>>>16],i=this._C=[t[2]<<16|t[2]>>>16,4294901760&t[0]|65535&t[1],t[3]<<16|t[3]>>>16,4294901760&t[1]|65535&t[2],t[0]<<16|t[0]>>>16,4294901760&t[2]|65535&t[3],t[1]<<16|t[1]>>>16,4294901760&t[3]|65535&t[0]],n=this._b=0;n<4;n++)q.call(this);for(n=0;n<8;n++)i[n]^=r[n+4&7];if(e){var o,s=(e=16711935&((s=(o=e.words)[0])<<8|s>>>24)|4278255360&(s<<24|s>>>8))>>>16|4294901760&(o=16711935&((t=o[1])<<8|t>>>24)|4278255360&(t<<24|t>>>8));for(t=o<<16|65535&e,i[0]^=e,i[1]^=s,i[2]^=o,i[3]^=t,i[4]^=e,i[5]^=s,i[6]^=o,i[7]^=t,n=0;n<4;n++)q.call(this)}},_doProcessBlock:function(t,e){var r=this._X;q.call(this),W[0]=r[0]^r[5]>>>16^r[3]<<16,W[1]=r[2]^r[7]>>>16^r[5]<<16,W[2]=r[4]^r[1]>>>16^r[7]<<16,W[3]=r[6]^r[3]>>>16^r[1]<<16;for(var i=0;i<4;i++)W[i]=16711935&(W[i]<<8|W[i]>>>24)|4278255360&(W[i]<<24|W[i]>>>8),t[e+i]^=W[i]},blockSize:4,ivSize:2}),M.RabbitLegacy=F._createHelper(P),U}()),cryptoJs4_1_1_min$1.exports}(),sm3=function requireMiniprogram_dist(){return hasRequiredMiniprogram_dist||(hasRequiredMiniprogram_dist=1,miniprogram_dist.exports=function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{enumerable:!0,get:getter})},__webpack_require__.r=function(exports){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports,"__esModule",{value:!0})},__webpack_require__.t=function(value,mode){if(1&mode&&(value=__webpack_require__(value)),8&mode)return value;if(4&mode&&"object"==typeof value&&value&&value.__esModule)return value;var ns=Object.create(null);if(__webpack_require__.r(ns),Object.defineProperty(ns,"default",{enumerable:!0,value:value}),2&mode&&"string"!=typeof value)for(var key in value)__webpack_require__.d(ns,key,function(key){return value[key]}.bind(null,key));return ns},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function getDefault(){return module.default}:function getModuleExports(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=2)}([function(module,exports){module.exports=requireJsbn()},function(module,exports,__webpack_require__){var W=new Uint32Array(68),M=new Uint32Array(64);function rotl(x,n){var s=31&n;return x<<s|x>>>32-s}function xor(x,y){for(var result=[],i=x.length-1;i>=0;i--)result[i]=255&(x[i]^y[i]);return result}function P0(X){return X^rotl(X,9)^rotl(X,17)}function P1(X){return X^rotl(X,15)^rotl(X,23)}function sm3(array){var len=8*array.length,k=len%512;k=k>=448?512-k%448-1:448-k-1;for(var kArr=new Array((k-7)/8),lenArr=new Array(8),i=0,_len=kArr.length;i<_len;i++)kArr[i]=0;for(var _i=0,_len2=lenArr.length;_i<_len2;_i++)lenArr[_i]=0;len=len.toString(2);for(var _i2=7;_i2>=0;_i2--)if(len.length>8){var start=len.length-8;lenArr[_i2]=parseInt(len.substr(start),2),len=len.substr(0,start)}else len.length>0&&(lenArr[_i2]=parseInt(len,2),len="");for(var m=new Uint8Array([].concat(array,[128],kArr,lenArr)),dataView=new DataView(m.buffer,0),n=m.length/64,V=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]),_i3=0;_i3<n;_i3++){W.fill(0),M.fill(0);for(var _start=16*_i3,j=0;j<16;j++)W[j]=dataView.getUint32(4*(_start+j),!1);for(var _j=16;_j<68;_j++)W[_j]=P1(W[_j-16]^W[_j-9]^rotl(W[_j-3],15))^rotl(W[_j-13],7)^W[_j-6];for(var _j2=0;_j2<64;_j2++)M[_j2]=W[_j2]^W[_j2+4];for(var A=V[0],B=V[1],C=V[2],D=V[3],E=V[4],F=V[5],G=V[6],H=V[7],SS1=void 0,TT1=void 0,TT2=void 0,T=void 0,_j3=0;_j3<64;_j3++)T=_j3>=0&&_j3<=15?2043430169:2055708042,TT1=(_j3>=0&&_j3<=15?A^B^C:A&B|A&C|B&C)+D+((SS1=rotl(rotl(A,12)+E+rotl(T,_j3),7))^rotl(A,12))+M[_j3],TT2=(_j3>=0&&_j3<=15?E^F^G:E&F|~E&G)+H+SS1+W[_j3],D=C,C=rotl(B,9),B=A,A=TT1,H=G,G=rotl(F,19),F=E,E=P0(TT2);V[0]^=A,V[1]^=B,V[2]^=C,V[3]^=D,V[4]^=E,V[5]^=F,V[6]^=G,V[7]^=H}for(var result=[],_i4=0,_len3=V.length;_i4<_len3;_i4++){var word=V[_i4];result.push((4278190080&word)>>>24,(16711680&word)>>>16,(65280&word)>>>8,255&word)}return result}for(var iPad=new Uint8Array(64),oPad=new Uint8Array(64),i=0;i<64;i++)iPad[i]=54,oPad[i]=92;module.exports={sm3:sm3,hmac:function hmac(input,key){for(key.length>64&&(key=sm3(key));key.length<64;)key.push(0);var iPadKey=xor(key,iPad),oPadKey=xor(key,oPad),hash=sm3([].concat(iPadKey,input));return sm3([].concat(oPadKey,hash))}}},function(module,exports,__webpack_require__){module.exports={sm2:__webpack_require__(3),sm3:__webpack_require__(7),sm4:__webpack_require__(8)}},function(module,exports,__webpack_require__){var BigInteger=__webpack_require__(0).BigInteger,_require2=__webpack_require__(4),encodeDer=_require2.encodeDer,decodeDer=_require2.decodeDer,_=__webpack_require__(5),sm3=__webpack_require__(1).sm3,_$generateEcparam=_.generateEcparam(),G=_$generateEcparam.G,curve=_$generateEcparam.curve,n=_$generateEcparam.n;function getHash(hashHex,publicKey){var userId=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"1234567812345678";userId=_.utf8ToHex(userId);var a=_.leftPad(G.curve.a.toBigInteger().toRadix(16),64),b=_.leftPad(G.curve.b.toBigInteger().toRadix(16),64),gx=_.leftPad(G.getX().toBigInteger().toRadix(16),64),gy=_.leftPad(G.getY().toBigInteger().toRadix(16),64),px=void 0,py=void 0;if(128===publicKey.length)px=publicKey.substr(0,64),py=publicKey.substr(64,64);else{var point=G.curve.decodePointHex(publicKey);px=_.leftPad(point.getX().toBigInteger().toRadix(16),64),py=_.leftPad(point.getY().toBigInteger().toRadix(16),64)}var data=_.hexToArray(userId+a+b+gx+gy+px+py),entl=4*userId.length;data.unshift(255&entl),data.unshift(entl>>8&255);var z=sm3(data);return _.arrayToHex(sm3(z.concat(_.hexToArray(hashHex))))}function getPublicKeyFromPrivateKey(privateKey){var PA=G.multiply(new BigInteger(privateKey,16));return"04"+_.leftPad(PA.getX().toBigInteger().toString(16),64)+_.leftPad(PA.getY().toBigInteger().toString(16),64)}function getPoint(){var keypair=_.generateKeyPairHex(),PA=curve.decodePointHex(keypair.publicKey);return keypair.k=new BigInteger(keypair.privateKey,16),keypair.x1=PA.getX().toBigInteger(),keypair}module.exports={generateKeyPairHex:_.generateKeyPairHex,compressPublicKeyHex:_.compressPublicKeyHex,comparePublicKeyHex:_.comparePublicKeyHex,doEncrypt:function doEncrypt(msg,publicKey){var cipherMode=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;msg="string"==typeof msg?_.hexToArray(_.utf8ToHex(msg)):Array.prototype.slice.call(msg),publicKey=_.getGlobalCurve().decodePointHex(publicKey);var keypair=_.generateKeyPairHex(),k=new BigInteger(keypair.privateKey,16),c1=keypair.publicKey;c1.length>128&&(c1=c1.substr(c1.length-128));var p=publicKey.multiply(k),x2=_.hexToArray(_.leftPad(p.getX().toBigInteger().toRadix(16),64)),y2=_.hexToArray(_.leftPad(p.getY().toBigInteger().toRadix(16),64)),c3=_.arrayToHex(sm3([].concat(x2,msg,y2))),ct=1,offset=0,t=[],z=[].concat(x2,y2),nextT=function nextT(){t=sm3([].concat(z,[ct>>24&255,ct>>16&255,ct>>8&255,255&ct])),ct++,offset=0};nextT();for(var i=0,len=msg.length;i<len;i++)offset===t.length&&nextT(),msg[i]^=255&t[offset++];var c2=_.arrayToHex(msg);return 0===cipherMode?c1+c2+c3:c1+c3+c2},doDecrypt:function doDecrypt(encryptData,privateKey){var cipherMode=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,_ref$output=(arguments.length>3&&void 0!==arguments[3]?arguments[3]:{}).output,output=void 0===_ref$output?"string":_ref$output;privateKey=new BigInteger(privateKey,16);var c3=encryptData.substr(128,64),c2=encryptData.substr(192);0===cipherMode&&(c3=encryptData.substr(encryptData.length-64),c2=encryptData.substr(128,encryptData.length-128-64));var msg=_.hexToArray(c2),p=_.getGlobalCurve().decodePointHex("04"+encryptData.substr(0,128)).multiply(privateKey),x2=_.hexToArray(_.leftPad(p.getX().toBigInteger().toRadix(16),64)),y2=_.hexToArray(_.leftPad(p.getY().toBigInteger().toRadix(16),64)),ct=1,offset=0,t=[],z=[].concat(x2,y2),nextT=function nextT(){t=sm3([].concat(z,[ct>>24&255,ct>>16&255,ct>>8&255,255&ct])),ct++,offset=0};nextT();for(var i=0,len=msg.length;i<len;i++)offset===t.length&&nextT(),msg[i]^=255&t[offset++];return _.arrayToHex(sm3([].concat(x2,msg,y2)))===c3.toLowerCase()?"array"===output?msg:_.arrayToUtf8(msg):"array"===output?[]:""},doSignature:function doSignature(msg,privateKey){var _ref2=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},pointPool=_ref2.pointPool,der=_ref2.der,hash=_ref2.hash,publicKey=_ref2.publicKey,userId=_ref2.userId,hashHex="string"==typeof msg?_.utf8ToHex(msg):_.arrayToHex(msg);hash&&(hashHex=getHash(hashHex,publicKey=publicKey||getPublicKeyFromPrivateKey(privateKey),userId));var dA=new BigInteger(privateKey,16),e=new BigInteger(hashHex,16),k=null,r=null,s=null;do{do{var point=void 0;k=(point=pointPool&&pointPool.length?pointPool.pop():getPoint()).k,r=e.add(point.x1).mod(n)}while(r.equals(BigInteger.ZERO)||r.add(k).equals(n));s=dA.add(BigInteger.ONE).modInverse(n).multiply(k.subtract(r.multiply(dA))).mod(n)}while(s.equals(BigInteger.ZERO));return der?encodeDer(r,s):_.leftPad(r.toString(16),64)+_.leftPad(s.toString(16),64)},doVerifySignature:function doVerifySignature(msg,signHex,publicKey){var _ref3=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},der=_ref3.der,hash=_ref3.hash,userId=_ref3.userId,hashHex="string"==typeof msg?_.utf8ToHex(msg):_.arrayToHex(msg);hash&&(hashHex=getHash(hashHex,publicKey,userId));var r=void 0,s=void 0;if(der){var decodeDerObj=decodeDer(signHex);r=decodeDerObj.r,s=decodeDerObj.s}else r=new BigInteger(signHex.substring(0,64),16),s=new BigInteger(signHex.substring(64),16);var PA=curve.decodePointHex(publicKey),e=new BigInteger(hashHex,16),t=r.add(s).mod(n);if(t.equals(BigInteger.ZERO))return!1;var x1y1=G.multiply(s).add(PA.multiply(t)),R=e.add(x1y1.getX().toBigInteger()).mod(n);return r.equals(R)},getPublicKeyFromPrivateKey:getPublicKeyFromPrivateKey,getPoint:getPoint,verifyPublicKey:_.verifyPublicKey}},function(module,exports,__webpack_require__){function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var BigInteger=__webpack_require__(0).BigInteger,ASN1Object=function(){function ASN1Object(){_classCallCheck(this,ASN1Object),this.tlv=null,this.t="00",this.l="00",this.v=""}return ASN1Object.prototype.getEncodedHex=function getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv},ASN1Object.prototype.getLength=function getLength(){var n=this.v.length/2,nHex=n.toString(16);return nHex.length%2==1&&(nHex="0"+nHex),n<128?nHex:(128+nHex.length/2).toString(16)+nHex},ASN1Object.prototype.getValue=function getValue(){return""},ASN1Object}(),DERInteger=function(_ASN1Object){function DERInteger(bigint){_classCallCheck(this,DERInteger);var _this=_possibleConstructorReturn(this,_ASN1Object.call(this));return _this.t="02",bigint&&(_this.v=function bigintToValue(bigint){var h=bigint.toString(16);if("-"!==h[0])h.length%2==1?h="0"+h:h.match(/^[0-7]/)||(h="00"+h);else{var len=(h=h.substr(1)).length;len%2==1?len+=1:h.match(/^[0-7]/)||(len+=2);for(var mask="",i=0;i<len;i++)mask+="f";h=(h=(mask=new BigInteger(mask,16)).xor(bigint).add(BigInteger.ONE)).toString(16).replace(/^-/,"")}return h}(bigint)),_this}return _inherits(DERInteger,_ASN1Object),DERInteger.prototype.getValue=function getValue(){return this.v},DERInteger}(ASN1Object),DERSequence=function(_ASN1Object2){function DERSequence(asn1Array){_classCallCheck(this,DERSequence);var _this2=_possibleConstructorReturn(this,_ASN1Object2.call(this));return _this2.t="30",_this2.asn1Array=asn1Array,_this2}return _inherits(DERSequence,_ASN1Object2),DERSequence.prototype.getValue=function getValue(){return this.v=this.asn1Array.map(function(asn1Object){return asn1Object.getEncodedHex()}).join(""),this.v},DERSequence}(ASN1Object);function getLenOfL(str,start){return+str[start+2]<8?1:128&+str.substr(start+2,2)}function getL(str,start){var len=getLenOfL(str,start),l=str.substr(start+2,2*len);return l?(+l[0]<8?new BigInteger(l,16):new BigInteger(l.substr(2),16)).intValue():-1}function getStartOfV(str,start){return start+2*(getLenOfL(str,start)+1)}module.exports={encodeDer:function encodeDer(r,s){var derR=new DERInteger(r),derS=new DERInteger(s);return new DERSequence([derR,derS]).getEncodedHex()},decodeDer:function decodeDer(input){var start=getStartOfV(input,0),vIndexR=getStartOfV(input,start),lR=getL(input,start),vR=input.substr(vIndexR,2*lR),nextStart=vIndexR+vR.length,vIndexS=getStartOfV(input,nextStart),lS=getL(input,nextStart),vS=input.substr(vIndexS,2*lS);return{r:new BigInteger(vR,16),s:new BigInteger(vS,16)}}}},function(module,exports,__webpack_require__){var _require=__webpack_require__(0),BigInteger=_require.BigInteger,SecureRandom=_require.SecureRandom,ECCurveFp=__webpack_require__(6).ECCurveFp,rng=new SecureRandom,_generateEcparam=generateEcparam(),curve=_generateEcparam.curve,G=_generateEcparam.G,n=_generateEcparam.n;function generateEcparam(){var p=new BigInteger("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),a=new BigInteger("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),b=new BigInteger("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),curve=new ECCurveFp(p,a,b),G=curve.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:curve,G:G,n:new BigInteger("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function leftPad(input,num){return input.length>=num?input:new Array(num-input.length+1).join("0")+input}module.exports={getGlobalCurve:function getGlobalCurve(){return curve},generateEcparam:generateEcparam,generateKeyPairHex:function generateKeyPairHex(a,b,c){var d=(a?new BigInteger(a,b,c):new BigInteger(n.bitLength(),rng)).mod(n.subtract(BigInteger.ONE)).add(BigInteger.ONE),privateKey=leftPad(d.toString(16),64),P=G.multiply(d);return{privateKey:privateKey,publicKey:"04"+leftPad(P.getX().toBigInteger().toString(16),64)+leftPad(P.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function compressPublicKeyHex(s){if(130!==s.length)throw new Error("Invalid public key to compress");var len=(s.length-2)/2,xHex=s.substr(2,len),prefix="03";return new BigInteger(s.substr(len+2,len),16).mod(new BigInteger("2")).equals(BigInteger.ZERO)&&(prefix="02"),prefix+xHex},utf8ToHex:function utf8ToHex(input){for(var length=(input=unescape(encodeURIComponent(input))).length,words=[],i=0;i<length;i++)words[i>>>2]|=(255&input.charCodeAt(i))<<24-i%4*8;for(var hexChars=[],_i=0;_i<length;_i++){var bite=words[_i>>>2]>>>24-_i%4*8&255;hexChars.push((bite>>>4).toString(16)),hexChars.push((15&bite).toString(16))}return hexChars.join("")},leftPad:leftPad,arrayToHex:function arrayToHex(arr){return arr.map(function(item){return 1===(item=item.toString(16)).length?"0"+item:item}).join("")},arrayToUtf8:function arrayToUtf8(arr){for(var words=[],j=0,i=0;i<2*arr.length;i+=2)words[i>>>3]|=parseInt(arr[j],10)<<24-i%8*4,j++;try{for(var latin1Chars=[],_i2=0;_i2<arr.length;_i2++){var bite=words[_i2>>>2]>>>24-_i2%4*8&255;latin1Chars.push(String.fromCharCode(bite))}return decodeURIComponent(escape(latin1Chars.join("")))}catch(e){throw new Error("Malformed UTF-8 data")}},hexToArray:function hexToArray(hexStr){var words=[],hexStrLength=hexStr.length;hexStrLength%2!=0&&(hexStr=leftPad(hexStr,hexStrLength+1)),hexStrLength=hexStr.length;for(var i=0;i<hexStrLength;i+=2)words.push(parseInt(hexStr.substr(i,2),16));return words},verifyPublicKey:function verifyPublicKey(publicKey){var point=curve.decodePointHex(publicKey);if(!point)return!1;var x=point.getX();return point.getY().square().equals(x.multiply(x.square()).add(x.multiply(curve.a)).add(curve.b))},comparePublicKeyHex:function comparePublicKeyHex(publicKey1,publicKey2){var point1=curve.decodePointHex(publicKey1);if(!point1)return!1;var point2=curve.decodePointHex(publicKey2);return!!point2&&point1.equals(point2)}}},function(module,exports,__webpack_require__){function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var BigInteger=__webpack_require__(0).BigInteger,TWO=new BigInteger("2"),THREE=new BigInteger("3"),ECFieldElementFp=function(){function ECFieldElementFp(q,x){_classCallCheck(this,ECFieldElementFp),this.x=x,this.q=q}return ECFieldElementFp.prototype.equals=function equals(other){return other===this||this.q.equals(other.q)&&this.x.equals(other.x)},ECFieldElementFp.prototype.toBigInteger=function toBigInteger(){return this.x},ECFieldElementFp.prototype.negate=function negate(){return new ECFieldElementFp(this.q,this.x.negate().mod(this.q))},ECFieldElementFp.prototype.add=function add(b){return new ECFieldElementFp(this.q,this.x.add(b.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.subtract=function subtract(b){return new ECFieldElementFp(this.q,this.x.subtract(b.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.multiply=function multiply(b){return new ECFieldElementFp(this.q,this.x.multiply(b.toBigInteger()).mod(this.q))},ECFieldElementFp.prototype.divide=function divide(b){return new ECFieldElementFp(this.q,this.x.multiply(b.toBigInteger().modInverse(this.q)).mod(this.q))},ECFieldElementFp.prototype.square=function square(){return new ECFieldElementFp(this.q,this.x.square().mod(this.q))},ECFieldElementFp}(),ECPointFp=function(){function ECPointFp(curve,x,y,z){_classCallCheck(this,ECPointFp),this.curve=curve,this.x=x,this.y=y,this.z=null==z?BigInteger.ONE:z,this.zinv=null}return ECPointFp.prototype.getX=function getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.getY=function getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},ECPointFp.prototype.equals=function equals(other){return other===this||(this.isInfinity()?other.isInfinity():other.isInfinity()?this.isInfinity():!!other.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(other.z)).mod(this.curve.q).equals(BigInteger.ZERO)&&other.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(other.z)).mod(this.curve.q).equals(BigInteger.ZERO))},ECPointFp.prototype.isInfinity=function isInfinity(){return null===this.x&&null===this.y||this.z.equals(BigInteger.ZERO)&&!this.y.toBigInteger().equals(BigInteger.ZERO)},ECPointFp.prototype.negate=function negate(){return new ECPointFp(this.curve,this.x,this.y.negate(),this.z)},ECPointFp.prototype.add=function add(b){if(this.isInfinity())return b;if(b.isInfinity())return this;var x1=this.x.toBigInteger(),y1=this.y.toBigInteger(),z1=this.z,x2=b.x.toBigInteger(),y2=b.y.toBigInteger(),z2=b.z,q=this.curve.q,w1=x1.multiply(z2).mod(q),w2=x2.multiply(z1).mod(q),w3=w1.subtract(w2),w4=y1.multiply(z2).mod(q),w5=y2.multiply(z1).mod(q),w6=w4.subtract(w5);if(BigInteger.ZERO.equals(w3))return BigInteger.ZERO.equals(w6)?this.twice():this.curve.infinity;var w7=w1.add(w2),w8=z1.multiply(z2).mod(q),w9=w3.square().mod(q),w10=w3.multiply(w9).mod(q),w11=w8.multiply(w6.square()).subtract(w7.multiply(w9)).mod(q),x3=w3.multiply(w11).mod(q),y3=w6.multiply(w9.multiply(w1).subtract(w11)).subtract(w4.multiply(w10)).mod(q),z3=w10.multiply(w8).mod(q);return new ECPointFp(this.curve,this.curve.fromBigInteger(x3),this.curve.fromBigInteger(y3),z3)},ECPointFp.prototype.twice=function twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;var x1=this.x.toBigInteger(),y1=this.y.toBigInteger(),z1=this.z,q=this.curve.q,a=this.curve.a.toBigInteger(),w1=x1.square().multiply(THREE).add(a.multiply(z1.square())).mod(q),w2=y1.shiftLeft(1).multiply(z1).mod(q),w3=y1.square().mod(q),w4=w3.multiply(x1).multiply(z1).mod(q),w5=w2.square().mod(q),w6=w1.square().subtract(w4.shiftLeft(3)).mod(q),x3=w2.multiply(w6).mod(q),y3=w1.multiply(w4.shiftLeft(2).subtract(w6)).subtract(w5.shiftLeft(1).multiply(w3)).mod(q),z3=w2.multiply(w5).mod(q);return new ECPointFp(this.curve,this.curve.fromBigInteger(x3),this.curve.fromBigInteger(y3),z3)},ECPointFp.prototype.multiply=function multiply(k){if(this.isInfinity())return this;if(!k.signum())return this.curve.infinity;for(var k3=k.multiply(THREE),neg=this.negate(),Q=this,i=k3.bitLength()-2;i>0;i--){Q=Q.twice();var k3Bit=k3.testBit(i);k3Bit!==k.testBit(i)&&(Q=Q.add(k3Bit?this:neg))}return Q},ECPointFp}(),ECCurveFp=function(){function ECCurveFp(q,a,b){_classCallCheck(this,ECCurveFp),this.q=q,this.a=this.fromBigInteger(a),this.b=this.fromBigInteger(b),this.infinity=new ECPointFp(this,null,null)}return ECCurveFp.prototype.equals=function equals(other){return other===this||this.q.equals(other.q)&&this.a.equals(other.a)&&this.b.equals(other.b)},ECCurveFp.prototype.fromBigInteger=function fromBigInteger(x){return new ECFieldElementFp(this.q,x)},ECCurveFp.prototype.decodePointHex=function decodePointHex(s){switch(parseInt(s.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var x=this.fromBigInteger(new BigInteger(s.substr(2),16)),y=this.fromBigInteger(x.multiply(x.square()).add(x.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new BigInteger("4")).add(BigInteger.ONE),this.q));return y.toBigInteger().mod(TWO).equals(new BigInteger(s.substr(0,2),16).subtract(TWO))||(y=y.negate()),new ECPointFp(this,x,y);case 4:case 6:case 7:var len=(s.length-2)/2,xHex=s.substr(2,len),yHex=s.substr(len+2,len);return new ECPointFp(this,this.fromBigInteger(new BigInteger(xHex,16)),this.fromBigInteger(new BigInteger(yHex,16)));default:return null}},ECCurveFp}();module.exports={ECPointFp:ECPointFp,ECCurveFp:ECCurveFp}},function(module,exports,__webpack_require__){var _require=__webpack_require__(1),sm3=_require.sm3,hmac=_require.hmac;function ArrayToHex(arr){return arr.map(function(item){return 1===(item=item.toString(16)).length?"0"+item:item}).join("")}function hexToArray(hexStr){var words=[],hexStrLength=hexStr.length;hexStrLength%2!=0&&(hexStr=function leftPad(input,num){return input.length>=num?input:new Array(num-input.length+1).join("0")+input}(hexStr,hexStrLength+1)),hexStrLength=hexStr.length;for(var i=0;i<hexStrLength;i+=2)words.push(parseInt(hexStr.substr(i,2),16));return words}module.exports=function(input,options){if(input="string"==typeof input?function utf8ToArray(str){for(var arr=[],i=0,len=str.length;i<len;i++){var point=str.codePointAt(i);if(point<=127)arr.push(point);else if(point<=2047)arr.push(192|point>>>6),arr.push(128|63&point);else if(point<=55295||point>=57344&&point<=65535)arr.push(224|point>>>12),arr.push(128|point>>>6&63),arr.push(128|63&point);else{if(!(point>=65536&&point<=1114111))throw arr.push(point),new Error("input is not supported");i++,arr.push(240|point>>>18&28),arr.push(128|point>>>12&63),arr.push(128|point>>>6&63),arr.push(128|63&point)}}return arr}(input):Array.prototype.slice.call(input),options){if("hmac"!==(options.mode||"hmac"))throw new Error("invalid mode");var key=options.key;if(!key)throw new Error("invalid key");return key="string"==typeof key?hexToArray(key):Array.prototype.slice.call(key),ArrayToHex(hmac(input,key))}return ArrayToHex(sm3(input))}},function(module,exports,__webpack_require__){var Sbox=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],CK=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function hexToArray(str){for(var arr=[],i=0,len=str.length;i<len;i+=2)arr.push(parseInt(str.substr(i,2),16));return arr}function rotl(x,n){var s=31&n;return x<<s|x>>>32-s}function byteSub(a){return(255&Sbox[a>>>24&255])<<24|(255&Sbox[a>>>16&255])<<16|(255&Sbox[a>>>8&255])<<8|255&Sbox[255&a]}function l1(b){return b^rotl(b,2)^rotl(b,10)^rotl(b,18)^rotl(b,24)}function l2(b){return b^rotl(b,13)^rotl(b,23)}function sms4Crypt(input,output,roundKey){for(var x=new Array(4),tmp=new Array(4),i=0;i<4;i++)tmp[0]=255&input[4*i],tmp[1]=255&input[4*i+1],tmp[2]=255&input[4*i+2],tmp[3]=255&input[4*i+3],x[i]=tmp[0]<<24|tmp[1]<<16|tmp[2]<<8|tmp[3];for(var mid,r=0;r<32;r+=4)mid=x[1]^x[2]^x[3]^roundKey[r+0],x[0]^=l1(byteSub(mid)),mid=x[2]^x[3]^x[0]^roundKey[r+1],x[1]^=l1(byteSub(mid)),mid=x[3]^x[0]^x[1]^roundKey[r+2],x[2]^=l1(byteSub(mid)),mid=x[0]^x[1]^x[2]^roundKey[r+3],x[3]^=l1(byteSub(mid));for(var j=0;j<16;j+=4)output[j]=x[3-j/4]>>>24&255,output[j+1]=x[3-j/4]>>>16&255,output[j+2]=x[3-j/4]>>>8&255,output[j+3]=255&x[3-j/4]}function sm4(inArray,key,cryptFlag){var _ref=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},_ref$padding=_ref.padding,padding=void 0===_ref$padding?"pkcs#7":_ref$padding,mode=_ref.mode,_ref$iv=_ref.iv,iv=void 0===_ref$iv?[]:_ref$iv,_ref$output=_ref.output,output=void 0===_ref$output?"string":_ref$output;if("cbc"===mode&&("string"==typeof iv&&(iv=hexToArray(iv)),16!==iv.length))throw new Error("iv is invalid");if("string"==typeof key&&(key=hexToArray(key)),16!==key.length)throw new Error("key is invalid");if(inArray="string"==typeof inArray?0!==cryptFlag?function utf8ToArray(str){for(var arr=[],i=0,len=str.length;i<len;i++){var point=str.codePointAt(i);if(point<=127)arr.push(point);else if(point<=2047)arr.push(192|point>>>6),arr.push(128|63&point);else if(point<=55295||point>=57344&&point<=65535)arr.push(224|point>>>12),arr.push(128|point>>>6&63),arr.push(128|63&point);else{if(!(point>=65536&&point<=1114111))throw arr.push(point),new Error("input is not supported");i++,arr.push(240|point>>>18&28),arr.push(128|point>>>12&63),arr.push(128|point>>>6&63),arr.push(128|63&point)}}return arr}(inArray):hexToArray(inArray):[].concat(inArray),("pkcs#5"===padding||"pkcs#7"===padding)&&0!==cryptFlag)for(var paddingCount=16-inArray.length%16,i=0;i<paddingCount;i++)inArray.push(paddingCount);var roundKey=new Array(32);!function sms4KeyExt(key,roundKey,cryptFlag){for(var x=new Array(4),tmp=new Array(4),i=0;i<4;i++)tmp[0]=255&key[0+4*i],tmp[1]=255&key[1+4*i],tmp[2]=255&key[2+4*i],tmp[3]=255&key[3+4*i],x[i]=tmp[0]<<24|tmp[1]<<16|tmp[2]<<8|tmp[3];x[0]^=2746333894,x[1]^=1453994832,x[2]^=1736282519,x[3]^=2993693404;for(var mid,r=0;r<32;r+=4)mid=x[1]^x[2]^x[3]^CK[r+0],roundKey[r+0]=x[0]^=l2(byteSub(mid)),mid=x[2]^x[3]^x[0]^CK[r+1],roundKey[r+1]=x[1]^=l2(byteSub(mid)),mid=x[3]^x[0]^x[1]^CK[r+2],roundKey[r+2]=x[2]^=l2(byteSub(mid)),mid=x[0]^x[1]^x[2]^CK[r+3],roundKey[r+3]=x[3]^=l2(byteSub(mid));if(0===cryptFlag)for(var _mid,_r=0;_r<16;_r++)_mid=roundKey[_r],roundKey[_r]=roundKey[31-_r],roundKey[31-_r]=_mid}(key,roundKey,cryptFlag);for(var outArray=[],lastVector=iv,restLen=inArray.length,point=0;restLen>=16;){var input=inArray.slice(point,point+16),_output=new Array(16);if("cbc"===mode)for(var _i=0;_i<16;_i++)0!==cryptFlag&&(input[_i]^=lastVector[_i]);sms4Crypt(input,_output,roundKey);for(var _i2=0;_i2<16;_i2++)"cbc"===mode&&0===cryptFlag&&(_output[_i2]^=lastVector[_i2]),outArray[point+_i2]=_output[_i2];"cbc"===mode&&(lastVector=0!==cryptFlag?_output:input),restLen-=16,point+=16}if(("pkcs#5"===padding||"pkcs#7"===padding)&&0===cryptFlag){for(var len=outArray.length,_paddingCount=outArray[len-1],_i3=1;_i3<=_paddingCount;_i3++)if(outArray[len-_i3]!==_paddingCount)throw new Error("padding is invalid");outArray.splice(len-_paddingCount,_paddingCount)}return"array"!==output?0!==cryptFlag?function ArrayToHex(arr){return arr.map(function(item){return 1===(item=item.toString(16)).length?"0"+item:item}).join("")}(outArray):function arrayToUtf8(arr){for(var str=[],i=0,len=arr.length;i<len;i++)arr[i]>=240&&arr[i]<=247?(str.push(String.fromCodePoint(((7&arr[i])<<18)+((63&arr[i+1])<<12)+((63&arr[i+2])<<6)+(63&arr[i+3]))),i+=3):arr[i]>=224&&arr[i]<=239?(str.push(String.fromCodePoint(((15&arr[i])<<12)+((63&arr[i+1])<<6)+(63&arr[i+2]))),i+=2):arr[i]>=192&&arr[i]<=223?(str.push(String.fromCodePoint(((31&arr[i])<<6)+(63&arr[i+1]))),i++):str.push(String.fromCodePoint(arr[i]));return str.join("")}(outArray):outArray}module.exports={encrypt:function encrypt(inArray,key,options){return sm4(inArray,key,1,options)},decrypt:function decrypt(inArray,key,options){return sm4(inArray,key,0,options)}}}])),miniprogram_dist.exports}().sm3;let _sKey="",_signType=2;var hasRequiredWeapp_socket_io,weapp_socket_io={exports:{}};const e=e=>void 0===e,t=e=>"string"==typeof e,s=e=>{var t;return null===(t=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))||void 0===t?void 0:t[1].toLowerCase()},n=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===s(e),o=e=>null!==e&&"object"==typeof e,i=e=>n(e)||o(e),r=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},a=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s};function c(e=99999999){return Math.round(Math.random()*e)}const u=(t,s,n,o)=>{if(!i(t)||!i(s))return 0;let r=0;const a=Object.keys(s);let c;for(let l=0,d=a.length;l<d;l++)if(c=a[l],!(e(s[c])||n&&n.includes(c)))if(i(t[c])&&i(s[c]))r+=u(t[c],s[c],n,o);else{if(o&&o.includes(s[c]))continue;t[c]!==s[c]&&(t[c]=s[c],r+=1)}return r};function l(e){let t,s,n=e;e.length%8!=0&&(n="0".repeat(8-e.length%8)+e);let o="";for(let e=0,{length:i}=n;e<i;e+=8)t=parseInt(n.slice(e,e+4),2),s=parseInt(n.slice(e+4,e+8),2),o+=base16Map.get(t)+base16Map.get(s);return o}const 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},h=["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 g;!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"}(g||(g={}));const p="LiteChat",_={[g.DEBUG]:console.debug,[g.INFO]:console.info,[g.WARN]:console.warn,[g.ERROR]:console.error},m={[g.INFO]:4,[g.WARN]:5,[g.ERROR]:6},v=1e3,f=2,I=5e3,E=50,S={CHINA:"CHINA",OVERSEA:"OVERSEA",SINGAPORE:"SINGAPORE",KOREA:"KOREA",GERMANY:"GERMANY",IND:"IND",JPN:"JPN",USA:"USA",INDONESIA:"INDONESIA",KSA:"KSA"},C={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"},KSA:{DEFAULT:"wss://wssksa-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"},KSA:{INITIAL:"wss://*w4a.my-imcloud.com",DEFAULT:"wss://wssksa.im.qcloud.com",IPV6:"wss://wssksav6.im.qcloud.com",BACKUP:"wss://wssksa.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4a.my-cpaas.com",STAT:"https://apiksa.my-imcloud.com",ANYCAST:"wss://43.164.68.251"}}};var M;!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"}(M||(M={}));var y=Object.freeze({__proto__:null,ACCESS_ENVIRONMENT:S,CONSOLE_METHOD:_,CloudConfigReportLevelMap:m,get ConvModifyPushType(){return M},DEFAULT_GLOBAL_MAX_TOTAL_COUNT:E,DEFAULT_GLOBAL_THROTTLE_TIME:I,DEFAULT_SINGLE_MAX_TOTAL_COUNT:f,DEFAULT_SINGLE_THROTTLE_TIME:v,ENUM_PLATFORM:d,HOST_CONFIG:C,IS_TOPIC_MESSAGE:2,get LogLevel(){return g},NOT_NEED_CRC_SERVCMD:h,SDK_NAME:p});const O="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform)&&void 0===wx.getSystemInfoSync().uniPlatform,A="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||O,T=A&&"function"==typeof wx.createGamePortal,R="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),b=D&&"function"==typeof tt.onShow,N="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),L="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),P="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,G="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=A&&"object"==typeof wx.miniapp,U="undefined"!=typeof uni,k=D&&"function"==typeof tt.enterChat,F=A||R||D||N||L||G||P,$="undefined"==typeof window&&!F&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,x="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),q="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),V="undefined"!=typeof uni?!F:"undefined"!=typeof window&&!F&&!x,B=R?qq:D?tt:N?swan:L?my:A?wx:G?uni:P?jd:{},j=V&&window&&window.navigator&&window.navigator.userAgent||"",H=/(micromessenger|webbrowser)/i.test(j),K=function(){let e="WEB";return H?e="WEB":R?e="QQ_MP":D?e="TT_MP":N?e="BAIDU_MP":L?e="ALI_MP":A?e=w?"DONUT_NATIVE_APP":"WX_MP":G?e="UNI_NATIVE_APP":$?e="NS_NATIVE_APP":x&&(e="RN_NATIVE_APP"),d[e]}(),W=/iPad/i.test(j),Y=/iPhone/i.test(j)&&!W,z=/iPod/i.test(j),J=Y||W||z,Q=function(){const e=j.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),X=/Android/i.test(j),Z=function(){const e=j.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(`${e[1]}.${e[2]}`):t||null}(),ee=/Firefox/i.test(j),te=/Edge/i.test(j),se=!te&&/Chrome/i.test(j),ne=/MSIE/.test(j)||j.indexOf("Trident")>-1&&j.indexOf("rv:11.0")>-1,oe=function(){const e=/MSIE\s(\d+)\.\d/.exec(j);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(j)&&/rv:11.0/.test(j)&&(t=11),t}(),ie=/Safari/i.test(j)&&!se&&!X&&!te,re=/Windows/i.test(j),ae=/MAC OS X/i.test(j),ce=V&&"undefined"!=typeof Worker&&!ne,ue=X||J,le=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!J||e||ie)}();function de(){let e="unknown";if(ae&&(e="mac"),re&&(e="windows"),J&&(e="ios"),X&&(e="android"),F)try{const{platform:t}=B.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}const he="undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node&&"undefined"==typeof window;function ge(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(s[n[o]]=e[n[o]])}return s}function pe(e,t,s,n){return new(s||(s=Promise))(function(o,i){function r(e){try{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(r,a)}c((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const fe="application/x-www-form-urlencoded;charset=UTF-8";function Ie(e){return pe(this,arguments,void 0,function*({method:e,url:t,data:s,timeout:n=3e3}){return F?new Promise((o,i)=>{B.request({url:t,data:s,method:e,timeout:n,header:{"content-type":fe},success:e=>o(e.data),fail:()=>i(new Error('{"message":"Network error","code":2800}'))})}):he?void 0:new Promise((o,i)=>{const r=new XMLHttpRequest,a=setTimeout(()=>{r.abort(),i(new Error('{"message":"Request timeout","code":2801}'))},n);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(a),200===r.status||304===r.status)try{o(r.responseText?JSON.parse(r.responseText):null)}catch(e){o(r.responseText)}else i(new Error('{"message":"Network error","code":2800}'))},r.open(e,t,!0),r.setRequestHeader("Content-type",fe),r.send(s||null)})})}function Ee(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(const 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 Se(e,t){if(null===e||"object"!=typeof e)return e;const s=t||new WeakMap;if(s.has(e))return s.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){const t=new Map;return s.set(e,t),e.forEach((e,n)=>{t.set(Se(n,s),Se(e,s))}),t}if(e instanceof Set){const t=new Set;return s.set(e,t),e.forEach(e=>{t.add(Se(e,s))}),t}if(Array.isArray(e)){const t=[];return s.set(e,t),e.forEach(e=>{t.push(Se(e,s))}),t}const n=Object.getPrototypeOf(e),o=Object.create(n);return s.set(e,o),[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach(t=>{if("__ob__"===t||"__v_skip"===t||"__v_isRef"===t||"__v_isReadonly"===t)return;const n=Object.getOwnPropertyDescriptor(e,t);n&&(n.get||n.set?Object.defineProperty(o,t,n):o[t]=Se(e[t],s))}),o}function Ce(e,t,s){const n=new WeakSet,o=(e,s)=>{if(t&&(s=t(e,s)),void 0===s)return"undefined";if(null===s)return null;if(Number.isNaN(s))return"NaN";if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if("function"==typeof s)return`[Function: ${s.name||"anonymous"}]`;if("symbol"==typeof s)return s.toString();if("bigint"==typeof s)return`${s.toString()}n`;if("object"==typeof s&&null!==s){if(n.has(s))return"[Circular]";n.add(s)}return s instanceof Date?s.toISOString():s instanceof Error?{name:s.name,message:s.message}:s instanceof Map?{dataType:"Map",value:Array.from(s.entries())}:s instanceof Set?{dataType:"Set",value:Array.from(s.values())}:s};try{return JSON.stringify(e,o,s)}catch(e){return console.error("Failed to stringify:",e),""}}function Me(){let e,t;return{promise:new Promise((s,n)=>{e=s,t=n}),resolve:e,reject:t}}var ye,Oe=Object.freeze({__proto__:null,ANDROID_VERSION:Z,IE_VERSION:oe,IN_ALIPAY_MINI_APP:L,IN_BAIDU_MINI_APP:N,IN_BROWSER:V,IN_DONUT_NATIVE_APP:w,IN_FEISHU_MINI_APP:k,IN_JD_MINI_APP:P,IN_MINI_APP:F,IN_NODE:he,IN_NS_NATIVE_APP:$,IN_QQ_MINI_APP:R,IN_RN_APP:x,IN_TT_MINI_APP:D,IN_TT_MINI_GAME:b,IN_UNI_APP:U,IN_UNI_NATIVE_APP:G,IN_WX_MINI_APP:A,IN_WX_MINI_APP_DESK:O,IN_WX_MINI_GAME:T,IN_WX_MINI_PLUGIN:q,IOS_VERSION:Q,IS_ANDROID:X,IS_CHROME:se,IS_EDGE:te,IS_FIREFOX:ee,IS_IE:ne,IS_IOS:J,IS_IPAD:W,IS_IPHONE:Y,IS_IPOD:z,IS_MAC:ae,IS_SAFARI:ie,IS_WECHAT:H,IS_WIN:re,IS_WORKER_AVAILABLE:ce,MINI_APP_NAMESPACE:B,USER_AGENT:j,base16EncodeBinaryString:l,deepCopyWithMethods:Se,deepMerge:u,generatePromise:Me,getPlatformType:de,getType:s,httpRequest:Ie,isArray:n,isArrayOrObject:i,isEmpty:Ee,isH5:ue,isIOSWebView:le,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(e-0)||"object"==typeof e&&e.constructor===Number),isObject:o,isPlainObject:a,isString:t,isUndefined:e,isUniIOSApp:function(){return G&&"ios"===uni.getDeviceInfo().platform.toLocaleLowerCase()},isValidRequestKey:r,platform:K,randomInt:c,randomString:function(){let t="";for(let s=32;s>0;--s)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return t},safeStringify:Ce});let Ae=function(){return _createClass(function Ae(){_classCallCheck(this,Ae),this.listeners={}},[{key:"on",value:function on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}},{key:"off",value:function off(e,t,s){var n;t&&(this.listeners[e]=null===(n=this.listeners[e])||void 0===n?void 0:n.filter(e=>{const n=e.fn===t,o=!s||e.context===s;return!(n&&o)}))}},{key:"emit",value:function emit(e,...t){const s=this.listeners[e];s&&s.forEach(s=>{const{fn:n,context:o}=s;try{n.apply(o,t)}catch(t){console.warn(`Error in event handler for ${e} error: ${Ce(t)}`)}})}},{key:"once",value:function once(e,t,s){const n=(...o)=>{t.apply(s,o),this.off(e,n)};this.on(e,n)}}])}();!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"}(ye||(ye={}));const Te=[16,17];function Re(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{var t;2===e.GroupInfo.MillionGroupFlag?s.push(ye.TOPIC_TIPS_NOTIFICATION):Te.includes(null===(t=null==e?void 0:e.MsgBody)||void 0===t?void 0:t.OpType)?s.push(ye.GROUP_MESSAGE_PINNED):s.push(ye.GROUP_TIPS_NOTIFICATION)}),s}const De=[{conditions:[{type:"event",value:100}],subType:ye.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:ye.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:ye.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:ye.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:ye.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:ye.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:ye.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:ye.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:ye.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:ye.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.C2cNotifyMsgArray)||void 0===t||t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(ye.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(ye.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(ye.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(ye.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:Re},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(ye.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(ye.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(ye.TOPIC_MESSAGE_READ_SYNC):s.push(ye.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(ye.TOPIC_SYSTEM_NOTIFICATION):s.push(ye.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:Re},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{const{GroupAtTips:{TopicId:t}}=e;t?s.push(ye.TOPIC_AT_TIPS):s.push(ye.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{switch(e.PushType){case M.CONV_MARK_UPDATED:s.push(ye.CONVERSATION_MARK_UPDATED);break;case M.CONV_GROUP_ADDED:s.push(ye.CONVERSATION_GROUP_ADD);break;case M.CONV_GROUP_DELETED:s.push(ye.CONVERSATION_GROUP_DELETED);break;case M.CONV_GROUP_UPDATED:s.push(ye.CONVERSATION_GROUP_UPDATED);break;default:s.push(ye.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:ye.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:ye.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:ye.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:ye.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:ye.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:ye.ALL_MESSAGE_READ}];var be;function Ne(e){var t;const s=Array.isArray(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.EventArray)?e.body.EventArray:[],n=[];return s.forEach(t=>{t.Flag=e.body.Flag;const s=De.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(!s)return null;let o=[];"function"==typeof s.subTypeParser?o=s.subTypeParser(t):s.subType&&(o=s.subType),Array.isArray(o)?o.forEach(e=>{n.push({type:`${be.SERVER_PUSH_MESSAGE}:${e}`,data:t})}):n.push({type:`${be.SERVER_PUSH_MESSAGE}:${o}`,data:t})}),n}!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"}(be||(be={}));const Le={[be.SERVER_PUSH_MESSAGE]:Ne,[be.SERVER_PUSH_MESSAGE_MULTIPLE]:Ne,[be.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}},Pe=new(function(){return _createClass(function _class(){_classCallCheck(this,_class),this._outerEventEmitter=null,this._innerEventEmitter=null,this._filteredCallbackMap=new Map,this._outerEventEmitter=new Ae,this._innerEventEmitter=new Ae,this.InnerEventSubType=ye},[{key:"subscribeInnerEvent",value:function subscribeInnerEvent(e,t,s,n,o){var i;let r,a,c,u;["string","number"].includes(typeof t)?(c=`${e}:${t}`,u=s,a=n,r=o):(c=e,u=t,a=s,r="function"==typeof n?n:void 0),r?this._subscribeWithFilter(c,u,a,r):null===(i=this._innerEventEmitter)||void 0===i||i.on(c,u,a)}},{key:"emitInnerEvent",value:function emitInnerEvent(e,t){var s,n;if(null===(s=this._innerEventEmitter)||void 0===s||s.emit(e,t),Object.keys(Le).includes(e)){const s=null===(n=Le[e])||void 0===n?void 0:n.call(Le,t);null==s||s.forEach(e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))})}}},{key:"subscribeOuterEvent",value:function subscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.on(e,t,s)}},{key:"unSubscribeOuterEvent",value:function unSubscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.off(e,t,s)}},{key:"unSubscribeInnerEvent",value:function unSubscribeInnerEvent(e,t,s,n){if(["string","number"].includes(typeof t)){const o=s,i=`${e}:${t}`;this._unsubscribeEvent(i,o,n)}else{const n=t;this._unsubscribeEvent(e,n,s)}}},{key:"emitOuterEvent",value:function emitOuterEvent(e,t){var s;null===(s=this._outerEventEmitter)||void 0===s||s.emit(e,t)}},{key:"getOuterEventEmitter",value:function getOuterEventEmitter(){return this._outerEventEmitter}},{key:"rest",value:function rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}},{key:"_subscribeWithFilter",value:function _subscribeWithFilter(e,t,s,n){var o;const i=e=>{n.call(s,e)&&t.call(s,e)};this._filteredCallbackMap.has(e)||this._filteredCallbackMap.set(e,[]),this._filteredCallbackMap.get(e).push({originalCallback:t,filteredCallback:i,filter:n,context:s}),null===(o=this._innerEventEmitter)||void 0===o||o.on(e,i,s)}},{key:"_unsubscribeEvent",value:function _unsubscribeEvent(e,t,s){var n,o;const i=this._filteredCallbackMap.get(e);if(i){const o=i.findIndex(e=>e.originalCallback===t&&e.context===s);if(-1!==o){const{filteredCallback:t}=i[o];return null===(n=this._innerEventEmitter)||void 0===n||n.off(e,t,s),i.splice(o,1),void(0===i.length&&this._filteredCallbackMap.delete(e))}}null===(o=this._innerEventEmitter)||void 0===o||o.off(e,t,s)}}])}());let Ge=function(){return _createClass(function Ge(){_classCallCheck(this,Ge),this._socket=null},[{key:"connectSocket",value:function connectSocket(e){return this._socket=new WebSocket(e),this._socket}},{key:"send",value:function send(e){var t,s;try{null===(t=this._socket)||void 0===t||t.send(e)}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}},{key:"bindSocketHandlers",value:function bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=t,this._socket.onmessage=s,this._socket.onclose=n,this._socket.onerror=o,this._onSendFail=i)}},{key:"unbindSocketHandlers",value:function unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}},{key:"disconnect",value:function disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}])}(),we=function(){return _createClass(function we(e){_classCallCheck(this,we),this._onError=e.onError},[{key:"connectSocket",value:function connectSocket(e){const t=this;return this._socket=B.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{},fail:e=>t._onError(e)}),this._socket}},{key:"send",value:function send(e){var t;null===(t=this._socket)||void 0===t||t.send({data:e,fail:this._onSendFail})}},{key:"bindSocketHandlers",value:function bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;this._socket&&(this._socket.onClose(n),this._socket.onOpen(t),this._socket.onMessage(s),this._socket.onError(o),this._onSendFail=i)}},{key:"unbindSocketHandlers",value:function unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}},{key:"disconnect",value:function disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}])}();const $e="OPEN",xe="MESSAGE",qe="CLOSE",Ve="ERROR",Be="SEND_FAIL";let je=function(){return _createClass(function je(){_classCallCheck(this,je),this._worker=null,this._blobUrl=null},[{key:"connectSocket",value:function connectSocket(e){const 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:"CONNECT",url:e})}},{key:"send",value:function send(e){var t,s;try{null===(t=this._worker)||void 0===t||t.postMessage({type:"SEND",data:e})}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}},{key:"bindSocketHandlers",value:function bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;if(this._worker){const e={[$e]:t,[xe]:s,[qe]:n,[Ve]:o,[Be]:i};this._onSendFail=i,this._worker.onmessage=t=>{var s;const{type:n}=(null==t?void 0:t.data)||{};"function"==typeof e[n]&&(null===(s=e[n])||void 0===s||s.call(e,null==t?void 0:t.data))}}}},{key:"unbindSocketHandlers",value:function unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}},{key:"disconnect",value:function disconnect(){this._worker&&(this._worker.postMessage({type:"DISCONNECT"}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}])}(),He=_createClass(function He(){_classCallCheck(this,He)});var Ke,We=new(function(){return _createClass(function _class2(){_classCallCheck(this,_class2),this._store=new Map},[{key:"get",value:function get(e){return this._store.get(e)}},{key:"getStorage",value:function getStorage(e){return F?L?my.getStorageSync({key:e}).data:B.getStorageSync(e):this._canUseLocalStorage()?localStorage.getItem(e):{}}},{key:"set",value:function set(e,t){const s=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},s),t))}},{key:"setStorage",value:function setStorage(e,t){F?L?my.setStorageSync({key:e,data:JSON.stringify(t)}):B.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}},{key:"clear",value:function clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}},{key:"clearLocalStorage",value:function clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}},{key:"reset",value:function reset(){this.clear()}},{key:"_canUseLocalStorage",value:function _canUseLocalStorage(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}}])}());let Ye=function(){return _createClass(function Ye(){_classCallCheck(this,Ye)},[{key:"connectSocket",value:function connectSocket(e){return this._socket=B.connectSocket({url:e,header:{"content-type":"application/json"},multiple:!0,complete:()=>{}}),this._socket}},{key:"send",value:function send(e){var t;null===(t=this._socket)||void 0===t||t.send({data:e,fail:this._onSendFail})}},{key:"bindSocketHandlers",value:function bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;this._socket&&(this._socket.onClose(n),this._socket.onOpen(t),this._socket.onMessage(e=>s(null==e?void 0:e.data)),this._socket.onError(()=>o),this._onSendFail=i)}},{key:"unbindSocketHandlers",value:function unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}},{key:"disconnect",value:function disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}])}();!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}(Ke||(Ke={}));let ze=function(){return _createClass(function ze(e){_classCallCheck(this,ze),this._url="",this._readyState=Ke.DISCONNECTED,this._url=e,this._id=c(),this._emitter=new Ae,L?this._socket=new Ye:A||G||D||R||P||N?this._socket=new we({onError:this._onError.bind(this)}):he?this._socket=new He:this._canUseWebWorker()?this._socket=new je:this._socket=new Ge,this.connect()},[{key:"connect",value:function connect(){this.doOpen(),this._bindSocketHandlers()}},{key:"doOpen",value:function doOpen(){[Ke.CONNECTED,Ke.CONNECTING].includes(this._readyState)||(this._readyState=Ke.CONNECTING,this._ws=this._socket.connectSocket(this._url))}},{key:"send",value:function send(e){this._readyState!==Ke.CONNECTED?this.reconnect():this._socket.send(e)}},{key:"reconnect",value:function reconnect(){[Ke.CONNECTED,Ke.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}},{key:"getId",value:function getId(){return this._id}},{key:"on",value:function on(e,t,s){this._emitter.on(e,t,s)}},{key:"off",value:function off(e,t,s){this._emitter.off(e,t,s)}},{key:"isConnected",value:function isConnected(){return this._readyState===Ke.CONNECTED}},{key:"disconnect",value:function disconnect(){this._readyState=Ke.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}},{key:"_onOpen",value:function _onOpen(e){this._readyState===Ke.CONNECTING&&(this._readyState=Ke.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}},{key:"_onMessage",value:function _onMessage(e){this._emitter.emit("message",e)}},{key:"_onClose",value:function _onClose(e){this._readyState=Ke.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}},{key:"_onError",value:function _onError(e){this._readyState=Ke.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}},{key:"_onSendFail",value:function _onSendFail(e){this._readyState=Ke.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}},{key:"_bindSocketHandlers",value:function _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)})}},{key:"_unbindSocketHandlers",value:function _unbindSocketHandlers(){this._socket.unbindSocketHandlers()}},{key:"_canUseWebWorker",value:function _canUseWebWorker(){const t=We.get("cloudConfig")||{};return(e(t.isWorkerEnabled)||"1"===t.isWorkerEnabled)&&ce}}])}();const Je={[S.SINGAPORE]:[[2e7,3e7],[172e7,173e7]],[S.KOREA]:[[3e7,4e7],[173e7,174e7]],[S.GERMANY]:[[4e7,5e7],[174e7,175e7]],[S.IND]:[[5e7,6e7],[175e7,176e7]],[S.JPN]:[[6e7,7e7],[176e7,177e7]],[S.USA]:[[7e7,8e7],[177e7,178e7]],[S.INDONESIA]:[[8e7,9e7],[178e7,179e7]],[S.KSA]:[[9e7,1e8],[179e7,18e8]]};function Qe(e){var t;if(null===(t=We.get("instance"))||void 0===t?void 0:t.oversea)return S.OVERSEA;for(const t of Object.keys(Je))for(const[s,n]of Je[t])if(e>=s&&e<n)return t;return S.CHINA}var Xe,Ze="4.4.3";!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"}(Xe||(Xe={}));let et=Xe.INITIAL;function st(){const e=Math.random();return 0===e?st():e}function nt(e,t){const{isBinary:s=!1}=t||{},n=We.get("instance"),{sdkAppId:o,instanceId:i}=n,r=st(),a=de(),c=function(){const e=de();let t=-1;return"ios"===e?t=Q||-1:"android"===e&&(t=Z||-1),t}(),u=(l={sdkappid:o,instanceid:i,random:r,platform:K,host:a,version:c,sdkversion:Ze},Object.keys(l).map(e=>`${e}=${l[e]}`).join("&"));var l;return s?`${e}/binfo?${u}&compress=gzip`:`${e}/info?${u}`}var it=new(function(){return _createClass(function _class3(){_classCallCheck(this,_class3),this._timeOffsetWithServer=0},[{key:"getServerTimeMs",value:function getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}},{key:"getServerTimeSeconds",value:function getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}},{key:"getTimeOffsetWithServer",value:function getTimeOffsetWithServer(){return this._timeOffsetWithServer}},{key:"calculateTimeOffsetWithServer",value:function calculateTimeOffsetWithServer(e,t){const s=Date.now(),n=s-e;this._timeOffsetWithServer=t+n-s}}])}());const rt=16;var at=new(function(){return _createClass(function _class4(){_classCallCheck(this,_class4),this._tasks=[],this._timer=null,this._taskMap=new Map},[{key:"_addTaskToScheduler",value:function _addTaskToScheduler(e){const{id:t}=e;this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}},{key:"_createTask",value:function _createTask(e){const{id:t,callback:s,context:n,isOnce:o=!1,intervalMs:i=rt}=e,r=Math.max(i,rt);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:i,callback:s,context:n,isOnce:o}}},{key:"addTask",value:function addTask(e){const t=this._createTask(e);this._addTaskToScheduler(t)}},{key:"addOnceTask",value:function addOnceTask(e){const t=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(t)}},{key:"removeTask",value:function removeTask(e){const t=this._tasks.findIndex(t=>t.id===e);t>-1&&(this._tasks.splice(t,1),this._taskMap.delete(e),this._scheduleNextTask())}},{key:"updateTaskInterval",value:function updateTaskInterval(e,t){const s=this._taskMap.get(e);s&&(s.intervalMs=t,s.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}},{key:"clearAllTasks",value:function clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}},{key:"dispose",value:function dispose(){this.clearAllTasks()}},{key:"_sort",value:function _sort(){this._tasks.sort((e,t)=>e.nextExecuteTime-t.nextExecuteTime)}},{key:"_scheduleNextTask",value:function _scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);const e=this._tasks[0];if(e){const t=Math.max(0,e.nextExecuteTime-Date.now());this._timer=setTimeout(()=>this._execute(),t)}}},{key:"_execute",value:function _execute(){const e=Date.now();for(;this._tasks.length&&this._tasks[0].nextExecuteTime<=e;){const 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 ct(e){const t=[];for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n>=55296&&n<=56319){const o=e.charCodeAt(++s)-56320+(n-55296<<10)+65536;t.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|63&o)}else n<=127?t.push(n):n<=2047?t.push(192|n>>6,128|63&n):t.push(224|n>>12,128|n>>6&63,128|63&n)}return new Uint8Array(t)}function ut(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&r(s)&&null!=e[s]&&(null===e[s]||"object"!=typeof e[s]?t[s]=e[s]:t[s]=ut(e[s]));return t}function lt(e,t){if(h.includes(e))return 0;const s=ct(JSON.stringify(t));let n=4294967295;const{length:o}=s;for(let e=0;e<o;e++){n^=s[e];for(let e=0;e<8;e++)1&~n?n>>>=1:n=n>>>1^3988292384}return(4294967295^n)>>>0}function dt(e){const{servcmd:t,data:s}=e,n=function(e){const t=We.get("login")||{},s=We.get("instance")||{};return{servcmd:e,ver:"v4",platform:K,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:s.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.a2Key?void 0:t.userId,usersig:t.a2Key?void 0:t.userSig,sdkability:478343027,sdkability_ext:l(""),cappid:s.applicationID||0,tjgID:"",seq:pt(),cs:0}}(t),o=ut(s);return n.cs=lt(t,o),{head:n,body:o}}function ht(e){const{servcmd:t,data:s}=e,n=function(e){const t=We.get("login")||{},s=We.get("instance")||{};return{servcmd:e,ver:"v4",platform:K,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:478343027,sdkability_ext:l(""),cappid:s.applicationID||0,seq:pt(),cs:0}}(t),o=ut(s);return n.cs=lt(t,o),{head:n,body:o}}let gt=c();function pt(){return gt=gt<2415919103?gt+1:c(),gt}function _t(){var e;const t=We.get("login")||{},s=We.get("instance")||{};return{sdk_type:30,sdk_app_id:s.sdkAppId,sdk_version:"4.4.3",tiny_id:Number(t.tinyID),user_id:t.userId||(null===(e=We.get("webPush"))||void 0===e?void 0:e.userId),platform:K,instance_id:s.instanceId,trace_id:(new Date).getTime()}}var mt,vt=Object.freeze({__proto__:null,calcBodyCRC:lt,filterProtocolDataInvalidFields:ut,generateCosSpecifiedData:function(e){const{servcmd:t,data:s}=e,n=function(e){const t=We.get("login")||{},s=We.get("instance")||{};return{servcmd:e,ver:"v4",platform:K,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:478343027,sdkability_ext:l(""),cappid:s.applicationID||0,seq:pt(),cs:0}}(t),o=ut(s);return n.cs=lt(t,o),{head:n,body:o}},generateProtocolData:dt,generateSSOLogProtocolData:ht,generateSequence:pt,getCommonHead:_t,getHostSite:Qe,taskScheduler:at,timeManager:it});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(mt||(mt={}));const ft={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"};let It=function(){return _createClass(function It(e){_classCallCheck(this,It),this.level=mt.info,this._canSendLog=!0,this._logCreatedAt=it.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();const{method:t,eventType:s=0,message:n="",costTime:o=0,error:i,uiPlatform:r,moreMessage:a="",code:c=0,startTime:u=0}=e||{};this.eventType=s,this.method=t,this.message=n,this.costTime=o,this.moreMessage=`${a} startTime:${u}`,this.code=c,i&&this.setError(i),Ee(r)||(this.uiPlatform=r)},[{key:"setMoreMessage",value:function setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}},{key:"updateLogCreatedAtByTimeOffset",value:function updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=it.getTimeOffsetWithServer()}},{key:"end",value:function end(e=!1){this._canSendLog&&(this._canSendLog=!1,this.timestamp=it.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe()),e&&this._ssoLogModule.uploadSSOLogData())}},{key:"setError",value:function setError(e){var t;return e instanceof Error?this._canSendLog?((null===(t=We.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=mt.error,this):this:(console.warn("SSOLogData.setError value not instanceof Error, please check!"),this)}},{key:"setLogInfo",value:function setLogInfo(e){return Object.keys(e).forEach(t=>{Object.keys(ft).includes(t)&&(this[t]=e[t])}),this}},{key:"setSSOLogModule",value:function setSSOLogModule(e){this._ssoLogModule=e}},{key:"_convertSSOLogDataKeyToServe",value:function _convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach(t=>{const s=t;ft[s]&&(e[ft[s]]=this[s])}),e}},{key:"_getUiPlatform",value:function _getUiPlatform(){var e;const t=null===(e=We.get("instance"))||void 0===e?void 0:e.scene;if("string"==typeof t){const e=Number(t);return isNaN(e)?void 0:e}}},{key:"_getSDKEdition",value:function _getSDKEdition(){var e;return null===(e=We.get("instance"))||void 0===e?void 0:e.sdkEdition}}])}();var Et;!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(Et||(Et={}));var St=Et;const Ct=20,Mt=6e4,yt=[4,5,6],Ot="report-logger";var At=new(function(){return _createClass(function _class5(){_classCallCheck(this,_class5),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=Ct,this._maxThreshold=100,this._waitingTime=Mt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,this._logLevel=g.DEBUG,this._throttleConfig={global:{throttleTime:I,maxCount:E},single:{throttleTime:v,maxCount:f}},this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap=new Map,Pe.subscribeInnerEvent(St.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),at.addTask({id:Ot,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()},[{key:"_handleCloudConfigUpdate",value:function _handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=Ct,evt_rpt_waiting:s=Mt,evt_rpt_level:n=yt,evt_rpt_sdkappid_bl:o="",evt_rpt_tinyid_wl:i="",evt_rpt_global_throttle_time:r=I,evt_rpt_global_throttle_count:a=E,evt_rpt_single_throttle_time:c=v,evt_rpt_single_throttle_count:u=f}=e||{};this._sdkAppIdBlackList=o.split(",").map(e=>Number(e)),this._waitingTime=Number(s),this._minThreshold=t,this._reportLevel=n,this._tinyIdWhiteList=i.split(","),this._throttleConfig={global:{throttleTime:r,maxCount:a},single:{throttleTime:c,maxCount:u}}}},{key:"createSSOLogData",value:function createSSOLogData(e){const t=new It(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}},{key:"getSSOLogData",value:function getSSOLogData(e){return this._ssoLogMap.get(e)||{}}},{key:"pushToLogQueue",value:function pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately()&&this.uploadSSOLogData())}},{key:"setLogLevel",value:function setLogLevel(e){[g.DEBUG,g.ERROR,g.INFO,g.NONE,g.WARN].includes(e)&&(this._logLevel=e)}},{key:"debug",value:function debug(e,t="",s){this._log(g.DEBUG,e,t,s)}},{key:"info",value:function info(e,t="",s){this._log(g.INFO,e,t,s)}},{key:"warn",value:function warn(e,t="",s){this._log(g.WARN,e,t,s)}},{key:"error",value:function error(e,t="",s){this._log(g.ERROR,e,t,s)}},{key:"_shouldUploadImmediately",value:function _shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}},{key:"_isReportDue",value:function _isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}},{key:"_checkAndReportIfDue",value:function _checkAndReportIfDue(){this._isReportDue()&&this._logQueue.length>0&&this.uploadSSOLogData()}},{key:"uploadSSOLogData",value:function uploadSSOLogData(){return pe(this,void 0,void 0,function*(){if(0===this._logQueue.length)return;const e=this._logQueue.slice();this._logQueue=[];try{const t=this._filterLogs(e);if(0===t.length)return void(this._lastReportAt=Date.now());const s={Header:_t(),Event:t};Ee(s.Header.user_id)||(yield function(e){const t="imopenstat.tim_web_report_v2",s=ht({servcmd:t,data:e}),n=`${s.head.seq}${t}`;return Wt.sendPacket(s,{requestId:n})}(s))}catch(t){this._requeueFailedLogs(e),this.debug("uploadSSOLogData",Ce(t))}finally{this._lastReportAt=Date.now()}})}},{key:"_requeueFailedLogs",value:function _requeueFailedLogs(e){this._logQueue=e.concat(this._logQueue);const t=this._logQueue.length-200;t>0&&(this._logQueue.splice(0,t),this.debug("uploadSSOLogData",`log queue overflow, dropped ${t} oldest logs`))}},{key:"_savePlatFormInfo",value:function _savePlatFormInfo(){var e,t;if(A){const s=null===(t=null===(e=wx.getAccountInfoSync)||void 0===e?void 0:e.call(wx))||void 0===t?void 0:t.miniProgram;if(s){const{appId:e,envVersion:t}=s;We.set("instance",{appId:e,envVersion:t})}}else V&&We.set("instance",{href:window.location.href})}},{key:"_filterLogs",value:function _filterLogs(e){const{tinyID:t}=We.get("login")||{},{sdkAppId:s}=We.get("instance")||{};return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}},{key:"_checkThrottle",value:function _checkThrottle(e){return!!this._checkGlobalThrottle()||this._checkSingleThrottle(e)}},{key:"_checkGlobalThrottle",value:function _checkGlobalThrottle(){const 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}},{key:"_checkSingleThrottle",value:function _checkSingleThrottle(e){const 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)}},{key:"_shouldLog",value:function _shouldLog(e){return e>=this._logLevel&&this._logLevel!==g.NONE}},{key:"_shouldReport",value:function _shouldReport(e){return this._reportLevel.includes(m[e])}},{key:"_formatLog",value:function _formatLog(e,t,s,n){const o=new Date,i=`${o.getHours()}:${o.getMinutes()}:${o.getSeconds()}:${o.getMilliseconds()}`,r=`<${g[e]}>`;return ne||F?[`${p} [${i}] ${r} [${t}] ${s}`]:["%c%s%c%s","background:#0abf5b; padding:1px; border-radius:3px; color: #fff",p,"",`[${i}] ${r} [${t}] ${s} params: ${Ce(n)}`]}},{key:"_log",value:function _log(e,t,s,n){if(this._shouldLog(e)){const o=this._formatLog(e,t,s,n);_[e].apply(console,o)}if(this._shouldReport(e)){const e=this._getThrottleKey(t,s,n);this._checkThrottle(e)||this.createSSOLogData(Object.assign(Object.assign({message:s},n),{method:t})).end()}}},{key:"_getThrottleKey",value:function _getThrottleKey(e,t,s){const n=`${e}${t}${Ce(Object.assign(Object.assign({},s),{costTime:""}))}`,o=ct(JSON.stringify(n));let i=4294967295;const{length:r}=o;for(let e=0;e<r;e++){i^=o[e];for(let e=0;e<8;e++)1&~i?i>>>=1:i=i>>>1^3988292384}return`${(4294967295^i)>>>0}`}},{key:"reset",value:function reset(){console.log("SSO_LOG_MODULE.reset"),at.removeTask(Ot),Pe.unSubscribeInnerEvent(St.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=Ct,this._maxThreshold=100,this._waitingTime=Mt,this._logQueue=[],this._logLevel=g.DEBUG,this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap.clear()}}])}());const Tt=15e3,Rt="Channel",Dt="channel_schedule_task",bt="channel_reconnect_task",Nt="connected",Pt="disconnected",wt="network_status_change";function Vt(e){return Vt="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},Vt(e)}function Bt(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 jt,Ht={exports:{}},Kt=(jt||(jt=1,Ht.exports=function e(t,s,n){function o(r,a){if(!s[r]){if(!t[r]){if(!a&&Bt)return Bt(r);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var u=s[r]={exports:{}};t[r][0].call(u.exports,function(e){return o(t[r][1][e]||e)},u,u.exports,e,t,s,n)}return s[r].exports}for(var i=Bt,r=0;r<n.length;r++)o(n[r]);return o}({1:[function(e,t,s){var n="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;s.assign=function(e){for(var t,s,n=Array.prototype.slice.call(arguments,1);n.length;){var o=n.shift();if(o){if("object"!=Vt(o))throw new TypeError(o+"must be non-object");for(var i in o)t=o,s=i,Object.prototype.hasOwnProperty.call(t,s)&&(e[i]=o[i])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var o={arraySet:function(e,t,s,n,o){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),o);else for(var i=0;i<n;i++)e[o+i]=t[s+i]},flattenChunks:function(e){var t,s,n,o,i,r;for(t=n=0,s=e.length;t<s;t++)n+=e[t].length;for(r=new Uint8Array(n),t=o=0,s=e.length;t<s;t++)i=e[t],r.set(i,o),o+=i.length;return r}},i={arraySet:function(e,t,s,n,o){for(var i=0;i<n;i++)e[o+i]=t[s+i]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,o)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,i))},s.setTyped(n)},{}],2:[function(e,t,s){var n=e("./common"),o=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch(e){o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){i=!1}for(var r=new n.Buf8(256),a=0;a<256;a++)r[a]=252<=a?6:248<=a?5:240<=a?4:224<=a?3:192<=a?2:1;function c(e,t){if(t<65534&&(e.subarray&&i||!e.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(e,t));for(var s="",r=0;r<t;r++)s+=String.fromCharCode(e[r]);return s}r[254]=r[254]=1,s.string2buf=function(e){var t,s,o,i,r,a=e.length,c=0;for(i=0;i<a;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),c+=s<128?1:s<2048?2:s<65536?3:4;for(t=new n.Buf8(c),i=r=0;r<c;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(o=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(o-56320),i++),s<128?t[r++]=s:(s<2048?t[r++]=192|s>>>6:(s<65536?t[r++]=224|s>>>12:(t[r++]=240|s>>>18,t[r++]=128|s>>>12&63),t[r++]=128|s>>>6&63),t[r++]=128|63&s);return t},s.buf2binstring=function(e){return c(e,e.length)},s.binstring2buf=function(e){for(var t=new n.Buf8(e.length),s=0,o=t.length;s<o;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){var s,n,o,i,a=t||e.length,u=new Array(2*a);for(s=n=0;s<a;)if((o=e[s++])<128)u[n++]=o;else if(4<(i=r[o]))u[n++]=65533,s+=i-1;else{for(o&=2===i?31:3===i?15:7;1<i&&s<a;)o=o<<6|63&e[s++],i--;1<i?u[n++]=65533:o<65536?u[n++]=o:(o-=65536,u[n++]=55296|o>>10&1023,u[n++]=56320|1023&o)}return c(u,n)},s.utf8border=function(e,t){var s;for((t=t||e.length)>e.length&&(t=e.length),s=t-1;0<=s&&128==(192&e[s]);)s--;return s<0||0===s?t:s+r[e[s]]>t?s:t}},{"./common":1}],3:[function(e,t,s){t.exports=function(e,t,s,n){for(var o=65535&e,i=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;i=i+(o=o+t[n++]|0)|0,--r;);o%=65521,i%=65521}return o|i<<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 n=function(){for(var e,t=[],s=0;s<256;s++){e=s;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}();t.exports=function(e,t,s,o){var i=n,r=o+s;e^=-1;for(var a=o;a<r;a++)e=e>>>8^i[255&(e^t[a])];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,o,i,r,a,c,u,l,d,h,g,p,_,m,v,f,I,E,S,C,M,y,O,A;s=e.state,n=e.next_in,O=e.input,o=n+(e.avail_in-5),i=e.next_out,A=e.output,r=i-(t-e.avail_out),a=i+(e.avail_out-257),c=s.dmax,u=s.wsize,l=s.whave,d=s.wnext,h=s.window,g=s.hold,p=s.bits,_=s.lencode,m=s.distcode,v=(1<<s.lenbits)-1,f=(1<<s.distbits)-1;e:do{p<15&&(g+=O[n++]<<p,p+=8,g+=O[n++]<<p,p+=8),I=_[g&v];t:for(;;){if(g>>>=E=I>>>24,p-=E,0==(E=I>>>16&255))A[i++]=65535&I;else{if(!(16&E)){if(!(64&E)){I=_[(65535&I)+(g&(1<<E)-1)];continue t}if(32&E){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}S=65535&I,(E&=15)&&(p<E&&(g+=O[n++]<<p,p+=8),S+=g&(1<<E)-1,g>>>=E,p-=E),p<15&&(g+=O[n++]<<p,p+=8,g+=O[n++]<<p,p+=8),I=m[g&f];s:for(;;){if(g>>>=E=I>>>24,p-=E,!(16&(E=I>>>16&255))){if(!(64&E)){I=m[(65535&I)+(g&(1<<E)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(C=65535&I,p<(E&=15)&&(g+=O[n++]<<p,(p+=8)<E&&(g+=O[n++]<<p,p+=8)),c<(C+=g&(1<<E)-1)){e.msg="invalid distance too far back",s.mode=30;break e}if(g>>>=E,p-=E,(E=i-r)<C){if(l<(E=C-E)&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(y=h,(M=0)===d){if(M+=u-E,E<S){for(S-=E;A[i++]=h[M++],--E;);M=i-C,y=A}}else if(d<E){if(M+=u+d-E,(E-=d)<S){for(S-=E;A[i++]=h[M++],--E;);if(M=0,d<S){for(S-=E=d;A[i++]=h[M++],--E;);M=i-C,y=A}}}else if(M+=d-E,E<S){for(S-=E;A[i++]=h[M++],--E;);M=i-C,y=A}for(;2<S;)A[i++]=y[M++],A[i++]=y[M++],A[i++]=y[M++],S-=3;S&&(A[i++]=y[M++],1<S&&(A[i++]=y[M++]))}else{for(M=i-C;A[i++]=A[M++],A[i++]=A[M++],A[i++]=A[M++],2<(S-=3););S&&(A[i++]=A[M++],1<S&&(A[i++]=A[M++]))}break}}break}}while(n<o&&i<a);n-=S=p>>3,g&=(1<<(p-=S<<3))-1,e.next_in=n,e.next_out=i,e.avail_in=n<o?o-n+5:5-(n-o),e.avail_out=i<a?a-i+257:257-(i-a),s.hold=g,s.bits=p}},{}],8:[function(e,t,s){var n=e("../utils/common"),o=e("./adler32"),i=e("./crc32"),r=e("./inffast"),a=e("./inftrees"),d=-2;function _(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){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 n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new n.Buf32(852),t.distcode=t.distdyn=new n.Buf32(592),t.sane=1,t.back=-1,0):d}function f(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,v(e)):d}function I(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)?d:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,f(e))):d}function E(e,t){var s,n;return e?(n=new m,(e.state=n).window=null,0!==(s=I(e,t))&&(e.state=null),s):d}var S,C,M=!0;function y(e){if(M){var t;for(S=new n.Buf32(512),C=new n.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(a(1,e.lens,0,288,S,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(2,e.lens,0,32,C,0,e.work,{bits:5}),M=!1}e.lencode=S,e.lenbits=9,e.distcode=C,e.distbits=5}function O(e,t,s,o){var i,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new n.Buf8(r.wsize)),o>=r.wsize?(n.arraySet(r.window,t,s-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(o<(i=r.wsize-r.wnext)&&(i=o),n.arraySet(r.window,t,s-o,i,r.wnext),(o-=i)?(n.arraySet(r.window,t,s-o,o,0),r.wnext=o,r.whave=r.wsize):(r.wnext+=i,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=i))),0}s.inflateReset=f,s.inflateReset2=I,s.inflateResetKeep=v,s.inflateInit=function(e){return E(e,15)},s.inflateInit2=E,s.inflate=function(e,t){var s,g,p,m,v,f,I,E,S,C,M,A,T,R,D,b,N,L,P,G,w,U,k,F,$=0,x=new n.Buf8(4),q=[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 d;12===(s=e.state).mode&&(s.mode=13),v=e.next_out,p=e.output,I=e.avail_out,m=e.next_in,g=e.input,f=e.avail_in,E=s.hold,S=s.bits,C=f,M=I,U=0;e:for(;;)switch(s.mode){case 1:if(0===s.wrap){s.mode=13;break}for(;S<16;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(2&s.wrap&&35615===E){x[s.check=0]=255&E,x[1]=E>>>8&255,s.check=i(s.check,x,2,0),S=E=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&E)<<8)+(E>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&E)){e.msg="unknown compression method",s.mode=30;break}if(S-=4,w=8+(15&(E>>>=4)),0===s.wbits)s.wbits=w;else if(w>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<w,e.adler=s.check=1,s.mode=512&E?10:12,S=E=0;break;case 2:for(;S<16;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(s.flags=E,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=E>>8&1),512&s.flags&&(x[0]=255&E,x[1]=E>>>8&255,s.check=i(s.check,x,2,0)),S=E=0,s.mode=3;case 3:for(;S<32;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}s.head&&(s.head.time=E),512&s.flags&&(x[0]=255&E,x[1]=E>>>8&255,x[2]=E>>>16&255,x[3]=E>>>24&255,s.check=i(s.check,x,4,0)),S=E=0,s.mode=4;case 4:for(;S<16;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}s.head&&(s.head.xflags=255&E,s.head.os=E>>8),512&s.flags&&(x[0]=255&E,x[1]=E>>>8&255,s.check=i(s.check,x,2,0)),S=E=0,s.mode=5;case 5:if(1024&s.flags){for(;S<16;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}s.length=E,s.head&&(s.head.extra_len=E),512&s.flags&&(x[0]=255&E,x[1]=E>>>8&255,s.check=i(s.check,x,2,0)),S=E=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(f<(A=s.length)&&(A=f),A&&(s.head&&(w=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),n.arraySet(s.head.extra,g,m,A,w)),512&s.flags&&(s.check=i(s.check,g,A,m)),f-=A,m+=A,s.length-=A),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===f)break e;for(A=0;w=g[m+A++],s.head&&w&&s.length<65536&&(s.head.name+=String.fromCharCode(w)),w&&A<f;);if(512&s.flags&&(s.check=i(s.check,g,A,m)),f-=A,m+=A,w)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===f)break e;for(A=0;w=g[m+A++],s.head&&w&&s.length<65536&&(s.head.comment+=String.fromCharCode(w)),w&&A<f;);if(512&s.flags&&(s.check=i(s.check,g,A,m)),f-=A,m+=A,w)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;S<16;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(E!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}S=E=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(;S<32;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}e.adler=s.check=_(E),S=E=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=v,e.avail_out=I,e.next_in=m,e.avail_in=f,s.hold=E,s.bits=S,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last){E>>>=7&S,S-=7&S,s.mode=27;break}for(;S<3;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}switch(s.last=1&E,S-=1,3&(E>>>=1)){case 0:s.mode=14;break;case 1:if(y(s),s.mode=20,6!==t)break;E>>>=2,S-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}E>>>=2,S-=2;break;case 14:for(E>>>=7&S,S-=7&S;S<32;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if((65535&E)!=(E>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&E,S=E=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(A=s.length){if(f<A&&(A=f),I<A&&(A=I),0===A)break e;n.arraySet(p,g,m,A,v),f-=A,m+=A,I-=A,v+=A,s.length-=A;break}s.mode=12;break;case 17:for(;S<14;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(s.nlen=257+(31&E),E>>>=5,S-=5,s.ndist=1+(31&E),E>>>=5,S-=5,s.ncode=4+(15&E),E>>>=4,S-=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(;S<3;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}s.lens[q[s.have++]]=7&E,E>>>=3,S-=3}for(;s.have<19;)s.lens[q[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,k={bits:s.lenbits},U=a(0,s.lens,0,19,s.lencode,0,s.work,k),s.lenbits=k.bits,U){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(;b=($=s.lencode[E&(1<<s.lenbits)-1])>>>16&255,N=65535&$,!((D=$>>>24)<=S);){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(N<16)E>>>=D,S-=D,s.lens[s.have++]=N;else{if(16===N){for(F=D+2;S<F;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(E>>>=D,S-=D,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}w=s.lens[s.have-1],A=3+(3&E),E>>>=2,S-=2}else if(17===N){for(F=D+3;S<F;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}S-=D,w=0,A=3+(7&(E>>>=D)),E>>>=3,S-=3}else{for(F=D+7;S<F;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}S-=D,w=0,A=11+(127&(E>>>=D)),E>>>=7,S-=7}if(s.have+A>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;A--;)s.lens[s.have++]=w}}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,k={bits:s.lenbits},U=a(1,s.lens,0,s.nlen,s.lencode,0,s.work,k),s.lenbits=k.bits,U){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,k={bits:s.distbits},U=a(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,k),s.distbits=k.bits,U){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<=f&&258<=I){e.next_out=v,e.avail_out=I,e.next_in=m,e.avail_in=f,s.hold=E,s.bits=S,r(e,M),v=e.next_out,p=e.output,I=e.avail_out,m=e.next_in,g=e.input,f=e.avail_in,E=s.hold,S=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;b=($=s.lencode[E&(1<<s.lenbits)-1])>>>16&255,N=65535&$,!((D=$>>>24)<=S);){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(b&&!(240&b)){for(L=D,P=b,G=N;b=($=s.lencode[G+((E&(1<<L+P)-1)>>L)])>>>16&255,N=65535&$,!(L+(D=$>>>24)<=S);){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}E>>>=L,S-=L,s.back+=L}if(E>>>=D,S-=D,s.back+=D,s.length=N,0===b){s.mode=26;break}if(32&b){s.back=-1,s.mode=12;break}if(64&b){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&b,s.mode=22;case 22:if(s.extra){for(F=s.extra;S<F;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}s.length+=E&(1<<s.extra)-1,E>>>=s.extra,S-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;b=($=s.distcode[E&(1<<s.distbits)-1])>>>16&255,N=65535&$,!((D=$>>>24)<=S);){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(!(240&b)){for(L=D,P=b,G=N;b=($=s.distcode[G+((E&(1<<L+P)-1)>>L)])>>>16&255,N=65535&$,!(L+(D=$>>>24)<=S);){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}E>>>=L,S-=L,s.back+=L}if(E>>>=D,S-=D,s.back+=D,64&b){e.msg="invalid distance code",s.mode=30;break}s.offset=N,s.extra=15&b,s.mode=24;case 24:if(s.extra){for(F=s.extra;S<F;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}s.offset+=E&(1<<s.extra)-1,E>>>=s.extra,S-=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===I)break e;if(A=M-I,s.offset>A){if((A=s.offset-A)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}A>s.wnext?(A-=s.wnext,T=s.wsize-A):T=s.wnext-A,A>s.length&&(A=s.length),R=s.window}else R=p,T=v-s.offset,A=s.length;for(I<A&&(A=I),I-=A,s.length-=A;p[v++]=R[T++],--A;);0===s.length&&(s.mode=21);break;case 26:if(0===I)break e;p[v++]=s.length,I--,s.mode=21;break;case 27:if(s.wrap){for(;S<32;){if(0===f)break e;f--,E|=g[m++]<<S,S+=8}if(M-=I,e.total_out+=M,s.total+=M,M&&(e.adler=s.check=s.flags?i(s.check,p,M,v-M):o(s.check,p,M,v-M)),M=I,(s.flags?E:_(E))!==s.check){e.msg="incorrect data check",s.mode=30;break}S=E=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;S<32;){if(0===f)break e;f--,E+=g[m++]<<S,S+=8}if(E!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}S=E=0}s.mode=29;case 29:U=1;break e;case 30:U=-3;break e;case 31:return-4;default:return d}return e.next_out=v,e.avail_out=I,e.next_in=m,e.avail_in=f,s.hold=E,s.bits=S,(s.wsize||M!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&O(e,e.output,e.next_out,M-e.avail_out)?(s.mode=31,-4):(C-=e.avail_in,M-=e.avail_out,e.total_in+=C,e.total_out+=M,s.total+=M,s.wrap&&M&&(e.adler=s.check=s.flags?i(s.check,p,M,e.next_out-M):o(s.check,p,M,e.next_out-M)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),(0===C&&0===M||4===t)&&0===U&&(U=-5),U)},s.inflateEnd=function(e){if(!e||!e.state)return d;var t=e.state;return t.window&&(t.window=null),e.state=null,0},s.inflateGetHeader=function(e,t){var s;return e&&e.state&&2&(s=e.state).wrap?((s.head=t).done=!1,0):d},s.inflateSetDictionary=function(e,t){var s,n=t.length;return e&&e.state?0!==(s=e.state).wrap&&11!==s.mode?d:11===s.mode&&o(1,t,n,0)!==s.check?-3:O(e,t,n,n)?(s.mode=31,-4):(s.havedict=1,0):d},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,s){var n=e("../utils/common"),o=[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],i=[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],r=[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],a=[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,c,u,l,d,h){var g,p,_,m,v,f,I,E,S,C=h.bits,M=0,y=0,O=0,A=0,T=0,R=0,D=0,b=0,N=0,L=0,P=null,G=0,w=new n.Buf16(16),U=new n.Buf16(16),k=null,F=0;for(M=0;M<=15;M++)w[M]=0;for(y=0;y<c;y++)w[t[s+y]]++;for(T=C,A=15;1<=A&&0===w[A];A--);if(A<T&&(T=A),0===A)return u[l++]=20971520,u[l++]=20971520,h.bits=1,0;for(O=1;O<A&&0===w[O];O++);for(T<O&&(T=O),M=b=1;M<=15;M++)if(b<<=1,(b-=w[M])<0)return-1;if(0<b&&(0===e||1!==A))return-1;for(U[1]=0,M=1;M<15;M++)U[M+1]=U[M]+w[M];for(y=0;y<c;y++)0!==t[s+y]&&(d[U[t[s+y]]++]=y);if(0===e?(P=k=d,f=19):1===e?(P=o,G-=257,k=i,F-=257,f=256):(P=r,k=a,f=-1),M=O,v=l,D=y=L=0,_=-1,m=(N=1<<(R=T))-1,1===e&&852<N||2===e&&592<N)return 1;for(;;){for(I=M-D,d[y]<f?(E=0,S=d[y]):d[y]>f?(E=k[F+d[y]],S=P[G+d[y]]):(E=96,S=0),g=1<<M-D,O=p=1<<R;u[v+(L>>D)+(p-=g)]=I<<24|E<<16|S,0!==p;);for(g=1<<M-1;L&g;)g>>=1;if(0!==g?(L&=g-1,L+=g):L=0,y++,0==--w[M]){if(M===A)break;M=t[s+d[y]]}if(T<M&&(L&m)!==_){for(0===D&&(D=T),v+=O,b=1<<(R=M-D);R+D<A&&!((b-=w[R+D])<=0);)R++,b<<=1;if(N+=1<<R,1===e&&852<N||2===e&&592<N)return 1;u[_=L&m]=T<<24|R<<16|v-l}}return 0!==L&&(u[v+L]=M-D<<24|64<<16),h.bits=T,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 n=e("./zlib/inflate"),o=e("./utils/common"),i=e("./utils/strings"),r=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),u=e("./zlib/gzheader"),l=Object.prototype.toString;function d(e){if(!(this instanceof d))return new d(e);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;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 c,this.strm.avail_out=0;var s=n.inflateInit2(this.strm,t.windowBits);if(s!==r.Z_OK)throw new Error(a[s]);if(this.header=new u,n.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=i.string2buf(t.dictionary):"[object ArrayBuffer]"===l.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(s=n.inflateSetDictionary(this.strm,t.dictionary))!==r.Z_OK))throw new Error(a[s])}function h(e,t){var s=new d(t);if(s.push(e,!0),s.err)throw s.msg||a[s.err];return s.result}d.prototype.push=function(e,t){var s,a,c,u,d,h=this.strm,g=this.options.chunkSize,p=this.options.dictionary,_=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?r.Z_FINISH:r.Z_NO_FLUSH,"string"==typeof e?h.input=i.binstring2buf(e):"[object ArrayBuffer]"===l.call(e)?h.input=new Uint8Array(e):h.input=e,h.next_in=0,h.avail_in=h.input.length;do{if(0===h.avail_out&&(h.output=new o.Buf8(g),h.next_out=0,h.avail_out=g),(s=n.inflate(h,r.Z_NO_FLUSH))===r.Z_NEED_DICT&&p&&(s=n.inflateSetDictionary(this.strm,p)),s===r.Z_BUF_ERROR&&!0===_&&(s=r.Z_OK,_=!1),s!==r.Z_STREAM_END&&s!==r.Z_OK)return this.onEnd(s),!(this.ended=!0);h.next_out&&(0!==h.avail_out&&s!==r.Z_STREAM_END&&(0!==h.avail_in||a!==r.Z_FINISH&&a!==r.Z_SYNC_FLUSH)||("string"===this.options.to?(c=i.utf8border(h.output,h.next_out),u=h.next_out-c,d=i.buf2string(h.output,c),h.next_out=u,h.avail_out=g-u,u&&o.arraySet(h.output,h.output,c,u,0),this.onData(d)):this.onData(o.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(_=!0)}while((0<h.avail_in||0===h.avail_out)&&s!==r.Z_STREAM_END);return s===r.Z_STREAM_END&&(a=r.Z_FINISH),a===r.Z_FINISH?(s=n.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===r.Z_OK):a!==r.Z_SYNC_FLUSH||(this.onEnd(r.Z_OK),!(h.avail_out=0))},d.prototype.onData=function(e){this.chunks.push(e)},d.prototype.onEnd=function(e){e===r.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},s.Inflate=d,s.inflate=h,s.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},s.ungzip=h},{"./utils/common":1,"./utils/strings":2,"./zlib/constants":4,"./zlib/gzheader":6,"./zlib/inflate":8,"./zlib/messages":10,"./zlib/zstream":11}]},{},[])("/lib/inflate.js")),Ht.exports),Wt=new(function(){return _createClass(function _class6(){_classCallCheck(this,_class6),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=1e3,this._currentConnectState=Nt,this._beforeSendInterceptors=[]},[{key:"init",value:function init(){at.addTask({id:Dt,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){const t=We.get("instance"),{sdkAppId:s,testEnv:n,disableIndependentDomain:o,proxyServer:i}=t,r=Qe(s);let a="";return n?a=C.TEST[r].DEFAULT:Ee(i)?o?(a=C.PRODUCTION[r].DEFAULT,et=Xe.DEFAULT):a=C.PRODUCTION[r].INITIAL.replace("*",`${s}`):a=i,nt(a,{isBinary:e})}(this._isBinarySupported),Pe.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),Pe.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}},{key:"sendPacket",value:function sendPacket(e,t){var s;const{requestId:n,timeout:o=Tt,canResend:i=!0,shouldRejectOnError:r=!0}=t||{};if(Ee(e))return At.warn("sendPacket",`${Rt}.sendPacket: packet is empty `),null;this._executeBeforeSendInterceptors(e),this._currentConnectState===Pt&&this._handleConnectStateChange({state:Pt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:"send_fail"});const a=JSON.stringify(e);let c=null;if(n){const{resolve:t,reject:s,promise:u}=Me();c=u,this._pendingRequests.set(n,{resolve:t,reject:s,timestamp:Date.now(),uplinkData:a,timeout:o,canResend:i,requestHead:null==e?void 0:e.head,shouldRejectOnError:r})}const u=this._isBinarySupported?ct(a).buffer:a;return null===(s=this._socketAdapter)||void 0===s||s.send(u),c}},{key:"connect",value:function connect(){var e;this._socketAdapter=new ze(this._url),this._connectionEstablishedTime=0,this._addEventListeners(),this._connectionStartTime=Date.now();const t=null===(e=this._socketAdapter)||void 0===e?void 0:e.getId(),s=`${Rt}.connect isWorkerEnabled: ${ce} socketID:${t} url:${this._url}`;this._connectionId=t,this._ssoLog({method:"connect",message:s})}},{key:"disconnect",value:function disconnect(){var e,t;const s=null===(e=this._socketAdapter)||void 0===e?void 0:e.getId(),n=`${Rt}.disconnect socketID:${s}`;this._ssoLog({method:"disconnect",message:n}),this._removeEventListeners(),null===(t=this._socketAdapter)||void 0===t||t.disconnect()}},{key:"getSocketAdapter",value:function getSocketAdapter(){return this._socketAdapter}},{key:"dispose",value:function dispose(){console.log(`${Rt}.dispose`),at.removeTask(Dt),at.removeTask(bt),Pe.unSubscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),Pe.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=1e3,this._url=""}},{key:"registerBeforeSendInterceptor",value:function registerBeforeSendInterceptor(e,t){this._beforeSendInterceptors.push(e.bind(t))}},{key:"_executeBeforeSendInterceptors",value:function _executeBeforeSendInterceptors(e){for(const t of this._beforeSendInterceptors){const{servcmd:s=""}=null==e?void 0:e.head;t(s.includes(".")?s.split(".").pop():"")}}},{key:"_shouldSkipReconnect",value:function _shouldSkipReconnect(){const e="connecting"===this._currentConnectState&&this._isReconnecting;return!this._socketAdapter||e}},{key:"reconnect",value:function reconnect(){return pe(this,void 0,void 0,function*(){const e=`${Rt}.reconnect isReconnecting: ${this._isReconnecting} currentConnectState: ${this._currentConnectState}`;if(this._ssoLog({method:"reconnect",message:e}),!this._shouldSkipReconnect()){this._url=function ot(e){const t=We.get("instance"),{sdkAppId:s,testEnv:n,proxyServer:o}=t,i=Qe(s);if(n)return nt(C.TEST[i].DEFAULT,{isBinary:e});if(!Ee(o))return nt(o,{isBinary:e});const r=C.PRODUCTION[i],a=V&&r.ANYCAST,c=V,u=!!r.BACKUP_CN;return nt({[Xe.INITIAL]:()=>(et=Xe.DEFAULT,r.DEFAULT),[Xe.DEFAULT]:()=>(et=Xe.IPV6,r.IPV6),[Xe.IPV6]:()=>(et=Xe.BACKUP,r.BACKUP),[Xe.BACKUP]:()=>c?(et=Xe.BACKUP_WEB_ONLY,function(e){const t=Math.floor(10001*Math.random())+1e4;return e.replace("*",String(t))}(r.BACKUP_WEB_ONLY)):u?(et=Xe.BACKUP_CN,r.BACKUP_CN):a?(et=Xe.ANYCAST,r.ANYCAST):r.DEFAULT,[Xe.BACKUP_WEB_ONLY]:()=>u?(et=Xe.BACKUP_CN,r.BACKUP_CN):a?(et=Xe.ANYCAST,r.ANYCAST):r.DEFAULT,[Xe.BACKUP_CN]:()=>(et=a?Xe.ANYCAST:Xe.DEFAULT,r[et]),[Xe.ANYCAST]:()=>(et=Xe.DEFAULT,r.ANYCAST="",r.DEFAULT)}[et](),{isBinary:e})}(this._isBinarySupported);try{this._isReconnecting=!0,this.disconnect(),this.connect()}catch(e){this._isReconnecting=!1,this._handleConnectStateChange({state:Pt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:"reconnect_failed"}),At.warn(`${Rt}.reconnect failed: ${Ce(e)}`)}}})}},{key:"_addEventListeners",value:function _addEventListeners(){var e,t,s,n,o;null===(e=this._socketAdapter)||void 0===e||e.on("connect",this._onConnect,this),null===(t=this._socketAdapter)||void 0===t||t.on("message",this._onMessage,this),null===(s=this._socketAdapter)||void 0===s||s.on("close",this._onClose,this),null===(n=this._socketAdapter)||void 0===n||n.on("error",this._onError,this),null===(o=this._socketAdapter)||void 0===o||o.on("sendFail",this._onSendFail,this)}},{key:"_removeEventListeners",value:function _removeEventListeners(){var e,t,s,n,o;null===(e=this._socketAdapter)||void 0===e||e.off("connect",this._onConnect,this),null===(t=this._socketAdapter)||void 0===t||t.off("message",this._onMessage,this),null===(s=this._socketAdapter)||void 0===s||s.off("close",this._onClose,this),null===(n=this._socketAdapter)||void 0===n||n.off("error",this._onError,this),null===(o=this._socketAdapter)||void 0===o||o.off("sendFail",this._onSendFail,this)}},{key:"_onClose",value:function _onClose(e){const{socketId:t,event:s}=e||{},n=0!==this._connectionEstablishedTime?Date.now()-this._connectionEstablishedTime:0,o=`${Rt}.onClose closeSocketID: ${t} currentSocketID: ${this._connectionId} connectionDuration: ${n} code: ${null==s?void 0:s.code} reason: ${null==s?void 0:s.reason}`;this._ssoLog({method:"onClose",message:o}),t===this._connectionId&&this._handleConnectStateChange({state:Pt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:"socket_close"}),this._isReconnecting&&(this._isReconnecting=!1)}},{key:"_onError",value:function _onError(e){const{socketId:t,error:s}=e||{},n=`${Rt}.onError sourceSocketID: ${t} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: ${JSON.stringify(s)}`;this._ssoLog({method:"onError",message:n}),t===this._connectionId&&this._handleConnectStateChange({state:Pt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:"socket_error"}),this._isReconnecting&&(this._isReconnecting=!1)}},{key:"_onSendFail",value:function _onSendFail(e){const{socketId:t,error:s}=e||{},n=`${Rt}.onSendFail sendFailSocketId: ${t} currentSocketID: ${this._connectionId} isReconnecting: ${this._isReconnecting} error: ${Ce(s)}`;this._ssoLog({method:"onSendFail",message:n}),this._isReconnecting&&(this._isReconnecting=!1)}},{key:"_onMessage",value:function _onMessage(e){let t,s;this._updateHeartbeatTime();try{t=this._isBinarySupported?this._isCompressedData(e.data)?(e=>{const t=new Uint8Array(e).slice(4);let s;try{s=Kt.inflate(t,{to:"string"})}catch(e){console.error("inflate error",e)}return s})(e.data):function(e){const t=new Uint8Array(e);let s="",n=0;const{length:o}=t;for(;n<o;){let e=t[n],i=0,r=0;if(e<=127?(i=0,r=255&e):e<=223?(i=1,r=31&e):e<=239?(i=2,r=15&e):e<=244&&(i=3,r=7&e),o-n-i>0)for(let s=0;s<i;s+=1)e=t[n+s+1],r=r<<6|63&e;else r=65533,i=o-n;s+=String.fromCodePoint(r),n+=i+1}return s}(e.data):e.data,s=JSON.parse(t)}catch(t){const s=`event.data: ${Ce(e.data)} error: ${Ce(t)}`;return void this._ssoLog({method:"jsonParseError",message:s})}if(!s||!s.head)return;const{seq:n,servcmd:o}=s.head,i=`${n}${o}`;this._pendingRequests.has(i)?this._handleRequestResponse(s):this._handlePushMessage(s)}},{key:"_handleRequestResponse",value:function _handleRequestResponse(e){var t,s;const{seq:n,servcmd:o}=e.head,{int32_error_code:i,str_error_message:r}=(null==e?void 0:e.body)||{},a=(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.ErrorCode)||i,c=(null===(s=null==e?void 0:e.body)||void 0===s?void 0:s.ErrorInfo)||r,u=`${n}${o}`,{resolve:l,reject:d,timestamp:h,headSeq:g,requestHead:p,shouldRejectOnError:_=!0}=this._pendingRequests.get(u);if(this._pendingRequests.delete(u),a&&0!==a&&_)return Pe.emitInnerEvent("error",{errorCode:a,errorInfo:c,requestHead:p}),void d({errorCode:a,errorInfo:c});l(e.body)}},{key:"_handlePushMessage",value:function _handlePushMessage(e){const{servcmd:t}=e.head,{NeedAck:s,SessionData:n}=e.body;1===s&&this._sendAck(n),Pe.emitInnerEvent(t,e)}},{key:"_checkPendingRequestsAndResend",value:function _checkPendingRequestsAndResend(){var e;At.debug("_checkPendingRequestsAndResend",` reConnectFlag:${this._isReconnecting} promiseMap.size:${this._pendingRequests.size}`),null===(e=this._pendingRequests)||void 0===e||e.forEach((e,t)=>{var s;const{uplinkData:n,canResend:o,resolve:i,reject:r,timeout:a}=e;if(o){this._pendingRequests.set(t,{resolve:i,reject:r,timestamp:Date.now(),uplinkData:n,timeout:a,canResend:o});const e=this._isBinarySupported?ct(n).buffer:n;null===(s=this._socketAdapter)||void 0===s||s.send(e)}else this._pendingRequests.delete(t)})}},{key:"_onConnect",value:function _onConnect(e){const{socketId:t,event:s={}}=e||{};this._connectionId=t,this._connectionEstablishedTime=Date.now();const n=Date.now()-this._connectionStartTime,o=`${Rt}.onConnect cost:${n} ms. socketID:${t} res:${JSON.stringify(s)}`;if(this._ssoLog({method:"onConnect",message:o}),this._checkPendingRequestsAndResend(),this._sendHeartbeatIfReady(),this._isReconnecting){const e=`${Rt}.reconnect success`;this._ssoLog({method:"reconnectSuccess",message:e}),Pe.emitInnerEvent(St.RECONNECTED),this._isReconnecting=!1}this._resetReconnectDelay(),this._handleConnectStateChange({state:Nt,shouldEmitEvent:!0,shouldAttemptReconnect:!1})}},{key:"_sendAck",value:function _sendAck(e){const t=dt({servcmd:"openim.ws_msg_push_ack",data:{SessionData:e}});this.sendPacket(t)}},{key:"_executeScheduledTaskIfReady",value:function _executeScheduledTaskIfReady(){return pe(this,void 0,void 0,function*(){this._clearTimeoutRequest(),this._sendHeartbeatIfReady()})}},{key:"_canSendHeartbeat",value:function _canSendHeartbeat(){var e;return(null===(e=this._socketAdapter)||void 0===e?void 0:e.isConnected())&&Date.now()>=this._nextHeartbeatAt&&!this._isHeartbeatInProgress}},{key:"_sendHeartbeat",value:function _sendHeartbeat(){return pe(this,void 0,void 0,function*(){var e;const t=dt({servcmd:"heartbeat.alive",data:{}});try{const e=`${t.head.seq}${t.head.servcmd}`;yield this.sendPacket(t,{requestId:e,timeout:3e3})}catch(t){const s=null===(e=We.get("netWorkMonitor"))||void 0===e?void 0:e.isNetworkOnline,n=`${Rt}.sendHeartbeat failed. isNetWorkOnline:${s} error: ${Ce(t)}`;this._ssoLog({method:"sendHeartbeatError",message:n}),this._handleConnectStateChange({state:Pt,shouldEmitEvent:!0,shouldAttemptReconnect:!0})}})}},{key:"_sendHeartbeatIfReady",value:function _sendHeartbeatIfReady(){return pe(this,void 0,void 0,function*(){this._canSendHeartbeat()&&(this._isHeartbeatInProgress=!0,yield this._sendHeartbeat(),this._isHeartbeatInProgress=!1)})}},{key:"_updateHeartbeatTime",value:function _updateHeartbeatTime(){this._nextHeartbeatAt=G?Date.now()+5e3:Date.now()+1e4}},{key:"_handleNetworkStatusChange",value:function _handleNetworkStatusChange(e){const t=`${Rt}.networkStatusChange ${JSON.stringify(e)}`;this._ssoLog({method:"networkStatusChange",message:t});const{isNetworkOnline:s,networkType:n}=e;s&&"none"!==n?this._handleConnectStateChange({state:Nt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:wt}):this._handleConnectStateChange({state:Pt,shouldEmitEvent:!1,shouldAttemptReconnect:!0,reason:wt})}},{key:"isPrivateNetWork",value:function isPrivateNetWork(){const e=We.get("instance")||{};return e.proxyServer&&!e.fileDownloadProxy}},{key:"_handleConnectStateChange",value:function _handleConnectStateChange(e){const{state:t,shouldAttemptReconnect:s,shouldEmitEvent:n,reason:o}=e,i=`${Rt}._handleConnectStateChange currentConnectState: ${this._currentConnectState} shouldAttemptReconnect: ${s} shouldEmitEvent: ${n} reason: ${o}`;this._currentConnectState!==t&&(this._ssoLog({method:"handleConnectStateChange",message:i}),n&&(At.info("_handleConnectStateChange",` from ${this._currentConnectState} to ${t}`),Pe.emitOuterEvent("netStateChange",{name:"netStateChange",data:{state:t}}),this._currentConnectState=t,t===Pt&&Pe.emitInnerEvent(St.SOCKET_DISCONNECTED)),s&&(this._resetReconnectDelay(),at.addTask({id:bt,intervalMs:this._intendedDelay,callback:this._scheduleReconnectWithBackoff,context:this})))}},{key:"_handleActivityStatusChange",value:function _handleActivityStatusChange(e){var t,s;const n=null===(s=null===(t=this._socketAdapter)||void 0===t?void 0:t._ws)||void 0===s?void 0:s.readyState,o=`${Rt}.activityStatusChange ${JSON.stringify(e)} readyState: ${n}`;At.debug("activityStatusChange",o),3===n&&this._handleConnectStateChange({state:Pt,shouldEmitEvent:!0,shouldAttemptReconnect:!0,reason:"activity_status_change"})}},{key:"_resetReconnectDelay",value:function _resetReconnectDelay(){var e;At.debug(`${Rt}._resetReconnectDelay`),at.removeTask(bt);null===(e=We.get("activityMonitor"))||void 0===e||e.isActive;this._intendedDelay=1e3}},{key:"_scheduleReconnectWithBackoff",value:function _scheduleReconnectWithBackoff(){var e;const t=null===(e=We.get("activityMonitor"))||void 0===e?void 0:e.isActive;this._intendedDelay=t?Math.min(5e3,Math.max(1e3,1.5*this._intendedDelay)):Math.min(3e5,Math.max(1e3,1.5*this._intendedDelay));const s=(new Date).toTimeString().slice(0,8),n=`${Rt}.scheduleReconnectWithBackoff timeStr: ${s} intendedDelay: ${this._intendedDelay}`;At.debug(n),this.reconnect(),at.updateTaskInterval(bt,this._intendedDelay)}},{key:"_ssoLog",value:function _ssoLog(e){const{method:t,message:s}=e;At.info(t,s)}},{key:"_diagnose",value:function _diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseAt=Date.now(),function(e){pe(this,void 0,void 0,function*(){const t=e.split("/")[2];if(!t.startsWith("ws"))return;const s=`https://${t}/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=${Date.now()}`;try{yield Ie({method:"GET",url:s,data:{}})}catch(e){At.warn("diagnoseBySSO",`diagnoseBySSO failed. error:${e.message}`)}})}(this._url),function(e){pe(this,void 0,void 0,function*(){const t=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=${Date.now()}`;try{yield Ie({method:"GET",url:t,data:{}})}catch(e){At.warn(`diagnoseByCDN', 'diagnoseByCDN failed. error:${e.message}`)}})}(this._url),this._beforeSendInterceptors=[])}},{key:"_clearTimeoutRequest",value:function _clearTimeoutRequest(){for(const[e,t]of this._pendingRequests.entries()){const{reject:s,timestamp:n,timeout:o}=t;Date.now()-n>=o&&(this._pendingRequests.delete(e),Date.now()-this._lastDiagnoseAt>=3e4&&this._diagnose(),s({errorCode:2801,errorInfo:"NETWORK_TIMEOUT",data:{requestId:e}}))}}},{key:"_updateIsBinarySupported",value:function _updateIsBinarySupported(){var e;if(null===(e=We.get("instance"))||void 0===e?void 0:e.devMode)return void(this._isBinarySupported=!1);const t=de();if((L||A&&"windows"===t||k)&&(this._isBinarySupported=!1),G){const{uniRuntimeVersion:e=""}=B.getSystemInfoSync();(function(e){const t=e.split(".").map(Number),[s=0,n=0,o=0]=t;return s>2||!(s<2)&&(n>2||!(n<2)&&o>=6)})(e)||(this._isBinarySupported=!1)}}},{key:"_isCompressedData",value:function _isCompressedData(e){const t=new Uint8Array(e);return 67===t[0]&&79===t[1]&&77===t[2]&&80===t[3]}}])}());const Yt={init:function(e){We.set("instance",e),Wt.init()},destroy:function(){Wt.dispose(),We.clear(),at.dispose()},notificationCenter:Pe,channel:Wt,store:We,ssoLog:At,utils:Oe,common:vt,constants:y},zt=e=>"function"==typeof e;function Jt(e,t,s){const n=s||[];if(!e||!t)return!1;const o=Object.keys(e).filter(e=>!n.includes(e)),i=Object.keys(t).filter(e=>!n.includes(e));return o.length===i.length&&o.every(n=>!!t.hasOwnProperty(n)&&("object"==typeof e[n]&&null!==e[n]?Jt(e[n],t[n],s):e[n]===t[n]))}var Qt;!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",e.WEB_PUSH_MESSAGE_RECEIVED="onWebPushMessageReceived",e.GROUP_ONLINE_MEMBER_COUNT_CHANGED="onGroupOnlineMemberCountChanged",e.RICH_STATUS_CHANGED="onRichStatusChanged"}(Qt||(Qt={}));var Xt,Zt=Qt;!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",e.HISTORY_MESSAGE_FETCHED="history_message_fetched"}(Xt||(Xt={}));var es,ts=Xt;!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"}(es||(es={}));var ss=es;const ns=Object.assign({},{KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick"}),os={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",MSG_STREAM:"TIMStreamElem"};var is;!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(is||(is={}));const rs={modify:ts.MESSAGE_MODIFIED,delete:ts.MESSAGE_DELETED,revoke:ts.MESSAGE_REVOKED};var as;!function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(as||(as={}));const cs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},os),{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:is,Direction:as}),us={[rs.modify]:ts.TOPIC_MESSAGE_MODIFIED,[rs.delete]:ts.TOPIC_MESSAGE_DELETED,[rs.revoke]:ts.TOPIC_MESSAGE_REVOKED},ls={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"},ds=Object.assign({},ls),hs={CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM"},gs=Object.assign(Object.assign(Object.assign(Object.assign({},hs),{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"}),ps=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"}),_s={GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live"},ms={COMMUNITY:"@TGS#_",TOPIC:"@TOPIC#_"},vs={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},fs=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},_s),{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:ms,GROUP_TIPS_OPERATION_TYPE:vs}),Is={IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"},Es=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ns),cs),ds),gs),ps),fs),Is),{NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",NET_STATE_CONNECTED:"connected"}),Ss={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},Cs={BASIC:"1",STANDARD:"2",PROFESSIONAL:"3",NODE:"4"},Ms={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"},ys={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",C2C_HISTORY_MESSAGE_RECOVER:"c2c-history-message-recover",FRIEND_APPLICATION_LIST_RECOVER:"friend-application-list-recover",EMIT_GROUP_TIPS_EVENT:"emit-group-tips-event",STREAM_MESSAGE_RECOVER:"stream-message-recover"},Os={[Ms.SYNC_SERVER_INFO_AFTER_RE_ONLINE]:[{stepId:ys.USER_STATUS_UPDATE},{stepId:ys.GROUP_ATTRIBUTE_CACHE_CLEAR},{stepId:ys.UNREAD_MESSAGE_SYNC,dependency:ys.C2C_HISTORY_MESSAGE_RECOVER},{stepId:ys.CONVERSATION_RECOVER},{stepId:ys.HISTORY_MESSAGE_RECOVER,dependency:ys.CONVERSATION_RECOVER},{stepId:ys.BLACKLIST_RECOVER},{stepId:ys.FRIEND_RECOVER},{stepId:ys.FRIEND_APPLICATION_LIST_RECOVER},{stepId:ys.GROUP_REVOKED_NOTICE_RECOVER,dependency:ys.HISTORY_MESSAGE_RECOVER},{stepId:ys.GROUP_TIPS_RECOVER,dependency:ys.HISTORY_MESSAGE_RECOVER},{stepId:ys.TOPIC_REQUEST_INFO_RESET},{stepId:ys.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,dependency:ys.UNREAD_MESSAGE_SYNC},{stepId:ys.HANDLE_GROUP_TIPS_FROM_SYNC_UNREAD,dependency:ys.UNREAD_MESSAGE_SYNC},{stepId:ys.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ys.UNREAD_MESSAGE_SYNC,ys.CONVERSATION_RECOVER]},{stepId:ys.EMIT_C2C_MESSAGE_EVENT,dependency:[ys.UNREAD_MESSAGE_SYNC,ys.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED],skipIfDependencyMissing:!1},{stepId:ys.C2C_HISTORY_MESSAGE_RECOVER,dependency:ys.CONVERSATION_RECOVER},{stepId:ys.STREAM_MESSAGE_RECOVER}],[Ms.SYNC_SERVER_INFO_AFTER_LOGIN]:[{stepId:ys.COMMERCIAL_CONFIG_UPDATE},{stepId:ys.CLOUD_CONFIG_SYNC},{stepId:ys.USER_PROFILE_SYNC},{stepId:ys.UNREAD_MESSAGE_SYNC},{stepId:ys.FRIEND_AND_BLACKLIST_SYNC},{stepId:ys.GROUP_LIST_SYNC},{stepId:ys.CONVERSATION_LIST_SYNC},{stepId:ys.SIGNALING_MESSAGE_RECOVER,dependency:ys.UNREAD_MESSAGE_SYNC},{stepId:ys.UPDATE_TOPIC_AFTER_UNREAD_SYNC_FINISHED,dependency:[ys.UNREAD_MESSAGE_SYNC]},{stepId:ys.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ys.UNREAD_MESSAGE_SYNC,ys.CONVERSATION_LIST_SYNC]},{stepId:ys.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,dependency:[ys.GROUP_LIST_SYNC,ys.CONVERSATION_LIST_SYNC]},{stepId:ys.CONVERSATION_GROUP_LIST_SYNC},{stepId:ys.CONVERSATION_GROUP_UPDATE,dependency:[ys.CONVERSATION_LIST_SYNC,ys.CONVERSATION_GROUP_LIST_SYNC]},{stepId:ys.QUALITY_REPORT}],[Ms.RECEIVE_C2C_NEW_MESSAGE]:[{stepId:ys.HANDLE_C2C_NEW_MESSAGE},{stepId:ys.UNREAD_MESSAGE_SYNC},{stepId:ys.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ys.HANDLE_C2C_NEW_MESSAGE},{stepId:ys.EMIT_C2C_MESSAGE_EVENT,dependency:[ys.HANDLE_C2C_NEW_MESSAGE,ys.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1},{stepId:ys.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,dependency:[ys.UNREAD_MESSAGE_SYNC]}],[Ms.RECEIVE_GROUP_NEW_MESSAGE]:[{stepId:ys.HANDLE_GROUP_NEW_MESSAGE},{stepId:ys.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ys.HANDLE_GROUP_NEW_MESSAGE},{stepId:ys.UPDATE_GROUP_NEXT_SEQUENCE,dependency:ys.HANDLE_GROUP_NEW_MESSAGE},{stepId:ys.UPDATE_TOPIC_BY_RECEIVE_NEW_MESSAGE,dependency:ys.HANDLE_GROUP_NEW_MESSAGE},{stepId:ys.EMIT_GROUP_MESSAGE_EVENT,dependency:[ys.HANDLE_GROUP_NEW_MESSAGE,ys.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE],skipIfDependencyMissing:!1}],[Ms.RECEIVE_GROUP_TIPS_NOTIFICATION]:[{stepId:ys.HANDLE_GROUP_TIPS_NOTIFICATION},{stepId:ys.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,dependency:ys.HANDLE_GROUP_TIPS_NOTIFICATION},{stepId:ys.EMIT_GROUP_TIPS_EVENT,dependency:[ys.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,ys.HANDLE_GROUP_TIPS_NOTIFICATION],skipIfDependencyMissing:!1}]},As={MESSAGE_SEND_SUCCESS_RATE:"messageSendSuccessRate"},Ts={TOTAL_COUNT:"sendMessageTotalCount",SUCCESS_COUNT:"sendMessageSuccessCount",FAILED_COUNT:"sendMessageFailedCount",SEND_COST:"sendMessageCost"},Rs=["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","sendMessageReadReceipt","getMessageReadReceiptList","getGroupMessageReadMemberList","createMergerMessage","invite","accept","cancel","reject","modifyInvitation","deleteConversation","pinConversation","setMessageRead","setAllMessageRead","getConversationList","getTotalUnreadMessageCount","renameConversationGroup","deleteConversationGroup","markConversation","setConversationCustomData","deleteConversationsFromGroup","addConversationsToGroup","createConversationGroup"];var bs,Ns,Ls,Ds=Object.freeze({__proto__:null,ERROR_CODE:Ss,InnerEvent:ts,NEED_LOG_API:Rs,OuterConstant:Es,OuterEvent:Zt,PUSH:Is,QUALITY_METRICS:As,SDK_EDITION:Cs,SDK_INFO:{VERSION:"1.7.3",APPID:537048168},SEND_MESSAGE_STAT:Ts,SignalingEvent:ss,WEB_PUSH_ACCOUNT_TYPE:1,WORKFLOW_DEFINITIONS:Os,WORKFLOW_NAME:Ms,WORKFLOW_STEP:ys});!function(e){e[e.USER_INITIATED=0]="USER_INITIATED",e[e.KICKED_OUT=1]="KICKED_OUT"}(bs||(bs={})),function(e){e[e.multipleAccount=1]="multipleAccount",e[e.multipleDevice=2]="multipleDevice",e[e.restApi=3]="restApi"}(Ns||(Ns={})),function(e){e[e.multipleDevice=3002]="multipleDevice",e[e.multipleAccount=3003]="multipleAccount",e[e.usersigExpired=70001]="usersigExpired",e[e.restApi=20002]="restApi"}(Ls||(Ls={}));const Ps={[Ns.multipleAccount]:"multipleAccount",[Ns.multipleDevice]:"multipleDevice",[Ns.restApi]:"REST_API_Kick",[Ls.multipleAccount]:"multipleAccount",[Ls.multipleDevice]:"multipleDevice",[Ls.restApi]:"REST_API_Kick",[Ls.usersigExpired]:"userSigExpired"},Gs="login_online_presence_task",{ERROR:ws,DESTROY:Us,FORCE_OFFLINE:ks}=ts,{KICKED_OUT_MULT_ACCOUNT:Fs,KICKED_OUT_MULT_DEVICE:$s,KICKED_OUT_REST_API:xs,ACCOUNT_A2KEY_EXPIRED:qs,MSG_A2KEY_EXPIRED:Vs}=Ss;let Bs=function(){return _createClass(function Bs(){_classCallCheck(this,Bs)},[{key:"init",value:function init(){const{notificationCenter:e}=Yt;e.subscribeInnerEvent(ks,this._handleForceOfflineFromServerPush,this),e.subscribeInnerEvent(ws,Vs,this._handleForceOfflineFromResponse,this,this._isChatLoginEvent),e.subscribeInnerEvent(ws,qs,this._handleForceOfflineFromResponse,this,this._isChatLoginEvent),e.subscribeInnerEvent(ws,Fs,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(ws,$s,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(ws,xs,this._handleForceOfflineFromResponse,this),e.subscribeInnerEvent(Us,this._dispose,this)}},{key:"_handleForceOfflineFromServerPush",value:function _handleForceOfflineFromServerPush(e){var t;if(!0===(null===(t=Yt.store.get("login"))||void 0===t?void 0:t.isLoggedIn)){const{EventArray:t=[]}=(null==e?void 0:e.body)||{};this._extractKickedOutMessages(t).forEach(e=>{const{KickoutMsgNotify:{KickType:t,NewInstInfo:s,Instid:n}}=e;this._isCurrentInstanceKickedOut(n)&&this._processKickedOutReasonInfo({kickedOutReasonCode:t,newInstanceInfo:s})})}}},{key:"_extractKickedOutMessages",value:function _extractKickedOutMessages(e){return e.reduce((e,t)=>[...e,...t.C2cNotifyMsgArray||[]],[]).filter(e=>{var t;return this._isKickedOut(null===(t=null==e?void 0:e.KickoutMsgNotify)||void 0===t?void 0:t.KickType)})}},{key:"_handleForceOfflineFromResponse",value:function _handleForceOfflineFromResponse(e){const{errorCode:t}=e;this._processKickedOutReasonInfo({kickedOutReasonCode:t})}},{key:"_processKickedOutReasonInfo",value:function _processKickedOutReasonInfo(e){return pe(this,void 0,void 0,function*(){const{kickedOutReasonCode:t}=e,{ssoLog:s,utils:{safeStringify:n}}=Yt;try{this._logKickedOutEvent(e),this._shouldLogoutAfterKickedOut(t)?yield Yt.login.loginAction.logout(bs.KICKED_OUT):Yt.login.loginAction.handleLogoutCompleted()}catch(e){s.debug("_processKickedOutReasonInfo",` fail ${n(e)}`)}finally{Yt.notificationCenter.emitOuterEvent(Zt.KICKED_OUT,{data:{type:Ps[t]},name:Zt.KICKED_OUT})}})}},{key:"_logKickedOutEvent",value:function _logKickedOutEvent(e){const{kickedOutReasonCode:t,newInstanceInfo:s={}}=e,n=`type:${Ps[t]} newInstanceInfo: ${JSON.stringify(s)}`;Yt.ssoLog.warn("kickedOut",n)}},{key:"_isKickedOut",value:function _isKickedOut(e){return[Ns.multipleAccount,Ns.multipleDevice,Ns.restApi].includes(e)}},{key:"_isChatLoginEvent",value:function _isChatLoginEvent(e){const{requestHead:t}=e||{};return 1!==(null==t?void 0:t.idtype)}},{key:"_shouldLogoutAfterKickedOut",value:function _shouldLogoutAfterKickedOut(e){return![Ls.usersigExpired,Ns.restApi].includes(e)}},{key:"_isCurrentInstanceKickedOut",value:function _isCurrentInstanceKickedOut(e){const{isLoggedIn:t,statusInstanceId:s}=Yt.store.get("login")||{};return!0===t&&e===s}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e}=Yt;e.unSubscribeInnerEvent(ks,this._handleForceOfflineFromServerPush,this),e.unSubscribeInnerEvent(ws,qs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(ws,Vs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(ws,Fs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(ws,$s,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(ws,xs,this._handleForceOfflineFromResponse,this),e.unSubscribeInnerEvent(Us,this._dispose,this)}}])}();function js(e){return pe(this,void 0,void 0,function*(){const t="im_open_status.wslogin",s=Yt.common.generateProtocolData({servcmd:t,data:{State:"Online",is_web_uniapp:0,InstType:0,CustomInfo:e}}),n=`${s.head.seq}${t}`,o=yield Yt.channel.sendPacket(s,{timeout:9e4,requestId:n});if(o){const{HelloInterval:e,InstId:t,TinyId:s,TimeStamp:n,CustomStatus:i,PurchaseBits:r,A2Key:a,RichMsgAuthKey:c,ErrorCode:u,ErrorInfo:l,ActionStatus:d}=o;return{helloInterval:e,instanceID:t,tinyID:s,timeStamp:n,customStatus:i,purchaseBits:r,a2Key:a,authKey:c,errorCode:u,errorInfo:l,actionStatus:d}}})}function Hs(){const{store:e}=Yt;return Qe(e.get("instance").sdkAppId)!==S.CHINA}function Ks(e){var t;try{const s=We.getStorage("errorMessage");if(!e||!s)return"";const n=(null===(t=JSON.parse(s))||void 0===t?void 0:t.errorMessage)||{},{code:o,replacement1:i="",replacement2:r=""}=e;if(!o)return"";const a=Hs()?`${o}_en`:`${o}_cn`;let c=n[n[a]?a:o]||"";return c&&(i&&(c=c.replace("$replacement1",i)),r&&(c=c.replace("$replacement2",r))),c}catch(e){return console.warn("Error parsing stored error messages:",e),""}}let Ws=function(){function Ws(e={}){var _this;_classCallCheck(this,Ws),e.code=e.code||e.errorCode;let{functionName:t="Unknown",code:s,message:n="",data:o="",moreMessage:i="",errorMessage:r=""}=e;r=(s?Ks(e):"")||r||n;let a=s?`${t} failed. error: {"message": ${r}, "code": ${s}}`:`${t} failed. error: {"message": ${r}}`;return a=`${a} ${i}`,(_this=_callSuper(this,Ws)).code=s,_this.errorCode=s,_this.errorMessage=r,_this.message=a,_this.data=o,_this}return _inherits(Ws,_wrapNativeSuper(Error)),_createClass(Ws)}();function Ys(e,t){var s;if(e&&!0!==(null===(s=Yt.store.get("login"))||void 0===s?void 0:s.isLoggedIn))throw new Ws({code:Ss.USER_NOT_LOGGED_IN,functionName:t})}function zs(e,t,s){if(Array.isArray(e))for(let n=0;n<e.length;n++)Js.call(this,Object.assign(Object.assign({},e[n]),{value:t[n],name:s}));else for(const n in e)Js.call(this,Object.assign(Object.assign({},e[n]),{value:t[0][n],name:s,key:n}))}function Js({required:e,rules:t,range:s,value:n,allowEmpty:o,name:i,key:r,customValidator:a}){if(void 0===n){if(e)throw new Ws({functionName:i,message:`[${i}] Missing required params: "${r}"`});return}let c="";if(!t.some(e=>{return e===(t=n,Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase());var t})){for(let e=0;e<t.length;e++){let s=t[e];s=s.replace(s[0],s[0].toUpperCase()),c+=`${s}/`}c=c.substring(0,c.length-1);const e=`[${r}] must be type of ${c}, received type: ${function(e){return Reflect.apply(Object.prototype.toString,e,[]).replace(/^\[object\s(\w+)\]$/,"$1").toLowerCase()}(n)}.`;throw new Ws({functionName:i,message:e})}if(!1===o){if(Array.isArray(n)&&(0===n.length||"string"==typeof n[0]&&""===n[0].trim()))throw new Ws({functionName:i,message:`${r} can not be empty.`});if("string"==typeof n&&""===n.trim())throw new Ws({functionName:i,message:`${r} can not be empty.`})}if(a&&"function"==typeof a){const e=a(n);if(!0!==e)throw new Ws({functionName:i,message:`[${r}] custom validation failed: ${e||"Invalid value"}`})}}const Qs=[],Xs={},Zs={};function en(e,t){Ys(Xs[e],e),zs(Zs[e],t,e),function(e){Qs.forEach(t=>{const{interceptor:s,context:n}=t;s.apply(n,[e])})}(e)}function tn(e,t){Qs.push({interceptor:e,context:t})}function sn(e){const{params:t,auth:s}=e;t&&"object"==typeof t&&Object.assign(Zs,t),s&&"object"==typeof s&&Object.assign(Xs,s)}function nn(e){return Yt.store.get("commercialConfig").get(e)}let on=function(){function on(){_classCallCheck(this,on),this._handlers=new Map,this._activeWorkflows=new Map,this._stepStartTimes=new Map,this._logHandlers={start:(e,t)=>{const s=Date.now();t?(this._stepStartTimes.set(`${e}-${t}`,s),Yt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] Step ${t} started at ${new Date(s).toISOString()}`)):(this._workflowStartTimes.set(e,s),Yt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] started at ${new Date(s).toISOString()}`))},success:(e,t)=>{const s=Date.now();if(t){const n=this._stepStartTimes.get(`${e}-${t}`),o=n?s-n:0;this._stepStartTimes.delete(`${e}-${t}`),Yt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] Step ${t} completed successfully at ${new Date(s).toISOString()} (${o}ms)`)}else{const t=this._workflowStartTimes.get(e),n=t?s-t:0;this._workflowStartTimes.delete(e),Yt.ssoLog.debug("_executeWorkflowStep",`[Workflow ${e}] completed successfully at ${new Date(s).toISOString()} (${n}ms)`)}},error:(e,t,s)=>{const{ssoLog:n,utils:{safeStringify:o}}=Yt,i=Date.now();if(t){const r=this._stepStartTimes.get(`${e}-${t}`),a=r?i-r:0;this._stepStartTimes.delete(`${e}-${t}`),n.error("_executeWorkflowStep",`[Workflow ${e}] Step ${t} failed at ${new Date(i).toISOString()} (${a}ms) ${o(s)}`,{error:s})}else{const t=this._workflowStartTimes.get(e),r=t?i-t:0;this._workflowStartTimes.delete(e),n.error("_executeWorkflowStep",`[Workflow ${e}] failed at ${new Date(i).toISOString()} (${r}ms) ${o(s)}`,{error:s})}}}}return _createClass(on,[{key:"init",value:function init(){this._initializeWorkflows()}},{key:"registerWorkflowStep",value:function registerWorkflowStep(e,t,s,n){if(!this._handlers.has(e))return void Yt.ssoLog.debug("registerWorkflowStep",`Workflow '${e}' not defined in core`);if(!Os[e].find(e=>e.stepId===t))return void Yt.ssoLog.debug("registerWorkflowStep",`Step '${t}' not defined in workflow '${e}'`);const o=this._handlers.get(e);o.has(t)||o.set(t,n?s.bind(n):s)}},{key:"executeWorkflow",value:function executeWorkflow(e,t){return pe(this,void 0,void 0,function*(){if(!this._validateWorkflow(e))return;Yt.ssoLog.debug("executeWorkflow",`[Workflow ${e}] Started execution at ${(new Date).toISOString()}`);const s=Os[e],n={},o={cancelled:!1};this._activeWorkflows.set(e,{cancelToken:o});try{const i=new Map;s.forEach(e=>{i.set(e.stepId,e)});const r={workflowName:e,pendingSteps:new Set(s.map(e=>e.stepId)),completedSteps:new Set,runningSteps:new Set,stepMap:i,stepResults:n,data:t,cancelToken:o};yield new Promise((t,s)=>{const n=()=>{o.cancelled?t():this._getExecutableSteps({pendingSteps:r.pendingSteps,completedSteps:r.completedSteps,stepMap:r.stepMap,workflowName:e}).filter(e=>!r.runningSteps.has(e)).forEach(o=>{r.completedSteps.has(o)||r.runningSteps.has(o)||this._executeWorkflowStep(o,r,{onComplete:()=>{0!==r.pendingSteps.size?0===this._getExecutableSteps({pendingSteps:r.pendingSteps,completedSteps:r.completedSteps,stepMap:r.stepMap,workflowName:e}).filter(e=>!r.runningSteps.has(e)).length&&0===r.runningSteps.size&&(Yt.ssoLog.debug("executeWorkflow",`Workflow ${e} completed with some steps skipped due to dependency failures`),t()):t()},onError:s,onStepComplete:n})})};n()}),Yt.ssoLog.debug("executeWorkflow",`[Workflow ${e}] Completed execution at ${(new Date).toISOString()}`)}catch(t){Yt.ssoLog.error("executeWorkflow",`[Workflow ${e}] Failed execution at ${(new Date).toISOString()}`,{error:t})}finally{this._activeWorkflows.delete(e)}})}},{key:"_executeWorkflowStep",value:function _executeWorkflowStep(e,s,n){return pe(this,void 0,void 0,function*(){const{workflowName:o,runningSteps:i,stepMap:r,stepResults:a,data:c}=s;i.add(e),this._logWorkflowExecution(o,e,"start");try{const n=r.get(e);let i=null;(null==n?void 0:n.dependency)&&(t(n.dependency)?i=a[n.dependency]:Array.isArray(n.dependency)&&(i={},n.dependency.forEach(e=>{i[e]=a[e]})));const u=this._handlers.get(o).get(e);if(u){const t=yield Promise.resolve(u({data:c,result:i}));a[e]=t,this._logWorkflowExecution(o,e,"success")}s.completedSteps.add(e)}catch(t){const s=`[Workflow].${o}.${e}`,{errorCode:i,errorInfo:r=`${s} failed`}=t||{},a=new Ws({functionName:s,code:i,message:r});Yt.ssoLog.error(s,r,{error:a}),this._logWorkflowExecution(o,e,"error",t),n.onError(t)}finally{i.delete(e),s.pendingSteps.delete(e),n.onStepComplete(),n.onComplete()}})}},{key:"reset",value:function reset(){this._cancelAllWorkflows()}},{key:"destroy",value:function destroy(){this.reset(),this._handlers.clear()}},{key:"_initializeWorkflows",value:function _initializeWorkflows(){Object.keys(Os).forEach(e=>{this._handlers.has(e)||this._handlers.set(e,new Map)})}},{key:"_cancelWorkFlow",value:function _cancelWorkFlow(e){const t=this._activeWorkflows.get(e);if(!t)return;const{cancelToken:s}=t;s.cancelled=!0,this._activeWorkflows.delete(e)}},{key:"_cancelAllWorkflows",value:function _cancelAllWorkflows(){Object.keys(Os).forEach(e=>{this._cancelWorkFlow(e)})}},{key:"_validateWorkflow",value:function _validateWorkflow(e){return!!Os[e]&&!!this._handlers.get(e)}},{key:"_getExecutableSteps",value:function _getExecutableSteps(e){const{pendingSteps:s,completedSteps:o,stepMap:i,workflowName:r}=e;return Array.from(s).filter(e=>{const s=i.get(e)||{},{dependency:a,skipIfDependencyMissing:c=!0}=s;if(!a)return!0;if(t(a))return this._isStepRegistered({workflowName:r,stepId:a})?o.has(a):!c;if(n(a)){if(a.filter(e=>!this._isStepRegistered({workflowName:r,stepId:e})).length>0&&c)return!1;for(const e of a)if(!o.has(e))return!1;return!0}return!1})}},{key:"_isStepRegistered",value:function _isStepRegistered(e){var t;const{workflowName:s,stepId:n}=e;return null===(t=this._handlers.get(s))||void 0===t?void 0:t.has(n)}},{key:"_logWorkflowExecution",value:function _logWorkflowExecution(e,t,s,n){this._logHandlers[s](e,t)}}],[{key:"getInstance",value:function getInstance(){return on._instance||(on._instance=new on),on._instance}},{key:"setInstance",value:function setInstance(e){on._instance=e}}])}();const rn=new Map,an=({type:e,groupID:t})=>e===Es.GRP_COMMUNITY||`${t}`.startsWith(ms.COMMUNITY)&&!`${t}`.includes(ms.TOPIC),cn=(e="")=>{const t=e.startsWith("GROUP")?e.replace("GROUP",""):e;return t.startsWith(ms.COMMUNITY)&&`${t}`.includes(ms.TOPIC)};function dn(e){return pe(this,void 0,void 0,function*(){const{servcmd:t,data:s}=function(e){const{data:t}=e;return hn(t)||gn(t)}(e)?function(e){let{servcmd:t,data:s}=e;return gn(s)?function(e){const{servcmd:t,data:s}=e;let{GroupId:n=""}=s;const o=n;return[n]=o.split(ms.TOPIC),{servcmd:pn(t),data:Object.assign(Object.assign({},s),{GroupId:n,TopicId:o})}}(e):(hn(s)&&(t=pn(t)),{servcmd:t,data:s})}(e):e,n=Yt.common.generateProtocolData({servcmd:t,data:s}),o=`${n.head.seq}${t}`;return Yt.channel.sendPacket(n,{requestId:o,timeout:e.timeout})})}function hn(e){const{Type:t,GroupId:s,GroupIdList:n=[]}=e,o=s||n[0]||"";return an({type:t,groupID:o})}function gn(e){const{GroupId:t=""}=e;return cn(t)}function pn(e){if(e.includes("openim"))return e;return`million_group_open_http_svc.${e.split(".")[1]}`}function _n(){var e;return null===(e=Yt.store.get("login"))||void 0===e?void 0:e.userId}const mn=e=>n(e)||o(e),vn=(t,s,n,o)=>{if(!mn(t)||!mn(s))return 0;let i=0;const r=Object.keys(s);let a;for(let c=0,u=r.length;c<u;c++)if(a=r[c],!(e(s[a])||n&&n.includes(a)))if(mn(t[a])&&mn(s[a]))i+=vn(t[a],s[a],n,o);else{if(o&&o.includes(s[a]))continue;t[a]!==s[a]&&(t[a]=s[a],i+=1)}return i},fn={zh:{MSG_IMAGE:"[图片]",MSG_LOCATION:"[位置]",MSG_AUDIO:"[语音]",MSG_VIDEO:"[视频]",MSG_FILE:"[文件]",MSG_CUSTOM:"[自定义消息]",MSG_GRP_TIP:"[群提示消息]",MSG_GRP_SYS_NOTICE:"[群系统通知]",MSG_FACE:"[动画表情]",MSG_MERGER:"[聊天记录]",MSG_STREAM:"[流式消息]",CREATE_GROUP:"创建群组",CREATE_COMMUNITY:"创建社群"},en:{MSG_IMAGE:"[Image]",MSG_LOCATION:"[Location]",MSG_AUDIO:"[Voice]",MSG_VIDEO:"[Video]",MSG_FILE:"[File]",MSG_CUSTOM:"[Custom Messages]",MSG_GRP_TIP:"[Group Notification]",MSG_GRP_SYS_NOTICE:"[Group System Message]",MSG_FACE:"[Animated Sticker]",MSG_MERGER:"[Chat Record]",MSG_STREAM:"[Stream Message]",CREATE_GROUP:"Create Group",CREATE_COMMUNITY:"Create Community"}};function In(e){var t;const s=Hs()?"en":"zh";return(null===(t=fn[s])||void 0===t?void 0:t[e])||e}const En={[Es.MSG_IMAGE]:"MSG_IMAGE",[Es.MSG_LOCATION]:"MSG_LOCATION",[Es.MSG_AUDIO]:"MSG_AUDIO",[Es.MSG_VIDEO]:"MSG_VIDEO",[Es.MSG_FILE]:"MSG_FILE",[Es.MSG_CUSTOM]:"MSG_CUSTOM",[Es.MSG_GRP_TIP]:"MSG_GRP_TIP",[Es.MSG_GRP_SYS_NOTICE]:"MSG_GRP_SYS_NOTICE",[Es.MSG_FACE]:"MSG_FACE",[Es.MSG_MERGER]:"MSG_MERGER",[Es.MSG_STREAM]:"MSG_STREAM"},Sn=(t,s)=>{if(e(s))return"";if(t===Es.MSG_TEXT)return s.text||"";const n=En[t];return n?In(n):""},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}],Mn="im_sdk_config_mgr.fetch_config",yn="im_sdk_config_mgr.push_configv2",On="cloud-config",Tn=new(function(){return _createClass(function _class7(){_classCallCheck(this,_class7)},[{key:"init",value:function init(e){this.core=e}}])}());function Rn(e){return pe(this,void 0,void 0,function*(){const{sdkAppId:t}=Tn.core.store.get("instance")||{},s=Tn.core.helper.generateProtocolData({servcmd:Mn,data:{uint32_sdkappid:t,uint64_version:e}}),n=`${s.head.seq}${Mn}`;return Tn.core.channel.sendPacket(s,{requestId:n})})}var Dn=new(function(){return _createClass(function _class8(){_classCallCheck(this,_class8),this._core=null,this._expirationTime=0,this._version=0,this._isFetching=!1,this._cmdFrequencyLimitMap=new Map,this._methodCallFrequencyMap=new Map},[{key:"install",value:function install(e){this._core=e;const{notificationCenter:t,InnerEvent:s,helper:n,constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:i},channel:r}=e;t.subscribeInnerEvent(yn,this._handlePushedConfig,this),n.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,i.CLOUD_CONFIG_SYNC,this._handleLoginSuccess,this),t.subscribeInnerEvent(s.LOGOUT,this._reset,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this),n.registerExperimentalAPI("getServerConfig",this),this._updateCmdFreqLimitMap(Cn),r.registerBeforeSendInterceptor(this.checkMethodCallOverLimit,this)}},{key:"getServerConfig",value:function getServerConfig(e){return pe(this,void 0,void 0,function*(){var t;const s={code:0,data:""};return e?(s.data=(null===(t=this._core.store.get("cloudConfig"))||void 0===t?void 0:t[e])||"",s):s})}},{key:"checkMethodCallOverLimit",value:function checkMethodCallOverLimit(e){if(!this._cmdFrequencyLimitMap.has(e))return;if(!this._methodCallFrequencyMap.has(e))return void this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});const{count:t,interval:s}=this._cmdFrequencyLimitMap.get(e);let{startTime:n,methodCallCounter:o}=this._methodCallFrequencyMap.get(e);if(Date.now()-n>1e3*s)this._methodCallFrequencyMap.set(e,{startTime:Date.now(),methodCallCounter:1});else if(o+=1,this._methodCallFrequencyMap.set(e,{startTime:n,methodCallCounter:o}),o>t)throw new this._core.helper.ChatError({code:2996,replacement1:e})}},{key:"_handlePushedConfig",value:function _handlePushedConfig(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.info("_handlePushedConfig",s(e)),yield this._updateCloudConfig(e)})}},{key:"_handleLoginSuccess",value:function _handleLoginSuccess(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;try{if(this._canFetch()){const s=yield Rn(this._version);e.info("_fetchCloudConfigIfLogin",t(s)),yield this._updateCloudConfig(s)}this._core.helper.taskScheduler.addTask({id:On,intervalMs:1e3,callback:this._fetchCloudConfigIfReady,context:this})}catch(s){e.debug("_fetchCloudConfigIfLogin",t(s))}})}},{key:"_fetchCloudConfigIfReady",value:function _fetchCloudConfigIfReady(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=this._core;if(this._canFetch())try{const s=yield Rn(this._version);e.info("_fetchCloudConfigIfReady",t(s)),yield this._updateCloudConfig(s)}catch(s){e.error("_fetchCloudConfigIfReady",t(s))}})}},{key:"_updateCloudConfig",value:function _updateCloudConfig(e){return pe(this,void 0,void 0,function*(){const t=this._parseCloudConfig(e);t&&(this._core.store.set("cloudConfig",t),yield this._parseCmdFreqLimit(),this._core.notificationCenter.emitInnerEvent(this._core.InnerEvent.CLOUD_CONFIG_UPDATE,t),this._core.notificationCenter.emitOuterEvent(this._core.OuterEvent.SERVER_CONFIG_UPDATED,{name:this._core.OuterEvent.SERVER_CONFIG_UPDATED,data:{config:t}}))})}},{key:"_canFetch",value:function _canFetch(){const{isLoggedIn:e}=this._core.store.get("login")||{};return e&&!this._isFetching&&Date.now()>=this._expirationTime}},{key:"_parseCloudConfig",value:function _parseCloudConfig(e){const{int32_error_code:t,str_error_message:s,str_json_config:n,uint32_expired_time:o,uint32_sdkappid:i,uint64_version:r}=e;let a=null;if(0===t){if(this._version!==r)try{a=JSON.parse(n),this._version=r}catch(e){}this._expirationTime=Date.now()+1e3*o}else this._expirationTime=void 0===t?Date.now()+36e5:Date.now()+12e4;return a}},{key:"_parseCmdFreqLimit",value:function _parseCmdFreqLimit(){return pe(this,void 0,void 0,function*(){var e;let t=null===(e=yield this.getServerConfig("cmd_frequency_limit"))||void 0===e?void 0:e.data;const{isEmpty:s}=this._core.utils;if(!s(t))try{t=JSON.parse(t),this._updateCmdFreqLimitMap(t)}catch(e){console.warn(e)}})}},{key:"_updateCmdFreqLimitMap",value:function _updateCmdFreqLimitMap(e){e.forEach(e=>{this._cmdFrequencyLimitMap.set(e.cmd,{interval:e.interval,count:e.count})})}},{key:"_reset",value:function _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}},{key:"_dispose",value:function _dispose(){const{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()}}])}());let bn=function(){return _createClass(function bn(e=0,t=0){_classCallCheck(this,bn),this.high=e,this.low=t},[{key:"equal",value:function equal(e){return null!==e&&this.low===e.low&&this.high===e.high}},{key:"toString",value:function toString(){const e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t=`0${t}`,e--}return e+t}}])}();const Nn={SEARCH_GRP_SNS:new bn(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new bn(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new bn(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new bn(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new bn(0,Math.pow(2,6)).toString(),USER_STATUS:new bn(0,Math.pow(2,7)).toString(),CONV_MARK:new bn(0,Math.pow(2,9)).toString(),CONV_GROUP:new bn(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new bn(0,Math.pow(2,11)).toString(),MSG_EXT:new bn(0,Math.pow(2,13)).toString(),GRP_COUNTER:new bn(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new bn(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new bn(Math.pow(2,7)).toString(),PLUGIN_CS:new bn(Math.pow(2,8)).toString(),PLUGIN_PUSH:new bn(Math.pow(2,9)).toString(),PLUGIN_BOT:new bn(Math.pow(2,10)).toString(),MSG_REACTION:new bn(Math.pow(2,16)).toString(),FOLLOW:new bn(Math.pow(2,20)).toString()},Ln="CommercialConfig",Pn="commercial-config";var $n,xn,Gn=new(function(){return _createClass(function _class9(){_classCallCheck(this,_class9),this._core=null,this._expirationTime=0,this._isFetching=!1,this._featureMap=new Map,this._methodKeyMap=new Map,this._purchaseBits="0"},[{key:"install",value:function install(e){this._core=e;const{helper:t,notificationCenter:s,constants:{WORKFLOW_NAME:n,WORKFLOW_STEP:o,InnerEvent:i}}=e;s.subscribeInnerEvent(i.COMMERCIAL_CONFIG_PUSH,this._handlePushedConfig,this),s.subscribeInnerEvent(i.LOGOUT,this._handleLogout,this),s.subscribeInnerEvent(i.DESTROY,this._dispose,this),t.registerWorkflowStep(n.SYNC_SERVER_INFO_AFTER_LOGIN,o.COMMERCIAL_CONFIG_UPDATE,this._syncCommercialConfig,this),e.helper.registerExperimentalAPI("isCommercialAbilityEnabled",this),e.helper.registerExperimentalAPI("queryCommercialAbility",this)}},{key:"isCommercialAbilityEnabled",value:function isCommercialAbilityEnabled(e){return pe(this,void 0,void 0,function*(){const t=parseInt(e,10).toString(2),{length:s}=t;let n,o=!0;for(let e=s-1,i=0;e>=0;e--,i++)if("1"===t.charAt(e)&&(n=i<32?new bn(0,2**i).toString():new bn(2**(i-32),0).toString(),!this._featureMap.get(n))){o=!1;break}return this._core.ssoLog.debug("isFeatureEnabled",`${Ln}.isFeatureEnabled decimalNumber:${e} key:${n} ret:${o}`),{code:0,data:{enabled:o}}})}},{key:"queryCommercialAbility",value:function queryCommercialAbility(){return this._purchaseBits}},{key:"_fetchAndParseCommercialConfig",value:function _fetchAndParseCommercialConfig(){return pe(this,void 0,void 0,function*(){var e;const{ssoLog:t,utils:{safeStringify:s},common:{buildAndSendPacket:n}}=this._core;try{this._isFetching=!0;const t=yield n({servcmd:"im_sdk_config_mgr.fetch_imsdk_purchase_bitsv2",data:{uint32_sdkappid:null===(e=this._core.store.get("instance"))||void 0===e?void 0:e.sdkAppId}});t&&(this._parseCommercialConfig(t),this._core.store.set("commercialConfig",this._methodKeyMap))}catch(e){t.error("_fetchAndParseCommercialConfig",s(e))}finally{this._isFetching=!1}})}},{key:"_syncCommercialConfig",value:function _syncCommercialConfig(e){return pe(this,void 0,void 0,function*(){const{purchaseBits:t}=(null==e?void 0:e.data)||{};t&&(this._parsePurchaseBits(t),this._core.store.set("commercialConfig",this._methodKeyMap)),this._canFetch()&&(yield this._fetchAndParseCommercialConfig()),this._core.helper.taskScheduler.addTask({id:Pn,intervalMs:1e3,callback:this._fetchCommercialConfigIfReady,context:this})})}},{key:"_canFetch",value:function _canFetch(){var e;const t=null===(e=this._core.store.get("login"))||void 0===e?void 0:e.isLoggedIn,s=Date.now()>=this._expirationTime;return t&&!this._isFetching&&s}},{key:"_handlePushedConfig",value:function _handlePushedConfig(e){(null==e?void 0:e.body)&&(this._parseCommercialConfig(e.body),this._core.store.set("commercialConfig",this._methodKeyMap))}},{key:"_fetchCommercialConfigIfReady",value:function _fetchCommercialConfigIfReady(){return pe(this,void 0,void 0,function*(){this._canFetch()&&(yield this._fetchAndParseCommercialConfig())})}},{key:"_parseCommercialConfig",value:function _parseCommercialConfig(e){const{ssoLog:t}=this._core;if("object"!=typeof e)return;const{int32_error_code:s,str_error_message:n,str_purchase_bits:o,uint32_expired_time:i}=e;0===s?(this._parsePurchaseBits(o),this._expirationTime=Date.now()+1e3*i):void 0===s?(t.warn("_parseCommercialConfig",`${Ln}._parseCommercialConfig failed. Invalid message format:`,e),this._expirationTime=Date.now()+36e5):(t.warn("_parseCommercialConfig",`${Ln}._parseCommercialConfig errorCode:${s} errorMessage:${n}`),this._expirationTime=Date.now()+12e4)}},{key:"_isValidPurchaseBits",value:function _isValidPurchaseBits(e){return e&&"string"==typeof e&&e.length>=1&&e.length<=64&&/[01]{1,64}/.test(e)}},{key:"_parsePurchaseBits",value:function _parsePurchaseBits(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;if(this._isValidPurchaseBits(e)){this._purchaseBits=e,this._featureMap.clear(),this._methodKeyMap.clear();let t=null;for(let s=e.length-1,n=0;s>=0;s--,n++)if(t=n<32?new bn(0,2**n).toString():new bn(2**(n-32),0).toString(),"1"===e[s]){this._featureMap.set(t,!0);const e=this._getKeyByValue(Nn,t);e&&this._methodKeyMap.set(e,!0)}else{this._featureMap.set(t,!1);const e=this._getKeyByValue(Nn,t);e&&this._methodKeyMap.set(e,!1)}}else t.warn("_parsePurchaseBits",`${Ln}.parsePurchaseBits invalid purchases:${s(e)}`)}},{key:"_getKeyByValue",value:function _getKeyByValue(e,t){const s=Object.entries(e).find(([e,s])=>s===t);return s?s[0]:void 0}},{key:"_handleLogout",value:function _handleLogout(){this._reset()}},{key:"_dispose",value:function _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)}},{key:"_reset",value:function _reset(){this._core.helper.taskScheduler.removeTask(Pn),this._core.store.set("commercialConfig",{}),this._expirationTime=0,this._isFetching=!1,this._featureMap.clear(),this._purchaseBits="0"}}])}()),wn=new(function(){return _createClass(function _class0(){_classCallCheck(this,_class0),this._core=null,this._serverOverloadInfoMap=new Map},[{key:"install",value:function install(e){this._core=e;const{notificationCenter:t,InnerEvent:s,channel:n}=this._core;t.subscribeInnerEvent(s.OVERLOAD_PUSH,this._handleOverLoadPush,this),t.subscribeInnerEvent(s.LOGOUT,this._reset,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this),n.registerBeforeSendInterceptor(this.checkServerOverload,this)}},{key:"checkServerOverload",value:function checkServerOverload(e){if(!this._serverOverloadInfoMap.has(e))return;const{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)}},{key:"_handleOverLoadPush",value:function _handleOverLoadPush(e){const{OverLoadServCmd:t,DelaySecs:s}=e;this._serverOverloadInfoMap.set(t,{overloadStartTimestamp:Date.now(),delaySeconds:s})}},{key:"_reset",value:function _reset(){this._serverOverloadInfoMap.clear()}},{key:"_dispose",value:function _dispose(){this._reset();const{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(function(){return _createClass(function _class1(){_classCallCheck(this,_class1),this.name="ConfigCenter"},[{key:"install",value:function install(e){Tn.init(e),Dn.install(e),Gn.install(e),wn.install(e)}}])}()),kn=new(function(){return _createClass(function _class10(){_classCallCheck(this,_class10),this.name="ErrorMessage",this._core=null},[{key:"install",value:function install(e){return pe(this,void 0,void 0,function*(){if(this._core=e,this._canFetch()){const e=yield this._fetchErrorMessage();if(!e)return;const t=this._parseResponse(e);this._saveErrorMessage(t)}})}},{key:"_canFetch",value:function _canFetch(){const e=this._core.store.getStorage("errorMessage");return!e||this._isExpired(e)}},{key:"_saveErrorMessage",value:function _saveErrorMessage(e){this._core.store.setStorage("errorMessage",{errorMessage:e,errorMessageSavedTime:(new Date).getTime()})}},{key:"_fetchErrorMessage",value:function _fetchErrorMessage(){return pe(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)}})}},{key:"_isExpired",value:function _isExpired(e){if(!e)return!0;const{errorMessageSavedTime:t}=e;return t&&(new Date).getTime()-t>=6048e5}},{key:"_parseResponse",value:function _parseResponse(e){if("string"==typeof e){const t=e.split(";\n"),s={},n=new RegExp(/'/g);for(let e=0;e<t.length;e++){const o=t[e].indexOf(":"),i=t[e].slice(0,o);let r=t[e].slice(o+1);if(!i.startsWith("//")){if(""===r)continue;r=r.replace(n,""),s[i]=r}}return s}}}])}());!function(e){e[e.START_SYNC=0]="START_SYNC",e[e.SYNCING=1]="SYNCING",e[e.SYNC_COMPLETE=2]="SYNC_COMPLETE"}($n||($n={})),function(e){e[e.LOGIN_SUCCESS=0]="LOGIN_SUCCESS",e[e.NEW_MESSAGE_RECEIVED=1]="NEW_MESSAGE_RECEIVED"}(xn||(xn={}));var qn=new(function(){return _createClass(function _class11(){_classCallCheck(this,_class11),this.name="UnreadMessageSynchronizer",this._unreadDBMessageMap=new Map,this._cookie="",this._localConversationIDListBeforeDisconnect=[]},[{key:"install",value:function install(e){this._core=e;const{constants:t}=e;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.SOCKET_DISCONNECTED,this._handleDisconnect,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}},{key:"_syncUnreadMessage",value:function _syncUnreadMessage(e){return pe(this,void 0,void 0,function*(){const{isAfterReOnline:t=!1,isAfterNewMessageReceived:s=!1,isAfterLogin:n=!1}=e||{};let o=$n.START_SYNC;const i=[],r=[],a=[],c=[];for(;this._canContinueSync({cookie:this._cookie,syncFlag:o});){const e=yield this._fetchUnreadDBMessage({cookie:this._cookie,syncFlag:o,syncTriggerEvent:s?xn.NEW_MESSAGE_RECEIVED:xn.LOGIN_SUCCESS});if(!e)break;const{unreadMessageList:n=[],revokedMessageList:u=[],overflowUnreadCountList:l,unreadCountList:d,groupTipList:h}=e;if(this._cookie=(null==e?void 0:e.cookie)||"",o=null==e?void 0:e.syncFlag,this._parseAndSaveUnreadMessageList(n),a.push(...u),this._updateConversationUnreadOptions({unreadCountList:d,overflowUnreadCountList:l,conversationUpdateFieldList:i}),Array.isArray(h)&&r.push(...h),t){const{messages:e}=this._handleNewMessageList(n);c.push(...e)}}return t?{conversationUpdateFieldList:i,revokedMessageList:a,unreadMessageMap:this._unreadDBMessageMap,groupTipList:r,messages:c,isUnreadC2CMessage:!0}:{conversationUpdateFieldList:i,isInstantMessage:!n,isUnreadC2CMessage:!0,revokedMessageList:a,unreadMessageMap:this._unreadDBMessageMap,groupTipList:r}})}},{key:"_syncUnreadDBMessageAfterLogin",value:function _syncUnreadDBMessageAfterLogin(){return pe(this,void 0,void 0,function*(){return this._cookie="",this._syncUnreadMessage({isAfterLogin:!0})})}},{key:"_syncUnreadDBMessageAfterNewMessageReceived",value:function _syncUnreadDBMessageAfterNewMessageReceived(e){return pe(this,void 0,void 0,function*(){if(1===e.data.Flag)return this._syncUnreadMessage({isAfterNewMessageReceived:!0})})}},{key:"_updateConversationUnreadOptions",value:function _updateConversationUnreadOptions(e){const{unreadCountList:t,overflowUnreadCountList:s,conversationUpdateFieldList:n}=e,{constants:{OuterConstant:{CONV_C2C:o,CONV_SYSTEM:i}}}=this._core;null==t||t.forEach(e=>{const{From_Account:t,UnreadCount:s}=e;if(t!==i){const e=n.find(({conversationID:e})=>e===`${o}${t}`);e?e.unreadCount=s:n.push({conversationID:`${o}${t}`,unreadCount:s,type:o})}}),null==s||s.forEach(e=>{const{From_Account:t,LastMsgTime:s}=e;t!==i&&(n.find(({conversationID:e})=>e===`${o}${t}`)||n.push({conversationID:`${o}${t}`,type:o,lastMsgTime:s}))})}},{key:"_syncUnreadDBMessageAfterReOnline",value:function _syncUnreadDBMessageAfterReOnline(){return pe(this,void 0,void 0,function*(){return this._syncUnreadMessage({isAfterReOnline:!0})})}},{key:"_updateMessageProfile",value:function _updateMessageProfile(e){var t;const{messageDataHandler:s}=this._core.message||{},n=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,{from:o,nick:i,avatar:r,conversationID:a=""}=e;if(o!==n){const t=s.getLatestMsgSentByPeer(a);if(t){const{nick:n,avatar:o}=t;i&&r?i===n&&r===o||s.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:i,latestAvatar:r,isSentByMe:!1}):(e.nick=n,e.avatar=o)}}else{const e=s.getLatestMsgSentByMe(a);!e||i===e.nick&&r===e.avatar||s.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:i,latestAvatar:r,isSentByMe:!0})}}},{key:"_handleNewMessageList",value:function _handleNewMessageList(e){const{messageDataHandler:t}=this._core.message||{},s=new Map,n=[];return e.forEach(e=>{this._updateMessageProfile(e);let o=1===e.isModified;if(t.isMessageSentByCurrentInstance(e)?e.isModified=o:o=!1,e.isOnlineMessage())e._onlineOnlyFlag=!0,t.isMessageSentByCurrentInstance(e)||n.push(e);else if(this._shouldStoreUnreadMessage(e)){if(t.storeConversationMessage(e)){const{conversationID:t,conversationType:n,conversationSubType:o,flow:i,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=e,c=a?"":e;s.has(t)?(s.get(t).lastMessage=c,"in"===i&&(r||s.get(t).unreadCount++)):s.set(t,{conversationID:t,type:n,subType:o,unreadCount:r||"in"!==i?0:1,lastMessage:c})}t.isMessageSentByCurrentInstance(e)&&!o||n.push(e)}}),{messages:n,conversationOptions:s}}},{key:"_shouldStoreUnreadMessage",value:function _shouldStoreUnreadMessage(e){var t;const{conversationID:s}=e,{message:n,appStore:o,utils:{isEmpty:i}}=this._core||{},r=Array.from((null===(t=o.conversationStore.getConversationMap())||void 0===t?void 0:t.keys())||[]),a=this._getLocalLastMessageTime(s);return!n.messageDataHandler.isInMessageList(e)&&r.includes(s)&&this._localConversationIDListBeforeDisconnect.includes(s)&&!i(a)}},{key:"_fetchUnreadDBMessage",value:function _fetchUnreadDBMessage(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;try{const n="unread-message-synchronizer._fetchUnreadDBMessage";t.debug("_fetchUnreadDBMessage",`${n} options:${s(e)}`);const o=yield function Fn(e,t){return pe(this,void 0,void 0,function*(){const{cookie:s,syncFlag:n,syncTriggerEvent:o}=e,i="openim.getmsg",r=t.helper.generateProtocolData({servcmd:i,data:{Cookie:s,SyncFlag:n,IsOnlineSync:o,NeedAbstract:1,NeedSignaling:1,NeedCachedMsg:1}}),a=`${r.head.seq}${i}`;try{const e=yield t.channel.sendPacket(r,{requestId:a});if(!e)return null;const{C2CPairUnreadCount:s,C2CRemainingUnreadCount:n,EventArray:o}=e,{unreadMessageList:i,revokedMessageList:c}=function(e,t){const s=[],n=[];return null==e||e.forEach(e=>{var o,i,r;const a=function(e,t){const{From_Account:s,From_AccountHeadurl:n,From_AccountNick:o,IsNeedReadReceipt:i,MsgBody:r,MsgClientTime:a,MsgRandom:c,MsgSeq:u,MsgTimeStamp:l,SendMsgControl:d,SupportMessageExtension:h,To_Account:g,TinyId:p,MsgCheckResult:_,CloudCustomData:m,IsPeerRead:v,MsgFlagBits:f,MsgVersion:I,EventArray:E}=e;return{from:s,avatar:n,nick:o,needReadReceipt:1===i,readReceiptSentByPeer:v,clientTime:a,messageFlagBits:f,random:c,sequence:u,time:l,messageControlInfo:d,isSupportExtension:h,to:g,tinyID:p,checkResult:_,cloudCustomData:m,messageVersion:I,eventArray:E,elements:t.message.messageHelper.parseServerPushMessageElement(r)}}(e,t);if(null===(r=null===(i=null===(o=null==e?void 0:e.EventArray)||void 0===o?void 0:o[0])||void 0===i?void 0:i.hasOwnProperty)||void 0===r?void 0:r.call(i,"C2cNotifyMsgArray"))n.push(...function(e){var t;const s=[];return null===(t=e.EventArray)||void 0===t||t.forEach(e=>{var t,n;const{C2cNotifyMsgArray:o}=e,i=null===(n=null===(t=null==o?void 0:o[0])||void 0===t?void 0:t.WithdrawC2cMsgNotify)||void 0===n?void 0:n.C2cWithdrawInfoArray;Array.isArray(i)&&s.push(...i)}),s}(e));else{const e=t.message.messageFactory.createMessage(Object.assign(Object.assign({},a),{conversationType:"C2C",flow:"in"})),{elements:n}=a;e.setElement(n),s.push(e)}}),{unreadMessageList:s,revokedMessageList:n}}(e.MsgList,t);return{syncFlag:null==e?void 0:e.SyncFlag,unreadMessageList:i,revokedMessageList:c,unreadCountList:s,overflowUnreadCountList:n,cookie:null==e?void 0:e.Cookie,groupTipList:o}}catch(e){console.warn(e)}})}(e,this._core);if(!o)return null;const{syncFlag:i,unreadMessageList:r,revokedMessageList:a,cookie:c,unreadCountList:u,overflowUnreadCountList:l,groupTipList:d}=o;return this._parseAndSaveUnreadMessageList(r),{syncFlag:i,cookie:c,unreadMessageList:r,revokedMessageList:a,unreadCountList:u,overflowUnreadCountList:l,groupTipList:d}}catch(e){console.log(e)}})}},{key:"_canContinueSync",value:function _canContinueSync({cookie:e,syncFlag:t}){var s;return t===$n.START_SYNC||t===$n.SYNCING&&!(null===(s=this._core)||void 0===s?void 0:s.helper.isEmpty(e))}},{key:"_parseAndSaveUnreadMessageList",value:function _parseAndSaveUnreadMessageList(e){e.forEach(e=>{const{ID:t}=e;this._unreadDBMessageMap.set(t,e)})}},{key:"_handleDisconnect",value:function _handleDisconnect(){var e;const{appStore:t}=this._core;this._localConversationIDListBeforeDisconnect=Array.from((null===(e=t.conversationStore.getConversationMap())||void 0===e?void 0:e.keys())||[])}},{key:"_getLocalLastMessageTime",value:function _getLocalLastMessageTime(e){const{message:t}=this._core,s=t.messageDataHandler.getLocalMessageList(e),n=s[s.length-1];return null==n?void 0:n.time}},{key:"_reset",value:function _reset(){this._cookie="",this._unreadDBMessageMap.clear()}},{key:"_dispose",value:function _dispose(){var e,t;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),this._reset()}}])}()),Vn=new(function(){return _createClass(function _class12(){_classCallCheck(this,_class12)},[{key:"init",value:function init(e){var t;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===(t=this._core)||void 0===t||t.store.set("activityMonitor",{isActive:!0})}},{key:"_handleVisibilityChange",value:function _handleVisibilityChange(){var e,t;const s="visible"===(null===document||void 0===document?void 0:document.visibilityState);null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:s}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:s})}},{key:"_reset",value:function _reset(){var e;null===(e=this._core)||void 0===e||e.store.clear("activityMonitor")}},{key:"_dispose",value:function _dispose(){null===document||void 0===document||document.removeEventListener("visibilitychange",this._visibilityChangeHandler);const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}}])}()),Bn=new(function(){return _createClass(function _class13(){_classCallCheck(this,_class13)},[{key:"init",value:function init(e){var t;this._core=e,this._bindAppActivityEvent(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),null===(t=this._core)||void 0===t||t.store.set("activityMonitor",{isActive:!0})}},{key:"_bindAppActivityEvent",value:function _bindAppActivityEvent(){var e,t,s,n,o;const{MINI_APP_NAMESPACE:i,IN_TT_MINI_GAME:r,IN_WX_MINI_GAME:a}=(null===(e=this._core)||void 0===e?void 0:e.utils)||{};r||a?(null===(t=null==i?void 0:i.onShow)||void 0===t||t.call(i,()=>{var e,t;null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!0}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),null===(s=null==i?void 0:i.onHide)||void 0===s||s.call(i,()=>{var e,t;null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!1}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})})):(null===(n=null==i?void 0:i.onAppShow)||void 0===n||n.call(i,()=>{var e,t;null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!0}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!0})}),null===(o=null==i?void 0:i.onAppHide)||void 0===o||o.call(i,()=>{var e,t;null===(e=this._core)||void 0===e||e.store.set("activityMonitor",{isActive:!1}),null===(t=this._core)||void 0===t||t.notificationCenter.emitInnerEvent("activityStatusChange",{isActive:!1})}))}},{key:"_reset",value:function _reset(){var e;null===(e=this._core)||void 0===e||e.store.clear("activityMonitor")}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this),this._reset()}}])}()),jn=new(function(){return _createClass(function _class14(){_classCallCheck(this,_class14)},[{key:"init",value:function init(e){const{IN_MINI_APP:t,IN_WX_MINI_PLUGIN:s}=e.helper;s||(t?Bn.init(e):Vn.init(e))}}])}());var Wn=new(function(){return _createClass(function _class15(){_classCallCheck(this,_class15)},[{key:"init",value:function init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}},{key:"_activateNetworkMonitoring",value:function _activateNetworkMonitoring(){return pe(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)})}},{key:"_deactivateNetworkMonitoring",value:function _deactivateNetworkMonitoring(){null!==this._onOnlineCallback&&(window.removeEventListener("online",this._onOnlineCallback),this._onOnlineCallback=null),null!==this._onOfflineCallback&&(window.removeEventListener("offline",this._onOfflineCallback),this._onOfflineCallback=null)}},{key:"_onNetworkStatusChange",value:function _onNetworkStatusChange(e){var t,s;const{isConnected:n,networkType:o}=e;null===(t=this._core)||void 0===t||t.store.set("netWorkMonitor",{isNetworkOnline:n,networkType:o}),null===(s=this._core)||void 0===s||s.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:n,networkType:o})}},{key:"_onOnline",value:function _onOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:"online"})}},{key:"_onOffline",value:function _onOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:"none"})}},{key:"_reset",value:function _reset(){var e;this._deactivateNetworkMonitoring(),null===(e=this._core)||void 0===e||e.store.clear("netWorkMonitor")}},{key:"_dispose",value:function _dispose(){var e,t;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(null===(t=this._core)||void 0===t?void 0:t.InnerEvent.DESTROY,this._dispose,this),this._reset()}}])}()),Yn=new(function(){return _createClass(function _class16(){_classCallCheck(this,_class16)},[{key:"init",value:function init(e){this._core=e,this._activateNetworkMonitoring(),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}},{key:"_activateNetworkMonitoring",value:function _activateNetworkMonitoring(){return pe(this,void 0,void 0,function*(){try{const{utils:{MINI_APP_NAMESPACE:e}}=this._core;this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),e.onNetworkStatusChange(this._onNetworkStatusChange.bind(this))}catch(e){console.error(e)}})}},{key:"_deactivateNetworkMonitoring",value:function _deactivateNetworkMonitoring(){if(null!==this._mpNetworkStatusCallback){const{utils:{MINI_APP_NAMESPACE:e}}=this._core;e.offNetworkStatusChange&&e.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null}}},{key:"_onNetworkStatusChange",value:function _onNetworkStatusChange(e){var t,s;const{isConnected:n,networkType:o}=e;null===(t=this._core)||void 0===t||t.store.set("netWorkMonitor",{isNetworkOnline:n,networkType:o}),null===(s=this._core)||void 0===s||s.notificationCenter.emitInnerEvent("networkStatusChange",{isNetworkOnline:n,networkType:o})}},{key:"_reset",value:function _reset(){var e;this._deactivateNetworkMonitoring(),null===(e=this._core)||void 0===e||e.store.clear("netWorkMonitor")}},{key:"_dispose",value:function _dispose(){var e,t;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(null===(t=this._core)||void 0===t?void 0:t.InnerEvent.DESTROY,this._dispose,this),this._reset()}}])}()),zn=new(function(){return _createClass(function _class17(){_classCallCheck(this,_class17)},[{key:"init",value:function init(e){const{IN_MINI_APP:t}=e.utils;t?Yn.init(e):Wn.init(e)}}])}()),Jn=new(function(){return _createClass(function _class18(){_classCallCheck(this,_class18),this.name="SystemStateMonitor"},[{key:"install",value:function install(e){jn.init(e),zn.init(e)}}])}());const Qn=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.*"]),Xn="tui_room_svr.*";var Zn=new(function(){return _createClass(function _class19(){_classCallCheck(this,_class19),this.name="BusinessCommandTransfer",this._transferredCommands=Qn},[{key:"install",value:function install(e){this._core=e;const{notificationCenter:t,InnerEvent:s,helper:n}=e;t.subscribeInnerEvent(s.CLOUD_CONFIG_UPDATE,this._onCloudConfigUpdate,this),t.subscribeInnerEvent(s.LOGOUT,this._reset,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this),t.subscribeInnerEvent("im_open_push.msg_push",t.InnerEventSubType.BUSINESS_COMMAND,this._onServerPushBusinessCommand,this),n.registerExperimentalAPI("sendTRTCCustomData",this,"transferBusinessCommand"),n.registerExperimentalAPI("sendRoomCustomData",this,"transferBusinessCommand")}},{key:"transferBusinessCommand",value:function transferBusinessCommand(e){return pe(this,void 0,void 0,function*(){const t="transferBusinessCommand";try{const{serviceCommand:s=Xn}=e||{};if(!this._isValidTransferredCommand(s))throw new this._core.helper.ChatError({code:2995,functionName:t});const n=yield function(e,t){return pe(this,void 0,void 0,function*(){const{helper:s,channel:n}=t,{serviceCommand:o=Xn,data:i}=e||{};let r={};try{r="string"==typeof i?JSON.parse(i):i}catch(e){console.warn(e)}const a=s.generateProtocolData({servcmd:o,data:r}),c=`${a.head.seq}${o}`;return n.sendPacket(a,{requestId:c,shouldRejectOnError:!1})})}(e,this._core);return{code:0,data:n||{}}}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})}})}},{key:"_onCloudConfigUpdate",value:function _onCloudConfigUpdate(e={}){try{if("string"!=typeof e.rtc_cmd)return;const t=JSON.parse(e.rtc_cmd);Array.isArray(t)&&(this._transferredCommands=new Set([...this._transferredCommands,...t]))}catch(e){console.log(e)}}},{key:"_isValidTransferredCommand",value:function _isValidTransferredCommand(e=""){const t=`${null==e?void 0:e.split(".")[0]}.*`;return this._transferredCommands.has(t)}},{key:"_onServerPushBusinessCommand",value:function _onServerPushBusinessCommand(e){const{OuterEvent:t,notificationCenter:s}=this._core,{MsgContent:n}=e||{},{ROOM_CUSTOM_DATA_RECEIVED:o}=t;s.emitOuterEvent(o,{name:o,data:n})}},{key:"_reset",value:function _reset(){this._transferredCommands=Qn}},{key:"_dispose",value:function _dispose(){const{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)}}])}());const po="signaling",mo="signaling-timeout";function vo(e){return e.filter(e=>{if("TIMCustomElem"===e.type){const{cloudCustomData:t="",payload:{data:s=""}={}}=e,n=t.match(/"type":"tsignaling"/),o=s.match(/inviteID/),i=s.match(/actionType/);return n||o&&i}return!1})}function fo(e){const{data:t}=e.payload;try{return JSON.parse(t)}catch(e){return console.error(e),null}}function Io(e,t){return e.toString(16).padStart(t,"0")}function Eo(e){if(e<0||e>53)throw new Error("Number of digits must be between 0 and 53");if(e<=30)return Math.floor(Math.random()*(1<<e));const t=e-30;return Math.floor(Math.random()*(1<<t))*(1<<30)+Math.floor(Math.random()*(1<<30))}var So=new(function(){return _createClass(function _class20(){_classCallCheck(this,_class20),this._onlineSignalingMap=new Map,this._isSignalingListening=!1},[{key:"init",value:function init(e){this._core=e,e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this)}},{key:"getOnlineSignalingMap",value:function getOnlineSignalingMap(){return this._onlineSignalingMap}},{key:"hasSignaling",value:function hasSignaling(e){return this._onlineSignalingMap.has(e)}},{key:"getSignaling",value:function getSignaling(e){return this._onlineSignalingMap.get(e)}},{key:"saveSignaling",value:function saveSignaling(e,t){return this._onlineSignalingMap.set(e,t)}},{key:"removeSignaling",value:function removeSignaling(e){return this._onlineSignalingMap.delete(e)}},{key:"isInvitationValid",value:function isInvitationValid(e){const t=`${po}.isInvitationValid`,{inviteID:s,groupID:n,inviter:o}=e,i=o===this._core.common.getCurrentUserID();if(!this._onlineSignalingMap.has(s))return!1;const{inviteeList:r}=this._onlineSignalingMap.get(s);if(console.log(`${t} inviteID:${s} inviteeList:${r} groupID:${n}`),n){if(i)return r.length>0;const e=this._core.common.getCurrentUserID();return r.includes(e)}return!0}},{key:"updateSignaling",value:function updateSignaling(e){const t=`${po}.updateSignaling`,{inviteID:s,inviter:n,inviteeList:o,groupID:i}=e;if(console.log(`${t} inviteID:${s} inviter:${n} groupID:${i}`),i&&this.hasSignaling(s)){const e=o[0],{inviteeList:n}=this._onlineSignalingMap.get(s);n.includes(e)&&(n.splice(n.indexOf(e),1),console.log(`${t} remove ${e}. localInviteeList.length:${n.length}`)),0===n.length&&this.removeSignaling(s)}else this.removeSignaling(s)}},{key:"setSignalingListenStatus",value:function setSignalingListenStatus(e){this._isSignalingListening=e}},{key:"getSignalingListenStatus",value:function getSignalingListenStatus(){return this._isSignalingListening}},{key:"_dispose",value:function _dispose(){var e,t;this._reset(),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),this._isSignalingListening=!1}},{key:"_reset",value:function _reset(){this._onlineSignalingMap.clear()}}])}()),Co=new(function(){return _createClass(function _class21(){_classCallCheck(this,_class21)},[{key:"init",value:function init(e){this._core=e}},{key:"createInviteSignaling",value:function createInviteSignaling(e){const t=this._generateInviteID(),s=this._createInviteSignalingData(Object.assign(Object.assign({},e),{inviteID:t})),{groupID:n,inviteeList:o}=s,i=n||o[0];return{signaling:this._createSignaling(s,i),signalingData:s,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}},{key:"createAcceptSignaling",value:function createAcceptSignaling(e){const t=this._createAcceptSignalingData(e),{groupID:s,inviter:n}=t,o=s||n;return{signaling:this._createSignaling(t,o),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}},{key:"createCancelSignaling",value:function createCancelSignaling(e){const t=this._createCancelSignalingData(e),{groupID:s,inviteeList:n}=t,o=s||n[0];return{signaling:this._createSignaling(t,o),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}},{key:"createRejectSignaling",value:function createRejectSignaling(e){const t=this._createRejectSignalingData(e),{groupID:s,inviter:n}=t,o=s||n;return{signaling:this._createSignaling(t,o),signalingData:t,signalingExtensionOptions:this._createSignalingExtensionOptions(e)}}},{key:"createTimeoutSignaling",value:function createTimeoutSignaling(e){const{isInviter:t=!1}=e,s=this._createTimeoutSignalingData(e),{groupID:n,inviteeList:o,inviter:i}=s,r=n||(t?o[0]:i);return{signaling:this._createSignaling(s,r),signalingData:s,signalingExtensionOptions:this._createSignalingExtensionOptions(s)}}},{key:"_createSignalingExtensionOptions",value:function _createSignalingExtensionOptions(e){var t,s;const{data:n="",onlineUserOnly:o,inviteID:i="",offlinePushInfo:r,actionType:a}=e,c=(null===(s=null===(t=So.getSignaling(i))||void 0===t?void 0:t.signaling)||void 0===s?void 0:s._onlineOnlyFlag)||!1;return{onlineUserOnly:o||c,offlinePushInfo:r,messageControlInfo:this._createMessageControlInfo(n,a)}}},{key:"_createMessageControlInfo",value:function _createMessageControlInfo(e,t){const s=5===t&&!!e.match(/excludeTimeoutSignalingFromHistoryMessage/),n=!!e.match(/excludeFromHistoryMessage/)||!!e.match(/excludeOriginalSignalingFromHistoryMessage/);return{excludedFromContentModeration:!0,excludedFromUnreadCount:s||n,excludedFromLastMessage:s||n}}},{key:"_createInviteSignalingData",value:function _createInviteSignalingData(e){const t=`${po}._createInviteSignalingData`,{userID:s,timeout:n=0,groupID:o="",inviteeList:i=[]}=e,r=this._core.common.getCurrentUserID(),a=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:1,inviter:r,inviteeList:o?i:[s],timeout:n});return console.log(`${t} signalingData:`,a),a}},{key:"_createAcceptSignalingData",value:function _createAcceptSignalingData(e){const t=`${po}._createAcceptSignalingData`,{inviteID:s}=e,n=this._core.common.getCurrentUserID(),{inviter:o,groupID:i}=So.getSignaling(s),r=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:3,groupID:i,inviter:o,inviteeList:[n]});return console.log(`${t} signalingData:`,r),r}},{key:"_createCancelSignalingData",value:function _createCancelSignalingData(e){const t=`${po}._createCancelSignalingData`,{inviteID:s}=e,n=this._core.common.getCurrentUserID(),{inviteeList:o,groupID:i}=So.getSignaling(s),r=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:2,groupID:i,inviter:n,inviteeList:o});return console.log(`${t} signalingData:`,r),r}},{key:"_createRejectSignalingData",value:function _createRejectSignalingData(e){const t=`${po}._createRejectSignalingData`,{inviteID:s}=e,n=this._core.common.getCurrentUserID(),{inviter:o,groupID:i}=So.getSignaling(s),r=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:4,groupID:i,inviter:o,inviteeList:[n]});return console.log(`${t} signalingData:`,r),r}},{key:"_createTimeoutSignalingData",value:function _createTimeoutSignalingData(e){const t=`${po}._createTimeoutSignalingData`,{isInviter:s=!1,inviteID:n}=e,{inviteeList:o,inviter:i}=So.getSignaling(n),r=this._core.common.getCurrentUserID(),a=Object.assign(Object.assign({},this._generateBaseSignalData(e)),{actionType:5,inviter:i,inviteeList:s?o:[r]});return console.log(`${t} signalingData:`,a),a}},{key:"_createSignaling",value:function _createSignaling(e,t){var s,n,o;const{groupID:i=""}=e,r={to:t,conversationType:i?"GROUP":"C2C",priority:"High",payload:{data:JSON.stringify(e)}};return null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageFactory)||void 0===o?void 0:o.createCustomMessage(r)}},{key:"_generateInviteID",value:function _generateInviteID(){return[Io(Eo(32),8),Io(Eo(16),4),Io(16384|Eo(12),4),Io(32768|Eo(14),4),Io(Eo(48),12)].join("-")}},{key:"_generateBaseSignalData",value:function _generateBaseSignalData(e){const{data:t="",inviteID:s="",groupID:n=""}=e;return{businessID:1,timeout:0,data:t,inviteID:s,groupID:n}}}])}()),Mo=new(function(){return _createClass(function _class22(){_classCallCheck(this,_class22),this._isProcessingSignaling=!1},[{key:"init",value:function init(e){this._core=e,e.helper.registerApi({apiName:"invite",context:this}),e.helper.registerApi({apiName:"accept",context:this}),e.helper.registerApi({apiName:"cancel",context:this}),e.helper.registerApi({apiName:"reject",context:this}),e.helper.registerApi({apiName:"modifyInvitation",context:this}),e.helper.registerApi({apiName:"getSignalingInfo",context:this}),e.helper.registerApi({apiName:"addSignalingListener",context:this}),e.helper.registerApi({apiName:"removeSignalingListener",context:this}),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this)}},{key:"invite",value:function invite(e){return pe(this,void 0,void 0,function*(){var t;try{this._validateBeforeInvite(e);const{signaling:s,signalingData:n,signalingExtensionOptions:o}=Co.createInviteSignaling(e),i=yield this._sendSignaling(s,o);if(0===(null==i?void 0:i.code)){const{inviteID:e,timeout:o}=n;return So.saveSignaling(e,Object.assign(Object.assign({},n),{signaling:s})),o>0&&(null===(t=this._core)||void 0===t||t.helper.taskScheduler.addOnceTask({id:`${mo}-${e}`,intervalMs:1e3*(o+5),callback:this.handleInvitationExpiryTimer.bind(this,e)})),Object.assign(Object.assign({},i),{inviteID:e})}return i}catch(e){throw e}})}},{key:"accept",value:function accept(e){return pe(this,void 0,void 0,function*(){try{const{inviteID:t}=e;this._validateBeforeAccept(t),this._isProcessingSignaling=!0;const{signaling:s,signalingData:n,signalingExtensionOptions:o}=Co.createAcceptSignaling(e),i=yield this._sendSignaling(s,o);return 0===(null==i?void 0:i.code)?(So.updateSignaling(n),Object.assign(Object.assign({},i),{inviteID:t})):i}catch(e){throw e}finally{this._isProcessingSignaling=!1}})}},{key:"cancel",value:function cancel(e){return pe(this,void 0,void 0,function*(){try{const{inviteID:t}=e;this._validateBeforeCancel(t),this._isProcessingSignaling=!0;const{signaling:s,signalingExtensionOptions:n}=Co.createCancelSignaling(e),o=yield this._sendSignaling(s,n);return 0===(null==o?void 0:o.code)?(So.removeSignaling(t),Object.assign(Object.assign({},o),{inviteID:t})):o}catch(e){throw e}finally{this._isProcessingSignaling=!1}})}},{key:"reject",value:function reject(e){return pe(this,void 0,void 0,function*(){try{const{inviteID:t}=e;this._validateBeforeReject(t),this._isProcessingSignaling=!0;const{signaling:s,signalingExtensionOptions:n}=Co.createRejectSignaling(e),o=yield this._sendSignaling(s,n);return 0===(null==o?void 0:o.code)?(So.removeSignaling(t),Object.assign(Object.assign({},o),{inviteID:t})):o}catch(e){throw e}finally{this._isProcessingSignaling=!1}})}},{key:"modifyInvitation",value:function modifyInvitation(e){return pe(this,void 0,void 0,function*(){var t,s;const{inviteID:n,data:o}=e;let i="";try{this._validateBeforeModifyInvitation(n);const e=So.getSignaling(n),{signaling:r}=e,a=ge(e,["signaling"]);i=r.payload.data,a.data=o,r.payload.data=JSON.stringify(a);const c=yield null===(s=null===(t=this._core)||void 0===t?void 0:t.message.messageAction)||void 0===s?void 0:s.modifyMessage(r);return So.hasSignaling(n)&&So.saveSignaling(n,Object.assign(Object.assign({},a),{signaling:r})),c}catch(e){if(i){const{signaling:e}=So.getSignaling(n);e.payload.data=i}throw e}})}},{key:"getSignalingInfo",value:function getSignalingInfo(e){const{ssoLog:t,utils:{safeStringify:s}}=this._core;if(0===vo([e]).length)return;const n=fo(e),o={businessID:n.businessID||1,inviteID:n.inviteID,groupID:n.groupID||"",inviter:n.inviter||"",inviteeList:n.inviteeList||[],data:n.data||"",actionType:n.actionType||1,timeout:n.timeout||0};return t.debug(`${po} getSignalingInfo ${s(o)}`),o}},{key:"addSignalingListener",value:function addSignalingListener(e,t,s){var n,o;e===(null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.NEW_INVITATION_RECEIVED)&&So.setSignalingListenStatus(!0),null===(o=this._core)||void 0===o||o.notificationCenter.subscribeOuterEvent(e,t,s)}},{key:"removeSignalingListener",value:function removeSignalingListener(e,t,s){var n,o;e===(null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.NEW_INVITATION_RECEIVED)&&So.setSignalingListenStatus(!1),null===(o=this._core)||void 0===o||o.notificationCenter.unSubscribeOuterEvent(e,t,s)}},{key:"handleInvitationExpiryTimer",value:function handleInvitationExpiryTimer(e){const t=So.getOnlineSignalingMap(),s=this._core.common.getCurrentUserID();if(!t.has(e))return;const n=t.get(e).inviter===s;this._sendTimeoutNotice({inviteID:e,isInviter:n})}},{key:"_sendSignaling",value:function _sendSignaling(e,t){return pe(this,void 0,void 0,function*(){var s,n,o;return null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageSender)||void 0===o?void 0:o.sendMessage(e,t)})}},{key:"_sendTimeoutNotice",value:function _sendTimeoutNotice(e){return pe(this,void 0,void 0,function*(){var t,s,n;this._core.ssoLog.debug("_sendTimeoutNotice",`${po}._sendTimeoutNotice params:${JSON.stringify(e)}`);const{isInviter:o,inviteID:i}=e,{signaling:r,signalingData:a,signalingExtensionOptions:c}=Co.createTimeoutSignaling(e),u=yield this._sendSignaling(r,c);if(0===(null==u?void 0:u.code)){const{data:e,groupID:c,inviteeList:u,inviter:l}=a;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(null===(s=this._core)||void 0===s?void 0:s.SignalingEvent.INVITATION_TIMEOUT,{name:null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.INVITATION_TIMEOUT,data:{data:e,groupID:c,inviteID:i,inviteeList:u,inviter:l,isSelfTimeout:!0,message:r}}),o?So.removeSignaling(i):So.updateSignaling(a)}})}},{key:"_validateInviteId",value:function _validateInviteId(e,t){if(!So.hasSignaling(t))throw new this._core.helper.ChatError({functionName:e,code:8010})}},{key:"_validateProcessStatus",value:function _validateProcessStatus(e){if(this._isProcessingSignaling)throw new this._core.helper.ChatError({functionName:e,message:"processing other signaling operations"})}},{key:"_validateBeforeInvite",value:function _validateBeforeInvite(e){const{userID:s}=e,n=this._core.common.getCurrentUserID();if(s===n)throw new this._core.helper.ChatError({functionName:"invite",message:`cannot invite yourself, currentUserId:${n}, inviteeId:${s}`})}},{key:"_validateBeforeAccept",value:function _validateBeforeAccept(e){const t="accept";this._validateInviteId(t,e),this._validateProcessStatus(t);const s=this._core.common.getCurrentUserID(),{inviteeList:n}=So.getSignaling(e);if(!n.includes(s)){const n=`userID:${s} not in inviteeList. inviteID:${e}`;throw new this._core.helper.ChatError({functionName:t,message:n})}}},{key:"_validateBeforeCancel",value:function _validateBeforeCancel(e){const t="cancel";this._validateInviteId(t,e),this._validateProcessStatus(t);const s=this._core.common.getCurrentUserID(),{inviter:n}=So.getSignaling(e);if(n!==s){const e=`unmatched inviter:${n} and my userID:${s}`;throw new this._core.helper.ChatError({functionName:t,message:e})}}},{key:"_validateBeforeReject",value:function _validateBeforeReject(e){const t="reject";this._validateInviteId(t,e),this._validateProcessStatus(t);const s=this._core.common.getCurrentUserID(),{inviteeList:n}=So.getSignaling(e);if(!n.includes(s)){const n=`userID:${s} not in inviteeList. inviteID:${e}`;throw new this._core.helper.ChatError({functionName:t,message:n})}}},{key:"_validateBeforeModifyInvitation",value:function _validateBeforeModifyInvitation(e){this._validateInviteId("modifyInvitation",e)}},{key:"_dispose",value:function _dispose(){var e,t;this._reset(),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this)}},{key:"_reset",value:function _reset(){this._isProcessingSignaling=!1}}])}()),yo=new(function(){return _createClass(function _class23(){_classCallCheck(this,_class23),this._actionProcessor=new Map([[1,this._onNewInvitationReceived.bind(this)],[4,this._onInviteeRejected.bind(this)],[3,this._onInviteeAccepted.bind(this)],[2,this._onInvitationCancelled.bind(this)],[5,this._onInvitationTimeout.bind(this)]])},[{key:"init",value:function init(e){this._core=e,e.notificationCenter.subscribeOuterEvent(e.OuterEvent.MESSAGE_RECEIVED,this._handleMessageReceived,this),e.notificationCenter.subscribeOuterEvent(e.OuterEvent.MESSAGE_MODIFIED,this._handleMessageModified,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this._dispose,this)}},{key:"handleActionSignaling",value:function handleActionSignaling(e){e.forEach(e=>{const t=fo(e);if(t){const s=this._actionProcessor.get(t.actionType);null==s||s(t,e)}})}},{key:"_handleMessageReceived",value:function _handleMessageReceived(e){if(!So.getSignalingListenStatus())return;const t=vo(e.data);0!==t.length&&this.handleActionSignaling(t)}},{key:"_handleMessageModified",value:function _handleMessageModified(e){if(!So.getSignalingListenStatus())return;const t=vo(e.data);t.length>0&&t.forEach(e=>{const t=fo(e);t&&this._onInvitationModified(t,e)})}},{key:"_onNewInvitationReceived",value:function _onNewInvitationReceived(e,t){var s,n;const o=`${po}._onNewInvitationReceived`,{inviteID:i,inviteeList:r,groupID:a}=e,c=this._core.common.getCurrentUserID();if(this._core.ssoLog.debug("_onNewInvitationReceived",`${o} signalingData:${JSON.stringify(e)}}`),a&&!r.includes(c))return;let{timeout:u}=e;const l=Date.now()/1e3-t.time;u>0&&l>0&&u>l&&(u-=l);const d=So.getSignaling(i);d!==e&&(d||So.saveSignaling(i,Object.assign(Object.assign({},e),{signaling:t})),u>0&&(null===(s=this._core)||void 0===s||s.helper.taskScheduler.addOnceTask({id:`${mo}-${i}`,intervalMs:1e3*u,callback:Mo.handleInvitationExpiryTimer.bind(Mo,i)})),this._emitEvent({name:null===(n=this._core)||void 0===n?void 0:n.SignalingEvent.NEW_INVITATION_RECEIVED,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{inviteeList:r})}))}},{key:"_onInviteeRejected",value:function _onInviteeRejected(e){var t;const s=`${po}._onInviteeRejected`,{inviteID:n,inviter:o,groupID:i,inviteeList:r}=e,a=So.hasSignaling(n);this._core.ssoLog.debug("_onInviteeRejected",`${s} inviteID:${n} hasInviteID:${a} inviter:${o} groupID:${i}`),a&&(So.updateSignaling(e),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITEE_REJECTED,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{invitee:r[0]})}))}},{key:"_onInviteeAccepted",value:function _onInviteeAccepted(e){var t;const s=`${po}._onInviteeAccepted`,{inviteID:n,inviter:o,groupID:i,inviteeList:r}=e,a=So.hasSignaling(n);this._core.ssoLog.debug("_onInviteeAccepted",`${s} inviteID:${n} hasInviteID:${a} inviter:${o} groupID:${i}`),a&&(So.updateSignaling(e),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITEE_ACCEPTED,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{invitee:r[0]})}))}},{key:"_onInvitationCancelled",value:function _onInvitationCancelled(e){var t;const s=`${po}._onInvitationCancelled`,{inviteID:n,inviter:o,groupID:i}=e,r=So.hasSignaling(n);this._core.ssoLog.debug("_onInvitationCancelled",`${s} inviteID:${n} hasInviteID:${r} inviter:${o} groupID:${i}`),r&&(So.removeSignaling(n),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITATION_CANCELLED,data:this._generateBaseEmitData(e)}))}},{key:"_onInvitationTimeout",value:function _onInvitationTimeout(e){var t;const s=`${po}._onInvitationTimeout`,{inviteID:n,inviteeList:o}=e,i=So.hasSignaling(n);this._core.ssoLog.debug("_onInvitationTimeout",`${s} inviteID:${n} hasInviteID:${i} data:${e.data}`),i&&(So.updateSignaling(e),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.SignalingEvent.INVITATION_TIMEOUT,data:Object.assign(Object.assign({},this._generateBaseEmitData(e)),{inviteeList:o,isSelfTimeout:!1})}))}},{key:"_onInvitationModified",value:function _onInvitationModified(e,t){var s;const n=`${po}._onInvitationModified`,{inviteID:o,data:i}=e,r=So.hasSignaling(o);this._core.ssoLog.debug("_onInvitationModified",`${n} inviteID:${o} data:${i}`),r&&(So.saveSignaling(o,Object.assign(Object.assign({},e),{signaling:t})),this._emitEvent({name:null===(s=this._core)||void 0===s?void 0:s.SignalingEvent.INVITATION_MODIFIED,data:{inviteID:o,data:i}}))}},{key:"_emitEvent",value:function _emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}},{key:"_generateBaseEmitData",value:function _generateBaseEmitData(e){const{inviteID:t,inviter:s,groupID:n,data:o}=e;return{inviteID:t,inviter:s,groupID:n,data:o||""}}},{key:"_dispose",value:function _dispose(){var e,t,s;null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeOuterEvent(this._core.OuterEvent.MESSAGE_RECEIVED,this._handleMessageReceived,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeOuterEvent(this._core.OuterEvent.MESSAGE_MODIFIED,this._handleMessageModified,this),null===(s=this._core)||void 0===s||s.notificationCenter.unSubscribeOuterEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}}])}()),Oo=new(function(){return _createClass(function _class24(){_classCallCheck(this,_class24),this._offlineSignalingMap=new Map},[{key:"init",value:function init(e){this._core=e;const{notificationCenter:t,helper:s,constants:{InnerEvent:n,WORKFLOW_STEP:o,WORKFLOW_NAME:i}}=e;t.subscribeInnerEvent(n.DESTROY,this._dispose,this),t.subscribeInnerEvent(n.LOGOUT,this._reset,this),s.registerWorkflowStep(i.SYNC_SERVER_INFO_AFTER_LOGIN,o.SIGNALING_MESSAGE_RECOVER,this._handleC2COfflineMessage,this)}},{key:"_handleC2COfflineMessage",value:function _handleC2COfflineMessage(e){const{result:{unreadMessageMap:t}={}}=e||{};if(0===(null==t?void 0:t.size)||!So.getSignalingListenStatus())return;const s=vo([...t.values()]);if(0!==s.length&&(s.forEach(e=>{this._handleC2CActionType(e)}),this._offlineSignalingMap.size>0)){const e=this._sortOfflineSignalingByTime();yo.handleActionSignaling(e)}}},{key:"_handleC2CActionType",value:function _handleC2CActionType(e){const t=fo(e);if(!t)return;const{actionType:s}=t;1===s?this._saveValidOfflineInvite(t,e):this._removeOfflineInvite(t)}},{key:"_saveValidOfflineInvite",value:function _saveValidOfflineInvite(e,t){const{inviteID:s,inviteeList:n=[],timeout:o=0}=e,i=this._core.common.getCurrentUserID();if(!n.includes(i))return;const r=Date.now()/1e3-t.time;o>0&&r>o&&0!==o||this._offlineSignalingMap.set(s,Object.assign(Object.assign({},e),{signalingList:[t]}))}},{key:"_removeOfflineInvite",value:function _removeOfflineInvite(e){const{inviteID:t=""}=e;this._offlineSignalingMap.has(t)&&this._offlineSignalingMap.delete(t)}},{key:"_sortOfflineSignalingByTime",value:function _sortOfflineSignalingByTime(){let e=[];return this._offlineSignalingMap.forEach(t=>{e=[...e,...t.signalingList]}),e.sort((e,t)=>e.time-t.time)}},{key:"_dispose",value:function _dispose(){var e,t;this._reset(),null===(e=this._core)||void 0===e||e.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.LOGOUT,this._reset,this),null===(t=this._core)||void 0===t||t.notificationCenter.unSubscribeInnerEvent(this._core.InnerEvent.DESTROY,this._dispose,this)}},{key:"_reset",value:function _reset(){this._offlineSignalingMap.clear()}}])}());const Ao={invite:{userID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0},timeout:{required:!1,rules:["number"],allowEmpty:!1},onlineUserOnly:{required:!1,rules:["boolean"],allowEmpty:!1},offlinePushInfo:{required:!1,rules:["object"],allowEmpty:!1}},cancel:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},accept:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},reject:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}},modifyInvitation:{inviteID:{required:!0,rules:["string"],allowEmpty:!1},data:{required:!1,rules:["string"],allowEmpty:!0}}},To={invite:!0,cancel:!0,accept:!0,reject:!0,modifyInvitation:!0};var Ro=new(function(){return _createClass(function _class25(){_classCallCheck(this,_class25),this.name="Signaling"},[{key:"install",value:function install(e){Mo.init(e),yo.init(e),Co.init(e),So.init(e),Oo.init(e),e.helper.registerValidateConfig({auth:To,params:Ao})}}])}());const Do=new(function(){return _createClass(function _class26(){_classCallCheck(this,_class26)},[{key:"init",value:function init(e){this.core=e}}])}());function bo(e){let t;const{message:s}=Do.core,{conversationID:n,messageID:o}=e;return t=s.messageDataHandler.getLocalMessageList(n).find(e=>e.ID===o),t||(t=s.messageDataHandler.getSparseMessageList(n).find(e=>e.ID===o)),t}function No(e){return e.map(e=>{const{from:t,to:s,cloudCustomData:n,avatar:o,nick:i,ID:r,clientSequence:a,clientTime:c,messageRandom:u,messageSequence:l,time:d}=e;return{ClientSeq:a,CloudCustomData:n,From_Account:t,From_AccountHeadurl:o,From_AccountNick:i,Id:r,MsgBody:JSON.parse(JSON.stringify(e.transformElementsToServerFormat())),MsgClientTime:c,MsgRandom:u,Random:u,MsgSeq:l,MsgTimeStamp:d,ReceiverId:s,SenderId:t,To_Account:s}})}function Lo(e){var t;const{From_Account:s,From_AccountHeadurl:n,From_AccountNick:o,GroupId:i,MsgClientTime:r,ClientSeq:a,To_Account:c,MsgTimeStamp:u,TinyId:l,MsgRandom:d,MsgSeq:h}=e;return{from:s,avatar:n,nick:o,clientTime:r,time:u,tinyID:l,random:d,sequence:h,to:c,groupID:i,clientSequence:a,_elements:null===(t=e.MsgBody)||void 0===t?void 0:t.map(e=>{const{MsgType:t}=e;return Do.core.message.messageFactory.getElementClass(t).parseServerPushElement(e)})}}var Po,Go;!function(e){e.MSG_TEXT="TIMTextElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_FACE="TIMFaceElem",e.MSG_STREAM="TIMStreamElem"}(Po||(Po={})),function(e){e[e.FORWARD=0]="FORWARD",e[e.BACKWARD=1]="BACKWARD"}(Go||(Go={}));const $o={ZH_CN:"zh (cmn-Hans-CN)",EN_US:"en-US",YUE_HK:"yue-Hant-HK",JA_JP:"ja-JP",ZH_PY:"zh-PY"},jo="16k_zh-PY",Ho={[$o.ZH_CN]:"16k_zh",[$o.EN_US]:"16k_en",[$o.YUE_HK]:"16k_yue",[$o.JA_JP]:"16k_ja",[$o.ZH_PY]:jo},Ko=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/,Wo={READ:0,UNREAD:1};var Qo;!function(e){e.IN="in",e.OUT="out"}(Qo||(Qo={}));var ei,ti;!function(e){e[e.DATA=0]="DATA",e[e.REVOKED=1]="REVOKED"}(ei||(ei={})),function(e){e[e.NORMAL=0]="NORMAL",e[e.TIMEOUT=1]="TIMEOUT"}(ti||(ti={}));const si="StreamMsg.PushStreamHttp";var ni=new(function(){return _createClass(function _class27(){_classCallCheck(this,_class27),this._reactionsMap=new Map},[{key:"init",value:function init(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:{MESSAGE_PUSH:n},InnerEventSubType:{MESSAGE_REACTION_UPDATED:o,MESSAGE_REACTION_UPDATED_SYNC:i}}=e;t.registerApi({apiName:"addMessageReaction",context:this}),t.registerApi({apiName:"removeMessageReaction",context:this}),t.registerApi({apiName:"getMessageReactions",context:this}),t.registerApi({apiName:"getAllUserListOfMessageReaction",context:this}),s.subscribeInnerEvent(n,o,this._handleReactionUpdated,this),s.subscribeInnerEvent(n,i,this._handleReactionSync,this)}},{key:"addMessageReaction",value:function addMessageReaction(e,t){return pe(this,void 0,void 0,function*(){const{OuterConstant:s,ssoLog:n,helper:o}=this._core;this._validateMessageReactionBusinessCapability();const{conversationID:i,ID:r,conversationType:a,from:c,to:u,clientSequence:l,random:d,time:h,sequence:g}=e,p=`conversationID:${i} messageID:${r} reactionID:${t}`;try{return this._recordMessageReactedByMe(r,t),a===s.CONV_C2C?yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{from:n,to:o,clientSequence:i,random:r,time:a,reactionID:c}=e,u={From_Account:n,To_Account:o,MsgKey:`${i}_${r}_${a}`,Reaction:c,Add_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_add",data:u})})}({from:c,to:u,clientSequence:l,random:d,time:h,reactionID:t},this._core):a===s.CONV_GROUP&&(yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{to:n,reactionID:o,sequence:i}=e,r={GroupId:n,MsgSeq:i,Reaction:o,Add_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_add",data:r})})}({to:u,reactionID:t,sequence:g},this._core)),{code:0,successLog:{message:p}}}catch(e){this._removeMyReactionRecord(r,t);const{errorCode:s}=e||{};throw new o.ChatError({functionName:"addMessageReaction",code:s,moreMessage:p})}})}},{key:"removeMessageReaction",value:function removeMessageReaction(e,t){return pe(this,void 0,void 0,function*(){const{OuterConstant:s,helper:n}=this._core;this._validateMessageReactionBusinessCapability();const{conversationID:o,ID:i,conversationType:r,from:a,to:c,clientSequence:u,random:l,time:d,sequence:h}=e,g=`conversationID:${o} messageID:${i} reactionID:${t}`;try{return this._removeMyReactionRecord(i,t),r===s.CONV_C2C?yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{from:n,to:o,clientSequence:i,random:r,time:a,reactionID:c}=e,u={From_Account:n,To_Account:o,MsgKey:`${i}_${r}_${a}`,Reaction:c,Del_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_del",data:u})})}({from:a,to:c,clientSequence:u,random:l,time:d,reactionID:t},this._core):r===s.CONV_GROUP&&(yield function(e,t){return pe(this,void 0,void 0,function*(){var s;const{to:n,reactionID:o,sequence:i}=e,r={GroupId:n,MsgSeq:i,Reaction:o,Del_Account:[null===(s=t.store.get("login"))||void 0===s?void 0:s.userId]};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_del",data:r},t)})}({to:c,reactionID:t,sequence:h},this._core)),{code:0,successLog:{message:g}}}catch(e){const{errorCode:t}=e||{};throw new n.ChatError({functionName:"removeMessageReaction",code:t,moreMessage:g})}})}},{key:"getAllUserListOfMessageReaction",value:function getAllUserListOfMessageReaction(e){return pe(this,void 0,void 0,function*(){this._validateMessageReactionBusinessCapability();const{message:t,reactionID:s,nextSeq:n=0}=e,o=e.count>100?100:e.count,{conversationID:i}=t,{ssoLog:r,helper:a,constants:c}=this._core;try{let e=null;if(e=i.startsWith(c.OuterConstant.CONV_C2C)?yield function(e){return pe(this,void 0,void 0,function*(){const{message:t,nextSeq:s,reactionID:n,count:o}=e,{from:i,to:r,clientSequence:a,random:c,time:u}=t,l={Reaction:n,NextSeq:s,Count:o,From_Account:i,To_Account:r,MsgKey:`${a}_${c}_${u}`};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_iterate",data:l})})}({message:t,reactionID:s,nextSeq:n,count:o}):yield function(e){return pe(this,void 0,void 0,function*(){const{message:t,nextSeq:s,reactionID:n,count:o}=e,{sequence:i,to:r}=t,a={Reaction:n,NextSeq:s,GroupId:r,Count:o,MsgSeq:i};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_iterate",data:a})})}({message:t,reactionID:s,nextSeq:n,count:o}),e){const{Reaction_Account:t,NextSeq:s}=e;return{code:0,data:{nextSeq:s,isCompleted:0===n,userList:yield this._getUserProfileList(t)}}}}catch(e){const{errorCode:t}=e||{};throw new a.ChatError({functionName:"getAllUserListOfMessageReaction",code:t})}})}},{key:"getMessageReactions",value:function getMessageReactions(e){return pe(this,void 0,void 0,function*(){const{constants:t}=this._core;this._validateMessageReactionBusinessCapability();const{messageList:s,maxUserCountPerReaction:n=10}=e,o=s[0];let i=null;const r=new Map,{from:a,to:c,conversationType:u}=o,l=this._generateMessageKeyList(s,r);u===t.OuterConstant.CONV_C2C?i=yield function(e){return pe(this,void 0,void 0,function*(){const{from:t,to:s,messageKeyList:n,maxUserCountPerReaction:o}=e,i={From_Account:t,To_Account:s,MsgKeyList:n,Count:o};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.reaction_multi_stat",data:i})})}({from:a,to:c,messageKeyList:l,maxUserCountPerReaction:n}):u===t.OuterConstant.CONV_GROUP&&(i=yield function(e){return pe(this,void 0,void 0,function*(){const{groupId:t,messageSequenceList:s,maxUserCountPerReaction:n}=e,o={GroupId:t,MsgSeqList:s,Count:n};return Do.core.common.buildAndSendPacket({servcmd:"openim_msg_ext_http_svc.group_reaction_multi_stat",data:o})})}({groupId:c,messageSequenceList:l,maxUserCountPerReaction:n}));const{Results:d=[]}=i||{},h=this._extractUserIDsFromReactionResults(d),g=yield this._getUserProfileMap(h);return{code:0,data:{resultList:d.map(e=>{const{ReactionList:t,MsgSeq:s,MsgKey:n}=e;return{messageID:this._generateMessageID({messageSequence:s,messageKey:n,messageIDMap:r}),reactionList:t.map(e=>{const{Reaction:t,Count:s,Reaction_Account:n,ReactedByMe:o}=e;return{reactionID:t,totalUserCount:s,partialUserList:this._generatePartialUserInfo({userIDList:n,userProfileMap:g}),reactedByMyself:1===o}})}})}}})}},{key:"dispose",value:function dispose(){this._reactionsMap.clear()}},{key:"_extractUserIDsFromReactionResults",value:function _extractUserIDsFromReactionResults(e){const t=[];return null==e||e.forEach(e=>{const{ReactionList:s=[]}=e;s.forEach(e=>{e.Reaction_Account&&t.push(...e.Reaction_Account)})}),t}},{key:"_getUserProfileList",value:function _getUserProfileList(e){return pe(this,void 0,void 0,function*(){var t;try{const s=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:e});return s?s.data:[]}catch(e){return[]}})}},{key:"_getUserProfileMap",value:function _getUserProfileMap(e){return pe(this,void 0,void 0,function*(){const t=new Map;return(yield this._getUserProfileList(e)).forEach(e=>{const{nick:s,avatar:n,userID:o}=e;t.set(o,{nick:s,avatar:n,userID:o})}),t})}},{key:"_recordMessageReactedByMe",value:function _recordMessageReactedByMe(e,t){const s=`${e}-${t}`;this._reactionsMap.has(s)?this._reactionsMap.get(s).reactedByMe=!0:this._reactionsMap.set(s,{reactedByMe:!0})}},{key:"_removeMyReactionRecord",value:function _removeMyReactionRecord(e,t){const s=`${e}-${t}`;this._reactionsMap.has(s)&&(this._reactionsMap.get(s).reactedByMe=!1)}},{key:"_recordMessageReactionInfo",value:function _recordMessageReactionInfo(e){const{messageID:t,reactionID:s,reactionInfo:n}=e,o=`${t}-${s}`,i=this._reactionsMap.get(o)||{};this._reactionsMap.set(o,Object.assign(Object.assign({},i),n))}},{key:"_validateMessageReactionBusinessCapability",value:function _validateMessageReactionBusinessCapability(){const{helper:e,constants:t}=this._core;if(!e.checkBusinessCapabilityBits("MSG_REACTION"))throw new e.ChatError({functionName:"addMessageReaction",code:t.ERROR_CODE.NO_USE,replacement1:"addMessageReaction"})}},{key:"_handleReactionUpdated",value:function _handleReactionUpdated(e){const{MsgReactionNotifyList:t}=e,{notificationCenter:s,constants:n}=this._core;t.forEach(e=>pe(this,void 0,void 0,function*(){const{C2CMsgInfo:t,GroupMsgInfo:o,MsgReactionSummary:i}=e,{TinyId:r,MsgClientTime:a,MsgRandom:c}=Object.assign(Object.assign({},t),o),u=`${r}-${a}-${c}`,l=this._extractUserIDsFromReactionResults([{ReactionList:i}]),d=yield this._getUserProfileMap(l),h=i.map(e=>{var t;const{Reaction:s,Reaction_Account:n}=e,o=this._generatePartialUserInfo({userIDList:n,userProfileMap:d}),i=n?e.Count:0,r=(null===(t=this._reactionsMap.get(`${u}-${s}`))||void 0===t?void 0:t.reactedByMe)||!1;return this._recordMessageReactionInfo({messageID:u,reactionID:s,reactionInfo:{reactionID:s,totalUserCount:i,partialUserList:o}}),{reactionID:s,totalUserCount:i,partialUserList:o,reactedByMyself:r}});s.emitOuterEvent(n.OuterEvent.MESSAGE_REACTIONS_UPDATED,{name:n.OuterEvent.MESSAGE_REACTIONS_UPDATED,data:{messageID:u,reactionList:h}})}))}},{key:"_handleReactionSync",value:function _handleReactionSync(e){var t;const{notificationCenter:s,constants:n}=this._core,{C2CMsgInfo:o={},GroupMsgInfo:i={},Reaction:r,OperateType:a}=e.MsgReactionNotify,{TinyId:c="",MsgClientTime:u=0,MsgRandom:l=0}=Object.assign(Object.assign({},o),i),d=`${c}-${u}-${l}`,h=`${d}-${r}`;if(1===a?this._recordMessageReactedByMe(d,r):this._removeMyReactionRecord(d,r),null===(t=this._reactionsMap.get(h))||void 0===t?void 0:t.reactionID){const e=this._reactionsMap.get(h);e.reactedByMyself=1===a,s.emitOuterEvent(n.OuterEvent.MESSAGE_REACTIONS_UPDATED,{name:n.OuterEvent.MESSAGE_REACTIONS_UPDATED,data:{messageID:d,reactionList:[e]}})}}},{key:"_generatePartialUserInfo",value:function _generatePartialUserInfo({userIDList:e,userProfileMap:t}){const s=[];return null==e||e.forEach(e=>{t.has(e)&&s.push(t.get(e))}),s}},{key:"_generateMessageID",value:function _generateMessageID(e){const{messageSequence:t,messageKey:s,messageIDMap:n}=e;return s?n.get(s):n.get(t)}},{key:"_generateMessageKeyList",value:function _generateMessageKeyList(e,t){const{constants:s}=this._core,n=e[0],{conversationType:o}=n;let i=[];return o===s.OuterConstant.CONV_C2C?i=e.map(e=>{const{clientSequence:s,random:n,time:o,ID:i}=e,r=`${s}_${n}_${o}`;return t.set(r,i),r}):o===s.OuterConstant.CONV_GROUP&&(i=e.map(e=>{const{ID:s,sequence:n}=e;return t.set(n,s),n})),i}}])}()),oi=new(function(){return _createClass(function _class28(){_classCallCheck(this,_class28)},[{key:"init",value:function init(e){this._core=e;const{helper:t,InnerEvent:{MESSAGE_PUSH:s},InnerEventSubType:{C2C_MESSAGE_READ_RECEIPT:n,GROUP_MESSAGE_READ_RECEIPT:o},notificationCenter:i}=e;t.registerApi({apiName:"sendMessageReadReceipt",context:this}),t.registerApi({apiName:"getMessageReadReceiptList",context:this}),t.registerApi({apiName:"getGroupMessageReadMemberList",context:this}),i.subscribeInnerEvent(s,n,this._handleC2CMessageReadReceipt,this),i.subscribeInnerEvent(s,o,this._handleGroupMessageReadReceipt,this)}},{key:"sendMessageReadReceipt",value:function sendMessageReadReceipt(e){return pe(this,void 0,void 0,function*(){var t;const{common:s,constants:n}=this._core,o=this._filterValidMessageSendByOther(e);if(0===o.length)throw new s.ChatError({code:n.ERROR_CODE.READ_RECEIPT_MSG_LIST_EMPTY});try{const{conversationType:e}=o[0];return e===n.OuterConstant.CONV_C2C?yield function(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=Do.core,n=e[0].conversationID.replace(s.OuterConstant.CONV_C2C,""),o=e.map(e=>{const{from:t,to:s,sequence:n,random:o,time:i,clientTime:r}=e;return{From_Account:t,To_Account:s,MsgSeq:n,MsgRandom:o,MsgTime:i,MsgClientTime:r}}),i={Peer_Account:n,C2CMsgInfo:o};return t.buildAndSendPacket({servcmd:"openim.c2c_msg_read_receipt",data:i})})}(o):yield function(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=Do.core,n={GroupId:e[0].conversationID.replace(s.OuterConstant.CONV_GROUP,""),MsgSeqList:e.map(e=>({MsgSeq:e.sequence}))};return t.buildAndSendPacket({servcmd:"group_open_http_svc.group_msg_receipt",data:n})})}(o),{code:0,data:{}}}catch(e){const{errorCode:n,errorInfo:i}=e;throw new s.ChatError({code:n,message:i,moreMessage:`peerAccount:${null===(t=null==o?void 0:o[0])||void 0===t?void 0:t.conversationID}`})}})}},{key:"getMessageReadReceiptList",value:function getMessageReadReceiptList(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=this._core;try{const{conversationType:t}=e[0];if(t===s.OuterConstant.CONV_GROUP){const t=this._filterValidMessageSendByMe(e);if((null==t?void 0:t.length)>0){const s=yield function(e){return pe(this,void 0,void 0,function*(){const{common:t,constants:s}=Do.core,n={GroupId:e[0].conversationID.replace(s.OuterConstant.CONV_GROUP,""),MsgSeqList:e.map(e=>({MsgSeq:e.sequence}))};return t.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_msg_receipt",data:n})})}(t),{GroupMsgReceiptList:n}=s||{};this._updateGroupMessagesReadReceiptInfo({messageList:e,readReceiptList:n})}}return{code:0,data:{messageList:e}}}catch(e){const{errorCode:s,errorInfo:n}=e;throw new t.ChatError({code:s,message:n})}})}},{key:"getGroupMessageReadMemberList",value:function getGroupMessageReadMemberList(e){return pe(this,void 0,void 0,function*(){const{constants:t,common:s}=this._core,{message:n,filter:o=Wo.READ,cursor:i=""}=e,{conversationID:r,sequence:a,ID:c}=n,u=r.replace(t.OuterConstant.CONV_GROUP,""),l=e.count>=100?100:e.count;try{const e=yield function(e){return pe(this,void 0,void 0,function*(){const{sequence:t,groupID:s,filter:n,cursor:o,count:i}=e,r={MsgSeq:t,GroupId:s,Filter:n,Cursor:o,Num:i};return Do.core.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_msg_receipt_detail",data:r})})}({groupID:u,sequence:a,filter:o,cursor:i,count:l});if(e){const{Cursor:t,IsFinish:s,UnreadList:n,ReadList:i}=e,r={cursor:t,isCompleted:1===s,messageID:c,unreadUserIDList:[],readUserIDList:[]};return o===Wo.READ?r.readUserIDList=i.map(e=>e.Read_Account):o===Wo.UNREAD&&(r.unreadUserIDList=n.map(e=>e.Unread_Account)),{code:0,data:r}}}catch(e){const{errorCode:t,errorInfo:n}=e;throw new s.ChatError({code:t,message:n})}})}},{key:"_handleC2CMessageReadReceipt",value:function _handleC2CMessageReadReceipt(e){const t=[],{constants:s,helper:n}=this._core,{C2cMsgInfo:o,PeerReadTime:i,Peer_Account:r}=e;if(n.isEmpty(o))return;const a=`${s.OuterConstant.CONV_C2C}${r}`;null==o||o.forEach(e=>{const{TinyId:s,MsgClientTime:n,MsgRandom:o}=e,c=`${s}-${n}-${o}`,u=bo({conversationID:a,messageID:c});u&&!u.readReceiptInfo.isPeerRead&&(u.readReceiptInfo.isPeerRead=!0,u.readReceiptInfo.timestamp=i,t.push({userID:r,messageID:c,isPeerRead:!0,timestamp:i}))}),this._emitReadReceiptEventIfNeed(t)}},{key:"_updateGroupMessagesReadReceiptInfo",value:function _updateGroupMessagesReadReceiptInfo(e){const{messageList:t,readReceiptList:s}=e,n=new Map;t.forEach(e=>{n.set(e.sequence,e)}),null==s||s.forEach(e=>{if(0===e.Code){const{MsgSeq:t,ReadNum:s,UnreadNum:o}=e,i=n.get(t);i&&(i.readReceiptInfo.readCount=s,i.readReceiptInfo.unreadCount=o)}})}},{key:"_handleGroupMessageReadReceipt",value:function _handleGroupMessageReadReceipt(e){const t=[],{constants:s}=this._core,{GroupTips:n}=e;n.forEach(e=>{const{MsgBody:{GroupMsgReceiptList:n},GroupInfo:{GroupId:o}}=e,i=`${s.OuterConstant.CONV_GROUP}${o}`;null==n||n.forEach(e=>{const{TinyId:s,MsgClientTime:n,MsgRandom:r,ReadNum:a,UnreadNum:c}=e,u=`${s}-${n}-${r}`,l=bo({conversationID:i,messageID:u}),d={groupID:o,messageID:u,readCount:0,unreadCount:0};l&&("number"==typeof a&&(l.readReceiptInfo.readCount=a,d.readCount=a),"number"==typeof c&&(l.readReceiptInfo.unreadCount=c,d.unreadCount=c),t.push(d))})}),this._emitReadReceiptEventIfNeed(t)}},{key:"_emitReadReceiptEventIfNeed",value:function _emitReadReceiptEventIfNeed(e){const{notificationCenter:t,OuterEvent:s}=this._core;e.length>0&&t.emitOuterEvent(s.MESSAGE_READ_RECEIPT_RECEIVED,{name:s.MESSAGE_READ_RECEIPT_RECEIVED,data:e})}},{key:"_filterValidMessageSendByOther",value:function _filterValidMessageSendByOther(e){return this._filterNeedReadReceiptMessages(e).filter(e=>{const{from:t}=e;return t!==this._core.common.getCurrentUserID()})}},{key:"_filterValidMessageSendByMe",value:function _filterValidMessageSendByMe(e){const{OuterConstant:t}=this._core.constants;return this._filterNeedReadReceiptMessages(e).filter(e=>{const{from:s,status:n}=e;return s===this._core.common.getCurrentUserID()&&n===t.MessageStatus.SUCCESS})}},{key:"_filterNeedReadReceiptMessages",value:function _filterNeedReadReceiptMessages(e){return e.filter(e=>!0===e.needReadReceipt)}},{key:"dispose",value:function dispose(){const{InnerEvent:{MESSAGE_PUSH:e},InnerEventSubType:{C2C_MESSAGE_READ_RECEIPT:t,GROUP_MESSAGE_READ_RECEIPT:s},notificationCenter:n}=this._core;n.unSubscribeInnerEvent(e,t,this._handleC2CMessageReadReceipt,this),n.unSubscribeInnerEvent(e,s,this._handleGroupMessageReadReceipt,this)}}])}());function ii(e,t,s){return pe(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:n}}=Do.core,{from:o,to:i,clientSequence:r,random:a,time:c}=e;return n({servcmd:"openim_msg_ext_http_svc.set_key_values",data:{From_Account:o,To_Account:i,MsgKey:`${r}_${a}_${c}`,OperateType:s,ExtensionList:t}})})}function ri(e,t,s){return pe(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:n}}=Do.core,{to:o,sequence:i}=e;return n({servcmd:"openim_msg_ext_http_svc.group_set_key_values",data:{GroupId:o,MsgSeq:i,OperateType:s,ExtensionList:t}})})}var ai=new(function(){return _createClass(function _class29(){_classCallCheck(this,_class29),this._messageExtensionsMap=new Map,this._extensionsLatestSequenceMap=new Map,this._completedFetchExtensions=new Set},[{key:"init",value:function init(e){this._core=e;const{notificationCenter:t,helper:{registerApi:s},InnerEvent:{MESSAGE_PUSH:n,LOGOUT:o},InnerEventSubType:{MESSAGE_EXTENSIONS_UPDATED:i}}=e;s({apiName:"setMessageExtensions",context:this}),s({apiName:"getMessageExtensions",context:this}),s({apiName:"deleteMessageExtensions",context:this}),t.subscribeInnerEvent(n,i,this._handleMessageExtensionsNotify,this),t.subscribeInnerEvent(o,this.reset,this)}},{key:"setMessageExtensions",value:function setMessageExtensions(e,t){return pe(this,void 0,void 0,function*(){this._validateMessageExtensionBusinessCapability("setMessageExtensions");const{constants:{OuterConstant:s},ssoLog:n}=this._core,{ID:o,conversationID:i,sequence:r,time:a,conversationType:c}=e;let u=t;t.length>20&&(u=t.slice(0,20),n.warn("setMessageExtensions","the length of extensions cannot exceed 20"));const l=this._generateServerExtensions(e,u),d=`convID:${i} messageID:${o} sequence:${r} time:${a} count:${u.length}`;try{let t;if(c===s.CONV_C2C?t=yield ii(e,l,1):c===s.CONV_GROUP&&(t=yield ri(e,l,1)),t){const{resultList:s,successCount:n,failureCount:o}=this._handleModifyMessageExtensions(e,t);return{code:0,data:{extensions:s},successLog:{message:`${d} successCount:${n} failCount:${o}`}}}return{code:0,data:{extensions:[]}}}catch(e){const{errorCode:t}=e;throw new this._core.helper.ChatError({functionName:"setMessageExtensions",code:t,moreMessage:d})}})}},{key:"getMessageExtensions",value:function getMessageExtensions(e){return pe(this,void 0,void 0,function*(){const{utils:{isUndefined:t}}=this._core;this._validateMessageExtensionBusinessCapability("getMessageExtensions");const{conversationID:s,ID:n,sequence:o,time:i}=e,r=`convID:${s} messageID:${n} sequence:${o} time:${i}`;try{let s;this._completedFetchExtensions.has(n)&&(s=this._extensionsLatestSequenceMap.get(n));const o=yield this._fetchMessageExtensions(e,s);return t(s)&&o.length>1&&this._completedFetchExtensions.add(n),{code:0,data:{extensions:o},successLog:{message:r}}}catch(e){const{errorCode:t,errorInfo:s=""}=e||{};throw new this._core.common.ChatError({code:t,message:s,moreMessage:r})}})}},{key:"deleteMessageExtensions",value:function deleteMessageExtensions(e,t){return pe(this,void 0,void 0,function*(){this._validateMessageExtensionBusinessCapability("deleteMessageExtensions");const{utils:{isEmpty:s},constants:{OuterConstant:n}}=this._core,{conversationType:o,conversationID:i,sequence:r,ID:a,time:c}=e;let u=3;const l=[];s(t)||(u=2,null==t||t.forEach(e=>{l.push({key:e,value:"",seq:0})}));const d=`convID:${i} messageID:${a} sequence:${r} time:${c} operateType:${u}`,h=this._generateServerExtensions(e,l);try{let t;if(o===n.CONV_C2C?t=yield ii(e,h,u):o===n.CONV_GROUP&&(t=yield ri(e,h,u)),t){const{resultList:s,successCount:n,failureCount:o}=this._handleModifyMessageExtensions(e,t);return{code:0,data:{extensions:s},successLog:{message:`${d}successCount:${n} failCount:${o}`}}}return{code:0,data:{extensions:[]}}}catch(e){const{errorCode:t}=e;throw new this._core.helper.ChatError({functionName:"deleteMessageExtensions",code:t,moreMessage:d})}})}},{key:"reset",value:function reset(){this._messageExtensionsMap.clear(),this._extensionsLatestSequenceMap.clear(),this._completedFetchExtensions.clear()}},{key:"dispose",value:function dispose(){this.reset();const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,LOGOUT:s},InnerEventSubType:{MESSAGE_EXTENSIONS_UPDATED:n}}=this._core;e.unSubscribeInnerEvent(t,n,this._handleMessageExtensionsNotify,this),e.subscribeInnerEvent(s,this.reset,this)}},{key:"_handleModifyMessageExtensions",value:function _handleModifyMessageExtensions(e,t){const{ID:s}=e,{Seq:n}=t,o=t.ExtensionList||[],i=[];let r=0,a=0,c=[];return o.forEach(e=>{const{ErrorCode:t,Extension:s}=e,{Key:n,Value:o,Seq:u}=s;i.push({code:t,key:n,value:o}),0===t?r++:a++,c.push({key:n,value:o,seq:u})}),this._extensionsLatestSequenceMap.set(s,n),c.length>0&&this._updateLocalExtensions(e.ID,c),{resultList:i,successCount:r,failureCount:a}}},{key:"_updateLocalExtensions",value:function _updateLocalExtensions(e,t){this._messageExtensionsMap.has(e)||this._messageExtensionsMap.set(e,new Map);const s=this._messageExtensionsMap.get(e);null==t||t.forEach(e=>{const{key:t,seq:n,value:o=""}=e;null==s||s.set(t,{value:o,seq:n})})}},{key:"_fetchMessageExtensions",value:function _fetchMessageExtensions(e,t){return pe(this,void 0,void 0,function*(){const{constants:{OuterConstant:s},utils:{isEmpty:n}}=this._core;try{let o;const{conversationType:i,ID:r}=e;if(i===s.CONV_C2C?o=yield function(e,t){const{common:{buildAndSendPacket:s}}=Do.core,{from:n,to:o,clientSequence:i,random:r,time:a}=e;return s({servcmd:"openim_msg_ext_http_svc.get_key_values",data:{From_Account:n,To_Account:o,MsgKey:`${i}_${r}_${a}`,StartSeq:t}})}(e,t):i===s.CONV_GROUP&&(o=yield function(e,t){const{common:{buildAndSendPacket:s}}=Do.core,{to:n,sequence:o}=e;return s({servcmd:"openim_msg_ext_http_svc.group_get_key_values",data:{GroupId:n,MsgSeq:o,StartSeq:t}})}(e,t)),o){const{LatestSeq:t,ClearSeq:s,CompleteFlag:i}=o,a=(o.ExtensionList||[]).map(e=>({key:e.Key,value:e.Value,seq:e.Seq}));if(this._updateLocalExtensions(r,a),this._clearLocationExtensions(r,s),this._extensionsLatestSequenceMap.set(r,t),1!==i){const t=a[a.length-1].seq+1;return this._fetchMessageExtensions(e,t)}const c=[];if(this._messageExtensionsMap.has(r)){const e=this._messageExtensionsMap.get(r);null==e||e.forEach((e,t)=>{const{value:s}=e;n(s)||c.push({key:t,value:s})})}return c}}catch(e){throw e}})}},{key:"_clearLocationExtensions",value:function _clearLocationExtensions(e,t){if(!(t<=0)&&this._messageExtensionsMap.has(e)){const s=this._messageExtensionsMap.get(e);null==s||s.forEach((e,n)=>{e.seq<=t&&s.delete(n)})}}},{key:"_generateServerExtensions",value:function _generateServerExtensions(e,t){const{ID:s}=e;if(this._messageExtensionsMap.has(s)){const e=this._messageExtensionsMap.get(s);return t.map(t=>{var s;const{key:n,value:o}=t;let i=0;return(null==e?void 0:e.has(n))&&(i=null===(s=e.get(n))||void 0===s?void 0:s.seq),{Key:n,Value:o,Seq:i}})}return t.map(e=>({Key:e.key,Value:e.value,Seq:0}))}},{key:"_validateMessageExtensionBusinessCapability",value:function _validateMessageExtensionBusinessCapability(e){const{helper:t,constants:s}=this._core;if(!t.checkBusinessCapabilityBits("MSG_EXT"))throw new t.ChatError({functionName:e,code:s.ERROR_CODE.NO_USE,replacement1:e})}},{key:"_handleMessageExtensionsNotify",value:function _handleMessageExtensionsNotify(e){const{SetKVInfo:t,DeleteKVInfo:s,ClearKVInfo:n,MsgOptType:o,TinyId:i,MsgLastSeq:r,ExtensionC2cMsgInfo:a,ExtensionGroupMsgInfo:c}=(null==e?void 0:e.MsgExtensionNotify)||{},u=a||c||{},{MsgClientTime:l,MsgRandom:d}=u,h=`${i}-${l}-${d}`;this._extensionsLatestSequenceMap.set(h,r),1===o?this._handleMessageExtensionsUpdated({messageID:h,updateMessageExtensionsInfo:t}):2===o?this._handleMessageExtensionsDeleted({messageID:h,deleteMessageExtensionsInfo:s}):3===o&&this._handleMessageExtensionsCleared({messageID:h,clearMessageExtensionsInfo:n})}},{key:"_handleMessageExtensionsUpdated",value:function _handleMessageExtensionsUpdated(e){const{notificationCenter:t,OuterEvent:s}=this._core,{messageID:n,updateMessageExtensionsInfo:o=[]}=e,i=[];o.forEach(e=>{const{MsgKeyValue:t=[]}=e,s=t.map(e=>(i.push({key:e.Key,value:e.Value}),{key:e.Key,value:e.Value,seq:e.Seq}));this._updateLocalExtensions(n,s)}),t.emitOuterEvent(s.MESSAGE_EXTENSIONS_UPDATED,{name:s.MESSAGE_EXTENSIONS_UPDATED,data:{messageID:n,extensions:i}})}},{key:"_handleMessageExtensionsDeleted",value:function _handleMessageExtensionsDeleted(e){const{notificationCenter:t,OuterEvent:s}=this._core,{messageID:n,deleteMessageExtensionsInfo:o=[]}=e,i=[];o.forEach(e=>{const{MsgKeyValue:t=[]}=e,s=t.map(e=>(i.push(e.Key),{key:e.Key,seq:e.Seq}));this._updateLocalExtensions(n,s)}),t.emitOuterEvent(s.MESSAGE_EXTENSIONS_DELETED,{name:s.MESSAGE_EXTENSIONS_DELETED,data:{messageID:n,keyList:i}})}},{key:"_handleMessageExtensionsCleared",value:function _handleMessageExtensionsCleared(e){const{notificationCenter:t,OuterEvent:{MESSAGE_EXTENSIONS_DELETED:s},utils:{isEmpty:n}}=this._core,{messageID:o,clearMessageExtensionsInfo:i=[]}=e,r=[];i.forEach(e=>{const{ClearMsgSeq:t}=e;this._messageExtensionsMap.has(o)&&(this._messageExtensionsMap.get(o)||[]).forEach((e,s)=>{e.seq<=t&&!n(e.value)&&r.push(s)}),this._clearLocationExtensions(o,t)}),t.emitOuterEvent(s,{name:s,data:{messageID:o,keyList:r}})}}])}());const ci={key:"message",required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{const{constants:{OuterConstant:t}}=Do.core;return e.status!==t.MessageStatus.SUCCESS?"message is not success":!0===e.isSupportExtension||"message is not support extension"}},ui={setMessageExtensions:[ci,{key:"extensions",required:!0,rules:["array"],allowEmpty:!1}],getMessageExtensions:[ci],deleteMessageExtensions:[ci]},li=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({deleteMessage:[{required:!0,rules:["array"],allowEmpty:!1}],revokeMessage:[{required:!0,rules:["object"],allowEmpty:!1}],resendMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"options",required:!1,rules:["object"],allowEmpty:!1}],getMessageList:{conversationID:{required:!0,rules:["string"],allowEmpty:!1},nextReqMessageID:{required:!1,rules:["string"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}},getMessageListHopping:{conversationID:{required:!0,rules:["string"],allowEmpty:!1},sequence:{required:!1,rules:["number"],allowEmpty:!0},direction:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}},createTextAtMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{const t=function(e){var t;return"string"==typeof(null==e?void 0:e.text)&&("string"!=typeof e.text||0!==(null===(t=null==e?void 0:e.text)||void 0===t?void 0:t.length))||"payload.text is invalid."}(e);return!0!==t?t:!((null==e?void 0:e.atUserList)&&!Array.isArray(e.atUserList))||"atUserList should be an array or undefind."}}},findMessage:[{required:!0,rules:["string"],allowEmpty:!1}],translateText:{sourceTextList:{required:!0,rules:["array"],allowEmpty:!1},sourceLanguage:{required:!0,rules:["string"],allowEmpty:!1},targetLanguage:{required:!0,rules:["string"],allowEmpty:!1}},createForwardMessage:{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}},createLocationMessage:{to:{required:!0,rules:["string"],allowEmpty:!1},conversationType:{required:!0,rules:["string"],allowEmpty:!1},payload:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>{const{utils:{isString:t,isNumber:s}}=Do.core;return t(null==e?void 0:e.description)?s(null==e?void 0:e.longitude)?!!s(null==e?void 0:e.latitude)||"payload.latitude must be a number.":"payload.longitude must be a number.":"payload.description must be a string."}}}},{addMessageReaction:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"reactionID",required:!0,rules:["string"],allowEmpty:!1}],removeMessageReaction:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"reactionID",required:!0,rules:["string"],allowEmpty:!1}],getMessageReactions:{messageList:{required:!0,rules:["array"],allowEmpty:!1},maxUserCountPerReaction:{required:!1,rules:["number"],allowEmpty:!0,customValidator:e=>"number"!=typeof e?"maxUserCountPerReaction is invalid.":!(e<0||e>10)||"maxUserCountPerReaction should between [0, 10]."}},getAllUserListOfMessageReaction:{message:{required:!0,rules:["object"],allowEmpty:!1,customValidator:e=>"success"===e.status||"message is invalid."},reactionID:{required:!0,rules:["string"],allowEmpty:!1},nextSeq:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0}}}),{sendMessageReadReceipt:[{required:!0,rules:["array"],allowEmpty:!1}],getMessageReadReceiptList:[{required:!0,rules:["array"],allowEmpty:!1}],getGroupMessageReadMemberList:{message:{required:!0,rules:["object"],allowEmpty:!1},filter:{required:!1,rules:["number"],allowEmpty:!0},count:{required:!1,rules:["number"],allowEmpty:!0},cursor:{required:!1,rules:["string"],allowEmpty:!0}}}),ui),{pinGroupMessage:{groupID:{required:!0,rules:["string"],allowEmpty:!1},message:{required:!0,rules:["object"],allowEmpty:!1},isPinned:{required:!0,rules:["boolean"],allowEmpty:!1}},getPinnedGroupMessageList:[{key:"groupID",required:!0,rules:["string"],allowEmpty:!1}]}),{createQuoteMessage:[{key:"message",required:!0,rules:["object"],allowEmpty:!1},{key:"quotedMessage",required:!0,rules:["object"],allowEmpty:!1}]}),di=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({deleteMessage:!0,revokeMessage:!0,resendMessage:!0,getMessageList:!0,getMessageListHopping:!0,createTextAtMessage:!0,findMessage:!0,translateText:!0,createForwardMessage:!0,createLocationMessage:!0},{addMessageReaction:!0,removeMessageReaction:!0,getMessageReactions:!0,getAllUserListOfMessageReaction:!0}),{sendMessageReadReceipt:!0,getMessageReadReceiptList:!0,getGroupMessageReadMemberList:!0}),{setMessageExtensions:!0,getMessageExtensions:!0,deleteMessageExtensions:!0}),{pinGroupMessage:!0,getPinnedGroupMessageList:!0}),{createQuoteMessage:!0});let hi=function(){return _createClass(function hi(e){_classCallCheck(this,hi),this._core=e},[{key:"deleteMessage",value:function deleteMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,messageIdentifiers:s}=e,n={From_Account:this._core.common.getCurrentUserID(),To_Account:t,MsgKeyList:s};return this._core.common.buildAndSendPacket({servcmd:"openim.delete_c2c_msg_ramble",data:n})})}},{key:"revokeMessage",value:function revokeMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,from:s,sequence:n,time:o,random:i}=e,r={MsgInfo:{From_Account:s,To_Account:t,MsgSeq:n,MsgRandom:i,MsgTimeStamp:o}};return this._core.common.buildAndSendPacket({servcmd:"openim.msgwithdraw",data:r})})}}])}(),gi=function(){return _createClass(function gi(e){_classCallCheck(this,gi),this._core=e},[{key:"deleteMessage",value:function deleteMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,messageIdentifiers:s}=e,n={GroupId:t,Deleter_Account:this._core.common.getCurrentUserID(),Seqs:s};return this._core.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_ramble_msg_by_seq",data:n})})}},{key:"revokeMessage",value:function revokeMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,sequence:s}=e,n={GroupId:t,MsgSeqList:[{MsgSeq:s}]};return this._core.common.buildAndSendPacket({servcmd:"group_open_http_svc.group_msg_recall",data:n})})}}])}();let _i=function(){return _createClass(function _i(e){_classCallCheck(this,_i),this._core=e},[{key:"generateRevokeMessage",value:function generateRevokeMessage(e){const{conversationID:t,sequence:s,random:n,tinyID:o,clientTime:i,revokeReason:r,revoker:a}=e;let c={};const{messageDataHandler:u}=this._core.message;return c=u.revokeMessage({conversationID:t,sequence:s,random:n,revoker:a}),c||(c={conversationID:t,sequence:s},o&&i&&n&&(c.ID=`${o}-${i}-${n}`)),c.revoker=a,c.revokeReason=r,c.revokerInfo={userID:a,nick:"",avatar:""},c}},{key:"updateRevokerInfo",value:function updateRevokerInfo(e){return pe(this,void 0,void 0,function*(){const t=e.map(e=>e.revoker);try{const s=yield this._fetchUserInfos(t);s&&e.forEach(e=>{const{revoker:t}=e;s[t]&&(e.revokerInfo.nick=s[t].nick||"",e.revokerInfo.avatar=s[t].avatar||"",e.revokerInfo.userID=t)})}catch(e){console.debug(e)}})}},{key:"_fetchUserInfos",value:function _fetchUserInfos(e){return pe(this,void 0,void 0,function*(){var t,s;const n=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:e});return(null==n?void 0:n.data)?null===(s=n.data)||void 0===s?void 0:s.reduce((e,{userID:t,nick:s,avatar:n})=>(e[t]={nick:s||"",avatar:n||""},e),{}):null})}}])}();var mi=new(function(){return _createClass(function _class30(){_classCallCheck(this,_class30),this._core=null,this._c2cMessageAction=null,this._groupMessageAction=null},[{key:"init",value:function init(e){this._core=e,this._groupMessageAction=new gi(e),this._c2cMessageAction=new hi(e),this._messageHelper=new _i(e);const{helper:t}=e;t.registerApi({apiName:"deleteMessage",context:this}),t.registerApi({apiName:"revokeMessage",context:this}),t.registerApi({apiName:"resendMessage",context:this}),t.registerApi({apiName:"findMessage",context:this}),t.registerApi({apiName:"createQuoteMessage",context:this})}},{key:"deleteMessage",value:function deleteMessage(e){return pe(this,void 0,void 0,function*(){let t=[],s=[];const{conversationID:n,conversationType:o}=e[0],i=n.replace(o,"");if("@TIM#SYSTEM"===o)throw new this._core.helper.ChatError({code:2116});if(e.forEach(e=>{const{conversationID:i,conversationType:r,status:a,_onlineOnlyFlag:c,sequence:u,random:l,time:d}=e||{};if("success"===a&&i===n&&r===o){if(!c){const e="C2C"===r?`${u}_${l}_${d}`:String(u);t.push(e)}s.push(e)}}),0===t.length)return this._handleDeleteMessageSuccess(s),{code:0,data:{messageList:s}};t.length>30&&(t=t.slice(0,30),s=s.slice(0,30));try{return"C2C"===o?yield this._c2cMessageAction.deleteMessage({to:i,messageIdentifiers:t}):yield this._groupMessageAction.deleteMessage({to:i,messageIdentifiers:t}),this._handleDeleteMessageSuccess(s),{code:0,data:{messageList:s}}}catch(e){const{utils:{safeStringify:s}}=this._core,{errorCode:n,errorInfo:o}=e;throw new this._core.helper.ChatError({functionName:"deleteMessage",code:n,message:o,moreMessage:`messageIdentifiers: ${s(t)}`})}})}},{key:"revokeMessage",value:function revokeMessage(e){return pe(this,void 0,void 0,function*(){var t;const{conversationType:s,isRevoked:n,ID:o,type:i,from:r,to:a}=e;let c=null;const u=`type:${i} from:${r} to:${a} ID:${o}`;if("@TIM#SYSTEM"===s)throw new this._core.helper.ChatError({message:"system message cannot be revoked"});if(n)throw new this._core.helper.ChatError({message:"message has been revoked",moreMessage:u});try{if(c="C2C"===s?yield this._c2cMessageAction.revokeMessage(e):yield this._groupMessageAction.revokeMessage(e),c){const{RecallRetList:s}=c,n=(null===(t=null==s?void 0:s[0])||void 0===t?void 0:t.RetCode)||0;if(0!==n)throw new this._core.helper.ChatError({code:n,moreMessage:u});return e.isRevoked=!0,yield this._handleRevokeMessageSuccess(e),{code:0,data:{message:e},successLog:{message:u}}}}catch(e){const{errorCode:t}=e;throw new this._core.helper.ChatError({functionName:"revokeMessage",code:t,moreMessage:u})}})}},{key:"resendMessage",value:function resendMessage(e,t){return pe(this,void 0,void 0,function*(){var s,n;return e.isResend=!0,e.status="unSend",null===(n=null===(s=this._core)||void 0===s?void 0:s.apiMap)||void 0===n?void 0:n.sendMessage(e,t)})}},{key:"findMessage",value:function findMessage(e){return this._core.message.messageDataHandler.findMessage(e)}},{key:"createQuoteMessage",value:function createQuoteMessage(e,t){const{ID:s,time:n,sequence:o}=t;return e.quoteInfo={msgID:s,messageTime:n,messageSequence:o},e}},{key:"_handleDeleteMessageSuccess",value:function _handleDeleteMessageSuccess(e){if(0===e.length)return;const{message:{messageDataHandler:t},common:{isTopic:s},notificationCenter:n,InnerEvent:o}=this._core;e.forEach(e=>{e.isDeleted=!0;const s=t.getLocalMessageList(e.conversationID);null==s||s.forEach(t=>{t.ID===e.ID&&(t.isDeleted=!0)})});const{conversationID:i=""}=e[0];s(i)?n.emitInnerEvent(o.TOPIC_MESSAGE_DELETED,i):n.emitInnerEvent(o.MESSAGE_DELETED,i)}},{key:"_handleRevokeMessageSuccess",value:function _handleRevokeMessageSuccess(e){return pe(this,void 0,void 0,function*(){var t;const s=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,{conversationID:n,sequence:o,random:i}=e;this._core.message.messageDataHandler.revokeMessage({conversationID:n,sequence:o,random:i,revoker:s}),yield this._messageHelper.updateRevokerInfo([e])})}}])}());let vi=function(){function vi(e){_classCallCheck(this,vi),this.type=Po.MSG_FACE;const{index:t,data:s}=e;this.content={index:t,data:s}}return _createClass(vi,[{key:"validateBeforeSend",value:function validateBeforeSend(){var e,t;return"number"==typeof(null===(e=this.content)||void 0===e?void 0:e.index)&&"string"==typeof(null===(t=this.content)||void 0===t?void 0:t.data)?{isValid:!0}:{isValid:!1,error:{message:"content is invalid"}}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{index:n,data:o}=s;return{MsgType:this.type,MsgContent:{Index:n,Data:o}}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t={}}=e,{Index:s,Data:n}=t;return new vi({index:s,data:n})}}])}(),fi=function(){function fi(e){_classCallCheck(this,fi),this.type=Po.MSG_LOCATION;const{description:t,longitude:s,latitude:n}=e;this.content={description:t,longitude:s,latitude:n}}return _createClass(fi,[{key:"validateBeforeSend",value:function validateBeforeSend(){return{isValid:!0}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{description:n,longitude:o,latitude:i}=s;return{MsgType:this.type,MsgContent:{Desc:n,Longitude:o,Latitude:i}}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t={}}=e,{Desc:s,Longitude:n,Latitude:o}=t;return new fi({description:s,longitude:n,latitude:o})}}])}(),Ii=function(){function Ii(e){_classCallCheck(this,Ii),this.type=Po.MSG_STREAM,this.content={streamMessageID:"",compatibleText:"",errorCode:0,errorMessage:"",isStreamEnded:!1},this._chunks=[],this._latestIndex=0;const{streamMessageID:t,compatibleText:s,markdown:n,binaryData:o,errorCode:i=0,errorMessage:r="",isStreamEnded:a=!1,chunks:c=[],latestIndex:u=0}=e;this.content.streamMessageID=t,this.content.compatibleText=s,this.content.markdown=n,this.content.binaryData=o,this.content.errorCode=i,this.content.errorMessage=r,this.content.isStreamEnded=a,this.content.chunks=c,this.content.latestIndex=u}return _createClass(Ii,[{key:"updateChunks",value:function updateChunks(e){if(!e||0===e.length)return;const t=e.sort((e,t)=>e.index-t.index),s=this._getMaxRevokedChunkIndex(t);s>=0&&(this._chunks=[],this._latestIndex=s,this._updateContent());const n=this._getValidChunks(t);if(0!==n.length&&(this._mergeAndSortChunks(n),this._chunks.length>0)){const e=this._chunks[this._chunks.length-1];this._latestIndex=e.index,this._updateContent(),this.content.isStreamEnded=e.isLast}}},{key:"getLatestIndex",value:function getLatestIndex(){return this._latestIndex}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{streamMessageID:n,chunks:o}=s,i=null==o?void 0:o.map(e=>({EventType:e.eventType||"data",Index:e.index,Markdown:e.markdown,IsLast:e.isLast}));return{MsgType:this.type,MsgContent:{StreamMsgID:n,Chunks:i}}}},{key:"validateBeforeSend",value:function validateBeforeSend(){var e,t;return(null===(t=null===(e=this.content)||void 0===e?void 0:e.chunks)||void 0===t?void 0:t.length)>0?{isValid:!0}:{isValid:!1,error:{message:"content is invalid"}}}},{key:"_filterContinuousChunks",value:function _filterContinuousChunks(e,t){if(0===e.length)return[];const s=[];let n=t;for(const t of e){if(t.index>n)break;t.index===n&&(s.push(t),n++)}return s}},{key:"_mergeAndSortChunks",value:function _mergeAndSortChunks(e){const t=new Map;this._chunks.forEach(e=>{t.set(e.index,e)}),e.forEach(e=>{t.set(e.index,e)}),this._chunks=Array.from(t.values()).sort((e,t)=>e.index-t.index)}},{key:"_updateContent",value:function _updateContent(){this.content.markdown=this._chunks.map(e=>e.markdown).join("");const e=this._chunks.map(e=>e.binaryData).filter(e=>(null==e?void 0:e.length)>0);if(0===e.length)this.content.binaryData=new Uint8Array(0);else if(1===e.length)this.content.binaryData=e[0];else{const t=e.reduce((e,t)=>e+t.length,0),s=new Uint8Array(t);let n=0;for(const t of e)s.set(t,n),n+=t.length;this.content.binaryData=s}}},{key:"_getMaxRevokedChunkIndex",value:function _getMaxRevokedChunkIndex(e){let t=-1;for(let s=0;s<e.length;s++){const n=e[s];n.eventType===ei.REVOKED&&n.index>t&&(t=n.index)}return t}},{key:"_getValidChunks",value:function _getValidChunks(e){const t=e.filter(e=>e.eventType===ei.DATA&&e.index>this._latestIndex);return this._filterContinuousChunks(t,this._latestIndex+1)}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t={}}=e,{StreamMsgID:s,CompatibleText:n,Markdown:o,BinaryData:i,ErrorCode:r,ErrorMsg:a}=t;return new Ii({streamMessageID:s,compatibleText:n,markdown:o,binaryData:i,errorCode:r,errorMessage:a})}}])}();var Ei=new(function(){return _createClass(function _class31(){_classCallCheck(this,_class31)},[{key:"init",value:function init(e){this._core=e,e.message.messageFactory.registerElementClass(Po.MSG_FACE,vi),e.message.messageFactory.registerElementClass(Po.MSG_LOCATION,fi),e.message.messageFactory.registerElementClass(Po.MSG_STREAM,Ii),e.helper.registerApi({apiName:"createFaceMessage",context:this}),e.helper.registerApi({apiName:"createTextAtMessage",context:this}),e.helper.registerApi({apiName:"createForwardMessage",context:this}),e.helper.registerApi({apiName:"createLocationMessage",context:this})}},{key:"createFaceMessage",value:function createFaceMessage(e){if(!e)return null;const{index:t,data:s}=(null==e?void 0:e.payload)||{},n=new vi({index:t,data:s}),o=this._core.common.getCurrentUserID(),i=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:o}));return i.setElement(n),i}},{key:"createTextAtMessage",value:function createTextAtMessage(e){const{atUserList:t}=(null==e?void 0:e.payload)||{},s=this._core.apiMap.createTextMessage(e),{OuterConstant:n}=this._core;if(!s)return null;if(Array.isArray(t)){const e=[],o=[];t.forEach(t=>{t!==n.MSG_AT_ALL?(e.push({GroupAtAllFlag:0,GroupAt_Account:t}),o.push(t)):(e.push({GroupAtAllFlag:1}),o.push(n.MSG_AT_ALL))}),s._groupAtInfoList=e,s.atUserList=o}return s}},{key:"createForwardMessage",value:function createForwardMessage(e){const{helper:t,OuterConstant:s}=this._core,{to:n,conversationType:o,priority:i,payload:r,needReadReceipt:a,receiverList:c,cloudCustomData:u="",isSupportExtension:l=!1}=e;if(!Array.isArray(r._elements))throw new t.ChatError({functionName:"createForwardMessage",code:2454});if(r.type===s.MSG_GRP_TIP)throw new t.ChatError({functionName:"createForwardMessage",code:2453});const d=this._core.common.getCurrentUserID(),h=this._core.message.messageFactory.createMessage({to:n,from:d,conversationType:o,isPlaceMessage:0,priority:i,payload:r,needReadReceipt:a,isSupportExtension:l,cloudCustomData:u,receiverList:c});return h.setRelayFlag(!0),h.setElement(r._elements[0]),h}},{key:"createLocationMessage",value:function createLocationMessage(e){if(!e)return null;const{description:t,longitude:s,latitude:n}=(null==e?void 0:e.payload)||{},o=new fi({description:t,longitude:s,latitude:n}),i=this._core.common.getCurrentUserID(),r=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:i}));return r.setElement(o),r}}])}());let Si=function(){return _createClass(function Si(){_classCallCheck(this,Si)},[{key:"init",value:function init(e){this._messageHelper=new _i(e),this._core=e;const{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s},InnerEventSubType:{C2C_REVOKED_MESSAGE:n},helper:{registerWorkflowStep:o},constants:{WORKFLOW_NAME:i,WORKFLOW_STEP:r}}=e;t.subscribeInnerEvent(s,n,this._handleC2CNotifyMessage,this),o(i.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.HANDLE_C2C_REVOKED_MESSAGE_FROM_SYNC_UNREAD,this._handleC2CRevokeMessagesFromUnreadMessageSync,this)}},{key:"_handleC2CNotifyMessage",value:function _handleC2CNotifyMessage(e){const{C2cNotifyMsgArray:t}=e;null==t||t.forEach(e=>{Object.keys(e).includes("WithdrawC2cMsgNotify")&&this._handleC2CRevokeMessage(e)})}},{key:"_handleC2CRevokeMessage",value:function _handleC2CRevokeMessage(e){return pe(this,void 0,void 0,function*(){try{const{WithdrawC2cMsgNotify:{C2cWithdrawInfoArray:t}}=e;yield this._parseAndEmitC2CRevokedMessages(t)}catch(e){console.debug(e)}})}},{key:"_parseAndEmitC2CRevokedMessages",value:function _parseAndEmitC2CRevokedMessages(e){return pe(this,void 0,void 0,function*(){const t=[],{notificationCenter:s,OuterEvent:n,common:{getCurrentUserID:o}}=this._core;e.forEach(e=>{var s;const{MsgRand:n,MsgSeq:i,To_Account:r,From_Account:a,RevokerInfo:{Revoker_Account:c,Revoke_Reason:u}}=e,l=o()===a?`C2C${r}`:`C2C${a}`,d=(null===(s=null==e?void 0:e.RevokerInfo)||void 0===s?void 0:s.Reason)||u,h=this._messageHelper.generateRevokeMessage({conversationID:l,sequence:i,random:n,revoker:c,revokeReason:d});t.push(h)}),t.length>0&&(yield this._messageHelper.updateRevokerInfo(t),s.emitOuterEvent(n.MESSAGE_REVOKED,{name:n.MESSAGE_REVOKED,data:t}))})}},{key:"_handleC2CRevokeMessagesFromUnreadMessageSync",value:function _handleC2CRevokeMessagesFromUnreadMessageSync(e){return pe(this,void 0,void 0,function*(){const{revokedMessageList:t}=e.result;yield this._parseAndEmitC2CRevokedMessages(t)})}},{key:"dispose",value:function dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{C2C_REVOKED_MESSAGE:s}}=this._core;e.unSubscribeInnerEvent(t,s,this._handleC2CNotifyMessage,this)}}])}(),Ci=function(){return _createClass(function Ci(){_classCallCheck(this,Ci)},[{key:"init",value:function init(e){this._messageHelper=new _i(e),this._core=e;const{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s},InnerEventSubType:{GROUP_MESSAGE_REVOKED:n}}=e;t.subscribeInnerEvent(s,n,this._handleGroupNotifyMessage,this)}},{key:"_handleGroupNotifyMessage",value:function _handleGroupNotifyMessage(e){const{GroupTips:t}=e;null==t||t.forEach(e=>{var t;Array.isArray(null===(t=null==e?void 0:e.MsgBody)||void 0===t?void 0:t.GroupWithdrawInfoArray)&&this._handleGroupRevokeMessage(e)})}},{key:"_handleGroupRevokeMessage",value:function _handleGroupRevokeMessage(e){return pe(this,void 0,void 0,function*(){try{const{RevokerInfo:t,MsgBody:{GroupWithdrawInfoArray:s},GroupInfo:n}=e,o=[],i=[],{notificationCenter:r,OuterEvent:a,utils:{isEmpty:c},common:{isCommunity:u}}=this._core;let l=!1;n&&(l=u({groupID:n.GroupId})||!c(n.TopicId)),s.forEach(e=>{const{Random:s,MsgSeq:r,GroupId:a,MsgClientTime:c,TinyId:u,TopicId:d,RevokerInfo:{Revoker_Account:h=(null==t?void 0:t.Revoker_Account)||"",Reason:g=(null==t?void 0:t.Reason)||""}}=e,p=d?`GROUP${d}`:`GROUP${a}`,_=this._messageHelper.generateRevokeMessage({conversationID:p,sequence:r,random:s,tinyID:u,clientTime:c,revoker:h,revokeReason:g});l?(_.revokerInfo.nick=n.From_AccountNick,_.revokerInfo.avatar=n.From_AccountHeadurl,o.push(_)):i.push(_)}),i.length>0&&(yield this._messageHelper.updateRevokerInfo(i),o.push(...i)),0!==o.length&&r.emitOuterEvent(a.MESSAGE_REVOKED,{name:a.MESSAGE_REVOKED,data:o})}catch(e){console.debug(e)}})}},{key:"dispose",value:function dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t},InnerEventSubType:{GROUP_MESSAGE_REVOKED:s}}=this._core;e.unSubscribeInnerEvent(t,s,this._handleGroupNotifyMessage,this)}}])}();var Mi=new(function(){return _createClass(function _class32(){_classCallCheck(this,_class32),this._c2cMessageReceiver=new Si,this._groupMessageReceiver=new Ci},[{key:"init",value:function init(e){this._c2cMessageReceiver.init(e),this._groupMessageReceiver.init(e)}},{key:"dispose",value:function dispose(){this._c2cMessageReceiver.dispose(),this._groupMessageReceiver.dispose()}}])}()),yi=new(function(){return _createClass(function _class33(){_classCallCheck(this,_class33),this._core=null},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"translateText",context:this})}},{key:"translateText",value:function translateText(e){return pe(this,void 0,void 0,function*(){try{const{sourceLanguage:t,sourceTextList:s,targetLanguage:n}=e,o=yield function(e,t){return pe(this,void 0,void 0,function*(){var s,n;const{sourceTextList:o,sourceLanguage:i,targetLanguage:r}=e,{store:a,common:c}=t,u={SourceText:o,Source:i,Target:r,FromAccount:null===(s=a.get("login"))||void 0===s?void 0:s.tinyID,SDKAppID:null===(n=a.get("instance"))||void 0===n?void 0:n.sdkAppId},l=yield c.buildAndSendPacket({servcmd:"im_open_translate.ws_batch_trans_text",data:u});if(l){const{CmdErrorCode:e,TargetText:t}=l;return{cmdErrorCode:e,translatedTextList:t}}})}({sourceLanguage:t,sourceTextList:s,targetLanguage:n},this._core);if(o){const{cmdErrorCode:{ErrorCode:e,ErrorInfo:t},translatedTextList:s}=o;if(0===e)return{code:0,data:{translatedTextList:s}};throw{errorCode:e,errorInfo:t,message:t}}}catch(e){const{errorCode:t,errorInfo:s}=e||{};throw new this._core.helper.ChatError({functionName:"translateText",code:t,message:s})}})}}])}()),Oi=new(function(){return _createClass(function _class34(){_classCallCheck(this,_class34)},[{key:"init",value:function init(e){this._core=e,e.helper.registerApi({apiName:"convertVoiceToText",context:this})}},{key:"convertVoiceToText",value:function convertVoiceToText(e){return pe(this,void 0,void 0,function*(){var t;const{message:s,language:n=$o.ZH_PY}=e;let{url:o}=s.payload||{};const i=this._core.common.getCurrentUserID();s.from===i&&"out"===s.flow&&(o=s.payload.remoteAudioUrl),this._validateVoiceFormat(o);const r=(null===(t=Ko.exec(o))||void 0===t?void 0:t[1])||"mp3",a=Ho[n]||jo;try{const e=yield function(e){var t;const{store:s,common:n}=Do.core,{url:o,format:i,serverLanguageType:r}=e,a={BytesUrl:o,BytesEngServiceType:r,BytesVoiceFormat:i,Uint32Sdkappid:null===(t=s.get("instance"))||void 0===t?void 0:t.sdkAppId,Uint64SourceType:0};return n.buildAndSendPacket({servcmd:"im_open_speech.ws_sentence_recognition",data:a})}({url:o,format:r,serverLanguageType:a});if(e){const{CmdErrorCode:t,BytesResult:s}=e;if(0===t.ErrorCode)return{code:0,data:{result:s}};throw{code:t.ErrorCode,message:t.ErrorInfo}}}catch(e){const{code:t,message:s}=e||{};throw new this._core.common.ChatError({functionName:"convertVoiceToText",code:t,message:s})}})}},{key:"_validateVoiceFormat",value:function _validateVoiceFormat(e){if(!Ko.test(e))throw new this._core.common.ChatError({code:2119})}}])}());let Ai=function(){return _createClass(function Ai(e){_classCallCheck(this,Ai);const{constants:t,common:s,utils:n}=Do.core,{CONV_C2C:o,CONV_GROUP:i}=t.OuterConstant,{ID:r,tinyID:a,from:c,to:u,clientTime:l=s.timeManager.getServerTimeSeconds()||0,random:d,sequence:h,cloudCustomData:g="",nick:p="",avatar:_="",clientSequence:m,conversationType:v,groupID:f,_elements:I,time:E}=e;this.ID=r||`${a}-${l}-${d}`,this.messageRandom=d,this.from=c,this.messageSender=c,this.time=E,this.messageSequence=h,this.clientSequence=m||h,this.clientTime=l,this.cloudCustomData=g,this.messageReceiver=u,this.avatar=_,this.nick=p;const S=n.deepCopyWithMethods(I);S.forEach(e=>{e.payload=e.content,delete e.content}),this.messageBody=S,r?v.startsWith(o)?this.receiverUserID=u:v.startsWith(i)&&(this.receiverGroupID=u):f?(this.receiverGroupID=f,this.messageReceiver=f):u&&(this.receiverUserID=u,this.messageReceiver=u)},[{key:"transformElementsToServerFormat",value:function transformElementsToServerFormat(){return this.messageBody?Array.isArray(this.messageBody)?this.messageBody.map(e=>e.transformToServerFormat({isMergerMessage:!0})):this.messageBody.transformToServerFormat({isMergerMessage:!0}):null}}])}(),Ti=function(){function Ti(e){_classCallCheck(this,Ti),this.type=Do.core.constants.OuterConstant.MSG_MERGER;const{messageList:t,title:s,abstractList:n,compatibleText:o,pbDownloadKey:i="",downloadKey:r="",version:a=0,layersOverLimit:c=!1}=e,u=[];t.forEach(e=>{if(e){const t=new Ai(e);u.push(t)}}),this.content={messageList:u,title:s,abstractList:n,compatibleText:o,version:a,downloadKey:r,pbDownloadKey:i,layersOverLimit:c}}return _createClass(Ti,[{key:"validateBeforeSend",value:function validateBeforeSend(){const{isEmpty:e}=Do.core.helper;return e(this.content.messageList)?{isValid:!1,error:{message:"content is invalid"}}:{isValid:!0}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{abstractList:n,compatibleText:o,downloadKey:i,layersOverLimit:r,pbDownloadKey:a,title:c,version:u,messageList:l}=s;return{MsgType:this.type,MsgContent:{AbstractList:n,CompatibleText:o,JsonMsgKey:i,LayersOverLimit:r,PbMsgKey:a,Title:c,Version:u,MsgList:No(l)}}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t}=e,{MsgList:s=[],CompatibleText:n,AbstractList:o,Title:i,PbMsgKey:r,JsonMsgKey:a}=t||{},c=s.map(e=>Lo(e));return new Ti({messageList:c,title:i,abstractList:o,compatibleText:n,pbDownloadKey:r,downloadKey:a})}}])}();var Ri=new(function(){return _createClass(function _class35(){_classCallCheck(this,_class35)},[{key:"init",value:function init(e){this._core=e;const{message:t,helper:s,constants:{OuterConstant:n}}=e;t.messageFactory.registerElementClass(n.MSG_MERGER,Ti),s.registerApi({apiName:"createMergerMessage",context:this}),s.registerApi({apiName:"sendMessage",context:this,matcher:e=>e[0].type===n.MSG_MERGER}),s.registerApi({apiName:"downloadMergerMessage",context:this})}},{key:"createMergerMessage",value:function createMergerMessage(e){const{common:t}=this._core;if(!e)return null;const s=new Ti(e.payload),n=t.getCurrentUserID(),o=this._core.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:n}));return o.setRelayFlag(!0),o.setElement(s),o}},{key:"sendMessage",value:function sendMessage(e,t){return pe(this,void 0,void 0,function*(){var s,n,o;try{const i=function(e){let t="utf-8";Do.core.helper.IN_BROWSER&&document&&(t=document.charset.toLowerCase());let s,n=0,o=0;if(o=e.length,"utf-8"===t||"utf8"===t)for(let t=0;t<o;t++)s=e.codePointAt(t),s<=127?n+=1:s<=2047?n+=2:s<=65535?n+=3:(n+=4,t++);else if("utf-16"===t||"utf16"===t)for(let t=0;t<o;t++)s=e.codePointAt(t),s<=65535?n+=2:(n+=4,t++);else n=e.replace(/[^\x00-\xff]/g,"aa").length;return n}(JSON.stringify(e));let r=e,a=null;if(i>11264){r=this._core.utils.deepCopyWithMethods(e);try{const{JsonMsgKey:e,PbMsgKey:t}=yield function(e){return pe(this,void 0,void 0,function*(){const{payload:{messageList:t}}=e,s={MsgList:No(t)};return Do.core.common.buildAndSendPacket({servcmd:"im_long_msg.save_relay_json_msg",data:s})})}(r),{payload:s}=r;a=new Ti(Object.assign(Object.assign({},s),{messageList:[],downloadKey:e,pbDownloadKey:t})),r.setElement(a)}catch(e){console.error(e)}}const{data:{message:c}}=yield null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageSender)||void 0===o?void 0:o.sendMessage(r,t);return a&&c.setElement(e._elements),{code:0,data:{message:c}}}catch(e){const{errorCode:t}=e;throw new this._core.helper.ChatError({code:t})}})}},{key:"downloadMergerMessage",value:function downloadMergerMessage(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,s=e.payload,{downloadKey:n,pbDownload:o,type:i,messageList:r}=s,a=ge(s,["downloadKey","pbDownload","type","messageList"]);try{const s=yield function(e){return pe(this,void 0,void 0,function*(){return Do.core.common.buildAndSendPacket({servcmd:"im_long_msg.get_relay_json_msg",data:{JsonMsgKey:e}})})}(n),{MsgList:o}=s||{},i=null==o?void 0:o.map(e=>{const t=Lo(e);return new Ai(t)});return"function"==typeof e.isOnlineMessage?e.setElement({type:e.type,content:Object.assign({messageList:i},a)}):(e.payload.messageList=i,e.payload.downloadKey="",e.payload.pbDownloadKey=""),t.info("downloadMergerMessage",` success downloadKey:${n}`),e}catch(e){const{errorCode:t}=e;throw new this._core.helper.ChatError({functionName:"downloadMergerMessage",code:t,moreMessage:n})}})}}])}()),Di=new(function(){return _createClass(function _class36(){_classCallCheck(this,_class36)},[{key:"init",value:function init(e){this._core=e,this._core.helper.registerExperimentalAPI("sendComboMessage",this)}},{key:"sendComboMessage",value:function sendComboMessage(e){return pe(this,void 0,void 0,function*(){const{appStore:t,message:s,common:{getCurrentUserID:n},utils:{isArray:o}}=this._core,{GroupId:i,To_Account:r}=e;e.From_Account=e.From_Account||n();let a=null;if(i){a=this._generateGroupMessage(Object.assign(Object.assign({},e),{ToGroupId:i}));const s=t.userStore.getUserProfile(n());a.level=(null==s?void 0:s.level)||0,o(r)&&r.length>0&&(a._receiverList=r)}else r&&(a=this._generateC2CMessage(e));return s.messageSender.sendMessage(a,e)})}},{key:"_generateC2CMessage",value:function _generateC2CMessage(e){const{message:t,OuterConstant:{CONV_C2C:s}}=this._core,n=s,o=t.messageHelper.parseServerPushMessage(e),i=t.messageFactory.createMessage(Object.assign(Object.assign({},o),{conversationType:n,flow:Qo.OUT})),{elements:r}=o;return i.setElement(r),i}},{key:"_generateGroupMessage",value:function _generateGroupMessage(e){const{message:t,OuterConstant:{CONV_GROUP:s}}=this._core,n=s,o=t.messageHelper.parseServerGroupMessage(e),i=t.messageFactory.createMessage(Object.assign(Object.assign({},o),{conversationType:n,flow:Qo.OUT})),{elements:r}=o;return i.setElement(r),i}}])}()),bi=new(function(){return _createClass(function _class37(){_classCallCheck(this,_class37)},[{key:"init",value:function init(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:{MESSAGE_PUSH:n},InnerEventSubType:{GROUP_MESSAGE_PINNED:o}}=e;s.subscribeInnerEvent(n,o,this._handleGroupMessagePinned,this),t.registerApi({apiName:"pinGroupMessage",context:this}),t.registerApi({apiName:"getPinnedGroupMessageList",context:this})}},{key:"pinGroupMessage",value:function pinGroupMessage(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,common:{isTopic:s},OuterConstant:{GROUP_ID_PREFIX:n},helper:{ChatError:o}}=this._core;let{groupID:i,message:r,isPinned:a}=e;const{sequence:c}=r;try{return yield function(e){return pe(this,void 0,void 0,function*(){const{common:{buildAndSendPacket:t,getCurrentUserID:s}}=Do.core,{groupID:n,sequence:o,isPinned:i}=e,r=s(),a=i?"group_open_http_svc.pin_message":"group_open_http_svc.unpin_message",c={GroupId:n,MsgSeq:o};return i?c.Pinner_Account=r:c.UnPinner_Account=r,t({servcmd:a,data:c})})}({groupID:i,sequence:c,isPinned:a}),{code:0,data:{}}}catch(e){const{errorCode:t,errorInfo:s}=e||{};throw new o({code:t,message:s})}})}},{key:"getPinnedGroupMessageList",value:function getPinnedGroupMessageList(e){return pe(this,void 0,void 0,function*(){let t=[];try{const s=yield function(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{common:{buildAndSendPacket:s}}=Do.core;return s({servcmd:"group_open_http_svc.get_pinned_messages",data:{GroupId:t}})})}({groupID:e});if(s){const{PinnedMsgList:n=[]}=s;t=yield this._updatePinnedMessageInfo({serverPinnedMessageList:n,groupID:e})}return{code:0,data:{messageList:t}}}catch(e){throw e}})}},{key:"_handleGroupMessagePinned",value:function _handleGroupMessagePinned(e){const{message:{messageHelper:t,messageFactory:s},notificationCenter:n,OuterEvent:o,OuterConstant:i}=this._core;e.GroupTips.forEach(e=>{const{ToGroupId:r,MsgBody:{PinnedMsg:a,OpType:c,MsgOperatorMemberExtraInfo:u,SdkGroupMessageId:l}}=e,{UserId:d,NickName:h="",ImageUrl:g=""}=u;let p=null,_=!1;if(16===c){_=!0;const e=t.parseServerGroupMessage(a);p=s.createMessage(Object.assign(Object.assign({},e),{conversationType:i.CONV_GROUP,flow:"in"})),p.setElement(e.elements),p.pinnerInfo={userID:d,nick:h,avatar:g}}else if(17===c){const{ClientTime:e,Random:t,SenderTinyId:s,ServerTime:n,MsgSeq:o}=l;p={ID:`${s}-${e}-${t}`,sequence:o,random:t,time:n,clientTime:e}}p&&n.emitOuterEvent(o.PINNED_GROUP_MESSAGE_UPDATED,{name:o.PINNED_GROUP_MESSAGE_UPDATED,data:{groupID:r,message:p,isPinned:_,operatorInfo:{userID:d,nick:h,avatar:g}}})})}},{key:"_findMessageBySequence",value:function _findMessageBySequence(e,t){const{message:{messageDataHandler:s}}=this._core;return[...s.getLocalMessageList(e),...s.getSparseMessageList(e)].find(e=>e.sequence===t)}},{key:"_updatePinnedMessageInfo",value:function _updatePinnedMessageInfo(e){return pe(this,arguments,void 0,function*({serverPinnedMessageList:e,groupID:t}){const{OuterConstant:{CONV_GROUP:s},utils:{isEmpty:n}}=this._core,o=[],i=[],r=[],a=new Map,c=`${s}${t}`;for(let t=0;t<e.length;t++){const s=e[t],{Pinner_Account:n,MsgSeq:u}=s,l=this._findMessageBySequence(c,u);i.push(n),a.set(u,n),l?o.push(l):r.push(u)}const u=yield this._fetchPinnedMessageInfo({conversationID:c,messageSequenceList:r,pinnerIDList:i});if(u){const{pinnerInfoMap:e,messageList:t}=u;return o.push(...t),o.forEach(t=>{const{sequence:s}=t,n=a.get(s),o=e[n]||{userID:n,nick:"",avatar:""};t.pinnerInfo=o}),o.sort((e,t)=>e.sequence-t.sequence),o}return[]})}},{key:"_fetchPinnedMessageInfo",value:function _fetchPinnedMessageInfo(e){return pe(this,void 0,void 0,function*(){var t,s;const{message:{messageHistory:n},user:{userProfile:o},utils:{isArray:i}}=this._core,{conversationID:r,messageSequenceList:a,pinnerIDList:c}=e,u=yield Promise.all([this._fetchMessageBySequence({conversationID:r,messageSequenceList:a}),null==o?void 0:o.getUserProfile({userIDList:c})]);if(i(u)){const e={};return((null===(t=u[1])||void 0===t?void 0:t.data)||[]).forEach(t=>{const{userID:s,nick:n="",avatar:o=""}=t;e[s]={userID:s,nick:n,avatar:o}}),{messageList:(null===(s=u[0])||void 0===s?void 0:s.messageList)||[],pinnerInfoMap:e}}})}},{key:"_fetchMessageBySequence",value:function _fetchMessageBySequence(e){return pe(this,void 0,void 0,function*(){const{utils:{isEmpty:t},message:{messageHistory:s}}=this._core,{conversationID:n,messageSequenceList:o}=e;return t(o)?[]:s.getGroupRoamingMessagesByAnchor({conversationID:n,messageSequenceList:o,getType:3})})}}])}());let Ni=_createClass(function Ni(e){_classCallCheck(this,Ni),this.eventType=ei.DATA,this.index=0,this.markdown="",this.isLast=!1,this.binaryData=null;const{EventType:t,Index:s,Markdown:n,IsLast:o,BinaryData:i}=e;this.eventType=t,this.index=s,this.markdown=n,this.isLast=o,this.binaryData=i});var Li=new(function(){return _createClass(function _class38(){_classCallCheck(this,_class38),this._messageMap=new Map,this._retryCountMap=new Map},[{key:"init",value:function init(e){this._core=e;const{notificationCenter:t,OuterEvent:{MESSAGE_RECEIVED:s},InnerEvent:{HISTORY_MESSAGE_FETCHED:n},common:{workflowManager:o},constants:{WORKFLOW_NAME:i,WORKFLOW_STEP:r}}=e;t.subscribeInnerEvent(si,this._handleStreamMessageChunkPush,this),t.subscribeOuterEvent(s,this._handleMessageReceived,this),t.subscribeInnerEvent(n,this.processHistoryMessage,this),o.registerWorkflowStep(i.SYNC_SERVER_INFO_AFTER_RE_ONLINE,r.STREAM_MESSAGE_RECOVER,this._recoverStreamMessage,this)}},{key:"processHistoryMessage",value:function processHistoryMessage(e){const{utils:{isEmpty:t,safeStringify:s},ssoLog:n}=this._core;try{null==e||e.forEach(e=>{var s;if(this._isValidStreamMessage(e)){const n=null===(s=null==e?void 0:e._elements)||void 0===s?void 0:s[0],{streamMessageID:o,markdown:i,binaryData:r}=(null==n?void 0:n.content)||{};t(i)&&t(r)?(this._messageMap.set(o,e),this._fetchStreamMessageChunks(e)):n.content.isStreamEnded=!0}})}catch(e){n.error("processHistoryMessage.error",s(e))}}},{key:"_handleMessageReceived",value:function _handleMessageReceived(e){const t=e.data;null==t||t.forEach(e=>{var t,s;if(this._isValidStreamMessage(e)){const{streamMessageID:n}=(null===(s=null===(t=null==e?void 0:e._elements)||void 0===t?void 0:t[0])||void 0===s?void 0:s.content)||{};n&&(this._messageMap.set(n,e),this._fetchStreamMessageChunks(e))}})}},{key:"_isValidStreamMessage",value:function _isValidStreamMessage(e){var t,s;const{utils:{isEmpty:n}}=this._core,{streamMessageID:o}=(null===(s=null===(t=null==e?void 0:e._elements)||void 0===t?void 0:t[0])||void 0===s?void 0:s.content)||{};return e.type===Po.MSG_STREAM&&!n(o)}},{key:"_fetchStreamMessageChunks",value:function _fetchStreamMessageChunks(e){return pe(this,void 0,void 0,function*(){var t,s;const{constants:{ERROR_CODE:n},ssoLog:o,utils:{safeStringify:i}}=this._core,r=null===(t=e._elements)||void 0===t?void 0:t[0],a=null===(s=null==r?void 0:r.content)||void 0===s?void 0:s.streamMessageID;try{const{from:t,to:s}=e,n=r.getLatestIndex();if(r.content.isStreamEnded)return;const o=yield function(e){return pe(this,void 0,void 0,function*(){const{from:t,to:s,streamMessageID:n,index:o}=e,i={From_Account:t,To_Account:s,StreamMsgID:n,AckIndex:o};return Do.core.common.buildAndSendPacket({servcmd:"StreamMsg.GetStreamHttp",data:i,timeout:5e3})})}({from:t,to:s,streamMessageID:a,index:n});if(o){const{ErrorCode:e,ErrorInfo:t}=o;if(0!==e)throw r.content.errorCode=e,r.content.errorMessage=t,{errorCode:e,errorMessage:t}}}catch(t){if(t.errorCode===n.NETWORK_TIMEOUT&&this._shouldRetryFetch(a)){const s=this._retryCountMap.get(a)||0;o.debug("_fetchStreamMessageChunks.timeout",`error: ${i(t)} retried: ${s}`),this._retryCountMap.set(a,s+1),this._fetchStreamMessageChunks(e)}else o.error("_fetchStreamMessageChunks.error",i(t))}})}},{key:"_shouldRetryFetch",value:function _shouldRetryFetch(e){const{utils:{isNumber:t}}=this._core;if(!this._retryCountMap.has(e))return this._retryCountMap.set(e,1),!0;const s=this._retryCountMap.get(e);return!!(t(s)&&s<=3)}},{key:"_onStreamEnded",value:function _onStreamEnded(e,t,s){const{ssoLog:n}=this._core;s.content.isStreamEnded=!0,s.stopReason=t,this._messageMap.delete(e),n.debug("_onStreamEnded",`streamMessage end, StopReason: ${t}`)}},{key:"_handleStreamMessageChunkPush",value:function _handleStreamMessageChunkPush(e){var t;const{ssoLog:s}=this._core,{StopReason:n,Chunks:o,StreamID:i}=(null==e?void 0:e.body)||{},r=this._messageMap.get(i);if(!r)return void s.warn(`_handleStreamMessageChunkPush, unfounded message: ${i}`);const a=null===(t=r._elements)||void 0===t?void 0:t[0];if(a&&this._validateExpectedChunk(a,o)){if(o.length>0){const e=o.map(e=>new Ni(e));a.updateChunks(e)}this._emitMessageModify(r),function(e,t){pe(this,void 0,void 0,function*(){const{common:{generateProtocolData:s},utils:{safeStringify:n},ssoLog:o,channel:i}=Do.core,r={StreamMsgID:e,AckIndex:t};try{const e=s({servcmd:"StreamMsg.AckHttp",data:r});i.sendPacket(e)}catch(e){o.debug("sendStreamChunkAck",n(e))}})}(i,a.getLatestIndex()),a.content.isStreamEnded&&this._onStreamEnded(i,n,a)}}},{key:"_emitMessageModify",value:function _emitMessageModify(e){const{notificationCenter:t,OuterEvent:{MESSAGE_MODIFIED:s}}=this._core;t.emitOuterEvent(s,{name:s,data:[e]})}},{key:"_validateExpectedChunk",value:function _validateExpectedChunk(e,t){const s=e.getLatestIndex()+1;let n=!1;for(let e=0;e<t.length;e++)if(t[e].Index===s){n=!0;break}if(!n){const{ssoLog:e}=this._core;return e.debug("_handleStreamMessageChunkPush",`Ignore push, expected index: ${s}, received: [${t.map(e=>e.Index).join(", ")}]`),!1}return!0}},{key:"_recoverStreamMessage",value:function _recoverStreamMessage(){this._retryCountMap.clear();const{ssoLog:e,utils:{safeStringify:t}}=this._core;try{const t=Array.from(this._messageMap.entries());for(let s=Math.max(0,t.length-300);s<t.length;s++){const n=t[s][0],o=t[s][1];!1===o.payload.isStreamEnded&&(e.debug("_recoverStreamMessage",`recover unfinished stream: ${n}`),this._fetchStreamMessageChunks(o))}}catch(s){e.error("_recoverStreamMessage.error",t(s))}}},{key:"reset",value:function reset(){this._messageMap.clear(),this._retryCountMap.clear()}},{key:"dispose",value:function dispose(){const{notificationCenter:e,OuterEvent:{MESSAGE_RECEIVED:t}}=this._core;this.reset(),e.unSubscribeInnerEvent(si,this._handleStreamMessageChunkPush,this),e.unSubscribeInnerEvent(t,this._handleMessageReceived,this)}}])}()),Pi=new(function(){return _createClass(function _class39(){_classCallCheck(this,_class39),this.name="MessageEnhancer"},[{key:"install",value:function install(e){this._core=e,Do.init(e),mi.init(e),Ei.init(e),Mi.init(e),ni.init(e),yi.init(e),Oi.init(e),oi.init(e),Ri.init(e),ai.init(e),Di.init(e),bi.init(e),Li.init(e),e.helper.registerValidateConfig({auth:di,params:li}),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this.dispose,this)}},{key:"dispose",value:function dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this.dispose,this),Mi.dispose(),oi.dispose(),ai.dispose(),Li.dispose()}},{key:"_reset",value:function _reset(){Li.reset()}}])}()),Gi=new(function(){return _createClass(function _class40(){_classCallCheck(this,_class40),this._name="WebRequest"},[{key:"init",value:function init(e){this._core=e}},{key:"request",value:function request(e,t){return pe(this,void 0,void 0,function*(){var s;const{isEmpty:n}=null===(s=this._core)||void 0===s?void 0:s.utils,{downloadUrl:o="",method:i="PUT",url:r,qs:a,headers:c={},resources:u,dataType:l="text",uploadByIP:d,uploadIP:h}=e;let g=r;if(a){const e=this._queryString(a);e&&(g+=`${g.includes("?")?"&":"?"}${e}`)}const p=new XMLHttpRequest;p.open(i.toUpperCase(),g,!0),p.responseType=l;const _=Object.assign({},c);if(d&&h&&(_.host=h),!n(_))for(const e in _)_.hasOwnProperty(e)&&!["content-length","user-agent","origin","host"].includes(e.toLowerCase())&&p.setRequestHeader(e,_[e]);return p.onload=()=>{const s=this._getResponseBody(p,o,d&&h),n=this._buildResponse(p,s);if(200===p.status)t(null,n);else{if(h&&!g.includes(h))return e.url=this._domainName2IP(g,h),e.uploadByIP=!0,this.request(e,t);t({code:p.status,message:JSON.stringify(p.responseText)},n)}},p.onerror=()=>{const e=this._getResponseBody(p,o,d&&h),s=this._buildResponse(p,e),n={code:p.status,message:0===p.status?"CORS blocked or network error":JSON.stringify(p.responseText)};t(n,s)},e.onProgress&&p.upload&&(p.upload.onprogress=t=>{const{total:s,loaded:n}=t,o=Math.min(Math.floor(100*n/s),100);e.onProgress({total:s,loaded:n,percent:o/100})}),p.send(u),p})}},{key:"_buildResponse",value:function _buildResponse(e,t){const s={};return e.getAllResponseHeaders().trim().split("\n").forEach(e=>{if(e){const[t,n]=e.split(":").map(e=>e.trim());s[t.toLowerCase()]=n}}),{statusCode:e.status,statusMessage:e.statusText,headers:s,data:t}}},{key:"_getResponseBody",value:function _getResponseBody(e,t,s){return 200===e.status&&t?{location:t,uploadIP:s}:{response:e.responseText,uploadIP:s}}},{key:"_queryString",value:function _queryString(e,t="&",s="="){var n;const{isEmpty:o,isPlainObject:i}=null===(n=this._core)||void 0===n?void 0:n.utils;return o(e)?"":i(e)?Object.keys(e).map(n=>{const o=encodeURIComponent(n)+s;return Array.isArray(e[n])?e[n].map(e=>o+encodeURIComponent(e)).join(t):o+encodeURIComponent(e[n])}).filter(Boolean).join(t):void 0}},{key:"_domainName2IP",value:function _domainName2IP(e,t){return e.replace(/^http(s)?:\/\/(.*?)\//,`https://${t}/`)}}])}());const wi=["unknown","image","video","audio","log"];var Ui=new(function(){return _createClass(function _class41(){_classCallCheck(this,_class41)},[{key:"init",value:function init(e){this._core=e}},{key:"request",value:function request(e,t){var s;const{MINI_APP_NAMESPACE:n,IN_ALIPAY_MINI_APP:o,isUniIOSApp:i}=null===(s=this._core)||void 0===s?void 0:s.utils,{resources:r="",headers:a={},url:c,downloadUrl:u=""}=e;let l=c,d=null;const h=u?u.match(/^(https?:\/\/[^/]+\/)([^/]*\/?)(.*)$/):null;if(!h)return void console.warn("message Invalid download URL format");const g=decodeURIComponent(h[3]),p=g.includes("?")?g.split("?")[0]:g||"",_={key:e.fileKey||p,success_action_status:200,"Content-Type":""},m={};if(i()){const[e,t]=c.split("?sign=");t&&(l=`${e}?sign=${encodeURIComponent(t)}`,m.sign=decodeURIComponent(t),m.signature=decodeURIComponent(t))}let v={url:l,header:a,name:"file",filePath:r,formData:Object.assign(Object.assign({},_),m),timeout:e.timeout||3e5};if(o){const{name:t}=v,s=ge(v,["name"]);v=Object.assign(Object.assign({},s),{fileName:"file",fileType:e.fileType?wi[e.fileType]:"image"})}return d=n.uploadFile(Object.assign(Object.assign({},v),{success:e=>{this._handleResponse({response:e,downloadUrl:u,callback:t})},fail:e=>{this._handleResponse({response:e,downloadUrl:u,callback:t})}})),d.onProgressUpdate&&d.onProgressUpdate(t=>{e.onProgress&&e.onProgress({total:t.totalBytesExpectedToSend||0,loaded:t.totalBytesSent||0,percent:t.progress?Math.floor(t.progress)/100:0})}),d}},{key:"_handleResponse",value:function _handleResponse(e){const{downloadUrl:t,response:s,callback:n}=e,o={};if(s.header)for(const e in s.header)s.header.hasOwnProperty(e)&&(o[e.toLowerCase()]=s.header[e]);const i=+s.statusCode;200===i?n(null,{statusCode:i,headers:o,data:Object.assign(Object.assign({},s.data),{location:t})}):n({code:i,message:JSON.stringify(s.data)},{statusCode:i,headers:o,data:void 0})}}])}());function ki(e){return"file"===function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()}(e)}function Fi(e){const t=e||99999999;return Math.round(Math.random()*t)}function $i(e,t=!0,s=!0){const n=Date.now();return t?s?n-e+" ms":`${Math.round((n-e)/1e3)} s`:s?n-e:Math.round((n-e)/1e3)}function xi(e){return`${Array.from({length:8},()=>Math.floor(65536*(1+Math.random())).toString(16).substring(1)).join("")}-${e}`}function qi(e,t){return Math.round(Number(e)*10**t)/10**t}function Vi(e){return e<=1048576?`${qi(e/1024,1)}KB/s`:`${qi(e/1048576,1)}MB/s`}const Bi="TIMImageElem",ji="TIMSoundElem",Hi="TIMFileElem",Ki="TIMVideoFileElem",Wi="RichMediaMessagePlugin",Yi=["rich.my-imcloud.com","imrich.qcloud.com"],zi=1,Ji=2,Qi=3,Xi=255;var Zi;!function(e){e.UNSENT="unSend",e.SUCCESS="success",e.FAIL="fail"}(Zi||(Zi={}));const er={wechat:/^(wxfile:\/\/tmp_|http:\/\/temp\/|cloud:\/\/temp-)/,alipay:/^(https:\/\/resource\/|alipayfile:\/\/tmp\/)/,baidu:/^(http:\/\/tmp\/|swanfile:\/\/tmp_)/,bytedance:/^(ttfile:\/\/tmp_|\/(var|tmp)\/|tttemp:\/\/)/,qq:/^(qqfile:\/\/tmp_|http:\/\/qtemp\/)/},tr=Symbol("isCustomUpload");var sr,nr=new(function(){return _createClass(function _class42(){_classCallCheck(this,_class42)},[{key:"init",value:function init(e){this._core=e}},{key:"addAuthToUrl",value:function addAuthToUrl(e=""){if(this._isMiniProgramTempFile(e))return e;const t=function(e){return e?e.startsWith("https://")?e:e.startsWith("http://")?e.replace("http://","https://"):e:""}(e);return this.processResourceUrl(t)}},{key:"removeAuthToUrl",value:function removeAuthToUrl(e){return function(e){const[s,n]=e.split("?");if(!n)return s;const o=n.split("&").reduce((e,s)=>{const[n,o]=s.split("=");return n&&"authKey"!==n&&(e[n]=o||""),e},{}),i=Object.keys(o).map(e=>`${e}${o[e]?`=${o[e]}`:""}`).join("&");return i?`${s}?${i}`:s}(e)}},{key:"_isMiniProgramTempFile",value:function _isMiniProgramTempFile(e){return!!this.getPlatformFlags().IN_MINI_APP&&Object.values(er).some(t=>t.test(e))}},{key:"extractFileFromInput",value:function extractFileFromInput(e){const{utils:{isArray:t}}=this._core;return ki(e)?e:function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s}(e)&&"undefined"!=typeof uni?t(e.tempFiles)&&e.tempFiles.length>0?e.tempFiles[0]:t(e.files)?e.files[0]:e.tempFile?e.tempFile:null:e instanceof HTMLInputElement&&e.files&&e.files.length>0?e.files[0]:null}},{key:"probeImageWidthHeight",value:function probeImageWidthHeight(e){return pe(this,void 0,void 0,function*(){var t;const{IN_MINI_APP:s,IN_BROWSER:n}=(null===(t=this._core)||void 0===t?void 0:t.utils)||{};return this._shouldSkipProbing()?{width:0,height:0}:n?this._probeImageDimensionsWeb(e):s?this._probeImageDimensionsMiniApp(e):void 0})}},{key:"isSimpleCos",value:function isSimpleCos(){var e;const t=(null===(e=this._core)||void 0===e?void 0:e.store.get("cloudConfig"))||{},{simple_cos:s}=t;return"0"!==s}},{key:"getFileDNList",value:function getFileDNList(){var e;let t=Yi;const s=(null===(e=this._core)||void 0===e?void 0:e.store.get("cloudConfig"))||{},{file_dn_list:n}=s;if(void 0===n)return t;try{JSON.parse(n).forEach(e=>{t.includes(e)||t.push(e)})}catch(e){console.warn(e),t=Yi}return t}},{key:"getPlatform",value:function getPlatform(){var e;return null===(e=this._core)||void 0===e?void 0:e.utils.platform}},{key:"generateUUID",value:function generateUUID(e,t){var s;let n=`${this.getSDKAppID()}-${this.getCurrentUserID()}-${null===(s=this._core)||void 0===s?void 0:s.utils.randomString()}`;if(t)return`${n}.${t}`;const o=e.name||e.value||e.url||e.tempFilePath,i=o&&o.slice(o.lastIndexOf(".")+1);return i&&(n=`${n}.${i}`),n}},{key:"processResourceUrl",value:function processResourceUrl(e){if(!e)return"";let t=e;const s=this.getFileDownloadProxy(),n=this.getAuthKey(),o=this.getFileDNList();s&&(e.startsWith("http://")?t=e.replace(/^http:\/\/[^/]+/,s):e.startsWith("https://")&&(t=e.replace(/^https:\/\/[^/]+/,s)));const i=n&&-1===t.indexOf("authKey=")&&function(e,t){let s=!1;if(e){const n=e.match(/:\/\/([0-9]?\.)?(.[^/:]+)/),o=n&&n[2]||"";if(o.includes("rich-dev"))return!0;for(let e=0;e<t.length;e++)if(o.endsWith(t[e])){s=!0;break}}return s}(t,o);return i&&(t=t.indexOf("?")>-1?`${t}&authKey=${n}`:`${t}?authKey=${n}`),t}},{key:"getCurrentUserID",value:function getCurrentUserID(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("login"))||void 0===t?void 0:t.userId}},{key:"getSDKAppID",value:function getSDKAppID(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.sdkAppId}},{key:"getFileDownloadProxy",value:function getFileDownloadProxy(){var e,t;return(null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.fileDownloadProxy)||""}},{key:"getFileUploadProxy",value:function getFileUploadProxy(){var e,t;return(null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.fileUploadProxy)||""}},{key:"getAuthKey",value:function getAuthKey(){var e,t;return(null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("login"))||void 0===t?void 0:t.authKey)||""}},{key:"isPrivateNetWork",value:function isPrivateNetWork(){var e,t;return null===(t=null===(e=this._core)||void 0===e?void 0:e.store.get("instance"))||void 0===t?void 0:t.proxyServer}},{key:"getPlatformFlags",value:function getPlatformFlags(){var e;const{IN_BROWSER:t,IN_MINI_APP:s,IN_RN_APP:n,IN_UNI_NATIVE_APP:o}=null===(e=this._core)||void 0===e?void 0:e.utils;return{IN_BROWSER:t,IN_MINI_APP:s,IN_RN_APP:n,IN_UNI_NATIVE_APP:o}}},{key:"isEmpty",value:function isEmpty(e){var t;const{isEmpty:s}=null===(t=this._core)||void 0===t?void 0:t.utils;return s(e)}},{key:"generateURL",value:function generateURL(e,t){const{needAddAuthToUrl:s=!0}=t||{};return s?this.addAuthToUrl(e):e}},{key:"_probeImageDimensionsMiniApp",value:function _probeImageDimensionsMiniApp(e){var t;const{MINI_APP_NAMESPACE:s}=(null===(t=this._core)||void 0===t?void 0:t.utils)||{};return new Promise(t=>{s.getImageInfo({src:e,success:e=>t({width:e.width,height:e.height}),fail:()=>t({width:0,height:0})})})}},{key:"_shouldSkipProbing",value:function _shouldSkipProbing(){var e;const{IN_RN_APP:t,IS_IE:s,IE_VERSION:n,IN_WX_MINI_GAME:o}=(null===(e=this._core)||void 0===e?void 0:e.utils)||{};return t||s&&9===n||o}},{key:"_probeImageDimensionsWeb",value:function _probeImageDimensionsWeb(e){return new Promise(t=>{const s=new Image,n=()=>{s.onload=null,s.onerror=null,s.src=""};s.onload=()=>{t({width:s.width,height:s.height}),n()},s.onerror=()=>{t({width:0,height:0}),n()},s.src=e})}}])}()),or={exports:{}},ir=(sr||(sr=1,or.exports=function(){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function s(e,t){var s=e[0],n=e[1],o=e[2],i=e[3];n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[0]-680876936|0)<<7|s>>>25)+n|0)&n|~s&o)+t[1]-389564586|0)<<12|i>>>20)+s|0)&s|~i&n)+t[2]+606105819|0)<<17|o>>>15)+i|0)&i|~o&s)+t[3]-1044525330|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[4]-176418897|0)<<7|s>>>25)+n|0)&n|~s&o)+t[5]+1200080426|0)<<12|i>>>20)+s|0)&s|~i&n)+t[6]-1473231341|0)<<17|o>>>15)+i|0)&i|~o&s)+t[7]-45705983|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[8]+1770035416|0)<<7|s>>>25)+n|0)&n|~s&o)+t[9]-1958414417|0)<<12|i>>>20)+s|0)&s|~i&n)+t[10]-42063|0)<<17|o>>>15)+i|0)&i|~o&s)+t[11]-1990404162|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&o|~n&i)+t[12]+1804603682|0)<<7|s>>>25)+n|0)&n|~s&o)+t[13]-40341101|0)<<12|i>>>20)+s|0)&s|~i&n)+t[14]-1502002290|0)<<17|o>>>15)+i|0)&i|~o&s)+t[15]+1236535329|0)<<22|n>>>10)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[1]-165796510|0)<<5|s>>>27)+n|0)&o|n&~o)+t[6]-1069501632|0)<<9|i>>>23)+s|0)&n|s&~n)+t[11]+643717713|0)<<14|o>>>18)+i|0)&s|i&~s)+t[0]-373897302|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[5]-701558691|0)<<5|s>>>27)+n|0)&o|n&~o)+t[10]+38016083|0)<<9|i>>>23)+s|0)&n|s&~n)+t[15]-660478335|0)<<14|o>>>18)+i|0)&s|i&~s)+t[4]-405537848|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[9]+568446438|0)<<5|s>>>27)+n|0)&o|n&~o)+t[14]-1019803690|0)<<9|i>>>23)+s|0)&n|s&~n)+t[3]-187363961|0)<<14|o>>>18)+i|0)&s|i&~s)+t[8]+1163531501|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n&i|o&~i)+t[13]-1444681467|0)<<5|s>>>27)+n|0)&o|n&~o)+t[2]-51403784|0)<<9|i>>>23)+s|0)&n|s&~n)+t[7]+1735328473|0)<<14|o>>>18)+i|0)&s|i&~s)+t[12]-1926607734|0)<<20|n>>>12)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[5]-378558|0)<<4|s>>>28)+n|0)^n^o)+t[8]-2022574463|0)<<11|i>>>21)+s|0)^s^n)+t[11]+1839030562|0)<<16|o>>>16)+i|0)^i^s)+t[14]-35309556|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[1]-1530992060|0)<<4|s>>>28)+n|0)^n^o)+t[4]+1272893353|0)<<11|i>>>21)+s|0)^s^n)+t[7]-155497632|0)<<16|o>>>16)+i|0)^i^s)+t[10]-1094730640|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[13]+681279174|0)<<4|s>>>28)+n|0)^n^o)+t[0]-358537222|0)<<11|i>>>21)+s|0)^s^n)+t[3]-722521979|0)<<16|o>>>16)+i|0)^i^s)+t[6]+76029189|0)<<23|n>>>9)+o|0,n=((n+=((o=((o+=((i=((i+=((s=((s+=(n^o^i)+t[9]-640364487|0)<<4|s>>>28)+n|0)^n^o)+t[12]-421815835|0)<<11|i>>>21)+s|0)^s^n)+t[15]+530742520|0)<<16|o>>>16)+i|0)^i^s)+t[2]-995338651|0)<<23|n>>>9)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[0]-198630844|0)<<6|s>>>26)+n|0)|~o))+t[7]+1126891415|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[14]-1416354905|0)<<15|o>>>17)+i|0)|~s))+t[5]-57434055|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[12]+1700485571|0)<<6|s>>>26)+n|0)|~o))+t[3]-1894986606|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[10]-1051523|0)<<15|o>>>17)+i|0)|~s))+t[1]-2054922799|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[8]+1873313359|0)<<6|s>>>26)+n|0)|~o))+t[15]-30611744|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[6]-1560198380|0)<<15|o>>>17)+i|0)|~s))+t[13]+1309151649|0)<<21|n>>>11)+o|0,n=((n+=((i=((i+=(n^((s=((s+=(o^(n|~i))+t[4]-145523070|0)<<6|s>>>26)+n|0)|~o))+t[11]-1120210379|0)<<10|i>>>22)+s|0)^((o=((o+=(s^(i|~n))+t[2]+718787259|0)<<15|o>>>17)+i|0)|~s))+t[9]-343485551|0)<<21|n>>>11)+o|0,e[0]=s+e[0]|0,e[1]=n+e[1]|0,e[2]=o+e[2]|0,e[3]=i+e[3]|0}function n(e){var t,s=[];for(t=0;t<64;t+=4)s[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return s}function o(e){var t,s=[];for(t=0;t<64;t+=4)s[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return s}function i(e){var t,o,i,r,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)s(l,n(e.substring(t-64,t)));for(o=(e=e.substring(t-64)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<o;t+=1)i[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(s(l,i),t=0;t<16;t+=1)i[t]=0;return r=(r=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),c=parseInt(r[1],16)||0,i[14]=a,i[15]=c,s(l,i),l}function r(e){var t,n,i,r,a,c,u=e.length,l=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=u;t+=64)s(l,o(e.subarray(t-64,t)));for(n=(e=t-64<u?e.subarray(t-64):new Uint8Array(0)).length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<n;t+=1)i[t>>2]|=e[t]<<(t%4<<3);if(i[t>>2]|=128<<(t%4<<3),t>55)for(s(l,i),t=0;t<16;t+=1)i[t]=0;return r=(r=8*u).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),c=parseInt(r[1],16)||0,i[14]=a,i[15]=c,s(l,i),l}function a(e){var s,n="";for(s=0;s<4;s+=1)n+=t[e>>8*s+4&15]+t[e>>8*s&15];return n}function c(e){var t;for(t=0;t<e.length;t+=1)e[t]=a(e[t]);return e.join("")}function u(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function g(e){var t,s=[],n=e.length;for(t=0;t<n-1;t+=2)s.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,s)}function p(){this.reset()}return c(i("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(s,n){var o,i,r,a,c=this.byteLength,u=t(s,c),l=c;return void 0!==n&&(l=t(n,c)),u>l?new ArrayBuffer(0):(o=l-u,i=new ArrayBuffer(o),r=new Uint8Array(i),a=new Uint8Array(this,u,o),r.set(a),i)}}(),p.prototype.append=function(e){return this.appendBinary(u(e)),this},p.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,o=this._buff.length;for(t=64;t<=o;t+=64)s(this._hash,n(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},p.prototype.end=function(e){var t,s,n=this._buff,o=n.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<o;t+=1)i[t>>2]|=n.charCodeAt(t)<<(t%4<<3);return this._finish(i,o),s=c(this._hash),e&&(s=g(s)),this.reset(),s},p.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},p.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},p.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},p.prototype._finish=function(e,t){var n,o,i,r=t;if(e[r>>2]|=128<<(r%4<<3),r>55)for(s(this._hash,e),r=0;r<16;r+=1)e[r]=0;n=(n=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(n[2],16),i=parseInt(n[1],16)||0,e[14]=o,e[15]=i,s(this._hash,e)},p.hash=function(e,t){return p.hashBinary(u(e),t)},p.hashBinary=function(e,t){var s=c(i(e));return t?g(s):s},p.ArrayBuffer=function(){this.reset()},p.ArrayBuffer.prototype.append=function(e){var t,n=function h(e,t,s){var n=new Uint8Array(e.byteLength+t.byteLength);return n.set(new Uint8Array(e)),n.set(new Uint8Array(t),e.byteLength),n}(this._buff.buffer,e),i=n.length;for(this._length+=e.byteLength,t=64;t<=i;t+=64)s(this._hash,o(n.subarray(t-64,t)));return this._buff=t-64<i?new Uint8Array(n.buffer.slice(t-64)):new Uint8Array(0),this},p.ArrayBuffer.prototype.end=function(e){var t,s,n=this._buff,o=n.length,i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<o;t+=1)i[t>>2]|=n[t]<<(t%4<<3);return this._finish(i,o),s=c(this._hash),e&&(s=g(s)),this.reset(),s},p.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},p.ArrayBuffer.prototype.getState=function(){var e=p.prototype.getState.call(this);return e.buff=function d(e){return String.fromCharCode.apply(null,new Uint8Array(e))}(e.buff),e},p.ArrayBuffer.prototype.setState=function(e){return e.buff=function l(e,t){var s,n=e.length,o=new ArrayBuffer(n),i=new Uint8Array(o);for(s=0;s<n;s+=1)i[s]=e.charCodeAt(s);return t?i:o}(e.buff,!0),p.prototype.setState.call(this,e)},p.ArrayBuffer.prototype.destroy=p.prototype.destroy,p.ArrayBuffer.prototype._finish=p.prototype._finish,p.ArrayBuffer.hash=function(e,t){var s=c(r(new Uint8Array(e)));return t?g(s):s},p}()),or.exports),rr=function qt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(ir),ar=new(function(){return _createClass(function _class43(){_classCallCheck(this,_class43),this.uploadFileTryCount=0,this.maxRetries=1,this.systemClockOffset=0,this.httpRequest=null,this.uploadFileType="",this.duration=900,this.fetchCosTryCount=0},[{key:"init",value:function init(e){var t;this._core=e;const{IN_MINI_APP:s}=e.utils;this.httpRequest=s?Ui:Gi,null===(t=this.httpRequest)||void 0===t||t.init(e)}},{key:"uploadToCOS",value:function uploadToCOS(e){return pe(this,void 0,void 0,function*(){const t=`${Wi} uploadToCOS`,{ssoLog:s,utils:{safeStringify:n}}=this._core,{file:o}=e;this.uploadFileType=e.uploadFileType,s.debug("uploadToCOS",`${t} options:${n(e)}`);try{const n=Date.now(),i=yield this._createCosOptions(e),r=i.fileExistsInCOS?{data:{location:i.downloadUrl}}:yield this._uploadFile(i);this._handleUploadError(r,e);const a=this._createUploadResult(o,r),c=Date.now()-n,u=function(e){const s=1048576;return e<1024?`${e}B`:e<s?`${Math.floor(e/1024)}KB`:`${Math.floor(e/s)}MB`}(o.size),l=`size:${u} time:${c}ms speed:${Vi(1e3*o.size/c)}`;return s.debug("uploadToCOS",`${t} ok. name:${o.name} ${l}`),{uploadOptions:i,response:a}}catch(e){throw s.warn("uploadToCOS",`${t} failed, error:${n(e)}`),e}})}},{key:"_handleUploadError",value:function _handleUploadError(e,t){var s,n;const{ChatError:o}=null===(s=this._core)||void 0===s?void 0:s.helper;if(403===e.statusCode)throw t.url,(null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.uploadIP)&&e.data.uploadIP,new o({message:"Upload failed with status 403"})}},{key:"_createUploadResult",value:function _createUploadResult(e,t){return{fileName:e.name,fileSize:e.size,fileType:e.type.slice(e.type.indexOf("/")+1).toLowerCase(),location:t.data.location||"",uploadTime:$i(Date.now(),!1),uploadSpeed:Vi(1e3*e.size/$i(Date.now(),!1))}}},{key:"_createCosOptions",value:function _createCosOptions(e){return pe(this,void 0,void 0,function*(){const{fileName:t,resources:s,uploadMethod:n}=yield this._prepareUploadParams(e),o=this._isC2CConversation(e.message.conversationID)?1:2;try{const i=yield this._fetchCosSignatureUrl({fileType:this.uploadFileType,fileName:t,uploadMethod:n,duration:this.duration,userID:e.message.from,conversationType:o}),{uploadUrl:r,downloadUrl:a,requestSnapshotUrl:c,thumbUrl:u,largeUrl:l,fileKey:d,existFlag:h}=i,g=!nr.isPrivateNetWork()&&i.uploadIP;return{url:this._getRawOrUploadProxyUrl(r),fileType:this.uploadFileType,fileName:t,resources:s,downloadUrl:a,requestSnapshotUrl:c,thumbUrl:u,largeUrl:l,fileKey:d,uploadIP:g||"",fileExistsInCOS:1===h,onProgress:t=>this._handleUploadProgress(t,e)}}catch(e){throw console.error("Failed to create COS pre-signed URL options:",e),e}})}},{key:"_prepareUploadParams",value:function _prepareUploadParams(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s,isEmpty:n}}=this._core;t.debug("_prepareUploadParams",` prepareUploadParams:${s(e)}`);const{file:o}=e,{IN_MINI_APP:i,IN_RN_APP:r}=nr.getPlatformFlags(),a=i||r,c=a&&e.message.type!==Hi,{name:u}=o,l=u.slice(u.lastIndexOf(".")),d=`${Fi(999999)}${l}`,h=c?o.name:d,g=yield this._generateHashFileName(o);return{fileName:n(g)?xi(h):`${g}${l}`,resources:a?o.url:o,uploadMethod:a?1:0}})}},{key:"_generateHashFileName",value:function _generateHashFileName(e){return pe(this,void 0,void 0,function*(){const{utils:{IN_MINI_APP:t,IN_BROWSER:s,IN_UNI_NATIVE_APP:n,isArray:o},ssoLog:i}=this._core,r=Date.now();let a="";return s&&(a=yield this._generateHashFileNameInWeb(e)),t&&(o(e.tempFiles)&&(e=e.tempFiles[0]),n||(a=yield this._generateFileNameInMiniProgram(e)),n&&(a=yield this._generateFileNameInUNINativeApp(e))),i.info("_generateHashFileName",`hashFileName:${a} costTime:${Date.now()-r}`),a})}},{key:"_generateHashFileNameInWeb",value:function _generateHashFileNameInWeb(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;let n="";try{n=yield new Promise((s,n)=>{const o=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;o||(t.warn("_generateHashFileNameInWeb","Browser does not support file slicing"),s(""));const i=10485760,r=Math.ceil(e.size/i);let a=0;const c=new rr.ArrayBuffer,u=new FileReader,l=setTimeout(()=>{u.abort(),t.warn("_generateHashFileNameInWeb","File hash generation timeout"),s("")},2e3);function d(){const t=a*i,s=t+i>=e.size?e.size:t+i;u.readAsArrayBuffer(o.call(e,t,s))}u.onload=e=>{t.debug("_generateHashFileNameInWeb",`read chunk nr ${a+1} of ${r}`),c.append(e.target.result),a++,a<r?d():(t.debug("_generateHashFileNameInWeb","finished loading"),clearTimeout(l),s(c.end()))},u.onerror=e=>{clearTimeout(l),n(e)},d()})}catch(e){t.warn("_generateHashFileNameInWeb",s(e))}return n})}},{key:"_generateFileNameInMiniProgram",value:function _generateFileNameInMiniProgram(e){return pe(this,void 0,void 0,function*(){const{utils:{MINI_APP_NAMESPACE:t,safeStringify:s,isEmpty:n},ssoLog:o}=this._core;let i="";if(n(e.url))return o.warn("_generateFileNameInMiniProgram","file.url is empty"),i;if("function"!=typeof(null==t?void 0:t.getFileSystemManager))return o.warn("_generateFileNameInUNINativeApp","getFileSystemManager is not a function"),i;try{i=yield new Promise((s,n)=>{t.getFileSystemManager().getFileInfo({filePath:e.url,success:e=>{s(e.digest)},fail:e=>{n(e)}})})}catch(e){o.warn("_generateFileNameInMiniProgram",s(e))}return i})}},{key:"_generateFileNameInUNINativeApp",value:function _generateFileNameInUNINativeApp(e){return pe(this,void 0,void 0,function*(){var t;const{utils:{safeStringify:s,isEmpty:n},ssoLog:o}=this._core;let i="";if(n(e.url))return o.warn("_generateFileNameInUNINativeApp","file.url is empty"),i;if("function"!=typeof(null===(t=null===plus||void 0===plus?void 0:plus.io)||void 0===t?void 0:t.getFileInfo))return o.warn("_generateFileNameInUNINativeApp","plus.io.getFileInfo is not a function"),i;try{i=yield new Promise((t,s)=>{plus.io.getFileInfo({filePath:e.url,success:e=>{t(e.digest)},fail:e=>{s(e)}})})}catch(e){o.warn("_generateFileNameInMiniProgram",s(e))}return i})}},{key:"_handleUploadProgress",value:function _handleUploadProgress(e,t){if("function"==typeof t.onProgress)try{t.onProgress(e.percent)}catch(e){throw console.warn("Upload progress callback error:",e),e}}},{key:"_fetchCosSignatureUrl",value:function _fetchCosSignatureUrl(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core,n=nr.isSimpleCos(),o=this._prepareCosRequestData(e),i=n?"im_cos_msg.simple_sig":"im_cos_msg.pre_sig";try{const e=yield function(e,t,s){return pe(this,void 0,void 0,function*(){try{const{helper:n,channel:o}=s,i=n.generateCosSpecifiedData({servcmd:e,data:t}),r=`${i.head.seq}${e}`;return yield o.sendPacket(i,{requestId:r})}catch(e){throw console.warn("getCosSig error:",e),e}})}(i,o,this._core);this.fetchCosTryCount=0;const r=this._processResponse(e);return t.debug("_fetchCosSignatureUrl",` ok. isSimpleCos:${n} data:${s(r)}`),r||{}}catch(t){if(this.fetchCosTryCount<1)return this.fetchCosTryCount++,this._fetchCosSignatureUrl(e);throw this.fetchCosTryCount=0,t}})}},{key:"_processResponse",value:function _processResponse(e){var t;const s=nr.isSimpleCos(),n=s?null===(t=null==e?void 0:e.rpt_pre_sig)||void 0===t?void 0:t[0]:e;if(!n)return{};if(s){const{str_final_ip:e,rpt_pre_sig:t,uint32_file_id:s,uint32_exist_flag:o,str_download_url:i,str_upload_url:r,str_snapshot_url:a,str_file_key:c}=n;return{uploadIP:e,preSig:t,fileID:s,existFlag:o,downloadUrl:i,uploadUrl:r,requestSnapshotUrl:a,fileKey:c}}const{upload_url:o,download_url:i,snapshot_url:r,thumb_url:a,large_url:c,file_key:u}=n;return{uploadUrl:o,downloadUrl:i,requestSnapshotUrl:r,thumbUrl:a,largeUrl:c,fileKey:u}}},{key:"_prepareCosRequestData",value:function _prepareCosRequestData(e){return nr.isSimpleCos()?{uint32_upload_method:e.uploadMethod,uint32_platform:nr.getPlatform(),uint32_sdkappid:nr.getSDKAppID(),str_user_id:e.userID,uint32_scene:e.conversationType,rpt_upload_object:[{uint32_file_id:1,uint32_file_type:e.fileType,str_file_name:e.fileName}]}:{file_type:e.fileType,file_name:e.fileName,upload_method:e.uploadMethod,Duration:e.duration}}},{key:"_uploadFile",value:function _uploadFile(e){return pe(this,void 0,void 0,function*(){return new Promise((t,s)=>{this.httpRequest.request(e,(n,o)=>{n&&this.uploadFileTryCount<this.maxRetries&&this.shouldRetry(n)?(this.uploadFileTryCount++,this._uploadFile(e).then(t).catch(s)):(this.uploadFileTryCount=0,n?s(n):t(o))})})})}},{key:"shouldRetry",value:function shouldRetry(e){return!!e&&(5===Math.floor(e.statusCode/100)||!(!this.isTimeRelatedError(e)||!this._isClockOutOfSync(e)||(this._syncSystemClock(e),0)))}},{key:"isTimeRelatedError",value:function isTimeRelatedError(e){var t,s;try{const n=null===(t=e.error)||void 0===t?void 0:t.Code,o=null===(s=e.error)||void 0===s?void 0:s.Message;return"RequestTimeTooSkewed"===n||"AccessDenied"===n&&"Request has expired"===o}catch(e){return!1}}},{key:"_isClockOutOfSync",value:function _isClockOutOfSync(e){var t,s,n;const o=(null===(t=e.headers)||void 0===t?void 0:t.date)||(null===(s=e.headers)||void 0===s?void 0:s.Date)||(null===(n=e.error)||void 0===n?void 0:n.ServerTime);if(!o)return!1;const i=Date.now(),r=Date.parse(o);return Math.abs(i+this.systemClockOffset-r)>=3e4}},{key:"_syncSystemClock",value:function _syncSystemClock(e){var t,s,n;const o=(null===(t=e.headers)||void 0===t?void 0:t.date)||(null===(s=e.headers)||void 0===s?void 0:s.Date)||(null===(n=e.error)||void 0===n?void 0:n.ServerTime);if(o){const e=Date.now(),t=Date.parse(o);this.systemClockOffset=t-e}}},{key:"_getRawOrUploadProxyUrl",value:function _getRawOrUploadProxyUrl(e){const t=nr.getFileUploadProxy();let s=e;return t&&(s=e.replace(/^https:\/\/[^/]+/,t)),s}},{key:"_isC2CConversation",value:function _isC2CConversation(e){return"C2C"===e.slice(0,3)}}])}());const hr=["jpg","jpeg","gif","png","bmp","image","webp"],gr={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255};let mr=function(){return _createClass(function mr(e,t){_classCallCheck(this,mr),this.instanceID=Fi(9999999),this.sizeType=e.type||0,this.type=0,this.size=e.size||0,this.width=e.width||0,this.height=e.height||0,this.imageUrl=nr.addAuthToUrl(e.imageUrl||e.url||""),this.url=nr.addAuthToUrl(e.url||t)},[{key:"setSizeType",value:function setSizeType(e){this.sizeType=e}},{key:"setType",value:function setType(e){this.type=e}},{key:"setImageUrl",value:function setImageUrl(e){e&&(this.imageUrl=nr.addAuthToUrl(e))}},{key:"getImageUrl",value:function getImageUrl(){return this.imageUrl}}])}();function vr(e){const{originUrl:t,originWidth:s,originHeight:n,min:o=198}=e,i=parseInt(s)||0,r=parseInt(n)||0,a={url:void 0,width:0,height:0};if((i<=r?i:r)<=o)a.url=t,a.width=i,a.height=r;else{r<=i?(a.width=Math.ceil(i*o/r),a.height=o):(a.width=o,a.height=Math.ceil(r*o/i));const e=t&&t.indexOf("?")>-1?`${t}&`:`${t}?`;a.url=198===o?`${e}imageView2/3/w/198/h/198`:`${e}imageView2/3/w/720/h/720`}if(void 0===t){const{url:e}=a;return ge(a,["url"])}return a}let fr=function(){function fr(e){_classCallCheck(this,fr),this._imageMemoryURL="",this._percent=0,this.type=Bi;const{uuid:t,file:s,imageFormat:n,imageInfoArray:o=[],isCustomUpload:i=!1}=e;this._imageMemoryURL=this.createImageDataAsURL(s),this.content={imageFormat:n,uuid:t,imageInfoArray:[]},this[tr]=i,this.initImageInfoArray(o),this.autoFixUrl()}return _createClass(fr,[{key:"createImageDataAsURL",value:function createImageDataAsURL(e){let t="";const{IN_MINI_APP:s,IN_RN_APP:n,IN_BROWSER:o}=nr.getPlatformFlags();return e?((s||n)&&(t=e.url),o&&(t=window.URL.createObjectURL(e)),t):t}},{key:"initImageInfoArray",value:function initImageInfoArray(e=[]){const t={type:0,size:0,width:0,height:0,url:""};for(let s=0;s<3;s++){const n=e[s]||Object.assign({},t),o=new mr(n,this._imageMemoryURL);o.setSizeType(s+1),o.setType(s),this.addImageInfo(o)}this.updateAccessSideImageInfoArray()}},{key:"autoFixUrl",value:function autoFixUrl(){const e=["http","https"];this.content.imageInfoArray.forEach(t=>{if(!t.url||""===t.imageUrl)return;const[s,...n]=t.imageUrl.split("://"),o=n.join("://");e.includes(s)||t.setImageUrl(`https://${o}`)})}},{key:"updatePercent",value:function updatePercent(e){this._percent=Math.min(e,1)}},{key:"updateImageFormat",value:function updateImageFormat(e){this.content.imageFormat=gr[e.toUpperCase()]||gr.UNKNOWN}},{key:"addImageInfo",value:function addImageInfo(e){this.content.imageInfoArray.length>=3||this.content.imageInfoArray.push(e)}},{key:"updateImageInfoArray",value:function updateImageInfoArray(e){const t=this.content.imageInfoArray.length;let s;for(let n=0;n<t;n++)s=this.content.imageInfoArray[n],e[n].size&&(s.size=e[n].size),e[n].url&&s.setImageUrl(e[n].url),e[n].width&&(s.width=e[n].width),e[n].height&&(s.height=e[n].height)}},{key:"updateAccessSideImageInfoArray",value:function updateAccessSideImageInfoArray(){const[e]=this.content.imageInfoArray;e&&0!==e.width&&0!==e.height&&(function(e){const t=e[2];e[2]=e[1],e[1]=t;for(let t=0;t<e.length;t++)e[t].setType(t)}(this.content.imageInfoArray),Object.assign(this.content.imageInfoArray[2],vr({originWidth:e.width,originHeight:e.height,min:720})))}},{key:"validateBeforeSend",value:function validateBeforeSend(){if(this[tr])return delete this[tr],{isValid:!0};const[e]=this.content.imageInfoArray,t=!!e&&""!==e.imageUrl&&0!==e.size;return{isValid:t,error:t?null:{message:"content can not be empty"}}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{uuid:n,imageFormat:o,imageInfoArray:i}=s;return{MsgType:this.type,MsgContent:{ImageFormat:o,ImageInfoArray:this.parseImageInfoArray(i),UUID:n}}}},{key:"parseImageInfoArray",value:function parseImageInfoArray(e){return e.map(e=>({InstanceId:e.instanceID,Type:e.sizeType,MsgType:e.type,Size:e.size,Width:e.width,Height:e.height,URL:nr.removeAuthToUrl(e.imageUrl)}))}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t}=e,{ImageFormat:s,ImageInfoArray:n,UUID:o}=t,i=function(e){return e.map(e=>({size:e.Size,type:e.Type,width:e.Width,height:e.Height,url:e.URL}))}(n);return new fr({imageFormat:s,imageInfoArray:i,uuid:o})}}])}();const Ir=new(function(){return _createClass(function _class44(){_classCallCheck(this,_class44)},[{key:"init",value:function init(e){this.core=e}}])}()),Er={[zi]:"i",[Qi]:"a",[Ji]:"v",[Xi]:"f"};let Sr=null,Cr=null;function Mr(e){var t;const{store:s,utils:{isNumber:n,safeStringify:o},ssoLog:i}=Ir.core;try{const o=(null===(t=s.get("cloudConfig"))||void 0===t?void 0:t.upload_size_limit)||"";o!==Cr&&(Cr=o,Sr=JSON.parse(o)||{});const i=null==Sr?void 0:Sr[Er[e]];if(n(i))return 1024*i*1024}catch(e){i.debug("getCloudControlUploadSizeLimit",o(e))}return null}var yr=new(function(){return _createClass(function _class45(){_classCallCheck(this,_class45),this._messageOptionsMap=new Map},[{key:"init",value:function init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createImageMessage",context:this}),n.registerExperimentalAPI("createImageMessage",this,"createCustomUploadImageMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(Bi,fr),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}},{key:"createImageMessage",value:function createImageMessage(e){var t,s,n;try{const o=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,i=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:o})),r=this._processImage(e);e.payload.file=r;const a={imageFormat:gr.UNKNOWN,uuid:nr.generateUUID(r),file:r,imageInfoArray:[]},c=new fr(a);return i.setElement(c),this._messageOptionsMap.set(i.clientSequence,e),i}catch(e){throw e}}},{key:"createCustomUploadImageMessage",value:function createCustomUploadImageMessage(e){var t,s,n,o;const{store:i,utils:{isEmpty:r}}=this._core,a=null===(t=i.get("login"))||void 0===t?void 0:t.userId,c=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:a})),{largeImageUuid:u,largeFileSize:l,largeImageWidth:d,largeImageHeight:h,largeImageUrl:g,originImageUuid:p,originFileSize:_,originImageWidth:m,originImageHeight:v,originImageUrl:f,thumbImageUuid:I,thumbFileSize:E,thumbImageWidth:S,thumbImageHeight:C,thumbImageUrl:M}=(null===(o=null==e?void 0:e.payload)||void 0===o?void 0:o.file)||{};if(r(f)||r(p))throw new Error("createImageMessageExperimental originImageUrl or originImageUuid is empty");const y=new fr({imageFormat:gr.UNKNOWN,uuid:p,imageInfoArray:[{instanceID:p,size:_,width:m,height:v,imageUrl:f,url:f},{instanceID:u,size:l,width:d,height:h,imageUrl:g,url:g},{instanceID:I,size:E,width:S,height:C,imageUrl:M,url:M}],isCustomUpload:!0});return c.setElement(y),this._messageOptionsMap.set(c.clientSequence,e),c._skipUpload=!0,c}},{key:"upload",value:function upload(e){return pe(this,void 0,void 0,function*(){const t=e.getElements()[0],{file:s}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadImage(s);const n=yield this._performImageUpload(t,e,s),o=this._generateImageInfo(n);return t.updateImageFormat(null==n?void 0:n.fileType),t.updateImageInfoArray(o),this._updateImageType(t.content.imageInfoArray),e})}},{key:"_performImageUpload",value:function _performImageUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:1,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{uploadOptions:i,response:r}=yield ar.uploadToCOS(o);return this._parseResponse(i,r)})}},{key:"_generateImageInfo",value:function _generateImageInfo(e){const{location:t,fileSize:s,width:n,height:o,smallImageUrl:i,smallImageWidth:r,smallImageHeight:a,largeImageUrl:c,largeImageWidth:u,largeImageHeight:l,imageInfoArray:d}=e,h=nr.addAuthToUrl(t),g={size:s,url:h,width:n,height:o};return(null==d?void 0:d.length)>0?this._processImageInfoArray(d,s):i&&c?[Object.assign({},g),{largeImageUrl:c,largeImageWidth:u,largeImageHeight:l},{smallImageUrl:i,smallImageWidth:r,smallImageHeight:a}]:[Object.assign({},g),this._generateThumbInfo(h,n,o,720),this._generateThumbInfo(h,n,o,198)]}},{key:"_generateThumbInfo",value:function _generateThumbInfo(e,t,s,n){return vr({originUrl:e,originWidth:t,originHeight:s,min:n})}},{key:"_processImageInfoArray",value:function _processImageInfoArray(e,t){let s,n,o;for(const i of e)1===i.type?(n=i,n.size=t):2===i.type?(o=i,o.size=t):(s=i,s.size=t);return[Object.assign({},s),Object.assign({},o),Object.assign({},n)]}},{key:"_parseResponse",value:function _parseResponse(e,t){return pe(this,void 0,void 0,function*(){try{const{thumbUrl:s,largeUrl:n,downloadUrl:o}=e;if(s&&n&&(yield this._getImageInfoByUrl(s,t,"thumb"),yield this._getImageInfoByUrl(n,t,"large")),nr.isSimpleCos()&&!nr.isPrivateNetWork()&&(yield this._getImageInfoArray(o,t),null==t?void 0:t.uploadIP)){const e=this._extractDomainFromUrl(o);e&&(yield this._getDownloadIP(e,t))}return t}catch(e){throw e}})}},{key:"_extractDomainFromUrl",value:function _extractDomainFromUrl(e){var t;try{const t=e.match(/:\/\/([^\/]+)/);return t?t[1]:null}catch(e){return null===(t=this._core)||void 0===t||t.ssoLog.warn("_extractDomainFromUrl",`Failed to extract domain from URL:${e.message}`),null}}},{key:"_getImageInfoByUrl",value:function _getImageInfoByUrl(e,t,s){return pe(this,void 0,void 0,function*(){var n;try{const n=nr.addAuthToUrl(e),{width:o=0,height:i=0}=yield nr.probeImageWidthHeight(n);t.width=o,t.height=i,"thumb"===s?(t.smallImageUrl=e,t.smallImageWidth=o,t.smallImageHeight=i):(t.largeImageUrl=e,t.largeImageWidth=o,t.largeImageHeight=i)}catch(e){null===(n=this._core)||void 0===n||n.ssoLog.warn("_getImageInfoByUrl",`Failed to get ${s} image info:${e.message}`)}})}},{key:"_validateBeforeUploadImage",value:function _validateBeforeUploadImage(e){var t;const{ChatError:s}=null===(t=this._core)||void 0===t?void 0:t.helper;if(!e)throw new s({code:2251});this._checkImageType(e),this._checkImageSize(e)}},{key:"_processImage",value:function _processImage(e){var t;try{const{IN_MINI_APP:s}=null===(t=this._core)||void 0===t?void 0:t.utils;let{file:n}=e.payload;return n=s?this._processMiniAppImageFile(n):this._processWebImageFile(n),n}catch(e){throw e}}},{key:"_processMiniAppImageFile",value:function _processMiniAppImageFile(e){ki(e)&&console.warn("FileUnsupportedInMiniApp","createImageMessage");const t=e.tempFiles[0].path||e.tempFiles[0].tempFilePath;return{url:t,name:t.slice(t.lastIndexOf("/")+1),size:e.tempFiles&&e.tempFiles[0].size||1,type:t.slice(t.lastIndexOf(".")+1).toLowerCase()}}},{key:"_processWebImageFile",value:function _processWebImageFile(e){var t;const{ChatError:s}=null===(t=this._core)||void 0===t?void 0:t.helper,n=nr.extractFileFromInput(e);if(!n)throw new s({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});return n}},{key:"_getDownloadIP",value:function _getDownloadIP(e,t){return pe(this,void 0,void 0,function*(){const s=`${Wi} getDownloadIP domainName: ${e}`;try{const n=yield function(e,t){return pe(this,void 0,void 0,function*(){try{const{helper:s,channel:n}=t,o="im_cos_msg.get_final_ip",i={str_domain:e},r=s.generateProtocolData({servcmd:o,data:i}),a=`${r.head.seq}${o}`;return yield n.sendPacket(r,{requestId:a})}catch(e){throw console.warn("getFinalIP error:",e),e}})}(e,this._core);if(!n||!n.str_final_ip)return;console.log(`${s} ok. downloadIP:${n}`);const o=t.location.split("/");o[0]=n.str_final_ip,t.location=o.join("/")}catch(e){console.warn(e)}})}},{key:"_getImageInfoArray",value:function _getImageInfoArray(e,t){return pe(this,void 0,void 0,function*(){try{const s=yield function(e,t){return pe(this,void 0,void 0,function*(){try{const{helper:s,channel:n}=t,o="im_cos_msg.get_imageinfo",i={str_image_url:e},r=s.generateProtocolData({servcmd:o,data:i}),a=`${r.head.seq}${o}`;return yield n.sendPacket(r,{requestId:a})}catch(e){throw console.warn("getImageInfo error:",e),e}})}(e,this._core);return t.imageInfoArray=this._processImageInfoResponse(s),t}catch(e){throw t.imageInfoArray=void 0,e}})}},{key:"_processImageInfoResponse",value:function _processImageInfoResponse(e){if(!e)return[];const{rpt_msg_image_info:t}=e;return t.map(e=>({type:e.uint32_image_type,url:e.str_url,width:e.uint32_width,height:e.uint32_height,imageFormat:e.str_image_format}))}},{key:"_checkImageType",value:function _checkImageType(e){const{utils:t,helper:s}=this._core;let n="";if(t.IN_MINI_APP&&(n=e.url.slice(e.url.lastIndexOf(".")+1)),t.IN_BROWSER&&(n=e.name.slice(e.name.lastIndexOf(".")+1)),hr.indexOf(n.toLowerCase())<0)throw new s.ChatError({code:2252})}},{key:"_checkImageSize",value:function _checkImageSize(e){const{utils:t,helper:s,store:n}=this._core;let o=0;if(t.IN_MINI_APP,o=e.size,0===o)throw new s.ChatError({code:2108});if(o>=(Mr(1)||20971520))throw new s.ChatError({code:2253})}},{key:"_updateImageType",value:function _updateImageType(e){e[1].type=2,e[2].type=1}},{key:"_reset",value:function _reset(){this._messageOptionsMap.clear()}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}])}());function br(e,t){const s=e.split("."),n=t.split("."),o=Math.max(s.length,n.length);for(;s.length<o;)s.push("0");for(;n.length<o;)n.push("0");for(let e=0;e<o;e++){const t=parseInt(s[e]),o=parseInt(n[e]);if(t>o)return 1;if(t<o)return-1}return 0}var Nr;let Lr=function(){function Lr(e){_classCallCheck(this,Lr),this.type=Hi,this.uploadProgress=0,this[Nr]=!1;const t=this._getFileInfo(e);this[tr]=e.isCustomUpload||!1,this.content={downloadFlag:2,fileUrl:nr.generateURL(e.url||e.fileUrl,{needAddAuthToUrl:!this[tr]})||"",uuid:e.uuid,fileName:t.name||"",fileSize:t.size||0}}return _createClass(Lr,[{key:"updatePercent",value:function updatePercent(e){this.uploadProgress=Math.min(e,1)}},{key:"updateFileUrl",value:function updateFileUrl(e){this.content.fileUrl=e}},{key:"validateBeforeSend",value:function validateBeforeSend(){if(this[tr])return{isValid:!0};const e=""!==this.content.fileUrl&&""!==this.content.fileName&&this.content.fileSize>0;return{isValid:e,error:e?null:{message:"content can not be empty"}}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{uuid:n,downloadFlag:o,fileUrl:i,fileName:r,fileSize:a}=s;return{MsgType:this.type,MsgContent:{Download_Flag:o,Url:nr.removeAuthToUrl(i),FileName:r,FileSize:a,UUID:n}}}},{key:"_getFileInfo",value:function _getFileInfo(e){const{utils:{IN_UNI_NATIVE_APP:t}}=Ir.core;if(e.fileName&&e.fileSize)return{size:e.fileSize,name:e.fileName};const{file:s}=e;return s?(t&&this._processNativeAppFile(s),{size:s.size,name:s.name}):{size:0,name:""}}},{key:"_processNativeAppFile",value:function _processNativeAppFile(e){if(e.path&&e.path.includes(".")){const t=e.path.slice(e.path.lastIndexOf(".")+1).toLowerCase();e.type=t,e.name||(e.name=`${Fi(999999)}.${t}`)}e.name||(e.type="",e.name=e.path.slice(e.path.lastIndexOf("/")+1).toLowerCase()),e.suffix&&(e.type=e.suffix),e.url||(e.url=e.path)}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t}=e,{Download_Flag:s,Url:n,FileName:o,FileSize:i,UUID:r}=t;return new Lr({downloadFlag:s,url:n,fileName:o,fileSize:i,uuid:r})}}])}();Nr=tr;var Pr=new(function(){return _createClass(function _class46(){_classCallCheck(this,_class46),this._messageOptionsMap=new Map},[{key:"init",value:function init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createFileMessage",context:this}),n.registerExperimentalAPI("createFileMessage",this,"createCustomUploadFileMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(Hi,Lr),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}},{key:"createFileMessage",value:function createFileMessage(e){var t,s,n;try{this._checkVersion();const o=this._processFile(e.payload.file);e.payload.file=o;const i=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:i})),a={uuid:nr.generateUUID(o),file:o},c=new Lr(a);return r.setElement(c),this._messageOptionsMap.set(r.clientSequence,e),r}catch(e){throw e}}},{key:"createCustomUploadFileMessage",value:function createCustomUploadFileMessage(e){var t,s,n;try{const{store:o,message:i,utils:{isEmpty:r}}=this._core,a=null===(t=o.get("login"))||void 0===t?void 0:t.userId,{url:c,uuid:u,fileSize:l,fileName:d=""}=(null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.file)||{};if(r(c))throw new Error("url is required");const h=null===(n=i.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:a})),g=new Lr({url:c,uuid:u,file:{size:l,name:d},isCustomUpload:!0});return h.setElement(g),h}catch(e){throw e}}},{key:"upload",value:function upload(e){return pe(this,void 0,void 0,function*(){const{file:t}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadFile(t);const s=e.getElements()[0],n=yield this._performFileUpload(s,e,t),o=nr.addAuthToUrl(null==n?void 0:n.location);return s.updateFileUrl(o),e})}},{key:"_validateBeforeUploadFile",value:function _validateBeforeUploadFile(e){const{helper:{ChatError:t}}=this._core;if(!e)throw new t({code:2401});const s=Mr(255)||104857600;if(e.size>s)throw new t({code:2402});if(0===e.size)throw new t({code:2108})}},{key:"_performFileUpload",value:function _performFileUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:255,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{response:i}=yield ar.uploadToCOS(o);return i})}},{key:"_processFile",value:function _processFile(e){var t,s;const{IN_BROWSER:n,IN_RN_APP:o,IN_WX_MINI_APP:i,IN_QQ_MINI_APP:r,IN_UNI_NATIVE_APP:a}=null===(t=this._core)||void 0===t?void 0:t.utils,{ChatError:c}=null===(s=this._core)||void 0===s?void 0:s.helper;if(n||a){const t=nr.extractFileFromInput(e);if(!t)throw new c({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});return t}if(i||r){const{tempFiles:t}=e;return Object.assign(Object.assign({},t[0]),{url:t[0].path})}return o?Object.assign(Object.assign({},e),{url:e.uri}):e}},{key:"_checkVersion",value:function _checkVersion(){var e,t;const{MINI_APP_NAMESPACE:s,IN_MINI_APP:n,IN_WX_MINI_APP:o,IN_QQ_MINI_APP:i,IN_UNI_NATIVE_APP:r}=null===(e=this._core)||void 0===e?void 0:e.utils,{ChatError:a}=null===(t=this._core)||void 0===t?void 0:t.helper;if(n){if(!(o||i||r))throw new a({message:"Unsupported mini app environment"});const e=s.getSystemInfoSync().SDKVersion;if(o&&br(e,"2.5.0")<0)throw new a({message:"WXChooseMessageFile requires SDK version 2.5.0 or higher"});if(i&&br(e,"1.18.0")<0)throw new a({message:"QQChooseMessageFile requires SDK version 1.18.0 or higher"})}}},{key:"_reset",value:function _reset(){this._messageOptionsMap.clear()}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}])}());const kr=["mp4","quicktime","mov","video"];var Fr;let $r=function(){function $r(e){_classCallCheck(this,$r),this.type=Ki,this.uploadProgress=0,this[Fr]=!1;const t="number"==typeof(null==e?void 0:e.videoSecond)?null==e?void 0:e.videoSecond:0;this[tr]=e.isCustomUpload||!1,this.content={remoteVideoUrl:nr.addAuthToUrl(e.remoteVideoUrl||e.videoUrl||""),videoFormat:e.videoFormat,videoSecond:parseInt(null==t?void 0:t.toString(),10),videoSize:e.videoSize,videoUrl:nr.addAuthToUrl(e.videoUrl),videoDownloadFlag:2,videoUUID:e.videoUUID,thumbUUID:e.thumbUUID,thumbFormat:e.thumbFormat,thumbWidth:e.thumbWidth,snapshotWidth:e.thumbWidth,thumbHeight:e.thumbHeight,snapshotHeight:e.thumbHeight,thumbSize:e.thumbSize,snapshotSize:e.thumbSize,thumbDownloadFlag:2,thumbUrl:nr.addAuthToUrl(e.thumbUrl),snapshotUrl:nr.addAuthToUrl(e.thumbUrl)}}return _createClass($r,[{key:"updatePercent",value:function updatePercent(e){this.uploadProgress=Math.min(e,1)}},{key:"updateVideoUrl",value:function updateVideoUrl(e){e&&(this.content.remoteVideoUrl=e)}},{key:"updateSnapshotInfo",value:function updateSnapshotInfo(e){const{snapshotUrl:t,snapshotWidth:s,snapshotHeight:n}=e;nr.isEmpty(t)||(this.content.thumbUrl=this.content.snapshotUrl=t),nr.isEmpty(s)||(this.content.thumbWidth=this.content.snapshotWidth=Number(s)),nr.isEmpty(n)||(this.content.thumbHeight=this.content.snapshotHeight=Number(n))}},{key:"validateBeforeSend",value:function validateBeforeSend(){if(this[tr])return{isValid:!0};const e=""!==this.content.remoteVideoUrl;return{isValid:e,error:e?null:{message:"content can not be empty"}}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{remoteVideoUrl:n,videoFormat:o,videoSecond:i,videoSize:r,videoDownloadFlag:a,videoUUID:c,thumbUUID:u,thumbFormat:l,thumbWidth:d,snapshotWidth:h,thumbHeight:g,snapshotHeight:p,thumbSize:_,snapshotSize:m,thumbDownloadFlag:v,thumbUrl:f,snapshotUrl:I}=s;return{MsgType:this.type,MsgContent:{VideoUrl:nr.removeAuthToUrl(n),VideoFormat:o,VideoSecond:i,VideoSize:r,VideoDownloadFlag:a,VideoUUID:c,ThumbUUID:u,ThumbFormat:l,ThumbWidth:d,SnapshotWidth:h,ThumbHeight:g,SnapshotHeight:p,ThumbSize:_,SnapshotSize:m,ThumbDownloadFlag:v,ThumbUrl:nr.removeAuthToUrl(f),SnapshotUrl:nr.removeAuthToUrl(I)}}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t}=e,{VideoUrl:s,VideoFormat:n,VideoSecond:o,VideoSize:i,VideoDownloadFlag:r,VideoUUID:a,ThumbUUID:c,ThumbFormat:u,ThumbWidth:l,SnapshotWidth:d,ThumbHeight:h,SnapshotHeight:g,ThumbSize:p,SnapshotSize:_,ThumbDownloadFlag:m,ThumbUrl:v,SnapshotUrl:f}=t;return new $r({videoUrl:s,videoFormat:n,videoSecond:o,videoSize:i,videoUUID:a,thumbUUID:c,thumbFormat:u,thumbWidth:l,thumbHeight:h,thumbSize:p,thumbUrl:v})}}])}();Fr=tr;var xr,qr=new(function(){return _createClass(function _class47(){_classCallCheck(this,_class47),this._messageOptionsMap=new Map},[{key:"init",value:function init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createVideoMessage",context:this}),n.registerExperimentalAPI("createVideoMessage",this,"createCustomUploadVideoMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(Ki,$r),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}},{key:"createVideoMessage",value:function createVideoMessage(e){var t,s,n;try{const o=this._processVideo(e);e.payload.file=o;const i=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:i})),a={videoFormat:o.videoFile.type,videoSecond:qi(o.videoFile.second,0),videoSize:o.videoFile.size,remoteVideoUrl:"",videoUrl:o.videoFile.url,videoUUID:nr.generateUUID(o.videoFile),thumbUUID:nr.generateUUID(o.videoFile,"jpg"),thumbWidth:o.width||200,thumbHeight:o.height||200,thumbUrl:o.thumbUrl,thumbSize:o.thumbSize,thumbFormat:"jpg"},c=new $r(a);return r.setElement(c),this._messageOptionsMap.set(r.clientSequence,e),r}catch(e){throw e}}},{key:"createCustomUploadVideoMessage",value:function createCustomUploadVideoMessage(e){var t,s,n;try{const{store:o,message:i}=this._core;this._validateCustomUploadVideoMessage(e);const r=null===(t=o.get("login"))||void 0===t?void 0:t.userId,{videoUrl:a,videoUuid:c,duration:u,snapshotUrl:l,snapshotUuid:d,videoFileSize:h,videoType:g,snapshotWidth:p,snapshotHeight:_,snapshotFileSize:m,snapshotType:v="jpg"}=(null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.file)||{},f=null===(n=i.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:r})),I=new $r({videoFormat:g,videoSecond:u||0,videoSize:h,remoteVideoUrl:a,videoUrl:a,videoUUID:c,thumbUUID:d,thumbWidth:p||200,thumbHeight:_||200,thumbUrl:l,thumbSize:m,thumbFormat:v,isCustomUpload:!0});return f.setElement(I),this._messageOptionsMap.set(f.clientSequence,e),f}catch(e){throw e}}},{key:"upload",value:function upload(e){return pe(this,void 0,void 0,function*(){const t=e.getElements()[0],{file:s}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadVideo(s);const n=yield this._performVideoUpload(t,e,s),{location:o,snapshotInfo:i}=n,r=nr.addAuthToUrl(o);return t.updateVideoUrl(r),nr.isEmpty(i)||t.updateSnapshotInfo(i),e})}},{key:"_validateBeforeUploadVideo",value:function _validateBeforeUploadVideo(e){const{helper:{ChatError:t}}=this._core,s=Mr(2)||104857600;if(e.videoFile.size>s)throw new t({code:2351});if(0===e.videoFile.size)throw new t({code:2108});if(-1===kr.indexOf(e.videoFile.type))throw new t({code:2352})}},{key:"_validateCustomUploadVideoMessage",value:function _validateCustomUploadVideoMessage(e){var t;const{utils:{isEmpty:s,isNumber:n}}=this._core,{videoUrl:o,videoUuid:i,duration:r,snapshotUrl:a,snapshotUuid:c}=(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.file)||{};if(s(o)||s(i)||!n(r)||s(a)||s(c))throw new Error("Invalid video message options: missing required fields (videoUrl, videoUuid, duration, snapshotUrl, snapshotUuid)")}},{key:"_performVideoUpload",value:function _performVideoUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:2,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{response:i,uploadOptions:r}=yield ar.uploadToCOS(o);return{snapshotInfo:yield this._getSnapshotInfoByUrl(r.requestSnapshotUrl),location:i.location}})}},{key:"_processVideo",value:function _processVideo(e){var t,s;try{const{ChatError:n}=null===(t=this._core)||void 0===t?void 0:t.helper,{IN_MINI_APP:o,IN_BROWSER:i}=null===(s=this._core)||void 0===s?void 0:s.utils;let{file:r}=e.payload,a={};if(o&&(a=this._processMiniVideoFile(r),r.name=a.name,r.url=a.url,r.type=a.type),i){const e=nr.extractFileFromInput(r);if(!e)throw new n({message:"Invalid file. Pass either `e.target` (from file input) or a File object"});r=e,a=this._processWebVideoFile(r)}return r.videoFile=a,r.thumbUrl="",r.thumbSize=0,r}catch(e){throw console.warn(`${Wi} _processFile error:`,e),e}}},{key:"_processMiniVideoFile",value:function _processMiniVideoFile(e){const{utils:{IN_UNI_NATIVE_APP:t},helper:{ChatError:s}}=this._core;if(ki(e))throw new s({message:"FileUnsupportedInMiniApp"});Array.isArray(e.tempFiles)&&(e=e.tempFiles[0]);let n=e.tempFilePath.slice(e.tempFilePath.lastIndexOf(".")+1).toLowerCase();return t&&(n=e.fileType||n),{url:e.tempFilePath,name:e.tempFilePath.slice(e.tempFilePath.lastIndexOf("/")+1),size:e.size||1,second:e.duration||0,type:n}}},{key:"_processWebVideoFile",value:function _processWebVideoFile(e){const{name:t,size:s=1,duration:n=0,type:o}=e,i=o.split("/")[1];return{url:window.URL.createObjectURL(e),name:t,size:s,second:n,type:i}}},{key:"_getSnapshotInfoByUrl",value:function _getSnapshotInfoByUrl(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core;try{t.debug("_getSnapshotInfoByUrl",`${Wi} _getSnapshotInfoByUrl url:${e}`);const s={version:1,platform:nr.getPlatform(),cover_name:xi(Fi(99999)),snapshot_url:e},n=yield function(e,t){return pe(this,void 0,void 0,function*(){try{const s="im_cos_msg.video_cover",{helper:n,channel:o}=t,i=n.generateCosSpecifiedData({servcmd:s,data:e}),r=`${i.head.seq}${s}`;return yield o.sendPacket(i,{requestId:r})}catch(e){throw console.warn("getSnapshotInfo error:",e),e}})}(s,this._core),{download_url:o}=n||{};if(t.debug("_getSnapshotInfoByUrl",`${Wi} _getSnapshotInfoByUrl OK snapshotUrl:${o}`),nr.isEmpty(o))return{};const i=nr.addAuthToUrl(o),{width:r=0,height:a=0}=yield nr.probeImageWidthHeight(i);return{snapshotUrl:i,snapshotWidth:r,snapshotHeight:a}}catch(e){throw e}})}},{key:"_reset",value:function _reset(){this._messageOptionsMap.clear()}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}])}());let Vr=function(){function Vr(e){_classCallCheck(this,Vr),this.uploadProgress=0,this.type=ji,this[xr]=!1,this[tr]=e.isCustomUpload||!1,this.content={downloadFlag:2,second:e.second,size:e.size,url:nr.generateURL(e.url,{needAddAuthToUrl:!this[tr]}),remoteAudioUrl:nr.addAuthToUrl(e.url||""),uuid:e.uuid}}return _createClass(Vr,[{key:"updatePercent",value:function updatePercent(e){this.uploadProgress=Math.min(e,1)}},{key:"updateAudioUrl",value:function updateAudioUrl(e){this.content.remoteAudioUrl=e}},{key:"validateBeforeSend",value:function validateBeforeSend(){if(this[tr])return{isValid:!0};const e=""!==this.content.remoteAudioUrl;return{isValid:e,error:e?null:{message:"content can not be empty"}}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{uuid:n,downloadFlag:o,remoteAudioUrl:i,size:r,second:a}=s;return{MsgType:this.type,MsgContent:{Url:nr.removeAuthToUrl(i),Download_Flag:o,Second:a,Size:r,UUID:n}}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t}=e,{Url:s,Download_Flag:n,Second:o,Size:i,UUID:r}=t;return new Vr({url:s,second:o,size:i,uuid:r})}}])}();xr=tr;var Kr=new(function(){return _createClass(function _class48(){_classCallCheck(this,_class48),this._messageOptionsMap=new Map},[{key:"init",value:function init(e){var t;this._core=e;const{notificationCenter:s,helper:n,InnerEvent:o,message:i}=e;n.registerApi({apiName:"createAudioMessage",context:this}),n.registerExperimentalAPI("createAudioMessage",this,"createCustomUploadAudioMessage"),null===(t=null==i?void 0:i.messageFactory)||void 0===t||t.registerElementClass(ji,Vr),s.subscribeInnerEvent(o.DESTROY,this._dispose,this)}},{key:"createAudioMessage",value:function createAudioMessage(e){var t,s,n;try{let{file:o}=e.payload;o=this._processAudioFile(e.payload.file),e.payload.file=o;const i=null===(t=this._core.store.get("login"))||void 0===t?void 0:t.userId,r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:i})),a={second:Math.max(1,Math.round((o.duration||o.second)/1e3)),size:o.fileSize||o.size||1,url:o.tempFilePath||o.uri||o.url,uuid:nr.generateUUID(o)},c=new Vr(a);return r.setElement(c),this._messageOptionsMap.set(r.clientSequence,e),r}catch(e){throw e}}},{key:"createCustomUploadAudioMessage",value:function createCustomUploadAudioMessage(e){var t,s,n;try{this._validateCustomUploadOptions(e);const{store:o,message:i}=this._core,r=null===(t=o.get("login"))||void 0===t?void 0:t.userId,{url:a,uuid:c,duration:u,fileSize:l}=(null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.file)||{},d=null===(n=i.messageFactory)||void 0===n?void 0:n.createMessage(Object.assign(Object.assign({},e),{from:r})),h=new Vr({second:u,size:l||1,url:a,uuid:c,isCustomUpload:!0});return d.setElement(h),this._messageOptionsMap.set(d.clientSequence,e),d}catch(e){throw e}}},{key:"upload",value:function upload(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;t.debug("upload",`${Wi} uploadAudio message:${s(e)}`);const{file:n}=this._messageOptionsMap.get(e.clientSequence).payload;this._validateBeforeUploadAudio(n);const o=e.getElements()[0],i=yield this._performAudioUpload(o,e,n),r=nr.addAuthToUrl(null==i?void 0:i.location);return o.updateAudioUrl(r),e})}},{key:"_validateBeforeUploadAudio",value:function _validateBeforeUploadAudio(e){const{helper:{ChatError:t},store:s}=this._core;if(!e)throw new t({code:2300});const n=Mr(3)||20971520;if(e.size>n)throw new t({code:2301});if(0===e.size)throw new t({code:2108})}},{key:"_performAudioUpload",value:function _performAudioUpload(e,t,s){return pe(this,void 0,void 0,function*(){const{to:n}=t,o={uploadFileType:3,file:s,to:n,message:t,onProgress:s=>{var n,o;e.updatePercent(s),null===(o=null===(n=this._messageOptionsMap.get(t.clientSequence))||void 0===n?void 0:n.onProgress)||void 0===o||o.call(n,s)}},{response:i}=yield ar.uploadToCOS(o);return i})}},{key:"_processAudioFile",value:function _processAudioFile(e){var t;const{IN_MINI_APP:s,IN_BROWSER:n}=null===(t=this._core)||void 0===t?void 0:t.utils;return s?this._processMiniFile(e):n?this._processWebFile(e):void 0}},{key:"_processMiniFile",value:function _processMiniFile(e){return{url:e.tempFilePath,name:e.tempFilePath.slice(e.tempFilePath.lastIndexOf("/")+1),size:e.fileSize,second:e.duration,type:e.tempFilePath.slice(e.tempFilePath.lastIndexOf(".")+1).toLowerCase()}}},{key:"_processWebFile",value:function _processWebFile(e){if(e.tempFilePath||e.uri)return e;const t=URL.createObjectURL(e);return e.tempFilePath=t,e}},{key:"_validateCustomUploadOptions",value:function _validateCustomUploadOptions(e){var t;const{utils:{isEmpty:s}}=this._core,{url:n,uuid:o,duration:i}=(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.file)||{};if(s(n)||s(o)||s(i))throw new Error("Invalid audio message options")}},{key:"_reset",value:function _reset(){this._messageOptionsMap.clear()}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}])}());const Wr={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},onProgress:{required:!1,rules:["function"],allowEmpty:!1}},Yr={createImageMessage:Wr,createAudioMessage:Wr,createVideoMessage:Wr,createFileMessage:Wr},zr={createImageMessage:!0,createAudioMessage:!0,createVideoMessage:!0,createFileMessage:!0},Jr={[Bi]:yr,[Hi]:Pr,[Ki]:qr,[ji]:Kr};var Qr=new(function(){return _createClass(function _class49(){_classCallCheck(this,_class49),this.name="RichMediaMessage"},[{key:"install",value:function install(e){this._core=e;const{constants:{OuterConstant:{MSG_AUDIO:t,MSG_FILE:s,MSG_IMAGE:n,MSG_VIDEO:o}}}=e;Ir.init(e),yr.init(e),Pr.init(e),qr.init(e),Kr.init(e),ar.init(e),nr.init(e),e.helper.registerApi({apiName:"sendMessage",context:this,matcher:e=>[t,s,n,o].includes(e[0].type)}),e.helper.registerValidateConfig({auth:zr,params:Yr})}},{key:"sendMessage",value:function sendMessage(e,t){return pe(this,void 0,void 0,function*(){var s,n,o;try{return this._isCustomUpload(e)||(yield this._upload(e)),yield null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageSender)||void 0===o?void 0:o.sendMessage(e,t)}catch(e){throw e}})}},{key:"_upload",value:function _upload(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{safeStringify:s}}=this._core;if(t.debug("_upload",` uploadFile message:${s(e)}`),!0!==e._relayFlag)try{const s=Jr[e.type];s&&(yield s.upload(e),t.info("_upload",` type:${e.type}`))}catch(t){throw e.status=Zi.FAIL,t instanceof Error&&(t.data={message:e}),this._core.message.messageDataHandler.storeConversationMessage(e),t}})}},{key:"_isCustomUpload",value:function _isCustomUpload(e){var t,s;return!0===(null===(s=null===(t=e._elements)||void 0===t?void 0:t[0])||void 0===s?void 0:s[tr])}}])}());const Xr=new(function(){return _createClass(function _class50(){_classCallCheck(this,_class50)},[{key:"init",value:function init(e){this.core=e}}])}());let Zr=function(){return _createClass(function Zr(e){_classCallCheck(this,Zr),this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=Xr.core.common.buildLastMessage(e.lastMessage),this.peerReadTime=e.peerReadTime||0,this.groupAtInfoList=[],this.remark=e.remark||"",this.isPinned=e.isPinned||!1,this.messageRemindType=e.messageRemindType,this.markList=e.markList||[],this.customData=e.customData||"",this.conversationGroupList=e.conversationGroupList||[],this.draftText=e.draftText||"",this.userProfile=e.userProfile,this.groupProfile=e.groupProfile,this.subType=e.subType||"",this._isInfoCompleted=!1,this._init()},[{key:"_init",value:function _init(){var e;const{core:{OuterConstant:t,utils:{isUndefined:s}}}=Xr;s(this.userProfile)&&this.type===t.CONV_C2C?this.userProfile={userID:this.conversationID.replace(t.CONV_C2C,"")}:this.type===t.CONV_GROUP&&(!this.subType&&(null===(e=this.groupProfile)||void 0===e?void 0:e.type)&&(this.subType=this.groupProfile.type),s(this.groupProfile)&&(this.groupProfile={groupID:this.conversationID.replace(t.CONV_GROUP,""),selfInfo:{},lastMessage:{},type:this.subType}))}},{key:"updateUnreadCount",value:function updateUnreadCount(e){var t;const{core:{OuterConstant:s,utils:{isUndefined:n},store:o}}=Xr,{nextUnreadCount:i,isFromGetConversations:r,isUnreadC2CMessage:a}=e;if(n(i))return;if(this.subType===s.GRP_AVCHATROOM)return void(this.unreadCount=0);if(r&&this.type===s.CONV_GROUP)return void(this.unreadCount=i);if(a&&this.type===s.CONV_C2C)return void(this.unreadCount=i);const c="1"===(null===(t=o.get("cloudConfig"))||void 0===t?void 0:t.support_unread_count_for_meeting);this.subType!==s.GRP_MEETING||c?this.unreadCount+=i:this.unreadCount=0}},{key:"updateLastMessage",value:function updateLastMessage(e){this.lastMessage=Xr.core.common.buildLastMessage(e)}},{key:"reduceUnreadCount",value:function reduceUnreadCount(){return this.unreadCount>=1&&(this.unreadCount-=1,!0)}},{key:"isLastMessageRevoked",value:function isLastMessageRevoked(e){const{core:{OuterConstant:t}}=Xr,{sequence:s,time:n}=e;return this.type===t.CONV_C2C&&s===this.lastMessage.lastSequence&&n===this.lastMessage.lastTime||this.type===t.CONV_GROUP&&s===this.lastMessage.lastSequence}},{key:"setLastMessageRevoked",value:function setLastMessageRevoked(e){this.lastMessage.isRevoked=e}},{key:"setLastMessageRevoker",value:function setLastMessageRevoker(e){this.lastMessage.revoker=e}},{key:"setDraftText",value:function setDraftText(e){this.draftText=e}},{key:"updateGroupAtInfoList",value:function updateGroupAtInfoList(e){const{core:{common:{updateGroupAtInfo:t}}}=Xr;t(e,this.groupAtInfoList)}},{key:"clearGroupAtInfoList",value:function clearGroupAtInfoList(){this.groupAtInfoList.length=0}},{key:"getProfileCompleted",value:function getProfileCompleted(){return this._isInfoCompleted}},{key:"setProfileCompleted",value:function setProfileCompleted(){this._isInfoCompleted=!0}}])}();const ea=e=>{const{core:{OuterConstant:t,utils:{isString:s}}}=Xr;return s(e)&&e.slice(0,3)===t.CONV_C2C},ta=e=>{const{core:{OuterConstant:t,utils:{isString:s}}}=Xr;return s(e)&&e.slice(0,5)===t.CONV_GROUP},sa=e=>{const{core:{OuterConstant:t,utils:{isString:s}}}=Xr;return s(e)&&e===t.CONV_SYSTEM};function na(e){const{OuterConstant:t}=Xr.core;let s="";return 0===e?s=t.MSG_REMIND_ACPT_AND_NOTE:1===e?s=t.MSG_REMIND_DISCARD:2===e?s=t.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(s=t.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),s}function oa(e){const{OuterConstant:t}=Xr.core;let s;return e.startsWith(t.CONV_C2C)&&(s=e.replace(t.CONV_C2C,"")),"@TLS#ERROR"===s||"@TLS#NOT_FOUND"===s}function ia(e,t){const{helper:s}=Xr.core,n=new s.ChatError({functionName:e,code:(null==t?void 0:t.errorCode)||(null==t?void 0:t.code),message:(null==t?void 0:t.errorInfo)||(null==t?void 0:t.message)});throw console.error(`${e} fail:`,n),n}var ra,aa,ca;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON"}(ra||(ra={})),function(e){e[e.ONLY_CONVERSATIONID=1]="ONLY_CONVERSATIONID"}(aa||(aa={})),function(e){e[e.CONV_NOT_FOUND=2500]="CONV_NOT_FOUND",e[e.USER_OR_GRP_NOT_FOUND=2501]="USER_OR_GRP_NOT_FOUND",e[e.CONV_UN_RECORDED_TYPE=2502]="CONV_UN_RECORDED_TYPE"}(ca||(ca={}));var da=new(function(){return _createClass(function _class51(){_classCallCheck(this,_class51),this._name="GetC2CMessageRemindType"},[{key:"init",value:function init(e){this._core=e}},{key:"get",value:function get(e){return pe(this,void 0,void 0,function*(){try{const{common:t}=this._core,s=yield function(e,t){return pe(this,void 0,void 0,function*(){const{toAccount:s,userIDList:n}=e,o={To_Account:s,Peer_Account:n};return t.common.buildAndSendPacket({servcmd:"openim.get_c2c_peer_mute_notifications",data:o})})}({toAccount:t.getCurrentUserID(),userIDList:e},this._core),{MuteNotificationsList:n=[]}=s||{};n.forEach(e=>{const{Peer_Account:t,MuteNotifications:s}=e,n=`${this._core.OuterConstant.CONV_C2C}${t}`,o=na(s);ga.patchMessageRemindType([n],o)})}catch(e){console.error(`${this._name}.get fail:`,e)}})}}])}()),ha=new(function(){return _createClass(function _class52(){_classCallCheck(this,_class52),this._name="GetGroupMessageRemindType"},[{key:"init",value:function init(e){this._core=e}},{key:"get",value:function get(e){return pe(this,void 0,void 0,function*(){if(0!==e.length)try{const t=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupIDList:s,responseFilter:n}=e,o={GroupIdList:s,ResponseFilter:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:o})})}({groupIDList:e,responseFilter:{MemberInfoFilter:["MsgFlag"]}},this._core),{GroupInfo:s=[]}=t||{};s.forEach(e=>{var t;const{GroupId:s,MemberList:n}=e,o=(null===(t=n[0])||void 0===t?void 0:t.MsgFlag)||"",i=`${this._core.OuterConstant.CONV_GROUP}${s}`;ga.patchMessageRemindType([i],o)})}catch(e){console.error(`${this._name}.get fail:`,e)}})}}])}()),ga=new(function(){return _createClass(function _class53(){_classCallCheck(this,_class53),this._name="ConversationDataHandler",this._totalUnreadCount=0,this._groupAtTipsList=[]},[{key:"init",value:function init(e){this._core=e;const{helper:t,notificationCenter:s,appStore:{conversationStore:n},constants:{WORKFLOW_NAME:o,WORKFLOW_STEP:i},InnerEvent:{SYNC_CONVERSATION_LIST:r,MESSAGE_PUSH:a,NEW_MESSAGE:c,MESSAGE_DELETED:u,MESSAGE_REVOKED:l,MESSAGE_MODIFIED:d,CONVERSATION_UPDATED:h,LOGOUT:g,DESTROY:p},InnerEventSubType:{C2C_MESSAGE_PEER_READ:_}}=e;this._conversationStore=n,t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,i.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_LOGIN,i.CONVERSATION_UPDATE_AFTER_GROUP_LIST_SYNC_FINISHED,this._handleGroupListSyncFinished,this),t.registerWorkflowStep(o.RECEIVE_C2C_NEW_MESSAGE,i.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),t.registerWorkflowStep(o.RECEIVE_C2C_NEW_MESSAGE,i.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(o.RECEIVE_GROUP_NEW_MESSAGE,i.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this),t.registerWorkflowStep(o.SYNC_SERVER_INFO_AFTER_RE_ONLINE,i.CONVERSATION_UPDATE_AFTER_UNREAD_SYNC_FINISHED,this._handleUnreadSyncFinished,this),t.registerWorkflowStep(o.RECEIVE_GROUP_TIPS_NOTIFICATION,i.CREATE_OR_UPDATE_CONVERSATION_BY_RECEIVE_NEW_MESSAGE,this._handleNewMessage,this);const{InnerEventSubType:{GROUP_AT_TIPS:m}}=s;s.subscribeInnerEvent(r,this._handleConversationSynced,this),s.subscribeInnerEvent(c,this._handleNewMessage,this),s.subscribeInnerEvent(a,m,this._handleNewGroupAtTips,this),s.subscribeInnerEvent(u,this._handleMessageDeleted,this),s.subscribeInnerEvent(l,this._handleMessageRevoked,this),s.subscribeInnerEvent(d,this._handleMessageModified,this),s.subscribeInnerEvent(h,this._handleConversationUpdated,this),s.subscribeInnerEvent(a,_,this._handleMessageRead,this),s.subscribeInnerEvent(g,this._reset,this),s.subscribeInnerEvent(p,this._dispose,this),e.ssoLog.debug(`${this._name}.init`)}},{key:"_handleConversationSynced",value:function _handleConversationSynced(e){this.updateLocalConversationList({conversationUpdateFieldList:e.conversationUpdateFieldList||[],isFromGetConversations:!0,updateUnreadCount:!0}),this.emitConversationListUpdate()}},{key:"_handleUnreadSyncFinished",value:function _handleUnreadSyncFinished(e){const{constants:{WORKFLOW_STEP:t}}=this._core,{conversationUpdateFieldList:s=[],groupTipList:n=[],isUnreadC2CMessage:o}=e.result[t.UNREAD_MESSAGE_SYNC]||{};let i=!1;s.forEach(e=>{const{conversationID:t,unreadCount:s}=e,n=this.getLocalConversation(t);n&&n.unreadCount!==s&&(n.updateUnreadCount({nextUnreadCount:s,isUnreadC2CMessage:o}),i=!0)}),i&&this.emitConversationListUpdate(),this._handleGroupAtTipsSynced(n)}},{key:"_handleGroupAtTipsSynced",value:function _handleGroupAtTipsSynced(e){var t;for(let s=0;s<e.length;s++)if(12===e[s].Event){if(null===(t=e[s].GroupTips[0].MsgBody)||void 0===t?void 0:t.TopicId)continue;this._handleNewGroupAtTips(e[s])}}},{key:"_handleGroupListSyncFinished",value:function _handleGroupListSyncFinished(e){var t;const{constants:{WORKFLOW_STEP:s}}=this._core,n=e.result[s.GROUP_LIST_SYNC]||[],{OuterConstant:{CONV_GROUP:o}}=this._core;let i=!1;for(let e=0;e<n.length;e++){const s=n[e],r=`${o}${s.groupID}`;if(!this.hasLocalConversation(r))continue;const a=this.getLocalConversation(r);a.groupProfile=JSON.parse(JSON.stringify(s)),a.lastMessage.lastSequence<s.nextMessageSeq&&(a.lastMessage.lastSequence=s.nextMessageSeq-1),a.subType||(a.subType=s.type),(null===(t=s._groupAtInfoList)||void 0===t?void 0:t.length)>0&&this._handleNewGroupAtTips({GroupTips:s._groupAtInfoList}),i=!0}i&&this.emitConversationListUpdate()}},{key:"_handleNewMessage",value:function _handleNewMessage(e){const{conversationUpdateFieldList:t=[],isInstantMessage:s=!0,isUnreadC2CMessage:n=!1,updateUnreadCount:o=!0}=e.result||{};if(0===t.length)return;const{common:{isTopic:i}}=this._core;i(t[0].conversationID)||(this.updateLocalConversationList({conversationUpdateFieldList:t,isInstantMessage:s,isUnreadC2CMessage:n,isFromGetConversations:!1,updateUnreadCount:o}),t.filter(e=>this._isConversationNeedShow(e.conversationID)).length>0&&this.emitConversationListUpdate())}},{key:"_handleNewGroupAtTips",value:function _handleNewGroupAtTips(e){const{GroupTips:t=[]}=e;t.forEach(e=>{const{GroupAtTips:t,MsgBody:s,MsgRandom:n,ClientSeq:o}=e;let i={};t?i=this._convertGroupAtTipsKey(t):s?i=Object.assign({},this._convertGroupAtTipsKey(s)):e.groupAtType&&(i=Object.assign({},e)),i.__random=n,i.__sequence=o,this._groupAtTipsList.push(i)}),console.log(`${this._name}._handleNewGroupAtTips groupAtTipsList: ${JSON.stringify(this._groupAtTipsList)}`),this._updateGroupAtInfoList()}},{key:"_convertGroupAtTipsKey",value:function _convertGroupAtTipsKey(e){const{From_Account:t,GroupId:s,MsgSeq:n,GroupAtType:o}=e;return{from:t,groupID:s,sequence:n,groupAtType:o}}},{key:"_updateGroupAtInfoList",value:function _updateGroupAtInfoList(){if(0===this._groupAtTipsList.length)return;const{common:e,OuterConstant:t}=this._core,s=e.getCurrentUserID();let n=!1;this._groupAtTipsList.forEach(e=>{const{groupID:o,from:i}=e;if(i!==s){const s=this.getLocalConversation(`${t.CONV_GROUP}${o}`);s&&(s.updateGroupAtInfoList(e),n=!0)}}),n&&this.emitConversationListUpdate(),this._groupAtTipsList.length=0}},{key:"_handleMessageDeleted",value:function _handleMessageDeleted(e){var t,s;console.log(`${this._name}._handleMessageDeleted, conversationID:`,e);const{message:{messageDataHandler:n},OuterConstant:o}=this._core,i=(null==n?void 0:n.getLocalMessageList(e))||[];let r={};for(let e=(i.length||0)-1;e>=0;e--)if(!i[e].isDeleted&&!0!==i[e]._isExcludedFromLastMessage){r=i[e];break}const a=this.getLocalConversation(e);if(!a)return;let c=!1;a.lastMessage.lastSequence===r.sequence&&a.lastMessage.lastTime===r.time||((null===(s=null===(t=this._core)||void 0===t?void 0:t.helper)||void 0===s?void 0:s.isEmpty(r))&&(r=void 0),a.updateLastMessage(r),c=!0),e.startsWith(o.CONV_C2C)&&this.updateUnreadCount(e),c&&(this.emitConversationListUpdate(),console.log(`${this._name}._handleMessageDeleted. update conversationID:${e} with lastMessage:`,a.lastMessage))}},{key:"_handleMessageRevoked",value:function _handleMessageRevoked(e){const{messageList:t=[],updateUnreadCount:s=!0}=e;if(console.log(`${this._name}._handleMessageRevoked messageList:${t.length}`),0===t.length)return;let n=null,o=!1;t.forEach(e=>{n=this.getLocalConversation(e.conversationID),n&&(s&&n.reduceUnreadCount()&&(o=!0),n.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(n.setLastMessageRevoked(!0),n.setLastMessageRevoker(e.revoker),o=!0))}),o&&this.emitConversationListUpdate()}},{key:"_handleMessageModified",value:function _handleMessageModified(e){const{utils:{isEmpty:t},common:{getMessagePreviewText:s},ssoLog:n}=this._core;n.debug(`${this._name}._handleMessageModified`,JSON.stringify(e));const{conversationID:o,messageList:i}=e,r=this.getLocalConversation(o);if(t(r))return;const{lastMessage:a}=r;if(a){const e=(null==i?void 0:i[0])||{};a.lastTime===e.time&&a.lastSequence===e.sequence&&a.version!==e.version&&(a.type=e.type,a.payload=e.payload,a.messageForShow=s(e.type,e.payload),a.cloudCustomData=e.cloudCustomData,a.version=e.version,this.emitConversationListUpdate(),console.log(`${this._name} conversationID:${o} lastMessage updated`))}}},{key:"_handleConversationUpdated",value:function _handleConversationUpdated(e){this.emitConversationListUpdate(null==e?void 0:e.needSort)}},{key:"updateLocalConversationList",value:function updateLocalConversationList(e){const{isFromGetConversations:t}=e,{newConversationList:s}=this._getTmpConversationListMapping(e);this._sortConversationList(),t||this._updateNewConversationProfile(s),this._core.ssoLog.debug("updateLocalConversationList",` newConversationList: ${s.length}`)}},{key:"_getTmpConversationListMapping",value:function _getTmpConversationListMapping(e){const{OuterConstant:t}=this._core,{conversationUpdateFieldList:s,isFromGetConversations:n,isInstantMessage:o,isUnreadC2CMessage:i=!1,updateUnreadCount:r}=e,a=[],c=null==s?void 0:s.length;for(let e=0;e<c;e++){const c=new Zr(s[e]),{conversationID:u,type:l}=c;if(!oa(u))if(this.hasLocalConversation(u)){const a=this.getLocalConversation(u);if(n){this.setLocalConversation(u,c),l===t.CONV_C2C?c.unreadCount=(null==a?void 0:a.unreadCount)||0:l===t.CONV_GROUP&&(c.groupProfile=JSON.parse(JSON.stringify(null==a?void 0:a.groupProfile)));continue}this._mergeConversationInfo({conversationID:u,tmpConversation:c,lastMessage:s[e].lastMessage,isFromGetConversations:n,isInstantMessage:o}),this._patchLastMessage({conversationID:u,lastMessage:s[e].lastMessage,isInstantMessage:o}),!0===r&&(null==a||a.updateUnreadCount({nextUnreadCount:c.unreadCount,isFromGetConversations:n,isUnreadC2CMessage:i}))}else a.push(c),this.setLocalConversation(u,c)}return{newConversationList:a}}},{key:"_mergeConversationInfo",value:function _mergeConversationInfo(e){const{conversationID:t,tmpConversation:s,lastMessage:n,isFromGetConversations:o,isInstantMessage:i}=e,r=this.getLocalConversation(t),a=["unreadCount","allowType","adminForbidType","payload"];!1===i&&a.push("lastMessage"),o||a.push("isPinned");const{utils:{isUndefined:c,isEmpty:u},common:{deepMerge:l}}=this._core;c(i)&&n&&null===(null==r?void 0:r.lastMessage.payload)&&(r.lastMessage.payload=n.payload),u(null==r?void 0:r.lastMessage.revoker)||(r.lastMessage.revoker=null),l(r,s,a,[null,void 0,"",0,NaN])}},{key:"_patchLastMessage",value:function _patchLastMessage(e){const{OuterConstant:t}=this._core,{conversationID:s,lastMessage:n,isInstantMessage:o}=e,i=this.getLocalConversation(s);if(i&&n){const{payload:e,nameCard:s,nick:r,cloudCustomData:a="",version:c=0}=n;o&&(e&&(i.lastMessage.payload=e),i.type===t.CONV_GROUP&&(i.lastMessage.nameCard=s,i.lastMessage.nick=r),i.lastMessage.version=c),i.lastMessage.cloudCustomData!==a&&(i.lastMessage.cloudCustomData=a)}}},{key:"_sortConversationList",value:function _sortConversationList(){const{utils:{isEmpty:e}}=this._core,t=[...this._conversationStore.getConversationMap()],s=[],n=[],o=[],i=[];t.forEach(t=>{!0===t[1].isPinned?e(t[1].lastMessage.lastTime)?n.push(t):s.push(t):e(t[1].lastMessage.lastTime)?i.push(t):o.push(t)});const r=s.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime).concat(n).concat(o.sort((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime)).concat(i);this._updateConversationMapFromList(r)}},{key:"_updateNewConversationProfile",value:function _updateNewConversationProfile(e){if(0===e.length)return;const t=[],s=[],{OuterConstant:{CONV_GROUP:n,CONV_C2C:o}}=this._core;e.forEach(e=>{const{conversationID:i,type:r}=e;if(r===o){const e=i.replace(o,"");t.push(e)}else if(r===n){const e=i.replace(n,"");s.push(e)}}),t.length>0&&this._updateC2CConversation(t),s.length>0&&this._updateGroupConversation(s)}},{key:"_updateC2CConversation",value:function _updateC2CConversation(e){var t;const{OuterConstant:{CONV_C2C:s},appStore:{userStore:n},user:o}=this._core;let i=!1;null===(t=o.userProfile)||void 0===t||t.getUserProfile({userIDList:e}).then(e=>{((null==e?void 0:e.data)||[]).forEach(e=>{var t;const{userID:o}=e,r=this.getLocalConversation(`${s}${o}`);if(r){const s=(null===(t=n.getFriend(o))||void 0===t?void 0:t.remark)||"";r.remark=s,r.userProfile=e,i=!0}}),i&&this.emitConversationListUpdate()}).catch(e=>{}),da.get(e)}},{key:"_updateGroupConversation",value:function _updateGroupConversation(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:{CONV_GROUP:t},appStore:{groupStore:s},utils:{safeStringify:n},ssoLog:o,apiMap:{getGroupProfile:i}}=this._core;let r=!1;try{yield Promise.all(e.map(e=>pe(this,void 0,void 0,function*(){const n=s.getGroup(e),o=this.getLocalConversation(`${t}${e}`);n&&o&&(o.groupProfile=n,r=!0),o&&!o.getProfileCompleted()&&"function"==typeof i&&(yield i({groupID:e}))}))),ha.get(e),r&&this.emitConversationListUpdate()}catch(e){o.debug("_updateGroupConversation",n(e))}})}},{key:"_handleMessageRead",value:function _handleMessageRead(e){const{OuterConstant:{CONV_C2C:t}}=this._core,{C2cNotifyMsgArray:s=[]}=e||{};s.forEach(e=>{const{To_Account:s,UinPairReadArray:n=[]}=(null==e?void 0:e.C2cReadedReceipt)||{};null==n||n.forEach(e=>{const{LastReadTime:n}=e,o=`${t}${s}`;this._updateConversationReadInfo({conversationID:o,peerReadTime:n}),this._updateMessageListPeerRead({conversationID:o,peerReadTime:n})})})}},{key:"_updateConversationReadInfo",value:function _updateConversationReadInfo(e){const{appStore:t,utils:{isEmpty:s},common:{getCurrentUserID:n}}=this._core,{conversationID:o,peerReadTime:i}=e,r=t.conversationStore.getConversationMap();if(r.has(o)){const e=r.get(o);e.peerReadTime=i;const a=null==e?void 0:e.lastMessage;s(a)||a.fromAccount===n()&&a.lastTime<=i&&!a.isPeerRead&&(a.isPeerRead=!0,t.conversationStore.updateConversation(o,{lastMessage:a}))}}},{key:"_updateMessageListPeerRead",value:function _updateMessageListPeerRead(e){const{notificationCenter:t,OuterEvent:s,message:n}=this._core,{conversationID:o,peerReadTime:i}=e,r=n.messageDataHandler.getLocalMessageList(o),a=n.messageDataHandler.getSparseMessageList(o),c=[];r.forEach(e=>{e.time<=i&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,c.push(e))}),a.forEach(e=>{e.time<=i&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,c.push(e))}),t.emitOuterEvent(s.MESSAGE_READ_BY_PEER,{name:s.MESSAGE_READ_BY_PEER,data:c})}},{key:"_isConversationNeedShow",value:function _isConversationNeedShow(e){var t,s;const{OuterConstant:{CONV_GROUP:n,GRP_ROOM:o,GRP_LIVE:i},utils:{isUndefined:r}}=this._core,a=this.getLocalConversation(e);if(r(a))return!0;const c=a.type===n&&(null===(t=a.groupProfile)||void 0===t?void 0:t.type)===o,u=a.type===n&&(null===(s=a.groupProfile)||void 0===s?void 0:s.type)===i;return!(c||u)}},{key:"updateUnreadCount",value:function updateUnreadCount(e,t=!0){var s,n;let o=!1;const i=this.getLocalConversation(e),r=null===(n=null===(s=this._core)||void 0===s?void 0:s.message.messageDataHandler)||void 0===n?void 0:n.getLocalMessageList(e);if(!i)return o;const a=i.unreadCount,c=null==r?void 0:r.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length;return console.log(`${this._name}._updateUnreadCount conversationID:${e} currentUnreadCount:${a} newUnreadCount:${c}`),a!==c&&(i.unreadCount=c,o=!0,!0===t&&this.emitConversationListUpdate()),o}},{key:"emitConversationListUpdate",value:function emitConversationListUpdate(e=!1){var t,s;e&&this._sortConversationList();const{OuterEvent:{CONVERSATION_LIST_UPDATED:n},conversation:o}=this._core,i=this.getLocalConversationList();this._emitEvent({name:n,data:i,isSyncCompleted:null===(s=null===(t=null==o?void 0:o.syncConversationHandler)||void 0===t?void 0:t.isSyncCompleted)||void 0===s?void 0:s.call(t)}),this._emitTotalUnreadCountUpdate()}},{key:"_emitTotalUnreadCountUpdate",value:function _emitTotalUnreadCountUpdate(){var e;const t=this.getTotalUnreadMessageCount();this._totalUnreadCount!==t&&(this._core.ssoLog.debug("_emitTotalUnreadCountUpdate",` from ${this._totalUnreadCount} to ${t}`),this._totalUnreadCount=t,this._emitEvent({name:null===(e=this._core)||void 0===e?void 0:e.OuterEvent.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,data:t}))}},{key:"_emitEvent",value:function _emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}},{key:"getTotalUnreadMessageCount",value:function getTotalUnreadMessageCount(){const{OuterConstant:e,utils:{isEmpty:t}}=this._core,s=this.getLocalConversationList();let n=0;return s.forEach(s=>{s.type!==e.CONV_SYSTEM&&(t(s.messageRemindType)||s.messageRemindType===e.MSG_REMIND_ACPT_AND_NOTE)&&(n+=s.unreadCount)}),n}},{key:"getLocalConversationList",value:function getLocalConversationList(){return[...this._conversationStore.getConversationMap().values()].filter(e=>this._isConversationNeedShow(e.conversationID))}},{key:"hasLocalConversation",value:function hasLocalConversation(e){return this._conversationStore.getConversationMap().has(e)}},{key:"getLocalConversation",value:function getLocalConversation(e){return this._conversationStore.getConversationMap().get(e)}},{key:"setLocalConversation",value:function setLocalConversation(e,t){return this._conversationStore.getConversationMap().set(e,t)}},{key:"deleteLocalConversation",value:function deleteLocalConversation(e){this._conversationStore.getConversationMap().delete(e)}},{key:"_updateConversationMapFromList",value:function _updateConversationMapFromList(e){this._clearConversationMap();for(const[t,s]of e)this.setLocalConversation(t,s)}},{key:"_clearConversationMap",value:function _clearConversationMap(){this._conversationStore.getConversationMap().clear()}},{key:"patchMessageRemindType",value:function patchMessageRemindType(e,t){let s=!1;e.forEach(e=>{const n=this.getLocalConversation(e);(null==n?void 0:n.messageRemindType)!==t&&(n.messageRemindType=t,s=!0)}),console.log(`${this._name}.patchMessageRemindType conversationIDList:${e} messageRemindType:${t} hasUpdated:${s}`),s&&this.emitConversationListUpdate()}},{key:"markMessageAsRead",value:function markMessageAsRead(e){const{message:{messageDataHandler:t}}=this._core,{conversationID:s,lastReadTime:n=0,lastReadSequence:o=0}=e,i=null==t?void 0:t.getLocalMessageList(s);if(0===i.length)return;const{length:r}=i;for(let e=r-1;e>=0;e--){const t=i[e],s=n&&t.time>n,r=o&&t.sequence>o;if(!s&&!r){if("in"===t.flow&&t.isRead)break;t.setIsRead(!0)}}}},{key:"appendToPinnedConversation",value:function appendToPinnedConversation(e){const t=[...this._conversationStore.getConversationMap().entries()],s=t.findIndex(e=>!1===e[1].isPinned);t.splice(s,0,[e.conversationID,e]),this._updateConversationMapFromList(t),this.emitConversationListUpdate()}},{key:"_reset",value:function _reset(){this._clearConversationMap(),this._totalUnreadCount=0,this._groupAtTipsList=[]}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e,InnerEvent:{NEW_MESSAGE:t,MESSAGE_DELETED:s,MESSAGE_REVOKED:n,MESSAGE_MODIFIED:o,CONVERSATION_UPDATED:i,LOGOUT:r,DESTROY:a,SYNC_CONVERSATION_LIST:c}}=this._core,{InnerEventSubType:{GROUP_AT_TIPS:u}}=e;e.unSubscribeInnerEvent(t,this._handleNewMessage,this),e.unSubscribeInnerEvent(t,u,this._handleNewGroupAtTips,this),e.unSubscribeInnerEvent(s,this._handleMessageDeleted,this),e.unSubscribeInnerEvent(n,this._handleMessageRevoked,this),e.unSubscribeInnerEvent(o,this._handleMessageModified,this),e.unSubscribeInnerEvent(i,this._handleConversationUpdated,this),e.unSubscribeInnerEvent(c,this._handleConversationSynced,this),e.unSubscribeInnerEvent(r,this._reset,this),e.unSubscribeInnerEvent(a,this._dispose,this)}}])}()),pa=new(function(){return _createClass(function _class54(){_classCallCheck(this,_class54),this._name="GetConversationList"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getConversationList",context:this})}},{key:"getConversationList",value:function getConversationList(e){return pe(this,void 0,void 0,function*(){return{code:0,data:{conversationList:this._getConversationList(e),isSyncCompleted:this._core.conversation.syncConversationHandler.isSyncCompleted()}}})}},{key:"_getConversationList",value:function _getConversationList(e){const{utils:{isUndefined:t,isArray:s,isPlainObject:n}}=this._core;if(t(e))return ga.getLocalConversationList();if(s(e))return 0===e.length?[]:ga.getLocalConversationList().filter(t=>e.includes(t.conversationID));if(n(e)){const{type:t,markType:s,groupName:n,hasUnreadCount:o,hasGroupAtInfo:i}=e;return ga.getLocalConversationList().filter(e=>this._filterType(e,t)&&this._filterMarkType(e,s)&&this._filterGroupName(e,n)&&this._filterUnreadCount(e,o)&&this._filterGroupAtInfo(e,i))}return[]}},{key:"_filterType",value:function _filterType(e,t){const{OuterConstant:s}=this._core;return t!==s.CONV_C2C&&t!==s.CONV_GROUP||e.type===t}},{key:"_filterGroupName",value:function _filterGroupName(e,t){const{utils:{isString:s}}=this._core;return!s(t)||(""===t?0===e.conversationGroupList.length:e.conversationGroupList.includes(t))}},{key:"_filterMarkType",value:function _filterMarkType(e,t){const{utils:{isNumber:s}}=this._core;return!s(t)||(0===t?0===e.markList.length:e.markList.includes(t))}},{key:"_filterUnreadCount",value:function _filterUnreadCount(e,t){let s=!0;return!0===t?s=e.unreadCount>=1:!1===t&&(s=0===e.unreadCount),s}},{key:"_filterGroupAtInfo",value:function _filterGroupAtInfo(e,t){let s=!0;return!0===t?s=e.groupAtInfoList.length>=1:!1===t&&(s=0===e.groupAtInfoList.length),s}}])}()),_a=new(function(){return _createClass(function _class55(){_classCallCheck(this,_class55),this._name="GetConversationProfile"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getConversationProfile",context:this})}},{key:"getConversationProfile",value:function getConversationProfile(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s,GRP_AVCHATROOM:n},appStore:{groupStore:o},utils:{isEmpty:i}}=this._core,r={code:0,data:{}};let a=ga.getLocalConversation(e);if(sa(e))return r.data.conversation=a,r;let c=!1;const u=ea(e)?t:s;if(i(a)&&(c=!0,a=new Zr({conversationID:e,type:u})),console.log(`${this._name}.getConversationProfile conversationID:${e} isNewConversation:${c}`),r.data.conversation=a,null==a?void 0:a.getProfileCompleted())return r;if(u===t){const s=e.replace(t,"");yield this._handleC2CConversation(a,s),c&&(yield da.get([s]))}if(u===s){const t=e.replace(s,"");if(!o.getGroup(t))return r;yield this._handleGroupConversation(a,t),c&&a.groupProfile.type!==n&&(yield ha.get([t]))}return r})}},{key:"_handleC2CConversation",value:function _handleC2CConversation(e,t){return pe(this,void 0,void 0,function*(){var s,n;const{user:o,helper:i,utils:{isEmpty:r},appStore:{conversationStore:a,userStore:c}}=this._core,{conversationID:u}=e,l=yield null===(s=o.userProfile)||void 0===s?void 0:s.getUserProfile({userIDList:[t]});if(0===(null==l?void 0:l.data.length))throw new i.ChatError({code:ca.USER_OR_GRP_NOT_FOUND});e.userProfile=null==l?void 0:l.data[0];const d=null===(n=c.getFriend(t))||void 0===n?void 0:n.remark;r(d)||e.remark===d||(e.remark=d),e.setProfileCompleted();const h=ga.hasLocalConversation(u);console.log(`${this._name}._handleC2CConversation conversationID:${u} hasLocalConversation: ${h}`),h?a.updateConversation(u,e):ga.appendToPinnedConversation(e)})}},{key:"_handleGroupConversation",value:function _handleGroupConversation(e,t){return pe(this,void 0,void 0,function*(){const{apiMap:{getGroupProfile:s},appStore:{conversationStore:n}}=this._core,{conversationID:o}=e,i=yield s({groupID:t});e.groupProfile=null==i?void 0:i.data.group,e.setProfileCompleted();const r=ga.hasLocalConversation(o);console.log(`${this._name}._handleGroupConversation conversationID:${o} hasLocalConversation: ${r}`),r?n.updateConversation(o,e):ga.appendToPinnedConversation(e)})}}])}()),ma=new(function(){return _createClass(function _class56(){_classCallCheck(this,_class56)},[{key:"init",value:function init(e){const{helper:t}=e;t.registerApi({apiName:"getTotalUnreadMessageCount",context:this})}},{key:"getTotalUnreadMessageCount",value:function getTotalUnreadMessageCount(){return ga.getTotalUnreadMessageCount()}}])}()),va=new(function(){return _createClass(function _class57(){_classCallCheck(this,_class57),this._serverGroupConversationLastReadSeqMap=new Map,this._name="SetMessageRead"},[{key:"init",value:function init(e){this._core=e;const{helper:t,common:{isTopic:s},notificationCenter:n,InnerEvent:{MESSAGE_PUSH:o},InnerEventSubType:{ALL_MESSAGE_READ:i}}=e;t.registerApi({apiName:"setMessageRead",context:this,matcher:e=>!s(e[0].conversationID)}),t.registerApi({apiName:"setAllMessageRead",context:this}),n.subscribeInnerEvent(o,i,this._handleAllMessageRead,this)}},{key:"handleC2CMessageReadSync",value:function handleC2CMessageReadSync(e){const{helper:{isEmpty:t},OuterConstant:s}=this._core;e.forEach(e=>{const{ReadC2cMsgNotify:n}=e;if(!t(n)){const{UinPairReadArray:e=[]}=n;e.forEach(e=>{const{From_Account:t,LastReadTime:n}=e,o=`${s.CONV_C2C}${t}`;console.log(`${this._name}.handleC2CMessageReadSync conversationID:${o} lastReadTime:${n}`),ga.markMessageAsRead({conversationID:o,lastReadTime:n}),ga.updateUnreadCount(o)})}})}},{key:"handleGroupMessageReadSync",value:function handleGroupMessageReadSync(e){const{OuterConstant:t,utils:{isUndefined:s}}=this._core;e.forEach(e=>{const{GroupReadInfoArray:n}=e.MsgBody;s(n)||n.forEach(e=>{const{GroupId:s,LastReadMsgSeq:n}=e,o=`${t.CONV_GROUP}${s}`;console.log(`${this._name}.handleGroupMessageReadSync conversationID:${o} lastReadSequence:${n}`),ga.markMessageAsRead({conversationID:o,lastReadSequence:n}),ga.updateUnreadCount(o),this._clearGroupAtInfoList(o)})})}},{key:"setMessageRead",value:function setMessageRead(e){return pe(this,void 0,void 0,function*(){var t,s;const{OuterConstant:n}=this._core,{conversationID:o}=e,i={code:0,data:{}},r=ga.getLocalConversation(o);let a=`${this._name}.setMessageRead conversationID:${o} unreadCount:${(null==r?void 0:r.unreadCount)||0}`;if(i.successLog={message:a},!r)return i;const c=!(null===(s=null===(t=this._core)||void 0===t?void 0:t.helper)||void 0===s?void 0:s.isEmpty(r.groupAtInfoList));if(r.type===n.CONV_GROUP&&c&&this._deleteGroupAtTips(o),0===r.unreadCount)return i;const{helper:{ChatError:u}}=this._core;try{if(r.type===n.CONV_C2C){const e=this._getLocalMessageMaxTime(r);a+=`lastMessageTime:${e}`,yield this._setC2CMessageRead(o,e)}if(r.type===n.CONV_GROUP){const e=this._getLocalMessageMaxSequence(r);a+=`lastMessageSequence:${e}`,yield this._setGroupMessageRead(o,e)}}catch(e){const{errorCode:t,errorInfo:s}=e;throw new u({functionName:"setMessageRead",code:t,message:s,moreMessage:a})}return r.type===n.CONV_SYSTEM&&(r.unreadCount=0),ga.emitConversationListUpdate(),Object.assign(Object.assign({},i),{successLog:{message:a}})})}},{key:"setAllMessageRead",value:function setAllMessageRead(){return pe(this,arguments,void 0,function*(e={}){const{OuterConstant:{READ_ALL_MSG:t},utils:{safeStringify:s}}=this._core;let n=`scope:${e.scope}`;e.scope||(e.scope=t);const{scope:o}=e,i=this._generateSetAllMessageReadRequestData(o);if(0===i.allC2CMessageReadStatus&&0===i.groupMessageReadInfoList.length)return{code:0};try{const e=yield function(e){return pe(this,void 0,void 0,function*(){const{allC2CMessageReadStatus:t,groupMessageReadInfoList:s}=e,n={C2CReadAllMsg:t,GroupReadInfo:s};return Xr.core.common.buildAndSendPacket({servcmd:"openim.read_all_unread_msg",data:n})})}(i);if(e){const{GroupReadInfoArray:t,C2CReadAllMsg:o}=e,i=this._parseGroupReadInfo(t);this._updateAllConversationReadStatus({allC2CMessageReadStatus:o})>0&&ga.emitConversationListUpdate(),n+=`failureGroupInfoList:${s(i)}`}return{code:0,successLog:{message:n}}}catch(e){const{errorCode:t}=e;throw new this._core.helper.ChatError({functionName:"setAllMessageRead",code:t,moreMessage:n})}})}},{key:"_handleAllMessageRead",value:function _handleAllMessageRead(e){const{GroupReadInfoArray:t,C2CReadAllMsg:s}=e;this._parseGroupReadInfo(t),this._updateAllConversationReadStatus({allC2CMessageReadStatus:s})>0&&ga.emitConversationListUpdate()}},{key:"_updateAllConversationReadStatus",value:function _updateAllConversationReadStatus(e){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s},appStore:n}=this._core,o=n.conversationStore.getConversationMap(),{allC2CMessageReadStatus:i}=e;let r=0;for(const[e,n]of o)if(n.unreadCount>=1){if(1===i&&n.type===t){const t=this._getLocalMessageMaxTime(n);ga.markMessageAsRead({conversationID:e,lastReadTime:t})}else if(n.type===s){const t=e.replace(s,"");if(this._serverGroupConversationLastReadSeqMap.has(t)){const s=this._serverGroupConversationLastReadSeqMap.get(t);ga.markMessageAsRead({conversationID:e,lastReadSequence:s})}}ga.updateUnreadCount(e,!1)&&(r+=1)}return r}},{key:"_generateSetAllMessageReadRequestData",value:function _generateSetAllMessageReadRequestData(e){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s,READ_ALL_C2C_MSG:n},appStore:o}=this._core,i={allC2CMessageReadStatus:0,groupMessageReadInfoList:[]},r=o.conversationStore.getConversationMap();for(const[,o]of r){const{type:r,unreadCount:a}=o;if(this._shouldSetAllMessageRead({scope:e,type:r,unreadCount:a}))if(r===t&&0===i.allC2CMessageReadStatus){if(i.allC2CMessageReadStatus=1,e===n)break}else if(r===s){const e=this._getLocalMessageMaxSequence(o),{groupID:t}=o.groupProfile;i.groupMessageReadInfoList.push({GroupId:t,MsgSeq:e})}}return i}},{key:"_parseGroupReadInfo",value:function _parseGroupReadInfo(e){const{utils:{isUndefined:t}}=this._core,s=[];return null==e||e.forEach(e=>{const{GroupId:n,MsgSeq:o,RetCode:i,LastReadMsgSeq:r}=e;t(i)?this._serverGroupConversationLastReadSeqMap.set(n,r):(this._serverGroupConversationLastReadSeqMap.set(n,o),0!==i&&s.push(`${n}-${o}-${i}`))}),s}},{key:"_deleteGroupAtTips",value:function _deleteGroupAtTips(e){return pe(this,void 0,void 0,function*(){console.log(`${this._name}._deleteGroupAtTips conversationID:${e}`);const t=ga.getLocalConversation(e);if(!t)return;const s=(null==t?void 0:t.groupAtInfoList)||[];if(0!==s.length)try{const{common:{getCurrentUserID:t,isCommunity:n},OuterConstant:{CONV_GROUP:o,CONV_AT_ALL:i}}=this._core;let r=[...s];if(n({groupID:e.replace(o,"")})&&(r=s.filter(e=>!e.atTypeArray.includes(i)),0===r.length))return void this._clearGroupAtInfoList(e,!1);const a=r.map(e=>({From_Account:e.from,To_Account:t(),MsgSeq:e.__sequence,MsgRandom:e.__random,GroupId:e.groupID}));yield function(e,t){return pe(this,void 0,void 0,function*(){const{messageListToDelete:s}=e,n={DelMsgList:s};return t.common.buildAndSendPacket({servcmd:"openim.deletemsg",data:n})})}({messageListToDelete:a},this._core),console.log(`${this._name}._deleteGroupAtTips ok. count:${s.length}`),this._clearGroupAtInfoList(e)}catch(e){console.error(`${this._name}._deleteGroupAtTips fail:`,e)}})}},{key:"_clearGroupAtInfoList",value:function _clearGroupAtInfoList(e,t=!0){const s=ga.getLocalConversation(e);s&&(s.groupAtInfoList.length>0&&(s.clearGroupAtInfoList(),console.log(`${this._name}._clearGroupAtInfoList conversationID:${e} needEmitConversationUpdate:${t}`)),t&&ga.emitConversationListUpdate())}},{key:"_getLocalMessageMaxTime",value:function _getLocalMessageMaxTime(e){var t;const{conversationID:s}=e,n=this._core.message.messageDataHandler.getLocalMessageList(s),o=Math.max(...n.map(e=>e.time));let i=(null===(t=null==e?void 0:e.lastMessage)||void 0===t?void 0:t.lastTime)||0;return o>i&&(console.log(`${this._name}._getLocalMessageMaxTime update lastMessageTime from ${i} to ${o}`),i=o),i}},{key:"_getLocalMessageMaxSequence",value:function _getLocalMessageMaxSequence(e){var t;const{conversationID:s}=e,n=this._core.message.messageDataHandler.getLocalMessageList(s),o=Math.max(...n.map(e=>e.sequence));let i=(null===(t=null==e?void 0:e.lastMessage)||void 0===t?void 0:t.lastSequence)||0;return o>i&&(console.log(`${this._name}._getLocalMessageMaxSequence update lastMessageSequence from ${i} to ${o}`),i=o),i}},{key:"_setC2CMessageRead",value:function _setC2CMessageRead(e,t){return pe(this,void 0,void 0,function*(){try{yield function(e,t){return pe(this,void 0,void 0,function*(){return t.common.buildAndSendPacket({servcmd:"openim.msgreaded",data:e})})}({C2CMsgReaded:{Cookie:"",C2CMsgReadedItem:[{To_Account:e.replace("C2C",""),LastedMsgTime:t,Receipt:1}]}},this._core),console.log(`${this._name}._setC2CMessageRead ok, lastReadTime:${t}`),ga.markMessageAsRead({conversationID:e,lastReadTime:t}),ga.updateUnreadCount(e)}catch(e){throw console.warn(`${this._name}._setC2CMessageRead fail:`,e),e}})}},{key:"_setGroupMessageRead",value:function _setGroupMessageRead(e,t){return pe(this,void 0,void 0,function*(){try{yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,lastMessageSequence:n}=e,o={GroupId:s,MsgReadedSeq:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.msg_read_report",data:o})})}({groupID:e.replace("GROUP",""),lastMessageSequence:t},this._core),console.log(`${this._name}._setGroupMessageRead ok, lastReadSequence:${t}`),ga.markMessageAsRead({conversationID:e,lastReadSequence:t}),ga.updateUnreadCount(e)}catch(e){throw console.warn(`${this._name}._setGroupMessageRead fail:`,e),e}})}},{key:"_shouldSetAllMessageRead",value:function _shouldSetAllMessageRead(e){const{OuterConstant:{CONV_C2C:t,CONV_GROUP:s,READ_ALL_MSG:n,READ_ALL_C2C_MSG:o,READ_ALL_GROUP_MSG:i}}=this._core,{type:r,scope:a,unreadCount:c}=e;return!(c<=0||(r!==t||![n,o].includes(a))&&(r!==s||![n,i].includes(a)))}}])}()),fa=new(function(){return _createClass(function _class58(){_classCallCheck(this,_class58),this._name="PinConversation"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"pinConversation",context:this})}},{key:"handleConversationPinned",value:function handleConversationPinned(e,t){const{utils:{isArray:s}}=this._core;if(!s(e))return;const{OuterConstant:n}=this._core;let o=!1;e.forEach(e=>{const{Type:s,Peer_Account:i,GroupId:r}=e;let a;1===s?a=ga.getLocalConversation(`${n.CONV_C2C}${i}`):2===s&&(a=ga.getLocalConversation(`${n.CONV_GROUP}${r}`)),a&&(console.log(`${this._name}.handleConversationPinned conversationID:${a.conversationID} localPinned:${a.isPinned} remotePinned:${t}`),t&&!a.isPinned&&(a.isPinned=!0,o=!0),!t&&a.isPinned&&(a.isPinned=!1,o=!0))}),o&&ga.emitConversationListUpdate(!0)}},{key:"pinConversation",value:function pinConversation(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t,common:s,helper:{ChatError:n}}=this._core,{conversationID:o,isPinned:i}=e,r={code:0,data:{conversationID:o}},a=ga.getLocalConversation(o);if(a&&a.isPinned===i)return r;if(sa(o))return a&&(a.isPinned=i),ga.emitConversationListUpdate(!0),r;const c=`conversationID:${o} isPinned:${i}`;try{let e=null;ea(o)?e={Type:1,To_Account:o.replace(t.CONV_C2C,"")}:ta(o)&&(e={Type:2,GroupId:o.replace(t.CONV_GROUP,"")});const n=yield function(e,t){return pe(this,void 0,void 0,function*(){const{fromAccount:s,operationType:n,itemList:o}=e,i={From_Account:s,OperationType:n,RecentContactItem:o};return t.common.buildAndSendPacket({servcmd:"recentcontact.top",data:i})})}({fromAccount:s.getCurrentUserID(),operationType:!0===i?1:2,itemList:[e]},this._core);if(n){if(a)a.isPinned!==i&&(a.isPinned=i);else{const e=new Zr({conversationID:o,type:ea(o)?t.CONV_C2C:t.CONV_GROUP,isPinned:i});ga.setLocalConversation(o,e)}ga.emitConversationListUpdate(!0)}return Object.assign(Object.assign({},r),{successLog:{message:c}})}catch(e){const{errorCode:t,errorInfo:s}=e;throw new n({functionName:"pinConversation",code:t,message:s,moreMessage:c})}})}}])}()),Ia=new(function(){return _createClass(function _class59(){_classCallCheck(this,_class59),this._name="DeleteConversation"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteConversation",context:this})}},{key:"handleConversationDeleted",value:function handleConversationDeleted(e){const{utils:{isArray:t}}=this._core;if(!t(e))return;const{OuterConstant:s}=this._core,n=[];e.forEach(e=>{const{Type:t,Peer_Account:o,GroupId:i}=e;1===t&&n.push(`${s.CONV_C2C}${o}`),2===t&&n.push(`${s.CONV_GROUP}${i}`)}),console.log(`${this._name}.handleConversationDeleted conversationIDList:${n}`),this._deleteLocalConversationList(n)}},{key:"deleteConversation",value:function deleteConversation(e){return pe(this,void 0,void 0,function*(){const{utils:{isString:t}}=this._core;if(t(e))return this._deleteConversation({conversationIDList:[e],flag:aa.ONLY_CONVERSATIONID});const s=Object.assign({},e);return s.conversationIDList.length>100&&(s.conversationIDList=s.conversationIDList.slice(0,100)),this._deleteConversation(s)})}},{key:"_deleteConversation",value:function _deleteConversation(e){return pe(this,void 0,void 0,function*(){const{conversationIDList:t,clearHistoryMessage:s=!0,flag:n=0}=e,{helper:{ChatError:o}}=this._core,i=`conversationIDList:${t} clearHistoryMessage:${s}`;try{const e=yield Promise.all([this._deleteConversationFromLocal(t),this._deleteConversationFromServer(t,s)]),o=[...e[0],...e[1]];if(0===o.length)throw new this._core.helper.ChatError({code:ca.CONV_NOT_FOUND});return{code:0,data:n===aa.ONLY_CONVERSATIONID?{conversationID:o[0]}:{conversationIDList:o},successLog:{message:i}}}catch(e){const{errorCode:t,errorInfo:s}=e;throw new o({code:t,message:s,moreMessage:i})}})}},{key:"_deleteConversationFromLocal",value:function _deleteConversationFromLocal(e){const{OuterConstant:t}=this._core;return e.filter(e=>{var s;if(!ga.hasLocalConversation(e))return!1;const n=null===(s=ga.getLocalConversation(e))||void 0===s?void 0:s.type;return n!==t.CONV_GROUP||this._hasLocalGroup(e)?n===t.CONV_SYSTEM&&(this._deleteLocalConversation(e),!0):(this._deleteLocalConversation(e),!0)})}},{key:"_deleteConversationFromServer",value:function _deleteConversationFromServer(e,t){return pe(this,void 0,void 0,function*(){const{OuterConstant:s,common:n}=this._core,o={fromAccount:n.getCurrentUserID(),conversationList:[],clearHistoryMessage:t?1:0};if(e.forEach(e=>{var t;if(ga.hasLocalConversation(e)){const n=(null===(t=ga.getLocalConversation(e))||void 0===t?void 0:t.type)||"",i=e.replace(n,"");n===s.CONV_C2C?o.conversationList.push({To_Account:i,Type:1}):n===s.CONV_GROUP&&this._hasLocalGroup(e)&&o.conversationList.push({ToGroupid:i,Type:2})}}),0===o.conversationList.length)return[];const i=yield function(e,t){return pe(this,void 0,void 0,function*(){const{fromAccount:s,conversationList:n,clearHistoryMessage:o}=e,i={From_Account:s,ContactItem:n,ClearRamble:o};return t.common.buildAndSendPacket({servcmd:"recentcontact.batch_delete",data:i})})}(o,this._core);if(i){const{ResultItem:e=[]}=i,t=[];return e.length>0&&e.forEach(e=>{if(0===e.ResultCode){const n=1===e.Type?`${s.CONV_C2C}${e.To_Account}`:`${s.CONV_GROUP}${e.ToGroupid}`;t.push(n)}}),this._deleteLocalConversationList(t),t}return[]})}},{key:"_deleteLocalConversationList",value:function _deleteLocalConversationList(e){let t=!1;e.forEach(e=>{ga.hasLocalConversation(e)&&(this._deleteLocalConversation(e,!1),t=!0)}),console.log(`${this._name}._deleteLocalConversationList isUpdate:${t}`),t&&ga.emitConversationListUpdate()}},{key:"_deleteLocalConversation",value:function _deleteLocalConversation(e,t=!0){const s=ga.hasLocalConversation(e);console.log(`${this._name}._deleteLocalConversation conversationID:${e} has:${s}`),s&&(ga.deleteLocalConversation(e),this._deleteConversationLocalMessage(e),t&&ga.emitConversationListUpdate())}},{key:"_hasLocalGroup",value:function _hasLocalGroup(e){const{OuterConstant:{CONV_GROUP:t},appStore:{groupStore:s}}=this._core,n=e.replace(t,"");return!!s.getGroup(n)}},{key:"_deleteConversationLocalMessage",value:function _deleteConversationLocalMessage(e){console.log(`${this._name}._deleteConversationLocalMessage conversationID:${e}`),this._core.message.messageDataHandler.deleteConversationMessageList(e),this._core.message.messageHistory.completedHistoryConversations.delete(e)}}])}()),Ea=new(function(){return _createClass(function _class60(){_classCallCheck(this,_class60),this._name="SetConversationDraft"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setConversationDraft",context:this})}},{key:"setConversationDraft",value:function setConversationDraft(e){return pe(this,void 0,void 0,function*(){const{conversationID:t,draftText:s}=e;if(console.log(`${this._name} conversationID:${t} draftText:${s}`),!ga.hasLocalConversation(t))throw new this._core.helper.ChatError({code:ca.CONV_NOT_FOUND});const n=ga.getLocalConversation(t);return null==n||n.setDraftText(s),ga.emitConversationListUpdate(),{code:0,data:{conversation:n}}})}}])}()),Sa=new(function(){return _createClass(function _class61(){_classCallCheck(this,_class61),this._name="SetC2CMessageRemindType"},[{key:"init",value:function init(e){this._core=e}},{key:"set",value:function set(e,t){return pe(this,void 0,void 0,function*(){e.length>30&&(console.warn(`${this._name}.set userIDList length:${e.length} exceeds limit 30`),e.splice(30));const s=function(){const{MSG_REMIND_ACPT_AND_NOTE:e,MSG_REMIND_DISCARD:t,MSG_REMIND_ACPT_NOT_NOTE:s}=Xr.core.OuterConstant;return{[e]:0,[t]:1,[s]:2}}()[t],n=yield function(e,t){return pe(this,void 0,void 0,function*(){const{userIDList:s,receiveMessageOption:n}=e,o={Peer_Account:s,Mute_Notifications:n};return t.common.buildAndSendPacket({servcmd:"openim.set_c2c_peer_mute_notifications",data:o})})}({userIDList:e,receiveMessageOption:s},this._core),{ErrorList:o=[]}=n||{},i=[];o.forEach(t=>{const{Peer_Account:s,ErrorCode:n}=t;i.push({userID:s,code:n});const o=e.indexOf(s);o>-1&&e.splice(o,1)});const r=[],a=[],{OuterConstant:c}=this._core;return e.forEach(e=>{a.push(`${c.CONV_C2C}${e}`),r.push({userID:e})}),ga.patchMessageRemindType(a,t),{code:0,data:{successUserIDList:r,failureUserIDList:i}}})}}])}()),Ca=new(function(){return _createClass(function _class62(){_classCallCheck(this,_class62),this._name="SetGroupMessageRemindType"},[{key:"init",value:function init(e){this._core=e}},{key:"set",value:function set(e,t){return pe(this,void 0,void 0,function*(){const{common:{getCurrentUserID:s,isTopic:n},OuterConstant:o}=this._core;if(yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userID:n,receiveMessageOption:o}=e,i={GroupId:s,Member_Account:n,MsgFlag:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:i})})}({groupID:e,userID:s(),receiveMessageOption:t},this._core),!n(e)){const s=`${o.CONV_GROUP}${e}`;ga.patchMessageRemindType([s],t)}return{code:0,data:{groupID:e,messageRemindType:t}}})}}])}()),Ma=new(function(){return _createClass(function _class63(){_classCallCheck(this,_class63),this._name="SetMessageRemindType"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setMessageRemindType",context:this})}},{key:"handleC2CMessageRemindTypeSync",value:function handleC2CMessageRemindTypeSync(e){const{helper:{isEmpty:t},OuterConstant:s,ssoLog:n}=this._core;e.forEach(e=>{const{MuteNotificationsSync:o}=e;if(!t(o)){const{To_Account:e,MuteNotifications:t}=o,i=e.map(e=>`${s.CONV_C2C}${e}`),r=na(t);n.debug(`${this._name}.handleC2CMessageRemindTypeSync conversationIDList:${i} messageRemindType:${r}`),ga.patchMessageRemindType(i,r)}})}},{key:"setMessageRemindType",value:function setMessageRemindType(e){return pe(this,void 0,void 0,function*(){const t="setMessageRemindType",{groupID:s,userIDList:n,messageRemindType:o}=e,{helper:i,utils:{isUndefined:r},ssoLog:a}=this._core;try{if(!r(s))return a.debug(`${this._name}.${t} groupID:${s} messageRemindType:${o}`),yield Ca.set(s,o);if(!r(n))return a.debug(`${this._name}.${t} userIDList:${n} messageRemindType:${o}`),yield Sa.set(n,o);throw new i.ChatError({functionName:t,message:"userIDList or groupID is required"})}catch(e){throw new i.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:`groupID:${s} userIDList:${n} messageRemindType:${o}`})}})}}])}()),ya=new(function(){return _createClass(function _class64(){_classCallCheck(this,_class64)},[{key:"init",value:function init(e){e.ssoLog.debug("ConversationAction.init"),this._core=e,pa.init(e),_a.init(e),ma.init(e),va.init(e),fa.init(e),Ia.init(e),Ea.init(e),Ma.init(e);const{notificationCenter:t,InnerEvent:{MESSAGE_PUSH:s,DESTROY:n}}=this._core,{InnerEventSubType:{CONV_MODIFIED:o,C2C_MESSAGE_READ_SYNC:i,GROUP_MESSAGE_READ_SYNC:r,C2C_REMIND_TYPE_SYNC:a}}=t;t.subscribeInnerEvent(s,o,this._onConversationModified,this),t.subscribeInnerEvent(s,i,this._onC2CMessageReadSync,this),t.subscribeInnerEvent(s,a,this._onC2CMessageRemindTypeSync,this),t.subscribeInnerEvent(s,r,this._onGroupMessageReadSync,this),t.subscribeInnerEvent(n,this._dispose,this)}},{key:"_onConversationModified",value:function _onConversationModified(e){const{constants:{ConvModifyPushType:t}}=this._core,{RecentContactMod:s=[]}=e;s.forEach(e=>{const{PushType:s}=e;if(s===t.CONV_DELETED){const{RecentContactList:t}=e.RecentContactDeleteItem;Ia.handleConversationDeleted(t)}if(s===t.CONV_PINED){const{RecentContactList:t}=e.RecentContactTopItem;fa.handleConversationPinned(t,!0)}if(s===t.CONV_UNPINED){const{RecentContactList:t}=e.RecentContactTopItem;fa.handleConversationPinned(t,!1)}})}},{key:"_onC2CMessageReadSync",value:function _onC2CMessageReadSync(e){const{C2cNotifyMsgArray:t=[]}=e;va.handleC2CMessageReadSync(t)}},{key:"_onC2CMessageRemindTypeSync",value:function _onC2CMessageRemindTypeSync(e){const{C2cNotifyMsgArray:t=[]}=e;Ma.handleC2CMessageRemindTypeSync(t)}},{key:"_onGroupMessageReadSync",value:function _onGroupMessageReadSync(e){const{GroupTips:t=[]}=e;va.handleGroupMessageReadSync(t)}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e,InnerEvent:{MESSAGE_PUSH:t,DESTROY:s}}=this._core,{InnerEventSubType:{CONV_MODIFIED:n,C2C_MESSAGE_READ_SYNC:o,GROUP_MESSAGE_READ_SYNC:i,C2C_REMIND_TYPE_SYNC:r}}=e;e.unSubscribeInnerEvent(t,n,this._onConversationModified,this),e.unSubscribeInnerEvent(t,o,this._onC2CMessageReadSync,this),e.unSubscribeInnerEvent(t,r,this._onC2CMessageRemindTypeSync,this),e.unSubscribeInnerEvent(t,i,this._onGroupMessageReadSync,this),e.unSubscribeInnerEvent(s,this._dispose,this)}}])}()),Oa=new(function(){return _createClass(function _class65(){_classCallCheck(this,_class65)},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setAllReceiveMessageOpt",context:this})}},{key:"setAllReceiveMessageOpt",value:function setAllReceiveMessageOpt(e){return pe(this,void 0,void 0,function*(){try{const{OuterConstant:{MSG_REMIND_ACPT_NOT_NOTE:t}}=this._core,{messageRemindType:s=t,isRepeated:n=!0}=e,{startTime:o=0,endTime:i=0}=this._calcStartAndEndTime(e),r=yield function(e){return pe(this,void 0,void 0,function*(){const{common:t}=Xr.core,{startTime:s,endTime:n,isRepeated:o,messageRemindType:i}=e,r={StartTime:s,EndTime:n,IsRepeated:o,Level:i};return t.buildAndSendPacket({servcmd:"im_msg_db_logic.ws_set_do_not_disturb",data:r})})}({messageRemindType:this._getType(s),startTime:o,endTime:i,isRepeated:n?ra.ON:ra.OFF});return{code:0,data:{errorCode:r.ErrorCode,errorInfo:r.ErrorInfo}}}catch(e){ia("setAllReceiveMessageOpt",e)}})}},{key:"_calcStartAndEndTime",value:function _calcStartAndEndTime(e){const{startHour:t=0,startMinute:s=0,startSecond:n=0,duration:o=0,isRepeated:i=!0}=e,r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate(),t,s,n),c=Math.round(a.getTime()/1e3);let u=c+o;return i&&o>=86400&&(u=c+86400),{startTime:c,endTime:u}}},{key:"_getType",value:function _getType(e){const{OuterConstant:t}=this._core;return{[t.MSG_REMIND_ACPT_AND_NOTE]:0,[t.MSG_REMIND_DISCARD]:1,[t.MSG_REMIND_ACPT_NOT_NOTE]:2}[e]}}])}()),Aa=new(function(){return _createClass(function _class66(){_classCallCheck(this,_class66)},[{key:"init",value:function init(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:n}=e;t.registerApi({apiName:"getAllReceiveMessageOpt",context:this}),s.subscribeInnerEvent(n.MESSAGE_PUSH,s.InnerEventSubType.ALL_RECEIVE_MESSAGE_OPTION,this.onAllReceiveMsgOptionNotify,this)}},{key:"onAllReceiveMsgOptionNotify",value:function onAllReceiveMsgOptionNotify(e){const t=this._handleResult(e),{notificationCenter:s,OuterEvent:{ALL_RECEIVE_MESSAGE_OPT_UPDATED:n}}=this._core;s.emitOuterEvent(n,{name:n,data:t})}},{key:"getAllReceiveMessageOpt",value:function getAllReceiveMessageOpt(){return pe(this,void 0,void 0,function*(){try{const e=yield function(){return pe(this,void 0,void 0,function*(){const{common:e}=Xr.core,t={To_Account:e.getCurrentUserID()};return e.buildAndSendPacket({servcmd:"im_msg_db_logic.ws_get_do_not_disturb",data:t})})}();return{code:0,data:this._handleResult(e)}}catch(e){ia("getAllReceiveMessageOpt",e)}})}},{key:"_handleResult",value:function _handleResult(e){const{OuterConstant:t}=this._core,{MSG_REMIND_ACPT_AND_NOTE:s,MSG_REMIND_DISCARD:n,MSG_REMIND_ACPT_NOT_NOTE:o}=t,i={0:s,1:n,2:o},{Level:r,StartTime:a,EndTime:c,IsRepeated:u}=e;return{messageRemindType:i[r]||s,startTime:a,endTime:c,isRepeated:u===ra.ON}}}])}()),Ta=new(function(){return _createClass(function _class67(){_classCallCheck(this,_class67)},[{key:"init",value:function init(e){e.ssoLog.debug("ReceiveMessageOptions.init"),this._core=e,Sa.init(e),Ca.init(e),da.init(e),ha.init(e),Oa.init(e),Aa.init(e)}}])}());const Ra=e=>!ea(e)&&!ta(e)&&!sa(e),Da={getConversationProfile:[{key:"conversationID",required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!Ra(e)||"conversationID is invalid."}],setMessageRead:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!Ra(e)||"conversationID is invalid."}},pinConversation:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!Ra(e)||"conversationID is invalid."},isPinned:{required:!0,rules:["boolean"],allowEmpty:!1}},deleteConversation:[{key:"options",required:!0,rules:["string","object"],allowEmpty:!1,customValidator:e=>{const{core:{utils:{isArray:t,isObject:s,isString:n}}}=Xr;if(!n(e)&&!s(e))return"options is String or Object.";if(n(e)&&Ra(e))return"conversationID is invalid.";if(s(e)){if(!t(e.conversationIDList))return"conversationIDList is not Array.";if(0===e.conversationIDList.length)return"conversationIDList is empty.";if(e.conversationIDList.some(e=>{if(Ra(e))return!0}))return"conversationIDList includes invalid conversationID.";if(e.clearHistoryMessage&&"boolean"!=typeof e.clearHistoryMessage)return"clearHistoryMessage is not Boolean."}return!0}}],setConversationDraft:{conversationID:{required:!0,rules:["string"],allowEmpty:!1,customValidator:e=>!(!ea(e)&&!ta(e))||"conversationID is invalid."},draftText:{required:!0,rules:["string"],allowEmpty:!0}},setAllReceiveMessageOpt:{messageRemindType:{required:!1,rules:["string"],allowEmpty:!0},startHour:{required:!1,rules:["number"],allowEmpty:!0},startMinute:{required:!1,rules:["number"],allowEmpty:!0},startSecond:{required:!1,rules:["number"],allowEmpty:!0},duration:{required:!1,rules:["number"],allowEmpty:!0},isRepeated:{required:!1,rules:["boolean"],allowEmpty:!0}}},ba={getConversationList:!0,getConversationProfile:!0,getTotalUnreadCount:!0,setMessageRead:!0,pinConversation:!0,deleteConversation:!0,setConversationDraft:!0,setMessageRemindType:!0,getAllReceiveMessageOpt:!0,setAllReceiveMessageOpt:!0};var Na=new(function(){return _createClass(function _class68(){_classCallCheck(this,_class68),this.name="Conversation"},[{key:"install",value:function install(e){Xr.init(e),ya.init(e),Ta.init(e),ga.init(e),e.helper.registerValidateConfig({auth:ba,params:Da})}}])}());const La=new(function(){return _createClass(function _class69(){_classCallCheck(this,_class69)},[{key:"init",value:function init(e){this.core=e}}])}()),Pa="AVChatRoom",wa="GRP_COUNTER",Va=["Type","Name","Introduction","Notification","FaceUrl","Owner_Account","CreateTime","InfoSeq","LastInfoTime","LastMsgTime","MemberNum","MaxMemberNum","ApplyJoinOption","NextMsgSeq","ShutUpAllMember","InviteJoinOption","LastRecallTime"],Ba=["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"],ja=["Role","JoinTime","MsgFlag","MsgSeq"],Ha=["Role","JoinTime","MsgSeq","MsgFlag","NameCard"],Ya="notStart",za="resolved",Ja="rejected",ec=["Owner","Admin","Member"],tc=["Role","JoinTime","NameCard","ShutUpUntil","OnlineStatus"],vc={from:!0,groupID:!0,groupName:!0,to:!0},fc={from:!0,groupID:!0,groupName:!0,to:!0,type:!0},Vc={0:"DisableInvite",1:"NeedPermission",2:"FreeAccess"},Bc=e=>e===La.core.OuterConstant.GRP_PUBLIC,jc=e=>e===La.core.OuterConstant.GRP_AVCHATROOM,Hc=(e,t)=>{const{isArray:s}=La.core.utils;if(!s(e)||!s(t))return!1;let n=!1;return t.forEach(({key:t,value:s})=>{const o=e.find(e=>e.key===t);o?o.value!==s&&(o.value=s,n=!0):(e.push({key:t,value:s}),n=!0)}),n},Kc=e=>{const t=[];if(!e)return t;for(let s=0,n=e.length;s<n;s++){const{Key:n,Value:o}=e[s];t.push({key:n,value:o})}return t},Wc=e=>{const t=[];for(let s=0,n=e.length;s<n;s++){const{key:n,value:o}=e[s];t.push({Key:n,Value:o})}return t};function Yc(e,t){const{helper:s}=La.core;if(!s.checkBusinessCapabilityBits(t))throw new s.ChatError({functionName:e,code:3122,replacement1:e})}function zc(e,t){const{helper:s}=La.core,n=new s.ChatError({functionName:e,code:(null==t?void 0:t.errorCode)||(null==t?void 0:t.code),message:(null==t?void 0:t.errorInfo)||(null==t?void 0:t.message)});throw console.error(`${e} fail:`,n),n}const Jc=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberCount","maxMemberCount","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime","_groupAtInfoList"];let Qc=function(){return _createClass(function Qc(e){_classCallCheck(this,Qc),this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime=0,this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:0,lastSequence:0,fromAccount:"",messageForShow:""},this.nextMessageSeq=0,this.memberCount=0,this.maxMemberCount=0,this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._groupAtInfoList=[],this._initGroup(e)},[{key:"_initGroup",value:function _initGroup(e){const{utils:{isString:t}}=La.core;for(const s in e)Jc.indexOf(s)<0||("selfInfo"!==s?"isSupportTopic"!==s?"muteAllMembers"===s&&t(e[s])?this.muteAllMembers="On"===e[s]:this[s]=e[s]:this.isSupportTopic=1===e[s]:this.updateSelfInfo(e[s]))}},{key:"updateGroup",value:function updateGroup(e){const{utils:{isArray:t,isUndefined:s,isNumber:n,isString:o},common:{deepMerge:i}}=La.core;e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0);const r=JSON.parse(JSON.stringify(e));r.lastMsgTime&&(this.lastMessage.lastTime=r.lastMsgTime),o(r.muteAllMembers)&&(r.muteAllMembers="On"===r.muteAllMembers),r.groupCustomField&&Hc(this.groupCustomField,r.groupCustomField),s(r.isSupportTopic)||(this.isSupportTopic=n(r.isSupportTopic)?1===r.isSupportTopic:r.isSupportTopic),i(this,r,["members","errorCode","lastMsgTime","groupCustomField","isSupportTopic"]),t(r.members)&&r.members.length>0&&r.members.forEach(e=>{e.userID===this.selfInfo.userID&&i(this.selfInfo,e,["sequence"])})}},{key:"updateSelfInfo",value:function updateSelfInfo(e){const{nameCard:t,joinTime:s,role:n,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:r}=e,{common:{deepMerge:a}}=La.core;a(this.selfInfo,{nameCard:t,joinTime:s,role:n,messageRemindType:o,readedSequence:i,excludedUnreadSequenceList:r},[],["",null,void 0,0,NaN])}},{key:"setSelfNameCard",value:function setSelfNameCard(e){this.selfInfo.nameCard=e}}])}();var Xc=new(function(){return _createClass(function _class70(){_classCallCheck(this,_class70),this._name="GroupDataHandler"},[{key:"init",value:function init(e){this._core=e;const{appStore:{groupStore:t}}=e;this._groupMap=t.getGroupMap()}},{key:"hasLocalGroup",value:function hasLocalGroup(e){return this._groupMap.has(e)}},{key:"getLocalGroup",value:function getLocalGroup(e){return this._groupMap.get(e)}},{key:"updateLocalGroup",value:function updateLocalGroup(e){const{common:{getCurrentUserID:t}}=this._core;let s;e.forEach(e=>{var t;s=e.groupID,this.hasLocalGroup(s)?null===(t=this.getLocalGroup(s))||void 0===t||t.updateGroup(e):(this._groupMap.set(s,new Qc(e)),this._clearGroupLocalMessage(s))});const n=t();for(const[,e]of this._groupMap)e.selfInfo.userID=n,"Owner"===e.selfInfo.role&&(e.ownerID=n)}},{key:"deleteLocalGroup",value:function deleteLocalGroup(e){this._groupMap.delete(e)}},{key:"getLocalGroupList",value:function getLocalGroupList(){const{OuterConstant:{GRP_ROOM:e,GRP_LIVE:t}}=this._core;return[...this._groupMap.values()].filter(s=>{const{type:n}=s;return n!==e&&n!==t})}},{key:"clearLocalGroup",value:function clearLocalGroup(){this._groupMap.clear()}},{key:"emitGroupListUpdate",value:function emitGroupListUpdate(){const e=this.getLocalGroupList(),{OuterEvent:{GROUP_LIST_UPDATED:t},notificationCenter:s}=this._core;s.emitOuterEvent(t,{name:t,data:e})}},{key:"updateConversationGroupProfile",value:function updateConversationGroupProfile(e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s}}=this._core,n=`${s}${e}`,o=t.getConversation(n);if(o){const s=this.getLocalGroup(e);o.setProfileCompleted(),t.updateConversation(n,{groupProfile:s})}}},{key:"reset",value:function reset(){this.clearLocalGroup()}},{key:"_clearGroupLocalMessage",value:function _clearGroupLocalMessage(e){const{message:{messageHistory:t,messageDataHandler:s},OuterConstant:{CONV_GROUP:n},ssoLog:o}=this._core;o.debug("_clearGroupLocalMessage",`groupID:${e}`);const i=`${n}${e}`;t.completedHistoryConversations.delete(i),s.deleteConversationMessageList(i)}}])}());function Zc(e,t){return pe(this,void 0,void 0,function*(){const{type:s,limit:n,offset:o,supportTopic:i=0,memberAccount:r,responseFilter:a}=e,c={Type:s,Limit:n,Offset:o,Member_Account:r,ResponseFilter:a,SupportTopic:i,NeedAppDefineData:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_joined_group_list",data:c})})}const eu=function(e,t){return{code:0,data:e||{},successLog:t}};var tu=new(function(){return _createClass(function _class71(){_classCallCheck(this,_class71),this._name="GetGroupList",this._pagingStatus=Ya,this.PAGING_GRP_COUNT_LIMIT=200},[{key:"init",value:function init(e){this._core=e;const{helper:t,constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n}}=e;t.registerApi({apiName:"getGroupList",context:this}),t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_LOGIN,n.GROUP_LIST_SYNC,this._syncGroupList,this)}},{key:"getGroupList",value:function getGroupList(){return pe(this,arguments,void 0,function*(e=!1){if(e){const e=[];return yield this._pagingGetJoinedCommunityList({limit:this.PAGING_GRP_COUNT_LIMIT,offset:0,groupList:e}),Xc.updateLocalGroup(e),Xc.getLocalGroupList()}if(this._core.ssoLog.debug("getGroupList",`${this._name}.getGroupList pagingStatus:${this._pagingStatus}`),this._pagingStatus===Ja||this._pagingStatus===Ya)return this._syncGroupList().then(()=>{const e=Xc.getLocalGroupList();return eu({groupList:e,isSyncCompleted:this._isSyncCompleted()})}).catch(e=>{throw e});const t=Xc.getLocalGroupList();return eu({groupList:t,isSyncCompleted:this._isSyncCompleted()},{message:`return group count:${t.length}`})})}},{key:"_syncGroupList",value:function _syncGroupList(){return pe(this,void 0,void 0,function*(){this._pagingStatus===Ya&&Xc.clearLocalGroup();const e=this.PAGING_GRP_COUNT_LIMIT,t=[];try{yield this._pagingGetGroupList({limit:e,offset:0,groupList:t}),this._pagingStatus=za,this._groupListTreeShaking(t),Xc.updateLocalGroup(t);const s=Xc.getLocalGroupList();return this._core.ssoLog.debug("_syncGroupList",`${this._name}._syncGroupList ok, count:${s.length}`),Xc.emitGroupListUpdate(),s}catch(e){throw this._pagingStatus=Ja,e}})}},{key:"_pagingGetGroupList",value:function _pagingGetGroupList(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,{isCommunityRelay:s=!1,groupList:n}=e;let o,{limit:i,offset:r}=e;const a=[...Va];s&&(o=this._core.OuterConstant.GRP_COMMUNITY,a.push("AtInfoList"));try{const e=yield Zc({type:o,limit:i,offset:r,memberAccount:this._core.store.get("login").userId,responseFilter:{GroupBaseInfoFilter:a,SelfInfoFilter:[...ja]}},this._core),{GroupIdList:c=[],TotalCount:u=0}=e||{},l=this._convertGroupKey(c);n.push(...l);const d=r+i,h=!(u>d),g=`offset:${r} limit:${i} total:${u} isCompleted:${h} current:${n.length} isCommunityRelay:${s}`;return t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. ${g}`),s?h?n:(r=d,this._pagingGetGroupList({isCommunityRelay:!0,limit:i,offset:r,groupList:n})):h?(t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList start to get community list`),r=0,this._pagingGetGroupList({isCommunityRelay:!0,limit:i,offset:r,groupList:n})):(r=d,this._pagingGetGroupList({limit:i,offset:r,groupList:n}))}catch(e){if(10018===e.ErrorCode)return t.warn("_pagingGetGroupList",`${this._name}._pagingGetGroupList response size exceeds the limit, request count:${i}`),i=50,this._pagingGetGroupList({isCommunityRelay:s,limit:i,offset:r,groupList:n});if(s)return 11e3===e.code&&t.debug("_pagingGetGroupList",`${this._name}._pagingGetGroupList ok. community unavailable`),n;throw e}})}},{key:"_pagingGetJoinedCommunityList",value:function _pagingGetJoinedCommunityList(e){return pe(this,void 0,void 0,function*(){const{common:{getCurrentUserID:t},OuterConstant:s,ssoLog:n}=this._core,{groupList:o}=e;let{limit:i,offset:r}=e;try{const e=yield Zc({limit:i,offset:r,type:s.GRP_COMMUNITY,memberAccount:t(),supportTopic:1,responseFilter:{GroupBaseInfoFilter:[...Va],SelfInfoFilter:[...ja]}},this._core),{GroupIdList:a=[],TotalCount:c=0}=e||{},u=this._convertGroupKey(a);o.push(...u);const l=r+i,d=!(c>l),h=`offset:${r} limit:${i} total:${c} isCompleted:${d} current:${o.length}`;return n.debug("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList ok. ${h}`),d?o:(r=l,this._pagingGetJoinedCommunityList({limit:i,offset:r,groupList:o}))}catch(e){if(10018===e.code)return n.warn("_pagingGetJoinedCommunityList",`${this._name}._pagingGetJoinedCommunityList response size exceeds the limit, request count:${i}`),i=50,this._pagingGetJoinedCommunityList({limit:i,offset:r,groupList:o});throw e}})}},{key:"_groupListTreeShaking",value:function _groupListTreeShaking(e){const t=new Map([...Xc.getLocalGroupList()]);for(let s=0,n=e.length;s<n;s++)t.delete(e[s].groupID);const s=[...t.keys()];for(let e=0,t=s.length;e<t;e++)Xc.deleteLocalGroup(s[e])}},{key:"_isSyncCompleted",value:function _isSyncCompleted(){return this._pagingStatus===za}},{key:"_convertGroupKey",value:function _convertGroupKey(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppDefinedData:n,ApplyJoinOption:o,CreateTime:i,FaceUrl:r,GroupId:a,Introduction:c,InviteJoinOption:u,LastInfoTime:l,LastMsgTime:d,MemberNum:h,MaxMemberNum:g,MuteAllMember:p,Name:_,NextMsgSeq:m,Notification:v,Owner_Account:f,Type:I,LastRecallTime:E,SelfInfo:S,AtInfoList:C=[],SupportTopic:M}=e[s],y=Kc(n),O=this._convertSelfInfo(S),A=this._convertAtInfoList(a,C);t.push({groupCustomField:y,joinOption:o,createTime:i,avatar:r,groupID:a,introduction:c,inviteOption:u,lastInfoTime:l,lastMsgTime:d,memberCount:h,maxMemberCount:g,muteAllMembers:p,name:_,nextMessageSeq:m,notification:v,ownerID:f,type:I,selfInfo:O,_lastRevokedTime:E,_groupAtInfoList:A,isSupportTopic:M})}return t}},{key:"_convertSelfInfo",value:function _convertSelfInfo(e){const{JoinTime:t,MsgFlag:s,MsgSeq:n,NoUnreadSeqList:o,Role:i}=e;return{joinTime:t,messageRemindType:s,readedSequence:n,excludedUnreadSequenceList:o,role:i}}},{key:"_convertAtInfoList",value:function _convertAtInfoList(e,t){if(0===t.length)return[];const s=[];return t.forEach(t=>{const{AtFlagList:n,AtMsgSeq:o,From_Account:i}=t;s.push({groupID:e,groupAtType:n,sequence:o,from:i})}),s}}])}()),su=new(function(){return _createClass(function _class72(){_classCallCheck(this,_class72),this._name="CreateGroup"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"createGroup",context:this})}},{key:"createGroup",value:function createGroup(e){return pe(this,void 0,void 0,function*(){var t;this._preCheckParams(e);const{helper:{ChatError:s}}=this._core;try{const{utils:{isEmpty:s},common:{getCurrentUserID:n},OuterConstant:{GRP_AVCHATROOM:o}}=this._core,i=yield function(e,t){return pe(this,void 0,void 0,function*(){const{name:s,type:n,groupID:o,introduction:i,notification:r,avatar:a,maxMemberNum:c,joinOption:u,inviteOption:l,memberList:d,groupCustomField:h,isSupportTopic:g}=e;let p,_;d&&(p=d.map(e=>{const{userID:t,memberCustomField:s}=e;return{Member_Account:t,AppMemberDefinedData:s?Wc(s):void 0}})),h&&(_=Wc(h));const m={Name:s,Type:n,GroupId:o,Introduction:i,Notification:r,FaceUrl:a,MaxMemberCount:c,ApplyJoinOption:u,InviteJoinOption:l,MemberList:p,AppDefinedData:_,SupportTopic:g,webPushFlag:1};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.create_group",data:m})})}(Object.assign(Object.assign({},e),{ownerID:n()}),this._core),{GroupId:r,OverJoinedGroupLimit_Account:a=[]}=i||{},c=`${this._name}.createGroup ok, type:${e.type} groupID:${r} overLimitUserIDList:${a}`;if(s(e.memberList)||s(a)||(e.memberList=null===(t=e.memberList)||void 0===t?void 0:t.filter(e=>a.includes(e.userID))),e.type===o)return eu({group:new Qc(Object.assign(Object.assign({},e),{groupID:r}))},{message:c});Xc.updateLocalGroup([Object.assign(Object.assign({},e),{groupID:r})]);const u=Xc.getLocalGroup(r);return this._notNeedSendCustomMessage(e)||(this._sendCustomMessage(r,e.type),Xc.emitGroupListUpdate()),eu({group:u},{message:c})}catch(t){const{errorCode:n,errorInfo:o}=t;throw new s({functionName:"createGroup",code:n,message:o,moreMessage:` groupID:${e.groupID}`})}})}},{key:"_preCheckParams",value:function _preCheckParams(e){const{type:t,groupID:s}=e,{utils:{isEmpty:n,isUndefined:o},common:{isCommunity:i}}=this._core,r=!n(s);if(!(()=>{const{GRP_PUBLIC:e,GRP_WORK:t,GRP_MEETING:s,GRP_AVCHATROOM:n,GRP_COMMUNITY:o}=La.core.OuterConstant;return[e,t,s,n,o]})().includes(t))throw new this._core.helper.ChatError({code:2600});if(!i({type:t})){if(r&&i({groupID:s}))throw new this._core.helper.ChatError({code:2602});o(e.isSupportTopic)||(e.isSupportTopic=void 0)}if(this._canIUseMemberList(t)||o(e.memberList)||(e.memberList=void 0),this._canIUseJoinOption(t)||o(e.joinOption)||(e.joinOption=void 0),i({type:t})){if(r&&!i({groupID:s}))throw new this._core.helper.ChatError({code:2602});e.isSupportTopic=this._canIUseTopic(e)?1:0}}},{key:"_canIUseMemberList",value:function _canIUseMemberList(e){return!jc(e)}},{key:"_canIUseJoinOption",value:function _canIUseJoinOption(e){return Bc(e)||this._core.common.isCommunity({type:e})}},{key:"_canIUseTopic",value:function _canIUseTopic(e){const{isSupportTopic:t}=e;return!0===t}},{key:"_notNeedSendCustomMessage",value:function _notNeedSendCustomMessage(e){const{type:t,isSupportTopic:s}=e,{OuterConstant:{GRP_AVCHATROOM:n,GRP_COMMUNITY:o}}=this._core;return t===n||t===o&&1===s}},{key:"_sendCustomMessage",value:function _sendCustomMessage(e,t){var s,n,o,i,r,a;const{OuterConstant:c,common:{t:u}}=this._core;let l=u("CREATE_GROUP"),d=0;t===c.GRP_COMMUNITY&&(l=u("CREATE_COMMUNITY"),d=1);const h={to:e,conversationType:"GROUP",payload:{data:JSON.stringify({businessID:"group_create",content:l,cmd:d,opUser:this._core.store.get("login").userId,version:4})}},g=null===(o=null===(n=null===(s=this._core)||void 0===s?void 0:s.message)||void 0===n?void 0:n.messageFactory)||void 0===o?void 0:o.createCustomMessage(h);null===(a=null===(r=null===(i=this._core)||void 0===i?void 0:i.message)||void 0===r?void 0:r.messageSender)||void 0===a||a.sendMessage(g,{})}}])}()),nu=new(function(){return _createClass(function _class73(){_classCallCheck(this,_class73),this._name="AttributesDataHandler",this._groupAttributesCache=new Map,this._groupAttributesCacheValuesCopy={}},[{key:"init",value:function init(e){this._core=e;const{helper:t,constants:s}=e;t.registerWorkflowStep(s.WORKFLOW_NAME.SYNC_SERVER_INFO_AFTER_RE_ONLINE,s.WORKFLOW_STEP.GROUP_ATTRIBUTE_CACHE_CLEAR,this.clearLocalMainSequence,this)}},{key:"clearLocalMainSequence",value:function clearLocalMainSequence(){this._groupAttributesCache.forEach(e=>{e.localMainSequence=0})}},{key:"isGroupAttributesUpdated",value:function isGroupAttributesUpdated(e){const{elements:{newGroupProfile:t}}=e,{utils:{isEmpty:s,isUndefined:n}}=this._core;return!n(t)&&!s(t.groupAttributeOption)}},{key:"handleGroupAttributesUpdated",value:function handleGroupAttributesUpdated(e){const{groupID:t,groupAttributeOption:s}=e,{serverMainSequence:n,groupAttributeList:o=[],operation:i}=s;this._core.ssoLog.debug("handleGroupAttributesUpdated",`${this._name}.handleGroupAttributesUpdated groupID:${t} operation:${i}`);const{utils:{isUndefined:r}}=this._core;r(i)||(this.refreshGroupAttributesCache({groupID:t,serverMainSequence:n,groupAttributeList:o,operation:i}),this.emitGroupAttributesUpdated(t))}},{key:"initGroupAttributesCache",value:function initGroupAttributesCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupAttributesCache.set(t,{lastUpdateTime:0,localMainSequence:0,serverMainSequence:0,avChatRoomKey:s,values:new Map}),this._core.ssoLog.debug("initGroupAttributesCache",`${this._name}.initGroupAttributesCache. groupID:${t} avChatRoomKey:${s}`)}},{key:"hasGroupAttributesCache",value:function hasGroupAttributesCache(e){return this._groupAttributesCache.has(e)}},{key:"getGroupAttributesCache",value:function getGroupAttributesCache(e){return this.hasGroupAttributesCache(e)||this.initGroupAttributesCache({groupID:e}),this._groupAttributesCache.get(e)}},{key:"deleteGroupAttributesCache",value:function deleteGroupAttributesCache(e){this.hasGroupAttributesCache(e)&&this._groupAttributesCache.delete(e)}},{key:"refreshGroupAttributesCache",value:function refreshGroupAttributesCache(e){const{groupID:t,serverMainSequence:s,groupAttributeList:n,operation:o}=e;if(this.hasGroupAttributesCache(t)){const e=this.getGroupAttributesCache(t),{localMainSequence:i}=e;5!==o&&s-i!==1||(e.serverMainSequence=s,e.localMainSequence=s,e.lastUpdateTime=Date.now(),this._updateGroupAttributesCacheValues({groupAttributes:e,groupAttributeList:n,operation:o})),s-i>1&&(e.serverMainSequence=s),this._groupAttributesCache.set(t,e),this._core.ssoLog.debug("refreshGroupAttributesCache",`${this._name}.refreshGroupAttributesCache. operation:${o} localMainSequence:${i} serverMainSequence:${s}`)}}},{key:"_updateGroupAttributesCacheValues",value:function _updateGroupAttributesCacheValues(e){const{groupAttributes:t,groupAttributeList:s=[],operation:n}=e;3!==n?4!==n?(1===n&&t.values.clear(),s.forEach(e=>{const{key:s,value:n,sequence:o}=e;t.values.set(s,{value:n,sequence:o})})):s.forEach(e=>{t.values.delete(e.key)}):t.values.clear()}},{key:"getGroupAttributesCacheValues",value:function getGroupAttributesCacheValues(e){var t;const{groupID:s,keyList:n=[]}=e,o={};if(this.hasGroupAttributesCache(s)){const{values:e}=this.getGroupAttributesCache(s);if(0===n.length){for(const s of e.keys())o[s]=(null===(t=e.get(s))||void 0===t?void 0:t.value)||"";return o}return n.forEach(t=>{var s;e.has(t)&&(o[t]=(null===(s=e.get(t))||void 0===s?void 0:s.value)||"")}),o}return o}},{key:"saveGroupAttributesCacheValuesCopy",value:function saveGroupAttributesCacheValuesCopy(e){this._groupAttributesCacheValuesCopy=this.getGroupAttributesCacheValues({groupID:e})}},{key:"emitGroupAttributesUpdated",value:function emitGroupAttributesUpdated(e){var t,s;const{OuterConstant:{GRP_ROOM:n,GRP_LIVE:o}}=this._core,i=this.getGroupAttributesCacheValues({groupID:e}),r=this._core.appStore.groupStore.getGroup(e),{updatedKeyList:a,deletedKeyList:c}=this._computeValuesChangedData(i);0===a.length&&0===c.length||([n,o].includes(r.type)?(this._core.ssoLog.debug("RICH_STATUS_CHANGED",`${this._name}.emitRichStatusChanged update count:${a.length}, delete count:${c.length}`),this._emitEvent({name:null===(t=this._core)||void 0===t?void 0:t.OuterEvent.RICH_STATUS_CHANGED,data:{groupID:e,richStatus:i,updatedKeyList:a,deletedKeyList:c}})):(this._core.ssoLog.debug("emitGroupAttributesUpdated",`${this._name}.emitGroupAttributesUpdated update count:${a.length}, delete count:${c.length}`),this._emitEvent({name:null===(s=this._core)||void 0===s?void 0:s.OuterEvent.GROUP_ATTRIBUTES_UPDATED,data:{groupID:e,groupAttributes:i,updatedKeyList:a,deletedKeyList:c}})))}},{key:"_computeValuesChangedData",value:function _computeValuesChangedData(e){const{utils:{isUndefined:t}}=this._core,s=[],n=[];return Object.keys(e).forEach(t=>{e[t]!==this._groupAttributesCacheValuesCopy[t]&&s.push(t)}),Object.keys(this._groupAttributesCacheValuesCopy).forEach(s=>{t(e[s])&&n.push(s)}),this._groupAttributesCacheValuesCopy={},{updatedKeyList:s,deletedKeyList:n}}},{key:"_emitEvent",value:function _emitEvent(e){var t;null===(t=this._core)||void 0===t||t.notificationCenter.emitOuterEvent(e.name,e)}},{key:"convertKeyValueMapToList",value:function convertKeyValueMapToList(e){const t=[];return Object.keys(e).forEach(s=>{t.push({key:s,value:e[s]})}),t}},{key:"reset",value:function reset(){this._groupAttributesCache.clear(),this._groupAttributesCacheValuesCopy={}}}])}()),ou=new(function(){return _createClass(function _class74(){_classCallCheck(this,_class74),this._name="DismissGroup"},[{key:"init",value:function init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"dismissGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Pa)})}},{key:"dismissGroup",value:function dismissGroup(e){return pe(this,void 0,void 0,function*(){const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.destroy_group",data:s})})}(e,this._core);const{type:t}=Xc.getLocalGroup(e);return Xc.deleteLocalGroup(e),Xc.emitGroupListUpdate(),nu.deleteGroupAttributesCache(e),eu({groupID:e,type:t},{message:e})}catch(e){const{errorCode:s,errorInfo:n}=e;throw new t({functionName:"dismissGroup",code:s,message:n})}})}}])}()),iu=new(function(){return _createClass(function _class75(){_classCallCheck(this,_class75),this._name="GetGroupProfile"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupProfile",context:this})}},{key:"getGroupProfile",value:function getGroupProfile(e){return pe(this,void 0,void 0,function*(){const{groupID:t,groupCustomFieldFilter:s}=e,n={groupIDList:[t],responseFilter:{GroupBaseInfoFilter:[...Va],AppDefinedDataFilter_Group:s,MemberInfoFilter:[...Ha]}},{helper:{ChatError:o}}=this._core;try{const e=yield this.getGroupProfileAdvance(n),{successGroupList:s,failureGroupList:o}=e;if(o.length>0)throw o[0];let i;return!Xc.hasLocalGroup(t)&&jc(s[0].type)?i=new Qc(s[0]):(Xc.updateLocalGroup(s),i=Xc.getLocalGroup(t)),i.isSupportTopic||Xc.updateConversationGroupProfile(t),eu({group:i},{message:`groupID:${t}`})}catch(e){const{code:t,message:s}=e;throw new o({functionName:"getGroupProfile",code:t,message:s})}})}},{key:"getGroupProfileAdvance",value:function getGroupProfileAdvance(e){return pe(this,void 0,void 0,function*(){const{groupIDList:t}=e,{common:{isCommunity:s}}=this._core,n=t.filter(e=>!s({groupID:e})),o=t.filter(e=>s({groupID:e}));n.length>50&&(n.length=50),o.length>50&&(o.length=50);const i=yield Promise.all([this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:n})),this._getGroupProfileAdvance(Object.assign(Object.assign({},e),{groupIDList:o,isCommunityProfile:!0}))]),r=[],a=[];return i.forEach(e=>{r.push(...e.successGroupList),a.push(...e.failureGroupList)}),{successGroupList:r,failureGroupList:a}})}},{key:"_getGroupProfileAdvance",value:function _getGroupProfileAdvance(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t,utils:{isUndefined:s}}=this._core,{isCommunityProfile:n=!1}=e,o=ge(e,["isCommunityProfile"]);if(0===o.groupIDList.length)return{successGroupList:[],failureGroupList:[]};try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupIDList:s,responseFilter:n}=e,o={GroupIdList:s,ResponseFilter:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_self_member_info",data:o})})}(o,this._core),{GroupInfo:n=[]}=e||{},i=this._convertGroupProfileKey(n),r=i.filter(e=>s(e.errorCode)||0===e.errorCode),a=i.filter(e=>e.errorCode&&0!==e.errorCode).map(e=>({code:e.errorCode,message:e.errorInfo,data:{groupID:e.groupID}}));return t.debug("_getGroupProfileAdvance",`${this._name}._getGroupProfileAdvance ok, groupID:${o.groupIDList.join(",")}`),{successGroupList:r,failureGroupList:a}}catch(e){if(n)return{successGroupList:[],failureGroupList:[]};throw e}})}},{key:"_convertGroupProfileKey",value:function _convertGroupProfileKey(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppDefinedData:n,ApplyJoinOption:o,CreateTime:i,FaceUrl:r,GroupId:a,InfoSeq:c,Introduction:u,InviteJoinOption:l,LastInfoTime:d,LastMsgTime:h,MaxMemberNum:g,MemberNum:p,MuteAllMember:_,Name:m,NextMsgSeq:v,Notification:f,Owner_Account:I,ShutUpAllMember:E,ShutUpUntil:S,Type:C,MemberList:M,ErrorCode:y,ErrorInfo:O}=e[s],A=Kc(n),T=this._convertMembers(M);t.push({groupCustomField:A,joinOption:o,createTime:i,avatar:r,groupID:a,infoSequence:c,introduction:u,inviteOption:l,lastInfoTime:d,lastMsgTime:h,maxMemberCount:g,memberCount:p,muteAllMembers:_,name:m,nextMessageSeq:v,notification:f,ownerID:I,shutUpAllMember:E,muteUntil:S,type:C,members:T,errorCode:y,errorInfo:O})}return t}},{key:"_convertMembers",value:function _convertMembers(e){if(!e)return[];const t=[];for(let s=0,n=e.length;s<n;s++){const{AppMemberDefinedData:n,JoinTime:o,Member_Account:i,MsgFlag:r,MsgSeq:a,NameCard:c,Role:u}=e[s],l=Kc(n);t.push({memberCustomField:l,joinTime:o,userID:i,messageRemindType:r,sequence:a,nameCard:c,role:u})}return t}}])}()),ru=new(function(){return _createClass(function _class76(){_classCallCheck(this,_class76),this._groupCountersMap=new Map},[{key:"init",value:function init(e){this._core=e}},{key:"getLocalGroupCounters",value:function getLocalGroupCounters(e){return this._hasLocalGroupCounters(e)||this.initGroupCountersCache({groupID:e}),this._groupCountersMap.get(e)}},{key:"updateLocalGroupCounters",value:function updateLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:n}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:o,groupCounterSeq:i}=this.getLocalGroupCounters(t);if(n>0&&n<i)return;s.forEach(t=>{const{Key:s,Value:n=0}=t;e.set(s,n)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:n,counters:e,avChatRoomKey:o})}}},{key:"initGroupCountersCache",value:function initGroupCountersCache(e){const{groupID:t,avChatRoomKey:s}=e;this._groupCountersMap.set(t,{lastUpdateTime:0,groupCounterSeq:0,counters:new Map,avChatRoomKey:s})}},{key:"getLocalCounters",value:function getLocalCounters(e,t){const s={};if(!this._hasLocalGroupCounters(e))return s;const{counters:n}=this.getLocalGroupCounters(e);if(t.length>0)t.forEach(e=>{n.has(e)&&(s[e]=n.get(e))});else for(const e of n.keys())s[e]=n.get(e);return s}},{key:"deleteLocalGroupCounters",value:function deleteLocalGroupCounters(e){const{groupID:t,counterList:s=[],groupCounterSeq:n}=e;if(this._hasLocalGroupCounters(t)){const{counters:e,avChatRoomKey:o}=this.getLocalGroupCounters(t);s.forEach(t=>{e.delete(t.key)}),this._groupCountersMap.set(t,{lastUpdateTime:Date.now(),groupCounterSeq:n,counters:e,avChatRoomKey:o})}}},{key:"setGroupCounters",value:function setGroupCounters(e,t){if(!this._hasLocalGroupCounters(e))return;const s=this.getLocalGroupCounters(e),{counters:n}=s;let o=!1;Object.entries(t).forEach(([e,t])=>{n.has(e)&&n.get(e)!==t&&(n.set(e,t),o=!0)}),o&&this._groupCountersMap.set(e,Object.assign(Object.assign({},s),{lastUpdateTime:Date.now(),counters:n}))}},{key:"_hasLocalGroupCounters",value:function _hasLocalGroupCounters(e){return this._groupCountersMap.has(e)}},{key:"reset",value:function reset(){this._groupCountersMap.clear()}}])}()),au=new(function(){return _createClass(function _class77(){_classCallCheck(this,_class77),this._name="JoinGroup"},[{key:"init",value:function init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"joinGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Pa)})}},{key:"joinGroup",value:function joinGroup(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{helper:{ChatError:s},OuterConstant:n,ssoLog:o}=this._core;try{if(Xc.hasLocalGroup(t))try{return yield iu.getGroupProfile({groupID:t}),eu({status:n.JOIN_STATUS_ALREADY_IN_GROUP,group:Xc.getLocalGroup(t)},{message:`groupID:${t} joinedStatus:${n.JOIN_STATUS_ALREADY_IN_GROUP}`})}catch(s){return o.warn("joinGroup",`${this._name}.joinGroup ${t} was unjoined, start to join!`),Xc.deleteLocalGroup(t),yield this._applyJoinGroup(e)}return yield this._applyJoinGroup(e)}catch(e){const{errorCode:n,errorInfo:o}=e;throw new s({functionName:"joinGroup",code:n,message:o,moreMessage:`groupID:${t}`})}})}},{key:"_applyJoinGroup",value:function _applyJoinGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t,helper:s,ssoLog:n}=this._core,{groupID:o}=e,i=Object.assign({},e),r=s.checkBusinessCapabilityBits("AV_HISTORY_MSG");r&&(i.historyMessageFlag=1);const a=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,applyMessage:n,historyMessageFlag:o}=e,i={GroupId:s,ApplyMsg:n,HugeGroupHistoryMsgFlag:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.apply_join_group",data:i})})}(i,this._core),{Type:c,JoinedStatus:u,LongPollingKey:l,StartSeq:d,HugeGroupFlag:h,AVChatRoomKey:g,RspMsgList:p=[]}=a||{},_=`groupID:${o} joinedStatus:${u} longPollingKey:${l} startSeq:${d} avChatRoomFlag:${h} canGetAVChatRoomHistoryMsg:${r}, historyMessageCount:${p.length}`;n.debug("_applyJoinGroup",`${this._name}._applyJoinGroup ok, ${_}`);let m=new Qc({groupID:o,type:c});if(u===t.JOIN_STATUS_WAIT_APPROVAL)return eu({status:t.JOIN_STATUS_WAIT_APPROVAL,group:m});if(u===t.JOIN_STATUS_SUCCESS){try{m=(yield iu.getGroupProfile({groupID:o})).data.group}catch(e){n.warn("_applyJoinGroup",`${this._name}._applyJoinGroup getGroupProfile failed, groupID: ${o}, errorCode:${null==e?void 0:e.code}`)}return this._handleJoinResult({group:m,avChatRoomFlag:h,longPollingKey:l,startSequence:d,avChatRoomKey:g,historyMessageList:p})}throw new this._core.helper.ChatError({code:2660})})}},{key:"_handleJoinResult",value:function _handleJoinResult(e){const{group:t,avChatRoomFlag:s,avChatRoomKey:n}=e;return 1===s?(nu.initGroupAttributesCache({groupID:t.groupID,avChatRoomKey:n}),ru.initGroupCountersCache({groupID:t.groupID,avChatRoomKey:n}),eu(e)):(Xc.updateLocalGroup([t]),Xc.emitGroupListUpdate(),eu({status:this._core.OuterConstant.JOIN_STATUS_SUCCESS,group:t},{message:`groupID:${t.groupID}`}))}}])}()),cu=new(function(){return _createClass(function _class78(){_classCallCheck(this,_class78),this._name="QuitGroup"},[{key:"init",value:function init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"quitGroup",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Pa)})}},{key:"quitGroup",value:function quitGroup(e){return pe(this,void 0,void 0,function*(){if(!Xc.hasLocalGroup(e))throw new this._core.helper.ChatError({code:2623});const{helper:{ChatError:t}}=this._core;try{yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.quit_group",data:s})})}(e,this._core);const{type:t}=Xc.getLocalGroup(e);return Xc.deleteLocalGroup(e),Xc.emitGroupListUpdate(),nu.deleteGroupAttributesCache(e),eu({groupID:e,type:t},{message:`groupID:${e}`})}catch(s){const{errorCode:n,errorInfo:o}=s;throw new t({functionName:"quitGroup",code:n,message:o,moreMessage:`groupID:${e}`})}})}}])}()),uu=new(function(){return _createClass(function _class79(){_classCallCheck(this,_class79),this._name="SearchGroup"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"searchGroupByID",context:this})}},{key:"searchGroupByID",value:function searchGroupByID(e){return pe(this,void 0,void 0,function*(){try{const t=yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupIdList:[e],GroupBasePublicInfoFilter:[...Ba]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_public_info",data:s})})}(e,this._core),{GroupInfo:s=[]}=t||{},{AppDefinedData:n=[],ApplyJoinOption:o,CreateTime:i,FaceUrl:r,Introduction:a,InviteJoinOption:c,MaxMemberNum:u,MemberNum:l,Name:d,Owner_Account:h,Type:g,ErrorCode:p,ErrorInfo:_}=s[0];if(0!==p)throw new this._core.helper.ChatError({code:p,message:_});const m=Kc(n),v=new Qc({groupID:e,name:d,avatar:r,introduction:a,joinOption:o,inviteOption:c,maxMemberCount:u,memberCount:l,type:g,ownerID:h,createTime:i,groupCustomField:m});return eu({group:v})}catch(e){const{errorCode:t,errorInfo:s}=e;throw new this._core.helper.ChatError({functionName:"searchGroupByID",code:t,message:s})}})}}])}()),lu=new(function(){return _createClass(function _class80(){_classCallCheck(this,_class80),this._name="UpdateGroupProfile"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"updateGroupProfile",context:this})}},{key:"updateGroupProfile",value:function updateGroupProfile(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{utils:{isUndefined:s,safeStringify:n},ssoLog:o,helper:i}=this._core;let r=Xc.getLocalGroup(t);if(r){const{type:n}=r;this._canIUseJoinOption(n)||s(e.joinOption)||(o.warn("updateGroupProfile",`${this._name}.updateGroupProfile groupID:${t} joinOption is unavailable for Work/Meeting/AVChatRoom`),e.joinOption=void 0)}s(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off");try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,name:n,avatar:o,introduction:i,notification:r,muteAllMembers:a,joinOption:c,inviteOption:u,groupCustomField:l}=e,d={GroupId:s,Name:n,FaceUrl:o,Introduction:i,Notification:r,ShutUpAllMember:a,ApplyJoinOption:c,InviteJoinOption:u,AppDefinedData:l?Wc(l):void 0};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_base_info",data:d})})}(e,this._core),r?(r.updateGroup(e),Xc.emitGroupListUpdate()):r=new Qc(e),eu({group:r},{message:`groupID:${t}`})}catch(t){const{errorCode:s,errorInfo:o}=t;throw new i.ChatError({code:s,message:o,moreMessage:`options:${n(e)}`})}})}},{key:"_canIUseJoinOption",value:function _canIUseJoinOption(e){return Bc(e)||this._core.common.isCommunity({type:e})}}])}()),du=new(function(){return _createClass(function _class81(){_classCallCheck(this,_class81),this._name="ChangeGroupOwner"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"changeGroupOwner",context:this})}},{key:"changeGroupOwner",value:function changeGroupOwner(e){return pe(this,void 0,void 0,function*(){const t="changeGroupOwner",{groupID:s,newOwnerID:n}=e,o=Xc.getLocalGroup(s),{helper:i,OuterConstant:r,common:{getCurrentUserID:a}}=this._core;if((null==o?void 0:o.type)===r.GRP_AVCHATROOM)throw new i.ChatError({functionName:t,code:2620});if(n===a())throw new i.ChatError({functionName:t,code:2621});try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,newOwnerID:n}=e,o={GroupId:s,NewOwner_Account:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.change_group_owner",data:o})})}(e,this._core),o.ownerID=n,Xc.emitGroupListUpdate(),eu({group:o})}catch(e){throw new i.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}}])}()),hu=new(function(){return _createClass(function _class82(){_classCallCheck(this,_class82),this._name="GetGroupOnlineMemberCount",this._onlineMemberCountMap=new Map},[{key:"init",value:function init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Pa)})}},{key:"getGroupOnlineMemberCount",value:function getGroupOnlineMemberCount(e){return pe(this,void 0,void 0,function*(){const t="getGroupOnlineMemberCount";if(!Xc.hasLocalGroup(e))return eu({memberCount:0});const s=Date.now();if(this._onlineMemberCountMap.has(e)){const t=this._onlineMemberCountMap.get(e),{lastReqTime:n=0,memberCount:o=0}=t||{};if(s-n<=6e4)return eu({memberCount:o})}try{const s=yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:s})})}(e,this._core),{OnlineMemberNum:n=0}=s||{};this._onlineMemberCountMap.set(e,{lastReqTime:Date.now(),memberCount:n});const o=`${this._name}.${t} ok. groupID:${e} memberCount:${n}`;return eu({memberCount:n},{message:o})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}}])}()),gu=new(function(){return _createClass(function _class83(){_classCallCheck(this,_class83)},[{key:"init",value:function init(e,t){e.ssoLog.debug("GroupAction.init"),tu.init(e),su.init(e),ou.init(e,t),au.init(e,t),cu.init(e,t),uu.init(e),iu.init(e),lu.init(e),du.init(e),hu.init(e,t)}},{key:"dismissGroup",value:function dismissGroup(e){return ou.dismissGroup(e)}},{key:"joinGroup",value:function joinGroup(e){return au.joinGroup(e)}},{key:"quitGroup",value:function quitGroup(e){return cu.quitGroup(e)}},{key:"getGroupOnlineMemberCount",value:function getGroupOnlineMemberCount(e){return hu.getGroupOnlineMemberCount(e)}}])}()),pu=new(function(){return _createClass(function _class84(){_classCallCheck(this,_class84),this._name="GetGroupApplicationList"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupApplicationList",context:this})}},{key:"getGroupApplicationList",value:function getGroupApplicationList(){return pe(this,void 0,void 0,function*(){const e="getGroupApplicationList";try{const t=yield Promise.all([this._getGroupApplicationList(),this._getGroupApplicationList({type:this._core.OuterConstant.GRP_COMMUNITY})]);this._core.ssoLog.debug("getGroupApplicationList",`${this._name}.${e} ok.`);const s=this._handleGroupApplicationResult([...t[0],...t[1]]);return eu({applicationList:s})}catch(t){throw new this._core.helper.ChatError({functionName:e,code:null==t?void 0:t.errorCode,message:null==t?void 0:t.errorInfo})}})}},{key:"_getGroupApplicationList",value:function _getGroupApplicationList(e){return pe(this,void 0,void 0,function*(){const{type:t,startTime:s=0,limit:n=20}=e||{},{common:o}=this._core;let i;try{i=yield function(e,t){return pe(this,void 0,void 0,function*(){const{type:s,startTime:n,limit:o,handleAccount:i}=e,r={Type:s,StartTime:n,Limit:o,Handle_Account:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_pendency",data:r})})}({type:t,startTime:s,limit:n,handleAccount:o.getCurrentUserID()},this._core)}catch(e){if(11e3!==(null==e?void 0:e.errorCode))throw e;i={}}const{NextStartTime:r=0,PendencyList:a=[]}=i||{};if(0===r)return a;const c=yield this._getGroupApplicationList(Object.assign(Object.assign({},e),{startTime:r}));return[...a,...c]})}},{key:"_handleGroupApplicationResult",value:function _handleGroupApplicationResult(e){const t=[];return e.forEach(e=>{const s=this._convertApplicationData(e),{handled:n}=s,o=ge(s,["handled"]);0===n&&t.push(o)}),t}},{key:"_convertApplicationData",value:function _convertApplicationData(e){const{Handled:t,AddTime:s,ApplyInviteMsg:n,Authentication:o,FromUserNickName:i,From_Account:r,GroupId:a,GroupName:c,PendencyType:u,To_Account:l}=e;return{handled:t,messageKey:s,applicant:r,applicantNick:i,groupID:a,groupName:c,authentication:o,applicationType:u,userID:l,note:n,addTime:s}}}])}()),_u=new(function(){return _createClass(function _class85(){_classCallCheck(this,_class85),this._name="HandleGroupApplication"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"handleGroupApplication",context:this})}},{key:"handleGroupApplication",value:function handleGroupApplication(e){return pe(this,void 0,void 0,function*(){const{application:t}=e,s=this._handleParams(e);try{2===(null==t?void 0:t.applicationType)?yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,handleAction:n,handleMessage:o,applicant:i,authentication:r,invitee:a}=e,c={GroupId:s,HandleMsg:n,ApprovalMsg:o,Applicant_Account:i,Authentication:r,Invited_Account:a};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_invite_join_permission_group",data:c})})}(s,this._core):yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,handleAction:n,handleMessage:o,applicant:i,authentication:r,messageKey:a}=e,c={GroupId:s,HandleMsg:n,ApprovalMsg:o,Applicant_Account:i,Authentication:r,MsgKey:a};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.handle_apply_join_group",data:c})})}(s,this._core);const e=Xc.getLocalGroup(s.groupID);return eu({group:e})}catch(e){throw new this._core.helper.ChatError({functionName:"handleGroupApplication",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},{key:"_handleParams",value:function _handleParams(e){var t;const{handleAction:s,handleMessage:n,message:o,application:i}=e;let r,a,c,u,l;if(o){const{payload:e}=o||{};r=e.operatorID,a=null===(t=e.groupProfile)||void 0===t?void 0:t.groupID,c=e.authentication,u=e.messageKey}else r=(null==i?void 0:i.applicant)||"",a=(null==i?void 0:i.groupID)||"",c=(null==i?void 0:i.authentication)||"",u=(null==i?void 0:i.messageKey)||0;return 2===(null==i?void 0:i.applicationType)&&(l=i.userID),{handleAction:s,handleMessage:n,applicant:r,invitee:l,groupID:a,authentication:c,messageKey:u}}}])}()),mu=new(function(){return _createClass(function _class86(){_classCallCheck(this,_class86)},[{key:"init",value:function init(e){e.ssoLog.debug("GroupApplication.init"),pu.init(e),_u.init(e)}}])}());let vu=function(){return _createClass(function vu(e){_classCallCheck(this,vu),this.userID="",this.avatar="",this.nick="",this.role="",this.joinTime="",this.nameCard="",this.muteUntil=0,this.memberCustomField=[],this.isOnline=!1,this.updateMember(e)},[{key:"updateMember",value:function updateMember(e){const{core:{utils:{isUndefined:t},common:{deepMerge:s}}}=La;t(e.muteTime)||(this.muteUntil=Math.floor((Date.now()+1e3*e.muteTime)/1e3)),t(e.onlineStatus)||(this.isOnline="Online"===e.onlineStatus);const n=[null,void 0,"",0,NaN];e.memberCustomField&&Hc(this.memberCustomField,e.memberCustomField),s(this,e,["memberCustomField","marks","onlineStatus","muteTime"],n)}}])}();function fu(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userID:n,muteTime:o,role:i,nameCard:r,memberCustomField:a}=e;let c;a&&(c=Wc(a));const u={GroupId:s,Member_Account:n,ShutUpTime:o,Role:i,NameCard:r,AppMemberDefinedData:c};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_member_info",data:u})})}var Iu=new(function(){return _createClass(function _class87(){_classCallCheck(this,_class87),this._name="GetGroupMemberList"},[{key:"init",value:function init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Pa)})}},{key:"getGroupMemberList",value:function getGroupMemberList(e){return pe(this,void 0,void 0,function*(){const t="getGroupMemberList",{groupID:s,offset:n=0,count:o=100,role:i="",filter:r=""}=e,a=Xc.getLocalGroup(s),c=o>100?100:o,u={groupID:s,offset:n,limit:c,memberRoleFilter:ec.includes(i)?[i]:void 0,memberInfoFilter:tc};try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{isCommunity:s}=t.common,{groupID:n,offset:o,limit:i,memberRoleFilter:r,memberInfoFilter:a}=e,c={GroupId:n,Limit:i,MemberRoleFilter:r,MemberInfoFilter:a};return s({groupID:n})?c.Next=String(o):c.Offset=o,t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_member_info",data:c})})}(u,this._core),{MemberList:o,MemberNum:i,Next:r}=e||{},l=`${this._name}.${t} ok, totalMemberCount:${i} next:${r}`,{utils:{isArray:d,isEmpty:h},common:{isCommunity:g}}=this._core;if(a&&(a.memberCount=i),!d(o)||0===o.length)return eu({memberList:[],offset:0},{message:l});let p=n+c;g({groupID:s})&&(p=h(r)?0:r),o.length<c&&(p=0);let _=this._convertMemberInfo(o);_=yield this._patchAvatarAndNick(_);const m=this._generateGroupMember(_);return eu({memberList:m,offset:p},{message:l})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},{key:"_convertMemberInfo",value:function _convertMemberInfo(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppMemberDefinedData:n,JoinTime:o,Member_Account:i,OnlineStatus:r,Role:a,ShutUpUntil:c,NameCard:u}=e[s],l=Kc(n);t.push({userID:i,joinTime:o,onlineStatus:r,role:a,muteUntil:c,memberCustomField:l,nameCard:u})}return t}},{key:"_patchAvatarAndNick",value:function _patchAvatarAndNick(e){return pe(this,void 0,void 0,function*(){var t;const s=e.map(e=>e.userID),n=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:s}),o=(null==n?void 0:n.data)||[],i=new Map(o.map(e=>[e.userID,e]));return e.forEach(e=>{if(i.has(e.userID)){const{nick:t="",avatar:s=""}=i.get(e.userID);e.nick=t,e.avatar=s}}),e})}},{key:"_generateGroupMember",value:function _generateGroupMember(e){const t=[];for(let s=0,n=e.length;s<n;s++){const n=new vu(e[s]);t.push(n)}return t}}])}()),Eu=new(function(){return _createClass(function _class88(){_classCallCheck(this,_class88),this._name="GetGroupMemberProfile"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupMemberProfile",context:this})}},{key:"getGroupMemberProfile",value:function getGroupMemberProfile(e){return pe(this,void 0,void 0,function*(){const t="getGroupMemberProfile",{groupID:s,userIDList:n,memberCustomFieldFilter:o}=e,i=Xc.getLocalGroup(s),{helper:r,utils:{isArray:a},ssoLog:c}=this._core;if(i&&jc(i.type))throw new r.ChatError({functionName:t,replacement1:t,code:2687});n.length>50&&(c.warn("getGroupMemberProfile",`${this._name}.${t} userIDList length:${n.length} exceeds limit 50`),n.splice(50));const u=`userIDList length:${n.length} groupID:${s}`;try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n,memberInfoFilter:o,memberCustomFieldFilter:i}=e,r={GroupId:s,Member_List_Account:n,MemberInfoFilter:o,AppDefinedDataFilter_GroupMember:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_specified_group_member_info",data:r})})}({groupID:s,userIDList:n,memberCustomFieldFilter:o,memberInfoFilter:[...tc]},this._core),{MemberList:t}=e||{};if(!a(t)||0===t.length)return eu({memberList:[]});let i=this._convertMemberInfo(t);i=yield this._getMemberAvatarAndNick(i);const r=this._generateGroupMember(i);return eu({memberList:r},{message:u})}catch(e){throw new r.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:u})}})}},{key:"_convertMemberInfo",value:function _convertMemberInfo(e){const t=[];for(let s=0,n=e.length;s<n;s++){const{AppMemberDefinedData:n,JoinTime:o,Member_Account:i,OnlineStatus:r,Role:a,ShutUpUntil:c,NameCard:u}=e[s],l=Kc(n);t.push({userID:i,joinTime:o,onlineStatus:r,role:a,muteUntil:c,memberCustomField:l,nameCard:u})}return t}},{key:"_getMemberAvatarAndNick",value:function _getMemberAvatarAndNick(e){return pe(this,void 0,void 0,function*(){var t;const s=e.map(e=>e.userID),n=yield null===(t=this._core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:s}),o=(null==n?void 0:n.data)||[],i=new Map(o.map(e=>[e.userID,e]));return e.forEach(e=>{if(i.has(e.userID)){const{nick:t="",avatar:s=""}=i.get(e.userID);e.nick=t,e.avatar=s}}),e})}},{key:"_generateGroupMember",value:function _generateGroupMember(e){const t=[];for(let s=0,n=e.length;s<n;s++){const n=new vu(e[s]);t.push(n)}return t}}])}()),Su=new(function(){return _createClass(function _class89(){_classCallCheck(this,_class89),this._name="AddGroupMember"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"addGroupMember",context:this})}},{key:"addGroupMember",value:function addGroupMember(e){return pe(this,void 0,void 0,function*(){const t="addGroupMember",{groupID:s,userIDList:n}=e,o=Xc.getLocalGroup(s),{helper:i}=this._core;if(o&&jc(o.type))throw new i.ChatError({functionName:t,code:2661});const r=n.map(e=>({Member_Account:e}));try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n}=e,o={GroupId:s,MemberList:n};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.add_group_member",data:o})})}({groupID:s,userIDList:r},this._core),{MemberList:t=[]}=e||{},{failureUserIDList:n,successUserIDList:i,existedUserIDList:a,overLimitUserIDList:c}=this._handleResult(t);return eu({failureUserIDList:n,successUserIDList:i,existedUserIDList:a,overLimitUserIDList:c,group:o},{message:` groupID:${s} successUserIDList:${i} failureUserIDList:${n} existedUserIDList:${a} overLimitUserIDList:${c}`})}catch(e){throw new i.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},{key:"_handleResult",value:function _handleResult(e){const t=[],s=[],n=[],o=[];return e.forEach(e=>{const{Result:i,Member_Account:r}=e;0===i?t.push(r):1===i?s.push(r):2===i?n.push(r):4===i&&o.push(r)}),{failureUserIDList:t,successUserIDList:s,existedUserIDList:n,overLimitUserIDList:o}}}])}()),Cu=new(function(){return _createClass(function _class90(){_classCallCheck(this,_class90),this._name="DeleteGroupMember"},[{key:"init",value:function init(e,t){this._core=e;const{helper:s}=e;s.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>!t.getInstalledSubPlugins().includes(Pa)})}},{key:"deleteGroupMember",value:function deleteGroupMember(e){return pe(this,void 0,void 0,function*(){const t="deleteGroupMember",{groupID:s,userIDList:n}=e,o=Xc.getLocalGroup(s),{helper:i,utils:{isUndefined:r},ssoLog:a}=this._core;if(r(o))throw new i.ChatError({functionName:t,code:2603});n.length>20&&(a.warn("deleteGroupMember",`${this._name}.${t} userIDList length:${n.length} exceeds limit 20`),n.splice(20));try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n,reason:o}=e,i={GroupId:s,MemberToDel_Account:n,Reason:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_member",data:i})})}({groupID:s,userIDList:n},this._core),eu({group:o,userIDList:n},{message:`groupID:${s} userIDList length:${n.length}`})}catch(e){throw new i.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}}])}()),Mu=new(function(){return _createClass(function _class91(){_classCallCheck(this,_class91),this._name="SetGroupMemberMuteTime"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberMuteTime",context:this})}},{key:"setGroupMemberMuteTime",value:function setGroupMemberMuteTime(e){return pe(this,void 0,void 0,function*(){const{helper:t}=this._core,{groupID:s,userID:n,muteTime:o}=e,i=` groupID:${s} userID:${n} muteTime:${o}`;this._preCheckSettingMuteParams(e);try{yield fu(e,this._core);const t=Xc.getLocalGroup(s),r=new vu({userID:n,muteTime:o});return eu({group:t,member:r},{message:i})}catch(e){throw new t.ChatError({functionName:"setGroupMemberMuteTime",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:i})}})}},{key:"_preCheckSettingMuteParams",value:function _preCheckSettingMuteParams(e){const{userID:t}=e,{store:s,helper:n}=this._core;if(t===s.get("login").userId)throw new n.ChatError({functionName:"setGroupMemberMuteTime",code:2685})}}])}()),yu=new(function(){return _createClass(function _class92(){_classCallCheck(this,_class92),this._name="SetGroupMemberRole"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberRole",context:this})}},{key:"setGroupMemberRole",value:function setGroupMemberRole(e){return pe(this,void 0,void 0,function*(){const t="setGroupMemberRole",{helper:s}=this._core,{groupID:n,userID:o,role:i}=e,r=`${this._name}.${t} ok, groupID:${n} userID:${o} role:${i}`;this._preCheckSettingRoleParams(e);try{yield fu(e,this._core);const t=Xc.getLocalGroup(n),s=new vu({userID:o,role:i});return eu({group:t,member:s},{message:r})}catch(e){throw new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:r})}})}},{key:"_preCheckSettingRoleParams",value:function _preCheckSettingRoleParams(e){var t;const{groupID:s,userID:n,role:o}=e,{store:i,helper:r,OuterConstant:a,common:{isCommunity:c}}=this._core,u=Xc.getLocalGroup(s);if((null===(t=null==u?void 0:u.selfInfo)||void 0===t?void 0:t.role)!==a.GRP_MBR_ROLE_OWNER)throw new r.ChatError({functionName:"setGroupMemberRole",code:2681});if(n===i.get("login").userId)throw new r.ChatError({functionName:"setGroupMemberRole",code:2684});const l=[...ec];if(c({groupID:s})&&l.push(a.GRP_MBR_ROLE_CUSTOM),!l.includes(o))throw new r.ChatError({functionName:"setGroupMemberRole",code:2683})}}])}()),Ou=new(function(){return _createClass(function _class93(){_classCallCheck(this,_class93),this._name="SetGroupMemberNameCard"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberNameCard",context:this})}},{key:"setGroupMemberNameCard",value:function setGroupMemberNameCard(e){return pe(this,void 0,void 0,function*(){var t;const s="setGroupMemberNameCard",{helper:n,common:{getCurrentUserID:o}}=this._core,{groupID:i,userID:r=o(),nameCard:a}=e,c=`${this._name}.${s} ok, groupID:${i} userID:${r} nameCard:${a}`;this._preCheckSettingNameCardParams(e);try{const e={groupID:i,userID:r,nameCard:a};yield fu(e,this._core);const s=Xc.getLocalGroup(i);r===(null===(t=null==s?void 0:s.selfInfo)||void 0===t?void 0:t.userID)&&(s.updateSelfInfo({nameCard:a}),Xc.emitGroupListUpdate(),Xc.updateConversationGroupProfile(i));const n=new vu({userID:r,nameCard:a});return eu({group:s,member:n},{message:c})}catch(e){throw new n.ChatError({functionName:s,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:c})}})}},{key:"_preCheckSettingNameCardParams",value:function _preCheckSettingNameCardParams(e){const{groupID:t}=e,{helper:s}=this._core,n=Xc.getLocalGroup(t);if(jc(null==n?void 0:n.type))throw new s.ChatError({functionName:"setGroupMemberNameCard",code:2687})}}])}()),Au=new(function(){return _createClass(function _class94(){_classCallCheck(this,_class94),this._name="SetGroupMemberCustomField"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupMemberCustomField",context:this})}},{key:"setGroupMemberCustomField",value:function setGroupMemberCustomField(e){return pe(this,void 0,void 0,function*(){const t="setGroupMemberCustomField",{helper:s,common:{getCurrentUserID:n}}=this._core;this._preCheckSettingCustomFiledParams(e);const{groupID:o,userID:i=n(),memberCustomField:r}=e,a=`${this._name}.${t} ok, groupID:${o}userID:${i} memberCustomField:${JSON.stringify(r)}`;try{const e={groupID:o,userID:i,memberCustomField:r};yield fu(e,this._core);const t=Xc.getLocalGroup(o),s=new vu({userID:i,memberCustomField:r});return eu({group:t,member:s},{message:a})}catch(e){throw new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo,moreMessage:a})}})}},{key:"_preCheckSettingCustomFiledParams",value:function _preCheckSettingCustomFiledParams(e){const{groupID:t}=e,{helper:s}=this._core,n=Xc.getLocalGroup(t);if(jc(null==n?void 0:n.type))throw new s.ChatError({functionName:"setGroupMemberCustomField",code:2687})}}])}()),Tu=new(function(){return _createClass(function _class95(){_classCallCheck(this,_class95)},[{key:"init",value:function init(e,t){e.ssoLog.debug("GroupMember.init"),Iu.init(e,t),Eu.init(e),Su.init(e),Cu.init(e,t),Mu.init(e),yu.init(e),Ou.init(e),Au.init(e)}},{key:"getGroupMemberList",value:function getGroupMemberList(e){return Iu.getGroupMemberList(e)}},{key:"deleteGroupMember",value:function deleteGroupMember(e){return Cu.deleteGroupMember(e)}}])}()),Ru=new(function(){return _createClass(function _class96(){_classCallCheck(this,_class96)},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupCounters",context:this})}},{key:"getGroupCounters",value:function getGroupCounters(e){return pe(this,void 0,void 0,function*(){const t="getGroupCounters";try{Yc(t,wa);const{groupID:s,keyList:n=[]}=e,{avChatRoomKey:o,lastUpdateTime:i}=ru.getLocalGroupCounters(s);if(!(Date.now()-i>=this._getExpireTime()))return{code:0,data:{counters:ru.getLocalCounters(s,n)}};const r=yield function(e){return pe(this,void 0,void 0,function*(){const{groupID:t,GroupCounterKeys:s,avChatRoomKey:n}=e,{common:o}=La.core,i={GroupId:t,keyList:s,BytesKey:n};return o.buildAndSendPacket({servcmd:"group_open_http_svc.get_group_counter",data:i})})}({groupID:s,keyList:n,avChatRoomKey:o}),{GroupCounter:a=[],GroupCounterSeq:c}=r;return ru.updateLocalGroupCounters({groupID:s,counterList:a,groupCounterSeq:c}),{code:0,data:{counters:ru.getLocalCounters(s,n)}}}catch(e){zc(t,e)}})}},{key:"_getExpireTime",value:function _getExpireTime(){const{store:e,utils:{isUndefined:t}}=this._core,s=e.get("cloudConfig")||{},{grp_counter_expire_time:n}=s;return t(n)?3e4:Number(n)}}])}()),Du=new(function(){return _createClass(function _class97(){_classCallCheck(this,_class97)},[{key:"init",value:function init(e){const{helper:t}=e;t.registerApi({apiName:"setGroupCounters",context:this}),t.registerApi({apiName:"increaseGroupCounter",context:this}),t.registerApi({apiName:"decreaseGroupCounter",context:this})}},{key:"setGroupCounters",value:function setGroupCounters(e){return pe(this,void 0,void 0,function*(){return this._handleCounterOperation("Set",e)})}},{key:"increaseGroupCounter",value:function increaseGroupCounter(e){return pe(this,void 0,void 0,function*(){return this._handleCounterOperation("Increase",e)})}},{key:"decreaseGroupCounter",value:function decreaseGroupCounter(e){return pe(this,void 0,void 0,function*(){return this._handleCounterOperation("Decrease",e)})}},{key:"_handleCounterOperation",value:function _handleCounterOperation(e,t){return pe(this,void 0,void 0,function*(){const s=`${e}GroupCounter`;try{Yc(s,wa);const{groupID:n,key:o,value:i=0}=t,{avChatRoomKey:r}=ru.getLocalGroupCounters(n),a="Set"===e?this._convertObjectToList(t.counters):[{Key:o,Value:i}],c=yield this._updateGroupCounters({groupID:n,counterList:a,avChatRoomKey:r,mode:e});return ru.setGroupCounters(n,c),{code:0,data:{counters:c}}}catch(e){zc(s,e)}})}},{key:"_updateGroupCounters",value:function _updateGroupCounters(e){return pe(this,void 0,void 0,function*(){const t=yield function(e){const{groupID:t,counterList:s,mode:n,avChatRoomKey:o}=e,{common:i}=La.core,r={GroupId:t,GroupCounter:s,Mode:n,BytesKey:o};return i.buildAndSendPacket({servcmd:"group_open_http_svc.update_group_counter",data:r})}(e),{GroupCounter:s=[]}=t,n={};return s.forEach(e=>{const{Key:t,Value:s=0}=e;n[t]=s}),n})}},{key:"_convertObjectToList",value:function _convertObjectToList(e){return Object.entries(e).map(([e,t])=>({Key:e,Value:t||0}))}}])}()),bu=new(function(){return _createClass(function _class98(){_classCallCheck(this,_class98)},[{key:"init",value:function init(e){this._core=e,Ru.init(e),Du.init(e)}},{key:"isGroupCounterUpdated",value:function isGroupCounterUpdated(e){const{elements:{groupCounterInfo:t}}=e,{utils:{isEmpty:s}}=this._core;return!s(t)}},{key:"handleGroupCounterUpdated",value:function handleGroupCounterUpdated(e){const{to:t,elements:{groupCounterInfo:s}}=e;s.forEach(e=>{const{type:s,groupCounterSeq:n,counterList:o=[]}=e;0!==s&&2!==s||this._processAndNotifyCounterUpdate(t,n,o),1===s&&ru.deleteLocalGroupCounters({groupID:t,groupCounterSeq:n,counterList:o})})}},{key:"_processAndNotifyCounterUpdate",value:function _processAndNotifyCounterUpdate(e,t,s){const{OuterEvent:n,notificationCenter:o}=this._core;ru.updateLocalGroupCounters({groupID:e,groupCounterSeq:t,counterList:s}),s.forEach(({Key:t,Value:s=0})=>{o.emitOuterEvent(n.GROUP_COUNTER_UPDATED,{name:n.GROUP_COUNTER_UPDATED,data:{groupID:e,key:t,value:s}})})}},{key:"reset",value:function reset(){ru.reset()}}])}()),Nu=new(function(){return _createClass(function _class99(){_classCallCheck(this,_class99),this._name="InitGroupAttributes"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"initGroupAttributes",context:this})}},{key:"initGroupAttributes",value:function initGroupAttributes(e){return pe(this,void 0,void 0,function*(){const{groupID:t,groupAttributes:s}=e,{serverMainSequence:n,avChatRoomKey:o}=nu.getGroupAttributesCache(t),i=nu.convertKeyValueMapToList(s);try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,groupAttributeList:o,avChatRoomKey:i}=e,r={GroupId:s,AttrMainSeq:n,GroupAttr:o,BytesKey:i,AttrControl:["RaceConflict"]};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.set_group_attr",data:r})})}({groupID:t,avChatRoomKey:o,groupAttributeList:i,mainSequence:n},this._core),{AttrMainSeq:r,GroupAttr:a}=e||{},c=a.map(e=>{const{Key:t,seq:n}=e;return{key:t,value:s[t],sequence:n}});return nu.saveGroupAttributesCacheValuesCopy(t),nu.refreshGroupAttributesCache({groupID:t,serverMainSequence:r,groupAttributeList:c,operation:1}),nu.emitGroupAttributesUpdated(t),eu({groupAttributes:s},{message:` groupID:${t} serverMainSequence:${r}`})}catch(e){throw new this._core.helper.ChatError({functionName:"initGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}}])}()),Lu=new(function(){return _createClass(function _class100(){_classCallCheck(this,_class100),this._name="SetGroupAttributes"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"setGroupAttributes",context:this}),t.registerExperimentalAPI("setRichStatus",this)}},{key:"setGroupAttributes",value:function setGroupAttributes(e){return pe(this,void 0,void 0,function*(){const{groupID:t,groupAttributes:s,richStatusMode:n}=e,{serverMainSequence:o,avChatRoomKey:i,values:r}=nu.getGroupAttributesCache(t),a=nu.convertKeyValueMapToList(s).map(e=>{var t;const{key:s,value:n}=e;return{key:s,value:n,seq:(null===(t=r.get(e.key))||void 0===t?void 0:t.sequence)||0}});try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,groupAttributeList:o,avChatRoomKey:i,richStatusMode:r}=e,a={GroupId:s,AttrMainSeq:n,GroupAttr:o,BytesKey:i,AttrControl:["RaceConflict"],AllowRoomEngineOpt:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.modify_group_attr",data:a})})}({groupID:t,avChatRoomKey:i,groupAttributeList:a,mainSequence:o,richStatusMode:n},this._core),{AttrMainSeq:r,GroupAttr:c}=e||{},u=c.map(e=>{const{Key:t,seq:n}=e;return{key:t,value:s[t],sequence:n}});return nu.saveGroupAttributesCacheValuesCopy(t),nu.refreshGroupAttributesCache({groupID:t,serverMainSequence:r,groupAttributeList:u,operation:2}),nu.emitGroupAttributesUpdated(t),eu({groupAttributes:s},{message:` groupID:${t} serverMainSequence:${r}`})}catch(e){throw new this._core.helper.ChatError({functionName:"setGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},{key:"setRichStatus",value:function setRichStatus(e){return pe(this,void 0,void 0,function*(){const{groupID:t,richStatus:s}=e;return this.setGroupAttributes({groupID:t,groupAttributes:s,richStatusMode:!0})})}}])}()),Pu=new(function(){return _createClass(function _class101(){_classCallCheck(this,_class101),this._name="DeleteGroupAttributes"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"deleteGroupAttributes",context:this}),t.registerExperimentalAPI("deleteRichStatus",this)}},{key:"deleteGroupAttributes",value:function deleteGroupAttributes(e){return pe(this,void 0,void 0,function*(){const t="deleteGroupAttributes",{groupID:s,keyList:n=[],richStatusMode:o}=e;try{let e;e=0===n.length?yield this._clearGroupAttributes(s,{richStatusMode:o}):yield this._deleteGroupAttributes(s,{keyList:n,richStatusMode:o});const{resultList:i,serverMainSequence:r,operation:a,groupAttributeList:c}=e||{},u=`${this._name}.${t} ok. groupID:${s} operation: ${a}`;return nu.saveGroupAttributesCacheValuesCopy(s),nu.refreshGroupAttributesCache({groupID:s,serverMainSequence:r,groupAttributeList:c,operation:a}),nu.emitGroupAttributesUpdated(s),eu({keyList:i},{message:u})}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},{key:"deleteRichStatus",value:function deleteRichStatus(e){return pe(this,void 0,void 0,function*(){return this.deleteGroupAttributes(Object.assign(Object.assign({},e),{richStatusMode:!0}))})}},{key:"_deleteGroupAttributes",value:function _deleteGroupAttributes(e,t){return pe(this,void 0,void 0,function*(){const{serverMainSequence:s,avChatRoomKey:n,values:o}=nu.getGroupAttributesCache(e),{keyList:i,richStatusMode:r}=t,a=[],c=[];i.forEach(e=>{if(o.has(e)){const{sequence:t=0}=o.get(e)||{};c.push({key:e,seq:t}),a.push(e)}});const u=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,groupAttributeList:o,avChatRoomKey:i,richStatusMode:r}=e,a={GroupId:s,AttrMainSeq:n,GroupAttr:o,BytesKey:i,AttrControl:["RaceConflict"],AllowRoomEngineOpt:r};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.delete_group_attr",data:a})})}({groupID:e,avChatRoomKey:n,groupAttributeList:c,mainSequence:s,richStatusMode:r},this._core),{AttrMainSeq:l}=u||{};return{resultList:a,serverMainSequence:l,groupAttributeList:c,operation:4}})}},{key:"_clearGroupAttributes",value:function _clearGroupAttributes(e,t){return pe(this,void 0,void 0,function*(){const{serverMainSequence:s,avChatRoomKey:n,values:o}=nu.getGroupAttributesCache(e),{richStatusMode:i}=t||{},r=[...o.keys()],a=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,mainSequence:n,avChatRoomKey:o,richStatusMode:i}=e,r={GroupId:s,AttrMainSeq:n,BytesKey:o,AttrControl:["RaceConflict"],AllowRoomEngineOpt:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.clear_group_attr",data:r})})}({groupID:e,avChatRoomKey:n,mainSequence:s,richStatusMode:i},this._core),{AttrMainSeq:c}=a||{};return{resultList:r,serverMainSequence:c,operation:3}})}}])}()),Gu=new(function(){return _createClass(function _class102(){_classCallCheck(this,_class102),this._name="GetGroupAttributes"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"getGroupAttributes",context:this}),t.registerExperimentalAPI("getRichStatus",this,"getGroupAttributes")}},{key:"getGroupAttributes",value:function getGroupAttributes(e){return pe(this,void 0,void 0,function*(){const{groupID:t}=e,{avChatRoomKey:s,lastUpdateTime:n,localMainSequence:o,serverMainSequence:i}=nu.getGroupAttributesCache(t),{helper:{ChatError:r}}=this._core,a=`groupID:${t} localMainSequence:${o} serverMainSequence:${i} keyList:${e.keyList}`;if(Date.now()-n>=3e4||o<i)try{const n=yield this.getGroupAttributesFromServer({groupID:t,avChatRoomKey:s}),o=nu.getGroupAttributesCacheValues(e),{serverGroupAttributeList:i=[]}=n||{};return eu({groupAttributes:o},{message:a,moreMessage:`from server, count:${i.length}`})}catch(e){throw new r({functionName:"getGroupAttributes",code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}const c=nu.getGroupAttributesCacheValues(e);return eu({groupAttributes:c},{message:a,moreMessage:"from cache"})})}},{key:"getGroupAttributesFromServer",value:function getGroupAttributesFromServer(e){return pe(this,void 0,void 0,function*(){const{utils:{isUndefined:t},ssoLog:s}=this._core,{groupID:n,avChatRoomKey:o}=e,i=t(o)?0:1,r=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,groupType:n,avChatRoomKey:o}=e,i={GroupId:s,GroupType:n,Key:o};return t.common.buildAndSendPacket({servcmd:"group_open_attr_http_svc.get_group_attr",data:i})})}({groupID:n,avChatRoomKey:o,groupType:i},this._core),{AttrMainSeq:a=0,GroupAttrAry:c}=r||{};s.debug("getGroupAttributesFromServer",`${this._name}._getGroupAttributesFromServer ok. groupID:${n} serverMainSequence:${a}`);const u=c.map(e=>{const{key:t,value:s,seq:n}=e;return{key:t,value:s,sequence:n}});return nu.refreshGroupAttributesCache({groupID:n,serverMainSequence:a,groupAttributeList:u,operation:5}),{serverGroupAttributeList:c}})}}])}()),wu=new(function(){return _createClass(function _class103(){_classCallCheck(this,_class103)},[{key:"init",value:function init(e){e.ssoLog.debug("GroupAttribute.init"),Nu.init(e),Lu.init(e),Pu.init(e),Gu.init(e),nu.init(e)}},{key:"isGroupAttributesUpdated",value:function isGroupAttributesUpdated(e){return nu.isGroupAttributesUpdated(e)}},{key:"handleGroupAttributesUpdated",value:function handleGroupAttributesUpdated(e){const{to:t,elements:{newGroupProfile:s}}=e,{groupAttributeOption:n}=s,{serverMainSequence:o,withChangedAttributeInfo:i}=n,{localMainSequence:r}=nu.getGroupAttributesCache(t),a=o-r;if(console.log(`GroupAttribute.handleGroupAttributesUpdated groupID:${t} withChangedAttributeInfo:${i} diffSequence:${a}`),0!==a)if(nu.saveGroupAttributesCacheValuesCopy(t),1!==i||1!==a){if(nu.hasGroupAttributesCache(t)){const{avChatRoomKey:e}=nu.getGroupAttributesCache(t);Gu.getGroupAttributesFromServer({groupID:t,avChatRoomKey:e}).then(()=>{nu.emitGroupAttributesUpdated(t)}).catch(()=>{})}}else nu.handleGroupAttributesUpdated({groupID:t,groupAttributeOption:n})}},{key:"reset",value:function reset(){nu.reset()}}])}());function Uu(e,t="tips"){const{ClientSeq:s,From_Account:n,MsgClientTime:o,MsgPriority:i,MsgRandom:r,MsgSeq:a,MsgTimeStamp:c,TinyId:u,ToGroupId:l,GroupInfo:d,MsgBody:h}=e,g=function(e){const{GroupCode:t,GroupId:s,GroupName:n,GroupType:o,MsgFrom_AccountExtraInfo:i,From_Account:r,To_Account:a}=e;return{groupCode:t,groupID:s,groupName:n,type:o,messageFromAccountExtraInformation:i,from:r,to:a}}(d);return{clientSequence:s,from:n,clientTime:o,priority:i,random:r,sequence:a,time:c,tinyID:u,to:l,groupProfile:g,elements:"tips"===t?ku(h):$u(h)}}function ku(e){const t={};return Object.keys(e).forEach(s=>{var n,o;switch(s){case"MemberNum":t.memberCount=e[s];break;case"OpType":t.operationType=e[s];break;case"Operator_Account":t.operatorID=e[s];break;case"List_Account":t.userIDList=e[s];break;case"MsgMemberExtraInfo":t.memberInfoList=null===(n=e[s])||void 0===n?void 0:n.map(e=>Fu(e));break;case"MsgOperatorMemberExtraInfo":t.operatorInfo=Fu(e[s]);break;case"MsgGroupNewInfo":t.newGroupProfile=function(e){const t={};return Object.keys(e).forEach(s=>{switch(s){case"GroupIntroduction":t.introduction=e[s];break;case"GroupName":t.groupName=e[s];break;case"GroupFaceUrl":t.avatar=e[s];break;case"GroupNotification":t.notification=e[s];break;case"ApplyJoinOption":t.joinOption=e[s];break;case"InviteJoinOption":t.inviteOption=e[s];break;case"ShutupAll":t.muteAllMembers=e[s];break;case"Owner_Account":t.ownerID=e[s];break;case"GroupAttrOption":t.groupAttributeOption=function(e){const{BytesChangedKeys:t,GroupAttrSeq:s,OpType:n,PushChangedAttrValFlag:o,GroupAttrInfo:i}=e,r=i.map(e=>{const{Key:t,Val:s,SubKeySeq:n}=e;return{key:t,value:s,sequence:n}});return{changedKeyList:t,groupAttributeList:r,serverMainSequence:s,operation:n,withChangedAttributeInfo:o}}(e[s]);break;case"MsgAppDefinedData":t.groupCustomField=null==(n=e[s])?void 0:n.map(e=>({key:e.Key,value:e.Value}));break;case"InviteOption":t.inviteOption=Vc[e[s]]||e[s]}var n}),t}(e[s]);break;case"MsgMemberInfo":t.msgMemberInfo=null===(o=e[s])||void 0===o?void 0:o.map(e=>function(e){const{ShutupTime:t,User_Account:s}=e;return{muteTime:t,userID:s}}(e));break;case"OnlineMemberInfo":t.onlineMemberInfo=function(e){const{ExpireTime:t,OnlineMemberNum:s}=e;return{expireTime:t,onlineMemberNum:s}}(e[s]);break;case"GroupCounterInfo":t.groupCounterInfo=function(e){return e.map(e=>{const{GroupCounterSeq:t,GroupCounter:s,Type:n}=e;return{type:n,groupCounterSeq:t,counterList:s}})}(e[s])}}),t}function Fu(e){const{ImageUrl:t,NickName:s,Role:n,UserId:o}=e;return{avatar:t,nick:s,role:n,userID:o}}function $u(e){const t={};return Object.keys(e).forEach(s=>{switch(s){case"MsgKey":t.messageKey=e[s];break;case"Operator_Account":t.operatorID=e[s];break;case"ReportType":t.operationType=e[s];break;case"Authentication":t.authentication=e[s];break;case"MsgFlag":t.messageRemindType=e[s];break;case"UserDefinedField":t.userDefinedField=e[s];break;case"RemarkInfo":t.remarkInfo=e[s];break;case"BanDuration":t.duration=e[s];break;case"MuteTime":t.muteTime=e[s];break;case"MsgMemberExtraInfoList":t.inviteeInfoList=null==(n=e[s]||[])?void 0:n.map(e=>{const{UserId:t,ImageUrl:s,NickName:n}=e;return{userID:t,avatar:s,nick:n}});break;case"MemberList_Account":t.inviteeList=e[s]}var n}),t}let xu=function(){function xu(e){_classCallCheck(this,xu),this.type=La.core.OuterConstant.MSG_GRP_TIP,this.content={},this._initContent(e)}return _createClass(xu,[{key:"_initContent",value:function _initContent(e){Object.keys(e).forEach(t=>{switch(t){case"groupProfile":this._initGroupProfile(e[t]);break;case"operatorInfo":this._initOperatorInfo(e[t]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"newGroupProfile":this._initNewGroupProfile(e[t]);break;case"memberExtraInfo":case"remarkInfo":case"onlineMemberInfo":break;default:this.content[t]=e[t]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}},{key:"_initGroupProfile",value:function _initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];vc[n]&&(this.content.groupProfile[n]=e[n])}}},{key:"_initOperatorInfo",value:function _initOperatorInfo(e){this.content.operatorInfo={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];this.content.operatorInfo[n]=e[n]}}},{key:"_updateMemberList",value:function _updateMemberList(e){this.content.memberList?this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})}):this.content.memberList=e}},{key:"_initNewGroupProfile",value:function _initNewGroupProfile(e){this.content.newGroupProfile={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];"muteAllMembers"!==n?this.content.newGroupProfile[n]=e[n]:this.content.newGroupProfile.muteAllMembers=1===e.muteAllMembers}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){return new xu(ku(e))}}])}();var qu=new(function(){return _createClass(function _class104(){_classCallCheck(this,_class104),this._name="GroupTipsNotification"},[{key:"init",value:function init(e){this._core=e;const{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n}}=e,{message:{messageFactory:o},OuterConstant:i}=e;null==o||o.registerElementClass(i.MSG_GRP_TIP,xu),t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.GROUP_TIPS_RECOVER,this._handleGroupTipsRecover,this),t.registerWorkflowStep(s.RECEIVE_GROUP_TIPS_NOTIFICATION,n.HANDLE_GROUP_TIPS_NOTIFICATION,this.onNewGroupTips,this),t.registerWorkflowStep(s.RECEIVE_GROUP_TIPS_NOTIFICATION,n.EMIT_GROUP_TIPS_EVENT,this._emitGroupTipsEvent,this)}},{key:"onNewGroupTips",value:function onNewGroupTips(e){const{data:t}=e||{},{messageList:s,conversationUpdateFieldList:n}=this._handleGroupTips(t);return s.length>0&&this._handleGroupTipMessage(s),{conversationUpdateFieldList:n,messageList:s}}},{key:"_emitGroupTipsEvent",value:function _emitGroupTipsEvent(e){var t;const{constants:{WORKFLOW_STEP:s}}=this._core,{messageList:n=[]}=(null===(t=null==e?void 0:e.result)||void 0===t?void 0:t[s.HANDLE_GROUP_TIPS_NOTIFICATION])||{};if(n.length>0){const{notificationCenter:e,OuterEvent:t}=this._core;e.emitOuterEvent(t.MESSAGE_RECEIVED,{name:t.MESSAGE_RECEIVED,data:n})}}},{key:"_handleGroupTips",value:function _handleGroupTips(e,t=!0){const{Event:s,GroupTips:n}=e,o=new Map,i=[],r=[];for(let e=0,i=n.length;e<i;e++){const i=Uu(n[e],"tips");if(6===s){if(wu.isGroupAttributesUpdated(i)){wu.handleGroupAttributesUpdated(i);continue}if(bu.isGroupCounterUpdated(i)){bu.handleGroupCounterUpdated(i);continue}}const{groupProfile:{groupID:a}}=i;if(!Xc.hasLocalGroup(a))continue;const c=this._assembleMessage(i);if(6===s&&(c._onlineOnlyFlag=!0,r.push(c)),4===s){if(!this._core.message.messageDataHandler.storeConversationMessage(c)&&t)continue;r.push(c)}this._handleConversationOptions(o,c)}return i.push(...o.values()),{conversationUpdateFieldList:i,messageList:r}}},{key:"_assembleMessage",value:function _assembleMessage(e){const{OuterConstant:t,message:{messageFactory:s},common:{setGroupTipsUserInfo:n}}=this._core;e.flow="in",e.conversationType=t.CONV_GROUP;const o=s.createMessage(e);n(e.elements,o);const i=new xu(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));return o.setElement(i),o.isSystemMessage=!1,o}},{key:"_handleConversationOptions",value:function _handleConversationOptions(e,t){const{common:{getMessagePreviewText:s},utils:{isObject:n},appStore:{conversationStore:o}}=this._core,{conversationID:i,conversationType:r}=t;let a;if(!o.getConversation(i)||!t._onlineOnlyFlag){if(e.has(i))a=e.get(i),"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||a.unreadCount++),a.type=r,a.lastMessage=t._isExcludedFromLastMessage?"":Object.assign({},t);else{let e=0;"in"===t.flow&&(t._isExcludedFromUnreadCount||t._onlineOnlyFlag||(e=1)),a={conversationID:i,unreadCount:e,type:r,lastMessage:t._isExcludedFromLastMessage?"":Object.assign({},t)}}n(a.lastMessage)&&(a.lastMessage.messageForShow=s(a.lastMessage.type,a.lastMessage.payload)),e.set(i,a)}}},{key:"_handleGroupTipMessage",value:function _handleGroupTipMessage(e){const{OuterConstant:{GROUP_TIPS_OPERATION_TYPE:t}}=this._core;e.forEach(e=>{const{operationType:s}=e.payload;switch(s){case t.JOINED:this._handleNewMemberJoined(e);break;case t.QUITTED:this._handleMemberQuitted(e);break;case t.KICKED:this._handleMemberKicked(e);break;case t.GROUP_PROFILE_UPDATED:this._handleGroupProfileUpdated(e);break;case t.ADMIN_SET:this._handleMemberGrantAdmin(e);break;case t.ADMIN_CANCELED:this._handleMemberRevokeAdmin(e)}})}},{key:"_handleNewMemberJoined",value:function _handleNewMemberJoined(e){this._handleGroupMemberCountUpdated(e)}},{key:"_handleMemberQuitted",value:function _handleMemberQuitted(e){this._handleGroupMemberCountUpdated(e)}},{key:"_handleMemberKicked",value:function _handleMemberKicked(e){this._handleGroupMemberCountUpdated(e)}},{key:"_handleGroupProfileUpdated",value:function _handleGroupProfileUpdated(e){var t;const{newGroupProfile:s,groupProfile:n,operatorInfo:o}=e.payload,{groupID:i}=n,r=Xc.getLocalGroup(i);Object.keys(s).forEach(e=>{switch(e){case"ownerID":this._handleGroupOwnerChanged(i,s);break;case"groupName":r.name=s[e];break;case"groupCustomField":Array.isArray(r[e])&&Array.isArray(s[e])?Hc(r[e],s[e]):r[e]=s[e];break;default:r[e]=s[e]}});const{utils:{isUndefined:a}}=this._core;a(o)||(null===(t=null==r?void 0:r.selfInfo)||void 0===t?void 0:t.userID)!==o.userID||Object.keys(o).forEach(e=>{"nameCard"===e&&r.updateSelfInfo({nameCard:o[e]}),"role"===e&&this._updateSelfRole(r,o[e])}),Xc.emitGroupListUpdate(),Xc.updateConversationGroupProfile(i)}},{key:"_handleGroupOwnerChanged",value:function _handleGroupOwnerChanged(e,t){const{common:s,OuterConstant:n}=this._core,o=Xc.getLocalGroup(e),i=s.getCurrentUserID(),{ownerID:r}=t;i===r&&o.updateGroup({ownerID:r,selfInfo:{role:n.GRP_MBR_ROLE_OWNER}})}},{key:"_updateSelfRole",value:function _updateSelfRole(e,t){const{OuterConstant:s}=this._core;let n=s.GRP_MBR_ROLE_MEMBER;400===t?n=s.GRP_MBR_ROLE_OWNER:300===t&&(n=s.GRP_MBR_ROLE_ADMIN),e.updateSelfInfo({role:n})}},{key:"_handleGroupMemberCountUpdated",value:function _handleGroupMemberCountUpdated(e){const{memberCount:t,groupProfile:{groupID:s}}=e.payload,n=Xc.getLocalGroup(s),{utils:{isNumber:o}}=this._core;n&&o(t)&&n.memberCount!==t&&(n.memberCount=t,Xc.emitGroupListUpdate(),Xc.updateConversationGroupProfile(s))}},{key:"_handleGroupTipsRecover",value:function _handleGroupTipsRecover(e){const{utils:{isArray:t}}=this._core,{groupTipList:s}=(null==e?void 0:e.result)||{};t(s)&&s.forEach(e=>{const{messageList:t}=this._handleGroupTips({Event:e.Event,GroupTips:[e]},!1);this._handleGroupTipMessage(t)})}},{key:"_handleMemberGrantAdmin",value:function _handleMemberGrantAdmin(e){const{OuterConstant:t}=this._core,{groupProfile:s,userIDList:n}=e.payload,o=this._core.common.getCurrentUserID(),{groupID:i}=s,r=Xc.getLocalGroup(i);r&&n.includes(o)&&(r.updateSelfInfo({role:t.GRP_MBR_ROLE_ADMIN}),Xc.emitGroupListUpdate(),Xc.updateConversationGroupProfile(i))}},{key:"_handleMemberRevokeAdmin",value:function _handleMemberRevokeAdmin(e){const{OuterConstant:t}=this._core,{groupProfile:s,userIDList:n}=e.payload,o=this._core.common.getCurrentUserID(),{groupID:i}=s,r=Xc.getLocalGroup(i);r&&n.includes(o)&&(r.updateSelfInfo({role:t.GRP_MBR_ROLE_MEMBER}),Xc.emitGroupListUpdate(),Xc.updateConversationGroupProfile(i))}}])}());let Vu=function(){function Vu(e){_classCallCheck(this,Vu),this.type=La.core.OuterConstant.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}return _createClass(Vu,[{key:"_initContent",value:function _initContent(e){Object.keys(e).forEach(t=>{switch(t){case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this._initGroupProfile(e[t]);break;case"memberInfoList":break;default:this.content[t]=e[t]}})}},{key:"_initGroupProfile",value:function _initGroupProfile(e){this.content.groupProfile={};const t=Object.keys(e);for(let s=0;s<t.length;s++){const n=t[s];fc[n]&&(this.content.groupProfile[n]=e[n])}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){return new Vu($u(e))}}])}();var Bu=new(function(){return _createClass(function _class105(){_classCallCheck(this,_class105),this._name="GroupSystemNotification"},[{key:"init",value:function init(e){this._core=e;const{message:{messageFactory:t},OuterConstant:{MSG_GRP_SYS_NOTICE:s}}=e;null==t||t.registerElementClass(s,Vu)}},{key:"onNewGroupSystemNotification",value:function onNewGroupSystemNotification(e){const{GroupTips:t=[],isInstantMessage:s=!0}=e;this._core.ssoLog.debug("onNewGroupSystemNotification",` count:${t.length} isInstantMessage:${s}`);const{conversationUpdateFieldList:n,messageList:o}=this._handleGroupSystemNotification(t,s),{notificationCenter:i,OuterEvent:r}=this._core;n.length>0&&this._handleGroupSysTemMessage(s,o),!0===s&&o.length>0&&i.emitOuterEvent(r.MESSAGE_RECEIVED,{name:r.MESSAGE_RECEIVED,data:o})}},{key:"_handleGroupSystemNotification",value:function _handleGroupSystemNotification(e,t){const s=[];let n={};for(let o=0;o<e.length;o++){const i=Uu(e[o],"system"),{elements:{operationType:r}}=i;if(15===r)continue;const a=this._assembleMessage(i);this._core.message.messageDataHandler.storeConversationMessage(a)&&(s.push(a),n=this._handleConversationOptions(a,t))}return n.lastMessage=s[s.length-1],{conversationUpdateFieldList:s.length>0?[n]:[],messageList:s}}},{key:"_assembleMessage",value:function _assembleMessage(e){const{message:{messageFactory:t},OuterConstant:s,utils:{randomInt:n}}=this._core;e.flow="in",e.conversationType=s.CONV_SYSTEM,e.conversationSubType=e.groupProfile.type,e.conversationID=s.CONV_SYSTEM;const o=t.createMessage(e),i=new Vu(Object.assign(Object.assign({},e.elements),{groupProfile:Object.assign({},e.groupProfile)}));o.setElement(i),o.isSystemMessage=!0;const r=1===o.sequence&&1===o.random,a=2===o.sequence&&2===o.random;return(r||a)&&(o.sequence=n(),o.random=n(),o.generateMessageID()),o}},{key:"_handleConversationOptions",value:function _handleConversationOptions(e,t){const{OuterConstant:s}=this._core,n={conversationID:s.CONV_SYSTEM,unreadCount:0,type:s.CONV_SYSTEM,subType:e.conversationSubType,lastMessage:null};return t&&n.unreadCount++,n}},{key:"_handleGroupSysTemMessage",value:function _handleGroupSysTemMessage(e,t){e&&t.forEach(e=>{const{operationType:t}=e.payload;switch(t){case 2:this._handleGroupJoinResult(e);break;case 4:this._handleMemberKicked(e);break;case 5:this._handleGroupDismissed(e);break;case 7:this._handleGroupInvitedResult(e);break;case 8:this._handleGroupQuitResult(e);break;case 20:this._handleMessageRemindTypeSynced(e);break;case 21:this._handleAVChatRoomMemberBanned(e)}})}},{key:"_handleGroupJoinResult",value:function _handleGroupJoinResult(e){const{groupProfile:t}=e.payload,{groupID:s,type:n}=t,o=Xc.hasLocalGroup(s);this._core.ssoLog.debug("_handleGroupJoinResult",` groupID:${s} type:${n} hasLocalGroup:${o}`),o||jc(n)||(Xc.updateLocalGroup([Object.assign({},t)]),Xc.emitGroupListUpdate())}},{key:"_handleMemberKicked",value:function _handleMemberKicked(e){const{groupProfile:{groupID:t,type:s}}=e.payload;Xc.hasLocalGroup(t)&&this._deleteLocalGroup(t,s),this._updateConversationProfile(t,{unreadCount:0})}},{key:"_handleGroupDismissed",value:function _handleGroupDismissed(e){const{groupProfile:{groupID:t,type:s}}=e.payload;Xc.hasLocalGroup(t)&&this._deleteLocalGroup(t,s),this._updateConversationProfile(t,{unreadCount:0})}},{key:"_handleGroupInvitedResult",value:function _handleGroupInvitedResult(e){const{groupProfile:t}=e.payload,{groupID:s}=t,n=Xc.hasLocalGroup(s);this._core.ssoLog.debug("_handleGroupInvitedResult",` groupID:${s} hasLocalGroup:${n}`),n||iu.getGroupProfile({groupID:s}).then(e=>{const{data:{group:t}}=e;Xc.updateLocalGroup([Object.assign({},t)]),Xc.emitGroupListUpdate()})}},{key:"_handleGroupQuitResult",value:function _handleGroupQuitResult(e){const{groupProfile:{groupID:t,type:s}}=e.payload,n=Xc.hasLocalGroup(t);this._core.ssoLog.debug("_handleGroupQuitResult",` groupID:${t} type:${s} hasLocalGroup:${n}`),n&&this._deleteLocalGroup(t,s),this._updateConversationProfile(t,{unreadCount:0})}},{key:"_handleMessageRemindTypeSynced",value:function _handleMessageRemindTypeSynced(e){const{groupProfile:{groupID:t},messageRemindType:s}=e.payload;this._updateConversationProfile(t,{messageRemindType:s})}},{key:"_handleAVChatRoomMemberBanned",value:function _handleAVChatRoomMemberBanned(e){const{groupProfile:{groupID:t,type:s}}=e.payload;this._deleteLocalGroup(t,s)}},{key:"_deleteLocalGroup",value:function _deleteLocalGroup(e,t){if(jc(t)){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s}}=this._core;t.deleteConversation(`${s}${e}`)}Xc.deleteLocalGroup(e),Xc.emitGroupListUpdate()}},{key:"_updateConversationProfile",value:function _updateConversationProfile(e,t){const{appStore:{conversationStore:s},OuterConstant:{CONV_GROUP:n}}=this._core,o=`${n}${e}`;s.getConversation(o)&&s.updateConversation(o,t)}}])}()),ju=new(function(){return _createClass(function _class106(){_classCallCheck(this,_class106)},[{key:"init",value:function init(e){this._core=e,e.ssoLog.debug("GroupNotificationHandler.init"),qu.init(e),Bu.init(e);const{notificationCenter:t,InnerEvent:s}=e,{InnerEventSubType:n}=t;t.subscribeInnerEvent(s.MESSAGE_PUSH,n.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),t.subscribeInnerEvent(s.MESSAGE_PUSH,n.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this),t.subscribeInnerEvent(s.DESTROY,this._dispose,this)}},{key:"_onNewGroupTipsNotification",value:function _onNewGroupTipsNotification(e){const{common:{workflowManager:t},constants:{WORKFLOW_NAME:s}}=this._core;t.executeWorkflow(s.RECEIVE_GROUP_TIPS_NOTIFICATION,e)}},{key:"_onNewGroupSystemNotification",value:function _onNewGroupSystemNotification(e){Bu.onNewGroupSystemNotification(e)}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e,InnerEvent:t}=this._core,{InnerEventSubType:s}=e;e.unSubscribeInnerEvent(t.MESSAGE_PUSH,s.GROUP_TIPS_NOTIFICATION,this._onNewGroupTipsNotification,this),e.unSubscribeInnerEvent(t.MESSAGE_PUSH,s.GROUP_SYSTEM_NOTIFICATION,this._onNewGroupSystemNotification,this)}}])}());const Hu={required:!0,rules:["string"],allowEmpty:!1},Ku={required:!0,rules:["number"],allowEmpty:!1},Wu={required:!0,rules:["array"],allowEmpty:!1},Yu={required:!0,rules:["object"],allowEmpty:!1},zu={createGroup:{name:Hu,type:Hu},dismissGroup:[Object.assign({key:"groupID"},Hu)],joinGroup:{groupID:Hu,applyMessage:{required:!1,rules:["string"],allowEmpty:!0}},quitGroup:[Object.assign({key:"groupID"},Hu)],searchGroupByID:[Object.assign({key:"groupID"},Hu)],getGroupProfile:{groupID:Hu,groupCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},updateGroupProfile:{groupID:Hu,muteAllMembers:{required:!1,rules:["boolean"],allowEmpty:!1}},changeGroupOwner:{groupID:Hu,newOwnerID:Hu},getGroupOnlineMemberCount:[Object.assign({key:"groupID"},Hu)],handleGroupApplication:{handleAction:Hu},getGroupMemberList:{groupID:Hu},getGroupMemberProfile:{groupID:Hu,userIDList:Wu,memberCustomFieldFilter:{required:!1,rules:["array"],allowEmpty:!0}},addGroupMember:{groupID:Hu,userIDList:Wu},deleteGroupMember:{groupID:Hu,userIDList:Wu},setGroupMemberMuteTime:{groupID:Hu,userID:Hu,muteTime:Object.assign(Object.assign({},Ku),{customValidator:e=>!(e<0)||"muteTime must be a non-negative number."})},setGroupMemberRole:{groupID:Hu,userID:Hu,role:Hu},setGroupMemberNameCard:{groupID:Hu,userID:{required:!1,rules:["string"],allowEmpty:!1},nameCard:Hu},setGroupMemberCustomField:{groupID:Hu,userID:{required:!1,rules:["string"],allowEmpty:!1},memberCustomField:Wu},markGroupMemberList:{groupID:Hu,markType:Object.assign(Object.assign({},Ku),{customValidator:e=>!(e<1e3)||"markType must be greater than or equal to 1000."}),enableMark:{required:!0,rules:["boolean"],allowEmpty:!1},userIDList:Wu},initGroupAttributes:{groupID:Hu,groupAttributes:Yu},setGroupAttributes:{groupID:Hu,groupAttributes:Yu},deleteGroupAttributes:{groupID:Hu,keyList:Object.assign(Object.assign({},Wu),{allowEmpty:!0})},getGroupAttributes:{groupID:Hu,keyList:Object.assign(Object.assign({},Wu),{allowEmpty:!0})},getGroupCounters:{groupID:Hu,keyList:{required:!1,rules:["array"],allowEmpty:!0}},setGroupCounters:{groupID:Hu,counters:Yu},increaseGroupCounter:{groupID:Hu,key:Hu,value:Ku},decreaseGroupCounter:{groupID:Hu,key:Hu,value:Ku}},Ju={getGroupList:!0,createGroup:!0,dismissGroup:!0,joinGroup:!0,quitGroup:!0,searchGroupByID:!0,getGroupProfile:!0,updateGroupProfile:!0,changeGroupOwner:!0,getGroupOnlineMemberCount:!0,getGroupApplicationList:!0,handleGroupApplication:!0,getGroupMemberList:!0,getGroupMemberProfile:!0,addGroupMember:!0,deleteGroupMember:!0,setGroupMemberMuteTime:!0,setGroupMemberRole:!0,setGroupMemberNameCard:!0,setGroupMemberCustomField:!0,markGroupMemberList:!0,initGroupAttributes:!0,setGroupAttributes:!0,getGroupAttributes:!0,deleteGroupAttributes:!0,getGroupCounters:!0,setGroupCounters:!0,increaseGroupCounter:!0,decreaseGroupCounter:!0};var Qu=new(function(){return _createClass(function _class107(){_classCallCheck(this,_class107),this._installedSubPlugins=[],this.groupDataHandler=Xc,this.groupAction=gu,this.groupAttribute=wu,this.groupMember=Tu,this.groupCounter=bu,this.name="Group"},[{key:"install",value:function install(e,t=[]){this._core=e,La.init(e),Xc.init(e),gu.init(e,this),Tu.init(e,this),mu.init(e),bu.init(e),wu.init(e),ju.init(e),e.helper.registerValidateConfig({auth:Ju,params:zu}),this._installSubPlugins(t);const{notificationCenter:s,InnerEvent:n}=e;s.subscribeInnerEvent(n.LOGOUT,this._reset,this),s.subscribeInnerEvent(n.DESTROY,this._dispose,this)}},{key:"getInstalledSubPlugins",value:function getInstalledSubPlugins(){return this._installedSubPlugins}},{key:"_installSubPlugins",value:function _installSubPlugins(e){const{utils:{isArray:t}}=this._core;e&&t(e)&&e.forEach(e=>{var t;this._installedSubPlugins.includes(e.name)||(null===(t=e.install)||void 0===t||t.call(e,this._core,this),this._installedSubPlugins.push(e.name))})}},{key:"_reset",value:function _reset(){Xc.reset(),wu.reset(),bu.reset()}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}])}());const Xu=new(function(){return _createClass(function _class108(){_classCallCheck(this,_class108)},[{key:"init",value:function init(e){this.core=e}}])}()),tl={NORMAL_MESSAGE:3,GROUP_TIPS_HAS_ROAMING:4,GROUP_SYSTEM_MESSAGE:5,GROUP_TIPS_HAS_NO_ROAMING:6,BROADCAST_MESSAGE:17,MESSAGE_REVOKED:20,MESSAGE_REACTION:21,LIVE_CUSTOM_DATA:100},sl={GROUP_DISMISSED:5,QUIT_GROUP:8,AVCHATROOM_MEMBER_BANNED:21},nl=60;let cl=function(){return _createClass(function cl(e){_classCallCheck(this,cl);const{core:t,manager:s,groupID:n,getRequestParams:o,onSuccess:i,onFail:r}=e;this._name="Polling",this._core=t,this._manager=s,this._timeoutID=-1,this._isRunning=!1,this._groupID=n,this._getRequestParams=o,this._onSuccess=i,this._onFail=r},[{key:"start",value:function start(){this._isRunning=!0,this._request(),console.log(`${this._name}.start pollingInterval:${this._manager.getCurrentPollingInterval(this._groupID)}`)}},{key:"isRunning",value:function isRunning(){return this._isRunning}},{key:"_request",value:function _request(){return pe(this,void 0,void 0,function*(){try{const e=this._getRequestParams(this._groupID),t=yield function(e,t){return pe(this,void 0,void 0,function*(){const{longPollingKey:s,startSequence:n,startBroadcastSeq:o,simplifiedMessage:i}=e,r={Key:s,StartSeq:n,StartBroadcastSeq:o,DownsizeFlag:i,USP:1,HoldTime:90};return t.common.buildAndSendPacket({servcmd:"group_open_long_polling_http_svc.get_msg",data:r})})}(e,this._core);this._onSuccess(this._groupID,t);const s=this._manager.getCurrentPollingInterval(this._groupID);this._runNextPolling(s)}catch(e){this._onFail(this._groupID,e),this._runNextPolling(2e3)}})}},{key:"_runNextPolling",value:function _runNextPolling(e){this.isRunning()&&(this._timeoutID>-1&&clearTimeout(this._timeoutID),this._timeoutID=setTimeout(this._request.bind(this),e))}},{key:"stop",value:function stop(){console.log(`${this._name}.stop timerID:${this._timeoutID}`),this._timeoutID>-1&&(clearTimeout(this._timeoutID),this._timeoutID=-1),this._isRunning=!1}}])}(),ul=function(){return _createClass(function ul(e){_classCallCheck(this,ul),this._maxLength=e,this._map=new Map},[{key:"set",value:function set(e){var t;if(this._map.size>=this._maxLength){const e=(null===(t=this._map.entries().next().value)||void 0===t?void 0:t[0])||"";this._map.delete(e)}this._map.set(e,1)}},{key:"has",value:function has(e){return this._map.has(e)}},{key:"delete",value:function _delete(e){this.has(e)&&this._map.delete(e)}},{key:"clear",value:function clear(){this._map.clear()}}])}();const ll=e=>e===tl.GROUP_TIPS_HAS_NO_ROAMING||e===tl.GROUP_TIPS_HAS_ROAMING,dl=e=>e===tl.GROUP_SYSTEM_MESSAGE;function hl(e){const t=function(e){const{E:t,MCT:s,MR:n,MP:o,MTS:i,GId:r,MS:a,CCD:c,F_Account:u,IsSys:l,GInf:d,MsgBody:h}=e,g=ge(e,["E","MCT","MR","MP","MTS","GId","MS","CCD","F_Account","IsSys","GInf","MsgBody"]);return Object.assign({Event:t,MsgClientTime:s,MsgRandom:n,MsgPriority:o,MsgTimeStamp:i,ToGroupId:r,MsgSeq:a,CloudCustomData:c,From_Account:u,IsSystemMsg:l,GroupInfo:gl(d),MsgBody:pl(h)},g)}(e);return function(e){const{Event:t}=e;(ll(t)||dl(t))&&(e.From_Account=e.From_Account||"@TIM#SYSTEM"),(t===tl.BROADCAST_MESSAGE||(e=>e===tl.NORMAL_MESSAGE)(t))&&function(e){const{core:{OuterConstant:t}}=Xu;e.CloudCustomData=e.CloudCustomData||"",e.MsgBody=e.MsgBody.map(e=>{if(e.MsgType===t.MSG_CUSTOM){const{content:t={}}=e;e.content=Object.assign({Data:"",Desc:"",Ext:""},t)}return e})}(e),ll(t)&&function(e){const{GroupJoinType:t,MsgOperatorMemberExtraInfo:s={},MsgMemberExtraInfo:n,Operator_Account:o,List_Account:i,OpType:r}=e.MsgBody||{};"number"==typeof t||1!==r&&2!==r||(e.MsgBody.GroupJoinType=2===r?0:1),n||(e.MsgBody.MsgMemberExtraInfo=null==i?void 0:i.map(e=>({UserId:e}))),1!==r||n||(e.MsgBody.MsgMemberExtraInfo=[{UserId:s.UserId}]),e.MsgBody.MsgOperatorMemberExtraInfo=Object.assign({Operator_Account:o,ImageUrl:"",NickName:""},s)}(e),dl(t)&&function(e){const{MsgOperatorMemberExtraInfo:t={},Operator_Account:s}=e.MsgBody||{};e.MsgBody.MsgMemberExtraInfo=Object.assign({UserId:s,ImageUrl:"",NickName:""},t),e.MsgBody=Object.assign({Authentication:"",RemarkInfo:"",MsgKey:1e3*e.MsgTimeStamp},e.MsgBody),e.MsgBody=Object.keys(e.MsgBody).filter(e=>"MsgOperatorMemberExtraInfo"!==e).reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:e.MsgBody[s]}),{})}(e)}(t),t}function gl(e){const t=e||{},{GN:s,GT:n,F_Hd:o,F_NN:i,F_Ll:r}=t,a=ge(t,["GN","GT","F_Hd","F_NN","F_Ll"]),c=Object.assign({GroupName:s,GroupType:n},a);return o&&(c.From_AccountHeadurl=o),i&&(c.From_AccountNick=i),r&&(c.From_AccountLevel=r),c}function pl(e){let t=e;Array.isArray(e)||(t=[e]);const s=t.map(e=>{const{O_Account:t,Opt:s,L_Account:n,RT:o,UDF:i,OpInf:r,OnlineInf:a,MsgMemberExtraInfo:c}=e,u=ge(e,["O_Account","Opt","L_Account","RT","UDF","OpInf","OnlineInf","MsgMemberExtraInfo"]),l=Object.assign({Operator_Account:t,OpType:s,List_Account:n,ReportType:o,UserDefinedField:i},u);return r&&(l.MsgOperatorMemberExtraInfo=function(e){const{Img:t,NN:s}=e,n=ge(e,["Img","NN"]);return Object.assign({ImageUrl:t,NickName:s},n)}(r)),c&&(l.MsgMemberExtraInfo=function(e){return null==e?void 0:e.map(e=>{const{Img:t,NN:s}=e,n=ge(e,["Img","NN"]);return Object.assign({ImageUrl:t,NickName:s},n)})}(c)),a&&(l.OnlineMemberInfo=function(e){const{ET:t,Num:s}=e;return{ExpireTime:t,OnlineMemberNum:s}}(a)),l});return Array.isArray(e)?s:s[0]}var _l=new(function(){return _createClass(function _class109(){_classCallCheck(this,_class109),this._name="MessageParser",this._sequenceList=new ul(200),this._messageIDList=new ul(100),this._broadcastMessageIDMap=new Map,this._reportMessageStackedCount=0},[{key:"init",value:function init(e,t){this._core=e,this._avChatRoomHandler=t}},{key:"onMessageReceived",value:function onMessageReceived(e,t,s=!1){this._sortServerMessageList({groupID:e,serverMessageList:t,isHistoryMessage:s});const n=this._handleMessageList(e,t);if(0===n.length)return;if(!s){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s},common:{buildLastMessage:o}}=this._core,i=o(n[n.length-1]);t.updateConversation(`${s}${e}`,{lastMessage:i})}this._checkMessageStacked(n);const o=n.filter(e=>!0===e.isModified),i=n.filter(e=>!1===e.isModified),{OuterEvent:{MESSAGE_RECEIVED:r,MESSAGE_MODIFIED:a}}=this._core;o.length>0&&this._emitEvent({name:a,data:o}),i.length>0&&this._emitEvent({name:r,data:i})}},{key:"_sortServerMessageList",value:function _sortServerMessageList(e){const{groupID:t,serverMessageList:s,isHistoryMessage:n}=e;let o=[];this._avChatRoomHandler.isPollingSimplifiedMessage()&&!n?(s.sort((e,t)=>e.MS-t.MS),o=s.map(e=>e.MS)):(s.sort((e,t)=>e.MsgSeq-t.MsgSeq),o=s.map(e=>e.MsgSeq)),console.log(`${this._name}._sortServerMessageList groupID:${t} count:${o.length} sequenceList:${o}`),o.length=0}},{key:"_handleMessageList",value:function _handleMessageList(e,t){var s;const{message:{messageDataHandler:n,messageHelper:o}}=this._core,i=this._avChatRoomHandler.isPollingSimplifiedMessage(),r=[],a=t.length;for(let c=0;c<a;c++){let a=t[c];if(i&&(a=hl(a)),dl(a.Event)&&Object.values(sl).includes(a.MsgBody.ReportType)){this._onGroupDismissed(e);break}if(null===this._filterMessageItem(a))continue;this._patchMessageType(a);const u=o.parseServerGroupMessage(a),l=this._createMessage(u);if(l.level=a.GroupInfo.From_AccountLevel,ll(a.Event)){const e=Object.assign(Object.assign({},u),{elements:Object.assign({},(null===(s=null==u?void 0:u.elements)||void 0===s?void 0:s.content)||{})});if(this._avChatRoomHandler.isGroupAttributesUpdated(e)){this._avChatRoomHandler.handleGroupAttributesUpdated(e);continue}if(this._avChatRoomHandler.isGroupCounterUpdated(e)){this._avChatRoomHandler.handleGroupCounterUpdated(e);continue}}null!==this._filterDuplicateMessage(l)&&(n.isMessageSentByCurrentInstance(l)||(1===u.isModified&&(l.isModified=!0),ll(a.Event)&&this._updateLocalOnlineMemberCountFromTips(a),r.push(l)))}return r}},{key:"_patchMessageType",value:function _patchMessageType(e){const{OuterConstant:t}=this._core;ll(e.Event)&&(e.MsgBody.MsgType=t.MSG_GRP_TIP),dl(e.Event)&&(e.MsgBody.MsgType=t.MSG_GRP_SYS_NOTICE)}},{key:"_filterMessageItem",value:function _filterMessageItem(e){const{Event:t}=e;return Object.values(tl).includes(t)?(e=>e===tl.MESSAGE_REVOKED)(t)?(this._handleMessageRevoked(e),null):(e=>e===tl.LIVE_CUSTOM_DATA)(t)?(this._onLiveCustomData(e),null):(e=>e===tl.MESSAGE_REACTION)(t)?null:e:(console.warn(`${this._name}.onMessageReceived unknown event:${t}`),null)}},{key:"_createMessage",value:function _createMessage(e){const{message:{messageFactory:t},OuterConstant:s}=this._core;let n=s.CONV_GROUP;e.elements.type===s.MSG_GRP_SYS_NOTICE&&(n=s.CONV_SYSTEM);const o=!!e.isSystemMessage,i=t.createMessage(Object.assign(Object.assign({},e),{conversationType:n,isSystemMessage:o,flow:"in"}));return i.setElement(e.elements),i}},{key:"_filterDuplicateMessage",value:function _filterDuplicateMessage(e){const{common:t}=this._core;if(!t.isUnlimitedAVChatRoom()){if(this._sequenceList.has(e.sequence))return null;this._sequenceList.set(e.sequence)}const s=this._messageIDList.has(e.ID);return s?(console.warn(`${this._name}_filterDuplicateMessageItem ID:${e.ID} has:${s}`),null):(this._messageIDList.set(e.ID),e)}},{key:"_handleMessageRevoked",value:function _handleMessageRevoked(e){const{OuterConstant:t,OuterEvent:{MESSAGE_REVOKED:s}}=this._core,{ToGroupId:n,MsgBody:{RevokeMsgList:o},RevokerInfo:{Revoker_Account:i,Reason:r=""}}=e,a=[];o.forEach(e=>{const{TinyId:s,MsgClientTime:o,Random:c,MsgSeq:u}=e,l={conversationID:`${t.CONV_GROUP}${n}`,ID:`${s}-${o}-${c}`,revoker:i,revokeReason:r,revokerInfo:{userID:i,nick:"",avatar:""},sequence:u};a.push(l)}),0!==a.length&&this._emitEvent({name:s,data:a})}},{key:"_onLiveCustomData",value:function _onLiveCustomData(e){const{OuterEvent:{ROOM_CUSTOM_DATA_RECEIVED:t}}=this._core,{ToGroupId:s,MsgSeq:n,MsgTimeStamp:o,MsgBody:i}=e,r=(null==i?void 0:i.Content)||(null==i?void 0:i.MsgContent)||"";this._emitEvent({name:t,data:r}),console.log(`${this._name}._onLiveCustomData groupID:${s} sequence:${n} time:${o} data:${r}`)}},{key:"_onGroupDismissed",value:function _onGroupDismissed(e){this._avChatRoomHandler.reset(e)}},{key:"_checkMessageStacked",value:function _checkMessageStacked(e){const{length:t}=e;if(t>=100&&this._reportMessageStackedCount<5){const e=this._avChatRoomHandler.getJoinedGroups();this._core.ssoLog.info("MessageStacked",`count:${t} groupID:${e.join(",")}`),this._reportMessageStackedCount+=1}}},{key:"_emitEvent",value:function _emitEvent(e){this._core.notificationCenter.emitOuterEvent(e.name,e)}},{key:"onBroadcastMessageReceived",value:function onBroadcastMessageReceived(e){const{message:{messageHelper:t},OuterEvent:{MESSAGE_RECEIVED:s}}=this._core,n=this._avChatRoomHandler.isPollingSimplifiedMessage(),o=[],i=e.length;for(let s=0;s<i;s++){let i=e[s];n&&(i=hl(i));const r=t.parseServerGroupMessage(i);if(!Object.values(tl).includes(i.Event)){console.warn(`${this._name}.onBroadcastMessageReceived unknown event:${i.Event}`);continue}const a=this._createMessage(r);a.isBroadcastMessage=!0,this._broadcastMessageIDMap.has(a.ID)||(o.push(a),this._broadcastMessageIDMap.set(a.ID,1))}o.length>0&&this._emitEvent({name:s,data:o})}},{key:"_updateLocalOnlineMemberCountFromTips",value:function _updateLocalOnlineMemberCountFromTips(e){const{utils:{isEmpty:t}}=this._core,{ToGroupId:s,MsgBody:{OnlineMemberInfo:n}}=e;if(t(n))return;const{OnlineMemberNum:o=0,ExpireTime:i=nl}=n,r=Date.now();let a=this._avChatRoomHandler.getLocalOnlineMemberCount(s);t(a)?a={lastReqTime:0,lastSyncTime:0,latestUpdateTime:r,memberCount:o,expireTime:i}:(a.latestUpdateTime=r,a.memberCount=o),this._avChatRoomHandler.updateLocalOnlineMemberCount(s,a)}},{key:"reset",value:function reset(){this._reportMessageStackedCount=0,this._sequenceList.clear(),this._messageIDList.clear(),this._broadcastMessageIDMap.clear()}}])}());const ml=e=>{const{core:{store:t}}=Xu;return(t.get("cloudConfig")||{})[e]},vl=e=>{const{core:{utils:{isUndefined:t}}}=Xu;return!t(e)},fl=()=>{const e=ml("polling_interval");return vl(e)?parseInt(e,10):300},Il=()=>{const e=ml("polling_simplified_msg");return vl(e)?parseInt(e,10):0};var El=new(function(){return _createClass(function _class110(){_classCallCheck(this,_class110),this._name="GetAVChatRoomOnlineMemberCount"},[{key:"init",value:function init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"getGroupOnlineMemberCount",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}},{key:"getGroupOnlineMemberCount",value:function getGroupOnlineMemberCount(e){return pe(this,void 0,void 0,function*(){const{appStore:{groupStore:t},OuterConstant:s}=this._core,n=t.getGroup(e);return n?n.type===s.GRP_AVCHATROOM?this._getOnlineMemberCount(e):this._parentPlugin.groupAction.getGroupOnlineMemberCount(e):{code:0,data:{memberCount:0}}})}},{key:"_getOnlineMemberCount",value:function _getOnlineMemberCount(e){return pe(this,void 0,void 0,function*(){const t="_getOnlineMemberCount",{utils:{isEmpty:s}}=this._core,n=Sl.getLocalOnlineMemberCount(e);if(s(n)||this._isExpired(e)){const{memberCount:s=0}=yield this._getOnlineMemberCountFromServer(e);return console.log(`${this._name}.${t} ok, groupID:${e} memberCount:${s} from server.`),{code:0,data:{memberCount:s}}}return console.log(`${this._name}.${t} ok, groupID:${e} memberCount:${n.memberCount} from local.`),{code:0,data:{memberCount:n.memberCount}}})}},{key:"_isExpired",value:function _isExpired(e){const t=Sl.getLocalOnlineMemberCount(e),s=Date.now(),n=s-t.lastSyncTime>1e3*t.expireTime,o=s-t.latestUpdateTime>1e4,i=s-t.lastReqTime>3e3;return n&&o&&i}},{key:"_getOnlineMemberCountFromServer",value:function _getOnlineMemberCountFromServer(e){return pe(this,void 0,void 0,function*(){const t="_getOnlineMemberCountFromServer";try{const t=yield function(e,t){return pe(this,void 0,void 0,function*(){const s={GroupId:e};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_online_member_num",data:s})})}(e,this._core),{OnlineMemberNum:s=0,ExpireTime:n=nl}=t||{},o=Date.now(),i={lastSyncTime:o,latestUpdateTime:o,lastReqTime:o,memberCount:s,expireTime:n};return Sl.updateLocalOnlineMemberCount(e,i),{memberCount:s}}catch(e){const s=new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,s),s}})}}])}()),Sl=new(function(){return _createClass(function _class111(){_classCallCheck(this,_class111),this._name="AVChatRoomHandler",this._joinedGroupMap=new Map,this._pollingRequestInfoMap=new Map,this._pollingInstanceMap=new Map,this._onlineMemberCountMap=new Map,this._pollingIntervalMap=new Map,this._pollingNoMessageCountMap=new Map,this._membersReqInfoMap=new Map,this._startBroadcastSequence=1},[{key:"init",value:function init(e,t){this._core=e,this._parentPlugin=t,_l.init(e,this),e.ssoLog.debug("AVChatRoomHandler.init")}},{key:"onAVChatRoomSystemNotification",value:function onAVChatRoomSystemNotification(e){const{OuterConstant:{GRP_AVCHATROOM:t}}=this._core,{GroupTips:s=[]}=e;for(let e=0;e<s.length;e++){const{MsgBody:n,GroupInfo:{GroupId:o,GroupType:i}}=s[e],r=Object.values(sl).includes(n.ReportType);i===t&&r&&this.reset(o)}}},{key:"getCurrentPollingInterval",value:function getCurrentPollingInterval(e){return this._pollingIntervalMap.get(e)||fl()}},{key:"isPollingSimplifiedMessage",value:function isPollingSimplifiedMessage(){return 0!==Il()}},{key:"isGroupAttributesUpdated",value:function isGroupAttributesUpdated(e){return this._parentPlugin.groupAttribute.isGroupAttributesUpdated(e)}},{key:"handleGroupAttributesUpdated",value:function handleGroupAttributesUpdated(e){this._parentPlugin.groupAttribute.handleGroupAttributesUpdated(e)}},{key:"updateLocalOnlineMemberCount",value:function updateLocalOnlineMemberCount(e,t){const{notificationCenter:s,OuterEvent:{GROUP_ONLINE_MEMBER_COUNT_CHANGED:n}}=this._core;this._onlineMemberCountMap.set(e,t),s.emitOuterEvent(n,{name:n,data:{groupID:e,count:t.memberCount}})}},{key:"getLocalOnlineMemberCount",value:function getLocalOnlineMemberCount(e){return this._onlineMemberCountMap.get(e)||{}}},{key:"hasPollingInstance",value:function hasPollingInstance(e){return this._pollingInstanceMap.has(e)}},{key:"getJoinedLiveList",value:function getJoinedLiveList(){const{OuterConstant:{GRP_LIVE:e}}=this._core;let t=[];return this._joinedGroupMap.size>0&&(t=[...this._joinedGroupMap.values()].filter(t=>t.type===e)),t}},{key:"handleJoinGroupResult",value:function handleJoinGroupResult(e){return pe(this,void 0,void 0,function*(){const{utils:{isUndefined:t},OuterConstant:{CONV_GROUP:s},apiMap:{getConversationProfile:n},OuterConstant:o}=this._core,{longPollingKey:i,group:r,historyMessageList:a=[]}=e,{groupID:c}=r;return yield this._preCheck(r),this._joinedGroupMap.set(c,r),this._parentPlugin.groupDataHandler.updateLocalGroup([r]),this._parentPlugin.groupDataHandler.emitGroupListUpdate(),n(`${s}${c}`),El.getGroupOnlineMemberCount(c),a.length>0&&_l.onMessageReceived(c,a,!0),t(i)?{code:0,data:{status:o.JOIN_STATUS_SUCCESS,group:r}}:{code:0,data:this.startMessageLongPolling(e)}})}},{key:"isGroupCounterUpdated",value:function isGroupCounterUpdated(e){return this._parentPlugin.groupCounter.isGroupCounterUpdated(e)}},{key:"handleGroupCounterUpdated",value:function handleGroupCounterUpdated(e){this._parentPlugin.groupCounter.handleGroupCounterUpdated(e)}},{key:"_preCheck",value:function _preCheck(e){return pe(this,void 0,void 0,function*(){const{common:t,OuterConstant:s,helper:n,apiMap:{quitGroup:o},ssoLog:i}=this._core;if(t.isUnlimitedAVChatRoom()){if(this._pollingInstanceMap.size>(()=>{const e=ml("polling_count_limit");return vl(e)&&e>0?parseInt(e,10):20})())throw new n.ChatError({code:2688,message:"the count of longPolling exceeds the max limit"});return}if(0===this._joinedAVChatRoomCount())return;if(e.type===s.GRP_LIVE)return;const[r,a]=this._joinedGroupMap.entries().next().value;if(a.selfInfo.role===s.GRP_MBR_ROLE_OWNER)this._parentPlugin.groupDataHandler.deleteLocalGroup(r);else try{yield o(r)}catch(e){i.debug("quitGroup",`${this._name}._preCheck quitGroup failed, groupID:${r} info:`,e)}this.reset(r)})}},{key:"startMessageLongPolling",value:function startMessageLongPolling(e){const{OuterConstant:t}=this._core,{longPollingKey:s,startSequence:n=1,group:o}=e,{groupID:i}=o;return this._pollingRequestInfoMap.set(i,{longPollingKey:s,startSequence:n}),this._pollingIntervalMap.set(i,fl()),this._startPolling(i),this._reportLongPollingCount(),{status:t.JOIN_STATUS_SUCCESS,group:o}}},{key:"_startPolling",value:function _startPolling(e){if(this._core.ssoLog.debug("_startPolling",`${this._name}._startPolling groupID:${e}`),this._pollingInstanceMap.has(e)){const t=this._pollingInstanceMap.get(e);return void((null==t?void 0:t.isRunning())||null==t||t.start())}const t=new cl({core:this._core,manager:this,groupID:e,getRequestParams:this._handleRequestParams.bind(this),onSuccess:this._handleSuccess.bind(this),onFail:this._handleFailure.bind(this)});t.start(),this._pollingInstanceMap.set(e,t)}},{key:"_handleRequestParams",value:function _handleRequestParams(e){const{longPollingKey:t,startSequence:s}=this._pollingRequestInfoMap.get(e)||{};return e===[...this._pollingInstanceMap.keys()][0]?{longPollingKey:t,startSequence:s,startBroadcastSeq:this._startBroadcastSequence,simplifiedMessage:Il()}:{longPollingKey:t,startSequence:s,simplifiedMessage:Il()}}},{key:"_handleSuccess",value:function _handleSuccess(e,t){const{ErrorCode:s}=t;if(0!==s){const{longPollingKey:t,startSequence:n}=this._pollingRequestInfoMap.get(e)||{};return void console.warn(`${this._name}._handleSuccess groupID:${e} key:${t} startSeq:${n} errorCode:${s}`)}this._hasJoinedAVChatRoom(e)&&this._handleResponseData(e,t)}},{key:"_handleResponseData",value:function _handleResponseData(e,t){const{Key:s,NextSeq:n,NextBroadcastSeq:o,RspMsgList:i=[],RspBroadcastMsgList:r=[]}=t;if(s&&n&&this._pollingRequestInfoMap.set(e,{longPollingKey:s,startSequence:n}),o&&o>this._startBroadcastSequence&&(this._startBroadcastSequence=o),i.length>0)0!==this._getPollingNoMessageCount(e)&&(this._updatePollingNoMessageCount(e,0),this._pollingIntervalMap.set(e,fl())),_l.onMessageReceived(e,i);else{let t=this._getPollingNoMessageCount(e);if(t+=1,this._updatePollingNoMessageCount(e,t),t===(()=>{const e=ml("polling_no_msg_count");return vl(e)?parseInt(e,10):20})()){const t=fl()+(()=>{const e=ml("polling_interval_plus");return vl(e)?parseInt(e,10):2e3})();this._pollingIntervalMap.set(e,t)}}r.length>0&&_l.onBroadcastMessageReceived(r)}},{key:"_handleFailure",value:function _handleFailure(e,t){const{ssoLog:s,utils:{safeStringify:n}}=this._core;s.warn("polling",`${this._name}._handleFailure groupID:${e} error: ${n(t)}`)}},{key:"_joinedAVChatRoomCount",value:function _joinedAVChatRoomCount(){const{OuterConstant:e}=this._core;let t=[];return this._joinedGroupMap.size>0&&(t=this.getJoinedGroups().filter(t=>t.type===e.GRP_AVCHATROOM)),t.length}},{key:"_hasJoinedAVChatRoom",value:function _hasJoinedAVChatRoom(e){return this._joinedGroupMap.has(e)}},{key:"getJoinedGroups",value:function getJoinedGroups(){return[...this._joinedGroupMap.values()]}},{key:"updateLocalLiveGroup",value:function updateLocalLiveGroup(e,t){this._joinedGroupMap.set(e,t),this._parentPlugin.groupDataHandler.updateLocalGroup([t])}},{key:"handleLiveHistoryMessages",value:function handleLiveHistoryMessages(e,t){_l.onMessageReceived(e,t,!0)}},{key:"isOverFrequencyLimit",value:function isOverFrequencyLimit(e){if(!this._membersReqInfoMap.has(e))return this._membersReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1;let{startTime:t,requestCount:s}=this._membersReqInfoMap.get(e);const{interval:n,count:o}=(()=>{const e=ml("av_members_freq_limit");if(vl(e)){const{interval:t,count:s}=JSON.parse(e);if(s>0&&t>0)return{interval:t,count:s}}return{interval:30,count:4}})();return Date.now()-t>1e3*n?(this._membersReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1):(s+=1,this._membersReqInfoMap.set(e,{startTime:t,requestCount:s}),s>o)}},{key:"_stopPolling",value:function _stopPolling(e){if(this._core.ssoLog.debug("_stopPolling",`${this._name}._stopPolling groupID:${e}`),e){const{appStore:{conversationStore:t},OuterConstant:{CONV_GROUP:s}}=this._core;t.deleteConversation(`${s}${e}`);const n=this._pollingInstanceMap.get(e);return null==n||n.stop(),this._parentPlugin.groupDataHandler.deleteLocalGroup(e),this._pollingInstanceMap.delete(e),this._pollingRequestInfoMap.delete(e),this._joinedGroupMap.delete(e),this._onlineMemberCountMap.delete(e),this._pollingIntervalMap.delete(e),this._pollingNoMessageCountMap.delete(e),void this._membersReqInfoMap.delete(e)}for(const e of this._pollingInstanceMap.values())null==e||e.stop();this._pollingInstanceMap.clear(),this._pollingRequestInfoMap.clear(),this._joinedGroupMap.clear(),this._onlineMemberCountMap.clear(),this._pollingIntervalMap.clear(),this._pollingNoMessageCountMap.clear(),this._membersReqInfoMap.clear()}},{key:"_updatePollingNoMessageCount",value:function _updatePollingNoMessageCount(e,t){this._pollingNoMessageCountMap.set(e,t)}},{key:"_getPollingNoMessageCount",value:function _getPollingNoMessageCount(e){return this._pollingNoMessageCountMap.get(e)||0}},{key:"_reportLongPollingCount",value:function _reportLongPollingCount(){const e=this._joinedGroupMap.size;if(e>1){const{common:t,OuterConstant:s,ssoLog:n}=this._core,o=t.isUnlimitedAVChatRoom()?1:0,i=[],r=[];Array.from(this._joinedGroupMap.values()).forEach(({groupID:e,type:t})=>{t===s.GRP_LIVE?r.push(e):i.push(e)}),n.info("longPollingCount",String(e),{moreMessage:`av:${i.join(",")} live:${r.join(",")} code: ${o}`,eventType:29})}}},{key:"reset",value:function reset(e){this._stopPolling(e),this._startBroadcastSequence=1,_l.reset()}}])}()),Cl=new(function(){return _createClass(function _class112(){_classCallCheck(this,_class112)},[{key:"init",value:function init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"joinGroup",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}},{key:"joinGroup",value:function joinGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=yield this._parentPlugin.groupAction.joinGroup(e),{data:{status:n,group:{type:o}}}=s;return o===t.GRP_AVCHATROOM?n===t.JOIN_STATUS_ALREADY_IN_GROUP?s:Sl.handleJoinGroupResult(s.data):s})}}])}()),Ml=new(function(){return _createClass(function _class113(){_classCallCheck(this,_class113)},[{key:"init",value:function init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"quitGroup",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}},{key:"quitGroup",value:function quitGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=yield this._parentPlugin.groupAction.quitGroup(e),{data:{type:n}}=s;return n===t.GRP_AVCHATROOM&&Sl.reset(e),s})}}])}()),yl=new(function(){return _createClass(function _class114(){_classCallCheck(this,_class114)},[{key:"init",value:function init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"dismissGroup",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}},{key:"dismissGroup",value:function dismissGroup(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=yield this._parentPlugin.groupAction.dismissGroup(e),{data:{type:n}}=s;return n===t.GRP_AVCHATROOM&&Sl.reset(e),s})}}])}()),Ol=new(function(){return _createClass(function _class115(){_classCallCheck(this,_class115),this._name="GetAVChatRoomMemberList"},[{key:"init",value:function init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"getGroupMemberList",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}},{key:"getGroupMemberList",value:function getGroupMemberList(e){return pe(this,void 0,void 0,function*(){const{appStore:{groupStore:t},helper:s,OuterConstant:n}=this._core,{groupID:o}=e,i=t.getGroup(o);if((null==i?void 0:i.type)===n.GRP_AVCHATROOM&&s.checkBusinessCapabilityBits("AV_MBR_LIST")){if(Sl.isOverFrequencyLimit(o))throw{code:2996,message:`Over frequency limit: get_members-${o}`};return this._getGroupMemberList(e)}return this._parentPlugin.groupMember.getGroupMemberList(e)})}},{key:"_getGroupMemberList",value:function _getGroupMemberList(e){return pe(this,void 0,void 0,function*(){const t="_getGroupMemberList",{helper:s}=this._core;try{const s=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,offset:n=0}=e,o={GroupId:s,Timestamp:n};return t.common.buildAndSendPacket({servcmd:"group_open_avchatroom_http_svc.get_members",data:o})})}(e,this._core),{MemberList:n=[],NextTimestamp:o=0}=s||{},i=this._handleMemberList(n);return console.log(`${this._name}.${t} ok, groupID:${e.groupID} count:${i.length} nextOffset:${o}`),{code:0,data:{memberList:i,offset:o}}}catch(e){const n=new s.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo});throw console.error(`${this._name}.${t} fail:`,n),n}})}},{key:"_handleMemberList",value:function _handleMemberList(e){return e.map(e=>{const{Member_Account:t,NickName:s="",Avatar:n="",Remark:o="",JoinTime:i=0,Marks:r=[]}=e;return{userID:t,nick:s,avatar:n,remark:o,joinTime:i,marks:r,isOnline:!0}})}}])}()),Al=new(function(){return _createClass(function _class116(){_classCallCheck(this,_class116),this._name="DeleteAVChatRoomMember"},[{key:"init",value:function init(e,t){this._core=e,this._parentPlugin=t;const{helper:s}=e;s.registerApi({apiName:"deleteGroupMember",context:this,matcher:()=>t.getInstalledSubPlugins().length>0})}},{key:"deleteGroupMember",value:function deleteGroupMember(e){return pe(this,void 0,void 0,function*(){const t="deleteGroupMember",{appStore:{groupStore:s},utils:{isUndefined:n},helper:o,OuterConstant:i}=this._core,{groupID:r}=e,a=s.getGroup(r);if(n(a))throw new o.ChatError({functionName:t,code:2603});if(a.type===i.GRP_AVCHATROOM){if(o.checkBusinessCapabilityBits("AV_BAN_MBR"))return this._deleteGroupMember(e);throw new o.ChatError({functionName:t,code:3122})}return this._parentPlugin.groupMember.deleteGroupMember(e)})}},{key:"_deleteGroupMember",value:function _deleteGroupMember(e){return pe(this,void 0,void 0,function*(){const t="_deleteGroupMember",{appStore:{groupStore:s},helper:n,ssoLog:o}=this._core,{groupID:i,duration:r=0,userIDList:a}=e;if(0===r)throw new n.ChatError({functionName:t,code:2686});try{return yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,userIDList:n,duration:o,reason:i}=e,r={GroupId:s,Members_Account:n,Duration:o,Description:i};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.ban_group_member",data:r})})}(e,this._core),o.debug(t,`${this._name}.${t} ok, groupID:${i}`),{code:0,data:{group:s.getGroup(i),userIDList:a}}}catch(e){throw new n.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}}])}()),Tl=new(function(){return _createClass(function _class117(){_classCallCheck(this,_class117),this._name="MarkAVChatRoomMember"},[{key:"init",value:function init(e){this._core=e;const{helper:t}=e;t.registerApi({apiName:"markGroupMemberList",context:this})}},{key:"markGroupMemberList",value:function markGroupMemberList(e){return pe(this,void 0,void 0,function*(){const t="markGroupMemberList",{groupID:s,markType:n,enableMark:o,userIDList:i=[]}=e,r=this._generateRequestData(e);try{const e=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,operationType:n,memberList:o}=e,i={GroupId:s,CommandType:n,MemberList:o};return t.common.buildAndSendPacket({servcmd:"group_open_avchatroom_http_svc.modify_user_info",data:i})})}(r,this._core),{MemberList:a=[]}=e||{},{successUserIDList:c,failureUserIDList:u}=this._handleResult(a,i);return{code:0,data:{successUserIDList:c,failureUserIDList:u},successLog:{message:`${this._name}.${t} ok, groupID:${s} markType:${n} enableMark:${o} success:${c.length} fail:${u.length}`}}}catch(e){throw new this._core.helper.ChatError({functionName:t,code:null==e?void 0:e.errorCode,message:null==e?void 0:e.errorInfo})}})}},{key:"_generateRequestData",value:function _generateRequestData(e){const{groupID:t,markType:s,enableMark:n,userIDList:o=[]}=e,i=!0===n?1:2,r=[...o];return r.length>500&&console.warn(`${this._name}._generateRequestData, the length of userIDList cannot exceed 500`),{groupID:t,operationType:i,memberList:r.map(e=>({Member_Account:e,Marks:[s]}))}}},{key:"_handleResult",value:function _handleResult(e,t){const s=[],n=[];return e.length===t.length?(s.push(...t),{successUserIDList:s,failureUserIDList:n}):(t.forEach(t=>{e.find(e=>e.Member_Account===t)?s.push(t):n.push(t)}),{successUserIDList:s,failureUserIDList:n})}}])}()),Rl=new(function(){return _createClass(function _class118(){_classCallCheck(this,_class118)},[{key:"init",value:function init(e,t){e.ssoLog.debug("AVChatRoomAction.init"),Cl.init(e,t),Ml.init(e,t),yl.init(e,t),Ol.init(e,t),El.init(e,t),Al.init(e,t),Tl.init(e)}}])}()),Dl=new(function(){return _createClass(function _class119(){_classCallCheck(this,_class119),this._name="LiveHandler"},[{key:"init",value:function init(e){this._core=e;const{helper:t,ssoLog:s}=e;t.registerExperimentalAPI("startMessageLongPolling",this),t.registerExperimentalAPI("stopMessageLongPolling",this),s.debug("LiveHandler.init")}},{key:"startMessageLongPolling",value:function startMessageLongPolling(e){const{common:t,utils:{isEmpty:s},OuterConstant:n,ssoLog:o}=this._core,{groupID:i,longPollingKey:r,longPollingSequence:a=1}=e;if(s(r))return o.warn("startMessageLongPolling",`${this._name}.startMessageLongPolling longPollingKey is empty.`),Promise.resolve({});Sl.hasPollingInstance(i)&&this.stopMessageLongPolling({groupID:i});const c=Sl.getJoinedLiveList(),u=t.isUnlimitedAVChatRoom();!u&&c.length>0&&this.stopMessageLongPolling({groupID:c[0].groupID}),o.debug("startMessageLongPolling",`${this._name}.startMessageLongPolling isUnlimited:${u} groupID:${i} longPollingKey:${r} longPollingSequence:${a}`);const l={groupID:i,type:n.GRP_LIVE};return Sl.updateLocalLiveGroup(i,l),this._getLiveHistoryMessages({groupID:i,longPollingKey:r,startSequence:a}),Sl.startMessageLongPolling({group:l,longPollingKey:r,startSequence:a})}},{key:"stopMessageLongPolling",value:function stopMessageLongPolling(e){const{groupID:t}=e;return Sl.reset(t),this._core.ssoLog.debug("stopMessageLongPolling",`${this._name}.stopMessageLongPolling ok, groupID:${t}`),Promise.resolve({groupID:t})}},{key:"_getLiveHistoryMessages",value:function _getLiveHistoryMessages(e){return pe(this,void 0,void 0,function*(){const{ssoLog:t}=this._core,{groupID:s}=e;try{const n=yield function(e,t){return pe(this,void 0,void 0,function*(){const{groupID:s,longPollingKey:n,startSequence:o}=e,i={GroupId:s,LongPollingKey:n,PullPreSeq:o};return t.common.buildAndSendPacket({servcmd:"group_open_http_svc.get_huge_group_msg",data:i})})}(e,this._core),{RspMsgList:o=[]}=n||{};t.debug("_getLiveHistoryMessages",`${this._name}._getLiveHistoryMessages ok, groupID:${s} count:${o.length}`),o.length>0&&Sl.handleLiveHistoryMessages(s,o)}catch(e){t.debug("_getLiveHistoryMessages",`${this._name}._getLiveHistoryMessages failed, groupID:${s} info:${e.message}`)}})}}])}()),bl=new(function(){return _createClass(function _class120(){_classCallCheck(this,_class120),this.name="AVChatRoom"},[{key:"install",value:function install(e,t){this._core=e,Xu.init(e),Sl.init(e,t),Rl.init(e,t),Dl.init(e);const{notificationCenter:s,InnerEvent:n}=e,{InnerEventSubType:o}=s;s.subscribeInnerEvent(n.MESSAGE_PUSH,o.GROUP_SYSTEM_NOTIFICATION,this._onAVChatRoomSystemNotification,this),s.subscribeInnerEvent(n.LOGOUT,this._reset,this),s.subscribeInnerEvent(n.DESTROY,this._dispose,this)}},{key:"_onAVChatRoomSystemNotification",value:function _onAVChatRoomSystemNotification(e){Sl.onAVChatRoomSystemNotification(e)}},{key:"_reset",value:function _reset(){Sl.reset()}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e,InnerEvent:t}=this._core,{InnerEventSubType:s}=e;e.unSubscribeInnerEvent(t.MESSAGE_PUSH,s.GROUP_SYSTEM_NOTIFICATION,this._onAVChatRoomSystemNotification,this),e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this._dispose,this)}}])}());const Nl=new(function(){return _createClass(function _class121(){_classCallCheck(this,_class121)},[{key:"init",value:function init(e){this.core=e}}])}()),Ll="message",Pl="user",Gl={OR:"or",AND:"and"},wl=20,Ul=20,kl=20,Fl={required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>!e||!!(Array.isArray(e)&&e.length<=5)||"keywordList should be an array and length <= 5"},$l={required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>!e||!![Gl.OR,Gl.AND].includes(e)||"keywordListMatchType should be OR or AND"},xl={required:!1,rules:["number"],allowEmpty:!0,customValidator:e=>"number"==typeof e&&e>=1&&e<=100||"count must be a number between 1 and 100"},ql={required:!1,rules:["string"],allowEmpty:!0},Vl={required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=Nl.core;if(!Array.isArray(e))return"groupTypeList should be an array";const s=[t.GRP_PUBLIC,t.GRP_COMMUNITY,t.GRP_WORK,t.GRP_MEETING];let n=!1;for(let t=0;t<e.length;t++)if(-1===s.indexOf(e[t])){n=!0;break}return!n||"groupTypeList should be supported group type"}},Bl={required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=Nl.core,s=[t.MSG_TEXT,t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_FILE,t.MSG_VIDEO,t.MSG_LOCATION,t.MSG_CUSTOM,t.MSG_MERGER];let n=!1;for(let t=0;t<e.length;t++)if(-1===s.indexOf(e[t])){n=!0;break}return!n||"messageTypeList should be supported message type"}},jl={required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=Nl.core;return!(!(null==e?void 0:e.startsWith(t.CONV_C2C))&&!(null==e?void 0:e.startsWith(t.CONV_GROUP))&&e!==t.CONV_SYSTEM)||"conversationID is invalid"}},Hl=e=>({required:!1,rules:["number"],allowEmpty:!0,customValidator:t=>"number"==typeof t&&t>=0||`${e} should be a number >= 0';`}),Kl={required:!1,rules:["string"],allowEmpty:!0,customValidator:e=>{const{OuterConstant:t}=Nl.core;return!![t.GENDER_FEMALE,t.GENDER_MALE].includes(e)||"gender is invalid"}},Wl={searchCloudMessages:{keywordList:Fl,keywordListMatchType:$l,cursor:ql,senderUserIDList:{required:!1,rules:["array"],allowEmpty:!0,customValidator:e=>!!(Array.isArray(e)&&e.length<=5)||"senderUserIDList should be an array and length <= 5"},messageTypeList:Bl,conversationID:jl,timePosition:Hl("timePosition"),timePeriod:Hl("timePeriod")},searchCloudUsers:{keywordList:Fl,keywordListMatchType:$l,cursor:ql,count:xl,miniBirthday:Hl("miniBirthday"),maxBirthday:Hl("maxBirthday"),gender:Kl},searchCloudGroupMembers:{keywordList:Fl,keywordListMatchType:$l,cursor:ql,count:xl,groupTypeList:Vl,groupIDList:{required:!1,rules:["array"],allowEmpty:!0}},searchCloudGroups:{keywordList:Fl,keywordListMatchType:$l,cursor:ql,count:xl,groupTypeList:Vl}},Yl={searchCloudMessages:!0,searchCloudUsers:!0,searchCloudGroupMembers:!0,searchCloudGroups:!0};var zl=new(function(){return _createClass(function _class122(){_classCallCheck(this,_class122),this.name="CloudSearch"},[{key:"install",value:function install(e){this._core=e,Nl.init(e),e.helper.registerApi({apiName:"searchCloudMessages",context:this}),e.helper.registerApi({apiName:"searchCloudUsers",context:this}),e.helper.registerApi({apiName:"searchCloudGroupMembers",context:this}),e.helper.registerApi({apiName:"searchCloudGroups",context:this}),e.helper.registerValidateConfig({auth:Yl,params:Wl})}},{key:"searchCloudMessages",value:function searchCloudMessages(e){return pe(this,void 0,void 0,function*(){try{const{OuterConstant:t,helper:s}=this._core,{conversationID:n,timePeriod:o,timePosition:i}=e,r=ge(e,["conversationID","timePeriod","timePosition"]),a=Object.assign({count:100},r);n&&(n.startsWith(t.CONV_C2C)?a.account=n.replace(t.CONV_C2C,""):n.startsWith(t.CONV_GROUP)&&(a.groupID=n.replace(t.CONV_GROUP,""))),this._setTimeRangeParams(a,{timePeriod:o,timePosition:i});const c=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,senderUserIDList:o,messageTypeList:i,endTime:r,startTime:a,cursor:c,account:u,groupID:l}=e,d={Count:t,KeywordList:s,MatchType:n,SendUserIDList:o,MsgTypeList:i,EndTime:r,StartTime:a,Cursor:c,PeerAccount:u,GroupID:l};return Nl.core.common.buildAndSendPacket({servcmd:"message_search.query",data:d})})}(a);if(!c)return{code:0,data:{}};const{ErrorCode:u,ErrorInfo:l,TotalCount:d,Cursor:h="",ConversationMsgs:g=[]}=c;if(0!==u)throw{errorCode:u,errorInfo:l};const p=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} res: totalCount:${d}`,_=g.map(n=>{const{MsgList:o,Count:i,GroupID:r,UserID:a}=n,c=r?`${t.CONV_GROUP}${r}`:`${t.CONV_C2C}${a}`;if(this._isSearchingAllConversations(e)&&i>1)return{conversationID:c,messageCount:i,messageList:[]};const u=o.map(e=>s.isEmpty(r)?function(e,t){const s=t.OuterConstant.CONV_C2C,n=t.message.messageHelper.parseServerPushMessage(e),o=t.message.messageFactory.createMessage(Object.assign(Object.assign({},n),{conversationType:s,flow:"in"}));return o.setElement(n.elements),o}(e,this._core):function(e,t){const s=t.OuterConstant.CONV_GROUP,n=t.message.messageHelper.parseServerGroupMessage(e),o=t.message.messageFactory.createMessage(Object.assign(Object.assign({},n),{conversationType:s,flow:"in"}));return o.setElement(n.elements),o}(e,this._core));return{conversationID:c,messageCount:i,messageList:u}});return{code:0,data:{searchResultList:_,cursor:h,totalCount:d},successLog:{message:p}}}catch(e){const{errorCode:t,errorInfo:s}=e||{};this._handleError({errorCode:t,errorInfo:s,searchType:Ll,functionName:"searchCloudMessages"})}})}},{key:"searchCloudUsers",value:function searchCloudUsers(e){return pe(this,void 0,void 0,function*(){var t;try{const{keywordListMatchType:s,count:n=Ul}=e,o=ge(e,["keywordListMatchType","count"]),i=Object.assign({count:n,keywordListMatchType:s===Gl.AND?1:0},o);this._setBirthdayRangeParams(i,e);const r=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,miniBirthday:o,maxBirthday:i,cursor:r,gender:a}=e,c={Count:t,Keywords:s,KeywordMatchType:n,Cursor:r,UserBirthStart:o,UserBirthEnd:i,Gender:a};return Nl.core.common.buildAndSendPacket({servcmd:"user_search.query",data:c})})}(i);if(!r)return{error:0,data:{}};const{ErrorCode:a,ErrorInfo:c,TotalCount:u,Cursor:l="",Users:d=[]}=r;if(0!==a)throw{errorCode:a,errorInfo:c};const h=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} count:${e.count} res: totalCount:${u}`,g=[];for(let e=0,s=d.length;e<s;e++){const{UserID:s,ProfileItems:n}=d[e];if(s===this._core.OuterConstant.USER_NOT_FOUND||""===s)continue;const o=n.map(e=>({tag:e.Tag,value:e.StrValue})),i=null===(t=this._core.user.userProfile)||void 0===t?void 0:t.createProfile(s,o);g.push(i)}return{code:0,data:{searchResultList:g,cursor:l,totalCount:u},successLog:{message:h}}}catch(e){const{errorCode:t,errorInfo:s}=e||{};this._handleError({errorCode:t,errorInfo:s,searchType:Pl,functionName:"searchCloudUsers"})}})}},{key:"searchCloudGroupMembers",value:function searchCloudGroupMembers(e){return pe(this,void 0,void 0,function*(){try{const{count:t=kl,keywordListMatchType:s}=e,n=ge(e,["count","keywordListMatchType"]),o=Object.assign({count:t,keywordListMatchType:s===Gl.AND?1:0},n),i=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,groupTypeList:o,cursor:i,groupIDList:r}=e,a={Count:t,Keywords:s,KeywordMatchType:n,Cursor:i,GroupType:o,GroupIdList:r};return Nl.core.common.buildAndSendPacket({servcmd:"group_member_search.query",data:a})})}(o);if(!i)return{code:0,data:{}};const{ErrorCode:r,ErrorInfo:a,GroupMembers:c=[],Cursor:u,TotalCount:l}=i;if(0!==r)throw{errorCode:r,errorInfo:a};const d=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} count:${e.count} res: totalCount:${l}`,h=new Map;return c.forEach(e=>{const{GroupID:t,GroupName:s,GroupType:n,GroupFaceUrl:o,GroupMemberUserName:i,GroupMemberUserID:r,GroupMemberNameCard:a,GroupMemberAvatar:c=""}=e,u={groupID:t,name:s,type:n,avatar:o},l={userID:r,nick:i,nameCard:a,avatar:c};if(h.has(t)){const e=h.get(t);e.memberList.push(l),h.set(t,e)}else h.set(t,{groupInfo:u,memberList:[l]})}),{code:0,data:{searchResultList:[...h.values()],cursor:u,totalCount:l},successLog:{message:d}}}catch(e){const{errorCode:t,errorInfo:s}=e||{};this._handleError({errorCode:t,errorInfo:s,searchType:Pl,functionName:"searchCloudGroupMembers"})}})}},{key:"searchCloudGroups",value:function searchCloudGroups(e){return pe(this,void 0,void 0,function*(){try{const{count:t=wl,keywordListMatchType:s}=e,n=ge(e,["count","keywordListMatchType"]),o=Object.assign({count:t,keywordListMatchType:s===Gl.AND?1:0},n),i=yield function(e){return pe(this,void 0,void 0,function*(){const{count:t,keywordList:s,keywordListMatchType:n,groupTypeList:o,cursor:i}=e,r={Count:t,Keywords:s,KeywordMatchType:n,Cursor:i,GroupType:o};return Nl.core.common.buildAndSendPacket({servcmd:"group_search.query",data:r})})}(o);if(!i)return{code:0,data:{}};const{ErrorCode:r,ErrorInfo:a,Groups:c,Cursor:u,TotalCount:l}=i;if(0!==r)throw{errorCode:r,errorInfo:a};const d=`keywordList:${e.keywordList} keywordListMatchType:${e.keywordListMatchType} cursor:${e.cursor} count:${e.count} res: totalCount:${l}`;return{code:0,data:{searchResultList:(null==c?void 0:c.map(e=>function(e){const{GroupFaceUrl:t,GroupID:s,GroupIntroduction:n,GroupMemberNum:o,GroupName:i,GroupOwnerTinyID:r,GroupOwnerUserID:a,GroupOwnerUserName:c,GroupType:u,GroupAddOption:l,GroupInviteOption:d}=e;return{avatar:t,groupID:s,introduction:n,memberCount:o,name:i,ownerTinyID:r,ownerID:a,ownerNick:c,type:u,joinOption:l,inviteOption:d}}(e)))||[],cursor:u,totalCount:l},successLog:{message:d}}}catch(e){const{errorCode:t,errorInfo:s}=e||{};this._handleError({errorCode:t,errorInfo:s,searchType:Pl,functionName:"searchCloudGroups"})}})}},{key:"_setTimeRangeParams",value:function _setTimeRangeParams(e,{timePeriod:t,timePosition:s}){t&&t>0&&(e.startTime=s&&s>0?s-t:this._core.helper.timeManager.getServerTimeSeconds()-t),e.startTime&&e.startTime<0&&(e.startTime=void 0),s&&s>0&&(e.endTime=s)}},{key:"_handleError",value:function _handleError({errorCode:e,errorMessage:t,searchType:s}){const{helper:n}=this._core;let o=e;throw 60020===e?o="SearchUnable":s!==Ll&&27003===e?o="SearchParamsError":s!==Ll&&60018===e&&(o="SearchOverLimit"),new n.ChatError({code:o,message:t})}},{key:"_isSearchingAllConversations",value:function _isSearchingAllConversations(e){return this._core.helper.isEmpty(e.conversationID)}},{key:"_setBirthdayRangeParams",value:function _setBirthdayRangeParams(e,t){const{miniBirthday:s,maxBirthday:n}=t;void 0!==s&&(e.miniBirthday=s,void 0===n&&(e.maxBirthday=4294967295)),void 0!==n&&(e.maxBirthday=n)}}])}());function Jl(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}const Ql="qualityStat",Xl="im-ssolog-quality-stat";var Zl;!function(e){e[e.ONLINE=8]="ONLINE"}(Zl||(Zl={}));const ed="networkRTT",td="messageE2EDelay",sd="sendMessageC2C",nd="sendMessageGroup",od="sendMessageGroupAV",id="sendMessageRichMedia",rd="cosUpload",ad="messageReceivedGroup",cd="messageReceivedGroupAVPush",ud="messageReceivedGroupAVPull",ld={[ed]:2,[td]:3,[sd]:4,[nd]:5,[od]:6,[id]:7,[ad]:8,[cd]:9,[ud]:10,[rd]:11},dd=[sd,nd,od,id,rd],hd=[ad,cd,ud],gd=[ed,td,sd,nd,od,id,rd,ad,cd,ud],pd={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MSG_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},_d="quality_stat";var md=new(function(){return _createClass(function _class123(){_classCallCheck(this,_class123),this._messageStatsMap=new Map,this._userSideErrorCodes=new Set(Object.values(pd))},[{key:"init",value:function init(e){this._core=e,Object.values(dd).forEach(e=>{this._messageStatsMap.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costSum:0,costCount:0,fileSizeSum:0})})}},{key:"dispatchSendStats",value:function dispatchSendStats(e){const{name:t,message:s,error:n,startTs:o}=e,{SEND_MESSAGE_STAT:i}=this._core.constants;switch(t){case i.TOTAL_COUNT:this._handleTotalCount(s);break;case i.SUCCESS_COUNT:this._handleSuccessCount(s);break;case i.FAILED_COUNT:this._handleFailedCount(s,n);break;case i.SEND_COST:this._handleSendCost(s,o)}}},{key:"getStatResult",value:function getStatResult(e){const t=this._messageStatsMap.get(e);if(!t||0===t.totalCount)return null;const{totalCount:s,successCount:n,failedCountOfUserSide:o}=t,i=Jl(n/s*100,2),r=n+o,a=Jl(r/s*100,2),c=this._calcAverageValue(t,e);return this._resetStat(e),{total_count:s,success_count_business:n,percent_business:i,success_count_platform:r,percent_platform:a,average_value:c}}},{key:"_handleTotalCount",value:function _handleTotalCount(e){const t=this._getSendMessageSpecifiedKey(e),s=t&&this._messageStatsMap.get(t);s&&s.totalCount++}},{key:"_handleSuccessCount",value:function _handleSuccessCount(e){const t=this._getSendMessageSpecifiedKey(e),s=t&&this._messageStatsMap.get(t);s&&s.successCount++}},{key:"_handleFailedCount",value:function _handleFailedCount(e,t){var s;const n=null!==(s=null==t?void 0:t.code)&&void 0!==s?s:null==t?void 0:t.errorCode;if(this._isUserSideError(n)){const t=this._getSendMessageSpecifiedKey(e),s=t&&this._messageStatsMap.get(t);s&&s.failedCountOfUserSide++}}},{key:"_handleSendCost",value:function _handleSendCost(e,t){const s=this._getSendMessageSpecifiedKey(e),n=s&&this._messageStatsMap.get(s);n&&(n.costSum+=Date.now()-t,n.costCount++)}},{key:"_isUserSideError",value:function _isUserSideError(e){return this._userSideErrorCodes.has(e)||e>=120001&&e<=13e4||e>=10100&&e<=10200}},{key:"_getSendMessageSpecifiedKey",value:function _getSendMessageSpecifiedKey(e){const{MSG_IMAGE:t,MSG_AUDIO:s,MSG_VIDEO:n,MSG_FILE:o,CONV_C2C:i,CONV_GROUP:r,GRP_AVCHATROOM:a}=this._core.OuterConstant;if([t,s,n,o].includes(e.type))return id;if(e.conversationType===i)return sd;if(e.conversationType===r){const{groupStore:t}=this._core.appStore,s=t.getGroup(e.to);if(!s)return;const{type:n}=s;return n===a?od:nd}}},{key:"_calcAverageValue",value:function _calcAverageValue(e,t){return 0===e.costCount?0:t===rd?Math.round(1e3*e.fileSizeSum/e.costSum):Math.round(e.costSum/e.costCount)}},{key:"_resetStat",value:function _resetStat(e){const t=this._messageStatsMap.get(e);t&&(t.totalCount=0,t.successCount=0,t.failedCountOfUserSide=0,t.costSum=0,t.costCount=0,t.fileSizeSum=0)}}])}()),vd=new(function(){return _createClass(function _class124(){_classCallCheck(this,_class124),this._lastCycleStats=new Map,this._currentCycleStats=new Map},[{key:"init",value:function init(e){this._core=e;const{OuterEvent:t,notificationCenter:s}=e;this._initStatsMap(),s.subscribeOuterEvent(t.MESSAGE_RECEIVED,this._onMessageReceived,this)}},{key:"addMessageSequence",value:function addMessageSequence(e){const t=this._getReceivedMessageSpecifiedKey(e),{utils:{isUndefined:s},OuterConstant:{CONV_GROUP:n},ssoLog:o}=this._core;if(s(t)||!this._currentCycleStats.has(t))return void o.debug("addMessageSequence",`${Ql}.addMessageSequence invalid key:${t}`);const{conversationID:i,sequence:r}=e,a=i.replace(n,""),c=this._lastCycleStats.get(t);if(0===c.size||!c.has(a))return void this._addToCurrentCycle(t,a,r);const u=c.get(a);r>u.minSeq&&r<u.maxSeq?this._insertToLastCycle(r,u):this._addToCurrentCycle(t,a,r)}},{key:"getStatResult",value:function getStatResult(e){const t=this._lastCycleStats.get(e);if(!t||0===t.size)return this._transferCycleDataOptimized(e),null;let s=0,n=0;return t.forEach(e=>{const{sortedSequences:t,minSeq:o,maxSeq:i}=e;t.length>0&&(n+=t.length,s+=i-o+1)}),0===s?null:(this._transferCycleDataOptimized(e),{total_count:s,success_count_business:n,percent_business:Jl(n/s*100,2)})}},{key:"reset",value:function reset(){this._lastCycleStats.clear(),this._currentCycleStats.clear()}},{key:"dispose",value:function dispose(){const{notificationCenter:e,OuterEvent:{MESSAGE_RECEIVED:t}}=this._core;e.unSubscribeOuterEvent(t,this._onMessageReceived,this),this.reset()}},{key:"_initStatsMap",value:function _initStatsMap(){Object.values(hd).forEach(e=>{this._lastCycleStats.set(e,new Map),this._currentCycleStats.set(e,new Map)})}},{key:"_onMessageReceived",value:function _onMessageReceived(e){const{data:t=[]}=e;t.forEach(e=>{this.addMessageSequence(e)})}},{key:"_transferCycleDataOptimized",value:function _transferCycleDataOptimized(e){const t=this._currentCycleStats.get(e);if(!t)return;const s=new Map;t.forEach((e,t)=>{const n=e.dirty?[...e.sortedSequences].sort((e,t)=>e-t):e.sortedSequences;s.set(t,{sortedSequences:n,minSeq:e.minSeq,maxSeq:e.maxSeq,dirty:!1})}),this._lastCycleStats.set(e,s),this._currentCycleStats.set(e,new Map)}},{key:"_getReceivedMessageSpecifiedKey",value:function _getReceivedMessageSpecifiedKey(e){const{OuterConstant:{CONV_GROUP:t,GRP_AVCHATROOM:s}}=this._core;if(e.conversationType===t&&!0!==(null==e?void 0:e._onlineOnlyFlag)){const{groupStore:t}=this._core.appStore,n=t.getGroup(e.to);if(!n)return null;const{type:o}=n;return o===s?ud:ad}}},{key:"_insertToLastCycle",value:function _insertToLastCycle(e,t){t.dirty&&(t.sortedSequences.sort((e,t)=>e-t),t.dirty=!1);const s=this._findInsertPos(t.sortedSequences,e);t.sortedSequences.splice(s,0,e),t.minSeq=Math.min(t.minSeq,e),t.maxSeq=Math.max(t.maxSeq,e)}},{key:"_findInsertPos",value:function _findInsertPos(e,t){let s=0,n=e.length-1;for(;s<=n;){const o=Math.floor((s+n)/2);if(e[o]===t)return o;e[o]<t?s=o+1:n=o-1}return s}},{key:"_addToCurrentCycle",value:function _addToCurrentCycle(e,t,s){let n=this._currentCycleStats.get(e).get(t);n?(n.sortedSequences.push(s),n.minSeq=Math.min(n.minSeq,s),n.maxSeq=Math.max(n.maxSeq,s),n.dirty=!0):(n={sortedSequences:[s],minSeq:s,maxSeq:s,dirty:!1},this._currentCycleStats.get(e).set(t,n))}}])}()),fd=new(function(){return _createClass(function _class125(){_classCallCheck(this,_class125),this._totalDelay=0,this._totalCount=0,this._countLessThan1s=0,this._countLessThan3s=0},[{key:"init",value:function init(e){this._core=e;const{OuterEvent:{MESSAGE_RECEIVED:t},notificationCenter:s}=e;s.subscribeOuterEvent(t,this._onMessageReceived,this)}},{key:"addMessageDelay",value:function addMessageDelay(e){const{timeManager:t}=this._core.common,s=t.getServerTimeSeconds()-e;s>0&&(this._totalDelay+=s,this._totalCount++,s<=1?this._countLessThan1s++:s<=3&&this._countLessThan3s++)}},{key:"getStatResult",value:function getStatResult(){if(0===this._totalCount)return null;const e={total_count:this._totalCount,success_count_business:this._countLessThan1s,success_count_platform:this._countLessThan3s,percent_business:this._calculatePercentage(this._countLessThan1s,this._totalCount),percent_platform:this._calculatePercentage(this._countLessThan3s,this._totalCount),average_value:this._calculateAverageDelay(this._totalCount)};return this.reset(),e}},{key:"reset",value:function reset(){this._totalDelay=0,this._totalCount=0,this._countLessThan1s=0,this._countLessThan3s=0}},{key:"dispose",value:function dispose(){const{notificationCenter:e,OuterEvent:{MESSAGE_RECEIVED:t}}=this._core;e.unSubscribeOuterEvent(t,this._onMessageReceived,this),this.reset()}},{key:"_onMessageReceived",value:function _onMessageReceived(e){const{data:t=[]}=e,{OuterConstant:{MSG_GRP_TIP:s,MSG_GRP_SYS_NOTICE:n}}=this._core,o=[s,n];t.forEach(e=>{!o.includes(e.type)&&e.clientTime>0&&this.addMessageDelay(e.clientTime)})}},{key:"_calculateAverageDelay",value:function _calculateAverageDelay(e){return 0===e?0:Jl(this._totalDelay/e,1)}},{key:"_calculatePercentage",value:function _calculatePercentage(e,t){return Jl(e/t*100,2)}}])}()),Id=new(function(){return _createClass(function _class126(){_classCallCheck(this,_class126)},[{key:"init",value:function init(e){this.core=e}}])}()),Ed=new(function(){return _createClass(function _class127(){_classCallCheck(this,_class127),this.name="MessageQualityStat",this._reportIndex=0,this._wholePeriod=!1,this._pendingReports=[],this._failedLogsCache=new Map},[{key:"install",value:function install(e){this._core=e;const{helper:t,notificationCenter:s,InnerEvent:{QUALITY_STAT:n,LOGOUT:o,DESTROY:i},constants:{WORKFLOW_NAME:r,WORKFLOW_STEP:a}}=e;Id.init(e),md.init(e),vd.init(e),fd.init(e),t.registerWorkflowStep(r.SYNC_SERVER_INFO_AFTER_LOGIN,a.QUALITY_REPORT,this.handleLoginSuccess,this),s.subscribeInnerEvent(n,this._handleQualityStat,this),s.subscribeInnerEvent(o,this._reset,this),s.subscribeInnerEvent(i,this._dispose,this)}},{key:"handleLoginSuccess",value:function handleLoginSuccess(){const{store:e,helper:t,utils:{isUndefined:s}}=this._core,n=e.get("cloudConfig")||{},{q_rpt_interval:o}=n,i=s(o)?12e4:Number(o);t.taskScheduler.addTask({id:_d,intervalMs:i,callback:this.report,context:this})}},{key:"report",value:function report(){this._wholePeriod=!0;const e=[...gd.map(e=>{const t=this._buildQualityReportItem(e);return t?Object.assign(Object.assign({},t),{report_index:this._reportIndex,whole_period:this._wholePeriod}):null}).filter(Boolean),...this._pendingReports];this._pendingReports=[],this._needSkipReport()||this._uploadQualityReports(e)}},{key:"_handleQualityStat",value:function _handleQualityStat(e){const{constants:{QUALITY_METRICS:t}}=this._core,{label:s,data:n}=e;s===t.MESSAGE_SEND_SUCCESS_RATE&&md.dispatchSendStats(n)}},{key:"_needSkipReport",value:function _needSkipReport(){return this._isSDKAppIDInBlacklist()&&!this._isTinyIDInWhitelist()}},{key:"_isSDKAppIDInBlacklist",value:function _isSDKAppIDInBlacklist(){const{store:e,utils:t}=this._core,s=e.get("cloudConfig")||{},n=e.get("instance")||{},{sdkAppId:o}=n,{q_rpt_sdkappid_bl:i=[]}=s;if(!t.isEmpty(i))return i.split(",").map(e=>Number(e)).includes(o)}},{key:"_isTinyIDInWhitelist",value:function _isTinyIDInWhitelist(){const{store:e,utils:t}=this._core,s=e.get("cloudConfig")||{},n=e.get("login")||{},o=Number(n.tinyID),{q_rpt_tinyid_wl:i=[]}=s;if(!t.isEmpty(i))return i.split(",").includes(o)}},{key:"_buildQualityReportItem",value:function _buildQualityReportItem(e){const t=this._getStatResultByKey(e);if(null===t)return null;const s={quality_type:ld[e],timestamp:Date.now(),network_type:Zl.ONLINE,extension:""};return Object.assign(Object.assign({},s),t)}},{key:"_getStatResultByKey",value:function _getStatResultByKey(e){switch(e){case td:return fd.getStatResult();case sd:case nd:case od:case id:case rd:return md.getStatResult(e);case ad:case cd:case ud:return vd.getStatResult(e);default:return null}}},{key:"_uploadQualityReports",value:function _uploadQualityReports(e){return pe(this,void 0,void 0,function*(){try{const t={header:this._core.common.getCommonHead(),quality:e};yield function(e){const{common:t,channel:s}=Id.core,n="imopenstat.tim_web_report_v2",o=t.generateSSOLogProtocolData({servcmd:n,data:e}),i=`${o.head.seq}${n}`;return s.sendPacket(o,{requestId:i})}(t),this._reportIndex++,this._wholePeriod=!1}catch(t){console.warn("doReport failed. error:",t),this._pendingReports=this._pendingReports.concat(e),this._cacheFailedLogs()}})}},{key:"_cacheFailedLogs",value:function _cacheFailedLogs(){const e=this._pendingReports,t=`${Ql}._cacheFailedLogs`;let s=[...this._failedLogsCache.get(Xl)||[],...e];s.length>10&&(s=s.slice(s.length-10),console.log(`${t} logs overflow, keeping last 10 items`)),this._failedLogsCache.set(Xl,s),console.log(`${t} count: ${s.length}`),this._pendingReports=[]}},{key:"_reset",value:function _reset(){const{helper:e}=this._core;e.taskScheduler.removeTask(_d)}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e,InnerEvent:{QUALITY_STAT:t,LOGOUT:s,DESTROY:n}}=this._core;e.unSubscribeInnerEvent(t,this._handleQualityStat,this),e.unSubscribeInnerEvent(s,this._reset,this),e.unSubscribeInnerEvent(n,this._dispose,this),this._reset(),fd.dispose(),vd.dispose()}}])}());const Sd=new(function(){return _createClass(function _class128(){_classCallCheck(this,_class128)},[{key:"init",value:function init(e){this.core=e}}])}());function Cd(e){return pe(this,void 0,void 0,function*(){var t;const{message:s,user:n,appStore:o,constants:{OuterConstant:i}}=Sd.core,r=o.conversationStore.getConversationMap();if(r.has(e)){const s=null===(t=r.get(e))||void 0===t?void 0:t.userProfile;if(s&&e.startsWith(i.CONV_C2C)){const{avatar:t,nick:n}=s;Sd.core.message.messageDataHandler.updateNickAndAvatarOfSentMessage({conversationID:e,latestAvatar:t,latestNick:n,isSentByMe:!1})}}const{data:a}=(yield n.userProfile.getMyProfile())||{};if(a){const{avatar:t,nick:n}=a;s.messageDataHandler.updateNickAndAvatarOfSentMessage({conversationID:e,latestAvatar:t,latestNick:n,isSentByMe:!0})}})}const Ad=20;function bd(e){return pe(this,void 0,void 0,function*(){var t,s;const{appStore:n,utils:{isEmpty:o},common:{getCurrentUserID:i},notificationCenter:r,OuterEvent:a,OuterConstant:{CONV_C2C:c}}=Sd.core,{messageList:u,conversationID:l}=e,d=n.conversationStore.getConversationMap();let h=null===(t=d.get(l))||void 0===t?void 0:t.peerReadTime;if(!h){const e=l.replace(c,""),t=yield function(e){return pe(this,void 0,void 0,function*(){const t={To_Account:e};return Sd.core.common.buildAndSendPacket({servcmd:"openim.get_peer_read_time",data:t})})}([e]);if(t){const{ReadTime:e}=t;h=null==e?void 0:e[0],d.has(l)&&(d.get(l).peerReadTime=h)}}if(d.has(l)){const e=null===(s=d.get(l))||void 0===s?void 0:s.lastMessage;o(e)||e.fromAccount===i()&&e.lastTime<=h&&!e.isPeerRead&&(e.isPeerRead=!0,n.conversationStore.updateConversation(l,{lastMessage:e}))}const g=[];u.forEach(e=>{e.time<=h&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0,g.push(e))}),g.length>0&&r.emitOuterEvent(a.MESSAGE_READ_BY_PEER,{name:a.MESSAGE_READ_BY_PEER,data:g})})}var Nd=new(function(){return _createClass(function _class129(){_classCallCheck(this,_class129)},[{key:"init",value:function init(e){this._core=e,e.helper.registerApi({apiName:"getMessageList",context:this}),e.helper.registerApi({apiName:"getMessageListHopping",context:this}),e.helper.registerApi({apiName:"clearHistoryMessage",context:this})}},{key:"getMessageList",value:function getMessageList(e){return pe(this,void 0,void 0,function*(){try{const{message:t,OuterConstant:{Direction:s,CONV_C2C:n,CONV_GROUP:o},InnerEvent:{HISTORY_MESSAGE_FETCHED:i},notificationCenter:r}=this._core,{conversationID:a,nextReqMessageID:c}=e,u=Ad;if("@TIM#SYSTEM"===a)return{code:0,data:{messageList:[],isCompleted:!1,nextMessageSeq:""}};const l=this._getAvailableLocalMessagesCount({conversationID:a,nextReqMessageID:c});if(this._needFetchHistoryMessageList({conversationID:a,availableLocalMessagesCount:l,targetCount:u})){let e=null;if(a.startsWith(o)?e=yield t.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:a,sequence:Number(c),count:u,direction:s.FORWARD,shouldMarkCompleted:!0}):a.startsWith(n)&&(e=yield t.messageHistory.getC2CRoamingMessagesByAnchor({conversationID:a,messageID:c,count:u,direction:s.FORWARD,shouldMarkCompleted:!0})),e){const{nextReqMessageIDFromServer:s,hasNoMoreHistoryMessage:o,messageList:u}=e,d=t.messageDataHandler.prependLocalMessageList({messageList:u,conversationID:a});!function(e){const{appStore:t,message:s,OuterConstant:n}=Sd.core,o=t.conversationStore.getConversation(e),i=s.messageDataHandler.getLocalMessageList(e);if(!o||0===i.length||e===n.CONV_SYSTEM)return;const r=[];for(let e=0;e<i.length;e++)"in"!==i[e].flow?"out"!==i[e].flow||i[e].isRead||i[e].setIsRead(!0):r.push(i[e]);let a=0;if(o.type===n.CONV_C2C){const e=r.slice(-o.unreadCount).filter(e=>e.isRevoked).length;a=r.length-o.unreadCount-e}else a=r.length-o.unreadCount;for(let e=0;e<a&&!r[e].isRead;e++)r[e].setIsRead(!0)}(a),yield Cd(a),a.startsWith(n)&&(yield bd({messageList:u,conversationID:a}));const h=this._core.message.messageDataHandler.getLocalMessageList(a).slice(0,d.length+l),g=h.filter(e=>e.isRevoked);yield function Md(e){return pe(this,void 0,void 0,function*(){const t=e.map(e=>e.revoker);try{const s=yield function(e){return pe(this,void 0,void 0,function*(){var t,s;const n=yield null===(t=Sd.core.user.userProfile)||void 0===t?void 0:t.getUserProfile({userIDList:e});return(null==n?void 0:n.data)?null===(s=n.data)||void 0===s?void 0:s.reduce((e,{userID:t,nick:s,avatar:n})=>(e[t]={nick:s||"",avatar:n||""},e),{}):null})}(t);s&&e.forEach(e=>{const{revoker:t}=e;s[t]&&(e.revokerInfo.nick=s[t].nick||"",e.revokerInfo.avatar=s[t].avatar||"",e.revokerInfo.userID=t)})}catch(e){console.debug(e)}})}(g),r.emitInnerEvent(i,d);const p={nextReqMessageID:o?"":String(s),messageList:h,isCompleted:o},_=h.map(e=>e.sequence);return{code:0,data:p,successLog:{message:`conversationID: ${a} nextReqMessageID: ${c} availableLocalMessagesCount: ${l} sequenceList: ${JSON.stringify(_)}`}}}return{code:0,data:{messageList:[],isCompleted:!1,nextReqMessageID:""}}}return{code:0,data:yield this._getMessageListFromMemory({conversationID:a,nextReqMessageID:c,count:u}),successLog:{message:`conversationID: ${a} nextReqMessageID: ${c} availableLocalMessagesCount: ${l}}`}}}catch(t){const{code:s,message:n}=t||{};throw new this._core.helper.ChatError({code:s,message:n,moreMessage:`options: ${this._core.utils.safeStringify(e)}`})}})}},{key:"getMessageListHopping",value:function getMessageListHopping(e){return pe(this,void 0,void 0,function*(){var t,s;const{OuterConstant:{Direction:n,CONV_C2C:o,CONV_GROUP:i},utils:{safeStringify:r}}=this._core,{conversationID:a,sequence:c,time:u,direction:l=n.FORWARD}=e,{utils:{isEmpty:d},message:h,notificationCenter:g,InnerEvent:{HISTORY_MESSAGE_FETCHED:p}}=this._core;if(![n.BACKWARD,n.FORWARD].includes(l))throw new this._core.helper.ChatError({message:"direction must be 0 or 1",moreMessage:`options: ${r(e)}`});let{count:_=Ad}=e;_=_>Ad?Ad:_;let m=null;if(a.startsWith(i)){if(m=yield h.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:a,sequence:c,count:_,direction:l}),m){const{nextReqMessageIDFromServer:e,hasNoMoreHistoryMessage:o,messageList:i,invisibleSequenceList:r}=m;if(this._core.message.messageDataHandler.storeSparseMessageList(i),g.emitInnerEvent(p,i),l===n.FORWARD){const t=o&&e<1;return{code:0,data:{messageList:i,isCompleted:t,nextMessageSeq:t?"":e}}}if(l===n.BACKWARD){if(d(i)&&d(r))return{code:0,data:{messageList:[],isCompleted:!0,nextMessageSeq:""}};const e=(null===(t=null==i?void 0:i[i.length-1])||void 0===t?void 0:t.sequence)||0,n=(null===(s=null==r?void 0:r[r.length-1])||void 0===s?void 0:s.sequence)||0;return{code:0,data:{messageList:i.filter(e=>e.sequence>=c),isCompleted:!o,nextMessageSeq:o?Math.max(e,n)+1:""}}}return{code:0,data:m}}}else if(a.startsWith(o)&&(m=yield h.messageHistory.getC2CRoamingMessagesByAnchor({conversationID:a,count:_+1,time:u,direction:l}),m)){const{messageList:e,lastMessageTime:t,hasNoMoreHistoryMessage:s}=m;return g.emitInnerEvent(p,e),s||(l===n.FORWARD?e.shift():e.pop()),h.messageDataHandler.storeSparseMessageList(e),yield bd({messageList:e,conversationID:a}),{code:0,data:{messageList:e,isCompleted:s,nextMessageTime:s?"":t}}}})}},{key:"clearHistoryMessage",value:function clearHistoryMessage(e){return pe(this,void 0,void 0,function*(){var t;const{appStore:s,common:{ChatError:n,getCurrentUserID:o},OuterConstant:{CONV_C2C:i,CONV_GROUP:r},apiMap:a,message:c}=this._core,u=s.conversationStore.getConversation(e);if(!u)throw new n({code:2500});const l={fromAccount:o()},{type:d}=u;d===i?(l.type=1,l.toAccount=e.replace(i,"")):d===r&&(l.type=2,l.toGroupID=e.replace(r,""));try{yield null===(t=null==a?void 0:a.setMessageRead)||void 0===t?void 0:t.call(a,{conversationID:e});const s=yield function(e){return pe(this,void 0,void 0,function*(){const{fromAccount:t,type:s,toAccount:n,toGroupID:o}=e,i={From_Account:t,Type:s,To_Account:n,ToGroupid:o};return Sd.core.common.buildAndSendPacket({servcmd:"recentcontact.clear_msg",data:i})})}(l);return s&&(c.messageDataHandler.deleteConversationMessageList(e),c.messageHistory.completedHistoryConversations.delete(e),c.messageHistory.clearHistoryMessageListFetchAnchors(e),this._updateConversationLastMessage(e)),{code:0,data:{conversationID:e},successLog:{message:`convID:${e}`}}}catch(t){const{errorCode:s}=t;throw new this._core.helper.ChatError({functionName:"clearHistoryMessage",code:s,moreMessage:`convID:${e}`})}})}},{key:"_updateConversationLastMessage",value:function _updateConversationLastMessage(e){const{appStore:t}=this._core;t.conversationStore.updateConversation(e,{lastMessage:this._generateLastMessage()},{needSort:!0})}},{key:"_getAvailableLocalMessagesCount",value:function _getAvailableLocalMessagesCount({conversationID:e,nextReqMessageID:t}){const{OuterConstant:{CONV_C2C:s,CONV_GROUP:n}}=this._core,o=this._core.message.messageDataHandler.getLocalMessageList(e),{length:i}=o;if(!t)return i;let r=-1;return(null==e?void 0:e.startsWith(s))?r=o.findIndex(e=>e.ID===t):(null==e?void 0:e.startsWith(n))&&(r=o.findIndex(e=>t.includes("-")?e.ID===t:String(e.sequence)===t)),-1===r?0:r}},{key:"_needFetchHistoryMessageList",value:function _needFetchHistoryMessageList({conversationID:e,availableLocalMessagesCount:t,targetCount:s}){const{message:n}=this._core;return t<s&&!n.messageHistory.completedHistoryConversations.has(e)}},{key:"_getMessageListFromMemory",value:function _getMessageListFromMemory(e){return pe(this,arguments,void 0,function*({conversationID:e,nextReqMessageID:t,count:s}){const{OuterConstant:{CONV_C2C:n},message:o}=this._core,i=this._core.message.messageDataHandler.getLocalMessageList(e),r=i.length;let a=r,c={isCompleted:!1,nextReqMessageID:"",messageList:[]},u=0,l=r;return t?t&&(l=i.findIndex(s=>e.startsWith(n)?s.ID===t:String(s.sequence)===t),u=l>s?l-s:0,a=l):u=r>s?r-s:0,c.messageList=i.slice(u,l),c.isCompleted=a<=s&&o.messageHistory.completedHistoryConversations.has(e),c.isCompleted?c.nextReqMessageID="":c.nextReqMessageID=this._generateNextReqMessageID({conversationID:e,targetIndex:u}),e.startsWith(n)&&(yield Cd(e),yield bd({messageList:c.messageList,conversationID:e})),c})}},{key:"_generateNextReqMessageID",value:function _generateNextReqMessageID({conversationID:e,targetIndex:t}){const s=this._core.message.messageDataHandler.getLocalMessageList(e);return e.startsWith("C2C")?s[t].ID:String(s[t].sequence)}},{key:"_generateLastMessage",value:function _generateLastMessage(){return{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}}}])}()),Ld=new(function(){return _createClass(function _class130(){_classCallCheck(this,_class130),this._lastMessageSequenceMapOnDisconnect=new Map,this._lastMessageTimeMapOnDisconnect=new Map},[{key:"init",value:function init(e){this._core=e;const{common:{workflowManager:t},constants:{WORKFLOW_NAME:s,WORKFLOW_STEP:n,InnerEvent:o}}=e;t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.HISTORY_MESSAGE_RECOVER,this._syncGroupOfflineMessage,this),t.registerWorkflowStep(s.SYNC_SERVER_INFO_AFTER_RE_ONLINE,n.C2C_HISTORY_MESSAGE_RECOVER,this._syncC2COfflineMessage,this),e.notificationCenter.subscribeInnerEvent(o.SOCKET_DISCONNECTED,this._updateLastMessageSequenceMapOnDisconnect,this)}},{key:"_syncGroupOfflineMessage",value:function _syncGroupOfflineMessage(e){const{conversationList:t}=(null==e?void 0:e.result)||{},{OuterConstant:s,utils:{isArray:n}}=this._core;if(n(t)){const e=t.filter(e=>e.type===s.CONV_GROUP&&e.groupProfile.type!==s.GRP_AVCHATROOM);return this._recoverGroupHistoryMessage(e)}}},{key:"_recoverGroupHistoryMessage",value:function _recoverGroupHistoryMessage(e){return pe(this,void 0,void 0,function*(){const{OuterConstant:t}=this._core,s=[],n=[];return yield Promise.all(null==e?void 0:e.map(e=>pe(this,void 0,void 0,function*(){const{groupProfile:{groupID:o}={},lastMessage:{lastSequence:i}={}}=e,r=`${t.CONV_GROUP}${o}`;let a=this._getLocalLastMessageSequence(r);this._shouldRecoverHistory({localLastMessageSequence:a,serverLastMessageSequence:i})&&(yield this._recoverGroupHistoryForConversation({conversationID:r,localLastMessageSequence:a,serverLastMessageSequence:i,groupTipList:n})),s.push(r.replace(t.CONV_GROUP,""))}))),{recoverRevokeNoticeGroupIDList:s,groupTipList:n}})}},{key:"_recoverGroupHistoryForConversation",value:function _recoverGroupHistoryForConversation(e){return pe(this,arguments,void 0,function*({conversationID:e,localLastMessageSequence:t,serverLastMessageSequence:s,groupTipList:n}){try{const{utils:{isArray:o,isObject:i,isEmpty:r},OuterEvent:a,OuterConstant:c,notificationCenter:u,message:l,appStore:d,common:{getMessagePreviewText:h,buildLastMessage:g}}=this._core,p=s-t,_=Math.min(20,p),m={},v=yield l.messageHistory.getGroupRoamingMessagesByAnchor({conversationID:e,sequence:t+_,direction:c.Direction.FORWARD,count:_}),{nextReqMessageIDFromServer:f,hasNoMoreHistoryMessage:I,messageList:E,serverGroupTipList:S}=v;o(S)&&n.push(...S);const C=I&&f<0,M=[];if(o(E)&&(E.forEach(e=>{l.messageReceiver.groupMessageReceiver.updateMessageProfile(e),e.from===c.CONV_SYSTEM&&(e.isSystemMessage=!1),l.messageDataHandler.storeConversationMessage(e)&&!r(e.payload)&&(M.push(e),e._isExcludedFromLastMessage||(m.lastMessage=g(e)))}),M.length>0&&u.emitOuterEvent(a.MESSAGE_RECEIVED,{name:a.MESSAGE_RECEIVED,data:M})),!C&&E.length>0){const t=E[E.length-1].sequence;yield this._recoverGroupHistoryForConversation({conversationID:e,localLastMessageSequence:t,serverLastMessageSequence:s,groupTipList:n})}i(m.lastMessage)&&(m.lastMessage.messageForShow=h(m.lastMessage.type,m.lastMessage.payload),d.conversationStore.updateConversation(e,m))}catch(t){this._core.ssoLog.error("_recoverGroupHistoryForConversation",`Recovery failed for conversation:${e}`,{error:t})}})}},{key:"_updateLastMessageSequenceMapOnDisconnect",value:function _updateLastMessageSequenceMapOnDisconnect(){const{message:e}=this._core,t=e.messageDataHandler.getContinuousMessagesByConversation();for(const[e,s]of t){const t=Array.from(s.values());if((null==t?void 0:t.length)>0){const s=t[t.length-1];e.startsWith("C2C")?this._lastMessageTimeMapOnDisconnect.set(e,s.time):e.startsWith("GROUP")&&this._lastMessageSequenceMapOnDisconnect.set(e,s.sequence)}}}},{key:"_getLocalLastMessageSequence",value:function _getLocalLastMessageSequence(e){const{message:t}=this._core;if(this._lastMessageSequenceMapOnDisconnect.has(e))return this._lastMessageSequenceMapOnDisconnect.get(e);const s=t.messageDataHandler.getLocalMessageList(e),n=s[s.length-1];return null==n?void 0:n.sequence}},{key:"_shouldRecoverHistory",value:function _shouldRecoverHistory(e){const{localLastMessageSequence:t,serverLastMessageSequence:s}=e;if("number"!=typeof t||"number"!=typeof s)return!1;const n=s-t;return 0!==s&&t>0&&n>=1&&n<300}},{key:"_syncC2COfflineMessage",value:function _syncC2COfflineMessage(e){const{conversationList:t}=(null==e?void 0:e.result)||{},{OuterConstant:s,utils:{isArray:n}}=this._core;if(n(t)){const e=[];return t.forEach(t=>{t.type===s.CONV_C2C&&e.push(t)}),this._recoverC2CHistoryMessage(e)}}},{key:"_recoverC2CHistoryMessage",value:function _recoverC2CHistoryMessage(e){return pe(this,void 0,void 0,function*(){yield Promise.all(null==e?void 0:e.map(e=>pe(this,void 0,void 0,function*(){const{conversationID:t,lastMessage:{lastTime:s}={}}=e,n=this._getLocalLastMessageTime(t);this._shouldRecoverC2CHistory({localLastMessageTime:n,serverLastMessageTime:s})&&(yield this._recoverHistoryForC2CConversation({conversationID:t,localLastMessageTime:n,serverLastMessageTime:s}))})))})}},{key:"_shouldRecoverC2CHistory",value:function _shouldRecoverC2CHistory(e){const{localLastMessageTime:t,serverLastMessageTime:s}=e,n=s-t;return t>0&&n>=1&&n<=600}},{key:"_recoverHistoryForC2CConversation",value:function _recoverHistoryForC2CConversation(e){return pe(this,void 0,void 0,function*(){var t;const{conversationID:s,localLastMessageTime:n,serverLastMessageTime:o}=e,{utils:{isArray:i,isObject:r,isEmpty:a,safeStringify:c},OuterEvent:u,OuterConstant:l,notificationCenter:d,message:h,appStore:g,common:{getMessagePreviewText:p,buildLastMessage:_}}=this._core;try{const e={},c=yield h.messageHistory.getC2CRoamingMessagesByAnchor({conversationID:s,direction:l.Direction.BACKWARD,time:n,count:20});if(a(c))return;const{hasNoMoreHistoryMessage:m,messageList:v}=c,f=[];i(v)&&(v.forEach(t=>{h.messageDataHandler.storeConversationMessage(t)&&!a(t.payload)&&(f.push(t),t._isExcludedFromLastMessage||(e.lastMessage=_(t)))}),f.length>0&&d.emitOuterEvent(u.MESSAGE_RECEIVED,{name:u.MESSAGE_RECEIVED,data:f}));const I=null===(t=v[v.length-1])||void 0===t?void 0:t.time;!m&&I>o&&(yield this._recoverHistoryForC2CConversation({conversationID:s,localLastMessageTime:I,serverLastMessageTime:o})),r(e.lastMessage)&&(e.lastMessage.messageForShow=p(e.lastMessage.type,e.lastMessage.payload),g.conversationStore.updateConversation(s,e))}catch(e){this._core.ssoLog.error("_recoverHistoryForC2CConversation",`Recovery failed for conversation:${s} error: ${c(e)}`)}})}},{key:"_getLocalLastMessageTime",value:function _getLocalLastMessageTime(e){const{message:t}=this._core;if(this._lastMessageTimeMapOnDisconnect.has(e))return this._lastMessageTimeMapOnDisconnect.get(e);const s=t.messageDataHandler.getLocalMessageList(e),n=s[s.length-1];return null==n?void 0:n.time}},{key:"reset",value:function reset(){this._lastMessageSequenceMapOnDisconnect.clear(),this._lastMessageTimeMapOnDisconnect.clear()}},{key:"dispose",value:function dispose(){this.reset()}}])}()),Pd=new(function(){return _createClass(function _class131(){_classCallCheck(this,_class131),this.name="HistoryMessage"},[{key:"install",value:function install(e){this._core=e,Sd.init(e),Nd.init(e),Ld.init(e),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.LOGOUT,this._reset,this),e.notificationCenter.subscribeInnerEvent(e.InnerEvent.DESTROY,this.dispose,this)}},{key:"dispose",value:function dispose(){const{notificationCenter:e,InnerEvent:t}=this._core;e.unSubscribeInnerEvent(t.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(t.DESTROY,this.dispose,this),Ld.dispose()}},{key:"_reset",value:function _reset(){Ld.reset()}}])}()),Gd=new(function(){return _createClass(function _class132(){_classCallCheck(this,_class132)},[{key:"init",value:function init(e){this.core=e}}])}()),wd=new(function(){return _createClass(function _class133(){_classCallCheck(this,_class133),this._reportedAtomicStoreIDs=new Set},[{key:"init",value:function init(e){const{helper:{registerExperimentalAPI:t}}=e;this._core=e,t("reportModalView",this),t("reportTUIFeatureUsage",this),t("reportRoomEngineEvent",this)}},{key:"reportModalView",value:function reportModalView(e){const{ssoLog:t,utils:{safeStringify:s,isString:n}}=this._core;try{if(!n(e))throw new Error("reportModalView data is not a string");t.createSSOLogData({method:"reportModalView",message:e,eventType:30}).end(!0)}catch(e){t.debug(`reportModalView Report failed: ${s(e)}`)}}},{key:"reportTUIFeatureUsage",value:function reportTUIFeatureUsage(e){const{ssoLog:t,utils:{safeStringify:s,isEmpty:n}}=this._core,{atomicStoreID:o}=e;try{n(o)||this._reportedAtomicStoreIDs.has(o)||(this._core.ssoLog.info("reportTUIFeatureUsage",`atomicStoreID: ${e.atomicStoreID}`,{method:"reportTUIFeatureUsage",eventType:31,code:o}),this._reportedAtomicStoreIDs.add(o))}catch(e){t.debug(`reportTUIFeatureUsage Report failed: ${s(e)}`)}}},{key:"reportRoomEngineEvent",value:function reportRoomEngineEvent(e){const{utils:{safeStringify:t},ssoLog:s}=this._core;try{s.debug(`reportRoomEngineEvent Report: ${t(e)}`);const{eventId:n,eventCode:o,eventResult:i,eventMessage:r,moreMessage:a,extensionMessage:c}=e;s.createSSOLogData({method:c,code:n,message:r,eventType:30,costTime:o,uiPlatform:i,moreMessage:a}).end(!0)}catch(e){s.debug(`reportRoomEngineEvent Report failed: ${t(e)}`)}}},{key:"reset",value:function reset(){this._reportedAtomicStoreIDs.clear()}},{key:"dispose",value:function dispose(){this.reset()}}])}()),Ud=new(function(){return _createClass(function _class134(){_classCallCheck(this,_class134),this.name="DataReport"},[{key:"install",value:function install(e){this._core=e;const{notificationCenter:t,InnerEvent:{LOGOUT:s,DESTROY:n}}=e;Gd.init(e),wd.init(e),t.subscribeInnerEvent(s,this._reset,this),t.subscribeInnerEvent(n,this._dispose,this)}},{key:"_reset",value:function _reset(){wd.reset()}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e,InnerEvent:{LOGOUT:t,DESTROY:s}}=this._core;e.unSubscribeInnerEvent(t,this._reset,this),e.unSubscribeInnerEvent(s,this._dispose,this),wd.dispose()}}])}());let kd=Cs.STANDARD,Fd=[];function $d(e,t){const{operationType:s,memberInfoList:n,operatorInfo:o}=e||{};let i={};if(Ee(n)?Ee(o)||(i=o):s!==vs.JOINED&&s!==vs.KICKED&&s!==vs.ADMIN_SET&&s!==vs.ADMIN_CANCELED||(i=Object.assign({},n[0])),!Ee(i)){const{nick:e="",avatar:s=""}=i;t.nick=e,t.avatar=s}}kd=Cs.STANDARD,Fd=[kn,Un,qn,Jn,Zn,Ed,Pd,Ud,Pi,Qr,Na,Qu,bl,zl,Ro];const xd=e=>({lastTime:(null==e?void 0:e.time)||(null==e?void 0:e.lastTime)||0,lastSequence:(null==e?void 0:e.sequence)||(null==e?void 0:e.lastSequence)||0,fromAccount:(null==e?void 0:e.from)||(null==e?void 0:e.fromAccount)||"",messageForShow:Sn(null==e?void 0:e.type,null==e?void 0:e.payload),payload:(null==e?void 0:e.payload)||null,type:(null==e?void 0:e.type)||"",isRevoked:(null==e?void 0:e.isRevoked)||!1,cloudCustomData:(null==e?void 0:e.cloudCustomData)||"",onlineOnlyFlag:(null==e?void 0:e._onlineOnlyFlag)||!1,nick:(null==e?void 0:e.nick)||"",nameCard:(null==e?void 0:e.nameCard)||"",version:(null==e?void 0:e.version)||0,isPeerRead:(null==e?void 0:e.isPeerRead)||!1,revoker:(null==e?void 0:e.revoker)||null});var qd=Object.freeze({__proto__:null,ChatError:Ws,WorkflowManager:on,buildAndSendPacket:dn,buildLastMessage:xd,get builtInPlugins(){return Fd},checkBusinessCapabilityBits:nn,deepMerge:vn,getCurrentUserID:_n,getErrorMessage:Ks,getMessagePreviewText:Sn,isC2CConv:e=>t(e)&&e.slice(0,3)===hs.CONV_C2C,isCommunity:an,isGroupConv:e=>t(e)&&e.slice(0,5)===hs.CONV_GROUP,isInternational:Hs,isTopic:cn,isUnlimitedAVChatRoom:function(){var e;return!!(null===(e=Yt.store.get("instance"))||void 0===e?void 0:e.unlimitedAVChatRoom)},liteChatInstanceMap:rn,registerInterceptor:tn,registerValidateConfig:sn,requireAuth:Ys,get sdkEdition(){return kd},setGroupTipsUserInfo:$d,t:In,updateGroupAtInfo:(e,t)=>{const{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:o}=Es;if(function(e,t){const{CONV_AT_ME:s,CONV_AT_ALL:n,CONV_AT_ALL_AT_ME:o}=Es,{groupID:i,sequence:r}=e;let a=!1;return an({groupID:i})?(t.forEach(t=>{t.messageSequence===r&&(t.atTypeArray.includes(s)&&e.groupAtType.includes(n)&&(t.atTypeArray=[o]),t.atTypeArray.includes(n)&&e.groupAtType.includes(s)&&(t.atTypeArray=[o],t.__random=e.__random,t.__sequence=e.__sequence),a=!0)}),a):a}(e,t))return;let i=[...e.groupAtType];i.includes(s)&&i.includes(n)&&(i=[o]);const r={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:i,__random:e.__random,__sequence:e.__sequence};t.push(r)},validateAndExecute:en,validateParameters:zs});let Vd=function(){function Vd(){_classCallCheck(this,Vd),this._builtInPlugins=new Set,this._externalPlugins=new Set}return _createClass(Vd,[{key:"installBuiltInPlugin",value:function installBuiltInPlugin(e){e&&this._installPlugin(e,this._builtInPlugins)}},{key:"installExternalPlugin",value:function installExternalPlugin(e){e&&this._installPlugin(e,this._externalPlugins)}},{key:"clear",value:function clear(){this._builtInPlugins=new Set,this._externalPlugins=new Set}},{key:"_installPlugin",value:function _installPlugin(e,t){let s=[];s=n(e)?e:[e];const o=s.findIndex(e=>"AVChatRoom"===(null==e?void 0:e.name)),i=o>-1?s.splice(o,1):[];s.forEach(e=>{this._isPluginInstalled(e.name)||(e&&zt(e.install)?(t.add(e.name),zt(e.getInstalledSubPlugins)?(null==i||i.forEach(e=>t.add(null==e?void 0:e.name)),e.install(zd.getInstance().exposeApiForPlugin(),i)):e.install(zd.getInstance().exposeApiForPlugin()),zt(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):zt(e)?(t.add(e.name),e(zd.getInstance().exposeApiForPlugin()),zt(e.handleLoginSuccess)&&this._isLoggedIn()&&e.handleLoginSuccess()):console.warn('A plugin must either be a function or an object with an "install" function.'))})}},{key:"_isPluginInstalled",value:function _isPluginInstalled(e){return this._builtInPlugins.has(e)||this._externalPlugins.has(e)}},{key:"_isLoggedIn",value:function _isLoggedIn(){var e;return!0===(null===(e=Yt.store.get("login"))||void 0===e?void 0:e.isLoggedIn)}}],[{key:"getInstance",value:function getInstance(){return Vd._instance||(Vd._instance=new Vd),Vd._instance}},{key:"setInstance",value:function setInstance(e){Vd._instance=e}}])}();var Bd=new(function(){return _createClass(function _class135(){_classCallCheck(this,_class135),this._conversationMap=new Map},[{key:"getConversationMap",value:function getConversationMap(){return this._conversationMap}},{key:"getConversation",value:function getConversation(e){return this._conversationMap.get(e)}},{key:"updateConversation",value:function updateConversation(e,t,s){const{emit:n=!0,needSort:o=!1}=s||{},i=this._conversationMap.get(e);i&&!Ee(t)&&(Object.keys(t).forEach(e=>{i[e]=t[e]}),n&&Yt.notificationCenter.emitInnerEvent(ts.CONVERSATION_UPDATED,{needSort:o}))}},{key:"deleteConversation",value:function deleteConversation(e){this._conversationMap.has(e)&&(this._conversationMap.delete(e),Yt.notificationCenter.emitInnerEvent(ts.CONVERSATION_UPDATED))}}])}()),Hd=new(function(){return _createClass(function _class136(){_classCallCheck(this,_class136),this._groupMap=new Map},[{key:"getGroupMap",value:function getGroupMap(){return this._groupMap}},{key:"getGroup",value:function getGroup(e){return this._groupMap.get(e)}},{key:"updateGroup",value:function updateGroup(e,t){const s=this._groupMap.get(e);s&&!Ee(t)&&Object.keys(t).forEach(e=>{s[e]=t[e]})}}])}()),Kd=new(function(){return _createClass(function _class137(){_classCallCheck(this,_class137),this._messagesByConversation=new Map},[{key:"updateMessage",value:function updateMessage(e,t,s){var n;const{operation:o,updateUnreadCount:i=!0}=s,r=ge(s,["operation","updateUnreadCount"]),a=[];for(const s of t){const t=null===(n=this._messagesByConversation.get(e))||void 0===n?void 0:n.get(s);if(!t)return!1;Object.keys(r).forEach(e=>{t[e]=r[e]}),a.push(t)}return this._emitMessageStoreOperationEvent(o,{conversationID:e,messageList:a,updateUnreadCount:i}),a}},{key:"getMessagesByConversation",value:function getMessagesByConversation(e){var t;return[...(null===(t=this._messagesByConversation.get(e))||void 0===t?void 0:t.values())||[]]}},{key:"getMessages",value:function getMessages(){return this._messagesByConversation}},{key:"_emitMessageStoreOperationEvent",value:function _emitMessageStoreOperationEvent(e,t){const{conversationID:s}=t;cn(s)?Yt.notificationCenter.emitInnerEvent(us[e],t):Yt.notificationCenter.emitInnerEvent(e,t)}}])}()),Wd=new(function(){return _createClass(function _class138(){_classCallCheck(this,_class138),this.userProfileMap=new Map,this.friendMap=new Map},[{key:"getUserProfileMap",value:function getUserProfileMap(){return this.userProfileMap}},{key:"getFriendMap",value:function getFriendMap(){return this.friendMap}},{key:"getUserProfile",value:function getUserProfile(e){return this.userProfileMap.get(e)}},{key:"getFriend",value:function getFriend(e){return this.friendMap.get(e)}}])}()),Yd=Object.freeze({__proto__:null,conversationStore:Bd,groupStore:Hd,messageStore:Kd,userStore:Wd});let zd=function(){function zd(){_classCallCheck(this,zd),this._experimentalApiMap={statTUIKeyFeatures:this.statKeyFeatureUsage.bind(this),setApplicationID:this.setApplicationID.bind(this)},this._apiHandlersMap={},this._apiMap={on:Yt.notificationCenter.subscribeOuterEvent.bind(Yt.notificationCenter),off:Yt.notificationCenter.unSubscribeOuterEvent.bind(Yt.notificationCenter),destroy:this.destroy.bind(this),callExperimentalAPI:this.callExperimentalAPI.bind(this),use:Vd.getInstance().installExternalPlugin.bind(Vd.getInstance()),registerPlugin:this.registerPlugin.bind(this),setLogLevel:this.setLogLevel.bind(this)}}return _createClass(zd,[{key:"registerPlugin",value:function registerPlugin(e){Yt.ssoLog.debug("registerPlugin",e)}},{key:"statKeyFeatureUsage",value:function statKeyFeatureUsage(e){Yt.ssoLog.debug("statTUIKeyFeatures",e)}},{key:"setLogLevel",value:function setLogLevel(e){Yt.ssoLog.debug("setLogLevel",e),Yt.ssoLog.setLogLevel(e)}},{key:"setApplicationID",value:function setApplicationID(e){Yt.store.set("instance",{applicationID:e})}},{key:"getApiMap",value:function getApiMap(){return this._apiMap}},{key:"setApiMap",value:function setApiMap(e){this._apiMap=e}},{key:"registerApi",value:function registerApi(e){const{common:{timeManager:t},utils:{safeStringify:s}}=Yt,{apiName:n,context:o,methodName:i=n,matcher:r}=e;this._apiHandlersMap[n]||(this._apiHandlersMap[n]=[]),this._apiHandlersMap[n].push({context:o,methodName:i,matcher:r}),this._apiMap[n]&&1!==this._apiHandlersMap[n].length||(this._apiMap[n]=(...e)=>{const o=t.getServerTimeMs();let r=0;"login"===n&&(r=4),Rs.includes(n)&&Yt.ssoLog.debug(n,`${n} start params: ${s(e)}`),en(i,e);const a=this._apiHandlersMap[n];for(const s of a)if(!s.matcher||s.matcher(e))try{const t=s.context[s.methodName].bind(s.context)(...e);return this._isPromiseLike(t)?this._handleAsyncResult(t,n,r,o):(this._reportApiSuccessLog({result:t,apiName:n,eventType:r,startTime:o}),t)}catch(e){throw Yt.ssoLog.error(n,`${n} fail ${(null==e?void 0:e.message)||(null==e?void 0:e.errorMessage)})`,{error:e,costTime:t.getServerTimeMs()-o,eventType:r,method:n}),e}})}},{key:"registerExperimentalAPI",value:function registerExperimentalAPI(e,t,s){const n=s||e;this._experimentalApiMap[e]=t[n].bind(t)}},{key:"destroy",value:function destroy(){return pe(this,void 0,void 0,function*(){var e,t;try{(null===(e=Yt.store.get("login"))||void 0===e?void 0:e.isLogin)&&(yield this._apiMap.logout()),Yt.notificationCenter.emitInnerEvent(ts.DESTROY)}catch(e){console.debug("destroy error: ",e)}finally{Yt.notificationCenter.emitOuterEvent(Zt.SDK_DESTROY,{SDKAppID:null===(t=Yt.store.get("instance"))||void 0===t?void 0:t.sdkAppId}),rn.clear(),Vd.getInstance().clear(),on.getInstance().destroy(),Yt.destroy()}})}},{key:"exposeApiForClient",value:function exposeApiForClient(){return this._apiMap}},{key:"exposeApiForPlugin",value:function exposeApiForPlugin(){return Object.assign(Object.assign({InnerEvent:ts,InnerEventSubType:Yt.notificationCenter.InnerEventSubType,OuterEvent:Zt,OuterConstant:Es,SignalingEvent:ss,helper:Object.assign(Object.assign(Object.assign({},Yt.utils),Yt.common),{registerApi:this.registerApi.bind(this),registerExperimentalAPI:this.registerExperimentalAPI.bind(this),registerInterceptor:tn,registerValidateConfig:sn,checkBusinessCapabilityBits:nn,registerWorkflowStep:on.getInstance().registerWorkflowStep.bind(on.getInstance()),ChatError:Ws}),apiMap:this._apiMap},Yt),{constants:Object.assign(Object.assign({},Ds),Yt.constants),common:Object.assign(Object.assign(Object.assign({},qd),Yt.common),{workflowManager:on.getInstance()}),utils:Yt.utils,appStore:Yd})}},{key:"callExperimentalAPI",value:function callExperimentalAPI(e,t){return Yt.ssoLog.debug(`callExperimentalAPI.${e} start params: ${Yt.utils.safeStringify(t)}`),this._experimentalApiMap[e]?this._experimentalApiMap[e](t):(Yt.ssoLog.error("callExperimentalAPI",`callExperimentalAPI.${e} not found, params: ${Yt.utils.safeStringify(t)}`),Promise.reject(new Ws({code:Ss.INVALID_OPERATION})))}},{key:"_isPromiseLike",value:function _isPromiseLike(e){return null!==e&&"object"==typeof e&&"function"==typeof e.then}},{key:"_handleAsyncResult",value:function _handleAsyncResult(e,t,s,n){return e.then(e=>(this._reportApiSuccessLog({result:e,apiName:t,eventType:s,startTime:n}),e)).catch(e=>{throw Yt.ssoLog.error(t,`${t} fail ${(null==e?void 0:e.message)||(null==e?void 0:e.errorMessage)})`,{error:e,costTime:Yt.common.timeManager.getServerTimeMs()-n,eventType:s,method:t,startTime:n}),e})}},{key:"_reportApiSuccessLog",value:function _reportApiSuccessLog(e){let{result:t,apiName:s,startTime:n,eventType:o}=e;const{timeManager:i}=Yt.common,{successLog:{message:r,moreMessage:a}={message:"",moreMessage:""}}=t||{},c=i.getServerTimeMs();"login"===s&&(n+=i.getTimeOffsetWithServer()),Rs.includes(s)&&Yt.ssoLog.info(s,`${s} success ${r} ${a}`,{costTime:c-n,eventType:o,message:r,moreMessage:a,startTime:n}),(null==t?void 0:t.successLog)&&delete t.successLog}}],[{key:"getInstance",value:function getInstance(){return zd._instance||(zd._instance=new zd),zd._instance}},{key:"setInstance",value:function setInstance(e){zd._instance=e}}])}(),Jd=function(){return _createClass(function Jd(){_classCallCheck(this,Jd),this._latestLoginAt=0,this._latestSendOnlinePresenceRequestTime=0,this._helloInterval=120,this._customLoginInfo=""},[{key:"init",value:function init(){const{notificationCenter:e,store:t}=Yt;t.set("login",{isReady:!1}),zd.getInstance().registerApi({apiName:"login",context:this}),zd.getInstance().registerApi({apiName:"logout",context:this}),zd.getInstance().registerApi({apiName:"getLoginUser",context:this}),zd.getInstance().registerApi({apiName:"isReady",context:this}),zd.getInstance().registerApi({apiName:"getServerTime",context:this}),zd.getInstance().registerExperimentalAPI("setCustomLoginInfo",this),e.subscribeInnerEvent(ts.RECONNECTED,this._reLogin,this),Yt.notificationCenter.subscribeInnerEvent(ts.DESTROY,this._dispose,this)}},{key:"login",value:function login(e){return pe(this,void 0,void 0,function*(){var t;const{sdkEdition:s}=Yt.store.get("instance")||{};try{if(this._isLoginIn())return this._createRepeatLoginResponse();if(this._isLoginFrequencyExceeded())throw new Ws({functionName:"login",code:Ss.REPEAT_LOGIN});const n=yield this._performLogin(e);this._validateAfterLogin(n),this._handleLoginSuccess(n),yield this._ensureAsyncComplete(),this._updateAndEmitSDKReady(),this._latestLoginAt=0;const o=null===(t=Yt.channel.getSocketAdapter())||void 0===t?void 0:t.getId(),{appId:i,href:r}=Yt.store.get("instance")||{},{instanceID:a,customStatus:c}=n||{};return{code:0,data:n,successLog:{message:s,moreMessage:`socketID:${o} instanceID:${a} customStatus:${c} href: ${r} appId: ${i}`}}}catch(e){const{errorCode:t}=e;t!==Ss.REPEAT_LOGIN&&(this._latestLoginAt=0);const s=new Ws({functionName:"login",code:t});throw console.error(s),s}})}},{key:"_reLogin",value:function _reLogin(){return pe(this,void 0,void 0,function*(){var e;try{if(!this._isLoginIn())return;const t=yield js(this._customLoginInfo);if(t){const{instanceID:s,customStatus:n}=t;Yt.store.set("login",{statusInstanceId:s}),on.getInstance().executeWorkflow(Ms.SYNC_SERVER_INFO_AFTER_RE_ONLINE,{customStatus:n,statusType:ls.USER_STATUS_ONLINE});const o=null===(e=Yt.channel.getSocketAdapter())||void 0===e?void 0:e.getId();Yt.ssoLog.info("reLogin",`socketId:${o} instanceId:${s}`)}}catch(e){console.warn(e)}})}},{key:"logout",value:function logout(){return pe(this,arguments,void 0,function*(e=bs.USER_INITIATED){const{ssoLog:t}=Yt;t.debug("logout",`logout start logoutReason: ${e}`);try{yield this._performLogout(e),t.info("logout","logout success"),Yt.ssoLog.uploadSSOLogData()}catch(e){const{errorCode:t}=e;throw new Ws({functionName:"logout",code:t})}finally{this.handleLogoutCompleted()}return{code:0,data:{}}})}},{key:"getLoginUser",value:function getLoginUser(){return this._isLoginIn()?_n():""}},{key:"isReady",value:function isReady(){var e;return null===(e=Yt.store.get("login"))||void 0===e?void 0:e.isReady}},{key:"setCustomLoginInfo",value:function setCustomLoginInfo(e=""){this._customLoginInfo=e}},{key:"handleLogoutCompleted",value:function handleLogoutCompleted(){this._updateAndEmitSDKNotReady(),this._reset(),on.getInstance().reset(),Yt.notificationCenter.emitInnerEvent("logout")}},{key:"getServerTime",value:function getServerTime(){const{timeManager:e}=Yt.common;return e.getServerTimeMs()}},{key:"_updateAndEmitSDKReady",value:function _updateAndEmitSDKReady(){Yt.store.set("login",{isReady:!0}),setTimeout(()=>{Yt.notificationCenter.emitOuterEvent(Zt.SDK_READY,{name:Zt.SDK_READY})},1)}},{key:"_updateAndEmitSDKNotReady",value:function _updateAndEmitSDKNotReady(){Yt.store.set("login",{isReady:!1}),Yt.notificationCenter.emitOuterEvent(Zt.SDK_NOT_READY,{name:Zt.SDK_NOT_READY})}},{key:"_validateAfterLogin",value:function _validateAfterLogin(e){const t="login";if(!e)throw new Ws({functionName:t,message:"login response is empty"});const{tinyID:s,a2Key:n}=e||{};if(!s)throw new Ws({functionName:t,code:Ss.NO_TINYID});if(!n)throw new Ws({functionName:t,code:Ss.NO_A2KEY})}},{key:"_createRepeatLoginResponse",value:function _createRepeatLoginResponse(){var e;return{code:0,data:{actionStatus:"OK",errorCode:0,errorInfo:Ks({code:"RepeatLogin",replacement1:null===(e=Yt.store.get("login"))||void 0===e?void 0:e.userId}),repeatLogin:!0}}}},{key:"_performLogin",value:function _performLogin(e){return pe(this,void 0,void 0,function*(){const{userID:t,userSig:s}=e;return Yt.store.set("login",{userId:t,userSig:s}),this._latestLoginAt=Date.now(),js(this._customLoginInfo)})}},{key:"_ensureAsyncComplete",value:function _ensureAsyncComplete(){return pe(this,void 0,void 0,function*(){yield new Promise(e=>{setTimeout(()=>e(null),1)})})}},{key:"_handleLoginSuccess",value:function _handleLoginSuccess(e){const{timeManager:t}=Yt.common,{helloInterval:s,timeStamp:n,customStatus:o,purchaseBits:i}=e,r=1e3*n;t.calculateTimeOffsetWithServer(this._latestLoginAt,r),this._helloInterval=s||120,this._updateLoginStore(e),Yt.user.userStatus.setCustomStatus(o),on.getInstance().executeWorkflow(Ms.SYNC_SERVER_INFO_AFTER_LOGIN,{purchaseBits:i}),Yt.common.taskScheduler.addTask({id:Gs,intervalMs:1e3*this._helloInterval,callback:this._sendOnlinePresenceRequest,context:this})}},{key:"_performLogout",value:function _performLogout(e){return function(e){return pe(this,void 0,void 0,function*(){const{logoutReason:t}=e,s="im_open_status.wslogout",n=Yt.common.generateProtocolData({servcmd:s,data:{wslogout_type:t,isWebUniapp:0}}),o=`${n.head.seq}${s}`;return yield Yt.channel.sendPacket(n,{requestId:o})})}({logoutReason:e})}},{key:"_updateLoginStore",value:function _updateLoginStore(e){const{a2Key:t,tinyID:s,instanceID:n,authKey:o}=e;Yt.store.set("login",{a2Key:t,tinyID:s,statusInstanceId:n,authKey:o,isLoggedIn:!0})}},{key:"_sendOnlinePresenceRequest",value:function _sendOnlinePresenceRequest(){return pe(this,void 0,void 0,function*(){this._latestSendOnlinePresenceRequestTime=Date.now();try{yield function(){const e="im_open_status.wshello",t=Yt.common.generateProtocolData({servcmd:e,data:{isWebUniapp:0}}),s=`${t.head.seq}${e}`;return Yt.channel.sendPacket(t,{requestId:s})}()}catch(e){Yt.ssoLog.warn("_sendOnlinePresenceRequest",` error:${e.message}`)}})}},{key:"_isLoginIn",value:function _isLoginIn(){var e;return!0===(null===(e=Yt.store.get("login"))||void 0===e?void 0:e.isLoggedIn)}},{key:"_isLoginFrequencyExceeded",value:function _isLoginFrequencyExceeded(){return Date.now()-this._latestLoginAt<=15e3}},{key:"_reset",value:function _reset(){Yt.common.taskScheduler.removeTask(Gs),this._helloInterval=120,this._latestSendOnlinePresenceRequestTime=0,this._latestLoginAt=0,this._customLoginInfo="",Yt.store.clear("login"),Yt.store.set("login",{isReady:!1}),Yt.store.set("instance",{applicationID:0})}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e}=Yt;e.unSubscribeInnerEvent(ts.RECONNECTED,this._reLogin,this),e.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this)}}])}();const Qd={login:{userID:{required:!0,rules:["string"],allowEmpty:!1},userSig:{required:!0,rules:["string"],allowEmpty:!1}}},Xd={logout:!0};let Zd=_createClass(function Zd(){_classCallCheck(this,Zd),this.loginAction=new Jd,this.kickedOutHandler=new Bs,this.loginAction.init(),this.kickedOutHandler.init(),sn({auth:Xd,params:Qd})});var eh,th,sh;!function(e){e.CONV_C2C="C2C",e.CONV_GROUP="GROUP",e.CONV_TOPIC="TOPIC",e.CONV_SYSTEM="@TIM#SYSTEM"}(eh||(eh={})),function(e){e.MSG_PRIORITY_HIGH="High",e.MSG_PRIORITY_NORMAL="Normal",e.MSG_PRIORITY_LOW="Low",e.MSG_PRIORITY_LOWEST="Lowest"}(th||(th={})),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"}(sh||(sh={}));const nh={1:th.MSG_PRIORITY_HIGH,2:th.MSG_PRIORITY_NORMAL,3:th.MSG_PRIORITY_LOW,4:th.MSG_PRIORITY_LOWEST};var rh;!function(e){e.IN="in",e.OUT="out"}(rh||(rh={}));const ch={};function uh(e){if(!e)return 0;if(void 0===ch[e]){const t=new Date,s=`3${t.getHours()}`.slice(-2),n=`0${t.getMinutes()}`.slice(-2),o=`0${t.getSeconds()}`.slice(-2);ch[e]=parseInt([s,n,o,"0001"].join(""),10),console.log(`autoIncrementIndex start index:${ch[e]}`)}else ch[e]+=1;return ch[e]}let lh=function(){return _createClass(function lh(e){_classCallCheck(this,lh),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=th.MSG_PRIORITY_NORMAL,this._relayFlag=!1;const{clientTime:t=Yt.common.timeManager.getServerTimeSeconds()||0,senderTinyID:s,currentUser:n,needReadReceipt:o,isSupportExtension:i,customModerationConfigurationId:r,to:a,from:c,nick:u="",avatar:l="",time:d,messageControlInfo:h,tinyID:g,cloudCustomData:p="",messageLifeTime:_,messageVersion:m=0,conversationType:v,sequence:f,checkResult:I=0,isPlaceMessage:E=0,messageFlagBits:S,receiverList:C,isSystemMessage:M=!1,status:y=is.SUCCESS,revokeReason:O="",conversationSubType:A,clientSequence:T,protocol:R="JSON",revokerInfo:D={userID:"",nick:"",avatar:""},readReceiptInfo:b={readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},random:N,groupProfile:L,atUserList:P,flow:G,isRead:w=!1,priority:U=th.MSG_PRIORITY_NORMAL,onlineOnlyFlag:k=!1,nameCard:F="",quoteInfo:$}=e;var x;this.clientTime=t,this.senderTinyID=s||g,this.needReadReceipt=!0===o||1===o,this.isSupportExtension=!0===i||1===i,this._cmConfigID=r,this.to=a,this.nick=u,this.avatar=l,this.protocol=R,this.random=void 0===N?(x=x||99999999,Math.round(Math.random()*x)):N,this.time=d||Math.ceil(Date.now()/1e3),this._isExcludedFromLastMessage=!!(null==h?void 0:h.excludedFromLastMessage),this._isExcludedFromUnreadCount=!!(null==h?void 0:h.excludedFromUnreadCount),this.isModified=!!m,this.cloudCustomData=p,this.messageLifeTime=_,this.from=c||null,this.sequence=f||0,this.conversationType=v||eh.CONV_C2C,this.hasRiskContent=I>1,this.version=m,this.isPlaceMessage=E,this.isRevoked=2===E||8===S,this.isSystemMessage=M,this.readReceiptInfo=b,this.revokeReason=O,this.revokerInfo=D,this._receiverList=C,this.conversationSubType=A,this.revoker=(null==D?void 0:D.revoker)||"",this.clientSequence=T||f||0,this.status=y,this.atUserList=P||[],this.flow=G,this.isRead=w,this.priority=U,this._onlineOnlyFlag=k,this.nameCard=F,this.quoteInfo=$,this.reInitialize(n),this._initC2CReadReceiptInfo(e),this._extractGroupInfo(L)},[{key:"getElements",value:function getElements(){return this._elements}},{key:"isOnlineMessage",value:function isOnlineMessage(){return 0===this.messageLifeTime}},{key:"setElement",value:function setElement(e){Array.isArray(e)?this._elements=e:this._elements=[e],this._updatePayloadAndType()}},{key:"transformElementsToServerFormat",value:function transformElementsToServerFormat(){return this._elements?Array.isArray(this._elements)?this._elements.map(e=>e.transformToServerFormat()):this._elements.transformToServerFormat():null}},{key:"setRelayFlag",value:function setRelayFlag(e){this._relayFlag=e}},{key:"validateBeforeSend",value:function validateBeforeSend(){var e,t,s;return this._relayFlag?{isValid:!0}:(null===(e=this._elements)||void 0===e?void 0:e.length)>0?null===(s=null===(t=this._elements[0])||void 0===t?void 0:t.validateBeforeSend)||void 0===s?void 0:s.call(t):{isValid:!1}}},{key:"_updatePayloadAndType",value:function _updatePayloadAndType(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}},{key:"_initC2CReadReceiptInfo",value:function _initC2CReadReceiptInfo(e){const{readReceiptSentByPeer:t,timestamp:s=0}=e;this.conversationType===eh.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===t,this.readReceiptInfo.timestamp=s)}},{key:"_extractGroupInfo",value:function _extractGroupInfo(e){if(!e)return;const{From_AccountNick:t,From_AccountHeadurl:s,MsgFrom_AccountExtraInfo:n,GroupType:o}=e,{NameCard:i}=n||{};"string"==typeof t&&(this.nick=t),"string"==typeof s&&(this.avatar=s),"string"==typeof i&&(this.nameCard=i),this.conversationSubType=o}},{key:"reInitialize",value:function reInitialize(e){e===this.from&&(this.isRead=!0),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}},{key:"_concatConversationID",value:function _concatConversationID(e){let t="";const s=this.conversationType;s!==eh.CONV_SYSTEM?(t=s===eh.CONV_C2C?e===this.from?this.to:this.from:this.to,this.conversationID=t?`${s}${t}`:null):this.conversationID=eh.CONV_SYSTEM}},{key:"_initSequence",value:function _initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=uh(e)),0===this.sequence&&this.conversationType===eh.CONV_C2C&&(this.sequence=this.clientSequence)}},{key:"generateMessageID",value:function generateMessageID(){this.from===eh.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-${this.random}`}},{key:"setIsRead",value:function setIsRead(e){this.isRead=e}}])}(),dh=function(){function dh(e){_classCallCheck(this,dh),this.type=sh.MSG_CUSTOM;const{data:t="",description:s="",extension:n=""}=e;this.content={data:t,description:s,extension:n}}return _createClass(dh,[{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{data:n,description:o,extension:i}=s;return{MsgType:this.type,MsgContent:{Data:n,Ext:i,Desc:o}}}},{key:"validateBeforeSend",value:function validateBeforeSend(){const{isEmpty:e}=Yt.utils,t=[this.content.data,this.content.description,this.content.extension].some(t=>!e(t));return{isValid:t,error:t?null:{message:"content can not be empty"}}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t={}}=e,{Data:s,Ext:n,Desc:o}=t;return new dh({data:s,description:o,extension:n})}}])}(),hh=function(){function hh(e){_classCallCheck(this,hh),this.type=os.MSG_TEXT,this.content={text:e.text||""}}return _createClass(hh,[{key:"validateBeforeSend",value:function validateBeforeSend(){var e,t;return(null===(t=null===(e=this.content)||void 0===e?void 0:e.text)||void 0===t?void 0:t.length)>0?{isValid:!0}:{isValid:!1,error:{message:"content can not be empty"}}}},{key:"transformToServerFormat",value:function transformToServerFormat(e){const{isMergerMessage:t=!1}=e||{},s=t?this.payload:this.content,{text:n}=s;return{MsgType:this.type,MsgContent:{Text:n}}}}],[{key:"parseServerPushElement",value:function parseServerPushElement(e){const{MsgContent:t={Text:""}}=e,{Text:s}=t;return new hh({text:s})}}])}();var gh=new(function(){return _createClass(function _class139(){_classCallCheck(this,_class139),this._elementClassMap={[sh.MSG_CUSTOM]:dh,[sh.MSG_TEXT]:hh}},[{key:"init",value:function init(){zd.getInstance().registerApi({apiName:"createCustomMessage",context:this}),zd.getInstance().registerApi({apiName:"createTextMessage",context:this})}},{key:"registerElementClass",value:function registerElementClass(e,t){var s;void 0!==(s=t).prototype&&"constructor"in s.prototype&&(this._elementClassMap[e]=t)}},{key:"getElementClass",value:function getElementClass(e){return this._elementClassMap[e]}},{key:"createMessage",value:function createMessage(e){const{from:t,flow:s=rh.OUT}=e,{userId:n}=Yt.store.get("login")||{};this._isSendByCurrentInstance({from:t,flow:s,currentUser:n})?this._updateWithSenderInfo(e):this._isMultiEndpointSyncMessage({from:t,flow:s,currentUser:n})&&(e.flow=rh.OUT);const o=Object.assign(Object.assign({},e),{currentUser:n});return new lh(o)}},{key:"createCustomMessage",value:function createCustomMessage(e){const t=_n(),s=this.createMessage(Object.assign(Object.assign({},e),{from:t})),n=this._elementClassMap[sh.MSG_CUSTOM];if(!s)return null;if(n){const t=new n(e.payload);s.setElement(t)}return s}},{key:"createTextMessage",value:function createTextMessage(e){var t;if(!e)return null;const s="string"==typeof e.payload?e.payload:(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text)||"",n=new hh({text:s}),o=_n(),i=Yt.message.messageFactory.createMessage(Object.assign(Object.assign({},e),{from:o}));return i.setElement(n),i}},{key:"_updateWithSenderInfo",value:function _updateWithSenderInfo(e){var t,s;const{nick:n,avatar:o,conversationType:i,to:r}=e,{userId:a,tinyID:c}=Yt.store.get("login")||{},u=Wd.getUserProfile(a);return e.nick=n||(null==u?void 0:u.nick)||"",e.avatar=o||(null==u?void 0:u.avatar)||"",e.tinyID=e.tinyID||c||"",e.from=a,e.status=is.UNSENT,e.flow=rh.OUT,i===hs.CONV_GROUP&&(e.nameCard=null===(s=null===(t=Hd.getGroup(r))||void 0===t?void 0:t.selfInfo)||void 0===s?void 0:s.nameCard),e}},{key:"_isMultiEndpointSyncMessage",value:function _isMultiEndpointSyncMessage(e){const{from:t,flow:s,currentUser:n}=e;return t===n&&s===rh.IN}},{key:"_isSendByCurrentInstance",value:function _isSendByCurrentInstance(e){const{from:t,flow:s,currentUser:n}=e;return t===n&&s===rh.OUT}}])}());const ph={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}},_h={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},mh={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function vh(e,t){return Object.keys(t).forEach(s=>{const{range:n,defaultValue:o}=t[s];e[s]=n.includes(e[s])?e[s]:o}),e}function fh(e){const t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Ih(e){const{androidInfo:t={},androidOPPOChannelID:s=""}=e,n=t.OPPOChannelID||s,o=vh(t,_h),{sound:i="",FCMChannelID:r=""}=o,a=ge(o,["sound","FCMChannelID"]);return Object.assign(Object.assign({},a),{Sound:fh(i),OPPOChannelID:n,GoogleChannelID:r})}function Eh(t){const{apnsInfo:s={},ignoreIOSBadge:n=!1,disableVoipPush:o}=t,i=vh(s,mh),{ignoreIOSBadge:r,disableVoipPush:a,enableIOSBackgroundNotification:c}=i,u=ge(i,["ignoreIOSBadge","disableVoipPush","enableIOSBackgroundNotification"]),l=!0===r||!0===n?1:0;let d;return e(o)||(d=!1===o?1:0),e(a)||(d=!1===a?1:0),Object.assign(Object.assign({},u),{BadgeMode:l,IsVoipPush:d,ContentAvailable:c?1:0})}function Sh(e){return Yt.utils.isPlainObject(e)?{PushFlag:!0===e.disablePush?1:0,Title:e.title||"",Desc:e.description||"",Ext:e.extension||"",ApnsInfo:Eh(e),AndroidInfo:Ih(e)}:ph}function Ch(e){const{From_AccountHeadurl:t,From_AccountNick:s,IsNeedReadReceipt:n,IsPeerRead:o,IsSyncMsg:i,MsgBody:r,MsgClientTime:a,MsgLifeTime:c,MsgRandom:u,MsgSeq:l,MsgTimeStamp:d,SendMsgControl:h,SupportMessageExtension:g,TinyId:p,MsgCheckResult:_,CloudCustomData:m,MsgVersion:v,MsgFlagBits:f,RevokerInfo:I,InnerSdkCustomData:E}=e;let S,{From_Account:C,To_Account:M}=e;if(1===i){const e=M;M=C,C=e}if(I){const{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=I;S={reason:e,revoker:t,revokerFromUin:s,userID:t}}return{from:C,avatar:t,nick:s,needReadReceipt:1===n,isSyncMessage:i,clientTime:a,messageLifeTime:c,random:u,sequence:l,time:d,messageControlInfo:{excludedFromLastMessage:1===(null==h?void 0:h.NoLastMsg),excludedFromUnreadCount:1===(null==h?void 0:h.NoUnread)},isSupportExtension:g,to:M,tinyID:p,checkResult:_,cloudCustomData:m,revokerInfo:S,messageVersion:v,messageFlagBits:f,readReceiptSentByPeer:o,elements:Ah(r),onlineOnlyFlag:0===c,quoteInfo:Rh(E)}}function Mh(e){const{From_Account:t,MsgBody:s,MsgClientTime:n,MsgRandom:o,MsgSeq:i,MsgTimeStamp:r,To_Account:a,MsgVersion:c,CloudCustomData:u,MsgCheckResult:l}=e;return{from:t,clientTime:n,random:o,sequence:i,time:r,to:a,elements:Ah(s),messageVersion:c,cloudCustomData:u,checkResult:l}}function yh(e){const{ClientSeq:t,From_Account:s,GroupInfo:n,MsgBody:o,MsgClientTime:i,MsgRandom:r,MsgSeq:a,MsgTimeStamp:c,SendMsgControl:u,SupportMessageExtension:l,TinyId:d,CloudCustomData:h,MsgVersion:g,MsgCheckResult:p,NeedReadReceipt:_,IsPlaceMsg:m,RevokerInfo:v,GroupAtInfo:f,OnlineOnlyFlag:I,InnerSdkCustomData:E}=e;let S,C=th.MSG_PRIORITY_NORMAL;if(Object.keys(nh).includes(String(e.MsgPriority))&&(C=nh[e.MsgPriority]),v){const{Reason:e,Revoker_Account:t,Revoker_FromUin:s}=v;S={reason:e,revoker:t,revokerFromUin:s,userID:t}}const M=function(e){const t=[];return Array.isArray(e)&&e.forEach(e=>{0===e.GroupAtAllFlag?t.push(e.GroupAt_Account):1===e.GroupAtAllFlag&&t.push(Es.MSG_AT_ALL)}),t}(f);return{clientSequence:t,from:s,groupProfile:n,clientTime:i,priority:C,random:r,sequence:a,time:c,messageControlInfo:{excludedFromLastMessage:1===(null==u?void 0:u.NoLastMsg),excludedFromUnreadCount:1===(null==u?void 0:u.NoUnread)},isSupportExtension:l,tinyID:d,cloudCustomData:h,messageVersion:g,checkResult:p,needReadReceipt:_,isPlaceMessage:m,revokerInfo:S,atUserList:M,elements:Ah(o),to:Oh(e),onlineOnlyFlag:1===I,quoteInfo:Rh(E)}}function Oh(e){const{utils:{isEmpty:t},constants:{IS_TOPIC_MESSAGE:s}}=Yt,{ToGroupId:n,GroupInfo:{MillionGroupFlag:o=0,TopicId:i}={}}=e;return o!==s||t(i)?n:i}function Ah(e){if(!e)return null;if(Array.isArray(e))return e.map(e=>{const t=Yt.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)});const t=Yt.message.messageFactory.getElementClass(e.MsgType);return null==t?void 0:t.parseServerPushElement(e)}function Th(e){const{From_Account:t,MsgBody:s,MsgClientTime:n,MsgRandom:o,MsgSeq:i,MsgTimeStamp:r,GroupId:a,TopicId:c,MsgVersion:u,CloudCustomData:l,MsgCheckResult:d}=e;return{from:t,clientTime:n,random:o,sequence:i,time:r,groupID:a,topicID:c,elements:Ah(s),messageVersion:u,cloudCustomData:l,checkResult:d}}function Rh(e){const{utils:{isString:t,safeStringify:s},ssoLog:n}=Yt;if(!t(e))return null;try{const{messageID:t,messageTime:s,messageSequence:n}=JSON.parse(e).businessQuote;return{msgID:t,messageTime:s,messageSequence:n}}catch(e){return n.debug("_parseServerQuoteInfo",s(e)),null}}function Dh({conversationUpdateFields:e,message:t}){const{conversationID:s,conversationType:n,conversationSubType:o,flow:i,_isExcludedFromUnreadCount:r,_isExcludedFromLastMessage:a}=t,c=a?"":xd(t),u=!r&&i===rh.IN;e.has(s)?(e.get(s).lastMessage=c,u&&e.get(s).unreadCount++):e.set(s,{conversationID:s,type:n,subType:o,unreadCount:u?1:0,lastMessage:c})}function bh(e){return e.filter(e=>{const t=!Ee(null==e?void 0:e._elements),s=1===(null==e?void 0:e.isPlaceMessage);return t||Yt.ssoLog.error("emptyMessageBody",`from:${e.from} to:${e.to} sequence:${e.sequence}`),t&&!s})}function Nh(e){const{messageDataHandler:t}=Yt.message;return!t.isInMessageList(e)&&!t.isMessageSentByCurrentInstance(e)}var Lh=Object.freeze({__proto__:null,autoIncrementIndex:uh,createAndroidPushInfo:Ih,createApnsPushInfo:Eh,createOfflinePushInfo:Sh,filterValidMessages:bh,getAndroidSoundName:fh,parseServerGroupMessage:yh,parseServerPushC2CModifyMessage:Mh,parseServerPushGroupModifyMessage:Th,parseServerPushMessage:Ch,parseServerPushMessageElement:Ah,shouldStoreMessage:Nh,updateConversationFields:Dh});const{isPlainObject:Ph}=Yt.utils;function Gh(e,t={}){const{onlineUserOnly:s,messageControlInfo:n}=t;let{offlinePushInfo:o}=t;e.conversationType===eh.CONV_C2C&&!0===s&&(o?o.disablePush=!0:o={disablePush:!0});let i="";"string"==typeof e.cloudCustomData&&e.cloudCustomData.length>0&&(i=e.cloudCustomData);const r=[];if(n&&Ph(n)){const{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=n;!0===e&&r.push("NoUnread"),!0===t&&r.push("NoLastMsg"),!0===s&&r.push("NoMsgCheck")}return{onlineUserOnly:s,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:o}}function wh(e){const{webhookInfo:{disableCloudMessagePreHook:t=!1,disableCloudMessagePostHook:s=!1}={}}=e||{};if(!t&&!s)return;const n=[];return t&&n.push("ForbidBeforeSendMsgCallback"),s&&n.push("ForbidAfterSendMsgCallback"),n}function Uh(e,t){return pe(this,void 0,void 0,function*(){const s=e.conversationType===eh.CONV_GROUP?function(e,t){var s;const o=Gh(e,t),{onlineUserOnly:i,cloudCustomData:r,messageControlInfo:a,offlinePushInfo:c}=o,u=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));let l;return n(e._receiverList)&&e._receiverList.length>0&&(l=e._receiverList,e._receiverList.length>50&&(l=e._receiverList.slice(0,50),console.warn("ReceiverListLimit"))),{servcmd:"group_open_http_svc.send_group_msg",data:{From_Account:null===(s=Yt.store.get("login"))||void 0===s?void 0:s.userId,GroupId:e.to,MsgBody:u,CloudCustomData:r,Random:e.random,MsgPriority:e.priority,ClientSeq:e.clientSequence,GroupAtInfo:e._groupAtInfoList,OnlineOnlyFlag:i?1:0,MsgClientTime:e.clientTime,OfflinePushInfo:Sh(c),SendMsgControl:i?void 0:a,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:wh(t),InnerSdkCustomData:qh(e)}}}(e,t):function(e,t){var s;const n=Gh(e,t),{onlineUserOnly:o,cloudCustomData:i,messageControlInfo:r,offlinePushInfo:a}=n,c=!0===o?0:void 0,u=JSON.parse(JSON.stringify(e.transformElementsToServerFormat()));return{servcmd:"openim.sendmsg",data:{From_Account:null===(s=Yt.store.get("login"))||void 0===s?void 0:s.userId,To_Account:e.to,MsgBody:u,CloudCustomData:i,MsgSeq:e.sequence,MsgRandom:e.random,MsgLifeTime:c,From_AccountNick:e.nick,From_AccountHeadurl:e.avatar,SendMsgControl:0!==c?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:Sh(a),ForbidCallbackControl:wh(t),InnerSdkCustomData:qh(e)}}}(e,t),o=yield dn(s);return o?{time:o.MsgTime,messageDropReason:o.MsgDropReason,sequence:o.MsgSeq}:null})}function kh(e){return pe(this,void 0,void 0,function*(){const{from:t,to:s,version:n=0,sequence:o,random:i,time:r,type:a,cloudCustomData:c}=e,u={From_Account:t,To_Account:s,MsgVersion:n,MsgSeq:o,MsgRandom:i,MsgTime:r,MsgType:a,MsgBody:e.transformElementsToServerFormat(),CloudCustomData:c},l=yield dn({servcmd:"openim.modify_c2c_msg",data:u});if(l){const{MsgBody:e,MsgVersion:t,CloudCustomData:s}=l;return{elements:Ah(e),messageVersion:t,cloudCustomData:s}}})}function Fh(e){return pe(this,void 0,void 0,function*(){const{to:t,version:s=0,sequence:n,cloudCustomData:o}=e,i={GroupId:t,MsgVersion:s,MsgSeq:n,MsgBody:e.transformElementsToServerFormat(),CloudCustomData:o},r=yield dn({servcmd:"openim.modify_group_msg",data:i});if(r){const{MsgBody:e,MsgVersion:t,CloudCustomData:s}=r;return{elements:Ah(e),messageVersion:t,cloudCustomData:s}}})}function $h(e){return pe(this,void 0,void 0,function*(){const{groupID:t,count:s,messageSequence:o,messageSequenceList:i,getType:r}=e,a={GroupId:t,ReqMsgNumber:s,WithRecalledMsg:1,Version:1,GetType:r};return o&&(a.ReqMsgSeq=o),n(i)&&i.length>0&&(a.ReqMsgSeqList=i),yield dn({servcmd:"group_open_http_svc.group_msg_get",data:a})})}function xh(e){return pe(this,void 0,void 0,function*(){const{peerAccount:t,count:s,lastMessageTime:n,messageKey:o,direction:i}=e;return dn({servcmd:"openim.getroammsg",data:{Peer_Account:t,MaxCnt:s,WithRecalledMsg:1,LastMsgTime:n,MsgKey:o,GetDirection:i}})})}function qh(e){if(Yt.utils.isObject(e.quoteInfo)){const{msgID:t,messageSequence:s,messageTime:n}=e.quoteInfo;return JSON.stringify({businessQuote:{messageID:t,messageSequence:s,messageTime:n}})}}var Vh=Object.freeze({__proto__:null,createMessagePackOptions:Gh,generateForbidCallbackControl:wh,getC2CRoamingMessagesByAnchor:xh,getGroupRoamingMessagesByAnchor:$h,getRoamingMessages:function(e){return pe(this,void 0,void 0,function*(){const{peerAccount:t,count:s,lastMessageTime:n,messageKey:o}=e,i={Peer_Account:t,MaxCnt:s||15,LastMsgTime:n||0,MsgKey:o,GetDirection:0,WithRecalledMsg:1};return(yield dn({servcmd:"openim.getroammsg",data:i}))||[]})},modifyC2CMessage:kh,modifyGroupMessage:Fh,sendMessage:Uh});const{isPlainObject:Bh}=Yt.utils,{MSG_AUDIO:jh,MSG_FILE:Hh,MSG_IMAGE:Kh,MSG_VIDEO:Wh,MSG_MERGER:Yh}=Es;let zh=function(){return _createClass(function zh(){_classCallCheck(this,zh),this._sendProtocolMap=new Map},[{key:"init",value:function init(){zd.getInstance().registerApi({apiName:"sendMessage",context:this,matcher:e=>![jh,Hh,Kh,Wh,Yh].includes(e[0].type)})}},{key:"registerSendProtocol",value:function registerSendProtocol(e,t,s){this._sendProtocolMap.set(e,t.bind(s))}},{key:"sendMessage",value:function sendMessage(e,t){return pe(this,void 0,void 0,function*(){const{TOTAL_COUNT:s,SEND_COST:n,SUCCESS_COUNT:o,FAILED_COUNT:i}=Ts;if(!(e instanceof lh))throw new Ws({code:Ss.MSG_INSTANCE_REQUIRED});const r=e.validateBeforeSend();if(!r.isValid){const{code:e,message:t=""}=r.error||{};throw new Ws({code:e,message:t})}this._reportMessageSendQuality({name:s,message:e});let a=!1;const{messageDataHandler:c}=Yt.message||{};try{const{messageControlInfo:s}=t||{};let i=null;c.addRandomOfSentMessage(e.random);const r=Date.now(),u=this._getSendProtocol(e);if(e.conversationType===eh.CONV_C2C?(a=!0===(null==t?void 0:t.onlineUserOnly),i=yield u(e,t)):e.conversationType===eh.CONV_GROUP&&(yield this._validateBeforeSendGroupMessage(e),i=yield u(e,t)),i){const{messageDropReason:t,sequence:u,time:l}=i;if(this._updateNickAndAvatarOfSentMessageByMe(e),t&&this._logRateLimitInfo(e,u,t),this._reportMessageSendQuality({name:o,message:e}),this._reportMessageSendQuality({name:n,message:e,startTs:r}),!0===e.isResend){const t=c.findMessage(e.ID);t&&(Yt.ssoLog.debug("sendMessage",`sendMessage resend ok. ID:${t.ID}`),c.deleteConversationMessage(t))}return e.status=is.SUCCESS,e.time=l,e.conversationType===eh.CONV_GROUP&&(e.sequence=u),a?e._onlineOnlyFlag=!0:(c.storeConversationMessage(e),this._applySentMessageControlInfo(e,s),this._emitOnlineMessageSent(e)),e.type===os.MSG_STREAM?{code:0,data:{message:e,streamMessageID:i.streamMessageID}}:{code:0,data:{message:e}}}}catch(t){e.status=is.FAIL,c.removeRandomOfSentMessage(e.random);let{errorCode:s}=t||{},n=(null==t?void 0:t.errorInfo)||(null==t?void 0:t.message)||"";throw this._hasRiskContent(s)&&(e.hasRiskContent=!0),a||this._isRejectedByRestApi(s)||c.storeConversationMessage(e),this._reportMessageSendQuality({name:i,message:e,error:t}),new Ws({code:s,message:n,data:{message:e},moreMessage:`type:${e.type} from:${e.from} to:${e.to}`})}})}},{key:"_hasRiskContent",value:function _hasRiskContent(e){return 80001===e||80004===e}},{key:"_isRejectedByRestApi",value:function _isRejectedByRestApi(e){return e>=10100&&e<=10200||e>=120001&&e<=13e4}},{key:"_emitOnlineMessageSent",value:function _emitOnlineMessageSent(e){const t=e._isExcludedFromLastMessage?"":e,{conversationID:s,conversationType:n}=e,o=cn(s)?ts.TOPIC_NEW_MESSAGE:ts.NEW_MESSAGE;Yt.notificationCenter.emitInnerEvent(o,{result:{conversationUpdateFieldList:[{conversationID:s,type:n,message:e,lastMessage:t,unreadCount:0}]}})}},{key:"_applySentMessageControlInfo",value:function _applySentMessageControlInfo(e,t){t&&Bh(t)&&(!0===t.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0),!0===t.excludedFromUnreadCount&&(e._isExcludedFromUnreadCount=!0))}},{key:"_logRateLimitInfo",value:function _logRateLimitInfo(e,t,s){const n=`from:${e.from} to:${e.to} sequence:${t} messageDropReason:${s}`;Yt.ssoLog.warn("messageDropReason",n)}},{key:"_updateNickAndAvatarOfSentMessageByMe",value:function _updateNickAndAvatarOfSentMessageByMe(e){const{messageDataHandler:t}=Yt.message||{};let s=!1;const{conversationID:n}=e,o=t.getLatestMsgSentByMe(n);if(o){const{nick:i,avatar:r}=o;i===e.nick&&r===e.avatar||(s=!0),s&&t.updateNickAndAvatarOfSentMessage({conversationID:n,latestNick:e.nick,latestAvatar:e.avatar,isSentByMe:!0})}}},{key:"_validateBeforeSendGroupMessage",value:function _validateBeforeSendGroupMessage(e){return pe(this,void 0,void 0,function*(){var t,s,n;const{to:o,from:i}=e;let r=o,a=Hd.getGroup(r);if(an({groupID:r})&&(null==a?void 0:a.isSupportTopic))throw new Ws({code:Ss.MSG_SEND_GRP_WITH_TOPIC_FAIL});if(cn(o)&&([r]=o.split(ms.TOPIC),a=Hd.getGroup(r)),!a&&"function"==typeof(null===(t=zd.getInstance().getApiMap())||void 0===t?void 0:t.getGroupProfile)){const e=yield zd.getInstance().getApiMap().getGroupProfile({groupID:r});if((null===(n=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.group)||void 0===n?void 0:n.type)===Es.GRP_AVCHATROOM){const e=Ks({code:Ss.MSG_SEND_FAIL_NOT_IN_AV,replacement1:i,replacement2:r});throw new Ws({code:Ss.MSG_SEND_FAIL_NOT_IN_AV,message:e})}}return!0})}},{key:"_reportMessageSendQuality",value:function _reportMessageSendQuality(e){Yt.notificationCenter.emitInnerEvent(ts.QUALITY_STAT,{label:As.MESSAGE_SEND_SUCCESS_RATE,data:e})}},{key:"_getSendProtocol",value:function _getSendProtocol(e){return this._sendProtocolMap.get(e.type)||Uh}}])}();var Jh=new(function(){return _createClass(function _class140(){_classCallCheck(this,_class140),this._sparseMessagesByConversation=new Map,this._latestMessageSentByPeerMap=new Map,this._latestMessageSentByMeMap=new Map,this._randomOfSentMessageList=new Set},[{key:"init",value:function init(){Yt.notificationCenter.subscribeInnerEvent(ts.LOGOUT,this._reset,this),Yt.notificationCenter.subscribeInnerEvent(ts.DESTROY,this._dispose,this)}},{key:"_messagesByConversation",get:function(){return Kd.getMessages()}},{key:"storeConversationMessage",value:function storeConversationMessage(e,t=!1){if(he)return!0;const{conversationID:s}=e;if(!s)return!1;if(this._messagesByConversation.has(s)||this._messagesByConversation.set(s,new Map),this._shouldSkipStoreMessage(e,t))return!1;const n=this._getUniqueIdOfMessage(e);return this._messagesByConversation.get(s).set(n,e),this._updateLatestMessageMap(e),!0}},{key:"_updateLatestMessageMap",value:function _updateLatestMessageMap(e){const{conversationID:t}=e;"out"===e.flow?this._setLatestMsgSentByMe(t,e):t.startsWith("C2C")&&this._setLatestMsgSentByPeer(t,e)}},{key:"_shouldSkipStoreMessage",value:function _shouldSkipStoreMessage(e,t){const s=this._getUniqueIdOfMessage(e),n=this._messagesByConversation.get(e.conversationID);if(null==n?void 0:n.has(s)){const e=null==n?void 0:n.get(s);if(!t||!0===(null==e?void 0:e.isModified))return!0}return!1}},{key:"deleteConversationMessage",value:function deleteConversationMessage(e){var t;const{conversationID:s=""}=e,n=this._getUniqueIdOfMessage(e);this._messagesByConversation.has(s)&&(null===(t=this._messagesByConversation.get(s))||void 0===t||t.delete(n))}},{key:"modifyConversationMessage",value:function modifyConversationMessage(e,t){var s;if(!this._messagesByConversation.has(e)&&!this._sparseMessagesByConversation.has(e))return{isUpdated:!1,message:null};const n=this._getUniqueIdOfMessage(t),o=this._getMessageFromLocalMessage(e,n);if(o){const{messageVersion:n,elements:i,cloudCustomData:r,checkResult:a=0}=t,c=a>1;if(Yt.ssoLog.debug("modifyConversationMessage",`conversationToMessageMap modifyConversationMessage localVersion:${o.version} remoteVersion:${n}`),o.version<n){const t=this._getUniqueIdOfMessage(o),a=Se(i);return(null===(s=this._messagesByConversation.get(e))||void 0===s?void 0:s.has(t))?Kd.updateMessage(e,[t],{isModified:!0,version:n,_elements:a,payload:a[0].content,type:a[0].type,cloudCustomData:r,hasRiskContent:c,operation:rs.modify}):(o.version=n,o._elements=a,o.payload=o._elements[0].content,o.type=o._elements[0].type,o.cloudCustomData=r,o.isModified=!0,o.hasRiskContent=c),{isUpdated:!0,message:o}}return{isUpdated:!1,message:o}}return{isUpdated:!1,message:null}}},{key:"_getMessageFromLocalMessage",value:function _getMessageFromLocalMessage(e,t){var s;if(this._messagesByConversation.has(e))return null===(s=this._messagesByConversation.get(e))||void 0===s?void 0:s.get(t);if(this._sparseMessagesByConversation.has(e)){const s=[...this._sparseMessagesByConversation.get(e).values()];for(let e=0;e<s.length;e++)if(this._getUniqueIdOfMessage(s[e])===t)return s[e]}return null}},{key:"findMessage",value:function findMessage(e){let t=null;const s=Array.from(this._messagesByConversation.values());for(const n of s)if(t=Array.from(n.values()).find(t=>t.ID===e)||null,t)break;if(!t){const s=Array.from(this._sparseMessagesByConversation.values());for(const n of s)if(t=n.get(e)||null,t)break}return t}},{key:"deleteConversationMessageList",value:function 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)}},{key:"revokeMessage",value:function revokeMessage({conversationID:e,sequence:t,random:s,revoker:n}){const o=this._messagesByConversation.get(e);let i=null;if(o){const r=Array.from(o.values());if(i=this._findMessageBySequenceAndRandom({messageList:r,random:s,sequence:t}),i){const t=this._getUniqueIdOfMessage(i);return Kd.updateMessage(e,[t],{isRevoked:!0,revoker:n,operation:rs.revoke}),i}}if(this._sparseMessagesByConversation.has(e)){const o=Array.from(this._sparseMessagesByConversation.get(e).values());if(i=this._findMessageBySequenceAndRandom({messageList:o,random:s,sequence:t}),i)return i.isRevoked=!0,i.revoker=n,i}}},{key:"_findMessageBySequenceAndRandom",value:function _findMessageBySequenceAndRandom({messageList:t,sequence:s,random:n}){for(let o=0;o<t.length;o+=1){const i=t[o];if(i.sequence===s&&(e(n)||i.random===n))return i}return null}},{key:"prependLocalMessageList",value:function prependLocalMessageList(e){const{messageList:t,conversationID:s}=e;if(0===t.length)return[];if(he)return t;const n=[],o=[],i=this._messagesByConversation.get(s)||new Map;for(const e of t){const t=this._getUniqueIdOfMessage(e);i.has(t)||(n.push(e),o.push([t,e]))}if(o.length>0){const e=new Map([...o,...i.entries()]);this._messagesByConversation.set(s,e),this._updateLatestMessageSentByMe(s),this._updateLatestMessageSentByPeer(s)}return n}},{key:"storeSparseMessageList",value:function storeSparseMessageList(e){if(0===e.length)return;const{conversationID:t}=e[0],s=e.length;this._sparseMessagesByConversation.has(t)||this._sparseMessagesByConversation.set(t,new Map);const n=this._sparseMessagesByConversation.get(t);for(let t=0;t<s;t++){const s=e[t];n.has(s.ID)||n.set(s.ID,s)}}},{key:"_updateLatestMessageSentByMe",value:function _updateLatestMessageSentByMe(e){var t;const s=Array.from((null===(t=this._messagesByConversation.get(e))||void 0===t?void 0:t.values())||[]);if(0!==s.length)for(let t=s.length-1;t>=0;t--)if("out"===s[t].flow){this._setLatestMsgSentByMe(e,s[t]);break}}},{key:"_updateLatestMessageSentByPeer",value:function _updateLatestMessageSentByPeer(e){var t;const s=Array.from((null===(t=this._messagesByConversation.get(e))||void 0===t?void 0:t.values())||[]);if(0!==s.length&&e.startsWith("C2C"))for(let t=s.length-1;t>=0;t--)if("in"===s[t].flow){this._setLatestMsgSentByPeer(e,s[t]);break}}},{key:"_getUniqueIdOfMessage",value:function _getUniqueIdOfMessage(e){const{from:t,to:s,random:n,sequence:o,time:i}=e;return`${t}-${s}-${n}-${o}-${i}`}},{key:"_setLatestMsgSentByPeer",value:function _setLatestMsgSentByPeer(e,t){this._latestMessageSentByPeerMap.set(e,t)}},{key:"_setLatestMsgSentByMe",value:function _setLatestMsgSentByMe(e,t){this._latestMessageSentByMeMap.set(e,t)}},{key:"getLatestMsgSentByPeer",value:function getLatestMsgSentByPeer(e){return this._latestMessageSentByPeerMap.get(e)}},{key:"getLatestMsgSentByMe",value:function getLatestMsgSentByMe(e){return this._latestMessageSentByMeMap.get(e)}},{key:"addRandomOfSentMessage",value:function addRandomOfSentMessage(e){this._randomOfSentMessageList.add(e)}},{key:"removeRandomOfSentMessage",value:function removeRandomOfSentMessage(e){this._randomOfSentMessageList.delete(e)}},{key:"updateNickAndAvatarOfSentMessage",value:function updateNickAndAvatarOfSentMessage(e){const{conversationID:t="",latestAvatar:s,latestNick:n,isSentByMe:o=!0}=e,i=this._messagesByConversation.get(t);if(!i)return;const r=Array.from(i.values()),a=o?"out":"in";r.forEach(e=>{const{nick:t,avatar:o,flow:i}=e;i===a&&(t!==n&&(e.nick=n),o!==s&&(e.avatar=s))})}},{key:"isInMessageList",value:function isInMessageList(e){var t;const{conversationID:s}=e;if(!s)return!1;if(!this._messagesByConversation.has(s))return!1;const n=this._getUniqueIdOfMessage(e);return null===(t=this._messagesByConversation.get(s))||void 0===t?void 0:t.has(n)}},{key:"isMessageSentByCurrentInstance",value:function isMessageSentByCurrentInstance(e){const{random:t}=e;return this._randomOfSentMessageList.has(t)}},{key:"getContinuousMessagesByConversation",value:function getContinuousMessagesByConversation(){return this._messagesByConversation}},{key:"getLocalMessageList",value:function getLocalMessageList(e){const t=this._messagesByConversation.get(e);return t?[...t.values()]:[]}},{key:"getSparseMessageList",value:function getSparseMessageList(e){const t=this._sparseMessagesByConversation.get(e);return t?[...t.values()]:[]}},{key:"_reset",value:function _reset(){this._messagesByConversation.clear(),this._latestMessageSentByPeerMap.clear(),this._latestMessageSentByMeMap.clear(),this._randomOfSentMessageList.clear()}},{key:"_dispose",value:function _dispose(){this._reset(),Yt.notificationCenter.unSubscribeInnerEvent(ts.LOGOUT,this._reset,this),Yt.notificationCenter.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this)}}])}());function Qh(e,t){const s=Bd.getConversation(e);if(null==s?void 0:s.lastMessage){const{lastMessage:n}=s,{lastTime:o,lastSequence:i,version:r}=n,{time:a,sequence:c,messageVersion:u,elements:l,cloudCustomData:d}=t;o===a&&i===c&&r!==u&&(n.type=l[0].type,n.payload=l[0].content,n.messageForShow=Sn(n.type,n.payload),n.cloudCustomData=d,n.version=u,Bd.updateConversation(e,{lastMessage:n}))}}let Xh=function(){return _createClass(function Xh(){_classCallCheck(this,Xh)},[{key:"init",value:function init(){zd.getInstance().registerApi({apiName:"modifyMessage",context:this})}},{key:"modifyMessage",value:function modifyMessage(e){return pe(this,void 0,void 0,function*(){const{to:t,payload:s,sequence:n,conversationType:o,random:i,time:r,from:a,type:c}=e;if(this._canModifyMessageElement(c)){const t=(null==e?void 0:e._elements)||[];t.length>=1&&(t[0].type=c,t[0].content=s)}try{let s=null,c=null;if(o===eh.CONV_C2C?s=yield kh(e):o===eh.CONV_GROUP&&(s=yield Fh(e)),s){let u=`${o}${t}`;return t===_n()&&o===eh.CONV_C2C&&(u=`${o}${a}`),c={conversationType:o,from:a,to:t,time:r,random:i,sequence:n,elements:null==s?void 0:s.elements,cloudCustomData:null==s?void 0:s.cloudCustomData,messageVersion:null==s?void 0:s.messageVersion,conversationID:u},this._handleModifyMessageSuccess(c),{code:0,data:{message:e},successLog:{message:`to:${t}`}}}}catch(e){const{errorCode:s}=e||{};throw new Ws({functionName:"modifyMessage",code:s,moreMessage:`to:${t}`})}})}},{key:"_handleModifyMessageSuccess",value:function _handleModifyMessageSuccess(e){const{conversationID:t}=e,{isUpdated:s,message:n}=Yt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Yt.notificationCenter.emitOuterEvent(Zt.MESSAGE_MODIFIED,{name:Zt.MESSAGE_MODIFIED,data:[n]}),Yt.notificationCenter.emitInnerEvent(ts.MESSAGE_MODIFIED,{conversationID:t,message:n}),Qh(t,e)}},{key:"_canModifyMessageElement",value:function _canModifyMessageElement(e){return[sh.MSG_TEXT,sh.MSG_CUSTOM,sh.MSG_LOCATION,sh.MSG_FACE].includes(e)}}])}(),Zh=function(){return _createClass(function Zh(){_classCallCheck(this,Zh)},[{key:"init",value:function init(){const{notificationCenter:e}=Yt,{InnerEventSubType:t}=e;on.getInstance().registerWorkflowStep(Ms.RECEIVE_C2C_NEW_MESSAGE,ys.HANDLE_C2C_NEW_MESSAGE,this._handleC2CMessagePush,this),on.getInstance().registerWorkflowStep(Ms.RECEIVE_C2C_NEW_MESSAGE,ys.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterReceiveNewMessage,this),on.getInstance().registerWorkflowStep(Ms.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ys.EMIT_C2C_MESSAGE_EVENT,this._emitMessageEventsAfterSyncUnreadMessage,this),e.subscribeInnerEvent(ts.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(ts.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),e.subscribeInnerEvent(ts.DESTROY,this._dispose,this)}},{key:"_executeReceiverNewMessageWorkFlow",value:function _executeReceiverNewMessageWorkFlow(e){on.getInstance().executeWorkflow(Ms.RECEIVE_C2C_NEW_MESSAGE,e)}},{key:"_handleC2CMessagePush",value:function _handleC2CMessagePush(e){const t=e.data||{},{messageDataHandler:s}=Yt.message||{},n=[],o=new Map;return t.C2cMsgArray.forEach(e=>{const t=this._generateC2CMessage(e);this._updateMessageProfile(t);let i=1===t.isModified;s.isMessageSentByCurrentInstance(t)?t.isModified=i:i=!1,t._onlineOnlyFlag?s.isMessageSentByCurrentInstance(t)||n.push(t):Nh(t)&&(s.storeConversationMessage(t)&&Dh({conversationUpdateFields:o,message:t}),s.isMessageSentByCurrentInstance(t)&&!i||n.push(t))}),{conversationUpdateFieldList:[...o.values()],messages:n}}},{key:"_emitMessageEventsAfterReceiveNewMessage",value:function _emitMessageEventsAfterReceiveNewMessage(e){var t;const{messages:s=[]}=(null===(t=e.result)||void 0===t?void 0:t[ys.HANDLE_C2C_NEW_MESSAGE])||{};this._emitMessageEvents(s)}},{key:"_emitMessageEventsAfterSyncUnreadMessage",value:function _emitMessageEventsAfterSyncUnreadMessage(e){var t;const{messages:s=[]}=(null===(t=e.result)||void 0===t?void 0:t[ys.UNREAD_MESSAGE_SYNC])||{};this._emitMessageEvents(s)}},{key:"_emitMessageEvents",value:function _emitMessageEvents(e){const t=(null==e?void 0:e.filter(e=>!0===(null==e?void 0:e.isModified)))||[];t.length>0&&Yt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:t});const s=null==e?void 0:e.filter(e=>!(null==e?void 0:e.isModified));s.length>0&&Yt.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:s})}},{key:"_generateC2CMessage",value:function _generateC2CMessage(e){const t=eh.CONV_C2C,s=Ch(e),n=Yt.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:rh.IN})),{elements:o}=s;return n.setElement(o),n}},{key:"_updateMessageProfile",value:function _updateMessageProfile(s){var n;const{messageDataHandler:o}=Yt.message||{},i=null===(n=Yt.store.get("login"))||void 0===n?void 0:n.userId,{from:r,nick:a,avatar:c,conversationID:u=""}=s;if(r!==i){const n=o.getLatestMsgSentByPeer(u);if(n){const{nick:i,avatar:r}=n;e(a)||e(c)?(s.nick=t(i)?i:s.nick,s.avatar=t(r)?r:s.avatar):a===i&&c===r||(o.updateNickAndAvatarOfSentMessage({conversationID:u,latestNick:a,latestAvatar:c,isSentByMe:!1}),this._updateConversationUserProfile({conversationID:u,nick:a,avatar:c}))}}else{const e=o.getLatestMsgSentByMe(u);!e||a===e.nick&&c===e.avatar||o.updateNickAndAvatarOfSentMessage({conversationID:u,latestNick:a,latestAvatar:c,isSentByMe:!0})}}},{key:"_updateConversationUserProfile",value:function _updateConversationUserProfile(e){const{conversationID:t,nick:s,avatar:n}=e,o=Bd.getConversation(t),{userProfile:i={}}=o||{};i.avatar===n&&i.nick===s||Bd.updateConversation(t,{userProfile:Object.assign(Object.assign({},i),{nick:s,avatar:n})})}},{key:"_updateMessageListDueToModify",value:function _updateMessageListDueToModify(e){const{conversationID:t}=e,{isUpdated:s,message:n}=Yt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Yt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),Yt.notificationCenter.emitInnerEvent("ModifyMessageSuccess",e),Qh(t,e)}},{key:"_handleC2CMessageModify",value:function _handleC2CMessageModify(e){e.C2cMsgModNotifys.forEach(e=>{var t;const s=eh.CONV_C2C;let n=Mh(e);const{to:o,from:i}=n;let r=`${s}${o}`;o===(null===(t=Yt.store.get("login"))||void 0===t?void 0:t.userId)&&(r=`${s}${i}`),n=Object.assign({conversationType:s,conversationID:r},n),this._updateMessageListDueToModify(n)})}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e}=Yt,{InnerEventSubType:t}=e;Yt.notificationCenter.unSubscribeInnerEvent(ts.MESSAGE_PUSH,t.C2C_REALTIME_MESSAGE,this._handleC2CMessagePush,this),Yt.notificationCenter.unSubscribeInnerEvent(ts.MESSAGE_PUSH,t.C2C_MESSAGE_MODIFIED,this._handleC2CMessageModify,this),Yt.notificationCenter.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this)}}])}(),eg=function(){return _createClass(function eg(){_classCallCheck(this,eg)},[{key:"init",value:function init(){const{notificationCenter:e}=Yt,{InnerEventSubType:t}=e;on.getInstance().registerWorkflowStep(Ms.RECEIVE_GROUP_NEW_MESSAGE,ys.HANDLE_GROUP_NEW_MESSAGE,this._handleGroupMessagePush,this),on.getInstance().registerWorkflowStep(Ms.RECEIVE_GROUP_NEW_MESSAGE,ys.EMIT_GROUP_MESSAGE_EVENT,this._emitMessageEvents,this),e.subscribeInnerEvent(ts.MESSAGE_PUSH,t.GROUP_REALTIME_MESSAGE,this._executeReceiverNewMessageWorkFlow,this),e.subscribeInnerEvent(ts.MESSAGE_PUSH,t.GROUP_MESSAGE_MODIFIED,this._handleGroupMessageModify,this),e.subscribeInnerEvent(ts.DESTROY,this._dispose,this)}},{key:"_executeReceiverNewMessageWorkFlow",value:function _executeReceiverNewMessageWorkFlow(e){this._canExecuteReceiverNewMessageWorkFlow(e)&&on.getInstance().executeWorkflow(Ms.RECEIVE_GROUP_NEW_MESSAGE,e)}},{key:"_handleGroupMessagePush",value:function _handleGroupMessagePush(e){const t=e.data||{},{messageDataHandler:s}=Yt.message,n=[],o=new Map,i=null==t?void 0:t.GroupMsgArray;return null==i||i.forEach(e=>{if(1===e.GroupInfo.NotVisible)return;const t=this._generateGroupMessage(e);this.updateMessageProfile(t);let i=1===t.isModified;s.isMessageSentByCurrentInstance(t)?t.isModified=i:i=!1,t._onlineOnlyFlag?s.isMessageSentByCurrentInstance(t)||n.push(t):Nh(t)&&s.storeConversationMessage(t)&&(n.push(t),Dh({conversationUpdateFields:o,message:t}))}),{conversationUpdateFieldList:[...o.values()],messages:n}}},{key:"_emitMessageEvents",value:function _emitMessageEvents(e){var t;const{messages:s}=(null===(t=e.result)||void 0===t?void 0:t[ys.HANDLE_GROUP_NEW_MESSAGE])||{},n=(null==s?void 0:s.filter(e=>!0===(null==e?void 0:e.isModified)))||[];n.length>0&&Yt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:n});const o=(null==s?void 0:s.filter(e=>!(null==e?void 0:e.isModified)))||[];o.length>0&&Yt.notificationCenter.emitOuterEvent("onMessageReceived",{name:"onMessageReceived",data:o})}},{key:"_generateGroupMessage",value:function _generateGroupMessage(e){const t=eh.CONV_GROUP,s=yh(e),n=Yt.message.messageFactory.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:rh.IN})),{elements:o}=s;return n.setElement(o),n}},{key:"updateMessageProfile",value:function updateMessageProfile(e){var t;const{messageDataHandler:s}=Yt.message||{},n=null===(t=Yt.store.get("login"))||void 0===t?void 0:t.userId,{from:o,nick:i,avatar:r,conversationID:a="",_elements:c}=e;if(o===n){const e=s.getLatestMsgSentByMe(a);!e||i===e.nick&&r===e.avatar||s.updateNickAndAvatarOfSentMessage({conversationID:a,latestNick:i,latestAvatar:r,isSentByMe:!0})}else if(o===Es.CONV_SYSTEM){const{operationType:t,memberInfoList:s,operatorInfo:n}=c;let o={};if(Ee(s)?Ee(n)||(o=n):[vs.JOINED,vs.KICKED,vs.ADMIN_SET,vs.ADMIN_CANCELED].includes(t)&&(o=Object.assign({},s[0])),!Ee(o)){const{nick:t="",avatar:s=""}=o;e.nick=t,e.avatar=s}}}},{key:"_updateMessageListDueToModify",value:function _updateMessageListDueToModify(e){const{conversationID:t}=e,{isUpdated:s,message:n}=Yt.message.messageDataHandler.modifyConversationMessage(t,e);!0===s&&Yt.notificationCenter.emitOuterEvent("onMessageModified",{name:"onMessageModified",data:[n]}),Qh(t,e)}},{key:"_handleGroupMessageModify",value:function _handleGroupMessageModify(e){e.GroupMsgModNotifys.forEach(e=>{const t=eh.CONV_GROUP;let s=Th(e);const{topicID:n,groupID:o}=s,i=n||o,r=`${t}${i}`;s=Object.assign({conversationType:t,conversationID:r,to:i},s),this._updateMessageListDueToModify(s)})}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e}=Yt,{InnerEventSubType:{GROUP_REALTIME_MESSAGE:t,GROUP_MESSAGE_MODIFIED:s}}=e;e.unSubscribeInnerEvent(ts.MESSAGE_PUSH,t,this._handleGroupMessagePush,this),e.unSubscribeInnerEvent(ts.MESSAGE_PUSH,s,this._handleGroupMessageModify,this),e.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this)}},{key:"_canExecuteReceiverNewMessageWorkFlow",value:function _canExecuteReceiverNewMessageWorkFlow(e){var t,s;const{GroupId:n,GroupType:o}=(null===(s=null===(t=null==e?void 0:e.GroupMsgArray)||void 0===t?void 0:t[0])||void 0===s?void 0:s.GroupInfo)||{},i=o===_s.GRP_AVCHATROOM;return!(!Hd.getGroup(n)&&i)}}])}();var tg=new(function(){return _createClass(function _class141(){_classCallCheck(this,_class141),this.c2cMessageReceiver=new Zh,this.groupMessageReceiver=new eg},[{key:"init",value:function init(){this.c2cMessageReceiver.init(),this.groupMessageReceiver.init()}}])}());const sg={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=>function(e){var t;return"string"==typeof(null==e?void 0:e.text)&&("string"!=typeof e.text||0!==(null===(t=null==e?void 0:e.text)||void 0===t?void 0:t.length))||"payload.text must be a string"}(e)}}},ng={createCustomMessage:!0,sendMessage:!0,modifyMessage:!0};var og=new(function(){return _createClass(function _class142(){_classCallCheck(this,_class142),this._historyMessageListFetchAnchors=new Map,this.completedHistoryConversations=new Set},[{key:"getGroupRoamingMessagesByAnchor",value:function getGroupRoamingMessagesByAnchor(e){return pe(this,void 0,void 0,function*(){try{const{conversationID:t,count:s,direction:n,sequence:o,messageSequenceList:i,shouldMarkCompleted:r=!1,getType:a}=e,c=t.replace(hs.CONV_GROUP,""),u=[];let l=o;if(n===as.BACKWARD){if("number"!=typeof o)return{messageList:[],hasNoMoreHistoryMessage:!1,nextReqMessageIDFromServer:""};l=o+s-1}const d=yield $h({groupID:c,count:s,messageSequence:l,messageSequenceList:i,getType:a});if(d){const{RspMsgList:e=[],NextReqMsgSeq:s=0,IsFinished:i,InvisibleMsgSeq:a}=d,h=`groupID:${c} sequence:${o} reqSeq:${l} direction:${n} complete:${i} nextSequence:${s} remoteMsgCount:${e.length} invisibleSequenceList:${a}`,g=[];for(let t=0;t<e.length;t++){const s=e[t];s.From_Account===Es.CONV_SYSTEM&&u.push(s);const n=this._parseMessage(s);g.push(n)}g.reverse();let p=2===i;n===as.BACKWARD&&(p=g[g.length-1].sequence>=o),p&&r&&this.completedHistoryConversations.add(t);const _=bh(g);return Yt.ssoLog.info("getGroupRoamingMessagesByAnchor",h),{messageList:_,invisibleSequenceList:a,nextReqMessageIDFromServer:s,hasNoMoreHistoryMessage:p,serverGroupTipList:u}}}catch(e){const{errorCode:t,errorInfo:s}=e||{};throw new Ws({code:t,message:s})}})}},{key:"clearHistoryMessageListFetchAnchors",value:function clearHistoryMessageListFetchAnchors(e){this._historyMessageListFetchAnchors.delete(e)}},{key:"isHistoryMessageFetchCompleted",value:function isHistoryMessageFetchCompleted(e){return this.completedHistoryConversations.has(e)}},{key:"_parseMessage",value:function _parseMessage(e){var t;const s=hs.CONV_GROUP;4===e.Event&&(e.MsgBody.MsgType=Es.MSG_GRP_TIP);const n=yh(e),o=gh.createMessage(Object.assign(Object.assign({},n),{conversationType:s,flow:"in"}));return $d((null===(t=n.elements)||void 0===t?void 0:t.content)||{},o),o.setElement(n.elements),o}},{key:"getC2CRoamingMessagesByAnchor",value:function getC2CRoamingMessagesByAnchor(e){return pe(this,void 0,void 0,function*(){var t;try{const{conversationID:s,count:n,messageID:o,time:i,direction:r,shouldMarkCompleted:a=!1}=e;let c=i,u="";if(!i){const e=o?Yt.message.messageDataHandler.findMessage(o):null;if(c=(null==e?void 0:e.time)||0,o&&this._historyMessageListFetchAnchors.has(s)){const e=this._historyMessageListFetchAnchors.get(s);c=e.lastMessageTime,u=e.messageKey}}const l=s.replace(hs.CONV_C2C,""),d=yield xh({count:n,lastMessageTime:c,messageKey:u,peerAccount:l,direction:r});if(d){const{MsgList:e=[],Complete:n,MsgKey:o,LastMsgTime:i}=d;this._historyMessageListFetchAnchors.set(s,{messageKey:o,lastMessageTime:i});const r=[];for(let t=0;t<e.length;t++){const s=e[t],n=this._parseC2CMessage(s);r.push(n)}const c=bh(r),u=null===(t=c[0])||void 0===t?void 0:t.ID,l=1===n;return l&&a&&this.completedHistoryConversations.add(s),{messageList:c,nextReqMessageIDFromServer:u,lastMessageTime:i,hasNoMoreHistoryMessage:l}}}catch(e){throw Yt.ssoLog.debug("getC2CRoamingMessagesByAnchor",Ce(e)),e}})}},{key:"_parseC2CMessage",value:function _parseC2CMessage(e){const t=hs.CONV_C2C,s=Ch(e),n=gh.createMessage(Object.assign(Object.assign({},s),{conversationType:t,flow:"in"}));return n.setElement(s.elements),n}},{key:"reset",value:function reset(){this._historyMessageListFetchAnchors.clear(),this.completedHistoryConversations.clear()}}])}());let ig=function(){return _createClass(function ig(){_classCallCheck(this,ig),this.messageHelper=Lh,this.messageDataProtocol=Vh,this.messageFactory=gh,this.messageSender=new zh,this.messageAction=new Xh,this.messageReceiver=tg,this.messageDataHandler=Jh,this.messageHistory=og,this.messageSender.init(),this.messageFactory.init(),this.messageAction.init(),this.messageReceiver.init(),this.messageDataHandler.init(),sn({auth:ng,params:sg}),Yt.notificationCenter.subscribeInnerEvent(ts.LOGOUT,this._reset,this),Yt.notificationCenter.subscribeInnerEvent(ts.DESTROY,this._dispose,this)},[{key:"_reset",value:function _reset(){this.messageHistory.reset()}},{key:"_dispose",value:function _dispose(){this._reset(),Yt.notificationCenter.unSubscribeInnerEvent(ts.LOGOUT,this._reset,this),Yt.notificationCenter.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this)}}])}();const rg="Tag_Profile_IM_",ag={NICK:`${rg}Nick`,GENDER:`${rg}Gender`,BIRTHDAY:`${rg}BirthDay`,LOCATION:`${rg}Location`,SELFSIGNATURE:`${rg}SelfSignature`,ALLOWTYPE:`${rg}AllowType`,LANGUAGE:`${rg}Language`,AVATAR:`${rg}Image`,MESSAGESETTINGS:`${rg}MsgSettings`,ADMINFORBIDTYPE:`${rg}AdminForbidType`,LEVEL:`${rg}Level`,ROLE:`${rg}Role`},cg="Tag_Profile_Custom",ug="profileCustomField",gg={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:[]},pg=new Map([[ag.NICK,"nick"],[ag.GENDER,"gender"],[ag.BIRTHDAY,"birthday"],[ag.LOCATION,"location"],[ag.SELFSIGNATURE,"selfSignature"],[ag.ALLOWTYPE,"allowType"],[ag.LANGUAGE,"language"],[ag.AVATAR,"avatar"],[ag.MESSAGESETTINGS,"messageSettings"],[ag.ADMINFORBIDTYPE,"adminForbidType"],[ag.LEVEL,"level"],[ag.ROLE,"role"]]);var _g=new(function(){return _createClass(function _class143(){_classCallCheck(this,_class143)},[{key:"createProfile",value:function createProfile(e,t){const s={userID:e,profileCustomField:[]};return t.forEach(e=>{const{tag:t,value:n}=e;t&&t.indexOf(cg)>-1?s.profileCustomField.push({key:t,value:n}):pg.has(t)&&(s[pg.get(t)]=n)}),Object.assign(Object.assign({},gg),s)}},{key:"parseProfileItem",value:function parseProfileItem(e=[]){const t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.Value})}),t}},{key:"parseProfileList",value:function parseProfileList(e=[]){const t=[];return e.forEach(e=>{t.push({tag:e.Tag,value:e.ValueBytes})}),t}},{key:"convertParamsToProfile",value:function convertParamsToProfile(e){const t=[];return Object.keys(e).forEach(s=>{s!==ug&&t.push({tag:ag[s.toUpperCase()],value:e[s]})}),e.profileCustomField&&n(e.profileCustomField)&&e.profileCustomField.forEach(e=>{t.push({tag:e.key,value:e.value})}),t}},{key:"normalizeProfileFields",value:function normalizeProfileFields(e){const t={},s=[];return e.forEach(e=>{const{tag:n,value:o}=e;if(n&&n.indexOf(cg)>-1&&s.push({key:n,value:o}),pg.has(n)&&void 0!==o){const e=pg.get(n);t[e]=o}}),s.length>0&&(t.profileCustomField=s),t}}])}());const{generateProtocolData:mg}=Yt.common;function vg(e){return pe(this,void 0,void 0,function*(){const t="profile.portrait_get_all",s={From_Account:_n(),UserItem:[]};e.forEach(e=>{s.UserItem.push({CustomSequence:0,StandardSequence:0,To_Account:e})});const n=mg({servcmd:t,data:s}),o=`${n.head.seq}${t}`,i=yield Yt.channel.sendPacket(n,{requestId:o});if(i)return function(e){const{ActionStatus:t,ErrorCode:s,ErrorDisplay:n,ErrorInfo:o,UserProfileItem:i}=e,r=[];return i.map(e=>{const{To_Account:t,CustomSequence:s,ResultCode:n,ResultInfo:o,StandardSequence:i,ProfileItem:a}=e,c=_g.parseProfileItem(a);r.push({userId:t,customSequence:s,resultCode:n,resultInfo:o,standardSequence:i,profileItem:c})}),{actionStatus:t,errorCode:s,errorDisplay:n,errorInfo:o,userProfile:r}}(i)})}function fg(e){return Wd.getFriendMap().has(e)}const{isEmpty:Ig}=Yt.utils;let Eg=function(){return _createClass(function Eg(){_classCallCheck(this,Eg),this._strangerProfileMap=new Map},[{key:"init",value:function init(){zd.getInstance().registerApi({apiName:"getMyProfile",context:this}),zd.getInstance().registerApi({apiName:"getUserProfile",context:this}),zd.getInstance().registerApi({apiName:"updateMyProfile",context:this}),this.createProfile=_g.createProfile.bind(_g);const{notificationCenter:e}=Yt;on.getInstance().registerWorkflowStep(Ms.SYNC_SERVER_INFO_AFTER_LOGIN,ys.USER_PROFILE_SYNC,this.getMyProfileCacheThenServer,this),e.subscribeInnerEvent(ts.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.subscribeInnerEvent(ts.LOGOUT,this._reset,this),e.subscribeInnerEvent(ts.DESTROY,this._dispose,this)}},{key:"getMyProfile",value:function getMyProfile(){return pe(this,void 0,void 0,function*(){try{const e=_n(),t=yield vg([e]);if(t){const s=this._handleProfileFormResponse(t)[0];return Wd.getUserProfileMap().set(e,s),{code:0,data:s}}}catch(e){const{errorCode:t,errorInfo:s}=e;throw new Ws({functionName:"getMyProfile",code:t,message:s})}})}},{key:"getUserProfile",value:function getUserProfile(e){return pe(this,void 0,void 0,function*(){try{let{userIDList:t}=e;const{userIdListToRequest:s,profileFromCache:o}=this._filterRequestAndCacheUsers(t);if(0===s.length)return{code:0,data:o,successLog:{message:`userIDList.length:${t.length}`}};s.length>1e3&&(Yt.ssoLog.warn("getUserProfile","userIdListToRequest.length > 1000"),s.length=1e3);const{data:i,error:r}=yield this._batchFetchUserProfiles(s),a=s.length,c=i.length,u=a-c;if(0===o.length&&a===u&&!Ig(r))throw r;if(n(i)){i.forEach(e=>{fg(e.userID)?Wd.getUserProfileMap().set(e.userID,e):this._strangerProfileMap.set(e.userID,e)});return{code:0,data:i.concat(o),successLog:{message:`getUserProfile query:${a} success:${c} fail:${u} from cache:${o.length}`}}}}catch(e){throw new Ws(e)}})}},{key:"getMyProfileCacheThenServer",value:function getMyProfileCacheThenServer(){return pe(this,void 0,void 0,function*(){const e=_n(),t=Wd.getUserProfileMap().has(e);return t?{code:0,data:t}:this.getMyProfile()})}},{key:"updateMyProfile",value:function updateMyProfile(e){return pe(this,void 0,void 0,function*(){const t=_n(),s={};for(const t in e)void 0!==e[t]&&(s[t]=e[t]);const n=_g.convertParamsToProfile(s);try{const e={From_Account:t,ProfileItem:n};yield function(e){return pe(this,void 0,void 0,function*(){const t="profile.portrait_set",s=mg({servcmd:t,data:e}),n=`${s.head.seq}${t}`,o=yield Yt.channel.sendPacket(s,{requestId:n});if(o){const{ActionStatus:e,ErrorCode:t,ErrorDisplay:s,ErrorInfo:n}=o;return{actionStatus:e,errorCode:t,errorDisplay:s,errorInfo:n}}})}(e);const o=Wd.getUserProfile(t);let i;i=o?Object.assign(Object.assign({},o),s):_g.createProfile(t,n);const r=!Jt(o,i,["lastUpdatedTime"]);return i.lastUpdatedTime=Date.now(),Wd.getUserProfileMap().set(t,i),r&&this._emitProfileUpdated(i),{code:0,data:i,successLog:{message:`profileArray: ${Yt.utils.safeStringify(n)}`}}}catch(t){const{errorCode:s,errorInfo:n}=t;throw new Ws({functionName:"updateMyProfile",code:s,message:n,moreMessage:`params: ${Yt.utils.safeStringify(e)}`})}})}},{key:"updateMyNickAndAvatar",value:function updateMyNickAndAvatar(e){return pe(this,void 0,void 0,function*(){const t=_n(),s=Date.now(),n=Wd.getUserProfile(t);let o={};o=n?Object.assign(n,e):_g.createProfile(t,e),o.lastUpdatedTime=s,Wd.getUserProfileMap().set(t,o)})}},{key:"_onProfileDataModify",value:function _onProfileDataModify(e){const t=function(e){const{Profile_Account:t,PushType:s,ProfileList:n}=e;return{userId:t,pushType:s,profileList:_g.parseProfileList(n)}}(e.ProfileDataMod[0]);if(Ig(t))return;const{isProfileUpdated:s,profile:n}=this._handleProfileModified(t);s&&this._emitProfileUpdated(n)}},{key:"_emitProfileUpdated",value:function _emitProfileUpdated(e){Yt.notificationCenter.emitInnerEvent(ts.PROFILE_UPDATE,{name:ts.PROFILE_UPDATE,data:[e]}),Yt.notificationCenter.emitOuterEvent(Zt.PROFILE_UPDATED,{name:Zt.PROFILE_UPDATED,data:[e]}),Bd.updateConversation(`C2C${null==e?void 0:e.userID}`,{userProfile:e})}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e}=Yt;e.unSubscribeInnerEvent(ts.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(ts.MESSAGE_PUSH,e.InnerEventSubType.PROFILE_MODIFIED,this._onProfileDataModify,this),e.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this),this._reset()}},{key:"_handleProfileModified",value:function _handleProfileModified(e){const{userId:t,profileList:s}=e,n=Wd.getUserProfile(t);if(!(_n()===t||fg(t)&&n))return{isProfileUpdated:!1,profile:null};const o=_g.normalizeProfileFields(s),i=Object.keys(o).some(e=>e===ug?this._isCustomFieldChanged(n.profileCustomField,o.profileCustomField):n[e]!==o[e]);if(!i)return{isProfileUpdated:!1,profile:n};const r=Date.now(),a=Object.prototype.hasOwnProperty.call(o,ug)?this._mergeProfileCustomField(n.profileCustomField,o.profileCustomField):n.profileCustomField,c=Object.assign(Object.assign(Object.assign({},n),o),{profileCustomField:a,lastUpdatedTime:r});return Wd.getUserProfileMap().set(t,c),{isProfileUpdated:i,profile:c}}},{key:"_filterRequestAndCacheUsers",value:function _filterRequestAndCacheUsers(e){const t=[],s=[];return e.forEach(e=>{const n=Wd.getUserProfileMap().has(e);fg(e)&&n?s.push(Wd.getUserProfile(e)):this._isStrangerAndProfileValid(e)?s.push(this._strangerProfileMap.get(e)):t.push(e)}),{userIdListToRequest:t,profileFromCache:s}}},{key:"_handleProfileFormResponse",value:function _handleProfileFormResponse(e){const{userProfile:t}=e;if(!Array.isArray(t))return[];const s=t.filter(e=>"@TLS#NOT_FOUND"!==e.userId&&""!==e.userId&&!Ig(e.profileItem)),n=Date.now();return s.map(e=>{const t=_g.createProfile(e.userId,e.profileItem);return t.lastUpdatedTime=n,t})}},{key:"_isStrangerAndProfileValid",value:function _isStrangerAndProfileValid(e){var t;if(!fg(e)){const{lastUpdatedTime:s=0}=this._strangerProfileMap.get(e)||{},n=(null===(t=Yt.store.get("cloudConfig"))||void 0===t?void 0:t.stranger_profile_expiration_time)||6e5;return Date.now()-s<=n}return!1}},{key:"_chunkUserIDList",value:function _chunkUserIDList(e,t){return Array.from({length:Math.ceil(e.length/t)},(s,n)=>e.slice(n*t,(n+1)*t))}},{key:"_batchFetchUserProfiles",value:function _batchFetchUserProfiles(e){return pe(this,void 0,void 0,function*(){const t=[],s=[];let o={};return this._chunkUserIDList(e,100).forEach(e=>{t.push(vg(e))}),(yield Promise.allSettled(t)).forEach(e=>{if("fulfilled"===e.status){const t=e.value,o=this._handleProfileFormResponse(t);n(o)&&s.push(...o)}else if("rejected"===e.status){const{code:t,message:s}=e.reason||{};o={errorCode:t,message:s}}}),{data:s,error:o}})}},{key:"_isCustomFieldChanged",value:function _isCustomFieldChanged(e=[],t=[]){if(!n(t)||0===t.length)return!1;if(!n(e)||0===e.length)return!0;const s=new Map(e.map(e=>[e.key,e.value]));return t.some(e=>s.get(e.key)!==e.value)}},{key:"_mergeProfileCustomField",value:function _mergeProfileCustomField(e=[],t=[]){const s=n(e)?e.map(e=>Object.assign({},e)):[];return n(t)&&0!==t.length?(t.forEach(({key:e,value:t})=>{const n=s.find(t=>t.key===e);n?n.value=t:s.push({key:e,value:t})}),s):s}},{key:"_reset",value:function _reset(){Wd.getUserProfileMap().clear(),this._strangerProfileMap.clear()}}])}();const Sg=new Map,Cg=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=Cg.length;e<t;e++)Sg.set(e,Cg[e]);function Mg(e){if(!e)return"";const t=String(e).replace(/[=]+$/,"");let s="";if(t.length%4==1)return"";for(let e,n,o=0,i=0;n=t.charAt(i++);~n&&(e=o%4?64*e+n:n,o++%4)?s+=String.fromCharCode(255&e>>(-2*o&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);try{return decodeURIComponent(escape(s))}catch(e){return console.warn(e),""}}const{isEmpty:yg}=Yt.utils,{generateProtocolData:Og}=Yt.common;function Tg(e){const t=[];return null==e||e.forEach(e=>{const{Platform:s,Status:n}=e;"Online"===n&&t.push(s)}),t}let Rg=function(){return _createClass(function Rg(){_classCallCheck(this,Rg),this._customStatus=""},[{key:"init",value:function init(){const{notificationCenter:e}=Yt;zd.getInstance().registerApi({apiName:"getUserStatus",context:this}),zd.getInstance().registerApi({apiName:"setSelfStatus",context:this}),zd.getInstance().registerApi({apiName:"subscribeUserStatus",context:this}),zd.getInstance().registerApi({apiName:"unsubscribeUserStatus",context:this}),on.getInstance().registerWorkflowStep(Ms.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ys.USER_STATUS_UPDATE,this._onReOnline,this),e.subscribeInnerEvent(ts.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.subscribeInnerEvent(ts.LOGOUT,this._reset,this),e.subscribeInnerEvent(ts.DESTROY,this._dispose,this)}},{key:"setSelfStatus",value:function setSelfStatus(e){return pe(this,void 0,void 0,function*(){const t=_n(),{customStatus:s}=e;try{return yield function(e){return pe(this,void 0,void 0,function*(){const t="im_open_status.ws_set_custom_status",s=Og({servcmd:t,data:{CustomStatus:e}}),n=`${s.head.seq}${t}`,o=yield Yt.channel.sendPacket(s,{requestId:n});if(o){const{ErrorCode:e,ErrorInfo:t}=o;return{errorCode:e,errorInfo:t}}})}(s),this._customStatus=s,{code:0,data:{userID:t,statusType:1,customStatus:s},successLog:{message:`customStatus: ${s}`}}}catch(e){const{errorCode:t,errorInfo:s}=e;throw new Ws({functionName:"setSelfStatus",code:t,message:s})}})}},{key:"getUserStatus",value:function getUserStatus(e){return pe(this,void 0,void 0,function*(){const{userIDList:t=[]}=e;if(this._isOnlyMeInArray(t))return this._getMyStatus();const s=yield this._getUserStatus(t);return Object.assign(Object.assign({},s),{successLog:{message:`userIDList length: ${t.length}`}})})}},{key:"setCustomStatus",value:function setCustomStatus(e){const t=Mg(e);this._customStatus=t}},{key:"subscribeUserStatus",value:function subscribeUserStatus(e){return pe(this,void 0,void 0,function*(){try{const{userIDList:t=[]}=e;this._checkBusinessCapabilityBits("subscribeUserStatus");const s=this._getMaxUserCount("subscribe"),n=this._sliceUserIDList(t,s),o=yield function(e){return pe(this,void 0,void 0,function*(){const{channel:t}=Yt,s="im_open_status.ws_status_subscribe",n=Og({servcmd:s,data:{To_Account:e}}),o=`${n.head.seq}${s}`;return yield t.sendPacket(n,{requestId:o})})}(n),i=this._parseResponse(o);return{code:0,data:{failureUserList:i},successLog:{message:`userID length:${t.length} failCount: ${i.length}`}}}catch(e){const{errorCode:t}=e;throw new Ws({functionName:"subscribeUserStatus",code:t})}})}},{key:"unsubscribeUserStatus",value:function unsubscribeUserStatus(e){return pe(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("unsubscribeUserStatus");const{userIDList:t=[]}=e,s=this._getMaxUserCount("unsubscribe"),n=this._sliceUserIDList(t,s),o=yield function(e){return pe(this,void 0,void 0,function*(){const{channel:t}=Yt,s="im_open_status.ws_status_unsubscribe";let n={};n=0===e.length?{UnsubscribeAll:1}:{To_Account:e};const o=Og({servcmd:s,data:n}),i=`${o.head.seq}${s}`;return yield t.sendPacket(o,{requestId:i})})}(n),i=this._parseResponse(o);return{code:0,data:{failureUserList:i},successLog:{message:`userID length:${t.length} failCount: ${i.length}`}}}catch(e){const{errorCode:t}=e;throw new Ws({functionName:"unsubscribeUserStatus",code:t})}})}},{key:"_onUserStatusUpdate",value:function _onUserStatusUpdate(e){const{UserStatusList:t=[]}=e||{},s=t.map(e=>{const{To_Account:t,Status:s,CustomStatus:n,Platform:o}=e,i={userID:t,statusType:s,customStatus:Mg(n)};return o&&(i.onlineDevices=o),i});this._emitUserStatusUpdatedEvent(s)}},{key:"_onReOnline",value:function _onReOnline(e){const t=Mg(e.data.customStatus);if(this._customStatus===t)return;this._customStatus=t;const s={userID:_n(),statusType:1,customStatus:t};this._emitUserStatusUpdatedEvent(s)}},{key:"_emitUserStatusUpdatedEvent",value:function _emitUserStatusUpdatedEvent(e){Yt.notificationCenter.emitOuterEvent(Zt.USER_STATUS_UPDATED,{name:Zt.USER_STATUS_UPDATED,data:e})}},{key:"_sliceUserIDList",value:function _sliceUserIDList(e,t){return e.slice(0,t)}},{key:"_parseResponse",value:function _parseResponse(e){const{ErrorList:t=[]}=e;return t.map(e=>{const{To_Account:t,Invalid_Account:s,ErrorCode:n,ErrorInfo:o}=e;return{userID:Yt.utils.isEmpty(s)?t:s,code:n,message:o}})}},{key:"_checkBusinessCapabilityBits",value:function _checkBusinessCapabilityBits(e){if(!Yt.store.get("commercialConfig").get("USER_STATUS"))throw new Ws({functionName:e,code:Ss.NO_USE,replacement1:e})}},{key:"_getMaxUserCount",value:function _getMaxUserCount(e){const t=Yt.store.get("cloudConfig")||{},{key:n,default:o}={query:{key:"status_query_count",default:500},subscribe:{key:"status_sub_count",default:100},unsubscribe:{key:"status_unsub_count",default:100}}[e],i=t[n]||o;return parseInt(i,10)}},{key:"_getMyStatus",value:function _getMyStatus(){return{code:0,data:{successUserList:[{userID:_n(),statusType:1,customStatus:this._customStatus}],failureUserList:[]}}}},{key:"_getUserStatus",value:function _getUserStatus(e){return pe(this,void 0,void 0,function*(){try{this._checkBusinessCapabilityBits("getUserStatus");const t=this._getMaxUserCount("query"),s=this._sliceUserIDList(e,t),n=yield function Ag(e){return pe(this,void 0,void 0,function*(){const t="im_open_status.ws_get_user_status",s=Og({servcmd:t,data:{To_Account:e}}),n=`${s.head.seq}${t}`,o=yield Yt.channel.sendPacket(s,{requestId:n});if(o)return function(e){const{ErrorCode:t,ErrorInfo:s,ErrorList:n=[],UserStatusList:o=[]}=e,i=o.map(e=>{const{To_Account:t,Status:s,CustomStatus:n,Detail:o=[]}=e;return{userID:t,statusType:s,customStatus:Mg(n),onlineDevices:Tg(o)}}),r=n.map(e=>{const{To_Account:t,Invalid_Account:s,ErrorCode:n,ErrorInfo:o}=e;return{userID:yg(s)?t:s,code:n,message:o}});return{errorCode:t,errorInfo:s,successUserList:i,failureUserList:r}}(o)})}(s),{successUserList:o,failureUserList:i}=n||{};return{code:0,data:{successUserList:o,failureUserList:i}}}catch(e){const{errorCode:t}=e;throw new Ws({functionName:"getUserStatus",code:t})}})}},{key:"_isOnlyMeInArray",value:function _isOnlyMeInArray(e){const t=_n();return 1===e.length&&e.indexOf(t)>-1}},{key:"_dispose",value:function _dispose(){const{notificationCenter:e}=Yt;e.unSubscribeInnerEvent(ts.MESSAGE_PUSH,e.InnerEventSubType.USER_STATUS_UPDATE,this._onUserStatusUpdate,this),e.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this),e.unSubscribeInnerEvent(ts.LOGOUT,this._reset,this),this._reset()}},{key:"_reset",value:function _reset(){this._customStatus=""}}])}();const Dg={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(const 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?void 0:t.key.startsWith(cg)))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}}},bg={getMyProfile:!0,getUserProfile:!0,updateMyProfile:!0,setSelfStatus:!0,getUserStatus:!0,subscribeUserStatus:!0,unsubscribeUserStatus:!0};let Ng=_createClass(function Ng(){_classCallCheck(this,Ng),this.userProfile=new Eg,this.userStatus=new Rg,this.userProfile.init(),this.userStatus.init(),sn({auth:bg,params:Dg})});function Lg(e){const s=[];if(!t(e))return s;const n=e.length;if(0===n)return s;for(let t=n-1;t>=0;t--)"1"===e[t]&&s.push(2**(n-t-1));return s}var Pg,Gg,wg;!function(e){e.NOT_START="notStart",e.PENDING="pending",e.RESOLVED="resolved",e.REJECTED="rejected"}(Pg||(Pg={})),function(e){e[e.C2C=1]="C2C",e[e.GROUP=2]="GROUP"}(Gg||(Gg={})),function(e){e[e.C2C=8]="C2C",e[e.GROUP=2]="GROUP"}(wg||(wg={}));let Ug=function(){return _createClass(function Ug(){_classCallCheck(this,Ug),this._name="SyncConversationHandler",this._pagingStatus=Pg.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0},[{key:"init",value:function init(){const{notificationCenter:e}=Yt;on.getInstance().registerWorkflowStep(Ms.SYNC_SERVER_INFO_AFTER_RE_ONLINE,ys.CONVERSATION_RECOVER,this._syncConversationList,this),on.getInstance().registerWorkflowStep(Ms.SYNC_SERVER_INFO_AFTER_LOGIN,ys.CONVERSATION_LIST_SYNC,this._syncConversationListAfterLogin,this),e.subscribeInnerEvent(ts.LOGOUT,this._reset,this),e.subscribeInnerEvent(ts.DESTROY,this._dispose,this),Yt.ssoLog.debug(`${this._name}.init`)}},{key:"isSyncCompleted",value:function isSyncCompleted(){return this._pagingStatus===Pg.RESOLVED}},{key:"_syncConversationListAfterLogin",value:function _syncConversationListAfterLogin(){return pe(this,void 0,void 0,function*(){return this._pagingStatus=Pg.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0,this._syncConversationList()})}},{key:"_syncConversationList",value:function _syncConversationList(){return pe(this,void 0,void 0,function*(){const{ssoLog:e,utils:{safeStringify:t}}=Yt;e.debug("_syncConversationList","start");try{const t=yield this._pagingGetConversationList(!0);this._pagingStatus=Pg.RESOLVED;const{conversationList:s=[]}=t||{};return e.info("_syncConversationList",`success count:${s.length}`),t}catch(s){const n=new Ws(s);e.error("_syncConversationList",`fail ${t(s)}`,{error:n})}})}},{key:"_pagingGetConversationList",value:function _pagingGetConversationList(e){return pe(this,void 0,void 0,function*(){try{const t=[];this._pagingStatus=Pg.PENDING;const s=yield function(e){return pe(this,void 0,void 0,function*(){const{fromAccount:t,pagingTimeStamp:s,pagingStartIndex:n,pagingPinnedTimeStamp:o,pagingPinnedStartIndex:i}=e;return dn({servcmd:"recentcontact.page_get",data:{AssistFlags:31,MsgAssistFlags:15,OrderType:1,From_Account:t,StartIndex:n,TimeStamp:s,TopStartIndex:i,TopTimeStamp:o}})})}({fromAccount:_n(),pagingTimeStamp:e?this._pagingTimeStamp:0,pagingStartIndex:e?this._pagingStartIndex:0,pagingPinnedTimeStamp:e?this._pagingPinnedTimeStamp:0,pagingPinnedStartIndex:e?this._pagingPinnedStartIndex:0}),{CompleteFlag:n,SessionItem:o=[],TimeStamp:i,StartIndex:r,TopTimeStamp:a,TopStartIndex:c}=s||{};let u=[];if(1===n&&(this._pagingStatus=Pg.RESOLVED),o.length>0&&(u=this._getConversationOptions(o),t.push(...u)),Yt.notificationCenter.emitInnerEvent(ts.SYNC_CONVERSATION_LIST,{conversationUpdateFieldList:u}),this._pagingTimeStamp=i,this._pagingStartIndex=r,this._pagingPinnedTimeStamp=a,this._pagingPinnedStartIndex=c,1!==n){const{conversationList:s}=yield this._pagingGetConversationList(e);t.push(...s)}return{conversationList:t}}catch(e){throw e}})}},{key:"_getConversationOptions",value:function _getConversationOptions(e){const{utils:{isUndefined:t}}=Yt,s=this._convertConversationKey(e);return this._filterValidConversations(s).map(e=>(t(e.lastMsg)&&(e.lastMsg={elements:[]}),e.type===Gg.C2C?this._assembleC2COption(e):this._assembleGroupOption(e)))}},{key:"_filterValidConversations",value:function _filterValidConversations(e){return e.filter(({type:e,userID:t})=>e===Gg.C2C&&!function(e){let t;return e.startsWith(Es.CONV_C2C)&&(t=e.replace(Es.CONV_C2C,"")),"@TLS#ERROR"===t||"@TLS#NOT_FOUND"===t}(t)||2===e)}},{key:"_assembleC2COption",value:function _assembleC2COption(e){var t,s,n,o,i,r,a,c;const u=this._createUserprofile(e);return{conversationID:`${Es.CONV_C2C}${e.userID}`,type:Es.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:(null===(t=e.lastMsg)||void 0===t?void 0:t.elements[0])?null===(s=e.lastMsg)||void 0===s?void 0:s.elements[0].type:null,payload:(null===(n=e.lastMsg)||void 0===n?void 0:n.elements[0])?this._amendLayersOverLimitProp(e.lastMsg.elements[0].content):null,cloudCustomData:(null===(r=null===(i=null===(o=e.lastMsg)||void 0===o?void 0:o.elements)||void 0===i?void 0:i[0])||void 0===r?void 0:r.cloudCustomData)||"",isRevoked:e.lastMessageFlag===wg.C2C,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:this._computeIsPeerRead(e),revoker:(null===(c=null===(a=e.lastMsg)||void 0===a?void 0:a.revokerInfo)||void 0===c?void 0:c.revoker)||null},unreadCount:0,userProfile:u,peerReadTime:e.peerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Lg(e.standardMark),conversationGroupList:[],remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}}},{key:"_createUserprofile",value:function _createUserprofile(e){var t;const{userID:s,nick:n,peerAvatar:o}=e,i=[{tag:"Tag_Profile_IM_Nick",value:n},{tag:"Tag_Profile_IM_Image",value:o}];return null===(t=Yt.user.userProfile)||void 0===t?void 0:t.createProfile(s,i)}},{key:"_computeIsPeerRead",value:function _computeIsPeerRead(e){const t=_n(),{lastC2CMsgFromAccount:s,time:n,c2cPeerReadTime:o}=e;return s===t&&n<=o}},{key:"_assembleGroupOption",value:function _assembleGroupOption(e){var t,s,n,o,i;return{conversationID:`${Es.CONV_GROUP}${e.groupID}`,type:Es.CONV_GROUP,lastMessage:Object.assign(Object.assign({lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount},this._patchTypeAndPayload(e)),{cloudCustomData:(null===(n=null===(s=null===(t=e.lastMsg)||void 0===t?void 0:t.elements)||void 0===s?void 0:s[0])||void 0===n?void 0:n.cloudCustomData)||"",isRevoked:e.lastMessageFlag===wg.GROUP,onlineOnlyFlag:!1,nick:e.msgGroupFromNickName||"",nameCard:e.msgGroupFromCardName||"",revoker:(null===(i=null===(o=e.lastMsg)||void 0===o?void 0:o.revokerInfo)||void 0===i?void 0:i.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:Lg(e.standardMark),conversationGroupList:[],messageRemindType:this._transMsgRemindType(e.messageRemindType),subType:e.groupType}}},{key:"_convertConversationKey",value:function _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}))}},{key:"_convertLastMsgKey",value:function _convertLastMsgKey(e){var t,s,n;const{utils:{isEmpty:o}}=Yt;if(o(e))return null;let i="",r=null;if(!o(e.GroupTips)){const{From_Account:s,GroupName:n}=(null===(t=e.GroupTips)||void 0===t?void 0:t.GroupInfo)||{};i=Es.MSG_GRP_TIP,r=Object.assign(Object.assign({},this._parseContent(i,e.GroupTips.MsgBody)),{groupProfile:{from:s,groupName:n}})}return e.MsgBody&&(i=null===(s=e.MsgBody[0])||void 0===s?void 0:s.MsgType,r=this._parseContent(i,e.MsgBody[0])),{event:e.Event,elements:[{type:i,content:r,cloudCustomData:e.CloudCustomData}],revokerInfo:{revoker:null===(n=e.RevokerInfo)||void 0===n?void 0:n.Revoker_Account}}}},{key:"_parseContent",value:function _parseContent(e,t){var s;if(!t)return t;const n=Yt.message.messageFactory.getElementClass(e);return n?null===(s=n.parseServerPushElement(t))||void 0===s?void 0:s.content:t}},{key:"_amendLayersOverLimitProp",value:function _amendLayersOverLimitProp(e){const{LayersOverLimit:t}=e;return ge(e,["LayersOverLimit"]).layersOverLimit=1===t,e}},{key:"_transMsgRemindType",value:function _transMsgRemindType(e){let t="";return 0===e?t=Es.MSG_REMIND_ACPT_AND_NOTE:1===e?t=Es.MSG_REMIND_DISCARD:2===e?t=Es.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=Es.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}},{key:"_patchTypeAndPayload",value:function _patchTypeAndPayload(e){var t;const{utils:{isUndefined:s}}=Yt,{event:n,elements:o=[]}=e.lastMsg||{};return s(n)?{type:o[0]?o[0].type:null,payload:o[0]?this._amendLayersOverLimitProp(o[0].content):null}:{type:Es.MSG_GRP_TIP,payload:(null===(t=null==o?void 0:o[0])||void 0===t?void 0:t.content)||{}}}},{key:"_computeGroupUnreadCount",value:function _computeGroupUnreadCount(e){const{unreadCount:t=0,noUnreadCount:s=0}=e,n=t-s;return n>0?n:0}},{key:"_reset",value:function _reset(){this._pagingStatus=Pg.NOT_START,this._pagingTimeStamp=0,this._pagingStartIndex=0,this._pagingPinnedTimeStamp=0,this._pagingPinnedStartIndex=0}},{key:"_dispose",value:function _dispose(){this._reset();const{notificationCenter:e}=Yt;e.unSubscribeInnerEvent(ts.LOGOUT,this._reset,this),e.unSubscribeInnerEvent(ts.DESTROY,this._dispose,this)}}])}(),kg=_createClass(function kg(){_classCallCheck(this,kg),this.syncConversationHandler=new Ug,this.syncConversationHandler.init()});console.log(`TencentCloudLiteChat.VERSION:${Ze}`);var Fg={create:function(e){var t,s;const{SDKAppID:n,testEnv:o=!1,devMode:i=!1,unlimitedAVChatRoom:r=!1,scene:a="",oversea:c=!1,instance:u,disableIndependentDomain:l=!1,proxyServer:d=""}=e;let h=n;if(!function(e){if("number"==typeof e)return!0;const t=Number(e);return!Number.isNaN(t)}(h))return console.error("Create SDK instance failed. Failed to parse the SDKAppID, please check the arguments"),null;if(h=Number(h),rn.has(h))return rn.get(h);let g=null;if(u)g=u,g._workflowManager&&on.setInstance(g._workflowManager),g._pluginManager&&g._pluginManager.installBuiltInPlugin(Fd),u.isReady()&&(null===(s=(t=on.getInstance()).executeWorkflow)||void 0===s||s.call(t,Ms.SYNC_SERVER_INFO_AFTER_LOGIN));else{const e=function(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return`${e()+e()}${e()}${e()}${e()}${e()}${e()}${e()}`}();Yt.init({sdkAppId:h,instanceId:e,testEnv:o,devMode:i,unlimitedAVChatRoom:r,disableIndependentDomain:l,scene:a,oversea:c,sdkEdition:kd,version:Ze,proxyServer:d}),on.getInstance().init(),Yt.message=new ig,Yt.user=new Ng,Yt.login=new Zd,Yt.conversation=new kg,Vd.getInstance().installBuiltInPlugin(Fd),g=zd.getInstance().exposeApiForClient(),g._workflowManager=on.getInstance(),g._pluginManager=Vd.getInstance();const{utils:{IS_WORKER_AVAILABLE:t,USER_AGENT:s,getPlatformType:u,isIOSWebView:p}}=Yt,_=`instanceID:${e} SDKAppID:${n} platform:${K} host:${u()} isIOSWebView:${p} workerAvailable:${t} UserAgent:${s}`;Yt.ssoLog.info("sdkConstruct",_)}return rn.set(h,g),g},TSignaling:ss,EVENT:Zt,VERSION:Ze,TYPES:Es};const LOG_LEVEL={trace:0,debug:1,info:2,log:2,warn:3,error:4,silent:5};let _logLevel=LOG_LEVEL.info;function formatTime(){const date=new Date,pad=(n,len=2)=>String(n).padStart(len,"0");return`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}:${pad(date.getMilliseconds(),3)}`}function createLogger(module=""){const prefix=module?`[${module}]`:"",appPrefix="VhallMiniSDK",enabled=level=>level>=_logLevel;return{trace:function trace(...args){enabled(LOG_LEVEL.trace)&&console.trace(`${appPrefix} [${formatTime()}] <TRACE> ${prefix} `,...args)},debug:function debug(...args){enabled(LOG_LEVEL.debug)&&console.debug(`${appPrefix} [${formatTime()}] <DEBUG> ${prefix} `,...args)},info:function info(...args){enabled(LOG_LEVEL.info)&&console.info(`${appPrefix} [${formatTime()}] <INFO> ${prefix}`,...args)},log:function log(...args){enabled(LOG_LEVEL.log)&&console.log(`${appPrefix} [${formatTime()}] <LOG> ${prefix}`,...args)},warn:function warn(...args){enabled(LOG_LEVEL.warn)&&console.warn(`${appPrefix} [${formatTime()}] <WARN> ${prefix}`,...args)},error:function error(...args){enabled(LOG_LEVEL.error)&&console.error(`${appPrefix} [${formatTime()}] <ERROR> ${prefix}`,...args)}}}const log={createLogger:createLogger,setLogLevel:function setLogLevel(level){if("number"!=typeof level){if("string"==typeof level){const lower=level.toLowerCase();if(void 0!==LOG_LEVEL[lower])return void(_logLevel=LOG_LEVEL[lower]);const num=Number(level);if(Number.isFinite(num))return void(_logLevel=num)}}else _logLevel=level},getLogLevel:function getLogLevel(){return _logLevel}},logger$6=createLogger("IM_tim");let Tim=function(){function Tim(options,msgIns,logReportServer){var _this;return _classCallCheck(this,Tim),(_this=_callSuper(this,Tim))._msgIns=msgIns,_this._logReportServer=logReportServer,_this.sdk_app_id=options.sdk_app_id,_this.user_id=options.user_id,_this.user_sig=options.user_sig,_this.group_list=options.group_list||[],_this.chatIns=null,_this.createTime=Date.now(),_this.retryCount=0,_this}return _inherits(Tim,EventEmitter),_createClass(Tim,[{key:"_report",value:function _report(code,data){this._logReportServer&&"function"==typeof this._logReportServer.report&&this._logReportServer.report(code,data).catch(()=>{})}},{key:"initialize",value:async function initialize(){logger$6.debug(`initialize retryCount=${this.retryCount}`),this._report(116999,{stage:"init_start",retryCount:this.retryCount}),this.retryCount++,this.chatIns||(this.chatIns=this._create()),this.chatIns&&(this.isReady()?await this.joinGroups(1):(logger$6.debug("登录 start"),await this._login()))}},{key:"_create",value:function _create(){if(this.chatIns)return this.chatIns;try{return this.chatIns=Fg.create({SDKAppID:this.sdk_app_id,unlimitedAVChatRoom:!0}),this.chatIns.setLogLevel(1),this.initEvents(),logger$6.debug("创建 TencentCloudChat 实例成功"),this._report(116999,{stage:"create_success"}),this.chatIns}catch(error){return logger$6.error("创建 TencentCloudChat 实例失败:",error),this._report(116999,{stage:"create_failed",logData:error}),this._handleTimInitFailed({type:"createTimInstanceFailed"}),null}}},{key:"_login",value:async function _login(){const params={userID:this.user_id,userSig:this.user_sig};logger$6.debug("登录参数",JSON.stringify(params));const[err,res]=await function to(promise,errorExt){return promise.then(function(data){return[null,data]}).catch(function(err){return[err,void 0]})}(this.chatIns.login(params));if(0===res?.code)logger$6.debug("登录成功","code=0"),this._report(116999,{stage:"login_success"});else if(2025===err?.code)logger$6.debug("重复登录","code=2025"),this._report(116999,{stage:"login_repeat"});else if(7501===res?.code)logger$6.debug("登录正在执行中",`res.code=${res.code}`),this._report(116999,{stage:"logining"});else{const result=err||res;logger$6.error("登录失败 login error:",result),this._report(116999,{stage:"login_failed",logData:result}),this._handleTimInitFailed({type:"loginFailed"})}}},{key:"joinGroups",value:async function joinGroups(scence=0){if(logger$6.debug(`joinGroups call scence=${scence}`),!this.chatIns)return;let promiseAllGroup=[];for(const group of this.group_list){let itemPromise=this.chatIns.joinGroup({groupID:group.group_id,type:group.group_type});promiseAllGroup.push(itemPromise)}const joinResult=await Promise.allSettled(promiseAllGroup),successGroupIds=[];for(let i=0;i<joinResult.length;i++){const rlt=joinResult[i];10013===rlt?.reason?.code||2903===rlt?.reason?.code||0===rlt?.value?.code?successGroupIds.push(this.group_list[i].group_id):logger$6.error("创建 加入群组失败:",rlt)}const isJoinAllSuccess=successGroupIds.length===this.group_list.length;return isJoinAllSuccess?(logger$6.debug("加入全部群组成功"),this._report(116999,{stage:"join_group_success"}),this.emit("evTimJoinGroupSuccess"),this._msgIns.emit(EVENT_TIM_JOIN_GROUP_SUCCESS)):(logger$6.error("加入全部群组失败"),this._report(116999,{stage:"join_group_failed",logData:joinResult.map(rlt=>rlt?.reason?.code)}),0!==scence&&1!==scence||this._handleTimInitFailed({type:"joinGroupFailed"}),this._msgIns.emit(EVENT_TIM_JOIN_GROUP_FAILED)),isJoinAllSuccess}},{key:"quitGroups",value:async function quitGroups(){if(logger$6.debug("quitGroups call"),!this.chatIns)return;const promisesArr=[];for(const group of this.group_list){let itemPromise=this.chatIns.quitGroup(group.group_id);promisesArr.push(itemPromise)}const quitResult=await Promise.allSettled(promisesArr);for(let i=0;i<quitResult.length;i++){const rlt=quitResult[i];"rejected"===rlt.status&&logger$6.error("quitGroups error.",JSON.stringify(rlt.reason))}return quitResult}},{key:"logout",value:function logout(){if(this.chatIns)return this.chatIns.logout().then(res=>(logger$6.debug(`logout success. code=${res?.code}`),res)).catch(error=>{if(2024===error.code)return logger$6.debug("logout success. code=2024"),error;throw logger$6.debug("logout failed. ",JSON.stringify(error)),error})}},{key:"isReady",value:function isReady(){return!!this.chatIns?.isReady()}},{key:"disconnect",value:async function disconnect(isQuitGroups=!1){if(this.removeEvents(),logger$6.debug("disconnect call"),this._report(116999,{stage:"disconnect"}),!this.chatIns)return logger$6.warn("tim chat instance is null when call the disconnect method"),!0;try{return isQuitGroups?(await this.quitGroups(),logger$6.debug("Tim destroy call"),await this.chatIns.destroy(),this.chatIns=null):(logger$6.debug("Tim logout call (keep instance for reconnect)"),await this.logout()),!0}catch(error){return logger$6.error("disconnect error:",JSON.stringify(error?.message)),!1}}},{key:"getSelfStatus",value:async function getSelfStatus(){if(!this.chatIns)return logger$6.debug("getSelfStatus: -1"),-1;return this.chatIns.getUserStatus({userIDList:[`${this.user_id}`]}).then(function(imResponse){const{successUserList:successUserList}=imResponse.data,selfItem=successUserList[0];return logger$6.debug(`getSelfStatus: ${selfItem.statusType}`),selfItem.statusType}).catch(function(imError){return logger$6.error("getSelfStatus: -2, error:",imError),-2})}},{key:"initEvents",value:function initEvents(){this.chatIns.on(Fg.EVENT.SDK_READY,this._onTimSdkReady,this),this.chatIns.on(Fg.EVENT.MESSAGE_RECEIVED,this._onTimMessageReceived,this),this.chatIns.on(Fg.EVENT.KICKED_OUT,this._onTimKickedOut,this),this.chatIns.on(Fg.EVENT.NET_STATE_CHANGE,this._onTimNetStateChange,this),this.chatIns.on(Fg.EVENT.ERROR,this._onTimError,this)}},{key:"removeEvents",value:function removeEvents(){this.chatIns&&(this.chatIns.off(Fg.EVENT.SDK_READY,this._onTimSdkReady,this),this.chatIns.off(Fg.EVENT.MESSAGE_RECEIVED,this._onTimMessageReceived,this),this.chatIns.off(Fg.EVENT.KICKED_OUT,this._onTimKickedOut,this),this.chatIns.off(Fg.EVENT.NET_STATE_CHANGE,this._onTimNetStateChange,this),this.chatIns.off(Fg.EVENT.ERROR,this._onTimError,this))}},{key:"_handleTimInitFailed",value:function _handleTimInitFailed(data){logger$6.error(`_handleTimInitFailed type=${data.type}`),this._report(116999,{stage:"handleTimInitFailed",failedType:data.type,retryCount:this.retryCount}),Date.now()-this.createTime<1e4&&setTimeout(()=>{this.initialize(1)},this.retryCount>0?200*this.retryCount:200)}},{key:"_onTimSdkReady",value:function _onTimSdkReady(event){logger$6.debug("sdk is ready"),this._report(116999,{stage:"sdk_ready"}),this.joinGroups(1)}},{key:"_onTimMessageReceived",value:function _onTimMessageReceived(event){logger$6.debug(`${function(date,format="HH:MM:SS.sss"){const hours=String(date.getHours()).padStart(2,"0"),minutes=String(date.getMinutes()).padStart(2,"0"),seconds=String(date.getSeconds()).padStart(2,"0"),milliseconds=String(date.getMilliseconds()).padStart(3,"0");let formatted=format;return formatted=formatted.replace("HH",hours).replace("MM",minutes).replace("SS",seconds).replace("sss",milliseconds),formatted}(new Date)} 触发 onMessageReceived 事件`,event);event.data.forEach(message=>{message.type===Fg.TYPES.MSG_TEXT?this.group_list.findIndex(g=>g.group_id===message.to)>-1&&this.emit("evMessageReceived",message.payload.text):message.type===Fg.TYPES.MSG_CUSTOM&&this.group_list.findIndex(g=>g.group_id===message.to)>-1&&this.emit("evMessageReceived",message.payload.data)})}},{key:"_onTimKickedOut",value:function _onTimKickedOut(event){logger$6.debug("触发 onKickedOut 事件",event.data.type),this._report(116999,{stage:"kicked_out",type:event.data.type}),this._msgIns.emit(EVENT_TIM_KICKED_OUT,event.data.type)}},{key:"_onTimNetStateChange",value:function _onTimNetStateChange(event){logger$6.debug("触发 onNetStateChange 事件",event.data.state),this._report(116999,{stage:"net_state_change",state:event.data.state}),event.data.state===Fg.TYPES.NET_STATE_CONNECTED&&this.isReady()&&this.joinGroups(2),this._msgIns.emit(EVENT_TIM_NET_STATE_CHANGE,event.data.state)}},{key:"_onTimError",value:function _onTimError(event){logger$6.debug("触发 error 事件",event),this._report(116999,{stage:"error",message:event}),this._msgIns.emit(EVENT_TIM_ERROR,event)}}])}();const IO=function requireWeapp_socket_io(){return hasRequiredWeapp_socket_io||(hasRequiredWeapp_socket_io=1,window,weapp_socket_io.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=18)}([function(t,e){t.exports=function(){return function(){}}},function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o=0;o<n.length;o++)if((r=n[o])===e||r.fn===e){n.splice(o,1);break}return this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),r=this._callbacks["$"+t];if(r)for(var n=0,o=(r=r.slice(0)).length;n<o;++n)r[n].apply(this,e);return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,r){var n,o=r(28),i=r(13),s=r(30),a=r(31),c=r(32);"undefined"!=typeof ArrayBuffer&&(n=r(33));var h="undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),u="undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),f=h||u;e.protocol=3;var p=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},l=o(p),d={type:"error",data:"parser error"},y=r(34);function g(t,e,r){for(var n=new Array(t.length),o=a(t.length,r),i=function(t,r,o){e(r,function(e,r){n[t]=r,o(e,n)})},s=0;s<t.length;s++)i(s,t[s],o)}e.encodePacket=function(t,r,n,o){"function"==typeof r&&(o=r,r=!1),"function"==typeof n&&(o=n,n=null);var i=void 0===t.data?void 0:t.data.buffer||t.data;if("undefined"!=typeof ArrayBuffer&&i instanceof ArrayBuffer)return function(t,r,n){if(!r)return e.encodeBase64Packet(t,n);var o=t.data,i=new Uint8Array(o),s=new Uint8Array(1+o.byteLength);s[0]=p[t.type];for(var a=0;a<i.length;a++)s[a+1]=i[a];return n(s.buffer)}(t,r,o);if(void 0!==y&&i instanceof y)return function(t,r,n){if(!r)return e.encodeBase64Packet(t,n);if(f)return function(t,r,n){if(!r)return e.encodeBase64Packet(t,n);var o=new FileReader;return o.onload=function(){e.encodePacket({type:t.type,data:o.result},r,!0,n)},o.readAsArrayBuffer(t.data)}(t,r,n);var o=new Uint8Array(1);return o[0]=p[t.type],n(new y([o.buffer,t.data]))}(t,r,o);if(i&&i.base64)return function(t,r){return r("b"+e.packets[t.type]+t.data.data)}(t,o);var s=p[t.type];return void 0!==t.data&&(s+=n?c.encode(String(t.data),{strict:!1}):String(t.data)),o(""+s)},e.encodeBase64Packet=function(t,r){var n,o="b"+e.packets[t.type];if(void 0!==y&&t.data instanceof y){var i=new FileReader;return i.onload=function(){var t=i.result.split(",")[1];r(o+t)},i.readAsDataURL(t.data)}try{n=String.fromCharCode.apply(null,new Uint8Array(t.data))}catch(e){for(var s=new Uint8Array(t.data),a=new Array(s.length),c=0;c<s.length;c++)a[c]=s[c];n=String.fromCharCode.apply(null,a)}return o+=btoa(n),r(o)},e.decodePacket=function(t,r,n){if(void 0===t)return d;if("string"==typeof t){if("b"===t.charAt(0))return e.decodeBase64Packet(t.substr(1),r);if(n&&!1===(t=function(t){try{t=c.decode(t,{strict:!1})}catch(t){return!1}return t}(t)))return d;var o=t.charAt(0);return Number(o)==o&&l[o]?t.length>1?{type:l[o],data:t.substring(1)}:{type:l[o]}:d}o=new Uint8Array(t)[0];var i=s(t,1);return y&&"blob"===r&&(i=new y([i])),{type:l[o],data:i}},e.decodeBase64Packet=function(t,e){var r=l[t.charAt(0)];if(!n)return{type:r,data:{base64:!0,data:t.substr(1)}};var o=n.decode(t.substr(1));return"blob"===e&&y&&(o=new y([o])),{type:r,data:o}},e.encodePayload=function(t,r,n){"function"==typeof r&&(n=r,r=null);var o=i(t);return r&&o?y&&!f?e.encodePayloadAsBlob(t,n):e.encodePayloadAsArrayBuffer(t,n):t.length?void g(t,function(t,n){e.encodePacket(t,!!o&&r,!1,function(t){n(null,function(t){return t.length+":"+t}(t))})},function(t,e){return n(e.join(""))}):n("0:")},e.decodePayload=function(t,r,n){if("string"!=typeof t)return e.decodePayloadAsBinary(t,r,n);var o;if("function"==typeof r&&(n=r,r=null),""===t)return n(d,0,1);for(var i,s,a="",c=0,h=t.length;c<h;c++){var u=t.charAt(c);if(":"===u){if(""===a||a!=(i=Number(a)))return n(d,0,1);if(a!=(s=t.substr(c+1,i)).length)return n(d,0,1);if(s.length){if(o=e.decodePacket(s,r,!1),d.type===o.type&&d.data===o.data)return n(d,0,1);if(!1===n(o,c+i,h))return}c+=i,a=""}else a+=u}return""!==a?n(d,0,1):void 0},e.encodePayloadAsArrayBuffer=function(t,r){if(!t.length)return r(new ArrayBuffer(0));g(t,function(t,r){e.encodePacket(t,!0,!0,function(t){return r(null,t)})},function(t,e){var n=e.reduce(function(t,e){var r;return t+(r="string"==typeof e?e.length:e.byteLength).toString().length+r+2},0),o=new Uint8Array(n),i=0;return e.forEach(function(t){var e="string"==typeof t,r=t;if(e){for(var n=new Uint8Array(t.length),s=0;s<t.length;s++)n[s]=t.charCodeAt(s);r=n.buffer}o[i++]=e?0:1;var a=r.byteLength.toString();for(s=0;s<a.length;s++)o[i++]=parseInt(a[s]);for(o[i++]=255,n=new Uint8Array(r),s=0;s<n.length;s++)o[i++]=n[s]}),r(o.buffer)})},e.encodePayloadAsBlob=function(t,r){g(t,function(t,r){e.encodePacket(t,!0,!0,function(t){var e=new Uint8Array(1);if(e[0]=1,"string"==typeof t){for(var n=new Uint8Array(t.length),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);t=n.buffer,e[0]=0}var i=(t instanceof ArrayBuffer?t.byteLength:t.size).toString(),s=new Uint8Array(i.length+1);for(o=0;o<i.length;o++)s[o]=parseInt(i[o]);if(s[i.length]=255,y){var a=new y([e.buffer,s.buffer,t]);r(null,a)}})},function(t,e){return r(new y(e))})},e.decodePayloadAsBinary=function(t,r,n){"function"==typeof r&&(n=r,r=null);for(var o=t,i=[];o.byteLength>0;){for(var a=new Uint8Array(o),c=0===a[0],h="",u=1;255!==a[u];u++){if(h.length>310)return n(d,0,1);h+=a[u]}o=s(o,2+h.length),h=parseInt(h);var f=s(o,0,h);if(c)try{f=String.fromCharCode.apply(null,new Uint8Array(f))}catch(t){var p=new Uint8Array(f);for(f="",u=0;u<p.length;u++)f+=String.fromCharCode(p[u])}i.push(f),o=s(o,h)}var l=i.length;i.forEach(function(t,o){n(e.decodePacket(t,r,!0),o,l)})}},function(t,e,r){var n=r(0)("socket.io-parser"),o=r(1),i=r(21),s=r(7),a=r(8);function c(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=c,e.Decoder=f;var h=e.ERROR+'"encode error"';function u(t){var r=""+t.type;if(e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(r+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(r+=t.nsp+","),null!=t.id&&(r+=t.id),null!=t.data){var o=function(t){try{return JSON.stringify(t)}catch(t){return!1}}(t.data);if(!1===o)return h;r+=o}return n("encoded %j as %s",t,r),r}function f(){this.reconstructor=null}function p(t){this.reconPack=t,this.buffers=[]}function l(t){return{type:e.ERROR,data:"parser error: "+t}}c.prototype.encode=function(t,r){n("encoding packet %j",t),e.BINARY_EVENT===t.type||e.BINARY_ACK===t.type?function(t,e){i.removeBlobs(t,function(t){var r=i.deconstructPacket(t),n=u(r.packet),o=r.buffers;o.unshift(n),e(o)})}(t,r):r([u(t)])},o(f.prototype),f.prototype.add=function(t){var r;if("string"==typeof t)r=function(t){var r=0,o={type:Number(t.charAt(0))};if(null==e.types[o.type])return l("unknown packet type "+o.type);if(e.BINARY_EVENT===o.type||e.BINARY_ACK===o.type){for(var i="";"-"!==t.charAt(++r)&&(i+=t.charAt(r),r!=t.length););if(i!=Number(i)||"-"!==t.charAt(r))throw new Error("Illegal attachments");o.attachments=Number(i)}if("/"===t.charAt(r+1))for(o.nsp="";++r&&","!==(c=t.charAt(r))&&(o.nsp+=c,r!==t.length););else o.nsp="/";var a=t.charAt(r+1);if(""!==a&&Number(a)==a){for(o.id="";++r;){var c;if(null==(c=t.charAt(r))||Number(c)!=c){--r;break}if(o.id+=t.charAt(r),r===t.length)break}o.id=Number(o.id)}if(t.charAt(++r)){var h=function(t){try{return JSON.parse(t)}catch(t){return!1}}(t.substr(r));if(!1===h||o.type!==e.ERROR&&!s(h))return l("invalid payload");o.data=h}return n("decoded %s as %j",t,o),o}(t),e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type?(this.reconstructor=new p(r),0===this.reconstructor.reconPack.attachments&&this.emit("decoded",r)):this.emit("decoded",r);else{if(!a(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");(r=this.reconstructor.takeBinaryData(t))&&(this.reconstructor=null,this.emit("decoded",r))}},f.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},p.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=i.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},p.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,r){(function(t){var n=r(22),o=r(23),i=r(24);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(s()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return f(this,t)}return h(this,t,e,r)}function h(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=p(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),o=(t=a(t,n)).write(e,r);return o!==n&&(t=t.slice(0,o)),t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|l(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):p(t,e);if("Buffer"===e.type&&i(e.data))return p(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function f(t,e){if(u(e),t=a(t,e<0?0:0|l(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function p(t,e){var r=e.length<0?0:0|l(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function l(t){if(t>=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|t}function d(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return q(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(t).length;default:if(n)return q(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return C(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return B(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function v(t,e,r,n,o){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=o?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(o)return-1;r=t.length-1}else if(r<0){if(!o)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,o);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,o);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,o){var i,s=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,c/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(o){var u=-1;for(i=r;i<a;i++)if(h(t,i)===h(e,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===c)return u*s}else-1!==u&&(i-=i-u),u=-1}else for(r+c>a&&(r=a-c),i=r;i>=0;i--){for(var f=!0,p=0;p<c;p++)if(h(t,i+p)!==h(e,p)){f=!1;break}if(f)return i}return-1}function b(t,e,r,n){r=Number(r)||0;var o=t.length-r;n?(n=Number(n))>o&&(n=o):n=o;var i=e.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var s=0;s<n;++s){var a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function w(t,e,r,n){return F(q(e,t.length-r),t,r,n)}function A(t,e,r,n){return F(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function k(t,e,r,n){return A(t,e,r,n)}function _(t,e,r,n){return F(Y(e),t,r,n)}function E(t,e,r,n){return F(function(t,e){for(var r,n,o,i=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,o=r%256,i.push(o),i.push(n);return i}(e,t.length-r),t,r,n)}function B(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],o=e;o<r;){var i,s,a,c,h=t[o],u=null,f=h>239?4:h>223?3:h>191?2:1;if(o+f<=r)switch(f){case 1:h<128&&(u=h);break;case 2:128==(192&(i=t[o+1]))&&(c=(31&h)<<6|63&i)>127&&(u=c);break;case 3:i=t[o+1],s=t[o+2],128==(192&i)&&128==(192&s)&&(c=(15&h)<<12|(63&i)<<6|63&s)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:i=t[o+1],s=t[o+2],a=t[o+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(c=(15&h)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,f=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),o+=f}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}function R(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(127&t[o]);return n}function O(t,e,r){var n="";r=Math.min(t.length,r);for(var o=e;o<r;++o)n+=String.fromCharCode(t[o]);return n}function C(t,e,r){var n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);for(var o="",i=e;i<r;++i)o+=D(t[i]);return o}function x(t,e,r){for(var n=t.slice(e,r),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function P(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function T(t,e,r,n,o,i){if(!c.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>o||e<i)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function N(t,e,r,n){e<0&&(e=65535+e+1);for(var o=0,i=Math.min(t.length-r,2);o<i;++o)t[r+o]=(e&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function L(t,e,r,n){e<0&&(e=4294967295+e+1);for(var o=0,i=Math.min(t.length-r,4);o<i;++o)t[r+o]=e>>>8*(n?o:3-o)&255}function j(t,e,r,n,o,i){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I(t,e,r,n,i){return i||j(t,0,r,4),o.write(t,e,r,n,23,4),r+4}function U(t,e,r,n,i){return i||j(t,0,r,8),o.write(t,e,r,n,52,8),r+8}e.Buffer=c,e.SlowBuffer=function(t){return+t!=t&&(t=0),c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=s(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return h(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,n){return u(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return f(null,t)},c.allocUnsafeSlow=function(t){return f(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,o=0,i=Math.min(r,n);o<i;++o)if(t[o]!==e[o]){r=t[o],n=e[o];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!i(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!c.isBuffer(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,o),o+=s.length}return n},c.byteLength=d,c.prototype._isBuffer=!0,c.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)g(this,e,e+1);return this},c.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},c.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},c.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?S(this,0,t):y.apply(this,arguments)},c.prototype.equals=function(t){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===c.compare(this,t)},c.prototype.inspect=function(){var t="",r=e.INSPECT_MAX_BYTES;return this.length>0&&(t=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(t+=" ... ")),"<Buffer "+t+">"},c.prototype.compare=function(t,e,r,n,o){if(!c.isBuffer(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),e<0||r>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&e>=r)return 0;if(n>=o)return-1;if(e>=r)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),a=Math.min(i,s),h=this.slice(n,o),u=t.slice(e,r),f=0;f<a;++f)if(h[f]!==u[f]){i=h[f],s=u[f];break}return i<s?-1:s<i?1:0},c.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},c.prototype.indexOf=function(t,e,r){return v(this,t,e,r,!0)},c.prototype.lastIndexOf=function(t,e,r){return v(this,t,e,r,!1)},c.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var o=this.length-e;if((void 0===r||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return b(this,t,e,r);case"utf8":case"utf-8":return w(this,t,e,r);case"ascii":return A(this,t,e,r);case"latin1":case"binary":return k(this,t,e,r);case"base64":return _(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,t,e,r);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),c.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=c.prototype;else{var o=e-t;r=new c(o,void 0);for(var i=0;i<o;++i)r[i]=this[i+t]}return r},c.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n},c.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t+--e],o=1;e>0&&(o*=256);)n+=this[t+--e]*o;return n},c.prototype.readUInt8=function(t,e){return e||P(t,1,this.length),this[t]},c.prototype.readUInt16LE=function(t,e){return e||P(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUInt16BE=function(t,e){return e||P(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUInt32LE=function(t,e){return e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},c.prototype.readUInt32BE=function(t,e){return e||P(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=this[t],o=1,i=0;++i<e&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*e)),n},c.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||P(t,e,this.length);for(var n=e,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*e)),i},c.prototype.readInt8=function(t,e){return e||P(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},c.prototype.readInt16LE=function(t,e){e||P(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(t,e){e||P(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(t,e){return e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,e){return e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readFloatLE=function(t,e){return e||P(t,4,this.length),o.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,e){return e||P(t,4,this.length),o.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,e){return e||P(t,8,this.length),o.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,e){return e||P(t,8,this.length),o.read(this,t,!1,52,8)},c.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);var o=1,i=0;for(this[e]=255&t;++i<r&&(o*=256);)this[e+i]=t/o&255;return e+r},c.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||T(this,t,e,r,Math.pow(2,8*r)-1,0);var o=r-1,i=1;for(this[e+o]=255&t;--o>=0&&(i*=256);)this[e+o]=t/i&255;return e+r},c.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,1,255,0),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},c.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):L(this,t,e,!0),e+4},c.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},c.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var i=0,s=1,a=0;for(this[e]=255&t;++i<r&&(s*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},c.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var i=r-1,s=1,a=0;for(this[e+i]=255&t;--i>=0&&(s*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/s|0)-a&255;return e+r},c.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,1,127,-128),c.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},c.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):N(this,t,e,!0),e+2},c.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):N(this,t,e,!1),e+2},c.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):L(this,t,e,!0),e+4},c.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),c.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):L(this,t,e,!1),e+4},c.prototype.writeFloatLE=function(t,e,r){return I(this,t,e,!0,r)},c.prototype.writeFloatBE=function(t,e,r){return I(this,t,e,!1,r)},c.prototype.writeDoubleLE=function(t,e,r){return U(this,t,e,!0,r)},c.prototype.writeDoubleBE=function(t,e,r){return U(this,t,e,!1,r)},c.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var o,i=n-r;if(this===t&&r<e&&e<n)for(o=i-1;o>=0;--o)t[o+e]=this[o+r];else if(i<1e3||!c.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+e]=this[o+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+i),e);return i},c.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!c.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{var s=c.isBuffer(t)?t:q(new c(t,n).toString()),a=s.length;for(i=0;i<r-e;++i)this[i+e]=s[i%a]}return this};var M=/[^+\/0-9A-Za-z-_]/g;function D(t){return t<16?"0"+t.toString(16):t.toString(16)}function q(t,e){var r;e=e||1/0;for(var n=t.length,o=null,i=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=65536+(o-55296<<10|r-56320)}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function Y(t){return n.toByteArray(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(M,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function F(t,e,r,n){for(var o=0;o<n&&!(o+r>=e.length||o>=t.length);++o)e[o+r]=t[o];return o}}).call(this,r(9))},function(t,e){e.encode=function(t){var e="";for(var r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e},e.decode=function(t){for(var e={},r=t.split("&"),n=0,o=r.length;n<o;n++){var i=r[n].split("=");e[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return e}},function(t,e){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,o=t.indexOf("["),i=t.indexOf("]");-1!=o&&-1!=i&&(t=t.substring(0,o)+t.substring(o,i).replace(/:/g,";")+t.substring(i,t.length));for(var s=r.exec(t||""),a={},c=14;c--;)a[n[c]]=s[c]||"";return-1!=o&&-1!=i&&(a.source=e,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,":"),a.authority=a.authority.replace("[","").replace("]","").replace(/;/g,":"),a.ipv6uri=!0),a}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){(function(e){t.exports=function(t){return r&&e.isBuffer(t)||n&&(t instanceof ArrayBuffer||function(t){return"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer}(t))};var r="function"==typeof e&&"function"==typeof e.isBuffer,n="function"==typeof ArrayBuffer}).call(this,r(4).Buffer)},function(t,e){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e,r){var n=r(25),o=r(15),i=r(1),s=r(3),a=r(16),c=r(17),h=r(0)("socket.io-client:manager"),u=r(14),f=r(49),p=Object.prototype.hasOwnProperty;function l(t,e){if(!(this instanceof l))return new l(t,e);t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.nsps={},this.subs=[],this.opts=e,this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(e.randomizationFactor||.5),this.backoff=new f({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this.readyState="closed",this.uri=t,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var r=e.parser||s;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this.autoConnect=!1!==e.autoConnect,this.autoConnect&&this.open()}t.exports=l,l.prototype.emitAll=function(){for(var t in this.emit.apply(this,arguments),this.nsps)p.call(this.nsps,t)&&this.nsps[t].emit.apply(this.nsps[t],arguments)},l.prototype.updateSocketIds=function(){for(var t in this.nsps)p.call(this.nsps,t)&&(this.nsps[t].id=this.generateId(t))},l.prototype.generateId=function(t){return("/"===t?"":t+"#")+this.engine.id},i(l.prototype),l.prototype.reconnection=function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection},l.prototype.reconnectionAttempts=function(t){return arguments.length?(this._reconnectionAttempts=t,this):this._reconnectionAttempts},l.prototype.reconnectionDelay=function(t){return arguments.length?(this._reconnectionDelay=t,this.backoff&&this.backoff.setMin(t),this):this._reconnectionDelay},l.prototype.randomizationFactor=function(t){return arguments.length?(this._randomizationFactor=t,this.backoff&&this.backoff.setJitter(t),this):this._randomizationFactor},l.prototype.reconnectionDelayMax=function(t){return arguments.length?(this._reconnectionDelayMax=t,this.backoff&&this.backoff.setMax(t),this):this._reconnectionDelayMax},l.prototype.timeout=function(t){return arguments.length?(this._timeout=t,this):this._timeout},l.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},l.prototype.open=l.prototype.connect=function(t,e){if(h("readyState %s",this.readyState),~this.readyState.indexOf("open"))return this;h("opening %s",this.uri),this.engine=n(this.uri,this.opts);var r=this.engine,o=this;this.readyState="opening",this.skipReconnect=!1;var i=a(r,"open",function(){o.onopen(),t&&t()}),s=a(r,"error",function(e){if(h("connect_error"),o.cleanup(),o.readyState="closed",o.emitAll("connect_error",e),t){var r=new Error("Connection error");r.data=e,t(r)}else o.maybeReconnectOnOpen()});if(!1!==this._timeout){var c=this._timeout;h("connect attempt will timeout after %d",c);var u=setTimeout(function(){h("connect attempt timed out after %d",c),i.destroy(),r.close(),r.emit("error","timeout"),o.emitAll("connect_timeout",c)},c);this.subs.push({destroy:function(){clearTimeout(u)}})}return this.subs.push(i),this.subs.push(s),this},l.prototype.onopen=function(){h("open"),this.cleanup(),this.readyState="open",this.emit("open");var t=this.engine;this.subs.push(a(t,"data",c(this,"ondata"))),this.subs.push(a(t,"ping",c(this,"onping"))),this.subs.push(a(t,"pong",c(this,"onpong"))),this.subs.push(a(t,"error",c(this,"onerror"))),this.subs.push(a(t,"close",c(this,"onclose"))),this.subs.push(a(this.decoder,"decoded",c(this,"ondecoded")))},l.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},l.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},l.prototype.ondata=function(t){this.decoder.add(t)},l.prototype.ondecoded=function(t){this.emit("packet",t)},l.prototype.onerror=function(t){h("error",t),this.emitAll("error",t)},l.prototype.socket=function(t,e){var r=this.nsps[t];if(!r){r=new o(this,t,e),this.nsps[t]=r;var n=this;r.on("connecting",i),r.on("connect",function(){r.id=n.generateId(t)}),this.autoConnect&&i()}function i(){~u(n.connecting,r)||n.connecting.push(r)}return r},l.prototype.destroy=function(t){var e=u(this.connecting,t);~e&&this.connecting.splice(e,1),this.connecting.length||this.close()},l.prototype.packet=function(t){h("writing packet %j",t);var e=this;t.query&&0===t.type&&(t.nsp+="?"+t.query),e.encoding?e.packetBuffer.push(t):(e.encoding=!0,this.encoder.encode(t,function(r){for(var n=0;n<r.length;n++)e.engine.write(r[n],t.options);e.encoding=!1,e.processPacketQueue()}))},l.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},l.prototype.cleanup=function(){h("cleanup");for(var t=this.subs.length,e=0;e<t;e++)this.subs.shift().destroy();this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},l.prototype.close=l.prototype.disconnect=function(){h("disconnect"),this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},l.prototype.onclose=function(t){h("onclose"),this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()},l.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)h("reconnect failed"),this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();h("will wait %dms before reconnect attempt",e),this.reconnecting=!0;var r=setTimeout(function(){t.skipReconnect||(h("attempting reconnect"),t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||t.open(function(e){e?(h("reconnect attempt error"),t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):(h("reconnect success"),t.onreconnect())}))},e);this.subs.push({destroy:function(){clearTimeout(r)}})}},l.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,r){const n=r(27);e.websocket=n},function(t,e,r){var n=r(2),o=r(1);function i(t){this.path=t.path,this.hostname=t.hostname,this.port=t.port,this.secure=t.secure,this.query=t.query,this.timestampParam=t.timestampParam,this.timestampRequests=t.timestampRequests,this.readyState="",this.agent=t.agent||!1,this.socket=t.socket,this.enablesXDR=t.enablesXDR,this.pfx=t.pfx,this.key=t.key,this.passphrase=t.passphrase,this.cert=t.cert,this.ca=t.ca,this.ciphers=t.ciphers,this.rejectUnauthorized=t.rejectUnauthorized,this.forceNode=t.forceNode,this.isReactNative=t.isReactNative,this.extraHeaders=t.extraHeaders,this.localAddress=t.localAddress}t.exports=i,o(i.prototype),i.prototype.onError=function(t,e){var r=new Error(t);return r.type="TransportError",r.description=e,this.emit("error",r),this},i.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},i.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},i.prototype.send=function(t){if("open"!==this.readyState)throw new Error("Transport not open");this.write(t)},i.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},i.prototype.onData=function(t){var e=n.decodePacket(t,this.socket.binaryType);this.onPacket(e)},i.prototype.onPacket=function(t){this.emit("packet",t)},i.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},function(t,e,r){(function(e){var n=r(29),o=Object.prototype.toString,i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===o.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===o.call(File);t.exports=function t(r){if(!r||"object"!=typeof r)return!1;if(n(r)){for(var o=0,a=r.length;o<a;o++)if(t(r[o]))return!0;return!1}if("function"==typeof e&&e.isBuffer&&e.isBuffer(r)||"function"==typeof ArrayBuffer&&r instanceof ArrayBuffer||i&&r instanceof Blob||s&&r instanceof File)return!0;if(r.toJSON&&"function"==typeof r.toJSON&&1===arguments.length)return t(r.toJSON(),!0);for(var c in r)if(Object.prototype.hasOwnProperty.call(r,c)&&t(r[c]))return!0;return!1}}).call(this,r(4).Buffer)},function(t,e){var r=[].indexOf;t.exports=function(t,e){if(r)return t.indexOf(e);for(var n=0;n<t.length;++n)if(t[n]===e)return n;return-1}},function(t,e,r){var n=r(3),o=r(1),i=r(48),s=r(16),a=r(17),c=r(0)("socket.io-client:socket"),h=r(5),u=r(13);t.exports=l;var f={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},p=o.prototype.emit;function l(t,e,r){this.io=t,this.nsp=e,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},r&&r.query&&(this.query=r.query),this.io.autoConnect&&this.open()}o(l.prototype),l.prototype.subEvents=function(){if(!this.subs){var t=this.io;this.subs=[s(t,"open",a(this,"onopen")),s(t,"packet",a(this,"onpacket")),s(t,"close",a(this,"onclose"))]}},l.prototype.open=l.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},l.prototype.send=function(){var t=i(arguments);return t.unshift("message"),this.emit.apply(this,t),this},l.prototype.emit=function(t){if(f.hasOwnProperty(t))return p.apply(this,arguments),this;var e=i(arguments),r={type:(void 0!==this.flags.binary?this.flags.binary:u(e))?n.BINARY_EVENT:n.EVENT,data:e,options:{}};return r.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof e[e.length-1]&&(c("emitting packet with ack id %d",this.ids),this.acks[this.ids]=e.pop(),r.id=this.ids++),this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this},l.prototype.packet=function(t){t.nsp=this.nsp,this.io.packet(t)},l.prototype.onopen=function(){if(c("transport is open - connecting"),"/"!==this.nsp)if(this.query){var t="object"==typeof this.query?h.encode(this.query):this.query;c("sending connect packet with query %s",t),this.packet({type:n.CONNECT,query:t})}else this.packet({type:n.CONNECT})},l.prototype.onclose=function(t){c("close (%s)",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",t)},l.prototype.onpacket=function(t){var e=t.nsp===this.nsp,r=t.type===n.ERROR&&"/"===t.nsp;if(e||r)switch(t.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(t);break;case n.ACK:case n.BINARY_ACK:this.onack(t);break;case n.DISCONNECT:this.ondisconnect();break;case n.ERROR:this.emit("error",t.data)}},l.prototype.onevent=function(t){var e=t.data||[];c("emitting event %j",e),null!=t.id&&(c("attaching ack callback to event"),e.push(this.ack(t.id))),this.connected?p.apply(this,e):this.receiveBuffer.push(e)},l.prototype.ack=function(t){var e=this,r=!1;return function(){if(!r){r=!0;var o=i(arguments);c("sending ack %j",o),e.packet({type:u(o)?n.BINARY_ACK:n.ACK,id:t,data:o})}}},l.prototype.onack=function(t){var e=this.acks[t.id];"function"==typeof e?(c("calling ack %s with %j",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):c("bad ack %s",t.id)},l.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},l.prototype.emitBuffered=function(){var t;for(t=0;t<this.receiveBuffer.length;t++)p.apply(this,this.receiveBuffer[t]);for(this.receiveBuffer=[],t=0;t<this.sendBuffer.length;t++)this.packet(this.sendBuffer[t]);this.sendBuffer=[]},l.prototype.ondisconnect=function(){c("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")},l.prototype.destroy=function(){if(this.subs){for(var t=0;t<this.subs.length;t++)this.subs[t].destroy();this.subs=null}this.io.destroy(this)},l.prototype.close=l.prototype.disconnect=function(){return this.connected&&(c("performing disconnect (%s)",this.nsp),this.packet({type:n.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},l.prototype.compress=function(t){return this.flags.compress=t,this},l.prototype.binary=function(t){return this.flags.binary=t,this}},function(t,e){t.exports=function(t,e,r){return t.on(e,r),{destroy:function(){t.removeListener(e,r)}}}},function(t,e){var r=[].slice;t.exports=function(t,e){if("string"==typeof e&&(e=t[e]),"function"!=typeof e)throw new Error("bind() requires a function");var n=r.call(arguments,2);return function(){return e.apply(t,n.concat(r.call(arguments)))}}},function(t,e,r){t.exports=r(19)},function(t,e,r){var n=r(20),o=r(3),i=r(10),s=r(0)("socket.io-client");t.exports=e=c;var a=e.managers={};function c(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};var r,o=n(t),c=o.source,h=o.id,u=o.path,f=a[h]&&u in a[h].nsps;return e.forceNew||e["force new connection"]||!1===e.multiplex||f?(s("ignoring socket cache for %s",c),r=i(c,e)):(a[h]||(s("new io instance for %s",c),a[h]=i(c,e)),r=a[h]),o.query&&!e.query&&(e.query=o.query),r.socket(o.path,e)}e.protocol=o.protocol,e.connect=c,e.Manager=r(10),e.Socket=r(15)},function(t,e,r){var n=r(6),o=r(0)("socket.io-client:url");t.exports=function(t,e){var r=t;e=e||"undefined"!=typeof location&&location,null==t&&(t=e.protocol+"//"+e.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?e.protocol+t:e.host+t),/^(https?|wss?):\/\//.test(t)||(o("protocol-less url %s",t),t=void 0!==e?e.protocol+"//"+t:"https://"+t),o("parse %s",t),r=n(t)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";var i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port,r.href=r.protocol+"://"+i+(e&&e.port===r.port?"":":"+r.port),r}},function(t,e,r){var n=r(7),o=r(8),i=Object.prototype.toString,s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===i.call(Blob),a="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===i.call(File);e.deconstructPacket=function(t){var e=[],r=t.data,i=t;return i.data=function t(e,r){if(!e)return e;if(o(e)){var i={_placeholder:!0,num:r.length};return r.push(e),i}if(n(e)){for(var s=new Array(e.length),a=0;a<e.length;a++)s[a]=t(e[a],r);return s}if("object"==typeof e&&!(e instanceof Date)){for(var c in s={},e)s[c]=t(e[c],r);return s}return e}(r,e),i.attachments=e.length,{packet:i,buffers:e}},e.reconstructPacket=function(t,e){return t.data=function t(e,r){if(!e)return e;if(e&&e._placeholder)return r[e.num];if(n(e))for(var o=0;o<e.length;o++)e[o]=t(e[o],r);else if("object"==typeof e)for(var i in e)e[i]=t(e[i],r);return e}(t.data,e),t.attachments=void 0,t},e.removeBlobs=function(t,e){var r=0,i=t;!function t(c,h,u){if(!c)return c;if(s&&c instanceof Blob||a&&c instanceof File){r++;var f=new FileReader;f.onload=function(){u?u[h]=this.result:i=this.result,--r||e(i)},f.readAsArrayBuffer(c)}else if(n(c))for(var p=0;p<c.length;p++)t(c[p],p,c);else if("object"==typeof c&&!o(c))for(var l in c)t(c[l],l,c)}(i),r||e(i)}},function(t,e,r){e.byteLength=function(t){var e=h(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,n=h(t),s=n[0],a=n[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,a)),u=0,f=a>0?s-4:s;for(r=0;r<f;r+=4)e=o[t.charCodeAt(r)]<<18|o[t.charCodeAt(r+1)]<<12|o[t.charCodeAt(r+2)]<<6|o[t.charCodeAt(r+3)],c[u++]=e>>16&255,c[u++]=e>>8&255,c[u++]=255&e;return 2===a&&(e=o[t.charCodeAt(r)]<<2|o[t.charCodeAt(r+1)]>>4,c[u++]=255&e),1===a&&(e=o[t.charCodeAt(r)]<<10|o[t.charCodeAt(r+1)]<<4|o[t.charCodeAt(r+2)]>>2,c[u++]=e>>8&255,c[u++]=255&e),c},e.fromByteArray=function(t){for(var e,r=t.length,o=r%3,i=[],s=0,a=r-o;s<a;s+=16383)i.push(u(t,s,s+16383>a?a:s+16383));return 1===o?(e=t[r-1],i.push(n[e>>2]+n[e<<4&63]+"==")):2===o&&(e=(t[r-2]<<8)+t[r-1],i.push(n[e>>10]+n[e>>4&63]+n[e<<2&63]+"=")),i.join("")};for(var n=[],o=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,c=s.length;a<c;++a)n[a]=s[a],o[s.charCodeAt(a)]=a;function h(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,r){for(var o,i,s=[],a=e;a<r;a+=3)o=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(n[(i=o)>>18&63]+n[i>>12&63]+n[i>>6&63]+n[63&i]);return s.join("")}o["-".charCodeAt(0)]=62,o["_".charCodeAt(0)]=63},function(t,e){e.read=function(t,e,r,n,o){var i,s,a=8*o-n-1,c=(1<<a)-1,h=c>>1,u=-7,f=r?o-1:0,p=r?-1:1,l=t[e+f];for(f+=p,i=l&(1<<-u)-1,l>>=-u,u+=a;u>0;i=256*i+t[e+f],f+=p,u-=8);for(s=i&(1<<-u)-1,i>>=-u,u+=n;u>0;s=256*s+t[e+f],f+=p,u-=8);if(0===i)i=1-h;else{if(i===c)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,n),i-=h}return(l?-1:1)*s*Math.pow(2,i-n)},e.write=function(t,e,r,n,o,i){var s,a,c,h=8*i-o-1,u=(1<<h)-1,f=u>>1,p=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:i-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=u):(s=Math.floor(Math.log(e)/Math.LN2),e*(c=Math.pow(2,-s))<1&&(s--,c*=2),(e+=s+f>=1?p/c:p*Math.pow(2,1-f))*c>=2&&(s++,c/=2),s+f>=u?(a=0,s=u):s+f>=1?(a=(e*c-1)*Math.pow(2,o),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,o),s=0));o>=8;t[r+l]=255&a,l+=d,a/=256,o-=8);for(s=s<<o|a,h+=o;h>0;t[r+l]=255&s,l+=d,s/=256,h-=8);t[r+l-d]|=128*y}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e,r){t.exports=r(26),t.exports.parser=r(2)},function(t,e,r){var n=r(11),o=r(1),i=r(0)("engine.io-client:socket"),s=r(14),a=r(2),c=r(6),h=r(5);function u(t,e){if(!(this instanceof u))return new u(t,e);e=e||{},t&&"object"==typeof t&&(e=t,t=null),t?(t=c(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=c(e.host).host),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.agent=e.agent||!1,this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=e.query||{},"string"==typeof this.query&&(this.query=h.decode(this.query)),this.upgrade=!1!==e.upgrade,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.jsonp=!1!==e.jsonp,this.forceBase64=!!e.forceBase64,this.enablesXDR=!!e.enablesXDR,this.timestampParam=e.timestampParam||"t",this.timestampRequests=e.timestampRequests,this.transports=e.transports||["websocket"],this.transportOptions=e.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=e.policyPort||843,this.rememberUpgrade=e.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=e.onlyBinaryUpgrades,this.perMessageDeflate=!1!==e.perMessageDeflate&&(e.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=e.pfx||null,this.key=e.key||null,this.passphrase=e.passphrase||null,this.cert=e.cert||null,this.ca=e.ca||null,this.ciphers=e.ciphers||null,this.rejectUnauthorized=void 0===e.rejectUnauthorized||e.rejectUnauthorized,this.forceNode=!!e.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(e.extraHeaders&&Object.keys(e.extraHeaders).length>0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}t.exports=u,u.priorWebsocketSuccess=!1,o(u.prototype),u.protocol=a.protocol,u.Socket=u,u.Transport=r(12),u.transports=r(11),u.parser=r(2),u.prototype.createTransport=function(t){i('creating transport "%s"',t);var e=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}(this.query);e.EIO=a.protocol,e.transport=t;var r=this.transportOptions[t]||{};return this.id&&(e.sid=this.id),new n[t]({query:e,socket:this,agent:r.agent||this.agent,hostname:r.hostname||this.hostname,port:r.port||this.port,secure:r.secure||this.secure,path:r.path||this.path,forceJSONP:r.forceJSONP||this.forceJSONP,jsonp:r.jsonp||this.jsonp,forceBase64:r.forceBase64||this.forceBase64,enablesXDR:r.enablesXDR||this.enablesXDR,timestampRequests:r.timestampRequests||this.timestampRequests,timestampParam:r.timestampParam||this.timestampParam,policyPort:r.policyPort||this.policyPort,pfx:r.pfx||this.pfx,key:r.key||this.key,passphrase:r.passphrase||this.passphrase,cert:r.cert||this.cert,ca:r.ca||this.ca,ciphers:r.ciphers||this.ciphers,rejectUnauthorized:r.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:r.perMessageDeflate||this.perMessageDeflate,extraHeaders:r.extraHeaders||this.extraHeaders,forceNode:r.forceNode||this.forceNode,localAddress:r.localAddress||this.localAddress,requestTimeout:r.requestTimeout||this.requestTimeout,protocols:r.protocols||void 0,isReactNative:this.isReactNative})},u.prototype.open=function(){var t;if(this.rememberUpgrade&&u.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length){var e=this;return void setTimeout(function(){e.emit("error","No transports available")},0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)},u.prototype.setTransport=function(t){i("setting transport %s",t.name);var e=this;this.transport&&(i("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",function(){e.onDrain()}).on("packet",function(t){e.onPacket(t)}).on("error",function(t){e.onError(t)}).on("close",function(){e.onClose("transport close")})},u.prototype.probe=function(t){i('probing transport "%s"',t);var e=this.createTransport(t,{probe:1}),r=!1,n=this;function o(){if(n.onlyBinaryUpgrades){var o=!this.supportsBinary&&n.transport.supportsBinary;r=r||o}r||(i('probe transport "%s" opened',t),e.send([{type:"ping",data:"probe"}]),e.once("packet",function(o){if(!r)if("pong"===o.type&&"probe"===o.data){if(i('probe transport "%s" pong',t),n.upgrading=!0,n.emit("upgrading",e),!e)return;u.priorWebsocketSuccess="websocket"===e.name,i('pausing current transport "%s"',n.transport.name),n.transport.pause(function(){r||"closed"!==n.readyState&&(i("changing transport and sending upgrade packet"),p(),n.setTransport(e),e.send([{type:"upgrade"}]),n.emit("upgrade",e),e=null,n.upgrading=!1,n.flush())})}else{i('probe transport "%s" failed',t);var s=new Error("probe error");s.transport=e.name,n.emit("upgradeError",s)}}))}function s(){r||(r=!0,p(),e.close(),e=null)}function a(r){var o=new Error("probe error: "+r);o.transport=e.name,s(),i('probe transport "%s" failed because of error: %s',t,r),n.emit("upgradeError",o)}function c(){a("transport closed")}function h(){a("socket closed")}function f(t){e&&t.name!==e.name&&(i('"%s" works - aborting "%s"',t.name,e.name),s())}function p(){e.removeListener("open",o),e.removeListener("error",a),e.removeListener("close",c),n.removeListener("close",h),n.removeListener("upgrading",f)}u.priorWebsocketSuccess=!1,e.once("open",o),e.once("error",a),e.once("close",c),this.once("close",h),this.once("upgrading",f),e.open()},u.prototype.onOpen=function(){if(i("socket open"),this.readyState="open",u.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){i("starting upgrade probes");for(var t=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])}},u.prototype.onPacket=function(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(i('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emit("data",t.data),this.emit("message",t.data)}else i('packet received with socket readyState "%s"',this.readyState)},u.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},u.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout(function(){"closed"!==e.readyState&&e.onClose("ping timeout")},t||e.pingInterval+e.pingTimeout)},u.prototype.setPing=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout(function(){i("writing ping packet - expecting pong within %sms",t.pingTimeout),t.ping(),t.onHeartbeat(t.pingTimeout)},t.pingInterval)},u.prototype.ping=function(){var t=this;this.sendPacket("ping",function(){t.emit("ping")})},u.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},u.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(i("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},u.prototype.write=u.prototype.send=function(t,e,r){return this.sendPacket("message",t,e,r),this},u.prototype.sendPacket=function(t,e,r,n){if("function"==typeof e&&(n=e,e=void 0),"function"==typeof r&&(n=r,r=null),"closing"!==this.readyState&&"closed"!==this.readyState){(r=r||{}).compress=!1!==r.compress;var o={type:t,data:e,options:r};this.emit("packetCreate",o),this.writeBuffer.push(o),n&&this.once("flush",n),this.flush()}},u.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var t=this;this.writeBuffer.length?this.once("drain",function(){this.upgrading?n():e()}):this.upgrading?n():e()}function e(){t.onClose("forced close"),i("socket closing - telling transport to close"),t.transport.close()}function r(){t.removeListener("upgrade",r),t.removeListener("upgradeError",r),e()}function n(){t.once("upgrade",r),t.once("upgradeError",r)}return this},u.prototype.onError=function(t){i("socket error %j",t),u.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)},u.prototype.onClose=function(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(i('socket close with reason: "%s"',t),clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)},u.prototype.filterUpgrades=function(t){for(var e=[],r=0,n=t.length;r<n;r++)~s(this.transports,t[r])&&e.push(t[r]);return e}},function(t,e,r){(function(e){var n,o,i=r(12),s=r(2),a=r(5),c=r(35),h=r(36),u=r(0)("engine.io-client:websocket");if("undefined"!=typeof WebSocket)n=WebSocket;else if("undefined"!=typeof self)n=self.WebSocket||self.MozWebSocket;else try{o=r(37)}catch(t){}var f=n||o;function p(t){t&&t.forceBase64&&(this.supportsBinary=!1),this.perMessageDeflate=t.perMessageDeflate,this.usingBrowserWebSocket=n&&!t.forceNode,this.protocols=t.protocols,this.usingBrowserWebSocket||(f=o),i.call(this,t)}t.exports=p,c(p,i),p.prototype.name="websocket",p.prototype.supportsBinary=!0,p.prototype.doOpen=function(){if(this.check()){var t=this.uri(),e=this.protocols,r={agent:this.agent,perMessageDeflate:this.perMessageDeflate};r.pfx=this.pfx,r.key=this.key,r.passphrase=this.passphrase,r.cert=this.cert,r.ca=this.ca,r.ciphers=this.ciphers,r.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(r.headers=this.extraHeaders),this.localAddress&&(r.localAddress=this.localAddress);try{this.ws=this.usingBrowserWebSocket&&!this.isReactNative?e?new f(t,e):new f(t):new f(t,e,r)}catch(t){return this.emit("error",t)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},p.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},p.prototype.write=function(t){var r=this;this.writable=!1;for(var n=t.length,o=0,i=n;o<i;o++)!function(t){s.encodePacket(t,r.supportsBinary,function(o){if(!r.usingBrowserWebSocket){var i={};t.options&&(i.compress=t.options.compress),r.perMessageDeflate&&("string"==typeof o?e.byteLength(o):o.length)<r.perMessageDeflate.threshold&&(i.compress=!1)}try{r.usingBrowserWebSocket?r.ws.send(o):r.ws.send(o,i)}catch(t){u("websocket closed before onclose event")}--n||a()})}(t[o]);function a(){r.emit("flush"),setTimeout(function(){r.writable=!0,r.emit("drain")},0)}},p.prototype.onClose=function(){i.prototype.onClose.call(this)},p.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},p.prototype.uri=function(){var t=this.query||{},e=this.secure?"wss":"ws",r="";return this.port&&("wss"===e&&443!==Number(this.port)||"ws"===e&&80!==Number(this.port))&&(r=":"+this.port),this.timestampRequests&&(t[this.timestampParam]=h()),this.supportsBinary||(t.b64=1),(t=a.encode(t)).length&&(t="?"+t),e+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+r+this.path+t},p.prototype.check=function(){return!(!f||"__initialize"in f&&this.name===p.prototype.name)}}).call(this,r(4).Buffer)},function(t,e){t.exports=Object.keys||function(t){var e=[],r=Object.prototype.hasOwnProperty;for(var n in t)r.call(t,n)&&e.push(n);return e}},function(t,e){var r={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==r.call(t)}},function(t,e){t.exports=function(t,e,r){var n=t.byteLength;if(e=e||0,r=r||n,t.slice)return t.slice(e,r);if(e<0&&(e+=n),r<0&&(r+=n),r>n&&(r=n),e>=n||e>=r||0===n)return new ArrayBuffer(0);for(var o=new Uint8Array(t),i=new Uint8Array(r-e),s=e,a=0;s<r;s++,a++)i[a]=o[s];return i.buffer}},function(t,e){function r(){}t.exports=function(t,e,n){var o=!1;return n=n||r,i.count=t,0===t?e():i;function i(t,r){if(i.count<=0)throw new Error("after called too many times");--i.count,t?(o=!0,e(t),e=n):0!==i.count||o||e(null,r)}}},function(t,e){var r,n,o,i=String.fromCharCode;function s(t){for(var e,r,n=[],o=0,i=t.length;o<i;)(e=t.charCodeAt(o++))>=55296&&e<=56319&&o<i?56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--):n.push(e);return n}function a(t,e){if(t>=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function c(t,e){return i(t>>e&63|128)}function h(t,e){if(!(4294967168&t))return i(t);var r="";return 4294965248&t?4294901760&t?!(4292870144&t)&&(r=i(t>>18&7|240),r+=c(t,12),r+=c(t,6)):(a(t,e)||(t=65533),r=i(t>>12&15|224),r+=c(t,6)):r=i(t>>6&31|192),r+i(63&t|128)}function u(){if(o>=n)throw Error("Invalid byte index");var t=255&r[o];if(o++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function f(t){var e,i;if(o>n)throw Error("Invalid byte index");if(o==n)return!1;if(e=255&r[o],o++,!(128&e))return e;if(192==(224&e)){if((i=(31&e)<<6|u())>=128)return i;throw Error("Invalid continuation byte")}if(224==(240&e)){if((i=(15&e)<<12|u()<<6|u())>=2048)return a(i,t)?i:65533;throw Error("Invalid continuation byte")}if(240==(248&e)&&(i=(7&e)<<18|u()<<12|u()<<6|u())>=65536&&i<=1114111)return i;throw Error("Invalid UTF-8 detected")}t.exports={version:"2.1.2",encode:function(t,e){for(var r=!1!==(e=e||{}).strict,n=s(t),o=n.length,i=-1,a="";++i<o;)a+=h(n[i],r);return a},decode:function(t,e){var a=!1!==(e=e||{}).strict;r=s(t),n=r.length,o=0;for(var c,h=[];!1!==(c=f(a));)h.push(c);return function(t){for(var e,r=t.length,n=-1,o="";++n<r;)(e=t[n])>65535&&(o+=i((e-=65536)>>>10&1023|55296),e=56320|1023&e),o+=i(e);return o}(h)}}},function(t,e){!function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=new Uint8Array(256),n=0;n<t.length;n++)r[t.charCodeAt(n)]=n;e.encode=function(e){var r,n=new Uint8Array(e),o=n.length,i="";for(r=0;r<o;r+=3)i+=t[n[r]>>2],i+=t[(3&n[r])<<4|n[r+1]>>4],i+=t[(15&n[r+1])<<2|n[r+2]>>6],i+=t[63&n[r+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i},e.decode=function(t){var e,n,o,i,s,a=.75*t.length,c=t.length,h=0;"="===t[t.length-1]&&(a--,"="===t[t.length-2]&&a--);var u=new ArrayBuffer(a),f=new Uint8Array(u);for(e=0;e<c;e+=4)n=r[t.charCodeAt(e)],o=r[t.charCodeAt(e+1)],i=r[t.charCodeAt(e+2)],s=r[t.charCodeAt(e+3)],f[h++]=n<<2|o>>4,f[h++]=(15&o)<<4|i>>2,f[h++]=(3&i)<<6|63&s;return u}}()},function(t,e){var r=void 0!==r?r:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,n=function(){try{return 2===new Blob(["hi"]).size}catch(t){return!1}}(),o=n&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(t){return!1}}(),i=r&&r.prototype.append&&r.prototype.getBlob;function s(t){return t.map(function(t){if(t.buffer instanceof ArrayBuffer){var e=t.buffer;if(t.byteLength!==e.byteLength){var r=new Uint8Array(t.byteLength);r.set(new Uint8Array(e,t.byteOffset,t.byteLength)),e=r.buffer}return e}return t})}function a(t,e){e=e||{};var n=new r;return s(t).forEach(function(t){n.append(t)}),e.type?n.getBlob(e.type):n.getBlob()}function c(t,e){return new Blob(s(t),e||{})}"undefined"!=typeof Blob&&(a.prototype=Blob.prototype,c.prototype=Blob.prototype),t.exports=n?o?Blob:c:i?a:void 0},function(t,e){t.exports=function(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}},function(t,e,r){var n,o="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),i={},s=0,a=0;function c(t){var e="";do{e=o[t%64]+e,t=Math.floor(t/64)}while(t>0);return e}function h(){var t=c(+new Date);return t!==n?(s=0,n=t):t+"."+c(s++)}for(;a<64;a++)i[o[a]]=a;h.encode=c,h.decode=function(t){var e=0;for(a=0;a<t.length;a++)e=64*e+i[t.charAt(a)];return e},t.exports=h},function(t,e,r){const n=r(38),{URL:o}=r(39),{addEventListener:i,removeEventListener:s}=r(46),a=r(47),c=r(0)("wx-ws:wx-ws"),h=["nodebuffer","arraybuffer"],u=["CONNECTING","OPEN","CLOSING","CLOSED"];let f=function(_n){function f(t,e,r){var _this;return _classCallCheck(this,f),_this=_callSuper(this,f),c("constructor: ",t,e,r),_this.readyState=f.CONNECTING,_this.protocol="",_this._closeCode=1006,_this._closeMessage="",_this._binaryType=h[0],_this._socket=null,_this.supports={binary:!0},null!==t&&(_this._bufferedAmount=0,_this._redirects=0,"object"==typeof e&&null!==e&&(r=e,e=void 0),function(t,e,r,n){const o={maxPayload:104857600,perMessageDeflate:!0,...n};c("initAsClient: opts: ",o),t.url=e;const i=function(t){c("start create conn: ",t);const r=wx.connectSocket(t);return r||{onClose:wx.onSocketClose,onOpen:wx.onSocketOpen,onError:wx.onSocketError,onMessage:wx.onSocketMessage,send:wx.sendSocketMessage,close:wx.closeSocket}}({url:t.url,header:o.headers,protocols:r,perMessageDeflate:!!o.perMessageDeflate,tcpNoDelay:!!o.tcpNoDelay});t.setSocket(i)}(_assertThisInitialized(_this),t,e,r)),_this}return _inherits(f,_n),_createClass(f,[{key:"CONNECTING",get:function(){return f.CONNECTING}},{key:"CLOSING",get:function(){return f.CLOSING}},{key:"CLOSED",get:function(){return f.CLOSED}},{key:"OPEN",get:function(){return f.OPEN}},{key:"bufferedAmount",get:function(){return this._socket?(this._socket.bufferSize||0)+this._sender._bufferedBytes:this._bufferedAmount}},{key:"binaryType",get:function(){return this._binaryType},set:function(t){c("set binaryType: ",t),h.includes(t)&&(this._binaryType=t)}},{key:"setSocket",value:function setSocket(t,e){this._socket=t,this._sender=new a(t),c("set socket: socket =",t,", head =",e,", this: ",this),this._socket.onOpen(t=>{c("socket onopen: ",t),this.readyState=f.OPEN,this.emit("open",t)}),this._socket.onClose(t=>{c("socket onclose: ",t),this._closeCode=t.code,this._closeMessage=t.reason,this.emitClose()}),this._socket.onError(t=>{c("socket onerror: ",t),this.emit("error",t)}),this._socket.onMessage(t=>{c("socket onmessage: ",t,this),this.emit("message",t.data)})}},{key:"emitClose",value:function emitClose(){this.readyState=f.CLOSED,this.removeEventListener(),this.emit("close",this._closeCode,this._closeMessage)}},{key:"send",value:function send(t,e,r){if(c("socket send msg: ",t,this.readyState,", sender: ",this._sender),this.readyState===f.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");"number"==typeof t&&(t=t.toString()),this.readyState===f.OPEN?this._sender.send(t,e,r):r&&r(new Error(`WebSocket is not open: readyState ${this.readyState} (${u[this.readyState]})`))}},{key:"close",value:function close(t,e){if(c("closing connection: ",this.readyState),this.readyState!==f.CLOSED){if(this.readyState===f.CONNECTING)throw new Error("WebSocket was closed before the connection was established");this.readyState!==f.CLOSING&&(this.readyState=f.CLOSING,this._socket.close({code:t,reason:e,success:()=>{c("connection closed..."),this.readyState=f.CLOSED,this._socket=null}}))}}}])}(n);u.forEach((t,e)=>{f[t]=e}),["open","error","close","message"].forEach(t=>{Object.defineProperty(f.prototype,`on${t}`,{get(){const e=this.listeners(t);for(let t=0;t<e.length;t++)if(e[t]._listener)return e[t]._listener},set(e){const r=this.listeners(t);for(let e=0;e<r.length;e++)r[e]._listener&&this.removeListener(t,r[e]);this.addEventListener(t,e)}})}),f.prototype.addEventListener=i,f.prototype.removeEventListener=s,t.exports=f},function(t,e,r){var n,o="object"==typeof Reflect?Reflect:null,i=o&&"function"==typeof o.apply?o.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};n=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var s=Number.isNaN||function(t){return t!=t};function a(){a.init.call(this)}t.exports=a,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var c=10;function h(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?a.defaultMaxListeners:t._maxListeners}function f(t,e,r,n){var o,i,s,a;if(h(r),void 0===(i=t._events)?(i=t._events=Object.create(null),t._eventsCount=0):(void 0!==i.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),i=t._events),s=i[e]),void 0===s)s=i[e]=r,++t._eventsCount;else if("function"==typeof s?s=i[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(o=u(t))>0&&s.length>o&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=s.length,a=c,console&&console.warn&&console.warn(a)}return t}function p(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},o=p.bind(n);return o.listener=r,n.wrapFn=o,o}function d(t,e,r){var n=t._events;if(void 0===n)return[];var o=n[e];return void 0===o?[]:"function"==typeof o?r?[o.listener||o]:[o]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(o):g(o,o.length)}function y(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function g(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");c=t}}),a.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||s(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)i(c,this,e);else{var h=c.length,u=g(c,h);for(r=0;r<h;++r)i(u[r],this,e)}return!0},a.prototype.addListener=function(t,e){return f(this,t,e,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(t,e){return f(this,t,e,!0)},a.prototype.once=function(t,e){return h(e),this.on(t,l(this,t,e)),this},a.prototype.prependOnceListener=function(t,e){return h(e),this.prependListener(t,l(this,t,e)),this},a.prototype.removeListener=function(t,e){var r,n,o,i,s;if(h(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(o=-1,i=r.length-1;i>=0;i--)if(r[i]===e||r[i].listener===e){s=r[i].listener,o=i;break}if(o<0)return this;0===o?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,o),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var o,i=Object.keys(r);for(n=0;n<i.length;++n)"removeListener"!==(o=i[n])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},a.prototype.listeners=function(t){return d(this,t,!0)},a.prototype.rawListeners=function(t){return d(this,t,!1)},a.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):y.call(t,e)},a.prototype.listenerCount=y,a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(t,e,r){var n=r(40),o=r(42);function i(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}e.parse=b,e.resolve=function(t,e){return b(t,!1,!0).resolve(e)},e.resolveObject=function(t,e){return t?b(t,!1,!0).resolveObject(e):e},e.format=function(t){return o.isString(t)&&(t=b(t)),t instanceof i?t.format():i.prototype.format.call(t)},e.Url=i;var s=/^([a-z0-9.+-]+:)/i,a=/:[0-9]*$/,c=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,h=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),u=["'"].concat(h),f=["%","/","?",";","#"].concat(u),p=["/","?","#"],l=/^[+a-z0-9A-Z_-]{0,63}$/,d=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},g={javascript:!0,"javascript:":!0},v={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},m=r(43);function b(t,e,r){if(t&&o.isObject(t)&&t instanceof i)return t;var n=new i;return n.parse(t,e,r),n}i.prototype.parse=function(t,e,r){if(!o.isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),a=-1!==i&&i<t.indexOf("#")?"?":"#",h=t.split(a);h[0]=h[0].replace(/\\/g,"/");var b=t=h.join(a);if(b=b.trim(),!r&&1===t.split("#").length){var w=c.exec(b);if(w)return this.path=b,this.href=b,this.pathname=w[1],w[2]?(this.search=w[2],this.query=e?m.parse(this.search.substr(1)):this.search.substr(1)):e&&(this.search="",this.query={}),this}var A=s.exec(b);if(A){var k=(A=A[0]).toLowerCase();this.protocol=k,b=b.substr(A.length)}if(r||A||b.match(/^\/\/[^@\/]+@[^@\/]+/)){var _="//"===b.substr(0,2);!_||A&&g[A]||(b=b.substr(2),this.slashes=!0)}if(!g[A]&&(_||A&&!v[A])){for(var E,B,S=-1,R=0;R<p.length;R++)-1!==(O=b.indexOf(p[R]))&&(-1===S||O<S)&&(S=O);for(-1!==(B=-1===S?b.lastIndexOf("@"):b.lastIndexOf("@",S))&&(E=b.slice(0,B),b=b.slice(B+1),this.auth=decodeURIComponent(E)),S=-1,R=0;R<f.length;R++){var O;-1!==(O=b.indexOf(f[R]))&&(-1===S||O<S)&&(S=O)}-1===S&&(S=b.length),this.host=b.slice(0,S),b=b.slice(S),this.parseHost(),this.hostname=this.hostname||"";var C="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!C)for(var x=this.hostname.split(/\./),P=(R=0,x.length);R<P;R++){var T=x[R];if(T&&!T.match(l)){for(var N="",L=0,j=T.length;L<j;L++)T.charCodeAt(L)>127?N+="x":N+=T[L];if(!N.match(l)){var I=x.slice(0,R),U=x.slice(R+1),M=T.match(d);M&&(I.push(M[1]),U.unshift(M[2])),U.length&&(b="/"+U.join(".")+b),this.hostname=I.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),C||(this.hostname=n.toASCII(this.hostname));var D=this.port?":"+this.port:"",q=this.hostname||"";this.host=q+D,this.href+=this.host,C&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),"/"!==b[0]&&(b="/"+b))}if(!y[k])for(R=0,P=u.length;R<P;R++){var Y=u[R];if(-1!==b.indexOf(Y)){var F=encodeURIComponent(Y);F===Y&&(F=escape(Y)),b=b.split(Y).join(F)}}var z=b.indexOf("#");-1!==z&&(this.hash=b.substr(z),b=b.slice(0,z));var W=b.indexOf("?");if(-1!==W?(this.search=b.substr(W),this.query=b.substr(W+1),e&&(this.query=m.parse(this.query)),b=b.slice(0,W)):e&&(this.search="",this.query={}),b&&(this.pathname=b),v[k]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){D=this.pathname||"";var H=this.search||"";this.path=D+H}return this.href=this.format(),this},i.prototype.format=function(){var t=this.auth||"";t&&(t=(t=encodeURIComponent(t)).replace(/%3A/i,":"),t+="@");var e=this.protocol||"",r=this.pathname||"",n=this.hash||"",i=!1,s="";this.host?i=t+this.host:this.hostname&&(i=t+(-1===this.hostname.indexOf(":")?this.hostname:"["+this.hostname+"]"),this.port&&(i+=":"+this.port)),this.query&&o.isObject(this.query)&&Object.keys(this.query).length&&(s=m.stringify(this.query));var a=this.search||s&&"?"+s||"";return e&&":"!==e.substr(-1)&&(e+=":"),this.slashes||(!e||v[e])&&!1!==i?(i="//"+(i||""),r&&"/"!==r.charAt(0)&&(r="/"+r)):i||(i=""),n&&"#"!==n.charAt(0)&&(n="#"+n),a&&"?"!==a.charAt(0)&&(a="?"+a),e+i+(r=r.replace(/[?#]/g,function(t){return encodeURIComponent(t)}))+(a=a.replace("#","%23"))+n},i.prototype.resolve=function(t){return this.resolveObject(b(t,!1,!0)).format()},i.prototype.resolveObject=function(t){if(o.isString(t)){var e=new i;e.parse(t,!1,!0),t=e}for(var r=new i,n=Object.keys(this),s=0;s<n.length;s++){var a=n[s];r[a]=this[a]}if(r.hash=t.hash,""===t.href)return r.href=r.format(),r;if(t.slashes&&!t.protocol){for(var c=Object.keys(t),h=0;h<c.length;h++){var u=c[h];"protocol"!==u&&(r[u]=t[u])}return v[r.protocol]&&r.hostname&&!r.pathname&&(r.path=r.pathname="/"),r.href=r.format(),r}if(t.protocol&&t.protocol!==r.protocol){if(!v[t.protocol]){for(var f=Object.keys(t),p=0;p<f.length;p++){var l=f[p];r[l]=t[l]}return r.href=r.format(),r}if(r.protocol=t.protocol,t.host||g[t.protocol])r.pathname=t.pathname;else{for(var d=(t.pathname||"").split("/");d.length&&!(t.host=d.shift()););t.host||(t.host=""),t.hostname||(t.hostname=""),""!==d[0]&&d.unshift(""),d.length<2&&d.unshift(""),r.pathname=d.join("/")}if(r.search=t.search,r.query=t.query,r.host=t.host||"",r.auth=t.auth,r.hostname=t.hostname||t.host,r.port=t.port,r.pathname||r.search){var y=r.pathname||"",m=r.search||"";r.path=y+m}return r.slashes=r.slashes||t.slashes,r.href=r.format(),r}var b=r.pathname&&"/"===r.pathname.charAt(0),w=t.host||t.pathname&&"/"===t.pathname.charAt(0),A=w||b||r.host&&t.pathname,k=A,_=r.pathname&&r.pathname.split("/")||[],E=(d=t.pathname&&t.pathname.split("/")||[],r.protocol&&!v[r.protocol]);if(E&&(r.hostname="",r.port=null,r.host&&(""===_[0]?_[0]=r.host:_.unshift(r.host)),r.host="",t.protocol&&(t.hostname=null,t.port=null,t.host&&(""===d[0]?d[0]=t.host:d.unshift(t.host)),t.host=null),A=A&&(""===d[0]||""===_[0])),w)r.host=t.host||""===t.host?t.host:r.host,r.hostname=t.hostname||""===t.hostname?t.hostname:r.hostname,r.search=t.search,r.query=t.query,_=d;else if(d.length)_||(_=[]),_.pop(),_=_.concat(d),r.search=t.search,r.query=t.query;else if(!o.isNullOrUndefined(t.search))return E&&(r.hostname=r.host=_.shift(),(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())),r.search=t.search,r.query=t.query,o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.href=r.format(),r;if(!_.length)return r.pathname=null,r.search?r.path="/"+r.search:r.path=null,r.href=r.format(),r;for(var B=_.slice(-1)[0],S=(r.host||t.host||_.length>1)&&("."===B||".."===B)||""===B,R=0,O=_.length;O>=0;O--)"."===(B=_[O])?_.splice(O,1):".."===B?(_.splice(O,1),R++):R&&(_.splice(O,1),R--);if(!A&&!k)for(;R--;R)_.unshift("..");!A||""===_[0]||_[0]&&"/"===_[0].charAt(0)||_.unshift(""),S&&"/"!==_.join("/").substr(-1)&&_.push("");var C,x=""===_[0]||_[0]&&"/"===_[0].charAt(0);return E&&(r.hostname=r.host=x?"":_.length?_.shift():"",(C=!!(r.host&&r.host.indexOf("@")>0)&&r.host.split("@"))&&(r.auth=C.shift(),r.host=r.hostname=C.shift())),(A=A||r.host&&_.length)&&!x&&_.unshift(""),_.length?r.pathname=_.join("/"):(r.pathname=null,r.path=null),o.isNull(r.pathname)&&o.isNull(r.search)||(r.path=(r.pathname?r.pathname:"")+(r.search?r.search:"")),r.auth=t.auth||r.auth,r.slashes=r.slashes||t.slashes,r.href=r.format(),r},i.prototype.parseHost=function(){var t=this.host,e=a.exec(t);e&&(":"!==(e=e[0])&&(this.port=e.substr(1)),t=t.substr(0,t.length-e.length)),t&&(this.hostname=t)}},function(t,e,r){(function(t,n){var o;!function(){e&&e.nodeType,t&&t.nodeType;var s="object"==typeof n&&n;s.global!==s&&s.window!==s&&s.self;var a,c=2147483647,h=/^xn--/,u=/[^\x20-\x7E]/,f=/[\x2E\u3002\uFF0E\uFF61]/g,p={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},l=Math.floor,d=String.fromCharCode;function y(t){throw new RangeError(p[t])}function g(t,e){for(var r=t.length,n=[];r--;)n[r]=e(t[r]);return n}function v(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+g((t=t.replace(f,".")).split("."),e).join(".")}function m(t){for(var e,r,n=[],o=0,i=t.length;o<i;)(e=t.charCodeAt(o++))>=55296&&e<=56319&&o<i?56320==(64512&(r=t.charCodeAt(o++)))?n.push(((1023&e)<<10)+(1023&r)+65536):(n.push(e),o--):n.push(e);return n}function b(t){return g(t,function(t){var e="";return t>65535&&(e+=d((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+d(t)}).join("")}function w(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function A(t,e,r){var n=0;for(t=r?l(t/700):t>>1,t+=l(t/e);t>455;n+=36)t=l(t/35);return l(n+36*t/(t+38))}function k(t){var e,r,n,o,i,s,a,h,u,f,p,d=[],g=t.length,v=0,m=128,w=72;for((r=t.lastIndexOf("-"))<0&&(r=0),n=0;n<r;++n)t.charCodeAt(n)>=128&&y("not-basic"),d.push(t.charCodeAt(n));for(o=r>0?r+1:0;o<g;){for(i=v,s=1,a=36;o>=g&&y("invalid-input"),((h=(p=t.charCodeAt(o++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||h>l((c-v)/s))&&y("overflow"),v+=h*s,!(h<(u=a<=w?1:a>=w+26?26:a-w));a+=36)s>l(c/(f=36-u))&&y("overflow"),s*=f;w=A(v-i,e=d.length+1,0==i),l(v/e)>c-m&&y("overflow"),m+=l(v/e),v%=e,d.splice(v++,0,m)}return b(d)}function _(t){var e,r,n,o,i,s,a,h,u,f,p,g,v,b,k,_=[];for(g=(t=m(t)).length,e=128,r=0,i=72,s=0;s<g;++s)(p=t[s])<128&&_.push(d(p));for(n=o=_.length,o&&_.push("-");n<g;){for(a=c,s=0;s<g;++s)(p=t[s])>=e&&p<a&&(a=p);for(a-e>l((c-r)/(v=n+1))&&y("overflow"),r+=(a-e)*v,e=a,s=0;s<g;++s)if((p=t[s])<e&&++r>c&&y("overflow"),p==e){for(h=r,u=36;!(h<(f=u<=i?1:u>=i+26?26:u-i));u+=36)k=h-f,b=36-f,_.push(d(w(f+k%b,0))),h=l(k/b);_.push(d(w(h,0))),i=A(r,v,n==o),r=0,++n}++r,++e}return _.join("")}a={version:"1.4.1",ucs2:{decode:m,encode:b},decode:k,encode:_,toASCII:function(t){return v(t,function(t){return u.test(t)?"xn--"+_(t):t})},toUnicode:function(t){return v(t,function(t){return h.test(t)?k(t.slice(4).toLowerCase()):t})}},void 0===(o=function(){return a}.call(e,r,e,t))||(t.exports=o)}()}).call(this,r(41)(t),r(9))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){t.exports={isString:function(t){return"string"==typeof t},isObject:function(t){return"object"==typeof t&&null!==t},isNull:function(t){return null===t},isNullOrUndefined:function(t){return null==t}}},function(t,e,r){e.decode=e.parse=r(44),e.encode=e.stringify=r(45)},function(t,e,r){function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}t.exports=function(t,e,r,i){e=e||"&",r=r||"=";var s={};if("string"!=typeof t||0===t.length)return s;var a=/\+/g;t=t.split(e);var c=1e3;i&&"number"==typeof i.maxKeys&&(c=i.maxKeys);var h=t.length;c>0&&h>c&&(h=c);for(var u=0;u<h;++u){var f,p,l,d,y=t[u].replace(a,"%20"),g=y.indexOf(r);g>=0?(f=y.substr(0,g),p=y.substr(g+1)):(f=y,p=""),l=decodeURIComponent(f),d=decodeURIComponent(p),n(s,l)?o(s[l])?s[l].push(d):s[l]=[s[l],d]:s[l]=d}return s};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)}},function(t,e,r){var n=function(t){switch(typeof t){case"string":return t;case"boolean":return t?"true":"false";case"number":return isFinite(t)?t:"";default:return""}};t.exports=function(t,e,r,a){return e=e||"&",r=r||"=",null===t&&(t=void 0),"object"==typeof t?i(s(t),function(s){var a=encodeURIComponent(n(s))+r;return o(t[s])?i(t[s],function(t){return a+encodeURIComponent(n(t))}).join(e):a+encodeURIComponent(n(t[s]))}).join(e):a?encodeURIComponent(n(a))+r+encodeURIComponent(n(t)):""};var o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e){if(t.map)return t.map(e);for(var r=[],n=0;n<t.length;n++)r.push(e(t[n],n));return r}var s=Object.keys||function(t){var e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r);return e}},function(t,e,r){let n=_createClass(function n(t,e){_classCallCheck(this,n),this.target=e,this.type=t}),o=function(_n2){function o(t,e){var _this2;return _classCallCheck(this,o),(_this2=_callSuper(this,o,["message",e])).data=t,_this2}return _inherits(o,_n2),_createClass(o)}(n),i=function(_n3){function i(t,e,r){var _this3;return _classCallCheck(this,i),(_this3=_callSuper(this,i,["close",r])).wasClean=r._closeFrameReceived&&r._closeFrameSent,_this3.reason=e,_this3.code=t,_this3}return _inherits(i,_n3),_createClass(i)}(n),s=function(_n4){function s(t){return _classCallCheck(this,s),_callSuper(this,s,["open",t])}return _inherits(s,_n4),_createClass(s)}(n),a=function(_n5){function a(t,e){var _this4;return _classCallCheck(this,a),(_this4=_callSuper(this,a,["error",e])).message=t.message,_this4.error=t,_this4}return _inherits(a,_n5),_createClass(a)}(n);const c={addEventListener(t,e){function r(t){e.call(this,new o(t,this))}function n(t,r){e.call(this,new i(t,r,this))}function c(t){e.call(this,new a(t,this))}function h(){e.call(this,new s(this))}"function"==typeof e&&("message"===t?(r._listener=e,this.on(t,r)):"close"===t?(n._listener=e,this.on(t,n)):"error"===t?(c._listener=e,this.on(t,c)):"open"===t?(h._listener=e,this.on(t,h)):this.on(t,e))},removeEventListener(t,e){const r=this.listeners(t);for(let n=0;n<r.length;n++)r[n]!==e&&r[n]._listener!==e||this.removeListener(t,r[n])}};t.exports=c},function(t,e,r){const n=r(0)("wx-ws:sender");t.exports=function(){function _class(t){_classCallCheck(this,_class),this._socket=t,this._queue=[],this._bufferedBytes=0,this._deflating=!1}return _createClass(_class,[{key:"send",value:function send(t,e,r){n("send msg: ",t," sender: ",this,this._deflating),this._deflating?this.enqueue([this.dispatch,t,e,r]):this.dispatch(t,e,r)}},{key:"dispatch",value:function dispatch(t,e,r){n("dispatch msg: ",t,", sender: ",this),this._deflating=!0,"function"==typeof e&&(r=e,e={}),this._deflating=!1,this._socket.send({data:t,success:t=>r&&r(null,t),fail:t=>r&&r(t)}),this.dequeue()}},{key:"dequeue",value:function dequeue(){for(;!this._deflating&&this._queue.length;){const t=this._queue.shift();this._bufferedBytes-=t[1].length,Reflect.apply(t[0],this,t.slice(1))}}},{key:"enqueue",value:function enqueue(t){this._bufferedBytes+=t[1].length,this._queue.push(t)}}])}()},function(t,e){t.exports=function(t,e){for(var r=[],n=(e=e||0)||0;n<t.length;n++)r[n-e]=t[n];return r}},function(t,e){function r(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}t.exports=r,r.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),r=Math.floor(e*this.jitter*t);t=1&Math.floor(10*e)?t+r:t-r}return 0|Math.min(t,this.max)},r.prototype.reset=function(){this.attempts=0},r.prototype.setMin=function(t){this.ms=t},r.prototype.setMax=function(t){this.max=t},r.prototype.setJitter=function(t){this.jitter=t}}])),weapp_socket_io.exports}(),logger$5=createLogger("IM_adapter");let Adapter=function(){function Adapter(params,msgIns){var _this;return _classCallCheck(this,Adapter),(_this=_callSuper(this,Adapter))._msgIns=msgIns,_this.opt=params||{},_this.opt.context&&"string"!=typeof _this.opt.context&&(_this.opt.context=JSON.stringify(_this.opt.context)),_this.opt.timConnectionInfo=_this.opt.extra_connection_info?.tim_connection_info?.sdk_app_id?_this.opt.extra_connection_info.tim_connection_info:null,_this.online=!1,_this._ws=null,_this._ps=null,_this._tim=null,_this.reconnectionAttempts=999,_this.reconnectionDelayMax=8e3,_this.lastPing=null,_this.lastPingCheckTime=3e4,_this._psReconnectCount=0,_this._psMaxReconnectAttempts=99,_this._psIsReconnecting=!1,_this._psReconnectTimer=null,_this.selfClose=!1,_this}return _inherits(Adapter,EventEmitter),_createClass(Adapter,[{key:"connect",value:async function connect(){this.selfClose=!1;const{channelId:channelId,socket_server:socket_server,connection_token:connection_token,nginx_server:nginx_server,timConnectionInfo:timConnectionInfo}=this.opt;if(timConnectionInfo){this._tim&&this._tim._msgIns===this._msgIns?(this._tim.createTime=Date.now(),this._tim.retryCount=0,logger$5.debug("[tim] user _tim")):(this._tim=new Tim(timConnectionInfo,this._msgIns,this.opt.logReportServer),this._timAddEventListener(),logger$5.debug("[tim] new Tim")),this._initSocket(socket_server,connection_token,channelId);const wsPromise=new Promise((resolve,reject)=>{this._ws.once("joined",resolve),setTimeout(()=>reject(new Error("join timeout")),1e4)}),timPromise=new Promise((resolve,reject)=>{this._tim.once("evTimJoinGroupSuccess",resolve),setTimeout(()=>reject(new Error("tim init timeout")),1e4)});this.join(channelId);const[wsResult,timResult]=await Promise.allSettled([wsPromise,timPromise]);return"rejected"===timResult.status&&this.destroyTim(!1),"rejected"===wsResult.status||"rejected"===timResult.status?Promise.reject(wsResult.reason||timResult.reason):Promise.resolve(wsResult.value)}return this._initSocket(socket_server,connection_token),this._initPushStream(nginx_server,channelId),this.join(channelId),new Promise((resolve,reject)=>{this._ws.once("joined",data=>resolve(data)),setTimeout(()=>{reject(new Error("join timeout"))},1e4)})}},{key:"_initSocket",value:function _initSocket(server,token){logger$5.debug("iows_initSocket");const opt={query:`token=${token}&ver=1.0.1&s=${pageSession}`,reconnectionAttempts:this.reconnectionAttempts,reconnectionDelayMax:this.reconnectionDelayMax,path:"/socket.io",rememberUpgrade:!0,autoConnect:!1,forceNew:!0,transports:["websocket"]},socket=IO(server,opt);socket.connect(),socket.on("connecting",()=>{logger$5.debug("iows_connecting event")}),socket.on("connect",()=>{logger$5.debug("iows_connect event")}),socket.on("connected",()=>{logger$5.debug("iows_connected event")}),socket.on("joined",msg=>{logger$5.debug("iows_joined event:",msg),this._onJoined(msg)}),socket.on("disconnect",reason=>{logger$5.debug("iows_disconnect event:",reason),this.emit("disconnect",reason)}),socket.on("reconnecting",attempt=>{logger$5.debug("iows_reconnecting event:"),this._onReconnecting(0,attempt)}),socket.on("reconnect_attempt",attempt=>{logger$5.debug("iows_reconnect_attempt event, attempt:",attempt),this.emit("reconnectAttempt",attempt)}),socket.on("reconnect",attempt=>{logger$5.debug("iows_reconnect event, attempt:",attempt),this._onReconnect(0,attempt)}),socket.io.on("packet",packet=>{this.lastPingCheckTime=Date.now()}),socket.on("error",error=>null),socket.on("msg",msg=>{this._ondata("iows",msg)}),socket.connect(),this._ws=socket}},{key:"_initPushStream",value:function _initPushStream(server,channelId){logger$5.debug("psws_initPushStream");const self=this,wss_address=`wss://${server.match(/^(https?:\/\/)?([^\/]+)/)[2]}/ws/${channelId}?_=1739435966054&tag=&time=&eventid=`;this._ps&&(this._ps.close(),this._ps=null);const _reconnect=()=>{if(self._psIsReconnecting||self._psReconnectCount>=self._psMaxReconnectAttempts)return;self._psIsReconnecting=!0,logger$5.debug(`psws_pushstream服务,第${self._psReconnectCount+1}次重连...`);const delay=1e3*Math.pow(2,self._psReconnectCount);self._psReconnectTimer=setTimeout(()=>{self._initPushStream(server,channelId),self._psReconnectCount++,self._psIsReconnecting=!1},delay)},st=wx.connectSocket({url:wss_address,success(res){logger$5.debug("psws_wx.connectSocket success",res)},fail(res){logger$5.error("psws_wx.connectSocket fail",res),_reconnect()}});this._ps=st,st.onOpen(data=>{logger$5.debug("psws_onOpen event"),self._psReconnectCount=0}),st.onClose(data=>{logger$5.debug("psws_onClose event:",data),this.selfClose?logger$5.debug("psws_onClose 主动调用断开不重连"):_reconnect()}),st.onError(err=>{logger$5.warn("psws_onError",err),this.selfClose||_reconnect()}),st.onMessage(res=>{logger$5.debug("psws_onMessage:",res);const text=JSON.parse(res.data).text,text_urldecode=decodeURIComponent(text);this._ondata("psws",text_urldecode)})}},{key:"join",value:function join(channelId,opt,callback){this.opt.timConnectionInfo&&this._tim&&this._tim.initialize(),this._emitwsjoin(channelId)}},{key:"leave",value:function leave(){this._ws&&this._ws.emit("leave",{channel:this.opt.channelId,third_party_user_id:this.opt.third_party_user_id}),logger$5.debug(`leave channelId: ${this.opt.channelId} , third_party_user_id: ${this.opt.third_party_user_id}`)}},{key:"disconnect",value:function disconnect(isQuitGroups=!1){this.selfClose=!0,this._ws&&this._ws.disconnect(),this._ps&&this._ps.close(),this._tim&&this.destroyTim(isQuitGroups),logger$5.debug("disconnect all websocket")}},{key:"_onTimData",value:function _onTimData(msg){this._ondata("tim",msg)}},{key:"destroyTim",value:function destroyTim(isQuitGroups=!1){this._tim&&(this._tim.off("evMessageReceived",this._onTimData.bind(this)),this._tim.disconnect(isQuitGroups),this._tim=null)}},{key:"_emitwsjoin",value:function _emitwsjoin(channelId){const opt=this.opt,{third_party_user_id:third_party_user_id,context:context,hide:hide}=opt,joinData={channel:channelId,third_party_user_id:third_party_user_id,context:context,hide:hide};this._ws&&this._ws.emit("join",joinData),logger$5.debug("_emitwsjoin call:",joinData)}},{key:"_onJoined",value:function _onJoined(data){this.online=!0,this.emit("online",data)}},{key:"_onReconnecting",value:function _onReconnecting(ch,attempt){logger$5.warn(`socket reconnecting, attempt: ${attempt}`),this.online&&(this.online=!1,this.emit("offline",{}))}},{key:"_onReconnect",value:function _onReconnect(ch,attempt){logger$5.warn(`socket reconnected success, attempt: ${attempt}`),this._emitwsjoin(this.opt.channelId)}},{key:"_timAddEventListener",value:function _timAddEventListener(){this._tim&&this._tim.on("evMessageReceived",this._onTimData.bind(this))}},{key:"_ondata",value:async function _ondata(flag,data){let msg=await this._parseData(data);if(logger$5.debug(`${flag} msg parsed:`,msg),msg){Array.isArray(msg)||(msg=[msg]);for(let item of msg){let c=safeJsonParse(item);Array.isArray(c)?this._dispatch(safeJsonParse(c[c.length-1])):this._dispatch(c)}}}},{key:"_parseData",value:async function _parseData(msg){msg=safeJsonParse(msg);const compAlg=msg?.comp_alg;if(!compAlg)return msg;const encoding=msg.encoding;let decodeContent,result;try{decodeContent="b64"===encoding?decode(msg.content):"b64_2"===encoding?toUint8Array(msg.content):msg.content}catch(ex){ex&&ex.message.indexOf("TypedArray.from requires")>-1&&(decodeContent=function(a){try{a=a.replace(/[^A-Za-z0-9+/]/g,"").replace(/[-_]/g,m0=>"-"==m0?"+":"/");const it="function"==typeof Buffer?Buffer.from(a,"base64"):_atob(a).split("").map(c=>c.charCodeAt(0));return new Uint8Array(Array.prototype.slice.call(it,0))}catch(ex){console.error("toUint8ArrayExt exec error:",ex)}}(msg.content))}if(decodeContent)if("gz"===compAlg){let originalContentStr;try{originalContentStr=await async function decompressData(data){return pako_inflate.inflate(data,{to:"string"})}(decodeContent)}catch(ex){logger$5.error("gunzip data error:",ex)}result=safeJsonParse(originalContentStr)}else result=safeJsonParse(decodeContent);return result}},{key:"_dirMsgFilter",value:function _dirMsgFilter(user_ids,accountId){return"string"!=typeof user_ids?1:(user_ids=user_ids.split(","),Array.isArray(user_ids)?user_ids.length&&user_ids.indexOf(accountId+"")>=0?2:-1:0)}},{key:"_dispatch",value:function _dispatch(data){data&&(this._dirMsgFilter(data.user_ids,this.opt.third_party_user_id)<=0||this.emit("service_message",data))}}])}(),WxHttp=function(){return _createClass(function WxHttp(store){_classCallCheck(this,WxHttp),this.store=store},[{key:"request",value:function request(url,data={},method="POST"){return new Promise((resolve,reject)=>{const config={url:url,method:method,data:data,header:{"Content-Type":"application/x-www-form-urlencoded"},timeout:1e4,success:res=>this._handleSuccess(res,resolve,reject),fail:err=>this._handleFail(err,reject)};wx.request(config)})}},{key:"_handleSuccess",value:function _handleSuccess(res,resolve,reject){if(200!==res.statusCode)return reject({code:res.statusCode,msg:"网络请求失败"});const response=res.data||{};200===+response.code?resolve(response.data):reject(response)}},{key:"_handleFail",value:function _handleFail(err,reject){reject({code:-1,msg:"网络连接失败",errMsg:err.errMsg})}}])}();let WxApi=function(){return _createClass(function WxApi(imIns){_classCallCheck(this,WxApi),this.currentEnvConfig=imIns.currentEnvConfig,this.opt=imIns.opt,this.http=new WxHttp},[{key:"requestVhallyunInit",value:function requestVhallyunInit(random_key){const url=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,VHALLYUN_API_LIST_INIT),data={app_id:this.opt.appId,channel_id:this.opt.channelId,third_party_user_id:this.opt.third_party_user_id,access_token:this.opt.token,random_key:random_key,version:"weapp_0.1.0",client:"wechat_applet",package_check:"package_check"};return this.http.request(url,data)}},{key:"sendMsg",value:function sendMsg(type,msg={},context={},no_audit=0,tag){const url=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,VHALLYUN_API_LIST_SEND_MESSAGE),data={app_id:this.opt.appId,channel_id:this.opt.channelId,access_token:this.opt.token,third_party_user_id:this.opt.third_party_user_id,type:type,no_audit:no_audit,context:JSON.stringify(context),body:"string"==typeof msg?msg:JSON.stringify(msg),client:"wechat_applet",package_check:"package_check"};tag&&(data.tag=tag),data.signed_at=Date.now(),data.sign_type=_signType;const sign=function(params,secretKey,signType){if(secretKey||(secretKey=_sKey),!secretKey)return console.warn("secretKey is empty"),"";isNaN(signType)&&(signType=_signType),"[object object]"!==Object.prototype.toString.call(params).toLowerCase()&&(params={});const newKeys=Object.keys(params).sort();let signParam="";for(const k of newKeys)signParam+=`${k}${params[k]}`;const readyKeyStr=`${secretKey}${signParam}${secretKey}`;return 3===signType?sm3(readyKeyStr).toString().toLocaleLowerCase():0===signType?CryptoJS.MD5(readyKeyStr).toString().toLocaleLowerCase():CryptoJS.SHA256(readyKeyStr).toString().toLocaleLowerCase()}(data);return sign&&(data.sign=sign),this.http.request(url,data)}},{key:"sendDirect",value:function sendDirect(type,msg={},context={},no_audit=0,tag,user_ids){}}])}(),VhallImInterface=function(){function VhallImInterface(VhallMsg,opt){var _this;return _classCallCheck(this,VhallImInterface),(_this=_callSuper(this,VhallImInterface)).VhallMsg=VhallMsg,_this.opt=opt,_this.compChannelId=void 0,_this.adapter=null,_this.currentEnvConfig=opt?.env&&envConfig[opt.env]?envConfig[opt.env]:envConfig.production,_this.api=new WxApi(_this),_this}return _inherits(VhallImInterface,EventEmitter),_createClass(VhallImInterface,[{key:"init",value:async function init(){const rnd=function(num=48){const library="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let key="";for(var i=0;i<num;i++){let randomPoz=Math.floor(62*Math.random());key+=library.substring(randomPoz,randomPoz+1)}return key}(48),random_key=function(val,publicKey){const encryptor=new JSEncrypt;return encryptor.setPublicKey(publicKey),encryptor.encrypt(val)}(rnd,this.currentEnvConfig.PUBLIC_KEY);if(this.info=await this.api.requestVhallyunInit(random_key),this.info.comp_channel_id&&(this.compChannelId=this.info.comp_channel_id),this.info.secret_key){const secretKey=function(data,key,iv){"string"!=typeof data&&(data=JSON.stringify(data));const result=CryptoJS.AES.decrypt(data,CryptoJS.enc.Utf8.parse(key),{iv:CryptoJS.enc.Utf8.parse(iv)});return CryptoJS.enc.Utf8.stringify(result)}(this.info.secret_key,rnd.substring(0,32),rnd.substring(32,48));val=this.info.sign_type,isNaN(val)||(_signType=val),function(val){_sKey=val}(secretKey)}var val}},{key:"connect",value:async function connect(){if(this.adapter)return"function"==typeof callback?(this.adapter.join(this.compChannelId||this.opt.channelId,this.opt,callback),this):new Promise((resolve,reject)=>{this.adapter.join(this.compChannelId||this.opt.channelId,this.opt,function(res){resolve(res)}),setTimeout(()=>reject(new Error("join timeout")),1e4)});{const adapterOptions={channelId:this.compChannelId||this.opt.channelId,third_party_user_id:this.opt.third_party_user_id,socket_server:this.info.socket_server,connection_token:this.info.connection_token,nginx_server:this.info.nginx_server,context:this.opt.context,hide:this.opt.hide,extra_connection_info:this.info?.extra_connection_info,logReportServer:this.opt.logReportServer};this.adapter=new Adapter(adapterOptions,this),this.adapter.on("online",data=>{this.emit("online",data)}),this.adapter.on("offline",data=>{this.emit("offline",data)}),this.adapter.on("service_message",msg=>{var html;if(msg.service_type&&(!msg.channel||adapterOptions.channelId.includes(msg.channel)))if("service_im"==msg.service_type){let context=JSON.stringify({});const{type:type}=JSON.parse(msg.data);msg.context&&(context=JSON.parse(msg.context),"nickname"in context&&delete context.nickname);const chatData={type:JSON.parse(msg.data).type,text_content:type===Type.TYPE_TEXT?(html=JSON.parse(msg.data).text_content,html.replace(/</g,"<").replace(/>/g,">")):JSON.parse(msg.data).text_content,data:JSON.parse(msg.data),user_id:msg.sender_id,target_id:JSON.parse(msg.data).target_id,context:context,msg_id:msg.msg_id,date_time:msg.date_time};this.emit(msg.service_type,chatData)}else if("service_online"==msg.service_type){switch(safeJsonParse(msg.data).type){case"Join":this.emit("service_online_join",msg);break;case"Leave":this.emit("service_online_leave",msg)}}else this.emit(msg.service_type,msg)});return await this.adapter.connect()}}},{key:"updateOption",value:function updateOption(opt){}},{key:"initSubEvent",value:function initSubEvent(){}},{key:"onOnLine",value:function onOnLine(callback){return this.on("online",callback)}},{key:"onOffLine",value:function onOffLine(callback){return this.on("offline",callback)}},{key:"onJoin",value:function onJoin(callback){return this.on("service_online_join",callback)}},{key:"onLeave",value:function onLeave(callback){return this.on("service_online_leave",callback)}},{key:"onChat",value:function onChat(callback){return this.on("service_im",callback)}},{key:"onCustomMsg",value:function onCustomMsg(callback){return this.on("service_custom",callback)}},{key:"onRoomMsg",value:function onRoomMsg(callback){return this.on("service_room",callback)}},{key:"onDocMsg",value:function onDocMsg(callback){return this.on("service_document",callback)}},{key:"_sendEvent",value:async function _sendEvent(params){if(!this.adapter.online)throw{code:"",message:"Adapter is offline",data:{}};const{type:type,msg:msg,context:context,no_audit:no_audit=0,tag:tag,user_ids:user_ids}=params;return await this.api.sendMsg(type,msg,context,no_audit,tag)}},{key:"sendChat",value:function sendChat(params){const{data:data="",context:context={},inspection:inspection=!0}=params;if("string"!=typeof data||"boolean"!=typeof inspection)return Promise.reject({code:"",message:"无效的参数",data:{}});const opt={type:"service_im",msg:{type:"text",text_content:data},context:Object.assign({avatar:this.opt?.userInfo?.avatar,nickname:this.opt?.userInfo?.nickname,role_name:this.opt?.userInfo?.role_name,user_id:this.opt?.userInfo?.user_id,member_level:this.opt?.userInfo?.member_level},context),no_audit:Number(!inspection),user_ids:params&¶ms.user_ids};return"string"==typeof params.tag&&(opt.tag=params.tag),this._sendEvent(opt)}},{key:"sendCustomEvent",value:function sendCustomEvent(params){let data=params&¶ms.data;"string"==typeof data&&(data=JSON.parse(data));const opt={type:"service_custom",msg:data,user_ids:params&¶ms.user_ids};return"string"==typeof params.tag&&(opt.tag=params.tag),this._sendEvent(opt)}},{key:"sendRoomEvent",value:function sendRoomEvent(params){let data=params&¶ms.data;"string"==typeof data&&(data=JSON.parse(data));const opt={type:"service_room",msg:data,user_ids:params&¶ms.user_ids};return"string"==typeof params.tag&&(opt.tag=params.tag),this._sendEvent(opt)}},{key:"destroy",value:function destroy(isQuitGroups=!1){this.api=null,this.adapter&&(this.adapter.leave(),this.adapter.disconnect(isQuitGroups)),this.clearEvents(),this.VhallMsg.channlIdMap[this.opt.channelId]=null}}])}();const logger$4=createLogger("IM_VhallMsg");let deviceInfo_platform,VhallMsg=function(){function VhallMsg(){_classCallCheck(this,VhallMsg)}return _createClass(VhallMsg,null,[{key:"createInstance",value:async function createInstance(sdkInstance){if(logger$4.debug("createInstance start:"),!sdkInstance)return;const env=sdkInstance.env;let{user:user,interact:interact,kickMark:kickMark,webinarId:webinarId,watchInitData:watchInitData,interactToolStatus:interactToolStatus}=sdkInstance.store.get("");kickMark||(kickMark=`${webinarId}_${function guid(){return"xxxxxxxx-xxxxxxxx".replace(/[xy]/g,function(c){var r=16*Math.random()|0;return("x"===c?r:3&r|8).toString(16)})}()}`,sdkInstance.store.set("kickMark",kickMark));const userInfo=user,appId=interact.paas_app_id,channelId=interact.channel_id,token=interact.paas_access_token,third_party_user_id=user.user_id;try{if(!(appId&&channelId&&token)){throw{code:"",message:"无效的参数",data:{}}}const existed=VhallMsg.channlIdMap[channelId];if(existed)return existed.clearEvents(),existed;const creating=VhallMsg.creatingMap[channelId];if(creating)return creating;const p=(async()=>{const logReportServer=sdkInstance.get("logReportServer"),vhallyunOpt={appId:appId,channelId:channelId,token:token,third_party_user_id:third_party_user_id,userInfo:userInfo,env:env,logReportServer:logReportServer,context:{role_name:2,nickname:userInfo.nickname,avatar:userInfo.avatar,user_id:userInfo.user_id,openid:userInfo.openid,device_type:1,device_status:0,kick_id:watchInitData?.sso?.kick_id,kick_mark:kickMark,pv:watchInitData?.pv&&(watchInitData.pv.num2??watchInitData.pv.real),uv:watchInitData?.online&&(watchInitData.online.num||watchInitData.online.virtual),is_banned:interactToolStatus?.is_banned,privacies:watchInitData?.join_info.privacies||""}},instance=new VhallImInterface(VhallMsg,vhallyunOpt);await instance.init();await instance.connect();return VhallMsg.channlIdMap[channelId]=instance,logger$4.debug("createInstance success."),instance})();VhallMsg.creatingMap[channelId]=p;try{return await p}finally{delete VhallMsg.creatingMap[channelId]}}catch(err){throw logger$4.error("createInstance error:",err),err instanceof Error?err:new Error(JSON.stringify(err))}}}])}();function formatTimestamp(timestamp,format="YYYY-MM-DD HH:mm:ss"){const ms=10===timestamp.toString().length?1e3*timestamp:timestamp,date=new Date(ms),year=date.getFullYear(),month=String(date.getMonth()+1).padStart(2,"0"),day=String(date.getDate()).padStart(2,"0"),hours=String(date.getHours()).padStart(2,"0"),minutes=String(date.getMinutes()).padStart(2,"0"),seconds=String(date.getSeconds()).padStart(2,"0");return format?format.replaceAll("YYYY",year).replaceAll("MM",month).replaceAll("DD",day).replaceAll("HH",hours).replaceAll("mm",minutes).replaceAll("ss",seconds):`${year}-${month}-${day} ${hours}:${minutes}:${seconds}`}_defineProperty(VhallMsg,"channlIdMap",{}),_defineProperty(VhallMsg,"creatingMap",{}),_defineProperty(VhallMsg,"Type",Type);const logger$3=createLogger("RoomServer");let lastDisconnectedTime;getApp();let RoomServer=function(){return _createClass(function RoomServer(sdkInstance){_classCallCheck(this,RoomServer),_defineProperty(this,"onForeground",({gap:gap})=>Promise.all([this.getCommonConfig(),this.getPermissions()]).catch(e=>logger$3.error("RoomServer.onForeground refresh failed:",e))),this.sdkInstance=sdkInstance,this.wxApi=this.sdkInstance.wxApi,this.sdkInstance.on(this.sdkInstance.EVENT.FOREGROUND_REFRESH,(...args)=>this.onForeground(...args))},[{key:"initRoom",value:async function initRoom(){const{webinarId:webinarId}=this.sdkInstance,user=this.sdkInstance.store.get("user");user?.token?this.wxApi.setCommonHeaders("token",user?.token):user?.scope_token&&this.wxApi.setCommonHeaders("scope-token",user?.scope_token);const res=await this.wxApi.sendPost("/v3/webinars/watch/sdk-init",Object.fromEntries(Object.entries({webinar_id:webinarId,nickname:truncateString(user?.nickname),token:user?.token,avatar:user?.avatar,openid:user?.openid,email:user?.email,visitor_id:cacheUtil.getStorageSync("vh_visitor_id")||void 0}).filter(([_,value])=>void 0!==value)));if(200===res?.code){const{webinar:webinar,join_info:join_info,interact:interact}=res.data;this.wxApi.setCommonHeaders("Interact-Token",res.data.interact.interact_token),this.sdkInstance.store.set("watchInitData",res.data),this.sdkInstance.store.set({liveInfo:Object.assign({},this.sdkInstance.store.get("liveInfo"),{bussinessId:webinar.userinfo.user_id,mode:webinar.webinar_show_type,coverImg:0==webinar.webinar_show_type&&webinar.vertical_img_url?webinar.vertical_img_url:webinar.img_url,title:webinar.subject,introduction:webinar.introduction,startTime:webinar.start_time}),interact:interact}),this.sdkInstance.store.set("webinarStatus",webinar.type);const userServer=this.sdkInstance.get("userServer");userServer?.updateLocalUser({role_name:join_info.role_name,avatar:join_info.avatar,user_id:join_info.third_party_user_id||join_info.user_id,nickname:join_info.nickname}),cacheUtil.setStorage({key:"vh_visitor_id",data:res.data.visitor_id})}return res}},{key:"initIM",value:async function initIM(){logger$3.log("initIM"),this.imInstance=await VhallMsg.createInstance(this.sdkInstance),this.imInstance.on("onTimNetStateChange",state=>{this.sdkInstance.emit(EVENT$1.NET_STATE_CHANGE,state),"disconnected"===state?lastDisconnectedTime=Date.now():"connecting"===state||"connected"===state&&(lastDisconnectedTime>0&&(this.sdkInstance.BRSAgent?.customLog(`NetState:disconnected: ${formatTimestamp(lastDisconnectedTime)}`),lastDisconnectedTime=0),this.sdkInstance.BRSAgent?.customLog(`NetState:${state}`))}),this.imInstance.onChat(msg=>{const user=this.sdkInstance.store.get("user"),store=this.sdkInstance.store;switch(msg.type){case"image":case"text":user.user_id!=msg.user_id&&this.sdkInstance.emit(EVENT$1.CHAT_MSG,msg);break;case"disable":msg.target_id==user.user_id&&store.set("interactToolStatus.is_banned",!0);break;case"permit":"customPraiseTotal"==msg.data.event_type?this.sdkInstance.emit(EVENT$1.LIKE_MSG,msg):msg.target_id==user.user_id&&store.set("interactToolStatus.is_banned",!1);break;case"disable_all":store.set("interactToolStatus.all_banned",!0);break;case"permit_all":store.set("interactToolStatus.all_banned",!1)}}),this.imInstance.onJoin(msg=>{this.sdkInstance.emit(EVENT$1.JOIN_MSG,msg)}),this.imInstance.onLeave(msg=>{this.sdkInstance.emit(EVENT$1.LEAVE_MSG,msg)}),this.imInstance.onRoomMsg(msg=>{if(msg){if(msg.data=safeJsonParse$1(msg.data),"banned_mode_update"===msg.data.type)this.sdkInstance.store.set("interactToolStatus.banned_mode",msg.data.mode);this.sdkInstance.emit(EVENT$1.ROOM_MSG,msg)}}),this.imInstance.onCustomMsg(msg=>{msg&&(msg.data=safeJsonParse$1(msg.data),this.sdkInstance.emit(EVENT$1.CUSTOM_MSG,msg))}),this.sdkInstance.sendChat=async data=>{const{all_banned:all_banned,is_banned:is_banned,banned_mode:banned_mode}=this.sdkInstance.store.get("interactToolStatus");if(!data||all_banned||is_banned&&1!=banned_mode)return;const user=this.sdkInstance.store.get("user");(!is_banned||1!=banned_mode)&&this.imInstance.sendChat(data),this.sdkInstance.emit(EVENT$1.CHAT_MSG,{type:"text",data:{text_content:data.data},context:{role_name:"2",nick_name:user.nickname,avatar:user.avatar,user_id:user.user_id,member_level:user.member_level||""}})},this.sdkInstance.leaveRoom=async(isLiveEnd=!1,options)=>this.imInstance?.destroy(isLiveEnd)}},{key:"getCommonConfig",value:async function getCommonConfig(){const tags=["webinar-tag","screen-poster","public-account","invite-card","keywords","like","sign","timer","menu","member-level"],watchInitData=this.sdkInstance.store.get("watchInitData");if(!watchInitData?.webinar)return;5!=watchInitData.webinar.type&&tags.push("room-tool");const params={webinar_id:watchInitData.webinar.id,switch_id:watchInitData.switch?.switch_id,tags:tags},res=await this.wxApi.sendPost("/v3/interacts/union/common-config",params);return 200===res?.code&&(this.sdkInstance.store.set("webinarTag",res.data?.["webinar-tag"]?.data||{}),this.sdkInstance.store.set("screenPosterInfo",res.data?.["screen-poster"]?.data||{}),this.sdkInstance.store.set("officicalInfo",res.data?.["public-account"]?.data||{}),this.sdkInstance.store.set("advDefault",res.data?.["adv-default"]?.data||{}),this.sdkInstance.store.set("inviteCardStatus",res.data?.["invite-card"]?.data||{}),this.sdkInstance.store.set("keywords",res.data?.keywords?.data||{}),this.sdkInstance.store.set("redPacket",res.data?.["red-packet"]?.data||{}),this.sdkInstance.store.set("pwdRedPacket",res.data?.["pwd-red-packet"]?.data||{}),this.sdkInstance.store.set("likeCount",res.data?.like?.data.total||0),this.sdkInstance.store.set("noticeInfo",res.data?.announcement?.data||{}),this.sdkInstance.store.set("signinInfo",res.data?.sign?.data||{}),this.sdkInstance.store.set("timerInfo",res.data?.timer?.data||{}),this.sdkInstance.store.set("examInfo",res.data?.exam?.data||{}),this.sdkInstance.store.set("pushCardInfo",res.data?.["push-screen-card"]?.data||{}),this.sdkInstance.store.set("interactToolStatus",res.data?.["room-tool"]?.data||{}),this.sdkInstance.store.set("customMenu",this._resolveCustomMenu(res.data?.menu)),this.sdkInstance.store.set("memberLevel",res.data?.member_level?.data||{})),res}},{key:"_resolveCustomMenu",value:function _resolveCustomMenu(originMenu){if(!originMenu||!originMenu.data||!originMenu.data.list)return{};const isPcClient=function isInPc(){try{return deviceInfo_platform||this.getDevicePlatform(),"windows"===deviceInfo_platform||"mac"===deviceInfo_platform}catch(ex){return!1}}();for(let i=originMenu.data.list.length-1;i>-1;i--){const item=originMenu.data.list[i];1==item.type?isPcClient&&0==item.pc_show?originMenu.data.list.splice(i,1):isPcClient||0!=item.wap_show||originMenu.data.list.splice(i,1):5!==item.type&&(item.status=isPcClient?1==item.pc_show?1:2:1==item.wap_show?1:2)}return originMenu.data}},{key:"getInavToolStatus",value:async function getInavToolStatus(){const watchInitData=this.sdkInstance.store.get("watchInitData");if(5==watchInitData.webinar.type){if(!watchInitData.interact?.interact_token)return{msg:"请检查活动是否设置了观看限制"};const res=await this.wxApi.sendGet("/v3/interacts/room/get-inav-tool-status",{room_id:watchInitData.interact.room_id,webinar_switch_id:watchInitData.switch.switch_id});return 200===res?.code&&res.data&&this.sdkInstance.store.set("interactToolStatus",res.data),res}return null}},{key:"getPermissions",value:async function getPermissions(){const{webinarId:webinarId}=this.sdkInstance,bussinessId=this.sdkInstance.store.get("liveInfo").bussinessId,res=await this.wxApi.sendGet("/v3/users/permission/get-config-list",{webinar_id:webinarId,webinar_user_id:bussinessId,scene_id:3});return 200===res.code&&this.sdkInstance.store.set(this._resolvePermissionResult(res.data)),res}},{key:"_resolvePermissionResult",value:function _resolvePermissionResult(result){return{permissions:"string"==typeof result.permissions?JSON.parse(result.permissions):result.permissions,permissionValue:"string"==typeof result.permission_value?JSON.parse(result.permission_value):result.permission_value}}},{key:"destroy",value:function destroy(isExitGroup){this.imInstance?.destroy(isExitGroup)}}])}();_defineProperty(RoomServer,"name","RoomServer");const logger$2=createLogger("UserServer");let UserServer=function(){function UserServer(sdkInstance){var _this;return _classCallCheck(this,UserServer),(_this=_callSuper(this,UserServer)).sdkInstance=sdkInstance,_this.wxApi=sdkInstance.wxApi,_this}return _inherits(UserServer,BaseServer),_createClass(UserServer,[{key:"login",value:async function login(params){const url=params.third_user_id?"/v3/users/open-user/login":"/v3/users/open-user/get-scope-token",res=await this.wxApi.sendPost(url,params,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});return 200==res.code&&(params.third_user_id?this.updateLocalUser({token:res.data.token}):this.updateLocalUser({scope_token:res.data.scope_token})),res}},{key:"updateUserInfo",value:async function updateUserInfo(params){return cosnt[basicRes,joinRes]=await Promise.all([this._updateUserBasicInfo(params),this._updateUserJoinInfo(params)]),200==basicRes.code&&200==joinRes.code&&(updateLocalUser(parms),!0)}},{key:"_updateUserBasicInfo",value:async function _updateUserBasicInfo(params){const watchInitData=this.sdkInstance.store.get("watchInitData"),userInfo=this.sdkInstance.store.get("user"),reqParams={...params,biz_id:2,biz_application_id:watchInitData?.interact?.paas_app_id,consumer_id:userInfo?.user_id};if(!reqParams.biz_application_id||!reqParams.consumer_id||!userInfo?.token)return logger$2.error("updateUserBasicInfo params: ",reqParams),Promise.reject("用户基本信息参数错误,请刷新直播间重试.");console.log("updateUserBasicInfo params: ",reqParams);const res=await this.wxApi.sendPost("/v1/ucenter/app/user/modify-basic-info",reqParams,{headers:{"Content-Type":"application/x-www-form-urlencoded",token:userInfo.token}});return 200!==res?.code&&this.sdkInstance.BRSAgent?.customLog(`updateUserJoinInfo error. ${JSON.stringify(res)}`),res}},{key:"_updateUserJoinInfo",value:async function _updateUserJoinInfo(params){const watchInitData=this.sdkInstance.store.get("watchInitData"),reqParams={...params,webinar_id:watchInitData?.webinar?.id};if(!reqParams?.webinar_id||!watchInitData.interact?.interact_token)return logger$2.error("updateUserJoinInfo params: ",reqParams),Promise.reject("用户参会信息参数错误,请刷新直播间重试.");console.log("updateUserJoinInfo params: ",reqParams);const res=await this.wxApi.sendPost("/v3/webinars/watch/update-join-info",reqParams);return 200!==res?.code&&this.sdkInstance.BRSAgent?.customLog(`updateUserJoinInfo error. ${JSON.stringify(res)}`),res}},{key:"updateLocalUser",value:function updateLocalUser(updateObj){if(!updateObj||"object"!=typeof updateObj)return;updateObj.nick_name&&(updateObj.nickname=updateObj.nick_name,delete updateObj.nick_name);const storeUser=this.sdkInstance.store.get("user")||{};this.sdkInstance.store.set("user",{...storeUser,...updateObj})}},{key:"getUserInfo",value:async function getUserInfo(){}}])}();_defineProperty(UserServer,"name","UserServer");const logger$1=createLogger("LogReportServer");let LogReportServer=function(){return _createClass(function LogReportServer(sdkInstance){_classCallCheck(this,LogReportServer),logger$1.log("LogReportServer ctor:"),this.sdkInstance=sdkInstance,this.logReportBaseUrl=this.sdkInstance.envConfig.LOG_REPORT_BASE_URL,this.commonReportData={bu:0,webinar_id:this.sdkInstance.webinarId,os:this._getReportOs(),type:8,entry_time:formatTimestamp(Date.now()),pf:9,env:this.sdkInstance.env,ua:"",user_agent:""},this._watchInitData()},[{key:"_updateCommonReportData",value:function _updateCommonReportData(){const watchInitData=this.sdkInstance.store.get("watchInitData");isEmpty(watchInitData)||Object.assign(this.commonReportData,{user_id:watchInitData?.join_info?.join_id,third_party_user_id:watchInitData?.join_info?.third_party_user_id,email:watchInitData?.join_info?.email,app_id:watchInitData?.interact?.paas_app_id,t_start:formatTimestamp(Date.now())})}},{key:"_watchInitData",value:function _watchInitData(){this.sdkInstance.store.get({watchInitData:watchInitData=>{isEmpty(watchInitData)||this._updateCommonReportData()}})}},{key:"_getReportOs",value:function _getReportOs(){const platform=function getDevicePlatform(){try{if(!deviceInfo_platform){const res=wx.getDeviceInfo();deviceInfo_platform=res.platform}return deviceInfo_platform}catch(ex){return"unkown"}}();let os=0;return"windows"===platform?os=12:"mac"===platform||("android"===platform?os=10:"ios"===platform&&(os=11)),os}},{key:"report",value:async function report(code,body){const token=Object.assign({},this.commonReportData,body),reportData={k:code,id:Date.now(),bu:0,token:gBase64_encode(JSON.stringify(token))};wx.request({url:this.logReportBaseUrl,method:"GET",data:reportData,success(res){},fail(err){}})}}])}();_defineProperty(LogReportServer,"name","LogReportServer");const BonreeSDK=function requireBonreeSDK_MP_Wechat_min(){if(hasRequiredBonreeSDK_MP_Wechat_min)return bonreeSDK_MP_Wechat_min;hasRequiredBonreeSDK_MP_Wechat_min=1;const Ge=t=>t instanceof Date?t:new Date,We=t=>t<10?"0"+t:""+t;function cr(t=new Date){return[(t=Ge(t)).getHours(),t.getMinutes(),t.getSeconds()].map(We).join(":")}function hr(t=new Date){return[(t=Ge(t)).getFullYear(),t.getMonth()+1,t.getDate()].map(We).join("-")}const Pt=()=>{},y={log:Pt,info:Pt,warn:Pt,debug:Pt,error:Pt},d=wx;function lr(){switch(function ur(){return(t=d.getSystemInfoSync())&&t.inFinChat?3:1;var t}()){case 1:return"WeChat";case 2:return"TikTok";case 3:return"FinClip";default:return}}const x="BonreeRUM",Dt="2.2.3",pe="2024041001",Q="mpview",Xt="custom_mpview",wt="action",nt="launch",$t="statechange",ge="network_statechange",gt="userchange",qt="span",Bt="jserror",bt="network",te="customlog",ee="speedtest",kt="customevent",ne="custommetric",re="crash",ie="clear_data",me="upload_data",ve="check_data",Ie="stop",ye="get_config",mt_CLEAR_DATA="clear_data",mt_GET_SIN_KEY="get_sin_key",mt_GET_DATA="get_data",At=Symbol("$hook"),pr=["unknown","http1.1","h1s","h2","","ws","wss","tcp","","","udp","quic"],ae="$$BonreeCfg",se="$$BonreeUploadData",Ee="$$BonreeAttributeData",Ye="$$BonreeCacheData",Ze="$$DEVICE_ID",Qe="firstVisitDayTime",Xe_ENCODE_URL_QUERY="_bonree_encode_url_query",vt_DEPTH="d",vt_SHARE_ID="i",vt_KEY="bonreeShare",z=256,It_MUST_STRING="Please pass in a string type parameter!",Ft="sm4",F_NAME="sessionReplay",F_SET_CONFIG="setConfig",F_SET_UPLOAD_DATA="setUploadData",F_INIT_DRAWER="initDrawer",F_SET_CANVAS_DRAWER="setCanvasDrawer",F_INIT_RECORD="initRecord",F_FINISH_RECORD="finishRecord",F_PAUSE_RECORD="pauseRecord",F_RESUME_RECORD="resumeRecord",F_CHECK_UPLOAD_DATA="checkUploadData",F_SET_VALUE="setValue",v_GET_CONFIG="getConfig",v_START_RELATE="startRelate",v_STOP_RELATE="stopRelate",v_SET_CURRENT_ROOT_ID="setCurrentRootId",v_GENERATE_RELATE="generateRelate",v_SET_LAST_ROOT_ID="setLastRootId",v_CLEAR_CURRENT_ID="clearCurrentId",v_CHECK_RELAT="checkRelat",v_SET_ROOT_NODE_DATA="setRootNodeData",v_ADD_RELATE_EVENT_DATA="addRelateEventData";var C=function(){};function c(t){return null!=t}function yt(t){return c(t)&&t instanceof Array}function gr(t){return c(t)&&!function(e){if(c(e)){if(Jt(e,"length"))return!e.length;if(Jt(e,"size"))return!e.size;for(var n in e)if(Jt(e,n))return}return 1}(t)}function Kt(t,e){return(yt(t)?function(n,r){if(yt(n))for(var i=0,a=n.length;i<a&&!1!==r(n[i],i);i++);}:Et)(t,e)}function Et(t,e){if(c(t))for(var n in t)if(Jt(t,n)&&!1===e(t[n],n))break}function L(t,e){return t&&e&&Et(e,function(n,r){t[r]=n}),t}function R(){return Date.now()}function q(){return O(_(32),8)+"-"+O(_(16),4)+"-"+O(16384|_(12),4)+"-"+O(32768|_(14),4)+"-"+O(_(48),12)}function oe(t){return c(t.length)?Array.prototype.slice.call(t):t}function tn(t,e){return!!(t&&e&&t.length>=e.length)&&t.substring(t.length-e.length)===e}function mr(t,e){return t?t.length<=e?t:t.substr(0,e-3)+"...":""}function en(t,e){return!(!t||!t.indexOf)&&0===t.indexOf(e)}function zt(t){if(E(t))try{var e=JSON.parse(t);return!("object"!=typeof e||!e)}catch(n){}else if("object"==typeof t)return!0;return!1}function E(t){return"[object String]"===Object.prototype.toString.call(t)}function nn(t){return""===t}function ut(t){return"number"==typeof t&&!isNaN(t)}const vr=Object.assign;function N(){return+new Date}function lt(t){return"function"==typeof t}function k(t){return"object"==typeof t}function rn(t){let e=0;for(let r=0,i=t.length;r<i;r++){var n=t.charCodeAt(r);e+=n<=127?1:n<=2047?2:n<=65535?3:4}return e}function Vt(t){if(t){if("string"==typeof t)return rn(t);if(t instanceof ArrayBuffer)return t.byteLength;if(k(t)){let e="";try{e=JSON.stringify(t)}catch(n){}return rn(e)}}return 0}function Te(t){if(c(t))return Array.isArray(t)||t.length?t.length:0}function an(t){var e=[];for(const n in t=t||{})Object.prototype.hasOwnProperty.call(t,n)&&void 0!==t[n]&&e.push(n+"="+Ir(t[n],"msg"===n));return e.join("&")}function Ir(t,e){try{t=e?encodeURIComponent(t).replace(/\(/g,"%28").replace(/\)/g,"%29"):encodeURIComponent(t)}catch(n){}return t}function Re(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function dt(t){try{return d.getStorageSync(t)}catch(e){try{return d.getStorageSync(t)}catch(n){console.debug(t," GetStorage fail!\n",n)}}}function ce(t,e){try{d.setStorageSync(t,e)}catch(n){try{d.setStorageSync(t,e)}catch(r){console.debug(t," SetStorage fail!\n",r)}}}function Jt(t,e){return t&&Object.prototype.hasOwnProperty.call(t,e)}function yr(t){if(t)return t.split(" ")[1]||"0"}function V(t,e,n,r,i){return void 0!==t&&(null==e||""===e||null!==r&&e.length>r||!(!i||!isNaN(e)))}function U(t,e){return t&&t.length>e?t.slice(0,e):t}function _(t){return t<0?NaN:t<=30?0|Math.random()*(1<<t):t<=53?(0|Math.random()*(1<<30))+(0|Math.random()*(1<<t-30))*(1<<30):NaN}function O(t,e){for(var n=t.toString(16),r=e-n.length,i="0";0<r;r>>>=1,i+=i)1&r&&(n=i+n);return n}function sn(t){var e=Math.floor(100*Math.random());return!(0<=t&&t<=100)||e<t}function Er(t){return 0<=t&&t<=100&&sn(t)?"00-"+O(_(32),8)+O(_(32),8)+O(_(32),8)+O(_(32),8)+"-"+O(_(32),8)+O(_(32),8)+"-01":"00-"+O(_(32),8)+O(_(32),8)+O(_(32),8)+O(_(32),8)+"-"+O(_(32),8)+O(_(32),8)+"-00"}function on(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{var e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}function cn(t){return 16==t?O(_(32),8)+O(_(32),8):32==t?O(_(32),8)+O(_(32),8)+O(_(32),8)+O(_(32),8):void 0}function Se(t){return/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/i.test(t)}function De(t){var e=/^(?:https?:\/\/)?(?:[^/@]+@)?(?:([^:/?#]+)|(?:\[(.*?)\]))/i.exec(t),n=/\?([^#]+)/i.exec(t);return{href:t,hostname:e&&e[1]||"",search:n&&n[1]||""}}function Nt(t){return/^[:a-zA-Z0-9_\-\s.@/]+$/.test(t)&&!/^[\s]+$/.test(t)}function Tr(n,e){var r=(n=String(n).split(e)).shift();return{startStr:r,endStr:n.join(e),all:n.concat([r])}}function he(){try{var t=getCurrentPages();if(0<t.length)return t[t.length-1];console.warn("get current page: failed")}catch(e){}}function we(t=he()){let e="";try{t&&(e=t.route)}catch(n){}return e}function hn(t=he()){let e="";return t&&"[object Object]"===Object.prototype.toString.call(t)&&t[Xe_ENCODE_URL_QUERY]?t[Xe_ENCODE_URL_QUERY]:e}function be(n=he()){var e=we(n);n=hn(n);return e?n?e+"?"+n:e:""}function un(t){let e;try{e=decodeURIComponent(t)}catch(n){e=t}return e}function ln(t){return 0<=["number","boolean","string"].indexOf(typeof t)}function Ht(t,e){return c(t)&&E(t)&&0<String(t).length&&String(t).length<=e&&Nt(t)}function dn(){return d.BonreeRUM&&d.BonreeRUM.viewInfo?d.BonreeRUM.viewInfo:{}}function ft(){return!d.BonreeRUM||d.BonreeRUM.$$Bonree||d.BonreeRUM.$$FinClip}const Rr=[Xt,gt,qt,te,ee,kt,ne,re,ie,ve,ye,me,ge,Ie];function T(t,e,n){if(d[x]){var r=d[x]&&d[x].emits,i=W.appId;for(let a=0;a<r.length;a++){const s=r[a],o=s.appId;-1<Rr.indexOf(t)&&o!==i||s.emit(t,e,o,n)}}}function _t(){this.plugin={},this.registedPlugin=new Set,this.pluginCfg={}}_t.prototype.register=function(t,e,n){t&&e&&(this.plugin[t]=e,this.pluginCfg[t]=n,this.registedPlugin.add(t))},_t.prototype.install=function(t,e){var n;t&&k(t)&&(n=t.name,t=t.exec,this.registedPlugin.has(n)||this.register(n,t,e))},_t.prototype.use=function(t){return this.plugin[t]},_t.prototype.has=function(t){return this.registedPlugin.has(t)},_t.prototype.getPluginCfg=function(t){return this.pluginCfg[t]};var ot=new _t;const H={sessionReplay:null,cfg:null,statu:!1,register:!1};function X(t,e){var n;!1===H.register&&ot&&(H.sessionReplay=ot.use(F_NAME),H.cfg=ot.getPluginCfg(F_NAME),H.register=!0,H.sessionReplay)&&k(H.sessionReplay)&&(H.statu=!0,H.sessionReplay[F_SET_VALUE])&&H.sessionReplay[F_SET_VALUE]({type:1,key:"option",value:H.cfg}),!0===H.register&&!1===H.statu||(n=H.sessionReplay)&&n[t]&&n[t](e)}const Gt={smKey:"",identifier:""},rt={encrypt:function(t){const e=ot.use(Ft),n=ot.getPluginCfg(Ft),r=n&&n.key,i=n&&n.identifier||"";if(Gt.identifier=i,e&&t&&n&&r&&i){Gt.smKey=r;const a=JSON.stringify(t);try{return e(a,r,1)||t}catch(s){console.warn("encrypt data error!",s)}}return t},decrypt:function(t,a){var n,r=ot.use(Ft),i=Gt.smKey;a=a&&a.split(":")[1];if(r&&t&&i&&t instanceof ArrayBuffer&&a===Gt.identifier)try{if(n=r(t,i,0))return JSON.parse(n)}catch(s){console.warn("decrypt data error",s)}},createReqHeader:function(){if(ot.has(Ft)){var t=(e=ot.getPluginCfg(Ft))&&e.identifier,e=e&&e.key;if(t&&e&&/^[A-Za-z0-9_-]{1,256}$/.test(t))return"sm4:"+t}},hasSm4:function(){return!!Gt.smKey}};function G(){this.currentUserId=null,this.currentCorrelationId="",this.deviceInfo={},this.appInfo={ai:"",av:"1.0.0",an:"",ci:"",at:5},this.shareInfo={flag:!1,s:1001,sl:0,iso:!1},this.cacheData={firstVisitTime:0,firstVisitDayTime:0},this.appLaunchInfo={initTime:R(),isFirstLaunch:!1},this.sessionStartTime=0,this.userAgent=null,this.launchTime=null,this.pageHideTime=null,this.eventViewInfo={},this.userInfoMap={},this.userInfoFui=null,this.networkStateInfo={dip:"",ns:""},this.networkStateInfoMap={},this.eventExtInfo={},this.channel=null,this.stopAgent=!1,this.unableConfig=!1,this.getSysInfo(),this.getAppInfo()}G.prototype.getSysInfo=function(){var t,e=d.getSystemInfoSync(),n=function Sr(){let t=dt(Ze);return t||(e=q(),ce(Ze,e),e);var e}();this.deviceInfo={di:n,a:"user",bn:e.brand,m:e.model,omv:e.system&&yr(e.system),ot:e.system&&((t=e.system)&&"string"==typeof t?-1<t.toLowerCase().indexOf("ios")?0:-1<t.toLowerCase().indexOf("android")?1:-1<t.toLowerCase().indexOf("windows")?2:-1<t.toLowerCase().indexOf("harmony")?3:4:4),l:e.language,ds:e.screenWidth+"*"+e.screenHeight,ram:-1,rom:-1,ctn:lr(),ctv:e.version},this.cacheData.clientId=n},G.prototype.getAppInfo=function(){var t={ai:(t=(t=d.getAccountInfoSync())&&t.miniProgram||{})&&t.appId||"",av:t&&t.version||"1.0.0",an:__wxConfig&&__wxConfig.accountInfo&&__wxConfig.accountInfo.nickname||"unkonw",ci:"",at:5};this.appInfo.an&&(t.an=this.appInfo.an),this.appInfo=Object.assign(this.appInfo,t)},G.prototype.setChannelId=function(t){V("channelId",t,0,z,!1)||(c(t)&&"string"==typeof t?this.appInfo.ci=t:y.log("Failed to set channel ID!"))},G.prototype.setAppVersion=function(t){c(t)&&"string"==typeof t&&Te(t)<=64?this.appInfo.av=t:y.log("Failed to set app version!")},G.prototype.setDeviceId=function(t){V("deviceID",t,0,z,!1)||/^[a-zA-Z0-9_-]+$/.test(t)&&(this.deviceInfo.di=t)},G.prototype.setAppName=function(t){V("appName",t,0,64,!1)||(this.appInfo.an=t)},G.prototype.closeConfig=function(){this.unableConfig=!0},G.prototype.closeAgent=function(t){t=!t,d.BonreeRUM&&(d.BonreeRUM.$$Bonree=t)},G.prototype.getIsFirstDay=function(){var t=this.cacheData.firstVisitDayTime,e=Date.now();return!!(t&&e<t)},G.prototype.setPageHideTime=function(t){return c(t)?this.pageHideTime=t:this.pageHideTime=R(),this},G.prototype.setScene=function(t){this.shareInfo.s=t,this.sendSessionReplayInfo(),this.shareInfo.flag=!0},G.prototype.sendSessionReplayInfo=function(){var t={di:this.deviceInfo,ai:Object.assign({},this.appInfo,this.shareInfo),v:pe,d:this.deviceInfo.di,a:this.appInfo.ai,sdkVersion:Dt};X(F_SET_UPLOAD_DATA,t)};var p=new G,W={confCount:5,beacon:{configAddress:"https://sdkupload.bonree.com/config"},appId:1,debug:!1,timeout:3e4,consoleError:!1,cacheSize:1038090240},A=W;const tt=new(function(){return _createClass(function _class(){_classCallCheck(this,_class),this.currentRootId="",this.lastRootId="",this.currentRelateId="",this.relateEventDatas={},this.maxTime=3e4,this.unModu=[]},[{key:"startRelate",value:function startRelate(t,e,n){let r="root";this.checkConfig(e)||(e!==Q&&e!==nt||(this.currentRelateId=t,this.lastRootId&&e===Q&&this.getRelateEventData(this.lastRootId)&&(r=this.lastRootId,this.currentRelateId=t)),this.currentRootId=t,e=new Dr(t,r,e,n),this.relateEventDatas[t]=e)}},{key:"checkRelat",value:function checkRelat(){!this.currentRootId&&this.currentRelateId&&(this.currentRootId=this.currentRelateId)}},{key:"checkConfig",value:function checkConfig(t){return-1<this.unModu.indexOf(t)}},{key:"getConfig",value:function getConfig(t){this.unModu=t}},{key:"setRootNodeData",value:function setRootNodeData(t,e,n){this.relateEventDatas[t]&&(t=this.relateEventDatas[t],e=this.format(e,!0),t.setRootNodeData(e,n))}},{key:"format",value:function format(t,e){return t={k:t.type,ent:t.ent||1e3*R(),sin:t.sin,v:t.data},e&&(t.revts=[]),t}},{key:"stopRelate",value:function stopRelate(t,e){this.currentRootId="",e!==wt&&e!==nt||(this.lastRootId=t)}},{key:"clearCurrentId",value:function clearCurrentId(){this.currentRootId=""}},{key:"packageData",value:function packageData(t,e){const n=this.getRelateEventData(t),r=this.hasChrildNode(t);if(n&&"root"===n.parentRootId&&!r&&n.rootNodeData.revts){const i=n.rootNodeData||{};e&&i.revts&&(i.revts.push(e),0<n.relateData.length)&&(i.revts=i.revts.concat(n.relateData)),delete this.relateEventDatas[t],clearTimeout(n.timeoutId),this.uploadData(i)}else if(n&&!r&&n.rootNodeData.revts){n.rootNodeData.revts=n.rootNodeData.revts.concat(n.relateData);const i=n.rootNodeData,a=n.parentRootId;delete this.relateEventDatas[t],i.revts&&0===i.revts.length&&delete i.revts,this.packageData(a,i)}else!n||"root"!==n.parentRootId||r||n.rootNodeData.revts||n.relateData.push(e)}},{key:"packageSelf",value:function packageSelf(t){var e,n;this.relateEventDatas[t]&&(n=(e=this.relateEventDatas[t]).parentRootId)&&this.relateEventDatas[n]&&(this.relateEventDatas[n].relateData.push(e.rootNodeData),delete this.relateEventDatas[t])}},{key:"uploadData",value:function uploadData(t){T(me,t)}},{key:"getCurrentRootId",value:function getCurrentRootId(){return this.currentRootId}},{key:"setCurrentRootId",value:function setCurrentRootId(t){return this.currentRootId=t,this}},{key:"setLastRootId",value:function setLastRootId(t){return this.lastRootId=t,this}},{key:"generateRelate",value:function generateRelate(t,e,n){this.relateEventDatas[t]&&!this.checkConfig(n)&&this.relateEventDatas[t].addRelateEventIds(e)}},{key:"addRelateEventData",value:function addRelateEventData(t,e,n,r){if(!this.checkConfig(r)&&this.relateEventDatas[t]){const i=this.relateEventDatas[t],a=this.format(n);i.addRelateEventData(e,a)}}},{key:"updateCurrentId",value:function updateCurrentId(){}},{key:"setRelateEventData",value:function setRelateEventData(t,e){this.relateEventDatas[t]=e}},{key:"getRelateEventData",value:function getRelateEventData(t){return this.relateEventDatas[t]}},{key:"delRelateEventData",value:function delRelateEventData(t){delete this.relateEventDatas[t]}},{key:"getNodeNumber",value:function getNodeNumber(t){if(this.relateEventDatas[t])return this.relateEventDatas[t].currentNodeNumber}},{key:"hasChrildNode",value:function hasChrildNode(t){for(const e in this.relateEventDatas)if(this.relateEventDatas[e].parentRootId===t)return!0;return!1}}])}());let Dr=function(){return _createClass(function Dr(e,n,r){_classCallCheck(this,Dr),this.rootId=e,this.parentRootId=n,this.childRootId="",this.rootNodeData={},this.relateData=[],this.relateEventIds=new Set,this.rootNodeType=r,this.timeoutId=0,this.maxNode=200,this.currentNodeNumber=0,"root"===this.parentRootId&&this.startTiming()},[{key:"setRootNodeData",value:function setRootNodeData(e,n){if(this.rootNodeData=e,"root"===this.parentRootId&&0===this.relateEventIds.size)this.rootNodeData.revts=this.rootNodeData.revts.concat(this.relateData),this.rootNodeType===wt||n?setTimeout(()=>{tt.packageData(this.rootId)},2e3):tt.packageData(this.rootId);else if("root"!==this.parentRootId){const r=this.getRootNodeInfo();c(r.rootNodeRelateIdNumbe)&&0===r.rootNodeRelateIdNumbe?tt.packageData(this.rootId):"root"!==this.parentRootId&&0===this.relateEventIds.size&&(this.rootNodeData.revts&&0===this.rootNodeData.revts.length&&delete this.rootNodeData.revts,tt.packageSelf(this.rootId))}}},{key:"addRelateEventData",value:function addRelateEventData(e,n){this.relateEventIds.has(e)&&(this.relateData.push(n),this.delRelateEventIds(e)),n=this.getRootNodeInfo(),this.rootNodeData.revts&&c(n.rootNodeRelateIdNumbe)&&0===n.rootNodeRelateIdNumbe&&(this.rootNodeData.revts=this.relateData.concat(),this.relateData=[],tt.packageData(this.rootId))}},{key:"addRelateEventIds",value:function addRelateEventIds(e){const n=this.getRootNodeInfo();if(c(n.rootNodeNumber)&&!(200<=n.rootNodeNumber)&&(this.relateEventIds.add(e),++this.currentNodeNumber,"root"!==this.parentRootId)){const r=tt.getRelateEventData(this.parentRootId);r&&r.addRelateEventIds(e)}}},{key:"delRelateEventIds",value:function delRelateEventIds(e){var n;this.relateEventIds.has(e)&&this.relateEventIds.delete(e),"root"!==this.parentRootId&&(n=tt.getRelateEventData(this.parentRootId))&&n.delRelateEventIds(e)}},{key:"startTiming",value:function startTiming(){this.timeoutId=setTimeout(()=>{const e=this.rootId,n=tt.relateEventDatas;let r=!1,i="rootId";for(const o in n){var a=n[o];a&&a.relateEventIds&&a.parentRootId===e&&(r=!0,a.relateEventIds.clear()),a&&a.relateEventIds&&a.rootId===e&&a.relateEventIds.clear()}r&&(i="parentRootId");for(const o in n){var s=n[o];if(s&&s.relateEventIds&&s[i]===e){const h=s.rootId;tt.packageData(h)}}this.relateEventIds.clear()},3e4)}},{key:"getRootNodeInfo",value:function getRootNodeInfo(){var e;return"root"!==this.parentRootId?(e=tt.getRelateEventData(this.parentRootId))?e.getRootNodeInfo():{}:{rootNodeNumber:this.currentNodeNumber,rootNodeRelateIdNumbe:this.relateEventIds.size}}}])}();function M(t,e){if(d.BonreeRUM&&d.BonreeRUM.relateEvents){var n=Object.keys(d.BonreeRUM.relateEvents);for(let a=0;a<n.length;a++){var r=n[a],i=d.BonreeRUM.relateEvents[r];switch(t){case v_GET_CONFIG:if(r!==W.appId)continue;i[v_GET_CONFIG](e.unModu);continue;case v_START_RELATE:i[v_START_RELATE](e.rootId,e.type);continue;case v_STOP_RELATE:i[v_STOP_RELATE](e.rootId,e.type);continue;case v_SET_CURRENT_ROOT_ID:i[v_SET_CURRENT_ROOT_ID](e.rootId);continue;case v_GENERATE_RELATE:i[v_GENERATE_RELATE](e.rootId,e.id,e.type);continue;case v_SET_LAST_ROOT_ID:i[v_SET_LAST_ROOT_ID](e.rootId);continue;case v_CLEAR_CURRENT_ID:i[v_CLEAR_CURRENT_ID]();continue;case v_CHECK_RELAT:i[v_CHECK_RELAT]();continue;case v_SET_ROOT_NODE_DATA:if(r!==W.appId)continue;i[v_SET_ROOT_NODE_DATA]();continue;case v_ADD_RELATE_EVENT_DATA:if(r!==W.appId)continue;i[v_ADD_RELATE_EVENT_DATA]();continue;default:continue}}}}function Ct(){if(d.BonreeRUM&&d.BonreeRUM.relateEvents)return(d.BonreeRUM.relateEvents[W.appId]||{}).currentRootId}function fn(t,e){var n;arguments.length<1||2<arguments.length?y.warn("Custom log parameters are missing!"):E(t)?V("logInfo",t,0,null,!1)||(n={},t=c(t)&&U(t,1e4)||"",e=c(e)&&U(e,1e4)||"",n.logInfo=t,n.logParam=e,T(te,n)):console.warn(It_MUST_STRING)}function pn(t,e,n){var r;arguments.length<1||3<arguments.length?y.warn("Custom indicator parameters are missing!"):E(t)?V("metricName",t,0,z,!1)||V("metricValue",e,0,null,!0)||(n&&1e4<n.length&&(n=U(n,1e4)),(r={}).metricName=c(t)?t:"",r.metricValue=c(e)?e:"",r.metricParam=c(n)?n:"",T(ne,r)):console.warn(It_MUST_STRING)}function gn(t,e){var n;arguments.length<1||2<arguments.length?y.warn("SetCustomSpeedTest custom log parameter number error!"):V("ip",t,0,z,!1)||(Array.isArray(e)&&0<e.length&&e.length<=1e3?((n={}).oip=t,n.sti=e,T(ee,n)):y.warn("The second parameter passed through the custom speed testing interface is invalid!"))}const Ot=new(function(){return _createClass(function _class2(){_classCallCheck(this,_class2),this.spansData={},this.spanIdArr=[],this.isOpen=!0},[{key:"startSpan",value:function startSpan(t,e){var n;return t&&E(t)&&e&&E(e)&&Nt(e)&&Nt(t)?(t=U(t,256),e=U(e,256),n=q(),this.spanIdArr.push(n),t=new Qt(t,e,!0,1,n,n),this.setSpan(n,t),this.checkSpanSize(),t):new Qt}},{key:"getSpan",value:function getSpan(t){return this.spansData[t]}},{key:"setSpan",value:function setSpan(t,e){this.spansData[t]=e}},{key:"delSpan",value:function delSpan(t){this.spansData[t]&&(delete this.spansData[t],this.spanIdArr.pop(t))}},{key:"uploadSpan",value:function uploadSpan(t,e){var n=this.getSpan(t);n&&n.sub&&mn(n.sub,e),n&&(c(n.du)||(n.du=R()-n.st),n.st=0,T(qt,{data:n,startTime:1e3*e,isOpen:this.isOpen}),this.delSpan(t))}},{key:"checkSpanSize",value:function checkSpanSize(){var t;20<this.spanIdArr.length&&(t=this.spanIdArr.pop(),this.delSpan(t))}},{key:"isOpen",value:function isOpen(t){this.isOpen=!0===t}}])}());let Qt=function(){function Qt(e,n,r,i,a,s){_classCallCheck(this,Qt),this.status=!!a,this.n=e,this.t=n,this.st=R(),this.du=null,this.sta=null,this.ic=r,s&&(this.spanId=s,this.spanNodes=1),this.recordInfo={deep:i,rootSpanId:a,spanState:!0}}return _createClass(Qt,[{key:"startChild",value:function startChild(e,n){var r,i;return e&&E(e)&&n&&E(n)&&Nt(n)&&Nt(e)?(this.status=!0,e=U(e,256),n=U(n,256),r=this.recordInfo.rootSpanId,i=++(Ot.getSpan(r)||{}).spanNodes,e=new Qt(e,n,!0,this.recordInfo.deep+1,r),this.recordInfo.deep<=10&&i<=201&&(this.sub||(this.sub=[]),this.sub.push(e)),e):new Qt}},{key:"setData",value:function setData(e,n){var r;this.status&&E(e)&&Ne(e)&&c(n)&&E(n)&&!nn(n)&&(this.da&&64<=this.da.length||(r={k:e,v:U(n,7e3)},this.da?Ae(this.da,e,n)&&this.da.push(r):(this.da=[],this.da.push(r))))}},{key:"removeData",value:function removeData(e){this.status&&c(e)&&E(e)&&e.length<=200&&this.da&&0<this.da.length&&(this.da=ke(this.da,e))}},{key:"setTag",value:function setTag(e,n){var r;this.status&&E(e)&&Ne(e)&&E(n)&&c(n)&&!nn(n)&&(this.tag&&64<=this.tag.length||(r={k:e,v:U(n,7e3)},this.tag?Ae(this.tag,e,n)&&this.tag.push(r):(this.tag=[],this.tag.push(r))))}},{key:"removeTag",value:function removeTag(e){this.status&&c(e)&&E(e)&&e.length<=200&&this.tag&&0<this.tag.length&&(this.tag=ke(this.tag,e))}},{key:"setMetric",value:function setMetric(e,n,r){var i;this.status&&E(e)&&Ne(e)&&ut(n)&&(this.m&&64<=this.m.length||(i={k:e,v:n},E(r)&&Nt(r)&&r.length<=256&&(i.u=r),this.m?Ae(this.m,e,n,r)&&this.m.push(i):(this.m=[],this.m.push(i))))}},{key:"removeMetric",value:function removeMetric(e){this.status&&c(e)&&E(e)&&e.length<=200&&this.m&&0<this.m.length&&(this.m=ke(this.m,e))}},{key:"setDuration",value:function setDuration(e){this.status&&c(e)&&ut(e)&&(this.du=e)}},{key:"setStatus",value:function setStatus(e){this.status&&ut(e)&&(this.sta=e)}},{key:"setStatusCode",value:function setStatusCode(e){this.status&&c(e)&&E(e)&&(e&&7e3<e.length||(this.stac=e))}},{key:"finish",value:function finish(e){this.status&&(c(e)&&ut(e)?this.sta=e:c(this.sta)||(this.sta=1),c(this.du)||this.spanId||(this.du=R()-this.st),this.spanId&&Ot.uploadSpan(this.spanId,this.st),this.status=!1)}}])}();function ke(t,e){for(let r=0;r<t.length;r++){var n=t[r];if(n&&n.k===e)return t.splice(r,1),t&&0===t.length?void 0:t}return t}function Ae(t,e,n,r){for(let i=0;i<t.length;i++)if(t[i]&&t[i].k===e)return t[i].v=n,c(r)&&(t[i].u=r),!c(r)&&c(t[i].u)&&delete t[i].u,!1;return!0}function mn(t,e){if(t&&0<t.length){50<t.length&&t.splice(50);for(let r=0;r<t.length;r++){var n=t[r]||{};c(n.du)||(n.du=R()-n.st),e&&(n.st=n.st-e),c(n.sta)||(n.sta=1),n.recordInfo&&delete n.recordInfo,c(n.status)&&delete n.status,n&&n.sub&&mn(n.sub,e)}}}function Ne(t){return/^[a-zA-Z][a-zA-Z\._-]{0,199}$/.test(t)}let xt=[];function vn(t,e,n="",r="",i){var a;arguments.length<1||5<arguments.length?y.warn("Custom event parameters are missing!"):E(t)?V("eventId",t,0,z,!1)||i&&k(i)&&7e3<JSON.stringify(i).length||(a={},e=U(e,z),r=U(r,7e3),a.eventId=c(t)?t:"",a.eventName=e,a.eventParam=r,a.eventLabel=U(n,256),a.info=i,a.type=0,T(kt,a)):console.warn(It_MUST_STRING)}function In(t,e,n="",r="",i){if(arguments.length<1||5<arguments.length)y.warn("Custom event start parameter is missing!");else if(E(t)){if(!(V("eventId",t,0,z,!1)||i&&k(i)&&7e3<JSON.stringify(i).length)){var a={};e=U(e,z),r=U(r,7e3),e=(a.eventId=c(t)?t:"",a.eventName=e,a.eventParam=r,a.eventLabel=U(n,256),a.info=i,a.type=1,q()),r={uid:a.uid=e,id:t,time:1e3*R()};let h=!1;0<xt.length&&xt.map(f=>{f.id===t&&(h=!0)}),h||(n=r,xt=xt.concat(n),T(kt,a))}}else console.warn(It_MUST_STRING)}function yn(t,e,n="",r,i){var a;arguments.length<1||5<arguments.length?y.warn("Custom event end parameter is missing!"):E(t)?V("eventId",t,0,z,!1)||i&&k(i)&&7e3<JSON.stringify(i).length||(a={},e=U(e,z),r=U(r,7e3),a.eventId=c(t)?t:"",a.eventName=e,a.eventParam=r,a.eventLabel=U(n,256),a.info=i,a.type=2,c(e=function(s){const o=xt.concat();let h=null;return o.map((f,u)=>{f.id===s&&(h=f,o.splice(u,1))}),xt=o.concat(),h}(t))&&(a.duration=1e3*R()-e.time,a.uid=e.uid,T(kt,a))):console.warn(It_MUST_STRING)}let ct={},Ut={},it=null;const Wt=[];let _e=!1;const br=()=>{try{var t=dt(Ee);t&&"object"==typeof t&&L(ct,t)}catch(e){}},ue=()=>{d.setStorage({key:Ee,data:ct,fail(){d.setStorage({key:Ee,data:ct})}})};function kr(){var t,e,n,r,i=L(Ut,ct);return 0===Object.keys(i).length?"":(t=q(),null===it?(it=t,Wt.push(it),p.eventExtInfo[t]=Object.assign({},i),t):(e=p.eventExtInfo[it],n=JSON.stringify(e),r=JSON.stringify(i),e&&n==r?it:e&&r!==n?(it=q(),p.eventExtInfo[it]=Object.assign({},i),Wt.push(it),t):""))}function Ce(t,e=!1){let n=!1;var r=e?ct:Ut;let i=0;if(k(t)){for(const o in t)if(Ht(o,256)){let h=t[o];var a=Object.keys(ct).length||0,s=Object.keys(Ut).length||0;i<64&&a+s<64&&ln(h)&&0<String(h).length&&c(h)&&(512<String(h).length&&(h=String(h).slice(0,512)),r[o]=h,i+=1,n=!0)}_e=!1,!e&&n&&ue()}}function En(t,e,n){c(t)&&E(t)&&c(e)&&Ce({[t]:e},n)}function Tn(){Ut={},ct={},ue(),_e=!0}function Rn(t){if(yt(t)){let e=!1;for(const n of t)ct.hasOwnProperty(n)&&(e=!0,delete ct[n]),Ut.hasOwnProperty(n)&&(e=!0,delete Ut[n]);e&&ue()}}function Sn(t,e){var n=p.currentUserId;c(n)&&""!==n&&c(e)&&0<String(e).length&&Ht(t,256)&&(512<String(e).length&&(e=String(e).slice(0,512)),T(gt,{userId:n,command:2,info:{[t]:e}}))}function Dn(t){const e=p.currentUserId;if(c(e)&&""!==e){if("object"!=typeof t||null===t)return!1;if(0!=Object.keys(t).length){let r=0;var n={};for(const i in t){let a=t[i];if(r<64&&c(a)&&0<String(a).length&&ln(a)&&Ht(i,256)&&(512<String(a).length&&(a=String(a).slice(0,512)),n[i]=a,r+=1),64<r)break}T(gt,{userId:e,command:1,info:n})}}}function wn(t,e){var n=p.currentUserId;c(n)&&""!==n&&ut(e)&&Ht(t,256)&&T(gt,{userId:n,command:4,info:{[t]:e}})}function bn(t){var e=p.currentUserId;c(e)&&""!==e&&Ht(t,256)&&T(gt,{userId:e,command:3,info:{[t]:""}})}let et={ui:null,ei:null},le=null;function kn(t){if(c(t)){if(V("userId",t,0,z,!1)||!/^[\u4E00-\u9FFFa-zA-Z0-9:._\-@/*#!]+$/.test(t))return;p.currentUserId=t,et=Object.assign({},et,{ui:t})}else p.currentUserId=t,et={ui:null,ei:null};Nn()}function An(t){var e;k(t)&&(e=JSON.stringify(t),t&&(7e3<e.length||"{}"==e)||et.ui&&(et.ei=JSON.stringify(t),Nn()))}function Nn(){if(c(et.ui)){const t={ui:et.ui};c(et.ei)&&(t.ei=et.ei);let e=!1;const n=L({},p.userInfoMap);if(0<Object.keys(n).length&&Object.entries(n).forEach(function(r){JSON.stringify(r[1])===JSON.stringify(t)&&(le=r[0],e=!0)}),!e){const r=q(),i=(le=r,p.userInfoFui=r,p.userInfoMap[r]=L({},t),{[r]:et.ui});X(F_SET_VALUE,{type:0,key:"ui",value:i})}}else le=null}let Lt=[];function _n(t,e){if(arguments.length<1||2<arguments.length)y.warn("Custom page starts with missing parameters!");else if(E(t)&&E(e)){if(!V("name",t,0,null,!1)){var n={},r=q(),i=(e=c(e)&&U(e,z)||"",{uid:r,name:t,time:1e3*R()}),a=Lt;let s=!1;0<a.length&&a.map(o=>{o.name===t&&(s=!0)}),s||((a=Ct())&&M(v_GENERATE_RELATE,{rootId:a,id:r,type:Q}),Lt=Lt.concat(i),n.ci=r,n.lt=999,n.m=1,n.pvid=r,n.rt=999,n.st=999,n.is=!1,n.std=[],n.name=c(t)?t:"",n.ic=!0,n.param=e||"",T(Xt,{data:n,mode:1,rootId:a}))}}else console.warn(It_MUST_STRING)}function Cn(t,e){var n,r,i;arguments.length<1||2<arguments.length?y.warn("Custom page end with missing parameters!"):E(t)&&E(e)?V("name",t,0,null,!1)||(e=c(e)&&U(e,z)||"",n={},c(r=function(a){const s=Lt&&Lt.concat();let o=null;return s.map((h,f)=>{h.name===a&&(o=h,s.splice(f,1))}),Lt=s.concat(),o}(t))&&(i=1e3*R()-r.time,n.ci=r.uid,n.lt=999,n.m=3,n.pvid=r.uid,n.rt=999,n.is=!1,n.std=[],n.name=c(t)?t:"",n.ic=!0,n.param=e||"",n.st=i,T(Xt,{data:n,mode:3}))):console.warn(It_MUST_STRING)}function On(t,e,n){var r;E(t)&&E(e)&&E(n)&&(V("exceptionType",t,0,z,!1)||(r={},e=c(e)&&U(e,512)||"",n=c(n)&&U(n,1e4)||"",r.exceptionType=c(t)?t:"",r.causedBy=e,r.errorDump=n,T(re,r)))}function xn(t){var e=A.mc;let n=0;if(e&&0<e.length)for(let r=0,i=e.length-1;r<=i;r++)if(e[r].n===t){n=e[r].tv;break}return 1e3*n}const l=new(function(){return _createClass(function _class3(){_classCallCheck(this,_class3),this.networkType="",this.appInfo=null,this.clientID=null,this.page=null,this.sid=Re(),this.uid="",this.pvidDatas={},this.pageModel=0,this.pageTimeId=0,this.pageRoutes=[],this.pageTitle={}},[{key:"popPage",value:function popPage(t=!1){var e=this.page;return t||(this.page=null),e}}])}());let Oe=function(){return _createClass(function Oe(e){_classCallCheck(this,Oe),this.ci=Re().concat("-",N()),this.networkType="",this.url=e.path,this.param=e.param,this.pvid=e.path?l.pvidDatas[e.path]:null,this.pre="",this.loadTs=null,this.showTs=null,this.showEndTs=null,this.readyTs=null,this.hideTs=null,this.unloadTs=null,this.loadEndTs=null,this.uploadTs=null,this.statesInfo=[],M(v_START_RELATE,{rootId:this.ci,type:Q}),p.currentCorrelationId=this.ci},[{key:"toJson",value:function toJson(){var o={};this.loadTs&&(o.onLoad=1e3*this.loadTs),this.showTs&&(o.onShow=1e3*this.showTs),this.readyTs&&(o.onReady=1e3*this.readyTs),this.hideTs&&(o.onHide=1e3*this.hideTs),this.unloadTs&&(o.onUnload=1e3*this.unloadTs);let e,n=999,r=0,i=0;this.readyTs&&this.loadTs&&(n=o.onReady-o.onLoad),this.hideTs&&this.showTs?r=1e3*(this.hideTs-this.showTs):this.unloadTs&&this.showTs&&(r=1e3*(this.unloadTs-this.showTs)),this.loadTs&&this.loadEndTs?i=this.loadEndTs-o.onLoad:this.showTs&&this.showEndTs&&(i=1e3*(this.showEndTs-this.showTs)),e=yt(this.statesInfo)?0<(e=JSON.parse(JSON.stringify(this.statesInfo))).length?e:"":this.statesInfo;var a=xn("mpview"),s=Un(this.url&&this.url.split("?")[0])||"";o={ci:this.ci,pvid:this.pvid,name:this.url,wpi:o,routes:vr([],this.routes),param:"{}"==JSON.stringify(this.param)?"":JSON.stringify(this.param),rt:n,lt:i,std:e,is:n>a,vt:s,ic:!1};return 0!=r&&(o.st=r),o}}])}(),Mt="";function Nr(t){var e=p.eventViewInfo[Mt];e&&(e.vt=t,xe())}function xe(t){d.BonreeRUM&&d.BonreeRUM.viewInfo&&(d.BonreeRUM.viewInfo.eventViewInfo=p.eventViewInfo,t)&&(d.BonreeRUM.viewInfo.currentViewKey=Mt)}function Un(t){return t&&""!==t?l.pageTitle[t]||function(e){try{if(__wxConfig){var n,r=__wxConfig,i=__wxConfig.page||{},a=i[e]||i[e+".html"];let s="",o="";return r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(s=r.global.window.navigationBarTitleText),(o=!(o=a&&a.window&&a.window.navigationBarTitleText?a.window.navigationBarTitleText:o)&&__wxAppCode__&&(n=__wxAppCode__[e+".json"])&&n.navigationBarTitleText?n.navigationBarTitleText:o)||s||""}}catch(s){}}(t):""}function Ln(t,e){if(!lt(e))return t;const n=L({},t);return Et(t,function(r,i){lt(r)&&(n[i]=e(r,i))}),n}function Mn(t,e,n){const r=L({},t);return Et(e,function(i,a){var s,o;r[a]=(o=n,$n(c(s=t)&<(s[a])?s[a]:function(){},i,c(o)&<(o[a])?o[a]:function(){}))}),r}function jn(t,e,n,r){const i=L({},t);return Et(e,function(a,s){i[s]=function(o,h,f,u){if((!c(o)||lt(o[h])||u)&&(!u||!u[h]))return $n(!u||c(o)&<(o[h])?o[h]:function(){},f)}(t,s,a,r)}),i}function Pn(t,e,n,r,i){return t[At]?t:function(a){if((a=Mn(Ln(a,r),e,n)).onShareAppMessage){var s=a;const o=s.onShareAppMessage;o&&(s.onShareAppMessage=function(){var h,f=Array.prototype.slice.call(arguments);let u=o.apply(this,f);if(ft)try{"object"!=typeof u&&((u={}).path=be(this)),"object"!=typeof u||void 0!==u.path&&""!==u.path||(u.path=be(this)),"object"==typeof u&&"string"==typeof u.path&&(-1===u.path.indexOf("?")?u.path=u.path+"?":"&"!==u.path.slice(-1)&&(u.path=u.path+"&"),u.path=u.path+(h=p.shareInfo.sl,h=JSON.stringify({[vt_DEPTH]:h,[vt_SHARE_ID]:p.deviceInfo.di}),vt_KEY+"="+un(h)))}catch(I){}return u})}return(t.$$origin=t).call(this,a)}}function $n(t,e,n){var r;return(t=c(t)?t:function(){}).$$original?t:((r=function(){var i=oe(arguments);if(!c(this)||!ft())return t.apply(this,i);if(c(e))try{e.apply(this,i)}catch(a){console.error(a)}try{return t.apply(this,i)}catch(a){throw a}finally{c(n)&&n.apply(this,i)}}).$$original=t,r)}function Ue(t="page",e){c(this.setUpdatePerformanceListener)&<(this.setUpdatePerformanceListener)&&this.setUpdatePerformanceListener({withDataPaths:!0},n=>{var r,i,a,s,o,h;c(l.page)&&ft()?(({updateStartTimestamp:n,updateEndTimestamp:r,pendingStartTimestamp:i,dataPaths:o}=n),yt(o)&&(a=Vt(o.map(f=>{if(1<f.length){let I="";var u=this.data;let g;for(const w of f)I+=ut(w)?`[${w}]`:"."+w,g=u&&u[w];return{[I.substring(1)]:g}}return{[f]:this.data[f]}})),s=o.reduce(function(f,u){return f.concat(u)},[]),0!==o.length)&&(o={ust:1e3*n,uet:1e3*r,pst:1e3*i,d:s,s:a,p:"page"===t?this.route:this.is},h=e,l.page)&&l.page.statesInfo&&(l.page.statesInfo[l.page.statesInfo.length]=o,4===l.pageModel)&&(1===l.page.statesInfo.length&&(l.pageTimeId=setTimeout(()=>{h&&h(),c(l.page)&&(l.page.statesInfo=[]),clearTimeout(l.pageTimeId)},15e3)),10<=l.page.statesInfo.length)&&(h&&h(),c(l.page)&&(l.page.statesInfo=[]),clearTimeout(l.pageTimeId))):y.log("Stop collecting setData data!")})}const K={target:null,count:0,lastTime:0};let Cr=function(){return _createClass(function Cr(e){_classCallCheck(this,Cr),this.id=q(),this.ti=_(16),this.mode=1,this.type=e.type,this.sourceAction=3,this.ci=void 0,this.info=e.fnName,this.name=e.name,this.viewName=e.viewName,this.ic=!1,this.ice=!1,this.param="",this.loadTime="",this.startTime=1e3*e.startTime,this.endTime="",this.vt=10,this.is=!1,this.ir=e.isRage,this.vci=p.currentCorrelationId,this.me=void 0,this.operationTimeoutId=0,this.createCollterInfo(e.controlInfo),this.createMethod(e.fnName,12,e.startTime)},[{key:"createMethod",value:function createMethod(e,n,r,i){e=new Or(e,n,r,i,this.ti),this.me=e}},{key:"createCollterInfo",value:function createCollterInfo(e){let n={};e&&k(e)&&(n=new xr(e.fnName)).create(e.c_type,e.text,e.tag),this.ci=n}},{key:"getRootId",value:function getRootId(){return this.id}},{key:"methodEnd",value:function methodEnd(e){this.me&&this.me.methodFinish(e)}},{key:"actionEnd",value:function actionEnd(){var e=R();this.endTime=1e3*e,this.loadTime=this.endTime-this.startTime,this.me&&this.me.methodFinish(e)}}])}(),Or=function(){return _createClass(function Or(e,n,r,i=!1,a){_classCallCheck(this,Or),this.n=e,this.t=n,this.to=!1,this.ice=i,this.st=1e3*r,this.et="",this.im=!0,this.ti=a},[{key:"methodFinish",value:function methodFinish(e){this.et||(this.et=1e3*e)}}])}(),xr=function(){return _createClass(function xr(e){_classCallCheck(this,xr),this.f=e},[{key:"create",value:function create(e,n,r){e&&(this.td=e),r&&(this.tag=r)}}])}();function qn(t,e){return function(){var n=arguments&&arguments[0];if(!(n&&n.target&&n.currentTarget&&"tap"===n.type&&ft()))return t.apply(this,arguments);{let r;try{r=function Ur(u,f,n){var a=JSON.stringify(f.target),r=R(),i=(s=r,i=K.target,h=K.count,o=K.lastTime,s=s||new Date,null===i&&0===h?(K.target=a,K.count=h+1,K.lastTime=s,0):i!==a?(K.target=a,K.count=1,K.lastTime=s,0):i==a&&300<=s-o?(K.count=1,K.lastTime=s,0):i==a&&h<2&&s-o<300?(K.count=h+1,K.lastTime=s,0):i==a&&2<=h&&s-o<300?(K.count=h+1,K.lastTime=s,1):void 0),s=(o=(a=f)&&a.currentTarget.dataset||{},h=a.currentTarget.id,k(s=o&&L({},o))&&h&&(s.id=h),h=a.type+" "+JSON.stringify(s),a={text:o&&"{}"!==JSON.stringify(o)?JSON.stringify(o):"unknow",name:h},f&&"tap"===f.type?1:f&&"input"===f.type?4:0),o={c_type:f&&f.type,text:a.text,fnName:n},h={viewName:u.route||u.is,fnName:n,type:s,startTime:r,name:a.name,controlInfo:o,isRage:i};return u=(f=new Cr(h)).getRootId(),M(v_START_RELATE,{rootId:u,type:"action"}),{rootId:u,actionData:f}}(this,n,e)}catch(i){console.error(i)}try{return t.apply(this,arguments)}catch(i){throw i}finally{if(!r)return;r.actionData&&r.actionData.actionEnd(),T(wt,{data:r.actionData,currentCorrelationId:p.currentCorrelationId}),M(v_STOP_RELATE,{rootId:r.rootId,type:wt})}}}}const Bn={onLoad:function(t){var e;l.pageModel=1,l.pvidDatas[this.route]=Re(),t={t:N(),path:this.route,param:t,pvid:l.pvidDatas[this.route]},l.page||(l.page=new Oe(t)),c((e=l.page).url)||c(e.param)||(e.url=t.path,e.param=t.param,e.pvid=t.pvid),e.didLoad=!0,e.loadTs=t.t,zn(),Ue.call(this,"page",Me)},onShow:function(){var t,e={t:N(),path:this.route,pvid:l.pvidDatas[this.route]};X(F_INIT_RECORD),l.page?M(v_CHECK_RELAT):l.page=new Oe(e),(t=l.page).showTs=e.t,t.pvid=e.pvid,l.page&&!c(l.page.didLoad)&&(zn(),l.pageModel=2,Ue.call(this,"page",Me)),X(F_INIT_DRAWER,this),X(F_RESUME_RECORD)},onReady:function(){var t=N(),e={t:t};p.launchTime||(p.launchTime=1e3*(t-p.appLaunchInfo.initTime)),t=e,l.page&&(M(v_CHECK_RELAT),l.page.readyTs=t.t,l.page.didLoad||Le())},onHide:function(){M(v_CLEAR_CURRENT_ID);var t={t:N()};p.setPageHideTime(R()),l.pageModel=3,X(F_PAUSE_RECORD),X(F_SET_CANVAS_DRAWER,{canvas:null,drawer:null}),Vn("hideTs",t)},onUnload:function(){var t={t:N()};l.pageModel=3,Vn("unloadTs",t)}},Fn={onShow:function(){var t;t={t:N()},l.page&&(l.page.showEndTs=t.t,l.page.didLoad||Le()),2===l.pageModel&&(t=Ct(),M(v_STOP_RELATE,{rootId:t,type:Q})),l.page&&!c(l.page.didLoad)&&setTimeout(()=>{l.pageModel=4},300)},onReady:function(){const t={t:N()};setTimeout(function(){var e=t;if(l.page){const n=1e3*e.t;if(c(l.page.statesInfo)&&0<l.page.statesInfo.length){const r=l.page.statesInfo.filter(i=>i.pst<n);0<r.length&&(r.sort((i,a)=>a.pst-i.pst),l.page.loadEndTs=r[0].uet>1e3*l.page.readyTs?r[0].uet:n)}else l.page.loadEndTs=n;1===l.pageModel&&l.page.didLoad&&0==l.page.statesInfo.length&&y.log("The 'setData' data cannot be collected. Maybe the user has overridden the 'setUpdatePerformanceListener' method or the user does not use 'setData'"),l.page.didLoad&&(Le(),l.page.statesInfo=[])}l.pageModel=4},300),M(v_CLEAR_CURRENT_ID)}},Kn={created:function(){l.page||(l.page=new Oe({t:null,path:null,param:null}))},attached:function(){Ue.call(this,"component",Me)}};function zn(){var t,e,n,r=he();r&&(r={url:t=be(r),path:we(r),query:hn(r),title:Un(t)},(t=l.pageRoutes).push(r),2<t.length&&t.shift(),r=q(),t=l.pageRoutes[l.pageRoutes.length-1],e=l.pageRoutes[0],n={},t&&(n.n=t.path,t.title)&&(n.vt=t.title),e&&1<l.pageRoutes.length&&(n.ru=e.path),Mt=r,p.eventViewInfo[r]=n,xe(Mt))}function Le(){var t;l.page&&(t=l.popPage(!0).toJson(),T(Q,{data:t,mode:l.pageModel,type:1,rootId:t.ci}))}function Me(){var t;l.page&&(l.page.uploadTs=N(),t=l.popPage(!0).toJson(),T(Q,{data:t,mode:l.pageModel,rootId:t.ci}))}function Vn(t,e){l.page&&(l.page[t]=e.t,t=l.popPage().toJson(),T(Q,{data:t,mode:l.pageModel,type:2,rootId:t.ci}))}function je(t){return{error:t,pvid:l.page&&l.page.pvid,url:l.page&&l.page.url,time:l.page&&l.page.showTs||N(),userAgent:p.userAgent}}function Mr(){var t=oe(arguments);t&&t[0]instanceof Error&&(t=je(t[0]),T(Bt,t))}function Jn(t){t=je(t),T(Bt,t)}let Pe=!1,$e=!1,qe=null;wx.onAppShow(()=>{var t,e,n;t=R(),e=qe,(n=dt(ae)||{})&&c(t)&&c(e)&&0!==e&&30<(t-e)/1e3&&((R()/1e3-n.setTime)/3600>n.spt?(n.sp=100,Rt(),p.sessionStartTime=1e3*N()):n.sp>100*Math.random()?(Rt(),p.sessionStartTime=1e3*N()):p.closeAgent(!0))}),wx.onAppHide(()=>{qe=R()});const jr={onLaunch:function(t){(function(n){let r;try{if(!n.query||!n.query[vt_KEY])return;{const h=un(n.query[vt_KEY]);r=JSON.parse(h)}}catch(h){return}const i=r[vt_DEPTH],a=r[vt_SHARE_ID],s=p.deviceInfo.di,o=p.shareInfo;"number"==typeof i?a&&a===s?(o.sl=i,o.iso=0<i):a&&a!==s&&(o.sl=i+1,o.iso=!0):(o.sl=0,o.iso=!1)})(t),p.setScene(t.scene),t=q(),M(v_START_RELATE,{rootId:t,type:nt});const e={time:1e3*N(),id:t};setTimeout(()=>{Pe=!1,p.appLaunchInfo.isFirstLaunch?e.type=3:e.type=1;var n=p.launchTime||0,r=xn("coollaunch");e.is=r<n,e.loadTime=n,T(nt,e)},3e3);try{d.getRendererUserAgent&&d.getRendererUserAgent().then&&d.getRendererUserAgent().then(n=>{E(n)?p.userAgent=n:k(n)&&(p.userAgent=n&&n.userAgent)})}catch(n){}},onShow:function(t){p.setScene(t.scene);var e=q(),n=R();if(function(){if(Pe){var r=qe;if(3e4<R()-r)return $e=!0}}()){M(v_START_RELATE,{rootId:e,type:nt});const r=Ct();T(nt,{type:2,is:!1,loadTime:999,id:r,time:n})}T($t,{t:2}),X(F_CHECK_UPLOAD_DATA)},onHide:function(){Pe=!0,T($t,{t:3},!0),X(F_FINISH_RECORD,"onHide")},onError:function(t){Jn(t)},onUnhandleRejection:function({reason:t}){Jn(t)}},Pr={onLaunch:function(){var t=Ct();M(v_STOP_RELATE,{rootId:t,type:nt}),M(v_SET_LAST_ROOT_ID,{rootId:t})},onShow:function(){var t;$e&&(t=Ct(),M(v_STOP_RELATE,{rootId:t,type:nt}),$e=!1)}},qr=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9","+","/"];var Br=function(t){for(var e=new Array;0<t;){var n=t%2;t=Math.floor(t/2),e.push(n)}return e.reverse(),e},Fr=function(t){for(var e=0,n=0,r=t.length-1;0<=r;--r)1==t[r]&&(e+=Math.pow(2,n)),++n;return e},Yt=function(t,e){for(var n=8-(t+1)+6*(t-1)-e.length;0<=--n;)e.unshift(0);for(var r=[],i=t;0<=--i;)r.push(1);r.push(0);for(var a=0,s=8-(t+1);a<s;++a)r.push(e[a]);for(var o=0;o<t-1;++o){r.push(1),r.push(0);for(var h=6;0<=--h;)r.push(e[a++])}return r};function Tt(t){for(var e=[],n=[],r=0,i=t.length;r<i;++r){var a=t.charCodeAt(r),s=Br(a);if(a<128){for(var o=8-s.length;0<=--o;)s.unshift(0);n=n.concat(s)}else 128<=a&&a<=2047?n=n.concat(Yt(2,s)):2048<=a&&a<=65535?n=n.concat(Yt(3,s)):65536<=a&&a<=2097151?n=n.concat(Yt(4,s)):2097152<=a&&a<=67108863?n=n.concat(Yt(5,s)):4e6<=a&&a<=2147483647&&(n=n.concat(Yt(6,s)))}var h=0;for(r=0,i=n.length;r<i;r+=6){var f=r+6-i;2==f?h=2:4==f&&(h=4);for(var u=h;0<=--u;)n.push(0);e.push(Fr(n.slice(r,r+6)))}var I="";for(r=0,i=e.length;r<i;++r)I+=qr[e[r]];for(r=0,i=h/2;r<i;++r)I+="=";return I}function Kr(h,o,n){var r=String(Tt(on())),i=String(Tt(on())),a=String(Tt(p.appInfo.an)),s=String(Tt(p.appInfo.av));o=o&&String(Tt(o))||String(Tt("/")),h=String(Tt(h));return n&&0<=n&&n<=100&&!sn(n)?`0-${r}-${i}-0-${a}-${s}-${o}-`+h:`1-${r}-${i}-0-${a}-${s}-${o}-`+h}const Be=new(function(){return _createClass(function _class4(){_classCallCheck(this,_class4),this.list={},this.isOpen=!1,this.blackKey=new Set},[{key:"checkIsOpen",value:function checkIsOpen(t){c(t)&&t?this.isOpen=!0:this.isOpen=!1}},{key:"getItem",value:function getItem(t,e){var n=t+"+"+e;return c(t)&&this.list[n]?this.list[n]:this.setItem(t,e)}},{key:"setItem",value:function setItem(t,e){let{utl:n,uwl:r,ubl:i}=this.getRuleCfg(),a={};if(c(n)&&0<n.length)for(let f=0,u=(n=200<n.length?n.slice(0,200):n).length-1;f<=u;f++)L(a,this.totalHead(n[f],t,e));if(c(r)&&0<r.length)for(let f=0,u=(r=200<r.length?r.slice(0,200):r).length-1;f<=u;f++)this.blackWhiteCheck(t,r[f],!0)&&L(a,this.blackWhiteHead(r[f],t,e));if(c(i)&&0<i.length){for(let f=0,u=(i=200<i.length?i.slice(0,200):i).length-1;f<=u;f++)this.blackWhiteCheck(t,i[f],!1)?L(a,this.blackWhiteHead(i[f],t,e)):this.getBlackKey(i[f]);a=this.delBlackKey(a)}200<Object.keys(a).length&&(a=k(s=a)?(o={},Object.keys(s).map((f,u)=>{u<200&&(o[f]=s[f])}),o):{});var s,o,h=t+"+"+e;return this.list[h]=a}},{key:"getRuleCfg",value:function getRuleCfg(){var t={ubl:[],utl:[],uwl:[]};if(d.BonreeRUM&&d.BonreeRUM.configs){var e,n=d.BonreeRUM.configs;for(const r in n)n[r]&&(e=n[r]).irhtc&&(c(e.irhtc.ubl)&&0<e.irhtc.ubl.length&&(t.ubl=t.ubl.concat(e.irhtc.ubl)),c(e.irhtc.utl)&&0<e.irhtc.utl.length&&(t.utl=t.utl.concat(e.irhtc.utl)),c(e.irhtc.uwl))&&0<e.irhtc.uwl.length&&(t.uwl=t.uwl.concat(e.irhtc.uwl))}return t}},{key:"totalHead",value:function totalHead(t,e,n){var r={};return L(r,this.constructData(t,e,n)),r}},{key:"blackWhiteCheck",value:function blackWhiteCheck(t,e,n=!0){if(e.rhr&&0<e.rhr.length)switch(e.t){case 0:if(t==e.r)return n;break;case 1:if(en(t,e.r))return n;break;case 2:if(tn(t,e.r))return n;break;case 3:var r=new RegExp(e.r);if(r instanceof RegExp&&r.test(t))return n;break;case 4:if(-1<t.indexOf(e.r))return n;break;default:return!n}return!n}},{key:"blackWhiteHead",value:function blackWhiteHead(t,e,n){var r=t.rhr,i={};if(c(r)&&0<r.length)for(let a=0,s=r.length-1;a<=s;a++)L(i,this.constructData(r[a],e,n));return i}},{key:"getBlackKey",value:function getBlackKey(t){var e=t&&t.rhr;if(c(e)&&0<e.length&&this.blackKey)for(let n=0,r=e.length-1;n<=r;n++)e[n]&&e[n].rhk&&this.blackKey.add(e[n].rhk)}},{key:"delBlackKey",value:function delBlackKey(t={}){if(this.blackKey&&0<this.blackKey.size&&t)for(const e of this.blackKey)t&&t[e]&&delete t[e];return this.blackKey.clear(),t}},{key:"checkKey",value:function checkKey(t,e,n){return!!(n&&1!==n||c(t)&&!(t.length>e)&&(256===e?/^[0-9a-zA-Z_-]{1,256}$/.test(t):512===e?/^[^\u4e00-\u9fa5]*$/.test(t):""!=((n=t)?String.prototype.trim?String.prototype.trim.call(n):n.toString().replace(/(^\s+)|(\s+$)/g,""):"")))}},{key:"constructData",value:function constructData(t,e,n){var r={};if(c(t)&&c(t.rht)&&this.checkKey(t.rhk,256)&&this.checkKey(t.rhv,512,t.rht))switch(t.rht){case 1:c(t.rhv)&&(r[t.rhk]=t.rhv);break;case 2:r[t.rhk]={fun:cn,len:16,sky:!1};break;case 3:r[t.rhk]={fun:cn,len:32,sky:!1};break;case 4:r[t.rhk]={fun:Kr,len:32,sky:!0,url:e,pathname:n,rhsr:t.rhsr||0};break;case 5:r[t.rhk]={fun:Er,len:32,sky:!1,rhsr:t.rhsr||0};break;case 6:r[t.rhk]="bnro=wechat_js/"+p.deviceInfo.ctv+"_request"}return r}},{key:"clear",value:function clear(){this.list=[]}}])}());let Fe;const zr=d.request,Hn={request:function(t){const e=t||{};if(!e.ignore&&ft()){const n=q(),r=Ct();if(M(v_GENERATE_RELATE,{rootId:r,id:n,type:bt}),e&&k(e)){const i=1e3*N();let a,s=0;const o={id:n,reqht:{},rh:{}},h=(e.$metric=o,e.success),f=e.fail,u=e.complete,I=e.data||"";e.success=function(){var g;h&&(a=a||N(),g=N(),M(v_SET_CURRENT_ROOT_ID,{rootId:r}),h.apply(this,arguments),s+=N()-g,M(v_CLEAR_CURRENT_ID))},e.fail=function(){var g;f&&(a=a||N(),g=N(),M(v_SET_CURRENT_ROOT_ID,{rootId:r}),f.apply(this,arguments),s+=N()-g,M(v_CLEAR_CURRENT_ID))},e.complete=function(g){const w=g&&g.profile,b=g&&g.errMsg,j=g&&g.header&&JSON.stringify(g.header)||"",D=(J={},(S=w)&&S.responseStart&&(ht=S.responseStart-S.requestStart,st=S.requestStart-S.connectEnd,jt=1e3*(S.SSLconnectionEnd-S.SSLconnectionStart),J.ti=S.peerIP||"",J.tp=S.port||443,J.dt=1e3*(S.domainLookUpEnd-S.domainLookUpStart),J.ct=1e3*(S.connectEnd-S.connectStart)-jt,J.sslt=jt,J.rt=0<st?1e3*st:0,J.rti=0<ht?1e3*ht:0,J.dti=1e3*(S.responseEnd-S.responseStart),J.ds=S.receivedBytedCount,J.rds=S.sendBytesCount,J.pt=S.protocol),J);var S,ht,st,jt,J;if(y.log("network profile:",D,w),a=a||N(),u){const Z=N();u.apply(this,arguments),s+=N()-Z}if(Se(e.url)){var P=Object.assign({},{id:n,ai:r||"",status:g.statusCode||0,method:e.method&&e.method.toUpperCase()||"GET",cb:s,ec:g.statusCode,st:i,end:a,url:e.url,rds:Vt(I),rhe:j,body:I,rh:o.rh?JSON.stringify(o.rh):"",ds:Number(Vr(g)),reqht:o.reqht||{},resht:{}},D),He=(c(b)&&!c(g.statusCode)&&(P.em=b,P.ec=g.statusCode||600),c(Fe)&&(P.tpar=Fe,Fe=void 0),400<=P.ec&&(P.ep="http"),A.reshtk||[]);for(const Z in g.header)yt(He)&&-1<He.indexOf(Z)&&k(P.resht)&&Object.keys(P.resht).length<64&&(P.resht[Z]=g.header[Z]),"br-resp-key"===Z.toLowerCase()&&(P.tid=g.header[Z]),"x-br-response"===Z.toLowerCase()&&(P.xbr=g.header[Z]),"traceresponse"===Z.toLowerCase()&&(P.trsp=g.header[Z]);k(P.resht)&&Object.keys(P.resht).length<=0&&(P.resht=""),k(P.reqht)&&Object.keys(P.reqht).length<=0&&(P.reqht=""),T(bt,{data:P,rh:Jr()})}}}}}};function Vr(t){var e;return t?(e=t.header,t=t.data,e&&e["content-length"]?e["content-length"]:Vt(t)):0}function Jr(){if(l.page)return{ci:l.page.ci,pl:l.page.url}}function Gr(){var t=oe(arguments);try{return c(Hn.request)&&Hn.request.apply(this,t),A.brss&&function Hr(t){const e=t[0]||{},n=A.irhtc||{};if(n&&k(n)&&!(Object.keys(n).length<1)){if(e.header){if(!k(e.header))return}else e.header={};t=function(r){if(c(r.url)&&/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(r.url)){var i=r.url.split("/")[2];if(i.includes(":")&&(i=i.split(":")[0]),r=r.url.split("/").slice(3).join("/").split("?")[0],c(i))return Be.getItem(i,r)}}(e),c(t)&&k(t)&&Et(t,function(r,i){var a;r&&k(r)?(a=r.sky?r.fun&&r.fun(r.url,r.pathname,r.rhsr):!1===r.sky?r.fun&&r.fun(r.rhsr):r.fun&&r.fun(r.len),e.header||(e.header={}),e.header[i]=a):(e.header||(e.header={}),e.header[i]=r)})}}(t),function(e){var n=e[0]||{};if(k(n)&&!n.ignore&&n.$metric){var r=n.header||{},i=(n.$metric.rh=r,A.reqhtk||[]);if(yt(i)&&0<i.length&&k(n.$metric.reqht))for(const a in r)if(-1<i.indexOf(a)){if(n.$metric.reqht&&64<=Object.keys(n.$metric.reqht).length)return;n.$metric.reqht[a]=r[a]}}}(t),zr.apply(this,t)}catch(e){throw e}finally{Wr.apply(this,t)}}function Wr(){}let Ke=null;function Gn(){return p.networkStateInfo}function Wn(t){return d.getNetworkType({success(e){ft()&&(p.networkStateInfo.ns=e.networkType,X(F_SET_VALUE,{type:1,key:"netState",value:e.networkType}),""!=p.networkStateInfo.ns)&&""!=p.networkStateInfo.dip&&Zn(t)}})}function Yn(t,e){c(t)&&(p.networkStateInfo.dip=t,""==p.networkStateInfo.ns||""==p.networkStateInfo.dip||Ke||Zn(e))}function Zn(t){t=t||q(),p.networkStateInfoMap[t]=L({},p.networkStateInfo),Ke=t,T(ve,t)}function Zr(){var t=d[x]&&d[x].emits.length;if(!(2<t)){if(1==t){if(function $r(){lt(d.getPerformance)?d.getPerformance().createObserver(function(t){var e=t.getEntries();for(let a=0;a<e.length;a++){var n=e[a],r=n&&n.entryType,i=n&&n.name;"navigation"===r&&"appLaunch"==i&&(y.log("launchTime:",n.duration),p.launchTime=1e3*n.duration)}}).observe({entryTypes:["navigation","render","script"]}):y.warn("Unable to obtain the getPerformance API!"),(App=Pn(App,jr,Pr,null))[At]=!0}(),!Page[At]){(Page=Pn(Page,Bn,Fn,qn))[At]=!0;const e=Component;e[At]||((Component=function(n){var r=c(n)?n.methods:{};let i=Object.assign({},n,{methods:Ln(r,qn)});return i.methods=Mn(i.methods,Bn,Fn),c(i.lifetimes)&&(i.lifetimes=jn(i.lifetimes,Kn)),n=i.lifetimes||{},i=jn(i,Kn,0,n),e.call(this,i)})[At]=!0)}Be.checkIsOpen(A.brss),d.request?Object.defineProperty(d,"request",{configurable:!0,enumerable:!0,writable:!0,value:Gr}):console.warn("sdk.request is not defined"),function Lr(){var t,n,r;A.consoleError&&console&&console.error&&(console.error=(t=console.error,n=Mr,t.$original?t:((r=function(){var i=oe(arguments);if(!ft())return t.apply(this,i);try{return c(null)&&null.apply(this,i),t.apply(this,i)}catch(a){throw a}finally{n.apply(this,i)}}).$original=t,r)))}(),function _r(){const t=d.setNavigationBarTitle;Object.defineProperty(d,"setNavigationBarTitle",{get:()=>function(e){t.call(this,e);var n=we(),r=e.title;if(n&&r&&(l.pageTitle[n]=r,l.pageRoutes)&&0<l.pageRoutes.length)for(let a=0;a<l.pageRoutes.length;a++){var i=l.pageRoutes[a];i&&i.path==n&&i.title!=r&&Nr(i.title=r)}}})}()}br(),d.onAppHide(ue);{const e=dt(Ye),n=new Date;if(e&&e[Qe]){const r=new Date,i=e[Qe];p.cacheData.firstVisitDayTime=i,p.cacheData.firstVisitTime=r.getTime()}else{const r=n.setHours(23,59,60);p.cacheData.firstVisitDayTime=r,p.cacheData.firstVisitTime=n.getTime(),p.appLaunchInfo.isFirstLaunch=!0,ce(Ye,p.cacheData)}}Gn(),function Yr(){try{d.onNetworkStatusChange(function(t){if(ft()){p.networkStateInfo.ns=t.networkType;var e=t=q();if(c(A)&&A.gdia){var n=A.gdia;try{d.request({url:n,method:"GET",ignore:!0,success(i){i&&200===i.statusCode&&((i=i&&i.data&&i.data.di)&&Yn(i,e),i=L({},p.networkStateInfo),T(ge,{tn:i,t:1}))},fail(){}})}catch(i){}}Wn(t)}})}catch(t){y.log("HackNetworkStatus error!",t)}}(),Wn()}}function Rt(){if(!p.unableConfig){let i={v:Dt,di:p.deviceInfo||{},ai:L(p.appInfo,{ai:A.appId})};var t=i.ai,e="ci";if(c(t)&&"object"==typeof t)if(!c(e)||c(t[e])&&""!==t[e])for(const s in t)c(t[s])&&""!==t[s]||delete t[s];else delete t[e];e=((e=Gn()).ns&&(i.nsi=e.ns),{});var n=(c((n=function Ar(){return et}()).ui)&&(e.ui=n.ui||""),c(n.ei)&&(e.ei=n.ei||""),c(e)&&e.ui&&(i.ui=e),i.nsi={ns:"WiFi"},{v:pe,a:A.appId||"",d:p.deviceInfo.di||""}),r=(e=A.beacon.configAddress||"",e="".concat(e,"?",an(n)),n=(T(ie,{type:1}),{}),rt.createReqHeader());let a="";r&&(n["BR-Encryption-Method"]=r,n["Content-Type"]="application/octet-stream",a="arraybuffer",i=rt.encrypt(i)),y.log("request config:",i);try{d.request({url:e,data:i,method:"POST",ignore:!0,header:n,timeout:W.timeout,responseType:a,success(s){if(s&&200===s.statusCode){let o=s&&s.data;s=s.header&&s.header["BR-Encryption-Method"]||s.header&&s.header["br-encryption-method"],function(h){if(!c(h)||h&&1e4!=h.rc)return de();var f,u=L({},A);(u=L(A,h)).newSetConfig=!0,u.setTime=R()/1e3,h=Yn,c(f=u)&&(A.initTime=1e3*R(),A=L(A,f),f.di&&h&&h(f.di),h=dt(ae)||{},f=Object.assign({},h,A),A.appId=p.appInfo.ai,ce(ae,f),p.cacheData.config=f),T(ye,A),u&&X(F_SET_CONFIG,{s:u.s,mc:u.mc,cmt:u.st});{const g=u&&u.mc;if(g&&0!=g.length){const w=[];["coollaunch","hotlaunch","mpview","network","statechange","customlog","customevent","custommetric","action"].map(b=>{let j=!1;g.map(D=>{D.n===b&&(j=!0)}),j||((b="coollaunch"!==b&&"hotlaunch"!==b?b:"launch")===bt&&w.push(qt),w.push(b))}),T(ie,{type:2,data:w}),M(v_GET_CONFIG,{unModu:w})}}}(o=rt.hasSm4()&&s?rt.decrypt(o,s):o),p.closeAgent(!1),de(!1)}else p.closeAgent(!0),0<W.confCount?setTimeout(function(){--W.confCount,Rt()},6e4):de(!0)},fail(){y.log("Config request failed, close SDK!"),de(!0),0<W.confCount?setTimeout(function(){--W.confCount,Rt()},6e4):p.closeConfig(!0)}})}catch(s){y.error("Config request error!",s)}}}function de(t){T(Ie,t),p.closeAgent(t)}function Qn(t){switch(t){case mt_CLEAR_DATA:!function Qr(){if(_e&&(p.eventExtInfo={},it=null),0!==Wt.length)for(let r=0;r<Wt.length;r++){var t=Wt[r];t!==it&&p.eventExtInfo[t]&&delete p.eventExtInfo[t]}var e=Object.keys(p.eventViewInfo);for(let r=0;r<e.length;r++){var n=e[r];Mt!==n&&p.eventViewInfo[n]&&(delete p.eventViewInfo[n],xe())}p.userInfoFui=null}();break;case mt_GET_SIN_KEY:return{userInfoKey:le,networkStateInfoKey:Ke,eeiKey:kr(),currentViewKey:Mt};case mt_GET_DATA:return p}}const St={cur:"",last:""};let Y=function(){return _createClass(function Y(e,n){_classCallCheck(this,Y),this.d_type=n,this.data=e||{},this.$metric={},this.ent=e&&e.info&&e.info.timestamp&&e.info.timestamp||1e3*R()},[{key:"info",value:function info(e,n="",r,i=!1){var a=this.data;if(c(a)){let s=a[e];c(s)||(s=n),c(r)&&(e=r),i&&""===s||(this.$metric[e]=s)}return this}},{key:"setMetricData",value:function setMetricData(e,n){e&&n&&(this.$metric[e]=n)}},{key:"getMetricData",value:function getMetricData(e){return this.$metric[e]||""}},{key:"metric",value:function metric(e,n="",r){var i=this.data;if(c(i)){let a=i[e];c(a)||(a=c(n)?n:-1),c(r)&&(e=r),this.$metric[e]=a}return this}},{key:"build",value:function build(e,n){var r=Qn(mt_GET_SIN_KEY),i=dn().currentViewKey;let a=r.networkStateInfoKey;return St.last!=a&&(""==St.cur&&(St.cur=a),St.last=St.cur),St.cur=a,this.d_type==$t&&this.data&&1==this.data.t&&(a=St.last),e={type:this.d_type,ent:e||this.ent,data:{},sin:[r.userInfoKey||"","",a||"",r.eeiKey,i||""]},n&&(e.revts=[]),r=this.$metric,e.data=r,e}}])}();function fe(t,e){let n=dt(se);const r=n&&n[0]&&n[0].s;if(c(n)&&n.length&&n[n.length-1]&&!r){const i=n[n.length-1]&&n[n.length-1].countSize+e;i>m.cacheSize?(ze(),n=new Array({data:t,size:e,countSize:e})):n.push({data:t,size:e,countSize:i})}else r&&ze(),n=new Array({data:t,size:e,countSize:e});ce(se,n)}function ze(){var t=se;try{d.removeStorageSync(t)}catch(e){try{d.removeStorageSync(t)}catch(n){console.debug(t," RemoveStorage fail!\n",n)}}}function Xn(r){var e=Ve(mt_GET_DATA),n=r.data||[];r=r.size;if(!(n.length<=0)){let o=n;n={brkey:q()};let f="";(a=rt&&rt.createReqHeader())&&rt&&(n["BR-Encryption-Method"]=a,n["Content-Type"]="application/octet-stream",f="arraybuffer",o=rt.encrypt(o));var i,a=m.usc,s=e.networkStateInfo.ns;y.log("net-type and usc:",s,a),0==a||1==a&&"wifi"==s?(y.log("serviceConfig:",m),a={v:pe,a:m.AppId||"",d:e.deviceInfo.di||"",mt:1e3*R(),cmt:m.st,s:m.s},s=m.ua,s="".concat(s,"?",an(a)),i={url:s,data:o,header:n,responseType:f,size:r},Zt.add(),y.log("uploadData:",i),d.request({url:i.url,data:i.data,method:"POST",header:i.header,timeout:m.timeout,responseType:i.responseType,ignore:!0,success(u){if(u&&u.statusCode<400){let g=u.data;var I=u.header&&u.header["BR-Encryption-Method"]||u.header&&u.header["br-encryption-method"];if((g=rt.hasSm4()&&I?rt.decrypt(u.data,I):g)&&1e4===g.rc){const w=dt(se),b=w&&w[0]&&w[0].s;if(ze(),c(w)&&0<w.length&&!b){const j=m.sat||0;w.forEach(D=>{var S=D&&D.data&&D.data.mt;1e3*R()-S<36e8*j&&Zt.addUploadData(D.data,D.size,2)})}}else fe(i.data,i.size)}else fe(i.data,i.size)},fail(){fe(i.data,i.size)},complete(){Zt.minus(),Zt.prepareUpload(!1)}})):fe(o,r)}}const Zt=new(function(){return _createClass(function _class5(){_classCallCheck(this,_class5),this.uploadDataArr=[],this.localStorageArr=[],this.uploadState=!0,this.maxPading=2,this.isPading=0,this.maxSize=1e3,this.currentSize=0},[{key:"add",value:function add(){this.isPading=this.isPading+1}},{key:"minus",value:function minus(){this.isPading=this.isPading-1}},{key:"addUploadData",value:function addUploadData(t,e,n){if(t={data:t,size:e,local:1!==n},1===n){if(this.currentSize>W.cacheSize)return;this.currentSize=this.currentSize+e,this.uploadDataArr.push(t)}else this.localStorageArr.push(t);this.isPading<this.maxPading&&this.prepareUpload(!1)}},{key:"prepareUpload",value:function prepareUpload(t){if(0<this.uploadDataArr.length&&(this.isPading<this.maxPading||t)){const e=this.uploadDataArr.shift();this.currentSize=this.currentSize-e.size,Xn(e)}0<this.localStorageArr.length&&(this.isPading<this.maxPading||t)&&Xn(this.localStorageArr.shift())}}])}());let B=_createClass(function B(){_classCallCheck(this,B),this.json={v:Dt,e:[]}});B.prototype.setNetworkStateInfo=function(t){return this.json.nsi=t,this},B.prototype.setMonitorTime=function(t){return this.json.mt=t,this},B.prototype.setConfigTime=function(t){return this.json.cmt=t,this},B.prototype.setSessionId=function(t){return this.json.s=t,this},B.prototype.setDeviceInfo=function(t){return this.json.di=t,this},B.prototype.setAppInfo=function(t,e){return this.json.ai=t,!1===e.flage?(this.json.ai.s=1001,this.json.ai.sl=0,this.json.ai.iso=!1):(this.json.ai.s=e.s,this.json.ai.sl=e.sl,this.json.ai.iso=e.iso),this},B.prototype.setFirstUserInfoIndex=function(t){return c(t)&&(this.json.fui=t),this},B.prototype.setUserInfo=function(t,e){if("{}"!==e){const n=new Set,r=(t.map(i=>{i.sin&&i.sin[0]&&n.add(i.sin[0])}),{});n.forEach(i=>{r[i]=e[i]}),this.json.ui=r}return this},B.prototype.setSessionDuration=function(t){return this.json.usd=0<=t?t:0,this},B.prototype.setSessionStartTime=function(t){return this.json.sst=t,this},B.prototype.setFirstDay=function(t){return this.json.ifd=t,this},B.prototype.setEvi=function(t){return this.json.evi=t,this},B.prototype.setEei=function(t){return t&&k(t)&&0<Object.keys(t).length&&(this.json.eei=t),this},B.prototype.pushEventData=function(t){var e=t.type&&t.data?{k:t.type,ent:t.ent,sin:t.sin,v:t.data}:{k:t.k,ent:t.ent,sin:t.sin,v:t.v};return t.revts&&0<t.revts.length&&(e.revts=t.revts),this.json.e.push(e),this},B.prototype.build=function(t){return this.json};var pt=0,at=0;function tr(t){if(t&&0<t.length)for(let r=0;r<t.length;r++){var e=t[r],n=e&&e.ent||1e3*R();(n<pt||0===pt)&&(pt=n),(at<n||0===at)&&(at=n),e.revts&&tr(e.revts)}}const $=new(function(){return _createClass(function _class6(){_classCallCheck(this,_class6),this.dataArr=[],this.setLen=15,this.setSize=20480,this.setTime=15e3,this.timer="",this.json={v:Dt,e:[]},this.close=!1,this.needCheckData=!1,this.clearDataArr=[],this.usdSt=null,this.sessionStartTime=0,this.hasUpload=!1},[{key:"dataArrAddFun",value:function dataArrAddFun(t,e=!1){""===t.sin[2]&&(this.needCheckData=!0);var n=Te(this.dataArr),r=Vt(this.dataArr);return(r<2*this.setSize||n<this.setLen&&r<this.setSize||!this.hasUpload)&&this.dataArr.push(t),e?(this.uploadData(r),clearTimeout(this.timer)):this.checkData(),this}},{key:"checkDataFun",value:function checkDataFun(t){this.needCheckData&&(this.dataArr.map(e=>{e.sin[2]=t}),this.needCheckData=!1)}},{key:"clearCacheData",value:function clearCacheData(t){this.clearDataArr=t}},{key:"checkData",value:function checkData(){clearTimeout(this.timer);const t=Te(this.dataArr),e=Vt(this.dataArr);if(t>=this.setLen||e>=this.setSize)this.uploadData(e);else{const n=this;this.timer=setTimeout(function(){n.uploadData(e)},this.setTime)}return this}},{key:"uploadData",value:function uploadData(t){var e;this.close?this.claerData():m.newSetConfig&&0<this.dataArr.length&&(e=this.dataArr.filter(n=>(n=n.type||n.k,!this.clearDataArr.includes(n))),this.hasUpload=!0,e&&0===e.length||(e=this.buildUploadData(e),Zt.addUploadData(e,t,1),this.claerData(),Ve(mt_CLEAR_DATA)))}},{key:"buildUploadData",value:function buildUploadData(t){var e=Ve(mt_GET_DATA),n=dn().eventViewInfo||{},i=t&&t[0]&&t[0].ent||0,r=(this.sessionStartTime=e.sessionStartTime,0===this.sessionStartTime&&(this.sessionStartTime=i),0!==this.sessionStartTime&&0!==i&&this.sessionStartTime>i&&(this.sessionStartTime=i),new B);r.setMonitorTime(1e3*N()).setConfigTime(m.st).setSessionId(m.s).setDeviceInfo(e.deviceInfo).setAppInfo(e.appInfo,e.shareInfo).setUserInfo(t,e.userInfoMap).setNetworkStateInfo(e.networkStateInfoMap).setFirstUserInfoIndex(e.userInfoFui).setSessionStartTime(this.sessionStartTime).setFirstDay(e.getIsFirstDay()).setEvi(n).setEei(e.eventExtInfo),at=pt=0,t&&0<t.length&&t.forEach(function(a){var s;a&&"object"==typeof a&&(s=a&&a.ent||1e3*R(),((a.ent=s)<pt||0===pt)&&(pt=s),(at<s||0===at)&&(at=s),a.revts&&tr(a.revts),r.pushEventData(a))}),i=c(this.usdSt)&&at-this.usdSt||at-pt;return this.changUsdTime(at),r.setSessionDuration(i),r.build()}},{key:"claerData",value:function claerData(){this.dataArr=[]}},{key:"stopDataCatch",value:function stopDataCatch(t){this.close=t}},{key:"updateTime",value:function updateTime(t){t&&0<t&&(this.setTime=1e3*t)}},{key:"changUsdTime",value:function changUsdTime(t){c(t)&&(this.usdSt=t)}}])}()),Xr=new(function(){return _createClass(function _class7(){_classCallCheck(this,_class7),this.url="",this.networkData={},this.originUrl="",this.urlObj={}},[{key:"checkSensitive",value:function checkSensitive(t,e){var n;!e||e&&0===e.length||Se(n=t.url||"")&&(this.url=n,this.networkData=t,this.originUrl=n,this.urlObj=De(n),this.urlObj.search||t.rh||t.rhe)&&this.startMatch(e)}},{key:"startMatch",value:function startMatch(t){for(let n=0;n<t.length;n++){var e=t[n];e&&e.sa&&e.t&&(this.url=this.networkData.url,this.urlObj=De(this.url),2===e.t?this.andLogic(e.sa,this.originUrl)&&this.desensitize(e):this.orLogic(e.sa,this.originUrl)&&this.desensitize(e))}this.clear()}},{key:"andLogic",value:function andLogic(t,e){return t.every(n=>this.matchURL(e,n.t,n.r,n.c))}},{key:"orLogic",value:function orLogic(t,e){return t.some(n=>this.matchURL(e,n.t,n.r,n.c))}},{key:"matchURL",value:function matchURL(t,e,n,r){var i=this.urlObj&&this.urlObj.hostname||"",a=1===e?i.toLowerCase():t;switch(r=1===e?r.toString().toLowerCase():r,n){case 1:if(a==r)return!0;break;case 2:if(-1<a.indexOf(r))return!0;break;case 3:if(en(a,r))return!0;break;case 4:if(tn(a,r))return!0}return!1}},{key:"desensitize",value:function desensitize(n){var e=n.mt;n=n.mk;this.urlObj&&this.urlObj.search&&c(n.aqk)&&this.delorVagueKey(e,n.aqk,"qka",n.qka),this.networkData.rh&&c(n.areqh)&&this.delorVagueKey(e,n.areqh,"reqhka",n.reqhka),this.networkData.rhe&&c(n.aresh)&&this.delorVagueKey(e,n.aresh,"reshka",n.reshka)}},{key:"delorVagueKey",value:function delorVagueKey(t,e,n,r){if(n)if("qka"!==n&&(r=this.toLowerCase(r)),!0===e)"qka"===n?1===t?this.networkData.url=this.networkData.url.split("?")[0]:this.VagueAllKey(0,n,r,this.networkData.url):"reqhka"===n?1===t?(this.networkData.rh="",this.networkData.reqht=""):this.VagueAllKey(1,n,r,this.networkData.rh,this.networkData.reqht):"reshka"===n&&(1===t?(this.networkData.rhe="",this.networkData.resht="",this.networkData.tid="",this.networkData.xbr="",this.networkData.trsp=""):(this.VagueAllKey(2,n,r,this.networkData.rhe,this.networkData.resht),this.networkData.tid="**",this.networkData.xbr="**",this.networkData.trsp="**"));else if(!1===e&&r&&0<r.length)if("qka"===n)for(let i=0;i<r.length;i++){const a=r[i],s=new RegExp(a+"=([^&]+)");if(s instanceof RegExp&&s.test(this.networkData.url)){let o=1===t?this.networkData.url.replace(s,""):this.networkData.url.replace(s,a+"=**");1===t&&o.endsWith("?")&&(o=o.replace("?","")),1===t&&o.includes("?&")&&(o=o.replace("?&","?")),this.networkData.url=o}}else if("reqhka"===n){const i=this.networkData.rh&&zt(this.networkData.rh)&&JSON.parse(this.networkData.rh),a=this.networkData.reqht;if(i){const s=this.traverseObject(i,r,t,!1);this.networkData.rh=JSON.stringify(s)}a&&k(a)&&(this.networkData.reqht=this.traverseObject(a,r,t,!1))}else if("reshka"===n){const i=this.networkData.rhe&&zt(this.networkData.rhe)&&JSON.parse(this.networkData.rhe),a=this.networkData.resht;if(i){const s=this.traverseObject(i,r,t,!1);this.networkData.rhe=JSON.stringify(s)}a&&k(a)&&(this.networkData.resht=this.traverseObject(a,r,t,!1)),this.networkData.tid&&r&&-1<r.indexOf("br-resp-key")&&(this.networkData.tid=1===t?"":"**"),this.networkData.xbr&&r&&-1<r.indexOf("x-br-response")&&(this.networkData.xbr=1===t?"":"**"),this.networkData.trsp&&r&&-1<r.indexOf("traceresponse")&&(this.networkData.trsp=1===t?"":"**")}}},{key:"VagueAllKey",value:function VagueAllKey(t,e,n,r,i){if(e&&r)if("qka"===e){const a=this.url.replace(/(\?|&)([^=&]+)=([^&]+)/g,"$1$2=**");this.networkData.url=a}else{if(r&&zt(r)){const a=JSON.parse(r),s=this.traverseObject(a,n,2,!0);1===t?this.networkData.rh=JSON.stringify(s):2===t&&(this.networkData.rhe=JSON.stringify(s))}if(i&&k(i)){const a=this.traverseObject(i,n,2,!0);1===t?this.networkData.reqht=a:2===t&&(this.networkData.resht=a)}}}},{key:"traverseObject",value:function traverseObject(t,e,n,r){if(t&&e&&!1===r){const a=e.toString();for(const s in t){var i;Object.hasOwnProperty.call(t,s)&&(i=new RegExp(""+s,"i"))instanceof RegExp&&i.test(a)&&(1===n?delete t[s]:t[s]="**")}}else if(t&&!0===r&&2===n)for(const a in t)Object.hasOwnProperty.call(t,a)&&(t[a]="**");return t}},{key:"toLowerCase",value:function toLowerCase(t){if(t&&0<t.length)return t.map(e=>e&&e.toString().toLowerCase())}},{key:"clear",value:function clear(){this.url="",this.networkData={},this.urlObj={},this.originUrl=""}}])}()),ti=new(function(){return _createClass(function _class8(){_classCallCheck(this,_class8),this.isFullCollection=-1,this.url=void 0,this.hostName=void 0,this.pathName=void 0,this.hostRule=[],this.pathRule=[]},[{key:"startFiltering",value:function startFiltering(t,e){if(this.isFullCollection&&1===this.isFullCollection)return!0;if(!e||!Se(e))return!1;if(this.pathName=e.split("?")[0],this.hostName=De(e).hostname,this.url=this.hostName,0===this.isFullCollection)return this.handleRule();{const n=this.handleConfig(t);return!0===n?this.handleRule():!1===n&&1===this.isFullCollection}}},{key:"handleConfig",value:function handleConfig(t){let e;if(t&&t.forEach(n=>{n&&"network"===n.n&&(e=n.cs)}),e&&c(e.fc)){const n=e&&e.wl;return this.isFullCollection=e.fc,!!n&&(this.hostRule=n.hr&&n.hr.slice(0,20)||[],this.pathRule=n.pr&&n.pr.slice(0,20)||[],0!==this.hostRule.length||0!==this.pathRule)}return!1}},{key:"handleRule",value:function handleRule(){var t=!!(this.hostRule&&0<this.hostRule.length)&&this.match("host");return!!(this.pathRule&&0<this.pathRule.length&&!1===t)&&this.match("path")||t}},{key:"match",value:function match(t){let e;"host"===t?e=this.hostRule:(e=this.pathRule,this.url=this.pathName);for(let i=0;i<e.length;i++){var n=e[i]||"";if(n&&-1<n.indexOf("*")){const{startStr:a,endStr:s,all:o}=Tr(n,"*");if(!(o&&2<o.length))if(a&&s){var r=new RegExp("("+a+").+("+s+")").test(this.url);if(r)return r}else if(!a&&s){const h=this.url.endsWith(s);if(h)return h}else{const h=this.url.startsWith(a);if(h)return h}}else if(this.url===n)return!0}return!1}},{key:"resetState",value:function resetState(){this.isFullCollection=-1,this.url=void 0}}])}());function ei(t){if(c(m.cbbk)&&0<m.cbbk.length){let a="";if(zt(t.body))try{let s;s="object"==typeof t.body?t.body:new Function("","return "+t.body)(),Kt(m.cbbk,function(o,h){c(s[o])&&(a+=`${o}=${encodeURIComponent(s[o])}&`)}),t.cbbq=a.slice(0,-1)}catch(s){}else if(E(t.body))try{Kt(t.body.split("&"),function(s){Kt(m.cbbk,function(o,h){o&&-1!==s.indexOf(o+"=")&&(a+=s+"&")})}),t.cbbq=a.slice(0,-1)}catch(s){}}if(c(m.cbqk)&&E(t.url))try{let a="",s=t.url.split("?")[1];Kt(s=s&&s.split("&"),function(o){Kt(m.cbqk,function(h,f){h&&-1!==o.indexOf(h+"=")&&(a+=o+"&")})}),t.cbq=a.slice(0,-1)}catch(a){}if(c(m.cbhk)&&c(t.rh))try{var e=m.cbhk;let a="";var n=zt(t.rh)&&JSON.parse(t.rh)||[],r=Object.keys(n);for(let s=0,o=r.length-1;s<=o;s++){var i=r[s];e.includes(i)&&(a+=i+"="+n[i]+"&")}t.cbhq=a.slice(0,-1)}catch(a){}return t}function ni(t){if((y.log("netWorkData:",t),t.data)&&(e=JSON.parse(JSON.stringify(t.data)))){e&&e.url&&4096<e.url.length&&(e.url=e.url.slice(0,4096));var n,r=e&&e.url,i=e.ai,a=e.id,s=!!e.ai,o=e.st||R();m&&m.snr&&Xr.checkSensitive(e,m.snr),ei.call(this,e);let u=0;try{-1===(u=pr.indexOf(e.pt))&&(u=0)}catch(g){}if(0===u&&(/^https/.test(r)?u=2:/^http/.test(r)&&(u=1)),/(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])/.test(r)){const g=(n=r)?/(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\:([0-9]{1,5})/.test(n)?[`${RegExp.$1}.${RegExp.$2}.${RegExp.$3}.`+RegExp.$4,Number(RegExp.$5)]:/\:([0-9]{1,5})/.test(n)?["",Number(RegExp.$1)]:-1<n.indexOf("https")?["",443]:["",80]:["",""];c(e.ti)&&""!==e.ti||(e.ti=g[0]),c(e.tp)&&""!==e.tp||(e.tp=g[1])}e.tp||(n=r.match(/:(\d+)(?=[/?#]|$)/))&&n[1]||(e.tp=/^https/.test(r)?443:80),e.pt=u;var h=new Y(e,bt),f=(h.info("url","","ru").info("method","","m").info("ec",200).info("dti",0,"dti").info("rt",0,"rt").info("rti",0,"rti").info("ds").info("rds","","rds").info("tid","","tid",!0).info("ti","").info("tp",443).info("dt",0).info("ct",0).info("sslt",0).info("pt",u).info("em","","em",!0).info("art",3).info("ic",!1).info("cbhq","","cbhq",!0).info("cbbq","","cbbq",!0).info("cbq","","cbq",!0).info("rei","","rei",!0).info("xbr","","xbr",!0).info("trsp","","trsp",!0).info("tpar","","tpar",!0).info("ep","","ep",!0).info("id","","id").info("ai","","ai",!0).info("reqht","","reqht",!0).info("resht","","resht",!0),m&&0===m.hcs?0:m&&m.hcs||1),e=(1===f?e&&400<=e.ec&&h.info("rh","","rh",!0).info("rhe","","rhe",!0):2===f&&h.info("rhe","","rhe",!0).info("rh","","rh",!0),h.build(o));if(s)d.BonreeRUM&&d.BonreeRUM.relateEvents[m.AppId].addRelateEventData(i,a,e,bt);else if(m&&m.mc){const g=ti.startFiltering(m.mc,r);s||!0!==g||$.dataArrAddFun(e)}else $.dataArrAddFun(e)}}const er=/([^@(\s)]+):(\d+):(\d+)/,nr=/\n/;function rr(t){return t=Number(t),isNaN(t)?0:t}function ii(t){var e;return 0===t.length?"unknown":1===t.length?t[0]:(e=t[0],-1<(t=t[1]).indexOf(e)?t:e+": "+t)}function ir(t){try{let n,r,i,a;const s=t.split(nr);let o=s.shift();for(var e=[];gr(o);){if(o=o.trim(),"MiniProgramError"!==o&&(e.push(o),er.test(o))){n=ii(e);const h=er.exec(o);r=h[1].replace(/^\(/,""),i=rr(h[2]),a=rr(h[3]);break}o=s.shift()}return{message:n||"unkonw",file:r||"<Anonymous>",line:i||0,column:a||0,duration:0,count:1,stack:mr(t,2e3)}}catch(n){y.warn("Error parsing JS stack error!",n)}}let m={stop:!1,AppId:""};function ar(t,e,n,r){if(n===m.AppId)switch(t){case bt:ni(e);break;case qt:!1!==(D=e).isOpen&&((S=new Y(D.data,qt)).info("n","","n").info("t",0,"t").info("st","","st").info("du",0,"du").info("sta",0,"sta").info("stac","","stac",!0).info("ic",!1,"ic").info("da","","da",!0).info("m","","m",!0).info("tag","","tag",!0).info("sub","","sub",!0),S=S.build(D.startTime),$.dataArrAddFun(S));break;case nt:D=e,y.log("launchData:",D),S=D&&D.time||1e3*R(),b=D.id,(j=new Y(D,nt)).info("type",D.type,"t").info("loadTime",D.loadTime,"lt").info("is",D.is),D=2!==D.type,j=j.build(S,D),d.BonreeRUM&&d.BonreeRUM.relateEvents[m.AppId].setRootNodeData(b,j,!D);break;case Q:case Xt:b=e,y.log("mpvieData:",b),j=b.data,u=b.rootId,I=new Y(j,Q),g=b.mode,b=b.type,w=j.ic,I.info("ci").info("pvid").info("name","","n").info("ic",w).info("m",g).info("param","","p",!0).info("rt").info("st",0,"st").info("lt").info("std","","std",!0).info("vt","","vt",!0),1===b?I.info("is",!1):I.info("",!1,"is"),c(j.param)&&"{}"!=j.param&&""!=j.param&&I.info("param","","p"),b=I.build("",!0),0!=w||1!==g&&2!==g?w&&u?d.BonreeRUM&&d.BonreeRUM.relateEvents[m.AppId].addRelateEventData(u,j.ci,b,Q):$.dataArrAddFun(b):d.BonreeRUM&&d.BonreeRUM.relateEvents[m.AppId].setRootNodeData(u,b);break;case Bt:!function ai(t){y.log("errorData:",t);let e=t.error;if(E(t.error)||t.error instanceof Error){var n=E(t.error)?t.error:t.error.stack;try{e=ir(n)}catch(a){(r=a.stack.split(nr)).splice(1,1),e=ir(n=r.join("\n"))}if(c(e)&&c(e.stack)&&(e.stack=e.stack.replace(/\n+/g,"\n")),c(e)&&c(e.message)){var r=t.pvid,i=(n=t.url,(i=t.time||N())&&1e3*i||1e3);const o=function(u){try{if(c(u)&&0<u.length)return u.split(":")[0]}catch(I){}return""}(e.message),h=new Y(e,Bt),f=t.userAgent||"";h.info("pvid",r).info("url",n).info("file","","n").info("message","","m").info("line",1,"l").info("column",1,"col").info("stack","","sta").info("pct",i).info("et",o).info("pt",3).info("ua",f,"ua",!0).info("ect",3),r=h.build(),$.dataArrAddFun(r)}}}(e);break;case wt:I=e,y.log("actionData:",I),g=(I=I.data).startTime,w=I.id,u=I.currentCorrelationId||"",(I=JSON.parse(JSON.stringify(I))).ice=!1,(I=new Y(I,wt)).info("id","","id").info("mode",1,"m").info("type",1,"t").info("sourceAction",3,"sa").info("name","","n").info("info","","i").info("viewName","","vn").info("ci","","ci").info("ic",!1,"ic").info("ice",!1,"ice").info("param","","p",!0).info("loadTime","","lt").info("is",!1,"is").info("vci",u,"vci").info("ir",0,"ir").info("vt",10),u=I.build(g),$.dataArrAddFun(JSON.parse(JSON.stringify(u))),I.info("me","","me"),I.setMetricData("m",2),u=I.build(g,!0),d.BonreeRUM&&d.BonreeRUM.relateEvents[m.AppId].setRootNodeData(w,u);break;case $t:case ge:o=e,h=r,y.log("stateChangeData:",o),f=o.t,(o=new Y(o,$t)).info("t",1),1===f&&o.info("tn",{}),f=o.build(),$.dataArrAddFun(f,h);break;case gt:(o=new Y(o=e,gt)).info("userId",1,"ui").info("command","","c").info("info","","i"),o=o.build(),$.dataArrAddFun(o);break;case kt:{const ht=(f=e)&&f.type,st=new Y(f,kt);if(st.info("eventId","","i").info("eventName","","n",!0).info("eventParam","","p",!0).info("t",ht).info("d",0).info("eventLabel","","l",!0).info("info","","info",!0),0===ht)st.info("d",0);else if(1===ht)st.info("ci",f.uid);else if(2==ht){const jt=f.duration;st.info("d",jt).info("ci",f.uid)}f=st.build(),$.dataArrAddFun(f)}break;case te:(h=new Y(h=e,te)).info("logInfo","","i").info("logParam","","p",!0),h=h.build(),$.dataArrAddFun(h);break;case ne:var i=e;(i=new Y(i,ne)).info("metricName","","n").info("metricValue",0,"v").info("metricParam","","p",!0),i=i.build(),$.dataArrAddFun(i);break;case ee:(i=new Y(i=e,ee)).info("oip").info("sti"),i=i.build(),$.dataArrAddFun(i);break;case re:var a=e;(a=new Y(a,re)).info("causedBy","","cab").info("exceptionType","","t").info("errorDump","","p").info("ic",!0).info("id",q()),a=a.build(),$.dataArrAddFun(a);break;case ie:var s=e;switch(s.type){case 1:Be.clear();break;case 2:$.clearCacheData(s.data)}break;case me:$.dataArrAddFun(e);break;case Ie:$.stopDataCatch(e);break;case ve:$.checkDataFun(e);break;case ye:a=e,y.log("getConfig:",a),m=L(m,a),$.updateTime(a.rct)}var o,h,f,u,I,g,w,b,j,D,S}function Ve(t){return d.BonreeRUM&&d.BonreeRUM.executes[m.AppId]&&d.BonreeRUM.executes[m.AppId](t)}const Je={version:Dt,setUserId:C,startSpan:C,customLog:C,customEvent:C,customMetric:C,customException:C,setExtraInfo:C,customPageStart:C,customPageEnd:C,customEventStart:C,customEventEnd:C,customSpeedTest:C,recordCustomActionEnd:C,addUserExtraInfo:C,setUserExtraInfo:C,removeUserExtraInfo:C,increaseUserExtraInfo:C,addEventAttributeWithKey:C,addEventAttributes:C,removeEventAttributeWithKeys:C,removeAllEventAttributes:C};function sr(t){var e,n,r;return c(t)&&function si(t){var e=A;if(c(t.configAddress)&&(e.beacon.configAddress=t.configAddress.trim()),c(t.appId)&&(e.appId=t.appId.trim(),p.appInfo.ai=t.appId.trim()),c(t.channelId)&&p.setChannelId(t.channelId),c(t.version)&&p.setAppVersion(t.version),c(t.deviceId)&&p.setDeviceId(t.deviceId),c(t.appName)&&p.setAppName(t.appName),t.timeout&&ut(t.timeout)&&0<t.timeout&&(e.timeout=t.timeout),c(t.consoleError)&&(e.consoleError=t.consoleError),ut(t.cacheSize)&&(Number(t.cacheSize)<100&&(t.cacheSize=100),990<Number(t.cacheSize)&&(t.cacheSize=990),e.cacheSize=1024*t.cacheSize),t.debug&&1==t.debug){for(const r in y)y[r]=(...i)=>{var a=[hr(),cr()].join(" ");console[r](a,...i)};e.debug=!0}A=L(A,e)}(t),e=(r=dt(ae))&&r.newSetConfig,c(r)&&e?(c(r.spt)&&c(r.setTime)&&((R()/1e3-r.setTime)/3600>r.spt?(r.sp=100,Rt()):r.sp>100*Math.random()?Rt():p.closeAgent(!0)),r.setTime=R()/1e3):Rt(),c(d)?!1===A.enable?(y.warn("Configuration does not allow SDK startup!"),Je):(d[x]||(d[x]={executes:{},viewInfo:{},relateEvents:{},configs:{},emits:[],$$Bonree:!0}),d[x]&&d[x].executes&&(d[x].executes[t.appId]=Qn),d[x]&&d[x].relateEvents&&(d[x].relateEvents[t.appId]=tt),2<(d[x]&&d[x].emits.length)?void 0:(d[x]&&d[x].configs&&(d[x].configs[W.appId]=A),(e=t.appId)&&(m.AppId=e),d[x]&&d[x].emits?d[x].emits.push({appId:e,emit:ar}):d[x].emits=[{appId:e,emit:ar}],Zr(),n=Je,r={setUserId:kn,setExtraInfo:An,startSpan:Ot.startSpan.bind(Ot),customLog:fn,customEvent:vn,customMetric:pn,customException:On,customPageStart:_n,customPageEnd:Cn,customEventStart:In,customEventEnd:yn,customSpeedTest:gn,recordCustomActionEnd:C,addUserExtraInfo:Sn,setUserExtraInfo:Dn,removeUserExtraInfo:bn,increaseUserExtraInfo:wn,addEventAttributeWithKey:En,addEventAttributes:Ce,removeEventAttributeWithKeys:Rn,removeAllEventAttributes:Tn},n&&Et(r,function(i,a){Jt(n,a)&&(n[a]=i)}),n)):(y.error("SDK does not support running in this environment!"),Je)}function or(t,e){t&&t.exec&&t.name&&ot.install(t,e)}const oi={start:sr,install:or,SDK_VERSION:Dt,onError:function(t){t instanceof Error&&(t=je(t),T(Bt,t))},customLog:fn,customEvent:vn,customMetric:pn,customException:On,customPageStart:_n,customPageEnd:Cn,customEventStart:In,customEventEnd:yn,customSpeedTest:gn,recordCustomActionEnd:C,setUserId:kn,setExtraInfo:An,startSpan:Ot.startSpan.bind(Ot),addUserExtraInfo:Sn,setUserExtraInfo:Dn,removeUserExtraInfo:bn,increaseUserExtraInfo:wn,addEventAttributeWithKey:En,addEventAttributes:Ce,removeEventAttributeWithKeys:Rn,removeAllEventAttributes:Tn};return bonreeSDK_MP_Wechat_min.BonreeRUM=oi,bonreeSDK_MP_Wechat_min.install=or,bonreeSDK_MP_Wechat_min.start=sr,bonreeSDK_MP_Wechat_min}(),logger=createLogger("VhallMiniSdk");getApp();let _brsAgent=null;let VhallMiniSdk=function(){function VhallMiniSdk(options){var _this;_classCallCheck(this,VhallMiniSdk),_defineProperty(_this=_callSuper(this,VhallMiniSdk),"EVENT",EVENT$1),_defineProperty(_this,"get",module=>{const func=_this._modules.get(module);if("function"==typeof func)return func();logger.warn(`模块不存在:${module}`)}),_defineProperty(_this,"registerPlugin",Ctors=>{if(Array.isArray(Ctors)&&Ctors.length>0)for(const Ctor of Ctors)_this._registerSinglePlugin(Ctor);else"function"==typeof Ctor&&_this._registerSinglePlugin(Ctors)}),_defineProperty(_this,"init",async()=>{logger.debug("init exec");const roomServer=_this.get("roomServer"),userServer=_this.get("userServer");try{const{app_key:app_key,signedat:signedat,sign:sign,account:account,username:username,head:head,sign_type:sign_type=0,email:email,roomid:roomid,webinar_id:webinar_id}=_this.options,params={app_key:app_key,signedat:signedat,sign:sign,nick_name:username,head:head,sign_type:sign_type};account?params.third_user_id=account:params.email=email,roomid?params.roomid=roomid:webinar_id&&(params.webinar_id=webinar_id);const loginRes=await(userServer?.login(params));if(200!==loginRes?.code)return _this._handleInitResult(ERR_CODE_LOGIN_FAILD,loginRes);cacheUtil.setStorageSync("token_expired",Date.now()+846e5);const initRoomRes=await roomServer.initRoom();if(200!==initRoomRes?.code)return _this._handleInitResult(ERR_CODE_INIT_ROOM_FAILD,initRoomRes);const[imRes,permissionRes,commonConfigRes,invaToolStatusRes]=await Promise.all([roomServer.initIM(),roomServer.getPermissions(),roomServer.getCommonConfig(),roomServer.getInavToolStatus()]);if(200!==permissionRes?.code)return _this._handleInitResult(ERR_CODE_INIT_PERMISSIONS_FAILD,permissionRes);if(200!==commonConfigRes?.code)return _this._handleInitResult(ERR_CODE_INIT_COMMON_CONFIG_FAILD,commonConfigRes);if(5==initRoomRes.data.webinar.type&&200!==invaToolStatusRes?.code)return _this._handleInitResult(ERR_CODE_INIT_INVATOOL_STATUS_FAILD,invaToolStatusRes);_this._handleBizErrorCode(""),_this.startTs=Date.now(),_this._isReady=!0;const watchInitData=_this.store.get("watchInitData");[1,5].includes(watchInitData.webinar.type)&&_this.get("logReportServer")?.report(606001,{behavior:6});const openid=_this.store.get("user")?.openid,query_invite_code=_this.store.get("query_invite_code");if(_this.BRSAgent?.customLog(`bindInviteRelation: query_invite_code=${query_invite_code} openid=${openid}`),query_invite_code&&openid){const inviteCardServer=_this.get("inviteCardServer");inviteCardServer?.bindInviteRelation(query_invite_code,openid)}return _this.emit(EVENT$1.SDK_READY,"ok"),_this._handleInitResult(ERR_CODE_OK)}catch(error){return console.error("init error:",error),_this._handleInitResult(ERR_CODE_INIT_EXCEPTION,error)}}),_defineProperty(_this,"isReady",()=>_this._isReady),_defineProperty(_this,"_handleBizErrorCode",(code,detail)=>{if(logger.log("_handleBizErrorCode code:",code," detail:",detail),code){switch(code){case 511006:break;case 512514:case 900002:case 900004:_this.destroy(!1)}_this.store.set("errorResp",{code:code,detail:detail})}else _this.store.set("errorResp",{code:"",detail:null})}),options&&options.hasOwnProperty("loglevel")&&log.setLogLevel(options.loglevel),logger.info("SDK start"),_this.BRSAgent=function getBRSAgent(){return _brsAgent||(_brsAgent=BonreeSDK.start({configAddress:"https://oneupload.bonree.com/RUM/config",appId:"96fac09b1a64485082d11c7079aa3020"})),_brsAgent}(),_this.BRSAgent?.setUserId(options.account||options.email);try{_this.options=(options=>{if(!options||"object"!=typeof options)throw new Error("sdk初始化参数错误");if(!(options.app_key&&options.signedat&&options.sign&&options.username))throw new Error("参数`app_key`、`signedat`、`sign`、`username`参数必填,请检查");if(!options.roomid==!options.webinar_id)throw new Error("参数`roomid`和`webinar_id`二选一必填,请检查");if(!options.account==!options.email)throw new Error("参数`account`和`email`二选一必填,请检查");const defaultOption={env:"production",app_key:"",sign:"",signedat:"",sign_type:0,roomid:"",webinar_id:"",wx_app_id:"",head:"",open_id:"",query_invite_code:"",username:"",account:"",email:"",member_level:void 0};for(const defaultKey in defaultOption)!defaultOption.hasOwnProperty(defaultKey)||options.hasOwnProperty(defaultKey)&&void 0!==options[defaultKey]||(options[defaultKey]=defaultOption[defaultKey]);options.wx_app_id||(options.wx_app_id=wx.getAccountInfoSync().miniProgram.appId),["test","production"].includes(options.env)||(options.env="production");const signType=parseInt(options.sign_type,10);options.sign_type=[0,1,2,3].includes(signType)?signType:0;const memberLevel=parseInt(options.member_level,10);return options.member_level=Number.isNaN(memberLevel)?void 0:memberLevel,options})(options)}catch(e){throw logger.error(e),e}const{roomid:_roomid,webinar_id:_webinar_id}=_this.options;return _this.env=_this.options.env,_this.envConfig=envConfig[_this.env],_this.wxApi=new RequestUtil({baseUrl:envConfig[_this.env].BASE_URL,platform:19}),_this.log=log,_this.webinarId=_roomid||_webinar_id,_this.wxAppId=_this.options.wx_app_id,_this._isReady=!1,_this.startTs=0,_this.store=new Store,_this.store.set("webinarId",_roomid||_webinar_id),_this.store.set("env",_this.env),_this.store.set("user",{nickname:_this.options.username,user_id:_this.options.account,open_id:_this.options.open_id,avatar:_this.options.head,member_level:_this.options.member_level,email:_this.options.email}),_this.store.set("query_invite_code",_this.options.query_invite_code),_this.listenEvent(),_this._bindAppShow(),_this._modules=new SerializableMap,_this.registerPlugin([RoomServer,UserServer,LogReportServer]),_this.options?.modules&&_this.registerPlugin(options.modules),_this}return _inherits(VhallMiniSdk,BaseServer),_createClass(VhallMiniSdk,[{key:"_registerSinglePlugin",value:function _registerSinglePlugin(Ctor){if(Ctor&&"function"==typeof Ctor&&Ctor.name)if(SUPPORTED_PLUGINS[Ctor.name]){const moduleName=function firstLetterToLower(str){return"string"!=typeof str||0===str.length?str:str.charAt(0).toLowerCase()+str.slice(1)}(Ctor.name);if(!this._modules.has(moduleName)){let _inst;this._modules.set(moduleName,()=>(_inst||(_inst=new Ctor(this)),_inst),!0)}}else logger.error("不支持的模块 registerSinglePlugin=>:",Ctor.name);else logger.warn("注册模块格式错误:",Ctor)}},{key:"listenEvent",value:function listenEvent(){this.unlistener&&this.unlistener(),this.unlistener=this.on({[EVENT$1.ROOM_MSG]:msg=>{switch(logger.debug("收到房间消息:",msg),msg.data?.type){case"live_start":this.emit(EVENT$1.LIVE_START);break;case"live_over":this.emit(EVENT$1.LIVE_END);break;case"room_kickout":const user=this.store.get("user");msg.data.target_id==user?.user_id&&(this.emit(EVENT$1.KICKOUT,msg.data),this._handleBizErrorCode(512514));break;case"record_watch_expire_set":this.emit(EVENT$1.RECORD_WATCH_EXPIRE_SET,msg.data);break;case"mall_reward_push":this.emit(EVENT$1.MALL_REWARD_PUSH,msg);break;case"mall_reward_end":this.emit(EVENT$1.MALL_REWARD_END,msg)}},[EVENT$1.JOIN_MSG]:msg=>{logger.debug("上线消息(onJoin) msg:",msg);const watchInitData=this.store.get("watchInitData");if(1==watchInitData?.sso?.enabled){const msgContex=safeJsonParse$1(msg?.context),kickMark=this.store.get("kickMark");msgContex?.kick_id&&msgContex?.kick_id===watchInitData.sso.kick_id&&msgContex.kick_mark!==kickMark&&this._handleBizErrorCode(900002)}},[EVENT$1.LEAVE_MSG]:msg=>{logger.debug("下线消息(onLeave) msg:",msg)}})}},{key:"_bindAppShow",value:function _bindAppShow(){if(VhallMiniSdk._appShowBound)return;VhallMiniSdk._appShowBound=!0;let hideTime=0;wx.onAppHide(()=>{console.log("onAppHide"),hideTime=Date.now(),this.BRSAgent?.customLog(`onAppHide hideTime:${hideTime}`),this.get("logReportServer")?.report("116999",{stage:"onAppHide"})}),wx.onAppShow(async()=>{console.log("onAppShow"),this.BRSAgent?.customLog(`onAppShow showTime:${Date.now()}`),this.get("logReportServer")?.report("116999",{stage:"onAppShow"});const gap=Date.now()-hideTime;if(hideTime=0,gap<3e3)return;if(!this._isReady)return;const tokenExpired=cacheUtil.getStorageSync("token_expired");if(!tokenExpired||Date.now()>Number(tokenExpired))return logger.log("token expired, re init"),void this.init();try{const res=await this.wxApi.sendGet("/v3/webinars/webinar/basic-info",{webinar_id:this.webinarId});if(200===res?.code){const webinarStatus=this.store.get("webinarStatus");if(res.data.webinar_state!==webinarStatus)return logger.log("webinar state changed, re init"),this.destroy(!0),void function reloadCurrentPage(){const pages=getCurrentPages();if(!pages||0===pages.length)return void console.error("[SDK] reloadCurrentPage failed: page stack is empty");const currentPage=pages[pages.length-1],{route:route,options:options}=currentPage,queryString=Object.keys(options).map(key=>`${key}=${encodeURIComponent(options[key])}`).join("&"),url=`/${route}`+(queryString?`?${queryString}`:"");wx.redirectTo({url:url,success:()=>{console.log("[SDK] Page reloaded via redirectTo:",url)},fail:err=>{console.warn("[SDK] redirectTo failed, fallback to reLaunch:",err.errMsg),wx.reLaunch({url:url})}})}()}}catch(e){logger.error("check webinar basic-info error:",e)}this.emit(EVENT$1.FOREGROUND_REFRESH,{gap:gap})})}},{key:"_handleInitResult",value:function _handleInitResult(code,detail){if(logger.log("InitResult code:",code),logger.log("InitResult detail:",detail),code===ERR_CODE_OK)return packReturnMsg(code);{const r=packReturnMsg(code,detail);return this.emit(EVENT$1.INIT_FAILED,r),this._handleBizErrorCode(detail?.code&&500!==detail.code?detail.code:code,detail),r}}},{key:"destroy",value:function destroy(isQuitGroups=!1){const roomServer=this.get("roomServer");roomServer?.destroy(isQuitGroups)}}])}();function packReturnMsg(code,detail){switch(code){case ERR_CODE_OK:return{code:ERR_CODE_OK,message:"成功"};case ERR_CODE_INIT_BEFORE_FAILD:return{code:ERR_CODE_INIT_BEFORE_FAILD,message:"init-before执行失败",detail:detail};case ERR_CODE_INIT_ROOM_FAILD:return{code:ERR_CODE_INIT_ROOM_FAILD,message:"初始化房间失败",detail:detail};case ERR_CODE_INIT_IM_FAILD:return{code:ERR_CODE_INIT_IM_FAILD,message:"初始化im失败",detail:detail};case ERR_CODE_INIT_PERMISSIONS_FAILD:return{code:ERR_CODE_INIT_PERMISSIONS_FAILD,message:"初始化权限失败",detail:detail};case ERR_CODE_INIT_COMMON_CONFIG_FAILD:return{code:ERR_CODE_INIT_COMMON_CONFIG_FAILD,message:"初始化通用配置失败",detail:detail};case ERR_CODE_INIT_EXCEPTION:return{code:ERR_CODE_INIT_EXCEPTION,message:"初始化异常",detail:detail};default:return"string"==typeof detail?{code:code,message:detail}:{code:code,detail:detail}}}_defineProperty(VhallMiniSdk,"EVENT",EVENT$1),module.exports=VhallMiniSdk;
|