@tencentcloud/lite-chat
Version:
Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut
1 lines • 188 kB
JavaScript
class e{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,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)})))}emit(e,...t){const s=this.listeners[e];s&&s.forEach((e=>{const{fn:s,context:n}=e;s.apply(n,t)}))}once(e,t,s){const n=(...o)=>{t.apply(s,o),this.off(e,n)};this.on(e,n)}}var t;!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"}(t||(t={}));const s=[{conditions:[{type:"event",value:100}],subType:t.BUSINESS_COMMAND},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:t.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:t.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:t.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:t.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:t.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:t.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:t.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){var s;const n=[];return null===(s=null==e?void 0:e.C2cNotifyMsgArray)||void 0===s||s.forEach((e=>{e.WithdrawC2cMsgNotify&&n.push(t.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&n.push(t.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&n.push(t.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&n.push(t.C2C_REMIND_TYPE_SYNC)})),n}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subType:t.GROUP_TIPS_NOTIFICATION},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){var s;const n=[];return null===(s=null==e?void 0:e.GroupTips)||void 0===s||s.forEach((e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)&&n.push(t.GROUP_MESSAGE_REVOKED),Array.isArray(e.MsgBody.GroupMsgReceiptList)&&n.push(t.GROUP_MESSAGE_READ_RECEIPT),Array.isArray(e.MsgBody.GroupReadInfoArray)?n.push(t.GROUP_MESSAGE_READ_SYNC):n.push(t.GROUP_SYSTEM_NOTIFICATION)})),n}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subType:t.GROUP_TIPS_NOTIFICATION},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subType:t.GROUP_AT_TIPS},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subType:t.CONV_MODIFIED},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:t.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:t.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:t.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:t.FOLLOW_LIST_UPDATED}];var n;!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.ERROR="error"}(n||(n={}));const o={[n.SERVER_PUSH_MESSAGE]:function(e){var t;const o=Array.isArray(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.EventArray)?e.body.EventArray:[],i=[];return o.forEach((t=>{t.Flag=e.body.Flag;const o=s.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(!o)return null;let r=[];"function"==typeof o.subTypeParser?r=o.subTypeParser(t):o.subType&&(r=o.subType),Array.isArray(r)?r.forEach((e=>{i.push({type:`${n.SERVER_PUSH_MESSAGE}:${e}`,data:t})})):i.push({type:`${n.SERVER_PUSH_MESSAGE}:${r}`,data:t})})),i},[n.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}};const i=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._outerEventEmitter=new e,this._innerEventEmitter=new e,this.InnerEventSubType=t}subscribeInnerEvent(e,t,s,n){var o,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(o=this._innerEventEmitter)||void 0===o||o.on(`${e}:${i}`,r,n)}else{const n=t;null===(i=this._innerEventEmitter)||void 0===i||i.on(e,n,s)}}emitInnerEvent(e,t){var s,n;if(null===(s=this._innerEventEmitter)||void 0===s||s.emit(e,t),Object.keys(o).includes(e)){const s=null===(n=o[e])||void 0===n?void 0:n.call(o,t);null==s||s.forEach((e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))}))}}unSubscribeInnerEvent(e,t,s,n){var o,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(o=this._innerEventEmitter)||void 0===o||o.off(`${e}:${i}`,r,n)}else{const n=t;null===(i=this._innerEventEmitter)||void 0===i||i.off(e,n,s)}}subscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var n;null===(n=this._outerEventEmitter)||void 0===n||n.off(e,t,s)}emitOuterEvent(e,t){var s;null===(s=this._outerEventEmitter)||void 0===s||s.emit(e,t)}getOuterEventEmitter(){return this._outerEventEmitter}rest(){this._outerEventEmitter=null,this._innerEventEmitter=null}};function r(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 a=e=>void 0===e,c=e=>"string"==typeof e,l=e=>{var t;return null===(t=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))||void 0===t?void 0:t[1].toLowerCase()},d=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===l(e),u=e=>null!==e&&"object"==typeof e,_=e=>d(e)||u(e),h=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},g=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 f(e=99999999){return Math.round(Math.random()*e)}const E=(e,t,s,n)=>{if(!_(e)||!_(t))return 0;let o=0;const i=Object.keys(t);let r;for(let c=0,l=i.length;c<l;c++)if(r=i[c],!(a(t[r])||s&&s.includes(r)))if(_(e[r])&&_(t[r]))o+=E(e[r],t[r],s,n);else{if(n&&n.includes(t[r]))continue;e[r]!==t[r]&&(e[r]=t[r],o+=1)}return o};function p(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 m={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},S=["heartbeat.alive","im_open_status.wslogin","im_open_status.wslogout","group_open_long_polling_http_svc.get_msg","group_open_long_polling_http_noauth_svc.get_msg"];var v=Object.freeze({__proto__:null,ENUM_PLATFORM:m,NOT_NEED_CRC_SERVCMD:S});const I="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),C=I&&"function"==typeof wx.createGamePortal,y="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),M="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),O="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),T="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),A="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,N="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,R=I&&"object"==typeof wx.miniapp,D="undefined"!=typeof uni,w=I||y||M||O||T||N||A,b="undefined"==typeof window&&!w&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,k="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),P="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),L="undefined"!=typeof uni?!w:"undefined"!=typeof window&&!w&&!k,U=y?qq:M?tt:O?swan:T?my:I?wx:N?uni:A?jd:{},G=L&&window&&window.navigator&&window.navigator.userAgent||"",F=/(micromessenger|webbrowser)/i.test(G),x=function(){let e="WEB";return F?e="WEB":y?e="QQ_MP":M?e="TT_MP":O?e="BAIDU_MP":T?e="ALI_MP":I?e=R?"DONUT_NATIVE_APP":"WX_MP":N?e="UNI_NATIVE_APP":b?e="NS_NATIVE_APP":k&&(e="RN_NATIVE_APP"),m[e]}(),B=/iPad/i.test(G),$=/iPhone/i.test(G)&&!B,V=/iPod/i.test(G),q=$||B||V,W=function(){const e=G.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Y=/Android/i.test(G),K=function(){const e=G.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}(),j=/Firefox/i.test(G),H=/Edge/i.test(G),z=!H&&/Chrome/i.test(G),Z=/MSIE/.test(G)||G.indexOf("Trident")>-1&&G.indexOf("rv:11.0")>-1,J=function(){const e=/MSIE\s(\d+)\.\d/.exec(G);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(G)&&/rv:11.0/.test(G)&&(t=11),t}(),X=/Safari/i.test(G)&&!z&&!Y&&!H,Q=/Windows/i.test(G),ee=/MAC OS X/i.test(G),te=L&&"undefined"!=typeof Worker&&!Z,se=Y||q,ne=L&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,oe=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!q||e||X)}();function ie(){let e="unknown";if(ee&&(e="mac"),Q&&(e="windows"),q&&(e="ios"),Y&&(e="android"),w)try{const{platform:t}=wx.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}const re=2800,ae=2801,ce=3e3,le="application/x-www-form-urlencoded;charset=UTF-8";function de(e){return r(this,arguments,void 0,(function*({method:e,url:t,data:s,timeout:n=ce}){return new Promise(w?(o,i)=>{U.request({url:t,data:s,method:e,timeout:n,header:{"content-type":le},success:e=>o(e.data),fail:()=>i(new Error(`{"message":"Network error","code":${re}}`))})}:(o,i)=>{const r=new XMLHttpRequest,a=setTimeout((()=>{r.abort(),i(new Error(`{"message":"Request timeout","code":${ae}}`))}),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":${re}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",le),r.send(s||null)})}))}function ue(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(g(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 _e(e){if(null===e||"object"!=typeof e)return 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 e.forEach(((e,s)=>{t.set(_e(s),_e(e))})),t}if(e instanceof Set){const t=new Set;return e.forEach((e=>{t.add(_e(e))})),t}if(Array.isArray(e))return e.map((e=>_e(e)));const t=Object.getPrototypeOf(e),s=Object.create(t);return[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach((t=>{const n=Object.getOwnPropertyDescriptor(e,t);n&&(n.get||n.set?Object.defineProperty(s,t,n):s[t]=_e(e[t]))})),s}function he(){let e,t;return{promise:new Promise(((s,n)=>{e=s,t=n})),resolve:e,reject:t}}var ge=Object.freeze({__proto__:null,ANDROID_VERSION:K,IE_VERSION:J,IN_ALIPAY_MINI_APP:T,IN_BAIDU_MINI_APP:O,IN_BROWSER:L,IN_DONUT_NATIVE_APP:R,IN_JD_MINI_APP:A,IN_MINI_APP:w,IN_NS_NATIVE_APP:b,IN_QQ_MINI_APP:y,IN_RN_APP:k,IN_TT_MINI_APP:M,IN_UNI_APP:D,IN_UNI_NATIVE_APP:N,IN_WX_MINI_APP:I,IN_WX_MINI_GAME:C,IN_WX_MINI_PLUGIN:P,IOS_VERSION:W,IS_ANDROID:Y,IS_CHROME:z,IS_EDGE:H,IS_FIREFOX:j,IS_IE:Z,IS_IOS:q,IS_IPAD:B,IS_IPHONE:$,IS_IPOD:V,IS_MAC:ee,IS_SAFARI:X,IS_WECHAT:F,IS_WIN:Q,IS_WORKER_AVAILABLE:te,MINI_APP_NAMESPACE:U,USER_AGENT:G,base16EncodeBinaryString:p,deepCopyWithMethods:_e,deepMerge:E,generatePromise:he,getPlatformType:ie,getType:l,httpRequest:de,isArray:d,isArrayOrObject:_,isEmpty:ue,isFlutterWeb:ne,isH5:se,isIOSWebView:oe,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(e-0)||"object"==typeof e&&e.constructor===Number),isObject:u,isPlainObject:g,isString:c,isUndefined:a,isValidRequestKey:h,platform:x,randomInt:f,randomString:function(){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let t="";for(let s=32;s>0;--s)t+=e[Math.floor(62*Math.random())];return t}});class fe{constructor(){this._socket=null}connectSocket(e){return this._socket=new WebSocket(e),this._socket}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)}}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)}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 Ee{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:s,onClose:n,onError:o,onSendFail:i}=e;this._socket.onClose(n),this._socket.onOpen(t),this._socket.onMessage(s),this._socket.onError(o),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose((()=>{})),this._socket.onOpen((()=>{})),this._socket.onMessage((()=>{})),this._socket.onError((()=>{})))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}const pe="CONNECT",me="SEND",Se="DISCONNECT",ve="OPEN",Ie="MESSAGE",Ce="CLOSE",ye="ERROR",Me="SEND_FAIL";class Oe{constructor(){this._worker=null,this._blobUrl=null}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:pe,url:e})}send(e){var t,s;try{null===(t=this._worker)||void 0===t||t.postMessage({type:me,data:e})}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:o,onSendFail:i}=e;if(this._worker){const e={[ve]:t,[Ie]:s,[Ce]:n,[ye]:o,[Me]: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))}}}unbindSocketHandlers(){this._worker&&(this._worker.onmessage=null)}disconnect(){this._worker&&(this._worker.postMessage({type:Se}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var Te,Ae=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){if(w){if(T){return my.getStorageSync({key:e}).data}return U.getStorageSync(e)}return this._canUseLocalStorage()?localStorage.getItem(e):{}}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))}setStorage(e,t){w?T?my.setStorageSync({key:e,data:JSON.stringify(t)}):U.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&(navigator&&navigator.cookieEnabled&&localStorage)}};!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}(Te||(Te={}));class Ne{constructor(t){this._url="",this._readyState=Te.DISCONNECTED,this._url=t,this._id=f(),this._emitter=new e,I?this._socket=new Ee:this._canUseWebWorker()?this._socket=new Oe:this._socket=new fe,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[Te.CONNECTED,Te.CONNECTING].includes(this._readyState)||(this._readyState=Te.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==Te.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[Te.CONNECTED,Te.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===Te.CONNECTED}disconnect(){this._readyState=Te.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===Te.CONNECTING&&(this._readyState=Te.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=Te.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=Te.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=Te.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){const e=Ae.get("cloudConfig")||{};return(a(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&te}}const Re="CHINA",De="SINGAPORE",we="KOREA",be="GERMANY",ke="IND",Pe="JPN",Le="USA",Ue="INDONESIA",Ge={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"}}},Fe={[De]:[[2e7,3e7],[172e7,173e7]],[we]:[[3e7,4e7],[173e7,174e7]],[be]:[[4e7,5e7],[174e7,175e7]],[ke]:[[5e7,6e7],[175e7,176e7]],[Pe]:[[6e7,7e7],[176e7,177e7]],[Le]:[[7e7,8e7],[177e7,178e7]],[Ue]:[[8e7,9e7],[178e7,179e7]]};function xe(e){for(const t of Object.keys(Fe))for(const[s,n]of Fe[t])if(e>=s&&e<n)return t;return Re}var Be,$e="1.2.1";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST"}(Be||(Be={}));let Ve=Be.INITIAL;function qe(){const e=Math.random();return 0===e?qe():e}function We(e,t){const{isBinary:s=!1}=t||{},n=Ae.get("instance"),{sdkAppId:o,instanceId:i}=n,r=qe(),a=ie(),c=function(){const e=ie();let t=-1;"ios"===e?t=W||-1:"android"===e&&(t=K||-1);return t}(),l=(d={sdkappid:o,instanceid:i,random:r,platform:x,host:a,version:c,sdkversion:$e},Object.keys(d).map((e=>`${e}=${d[e]}`)).join("&"));var d;return s?`${e}/binfo?${l}&compress=gzip`:`${e}/info?${l}`}var Ye=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 s=Date.now(),n=s-e;this._timeOffsetWithServer=t+n-s}};const Ke=16;var je=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:s,context:n,isOnce:o=!1,intervalMs:i=Ke}=e,r=Math.max(i,Ke);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:i,callback:s,context:n,isOnce:o}}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 s=this._taskMap.get(e);s&&(s.intervalMs=t,s.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 He(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 ze(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&h(s)&&null!=e[s]&&(null===e[s]||"object"!=typeof e[s]?t[s]=e[s]:t[s]=ze(e[s]));return t}function Ze(e,t){if(S.includes(e))return 0;const s=He(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 Je(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ae.get("login")||{},s=Ae.get("instance")||{};return{servcmd:e,ver:"v4",platform:x,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:75689843,sdkability_ext:p(""),cappid:t.cappid||0,tjgID:"",seq:et(),cs:0}}(t),o=ze(s);return n.cs=Ze(t,o),{head:n,body:o}}function Xe(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ae.get("login")||{},s=Ae.get("instance")||{};return{servcmd:e,ver:"v4",platform:x,websdkappid:537048168,websdkversion:"1.7.3",sdkappid:s.sdkAppId,contenttype:"",reqtime:Math.floor(Date.now()/1e3),identifier:"",usersig:"",status_instid:t.statusInstanceId||0,sdkability:75689843,sdkability_ext:p(""),cappid:t.cappid||0,seq:et(),cs:0}}(t),o=ze(s);return n.cs=Ze(t,o),{head:n,body:o}}let Qe=f();function et(){return Qe=Qe<2415919103?Qe+1:f(),Qe}var st,nt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){const{servcmd:t,data:s}=e,n=function(e){const t=Ae.get("login")||{},s=Ae.get("instance")||{};return{servcmd:e,ver:"v4",platform:x,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:75689843,sdkability_ext:p(""),cappid:t.cappid||0,seq:et(),cs:0}}(t),o=ze(s);return n.cs=Ze(t,o),{head:n,body:o}},generateProtocolData:Je,generateSSOLogProtocolData:Xe,generateSequence:et,taskScheduler:je,timeManager:Ye});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(st||(st={}));const ot={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 it{constructor(e){this.level=st.info,this._canSendLog=!0,this._logCreatedAt=Ye.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:s=0}=e||{};this.eventType=s,this.method=t}setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=Ye.getTimeOffsetWithServer()}end(e=!1){if(!this._canSendLog)return;const t=Ye.getServerTimeMs();0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:${t}`),e?(this._canSendLog=!1,this.timestamp=Ye.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout((()=>{this._canSendLog=!1,this.timestamp=Ye.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=Ae.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=st.error,this}setLogInfo(e){return Object.keys(e).forEach((t=>{Object.keys(ot).includes(t)&&(this[t]=e[t])})),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach((t=>{const s=t;ot[s]&&(e[ot[s]]=this[s])})),e}}var rt;function at(){const e=Ae.get("login")||{},t=Ae.get("instance")||{};return{sdk_type:30,sdk_app_id:t.sdkAppId,sdk_version:"1.2.1",tiny_id:Number(e.tinyID),user_id:e.userId,platform:x,instance_id:t.instanceId,trace_id:(new Date).getTime()}}!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(rt||(rt={}));var ct=rt;const lt=20,dt=6e4,ut=[4,5,6],_t=[],ht=[],gt="report-logger";var ft=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=lt,this._maxThreshold=100,this._waitingTime=dt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,i.subscribeInnerEvent(ct.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),je.addTask({id:gt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=lt,evt_rpt_waiting:s=dt,evt_rpt_level:n=ut,evt_rpt_sdkappid_bl:o=_t,evt_rpt_tinyid_wl:i=ht}=e||{};this._sdkAppIdBlackList=o,this._waitingTime=s,this._minThreshold=t,this._reportLevel=n,this._tinyIdWhiteList=i}createSSOLogData(e){const t=new it(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 s={Header:at(),Event:t};yield function(e){const t="imopenstat.tim_web_report_v2",s=Xe({servcmd:t,data:e}),n=`${s.head.seq}${t}`;Lt.sendPacket(s,{requestId:n})}(s),this._lastReportAt=Date.now()}))}_savePlatFormInfo(){var e,t;if(I){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;Ae.set("instance",{appId:e,envVersion:t})}}else L&&Ae.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=Ae.get("login")||{},{sdkAppId:s}=Ae.get("instance")||{};return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter((e=>this._reportLevel.includes(e.level)))}reset(){console.log("SSO_LOG_MODULE.reset"),je.removeTask(gt),i.unSubscribeInnerEvent(ct.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this._uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=lt,this._maxThreshold=100,this._waitingTime=dt,this._logQueue=[]}};const Et=15e3,pt="Channel",mt="channel_schedule_task",St="channel_reconnect_task",vt="connected",It="connecting",Ct="disconnected",yt=500,Mt="network_status_change",Ot="activity_status_change",Tt="send_fail",At="reconnect_failed",Nt="socket_error",Rt="socket_close";function Dt(e){return Dt="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},Dt(e)}function wt(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 bt,kt={exports:{}};var Pt=(bt||(bt=1,kt.exports=function e(t,s,n){function o(r,a){if(!s[r]){if(!t[r]){if(!a&&wt)return wt(r);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=s[r]={exports:{}};t[r][0].call(l.exports,(function(e){return o(t[r][1][e]||e)}),l,l.exports,e,t,s,n)}return s[r].exports}for(var i=wt,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"!=Dt(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,l=new Array(2*a);for(s=n=0;s<a;)if((o=e[s++])<128)l[n++]=o;else if(4<(i=r[o]))l[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?l[n++]=65533:o<65536?l[n++]=o:(o-=65536,l[n++]=55296|o>>10&1023,l[n++]=56320|1023&o)}return c(l,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~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,l,d,u,_,h,g,f,E,p,m,S,v,I,C,y,M,O,T;s=e.state,n=e.next_in,O=e.input,o=n+(e.avail_in-5),i=e.next_out,T=e.output,r=i-(t-e.avail_out),a=i+(e.avail_out-257),c=s.dmax,l=s.wsize,d=s.whave,u=s.wnext,_=s.window,h=s.hold,g=s.bits,f=s.lencode,E=s.distcode,p=(1<<s.lenbits)-1,m=(1<<s.distbits)-1;e:do{g<15&&(h+=O[n++]<<g,g+=8,h+=O[n++]<<g,g+=8),S=f[h&p];t:for(;;){if(h>>>=v=S>>>24,g-=v,0==(v=S>>>16&255))T[i++]=65535&S;else{if(!(16&v)){if(!(64&v)){S=f[(65535&S)+(h&(1<<v)-1)];continue t}if(32&v){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}I=65535&S,(v&=15)&&(g<v&&(h+=O[n++]<<g,g+=8),I+=h&(1<<v)-1,h>>>=v,g-=v),g<15&&(h+=O[n++]<<g,g+=8,h+=O[n++]<<g,g+=8),S=E[h&m];s:for(;;){if(h>>>=v=S>>>24,g-=v,!(16&(v=S>>>16&255))){if(!(64&v)){S=E[(65535&S)+(h&(1<<v)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(C=65535&S,g<(v&=15)&&(h+=O[n++]<<g,(g+=8)<v&&(h+=O[n++]<<g,g+=8)),c<(C+=h&(1<<v)-1)){e.msg="invalid distance too far back",s.mode=30;break e}if(h>>>=v,g-=v,(v=i-r)<C){if(d<(v=C-v)&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(M=_,(y=0)===u){if(y+=l-v,v<I){for(I-=v;T[i++]=_[y++],--v;);y=i-C,M=T}}else if(u<v){if(y+=l+u-v,(v-=u)<I){for(I-=v;T[i++]=_[y++],--v;);if(y=0,u<I){for(I-=v=u;T[i++]=_[y++],--v;);y=i-C,M=T}}}else if(y+=u-v,v<I){for(I-=v;T[i++]=_[y++],--v;);y=i-C,M=T}for(;2<I;)T[i++]=M[y++],T[i++]=M[y++],T[i++]=M[y++],I-=3;I&&(T[i++]=M[y++],1<I&&(T[i++]=M[y++]))}else{for(y=i-C;T[i++]=T[y++],T[i++]=T[y++],T[i++]=T[y++],2<(I-=3););I&&(T[i++]=T[y++],1<I&&(T[i++]=T[y++]))}break}}break}}while(n<o&&i<a);n-=I=g>>3,h&=(1<<(g-=I<<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=h,s.bits=g}},{}],8:[function(e,t,s){var n=e("../utils/common"),o=e("./adler32"),i=e("./crc32"),r=e("./inffast"),a=e("./inftrees"),c=1,l=2,d=0,u=-2,_=1,h=852,g=592;function f(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function E(){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 p(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=_,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(h),t.distcode=t.distdyn=new n.Buf32(g),t.sane=1,t.back=-1,d):u}function m(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,p(e)):u}function S(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)?u:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=s,n.wbits=t,m(e))):u}function v(e,t){var s,n;return e?(n=new E,(e.state=n).window=null,(s=S(e,t))!==d&&(e.state=null),s):u}var I,C,y=!0;function M(e){if(y){var t;for(I=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(c,e.lens,0,288,I,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;a(l,e.lens,0,32,C,0,e.work,{bits:5}),y=!1}e.lencode=I,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=m,s.inflateReset2=S,s.inflateResetKeep=p,s.inflateInit=function(e){return v(e,15)},s.inflateInit2=v,s.inflate=function(e,t){var s,h,g,E,p,m,S,v,I,C,y,T,A,N,R,D,w,b,k,P,L,U,G,F,x=0,B=new n.Buf8(4),$=[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===(s=e.state).mode&&(s.mode=13),p=e.next_out,g=e.output,S=e.avail_out,E=e.next_in,h=e.input,m=e.avail_in,v=s.hold,I=s.bits,C=m,y=S,U=d;e:for(;;)switch(s.mode){case _:if(0===s.wrap){s.mode=13;break}for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(2&s.wrap&&35615===v){B[s.check=0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0),I=v=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&v)<<8)+(v>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&v)){e.msg="unknown compression method",s.mode=30;break}if(I-=4,L=8+(15&(v>>>=4)),0===s.wbits)s.wbits=L;else if(L>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<L,e.adler=s.check=1,s.mode=512&v?10:12,I=v=0;break;case 2:for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(s.flags=v,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=v>>8&1),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0)),I=v=0,s.mode=3;case 3:for(;I<32;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.head&&(s.head.time=v),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,B[2]=v>>>16&255,B[3]=v>>>24&255,s.check=i(s.check,B,4,0)),I=v=0,s.mode=4;case 4:for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.head&&(s.head.xflags=255&v,s.head.os=v>>8),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0)),I=v=0,s.mode=5;case 5:if(1024&s.flags){for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.length=v,s.head&&(s.head.extra_len=v),512&s.flags&&(B[0]=255&v,B[1]=v>>>8&255,s.check=i(s.check,B,2,0)),I=v=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(m<(T=s.length)&&(T=m),T&&(s.head&&(L=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),n.arraySet(s.head.extra,h,E,T,L)),512&s.flags&&(s.check=i(s.check,h,T,E)),m-=T,E+=T,s.length-=T),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===m)break e;for(T=0;L=h[E+T++],s.head&&L&&s.length<65536&&(s.head.name+=String.fromCharCode(L)),L&&T<m;);if(512&s.flags&&(s.check=i(s.check,h,T,E)),m-=T,E+=T,L)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===m)break e;for(T=0;L=h[E+T++],s.head&&L&&s.length<65536&&(s.head.comment+=String.fromCharCode(L)),L&&T<m;);if(512&s.flags&&(s.check=i(s.check,h,T,E)),m-=T,E+=T,L)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;I<16;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(v!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}I=v=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(;I<32;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}e.adler=s.check=f(v),I=v=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=p,e.avail_out=S,e.next_in=E,e.avail_in=m,s.hold=v,s.bits=I,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last){v>>>=7&I,I-=7&I,s.mode=27;break}for(;I<3;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}switch(s.last=1&v,I-=1,3&(v>>>=1)){case 0:s.mode=14;break;case 1:if(M(s),s.mode=20,6!==t)break;v>>>=2,I-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}v>>>=2,I-=2;break;case 14:for(v>>>=7&I,I-=7&I;I<32;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if((65535&v)!=(v>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&v,I=v=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(T=s.length){if(m<T&&(T=m),S<T&&(T=S),0===T)break e;n.arraySet(g,h,E,T,p),m-=T,E+=T,S-=T,p+=T,s.length-=T;break}s.mode=12;break;case 17:for(;I<14;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(s.nlen=257+(31&v),v>>>=5,I-=5,s.ndist=1+(31&v),v>>>=5,I-=5,s.ncode=4+(15&v),v>>>=4,I-=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(;I<3;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.lens[$[s.have++]]=7&v,v>>>=3,I-=3}for(;s.have<19;)s.lens[$[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,G={bits:s.lenbits},U=a(0,s.lens,0,19,s.lencode,0,s.work,G),s.lenbits=G.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(;D=(x=s.lencode[v&(1<<s.lenbits)-1])>>>16&255,w=65535&x,!((R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(w<16)v>>>=R,I-=R,s.lens[s.have++]=w;else{if(16===w){for(F=R+2;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(v>>>=R,I-=R,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}L=s.lens[s.have-1],T=3+(3&v),v>>>=2,I-=2}else if(17===w){for(F=R+3;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}I-=R,L=0,T=3+(7&(v>>>=R)),v>>>=3,I-=3}else{for(F=R+7;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}I-=R,L=0,T=11+(127&(v>>>=R)),v>>>=7,I-=7}if(s.have+T>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;T--;)s.lens[s.have++]=L}}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,G={bits:s.lenbits},U=a(c,s.lens,0,s.nlen,s.lencode,0,s.work,G),s.lenbits=G.bits,U){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,G={bits:s.distbits},U=a(l,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,G),s.distbits=G.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<=m&&258<=S){e.next_out=p,e.avail_out=S,e.next_in=E,e.avail_in=m,s.hold=v,s.bits=I,r(e,y),p=e.next_out,g=e.output,S=e.avail_out,E=e.next_in,h=e.input,m=e.avail_in,v=s.hold,I=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;D=(x=s.lencode[v&(1<<s.lenbits)-1])>>>16&255,w=65535&x,!((R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(D&&!(240&D)){for(b=R,k=D,P=w;D=(x=s.lencode[P+((v&(1<<b+k)-1)>>b)])>>>16&255,w=65535&x,!(b+(R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}v>>>=b,I-=b,s.back+=b}if(v>>>=R,I-=R,s.back+=R,s.length=w,0===D){s.mode=26;break}if(32&D){s.back=-1,s.mode=12;break}if(64&D){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&D,s.mode=22;case 22:if(s.extra){for(F=s.extra;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.length+=v&(1<<s.extra)-1,v>>>=s.extra,I-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;D=(x=s.distcode[v&(1<<s.distbits)-1])>>>16&255,w=65535&x,!((R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}if(!(240&D)){for(b=R,k=D,P=w;D=(x=s.distcode[P+((v&(1<<b+k)-1)>>b)])>>>16&255,w=65535&x,!(b+(R=x>>>24)<=I);){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}v>>>=b,I-=b,s.back+=b}if(v>>>=R,I-=R,s.back+=R,64&D){e.msg="invalid distance code",s.mode=30;break}s.offset=w,s.extra=15&D,s.mode=24;case 24:if(s.extra){for(F=s.extra;I<F;){if(0===m)break e;m--,v+=h[E++]<<I,I+=8}s.offset+=v&(1<<s.extra)-1,v>>>=s.extra,I-=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===S)break e;if(T=y-S,s.offset>T){if((T=s.offset-T)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}T>s.wnext?(T-=s.wnext,A=s.wsize-T):A=s.wnext-T,T>s.length&&(T=s.length),N=s.window}else N=g,A=p-s.offset,T=s.length;for(S<T&&(T=S),S-=T,s.length-=T;g[p++]=N[A++],--T;);0===s.length&&(s.mode=21);break;case 26:if(0===S)break e;g[p++]=s.length,S--,s.mode=21;break;case 27:if(s.wrap){for(;I<32;){if(0===m)break e;m--,v|=h[E++]<<I,I+=8}if(y-=S,e.total_out+=y,s.total+=y,y&&(e.adler=s.check=s.flags?i(s.check,g,y,p-y):o(s.check,g,y,p-y)),y=S,(s.flags?v:f(v))!==s.check){e.msg="incorrect data check",s.mode=30;break}I=v=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;I<32;){if(0===m)break e;m--,v+=h[E++]<<