@tencentcloud/lite-chat
Version:
Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut
1 lines • 178 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TencentCloudChat=t()}(this,(function(){"use strict";class e{constructor(){this.listeners={}}on(e,t,n){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:n})}off(e,t,n){var s;t&&(this.listeners[e]=null===(s=this.listeners[e])||void 0===s?void 0:s.filter((e=>{const s=e.fn===t,i=!n||e.context===n;return!(s&&i)})))}emit(e,...t){const n=this.listeners[e];n&&n.forEach((e=>{const{fn:n,context:s}=e;n.apply(s,t)}))}once(e,t,n){const s=(...i)=>{t.apply(n,i),this.off(e,s)};this.on(e,s)}}var t;!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="C2cMsgArray",e.C2C_MODIFIED_MESSAGE="C2cMsgModNotifys",e.PROFILE_MODIFIED="ProfileDataMod",e.GROUP_REALTIME_MESSAGE="GroupMsgArray",e.GROUP_MODIFIED_MESSAGE="GroupMsgModNotifys",e.C2C_NOTIFY_MESSAGE="C2cNotifyMsgArray",e.GROUP_NOTIFY_MESSAGE="GroupTips"}(t||(t={}));const n=[{type:"event",value:100,subType:t.BUSINESS_COMMAND},{type:"hasKey",value:"C2cMsgArray",subType:t.C2C_REALTIME_MESSAGE},{type:"hasKey",value:"C2cMsgModNotifys",subType:t.C2C_MODIFIED_MESSAGE},{type:"hasKey",value:"ProfileDataMod",subType:t.PROFILE_MODIFIED},{type:"hasKey",value:"GroupMsgArray",subType:t.GROUP_REALTIME_MESSAGE},{type:"hasKey",value:"GroupMsgModNotifys",subType:t.GROUP_MODIFIED_MESSAGE},{type:"hasKey",value:"C2cNotifyMsgArray",subType:t.C2C_NOTIFY_MESSAGE},{type:"hasKey",value:"GroupTips",subType:t.GROUP_NOTIFY_MESSAGE}];var s;!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.ERROR="error"}(s||(s={}));const i={[s.SERVER_PUSH_MESSAGE]:function(e){const{EventArray:t}=(null==e?void 0:e.body)||{};return t.map((e=>{const{Event:t}=e,i=n.find((e=>"event"===e.type&&e.value===t));if(i)return{type:`${s.SERVER_PUSH_MESSAGE}:${i.subType}`,data:e};const o=n.find((t=>"hasKey"===t.type&&Object.prototype.hasOwnProperty.call(e,t.value)));return o?{type:`${s.SERVER_PUSH_MESSAGE}:${o.subType}`,data:e}:void 0}))},[s.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}};const o=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=t}subscribeInnerEvent(e,t,n,s){var i,o;if(["string","number"].includes(typeof t)){const o=t,r=n;null===(i=this._innerEventEmitter)||void 0===i||i.on(`${e}:${o}`,r,s)}else{const s=t;null===(o=this._innerEventEmitter)||void 0===o||o.on(e,s,n)}}emitInnerEvent(e,t){var n,s;if(null===(n=this._innerEventEmitter)||void 0===n||n.emit(e,t),Object.keys(i).includes(e)){const n=null===(s=i[e])||void 0===s?void 0:s.call(i,t);null==n||n.forEach((e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))}))}}unSubscribeInnerEvent(e,t,n,s){var i,o;if(["string","number"].includes(typeof t)){const o=t,r=n;null===(i=this._innerEventEmitter)||void 0===i||i.off(`${e}:${o}`,r,s)}else{const s=t;null===(o=this._innerEventEmitter)||void 0===o||o.off(e,s,n)}}subscribeOuterEvent(e,t,n){var s;null===(s=this._outerEventEmitter)||void 0===s||s.on(e,t,n)}unSubscribeOuterEvent(e,t,n){var s;null===(s=this._outerEventEmitter)||void 0===s||s.off(e,t,n)}emitOuterEvent(e,t){var n;null===(n=this._outerEventEmitter)||void 0===n||n.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function r(e,t,n,s){return new(n||(n=Promise))((function(i,o){function r(e){try{c(s.next(e))}catch(e){o(e)}}function a(e){try{c(s.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}c((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const a=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},c=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n};function l(e=99999999){return Math.round(Math.random()*e)}function d(e){let t,n,s=e;e.length%8!=0&&(s="0".repeat(8-e.length%8)+e);let i="";for(let e=0,{length:o}=s;e<o;e+=8)t=parseInt(s.slice(e,e+4),2),n=parseInt(s.slice(e+4,e+8),2),i+=base16Map.get(t)+base16Map.get(n);return i}const u={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"],_="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),g=_&&"function"==typeof wx.createGamePortal,f="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),v="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),p="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),S="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,I="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,E=_&&"object"==typeof wx.miniapp,y="undefined"!=typeof uni,C=_||f||m||v||p||I||S,M="undefined"==typeof window&&!C&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,O="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),T="undefined"!=typeof uni?!C:"undefined"!=typeof window&&!C&&!O,D=f?qq:m?tt:v?swan:p?my:_?wx:I?uni:S?jd:{},A=T&&window&&window.navigator&&window.navigator.userAgent||"",b=/(micromessenger|webbrowser)/i.test(A),w=function(){let e="WEB";return b?e="WEB":f?e="QQ_MP":m?e="TT_MP":v?e="BAIDU_MP":p?e="ALI_MP":_?e=E?"DONUT_NATIVE_APP":"WX_MP":I?e="UNI_NATIVE_APP":M?e="NS_NATIVE_APP":O&&(e="RN_NATIVE_APP"),u[e]}(),N=/iPad/i.test(A),R=/iPhone/i.test(A)&&!N,L=/iPod/i.test(A),k=R||N||L,P=function(){const e=A.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),U=/Android/i.test(A),F=function(){const e=A.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),n=e[2]&&parseFloat(e[2]);return t&&n?parseFloat(`${e[1]}.${e[2]}`):t||null}(),G=/Firefox/i.test(A),B=/Edge/i.test(A),$=!B&&/Chrome/i.test(A),x=/MSIE/.test(A)||A.indexOf("Trident")>-1&&A.indexOf("rv:11.0")>-1,q=function(){const e=/MSIE\s(\d+)\.\d/.exec(A);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(A)&&/rv:11.0/.test(A)&&(t=11),t}(),j=/Safari/i.test(A)&&!$&&!U&&!B,V=/Windows/i.test(A),Y=/MAC OS X/i.test(A),K=T&&"undefined"!=typeof Worker&&!x,H=U||k,W=T&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,z=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!k||e||j)}();function J(){let e="unknown";if(Y&&(e="mac"),V&&(e="windows"),k&&(e="ios"),U&&(e="android"),C)try{const{platform:t}=wx.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}const Z=2800,X=2801,Q=3e3,ee="application/x-www-form-urlencoded;charset=UTF-8";function te(e){return r(this,arguments,void 0,(function*({method:e,url:t,data:n,timeout:s=Q}){return new Promise(C?(i,o)=>{D.request({url:t,data:n,method:e,timeout:s,header:{"content-type":ee},success:e=>i(e.data),fail:()=>o(new Error(`{"message":"Network error","code":${Z}}`))})}:(i,o)=>{const r=new XMLHttpRequest,a=setTimeout((()=>{r.abort(),o(new Error(`{"message":"Request timeout","code":${X}}`))}),s);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(a),200===r.status||304===r.status)try{i(r.responseText?JSON.parse(r.responseText):null)}catch(e){i(r.responseText)}else o(new Error(`{"message":"Network error","code":${Z}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",ee),r.send(n||null)})}))}function ne(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(c(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(){let e,t;return{promise:new Promise(((n,s)=>{e=n,t=s})),resolve:e,reject:t}}var ie,oe=Object.freeze({__proto__:null,ANDROID_VERSION:F,IE_VERSION:q,IN_ALIPAY_MINI_APP:p,IN_BAIDU_MINI_APP:v,IN_BROWSER:T,IN_DONUT_NATIVE_APP:E,IN_JD_MINI_APP:S,IN_MINI_APP:C,IN_NS_NATIVE_APP:M,IN_QQ_MINI_APP:f,IN_RN_APP:O,IN_TT_MINI_APP:m,IN_UNI_APP:y,IN_UNI_NATIVE_APP:I,IN_WX_MINI_APP:_,IN_WX_MINI_GAME:g,IOS_VERSION:P,IS_ANDROID:U,IS_CHROME:$,IS_EDGE:B,IS_FIREFOX:G,IS_IE:x,IS_IOS:k,IS_IPAD:N,IS_IPHONE:R,IS_IPOD:L,IS_MAC:Y,IS_SAFARI:j,IS_WECHAT:b,IS_WIN:V,IS_WORKER_AVAILABLE:K,MINI_APP_NAMESPACE:D,USER_AGENT:A,base16EncodeBinaryString:d,generatePromise:se,getPlatformType:J,httpRequest:te,isEmpty:ne,isFlutterWeb:W,isH5:H,isIOSWebView:z,isPlainObject:c,isValidRequestKey:a,platform:w,randomInt:l});class re{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}send(e){var t,n;try{null===(t=this._socket)||void 0===t||t.send(e)}catch(e){null===(n=this._onSendFail)||void 0===n||n.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:n,onClose:s,onError:i,onSendFail:o}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=t,this._socket.onmessage=n,this._socket.onclose=s,this._socket.onerror=i,this._onSendFail=o)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class ae{connectSocket(e){return this._socket=wx.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null===(t=this._socket)||void 0===t||t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){const{onOpen:t,onMessage:n,onClose:s,onError:i,onSendFail:o}=e;this._socket.onClose(s),this._socket.onOpen(t),this._socket.onMessage(n),this._socket.onError(i),this._onSendFail=o}unbindSocketHandlers(){this._socket&&(this._socket.onClose((()=>{})),this._socket.onOpen((()=>{})),this._socket.onMessage((()=>{})),this._socket.onError((()=>{})))}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"}(ie||(ie={}));class ce{constructor(t){this._url="",this._readyState=ie.DISCONNECTED,this._url=t,this._id=l(),this._emitter=new e,this._socket=_?new ae:new re,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[ie.CONNECTED,ie.CONNECTING].includes(this._readyState)||(this._readyState=ie.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==ie.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[ie.CONNECTED,ie.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,n){this._emitter.on(e,t,n)}off(e,t,n){this._emitter.off(e,t,n)}isConnected(){return this._readyState===ie.CONNECTED}disconnect(){this._readyState=ie.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===ie.CONNECTING&&(this._readyState=ie.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=ie.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=ie.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=ie.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}}const le="CHINA",de="SINGAPORE",ue="KOREA",he="GERMANY",_e="IND",ge="JPN",fe="USA",me="INDONESIA",ve={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",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",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},pe={[de]:[[2e7,3e7],[172e7,173e7]],[ue]:[[3e7,4e7],[173e7,174e7]],[he]:[[4e7,5e7],[174e7,175e7]],[_e]:[[5e7,6e7],[175e7,176e7]],[ge]:[[6e7,7e7],[176e7,177e7]],[fe]:[[7e7,8e7],[177e7,178e7]],[me]:[[8e7,9e7],[178e7,179e7]]};function Se(e){for(const t of Object.keys(pe))for(const[n,s]of pe[t])if(e>=n&&e<s)return t;return le}var Ie,Ee=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){if(C){if(p){return my.getStorageSync({key:e}).data}return D.getStorageSync(e)}return this._canUseLocalStorage()?localStorage.getItem(e):{}}set(e,t){const n=this._store.get(e)||{};t instanceof Map?this._store.set(e,t):this._store.set(e,Object.assign(Object.assign({},n),t))}setStorage(e,t){C?p?my.setStorageSync({key:e,data:JSON.stringify(t)}):D.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&(navigator&&navigator.cookieEnabled&&localStorage)}},ye="1.0.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST"}(Ie||(Ie={}));let Ce=Ie.INITIAL;function Me(){const e=Math.random();return 0===e?Me():e}function Oe(e,t){const{isBinary:n=!1}=t||{},s=Ee.get("instance"),{sdkAppId:i,instanceId:o}=s,r=Me(),a=J(),c=function(){const e=J();let t=-1;"ios"===e?t=P||-1:"android"===e&&(t=F||-1);return t}(),l=(d={sdkappid:i,instanceid:o,random:r,platform:w,host:a,version:c,sdkversion:ye},Object.keys(d).map((e=>`${e}=${d[e]}`)).join("&"));var d;return n?`${e}/binfo?${l}&compress=gzip`:`${e}/info?${l}`}var Te=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){const n=Date.now(),s=n-e;this._timeOffsetWithServer=t+s-n}};const De=16;var Ae=new class{constructor(){this._tasks=[],this._timer=null,this._taskMap=new Map}_addTaskToScheduler(e){const{id:t}=e;this.removeTask(t),this._tasks.push(e),this._taskMap.set(t,e),this._sort(),this._scheduleNextTask()}_createTask(e){const{id:t,callback:n,context:s,isOnce:i=!1,intervalMs:o=De}=e,r=Math.max(o,De);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:o,callback:n,context:s,isOnce:i}}addTask(e){const t=this._createTask(e);this._addTaskToScheduler(t)}addOnceTask(e){const t=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(t)}removeTask(e){const t=this._tasks.findIndex((t=>t.id===e));t>-1&&(this._tasks.splice(t,1),this._taskMap.delete(e),this._scheduleNextTask())}updateTaskInterval(e,t){const n=this._taskMap.get(e);n&&(n.intervalMs=t,n.nextExecuteTime=Date.now()+t,this._sort(),this._scheduleNextTask())}clearAllTasks(){this._tasks=[],this._taskMap.clear(),this._timer&&(clearTimeout(this._timer),this._timer=null)}dispose(){this.clearAllTasks()}_sort(){this._tasks.sort(((e,t)=>e.nextExecuteTime-t.nextExecuteTime))}_scheduleNextTask(){this._timer&&(clearTimeout(this._timer),this._timer=null);const e=this._tasks[0];if(e){const t=Math.max(0,e.nextExecuteTime-Date.now());this._timer=setTimeout((()=>this._execute()),t)}}_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 be(e){const t=[];for(let n=0;n<e.length;n+=1){const s=e.charCodeAt(n);if(s>=55296&&s<=56319){const i=e.charCodeAt(++n)-56320+(s-55296<<10)+65536;t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i)}else s<=127?t.push(s):s<=2047?t.push(192|s>>6,128|63&s):t.push(224|s>>12,128|s>>6&63,128|63&s)}return new Uint8Array(t)}function we(e){const t=Array.isArray(e)?[]:Object.create(null);for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&a(n)&&null!=e[n]&&(null===e[n]||"object"!=typeof e[n]?t[n]=e[n]:t[n]=we(e[n]));return t}function Ne(e,t){if(h.includes(e))return 0;const n=be(JSON.stringify(t));let s=4294967295;const{length:i}=n;for(let e=0;e<i;e++){s^=n[e];for(let e=0;e<8;e++)1&~s?s>>>=1:s=s>>>1^3988292384}return(4294967295^s)>>>0}function Re(e){const{servcmd:t,data:n}=e,s=function(e){const t=Ee.get("login")||{},n=Ee.get("instance")||{};return{servcmd:e,ver:"v4",platform:w,websdkappid:537048168,websdkversion:"1.7.3",a2:t.a2Key||void 0,tinyid:t.tinyID||void 0,status_instid:t.statusInstanceId||0,sdkappid:n.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.a2Key?void 0:t.userId,usersig:t.a2Key?void 0:t.userSig,sdkability:75689843,sdkability_ext:d(""),cappid:t.cappid||0,tjgID:"",seq:Pe(),cs:0}}(t),i=we(n);return s.cs=Ne(t,i),{head:s,body:i}}function Le(e){const{servcmd:t,data:n}=e,s=function(e){const t=Ee.get("login")||{},n=Ee.get("instance")||{};return{servcmd:e,ver:"v4",platform:w,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:n.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:d(""),cappid:t.cappid||0,seq:Pe(),cs:0}}(t),i=we(n);return s.cs=Ne(t,i),{head:s,body:i}}let ke=l();function Pe(){return ke=ke<2415919103?ke+1:l(),ke}var Ue,Fe=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){const{servcmd:t,data:n}=e,s=function(e){const t=Ee.get("login")||{},n=Ee.get("instance")||{};return{servcmd:e,ver:"v4",platform:w,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:n.sdkAppId,contenttype:"json",reqtime:Math.floor(Date.now()/1e3),identifier:t.userId,usersig:t.userSig,status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:d(""),cappid:t.cappid||0,seq:Pe(),cs:0}}(t),i=we(n);return s.cs=Ne(t,i),{head:s,body:i}},generateProtocolData:Re,generateSSOLogProtocolData:Le,generateSequence:Pe,taskScheduler:Ae,timeManager:Te});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(Ue||(Ue={}));const Ge={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class Be{constructor(e){this.level=Ue.info,this._canSendLog=!0,this._logCreatedAt=Te.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=void 0;const{method:t,eventType:n=0}=e||{};this.eventType=n,this.method=t}setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=Te.getTimeOffsetWithServer()}end(e=!1){if(!this._canSendLog)return;const t=Te.getServerTimeMs();0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:${t}`),e?(this._canSendLog=!1,this.timestamp=Te.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout((()=>{this._canSendLog=!1,this.timestamp=Te.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())}),0)}setError(e){var t;if(!(e instanceof Error))return console.warn("SSOLogData.setError value not instanceof Error, please check!"),this;if(!this._canSendLog)return this;return(null===(t=Ee.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=Ue.error,this}setLogInfo(e){return Object.keys(e).forEach((t=>{Object.keys(Ge).includes(t)&&(this[t]=e[t])})),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach((t=>{const n=t;Ge[n]&&(e[Ge[n]]=this[n])})),e}}function $e(){const e=Ee.get("login")||{},t=Ee.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:ye,tiny_id:Number(e.tinyID),user_id:e.userId,platform:w,instance_id:t.instanceId,trace_id:(new Date).getTime()}}var xe;!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(xe||(xe={}));var qe=xe;const je=20,Ve=6e4,Ye=[4,5,6],Ke=[],He=[],We="report-logger";var ze=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=je,this._maxThreshold=100,this._waitingTime=Ve,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,o.subscribeInnerEvent(qe.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Ae.addTask({id:We,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=je,evt_rpt_waiting:n=Ve,evt_rpt_level:s=Ye,evt_rpt_sdkappid_bl:i=Ke,evt_rpt_tinyid_wl:o=He}=e||{};this._sdkAppIdBlackList=i,this._waitingTime=n,this._minThreshold=t,this._reportLevel=s,this._tinyIdWhiteList=o}createSSOLogData(e){const t=new Be(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}getSSOLogData(e){return this._ssoLogMap.get(e)||{}}pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately()&&this._uploadSSOLogData())}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&this._logQueue.length>0&&this._uploadSSOLogData()}_uploadSSOLogData(){return r(this,void 0,void 0,(function*(){if(0===this._logQueue.length)return;const e=this._logQueue.slice(),t=this._filterLogs(e);if(this._logQueue=[],0===t.length)return void(this._lastReportAt=Date.now());const n={Header:$e(),Event:t};yield function(e){const t="imopenstat.tim_web_report_v2",n=Le({servcmd:t,data:e}),s=`${n.head.seq}${t}`;mt.sendPacket(n,{requestId:s})}(n),this._lastReportAt=Date.now()}))}_savePlatFormInfo(){var e,t;if(_){const n=null===(t=null===(e=wx.getAccountInfoSync)||void 0===e?void 0:e.call(wx))||void 0===t?void 0:t.miniProgram;if(n){const{appId:e,envVersion:t}=n;Ee.set("instance",{appId:e,envVersion:t})}}else T&&Ee.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=Ee.get("login")||{},{sdkAppId:n}=Ee.get("instance")||{};return this._sdkAppIdBlackList.includes(n)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter((e=>this._reportLevel.includes(e.level)))}reset(){console.log("SSO_LOG_MODULE.reset"),Ae.removeTask(We),o.unSubscribeInnerEvent(qe.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this._uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=je,this._maxThreshold=100,this._waitingTime=Ve,this._logQueue=[]}};const Je=15e3,Ze="Channel",Xe="channel_schedule_task",Qe="channel_reconnect_task",et="connected",nt="connecting",st="disconnected",it=500,ot="network_status_change",rt="activity_status_change",at="send_fail",ct="reconnect_failed",lt="socket_error",dt="socket_close";function ut(e){return ut="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},ut(e)}function ht(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 _t,gt={exports:{}};var ft=(_t||(_t=1,function(e){e.exports=function e(t,n,s){function i(r,a){if(!n[r]){if(!t[r]){if(!a&&ht)return ht(r);if(o)return o(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[r]={exports:{}};t[r][0].call(l.exports,(function(e){return i(t[r][1][e]||e)}),l,l.exports,e,t,n,s)}return n[r].exports}for(var o=ht,r=0;r<s.length;r++)i(s[r]);return i}({1:[function(e,t,n){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;n.assign=function(e){for(var t,n,s=Array.prototype.slice.call(arguments,1);s.length;){var i=s.shift();if(i){if("object"!=ut(i))throw new TypeError(i+"must be non-object");for(var o in i)t=i,n=o,Object.prototype.hasOwnProperty.call(t,n)&&(e[o]=i[o])}}return e},n.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,n,s,i){if(t.subarray&&e.subarray)e.set(t.subarray(n,n+s),i);else for(var o=0;o<s;o++)e[i+o]=t[n+o]},flattenChunks:function(e){var t,n,s,i,o,r;for(t=s=0,n=e.length;t<n;t++)s+=e[t].length;for(r=new Uint8Array(s),t=i=0,n=e.length;t<n;t++)o=e[t],r.set(o,i),i+=o.length;return r}},o={arraySet:function(e,t,n,s,i){for(var o=0;o<s;o++)e[i+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};n.setTyped=function(e){e?(n.Buf8=Uint8Array,n.Buf16=Uint16Array,n.Buf32=Int32Array,n.assign(n,i)):(n.Buf8=Array,n.Buf16=Array,n.Buf32=Array,n.assign(n,o))},n.setTyped(s)},{}],2:[function(e,t,n){var s=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var r=new s.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&&o||!e.subarray&&i))return String.fromCharCode.apply(null,s.shrinkBuf(e,t));for(var n="",r=0;r<t;r++)n+=String.fromCharCode(e[r]);return n}r[254]=r[254]=1,n.string2buf=function(e){var t,n,i,o,r,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),c+=n<128?1:n<2048?2:n<65536?3:4;for(t=new s.Buf8(c),o=r=0;r<c;o++)55296==(64512&(n=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(n=65536+(n-55296<<10)+(i-56320),o++),n<128?t[r++]=n:(n<2048?t[r++]=192|n>>>6:(n<65536?t[r++]=224|n>>>12:(t[r++]=240|n>>>18,t[r++]=128|n>>>12&63),t[r++]=128|n>>>6&63),t[r++]=128|63&n);return t},n.buf2binstring=function(e){return c(e,e.length)},n.binstring2buf=function(e){for(var t=new s.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t},n.buf2string=function(e,t){var n,s,i,o,a=t||e.length,l=new Array(2*a);for(n=s=0;n<a;)if((i=e[n++])<128)l[s++]=i;else if(4<(o=r[i]))l[s++]=65533,n+=o-1;else{for(i&=2===o?31:3===o?15:7;1<o&&n<a;)i=i<<6|63&e[n++],o--;1<o?l[s++]=65533:i<65536?l[s++]=i:(i-=65536,l[s++]=55296|i>>10&1023,l[s++]=56320|1023&i)}return c(l,s)},n.utf8border=function(e,t){var n;for((t=t||e.length)>e.length&&(t=e.length),n=t-1;0<=n&&128==(192&e[n]);)n--;return n<0||0===n?t:n+r[e[n]]>t?n:t}},{"./common":1}],3:[function(e,t,n){t.exports=function(e,t,n,s){for(var i=65535&e,o=e>>>16&65535,r=0;0!==n;){for(n-=r=2e3<n?2e3:n;o=o+(i=i+t[s++]|0)|0,--r;);i%=65521,o%=65521}return i|o<<16}},{}],4:[function(e,t,n){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,n){var s=function(){for(var e,t=[],n=0;n<256;n++){e=n;for(var s=0;s<8;s++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t}();t.exports=function(e,t,n,i){var o=s,r=i+n;e^=-1;for(var a=i;a<r;a++)e=e>>>8^o[255&(e^t[a])];return~e}},{}],6:[function(e,t,n){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,n){t.exports=function(e,t){var n,s,i,o,r,a,c,l,d,u,h,_,g,f,m,v,p,S,I,E,y,C,M,O,T;n=e.state,s=e.next_in,O=e.input,i=s+(e.avail_in-5),o=e.next_out,T=e.output,r=o-(t-e.avail_out),a=o+(e.avail_out-257),c=n.dmax,l=n.wsize,d=n.whave,u=n.wnext,h=n.window,_=n.hold,g=n.bits,f=n.lencode,m=n.distcode,v=(1<<n.lenbits)-1,p=(1<<n.distbits)-1;e:do{g<15&&(_+=O[s++]<<g,g+=8,_+=O[s++]<<g,g+=8),S=f[_&v];t:for(;;){if(_>>>=I=S>>>24,g-=I,0==(I=S>>>16&255))T[o++]=65535&S;else{if(!(16&I)){if(!(64&I)){S=f[(65535&S)+(_&(1<<I)-1)];continue t}if(32&I){n.mode=12;break e}e.msg="invalid literal/length code",n.mode=30;break e}E=65535&S,(I&=15)&&(g<I&&(_+=O[s++]<<g,g+=8),E+=_&(1<<I)-1,_>>>=I,g-=I),g<15&&(_+=O[s++]<<g,g+=8,_+=O[s++]<<g,g+=8),S=m[_&p];n:for(;;){if(_>>>=I=S>>>24,g-=I,!(16&(I=S>>>16&255))){if(!(64&I)){S=m[(65535&S)+(_&(1<<I)-1)];continue n}e.msg="invalid distance code",n.mode=30;break e}if(y=65535&S,g<(I&=15)&&(_+=O[s++]<<g,(g+=8)<I&&(_+=O[s++]<<g,g+=8)),c<(y+=_&(1<<I)-1)){e.msg="invalid distance too far back",n.mode=30;break e}if(_>>>=I,g-=I,(I=o-r)<y){if(d<(I=y-I)&&n.sane){e.msg="invalid distance too far back",n.mode=30;break e}if(M=h,(C=0)===u){if(C+=l-I,I<E){for(E-=I;T[o++]=h[C++],--I;);C=o-y,M=T}}else if(u<I){if(C+=l+u-I,(I-=u)<E){for(E-=I;T[o++]=h[C++],--I;);if(C=0,u<E){for(E-=I=u;T[o++]=h[C++],--I;);C=o-y,M=T}}}else if(C+=u-I,I<E){for(E-=I;T[o++]=h[C++],--I;);C=o-y,M=T}for(;2<E;)T[o++]=M[C++],T[o++]=M[C++],T[o++]=M[C++],E-=3;E&&(T[o++]=M[C++],1<E&&(T[o++]=M[C++]))}else{for(C=o-y;T[o++]=T[C++],T[o++]=T[C++],T[o++]=T[C++],2<(E-=3););E&&(T[o++]=T[C++],1<E&&(T[o++]=T[C++]))}break}}break}}while(s<i&&o<a);s-=E=g>>3,_&=(1<<(g-=E<<3))-1,e.next_in=s,e.next_out=o,e.avail_in=s<i?i-s+5:5-(s-i),e.avail_out=o<a?a-o+257:257-(o-a),n.hold=_,n.bits=g}},{}],8:[function(e,t,n){var s=e("../utils/common"),i=e("./adler32"),o=e("./crc32"),r=e("./inffast"),a=e("./inftrees"),c=1,l=2,d=0,u=-2,h=1,_=852,g=592;function f(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 s.Buf16(320),this.work=new s.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=h,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new s.Buf32(_),t.distcode=t.distdyn=new s.Buf32(g),t.sane=1,t.back=-1,d):u}function p(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,v(e)):u}function S(e,t){var n,s;return e&&e.state?(s=e.state,t<0?(n=0,t=-t):(n=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?u:(null!==s.window&&s.wbits!==t&&(s.window=null),s.wrap=n,s.wbits=t,p(e))):u}function I(e,t){var n,s;return e?(s=new m,(e.state=s).window=null,(n=S(e,t))!==d&&(e.state=null),n):u}var E,y,C=!0;function M(e){if(C){var t;for(E=new s.Buf32(512),y=new s.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(c,e.lens,0,288,E,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(l,e.lens,0,32,y,0,e.work,{bits:5}),C=!1}e.lencode=E,e.lenbits=9,e.distcode=y,e.distbits=5}function O(e,t,n,i){var o,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new s.Buf8(r.wsize)),i>=r.wsize?(s.arraySet(r.window,t,n-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(i<(o=r.wsize-r.wnext)&&(o=i),s.arraySet(r.window,t,n-i,o,r.wnext),(i-=o)?(s.arraySet(r.window,t,n-i,i,0),r.wnext=i,r.whave=r.wsize):(r.wnext+=o,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=o))),0}n.inflateReset=p,n.inflateReset2=S,n.inflateResetKeep=v,n.inflateInit=function(e){return I(e,15)},n.inflateInit2=I,n.inflate=function(e,t){var n,_,g,m,v,p,S,I,E,y,C,T,D,A,b,w,N,R,L,k,P,U,F,G,B=0,$=new s.Buf8(4),x=[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 u;12===(n=e.state).mode&&(n.mode=13),v=e.next_out,g=e.output,S=e.avail_out,m=e.next_in,_=e.input,p=e.avail_in,I=n.hold,E=n.bits,y=p,C=S,U=d;e:for(;;)switch(n.mode){case h:if(0===n.wrap){n.mode=13;break}for(;E<16;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(2&n.wrap&&35615===I){$[n.check=0]=255&I,$[1]=I>>>8&255,n.check=o(n.check,$,2,0),E=I=0,n.mode=2;break}if(n.flags=0,n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&I)<<8)+(I>>8))%31){e.msg="incorrect header check",n.mode=30;break}if(8!=(15&I)){e.msg="unknown compression method",n.mode=30;break}if(E-=4,P=8+(15&(I>>>=4)),0===n.wbits)n.wbits=P;else if(P>n.wbits){e.msg="invalid window size",n.mode=30;break}n.dmax=1<<P,e.adler=n.check=1,n.mode=512&I?10:12,E=I=0;break;case 2:for(;E<16;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(n.flags=I,8!=(255&n.flags)){e.msg="unknown compression method",n.mode=30;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=30;break}n.head&&(n.head.text=I>>8&1),512&n.flags&&($[0]=255&I,$[1]=I>>>8&255,n.check=o(n.check,$,2,0)),E=I=0,n.mode=3;case 3:for(;E<32;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}n.head&&(n.head.time=I),512&n.flags&&($[0]=255&I,$[1]=I>>>8&255,$[2]=I>>>16&255,$[3]=I>>>24&255,n.check=o(n.check,$,4,0)),E=I=0,n.mode=4;case 4:for(;E<16;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}n.head&&(n.head.xflags=255&I,n.head.os=I>>8),512&n.flags&&($[0]=255&I,$[1]=I>>>8&255,n.check=o(n.check,$,2,0)),E=I=0,n.mode=5;case 5:if(1024&n.flags){for(;E<16;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}n.length=I,n.head&&(n.head.extra_len=I),512&n.flags&&($[0]=255&I,$[1]=I>>>8&255,n.check=o(n.check,$,2,0)),E=I=0}else n.head&&(n.head.extra=null);n.mode=6;case 6:if(1024&n.flags&&(p<(T=n.length)&&(T=p),T&&(n.head&&(P=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),s.arraySet(n.head.extra,_,m,T,P)),512&n.flags&&(n.check=o(n.check,_,T,m)),p-=T,m+=T,n.length-=T),n.length))break e;n.length=0,n.mode=7;case 7:if(2048&n.flags){if(0===p)break e;for(T=0;P=_[m+T++],n.head&&P&&n.length<65536&&(n.head.name+=String.fromCharCode(P)),P&&T<p;);if(512&n.flags&&(n.check=o(n.check,_,T,m)),p-=T,m+=T,P)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=8;case 8:if(4096&n.flags){if(0===p)break e;for(T=0;P=_[m+T++],n.head&&P&&n.length<65536&&(n.head.comment+=String.fromCharCode(P)),P&&T<p;);if(512&n.flags&&(n.check=o(n.check,_,T,m)),p-=T,m+=T,P)break e}else n.head&&(n.head.comment=null);n.mode=9;case 9:if(512&n.flags){for(;E<16;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(I!==(65535&n.check)){e.msg="header crc mismatch",n.mode=30;break}E=I=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=12;break;case 10:for(;E<32;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}e.adler=n.check=f(I),E=I=0,n.mode=11;case 11:if(0===n.havedict)return e.next_out=v,e.avail_out=S,e.next_in=m,e.avail_in=p,n.hold=I,n.bits=E,2;e.adler=n.check=1,n.mode=12;case 12:if(5===t||6===t)break e;case 13:if(n.last){I>>>=7&E,E-=7&E,n.mode=27;break}for(;E<3;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}switch(n.last=1&I,E-=1,3&(I>>>=1)){case 0:n.mode=14;break;case 1:if(M(n),n.mode=20,6!==t)break;I>>>=2,E-=2;break e;case 2:n.mode=17;break;case 3:e.msg="invalid block type",n.mode=30}I>>>=2,E-=2;break;case 14:for(I>>>=7&E,E-=7&E;E<32;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if((65535&I)!=(I>>>16^65535)){e.msg="invalid stored block lengths",n.mode=30;break}if(n.length=65535&I,E=I=0,n.mode=15,6===t)break e;case 15:n.mode=16;case 16:if(T=n.length){if(p<T&&(T=p),S<T&&(T=S),0===T)break e;s.arraySet(g,_,m,T,v),p-=T,m+=T,S-=T,v+=T,n.length-=T;break}n.mode=12;break;case 17:for(;E<14;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(n.nlen=257+(31&I),I>>>=5,E-=5,n.ndist=1+(31&I),I>>>=5,E-=5,n.ncode=4+(15&I),I>>>=4,E-=4,286<n.nlen||30<n.ndist){e.msg="too many length or distance symbols",n.mode=30;break}n.have=0,n.mode=18;case 18:for(;n.have<n.ncode;){for(;E<3;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}n.lens[x[n.have++]]=7&I,I>>>=3,E-=3}for(;n.have<19;)n.lens[x[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,F={bits:n.lenbits},U=a(0,n.lens,0,19,n.lencode,0,n.work,F),n.lenbits=F.bits,U){e.msg="invalid code lengths set",n.mode=30;break}n.have=0,n.mode=19;case 19:for(;n.have<n.nlen+n.ndist;){for(;w=(B=n.lencode[I&(1<<n.lenbits)-1])>>>16&255,N=65535&B,!((b=B>>>24)<=E);){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(N<16)I>>>=b,E-=b,n.lens[n.have++]=N;else{if(16===N){for(G=b+2;E<G;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(I>>>=b,E-=b,0===n.have){e.msg="invalid bit length repeat",n.mode=30;break}P=n.lens[n.have-1],T=3+(3&I),I>>>=2,E-=2}else if(17===N){for(G=b+3;E<G;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}E-=b,P=0,T=3+(7&(I>>>=b)),I>>>=3,E-=3}else{for(G=b+7;E<G;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}E-=b,P=0,T=11+(127&(I>>>=b)),I>>>=7,E-=7}if(n.have+T>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=30;break}for(;T--;)n.lens[n.have++]=P}}if(30===n.mode)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=30;break}if(n.lenbits=9,F={bits:n.lenbits},U=a(c,n.lens,0,n.nlen,n.lencode,0,n.work,F),n.lenbits=F.bits,U){e.msg="invalid literal/lengths set",n.mode=30;break}if(n.distbits=6,n.distcode=n.distdyn,F={bits:n.distbits},U=a(l,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,F),n.distbits=F.bits,U){e.msg="invalid distances set",n.mode=30;break}if(n.mode=20,6===t)break e;case 20:n.mode=21;case 21:if(6<=p&&258<=S){e.next_out=v,e.avail_out=S,e.next_in=m,e.avail_in=p,n.hold=I,n.bits=E,r(e,C),v=e.next_out,g=e.output,S=e.avail_out,m=e.next_in,_=e.input,p=e.avail_in,I=n.hold,E=n.bits,12===n.mode&&(n.back=-1);break}for(n.back=0;w=(B=n.lencode[I&(1<<n.lenbits)-1])>>>16&255,N=65535&B,!((b=B>>>24)<=E);){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(w&&!(240&w)){for(R=b,L=w,k=N;w=(B=n.lencode[k+((I&(1<<R+L)-1)>>R)])>>>16&255,N=65535&B,!(R+(b=B>>>24)<=E);){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}I>>>=R,E-=R,n.back+=R}if(I>>>=b,E-=b,n.back+=b,n.length=N,0===w){n.mode=26;break}if(32&w){n.back=-1,n.mode=12;break}if(64&w){e.msg="invalid literal/length code",n.mode=30;break}n.extra=15&w,n.mode=22;case 22:if(n.extra){for(G=n.extra;E<G;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}n.length+=I&(1<<n.extra)-1,I>>>=n.extra,E-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=23;case 23:for(;w=(B=n.distcode[I&(1<<n.distbits)-1])>>>16&255,N=65535&B,!((b=B>>>24)<=E);){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(!(240&w)){for(R=b,L=w,k=N;w=(B=n.distcode[k+((I&(1<<R+L)-1)>>R)])>>>16&255,N=65535&B,!(R+(b=B>>>24)<=E);){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}I>>>=R,E-=R,n.back+=R}if(I>>>=b,E-=b,n.back+=b,64&w){e.msg="invalid distance code",n.mode=30;break}n.offset=N,n.extra=15&w,n.mode=24;case 24:if(n.extra){for(G=n.extra;E<G;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}n.offset+=I&(1<<n.extra)-1,I>>>=n.extra,E-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=30;break}n.mode=25;case 25:if(0===S)break e;if(T=C-S,n.offset>T){if((T=n.offset-T)>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=30;break}T>n.wnext?(T-=n.wnext,D=n.wsize-T):D=n.wnext-T,T>n.length&&(T=n.length),A=n.window}else A=g,D=v-n.offset,T=n.length;for(S<T&&(T=S),S-=T,n.length-=T;g[v++]=A[D++],--T;);0===n.length&&(n.mode=21);break;case 26:if(0===S)break e;g[v++]=n.length,S--,n.mode=21;break;case 27:if(n.wrap){for(;E<32;){if(0===p)break e;p--,I|=_[m++]<<E,E+=8}if(C-=S,e.total_out+=C,n.total+=C,C&&(e.adler=n.check=n.flags?o(n.check,g,C,v-C):i(n.check,g,C,v-C)),C=S,(n.flags?I:f(I))!==n.check){e.msg="incorrect data check",n.mode=30;break}E=I=0}n.mode=28;case 28:if(n.wrap&&n.flags){for(;E<32;){if(0===p)break e;p--,I+=_[m++]<<E,E+=8}if(I!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=30;break}E=I=0}n.mode=29;case 29:U=1;break e;case 30:U=-3;break e;case 31:return-4;default:return u}return e.next_out=v,e.avail_out=S,e.next_in=m,e.avail_in=p,n.hold=I,n.bits=E,(n.wsize||C!==e.avail_out&&n.mode<30&&(n.mode<27||4!==t))&&O(e,e.output,e.next_out,C-e.avail_out)?(n.mode=31,-4):(y-=e.avail_in,C-=e.avail_out,e.total_in+=y,e.total_out+=C,n.total+=C,n.wrap&&C&&(e.adler=n.check=n.flags?o(n.check,g,C,e.next_out-C):i(n.check,g,C,e.next_out-C)),e.data_type=n.bits+(n.last?64:0)+(12===n.mode?128:0)+(20===n.mode||15===n.mode?256:0),(0===y&&0===C||4===t)&&U===d&&(U=-5),U)},n.inflateEnd=function(e){if(!e||!e.state)return u;var t=e.state;return t.window&&(t.window=null),e.state=null,d},n.inflateGetHeader=function(e,t){var n;return e&&e.state&&2&(n=e.state).wrap?((n.head=t).done=!1,d):u},n.inflateSetDictionary=function(e,t){var n,s=t.length;return e&&e.state?0!==(n=e.state).wrap&&11!==n.mode?u:11===n.mode&&i(1,t,s,0)!==n.check?-3:O(e,t,s,s)?(n.mode=31,-4):(n.havedict=1,d):u},n.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":1,"./adler32":3,"./crc32":5,"./inffast":7,"./inftrees":9}],9:[function(e,t,n){var s=e("../utils/common"),i=[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],o=[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,n,c,l,d,u,h){var _,g,f,m,v,p,S,I,E,y=h.bits,C=0,M=0,O=0,T=0,D=0,A=0,b=0,w=0,N=0,R=0,L=null,k=0,P=new s.Buf16(16),U=new s.Buf16(16),F=null,G=0;for(C=0;C<=15;C++)P[C]=0;for(M=0;M<c;M++)P[t[n+M]]++;for(D=y,T=15;1<=T&&0===P[T];T--);if(T<D&&(D=T),0===T)return l[d++]=20971520,l[d++]=20971520,h.bits=1,0;for(O=1;O<T&&0===P[O];O++);for(D<O&&(D=O),C=w=1;C<=15;C++)if(w<<=1,(w-=P[C])<0)return-1;if(0<w&&(0===e||1!==T))return-1;for(U[1]=0,C=1;C<15;C++)U[C+1]=U[C]+P[C];for(M=0;M<c;M++)0!==t[n+M]&&(u[U[t[n+M]]++]=M);if(0===e?(L=F=u,p=19):1===e?(L=i,k-=257,F=o,G-=257,p=256):(L=r,F=a,p=-1),C=O,v=d,b=M=R=0,f=-1,m=(N=1<<(A=D))-1,1===e&&852<N||2===e&&592<N)return 1;for(;;){for(S=C-b,u[M]<p?(I=0,E=u[M]):u[M]>p?(I=F[G+u[M]],E=L[k+u[M]]):(I=96,E=0),_=1<<C-b,O=g=1<<A;l[v+(R>>b)+(g-=_)]=S<<24|I<<16|E,0!==g;);for(_=1<<C-1;R&_;)_>>=1;if(0!==_?(R&=_-1,R+=_):R=0,M++,0==--P[C]){if(C===T)break;C=t[n+u[M]]}if(D<C&&(R&m)!==f){for(0===b&&(b=D),v+=O,w=1<<(A=C-b);A+b<T&&!((w-=P[A+b])<=0);)A++,w<<=1;if(N+=1<<A,1===e&&852<N||2===e&&592<N)return 1;l[f=R&m]=D<<24|A<<16|v-d}}return 0!==R&&(l[v+R]=C-b<<24|64<<16),h.bits=D,0}},{"../utils/common":1}],10:[function(e,t,n){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,n){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,n){var s=e("./zlib/inflate"),i=e("./utils/common"),o=e("./utils/strings"),r=e("./zlib/constants"),a=e("./zlib/messages"),c=e("./zlib/zstream"),l=e("./zlib/gzheader"),d=Object.prototype.toString;function u(e){if(!(this instanceof u))return new u(e);this.options=i.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 n=s.inflateInit2(this.strm,t.windowBits);if(n!==r.Z_OK)throw new Error(a[n]);if(this.header=new l,s.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=o.string2buf(t.dictionary):"[object ArrayBuffer]"===d.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=s.inflateSetDictionary(this.strm,t.dictionary))!==r.Z_OK))throw new Error(a[n])}function h(e,t){var n=new u(t);if(n.push(e,!0),n.err)throw n.msg||a[n.err];return n.result}u.prototype.push=function(e,t){var n,a,c,l,u,h=this.strm,_=this.options.chunkSize,g=this.options.dictionary,f=!1;if(this.ended)return!1;a=t===~~t?t:!0===t?r.Z_FINISH:r.Z_NO_FLUSH,"string"==typeof e?h.input=o.binstring2buf(e):"[object ArrayBuffer]"===d.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 i.Buf8(_),h.next_out=0,h.avail_out=_),(n=s.inflate(h,r.Z_NO_FLUSH))===r.Z_NEED_DICT&&g&&(n=s.inflateSetDictionary(this.strm,g)),n===r.Z_BUF_ERROR&&!0===f&&(n=r.Z_OK,f=!1),n!==r.Z_STREAM_END&&n!==r.Z_OK)return this.onEnd(n),!(this.ended=!0);h.next_out&&(0!==h.avail_out&&n!==r.Z_STREAM_END&&(0!==h.avail_in||a!==r.Z_FINISH&&a!==r.Z_SYNC_FLUSH)||("string"===this.options.to?(c=o.utf8border(h.output,h.next_out),l=h.next_out-c,u=o.buf2string(h.output,c),h.next_out=l,h.avail_out=_-l,l&&i.arraySet(h.output,h.output,c,l,0),this.onData(u)):this.onData(i.shrinkBuf(h.output,h.next_out)))),0===h.avail_in&&0===h.avail_out&&(f=!0)}while((0<h.avail_in||0===h.avail_out)&&n!==r.Z_STREAM_END);return n===r.Z_STREAM_END&&(a=r.Z_FINISH),a===r.Z_FINISH?(n=s.inflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===r.Z_OK):a!==r.Z_SYNC_FLUSH||(this.onEnd(r.Z_OK),!(h.avail_out=0))},u.prototype.onData=function(e){this.chunks.push(e)},u.prototype.onEnd=function(e){e===r.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg},n.Inflate=u,n.inflate=h,n.inflateRaw=function(e,t){return(t=t||{}).raw=!0,h(e,t)},n.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")}(gt)),gt.exports);var mt=new class{constructor(){this._socketAdapter=null,this._url="",this._isReconnecting=!1,this._pendingRequests=new Map,this._nextHeartbeatAt=0,this._lastDiagnoseAt=0,this._isHeartbeatInProgress=!1,this._connectionEstablishedTime=0,this._connectionStartTime=0,this._connectionId=-1,this._isBinarySupported=!0,this._intendedDelay=it,this._currentConnectState=et}init(){Ae.addTask({id:Xe,intervalMs:1e3,callback:this._executeScheduledTaskIfReady,context:this}),this._updateIsBinarySupported(),this._url=function(e){const t=Ee.get("instance"),{sdkAppId:n,testEnv:s}=t,i=Se(n);return Oe(s?ve.TEST[i].DEFAULT:ve.PRODUCTION[i].INITIAL.replace("*",`${n}`),{isBinary:e})}(this._isBinarySupported),o.subscribeInnerEvent("networkStatusChange",this._handleNetworkStatusChange,this),o.subscribeInnerEvent("activityStatusChange",this._handleActivityStatusChange,this),this.connect()}sendPacket(e,t){var n;const{requestId:s,timeout:i=Je,canResend:o=!0}=t||{};if(ne(e))return console.warn(`${Ze}.sendPacket: packet is empty `,e),null;const r=JSON.stringify(e);let a=null;if(s){const{resolve:e,reject:t,promise:n}=se();a=n,this._pendingRequests.set(s,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:r,timeout:i,canResend:o})}const c=this._isBinarySupported?be(r).buffer:r;return null===(n=this._socketAdapter)||void 0===n||n.send(c),a}connect(