UNPKG

@tencentcloud/lite-chat

Version:

Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut

1 lines 487 kB
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 o;t&&(this.listeners[e]=null===(o=this.listeners[e])||void 0===o?void 0:o.filter((e=>{const o=e.fn===t,n=!s||e.context===s;return!(o&&n)})))}emit(e,...t){const s=this.listeners[e];s&&s.forEach((e=>{const{fn:s,context:o}=e;s.apply(o,t)}))}once(e,t,s){const o=(...n)=>{t.apply(s,n),this.off(e,o)};this.on(e,o)}}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 o=[];return null===(s=null==e?void 0:e.C2cNotifyMsgArray)||void 0===s||s.forEach((e=>{e.WithdrawC2cMsgNotify&&o.push(t.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&o.push(t.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&o.push(t.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&o.push(t.C2C_REMIND_TYPE_SYNC)})),o}},{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 o=[];return null===(s=null==e?void 0:e.GroupTips)||void 0===s||s.forEach((e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)&&o.push(t.GROUP_MESSAGE_REVOKED),Array.isArray(e.MsgBody.GroupMsgReceiptList)&&o.push(t.GROUP_MESSAGE_READ_RECEIPT),Array.isArray(e.MsgBody.GroupReadInfoArray)?o.push(t.GROUP_MESSAGE_READ_SYNC):o.push(t.GROUP_SYSTEM_NOTIFICATION)})),o}},{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 o;!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.ERROR="error"}(o||(o={}));const n={[o.SERVER_PUSH_MESSAGE]:function(e){var t;const n=Array.isArray(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.EventArray)?e.body.EventArray:[],i=[];return n.forEach((t=>{t.Flag=e.body.Flag;const n=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(!n)return null;let r=[];"function"==typeof n.subTypeParser?r=n.subTypeParser(t):n.subType&&(r=n.subType),Array.isArray(r)?r.forEach((e=>{i.push({type:`${o.SERVER_PUSH_MESSAGE}:${e}`,data:t})})):i.push({type:`${o.SERVER_PUSH_MESSAGE}:${r}`,data:t})})),i},[o.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,o){var n,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(n=this._innerEventEmitter)||void 0===n||n.on(`${e}:${i}`,r,o)}else{const o=t;null===(i=this._innerEventEmitter)||void 0===i||i.on(e,o,s)}}emitInnerEvent(e,t){var s,o;if(null===(s=this._innerEventEmitter)||void 0===s||s.emit(e,t),Object.keys(n).includes(e)){const s=null===(o=n[e])||void 0===o?void 0:o.call(n,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,o){var n,i;if(["string","number"].includes(typeof t)){const i=t,r=s;null===(n=this._innerEventEmitter)||void 0===n||n.off(`${e}:${i}`,r,o)}else{const o=t;null===(i=this._innerEventEmitter)||void 0===i||i.off(e,o,s)}}subscribeOuterEvent(e,t,s){var o;null===(o=this._outerEventEmitter)||void 0===o||o.on(e,t,s)}unSubscribeOuterEvent(e,t,s){var o;null===(o=this._outerEventEmitter)||void 0===o||o.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){var s={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(s[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(s[o[n]]=e[o[n]])}return s}function a(e,t,s,o){return new(s||(s=Promise))((function(n,i){function r(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}c((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const c=e=>void 0===e,l=e=>"string"==typeof e,u=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"===u(e),h=e=>null!==e&&"object"==typeof e,p=e=>d(e)||h(e),g=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},_=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 m(e=99999999){return Math.round(Math.random()*e)}const f=(e,t,s,o)=>{if(!p(e)||!p(t))return 0;let n=0;const i=Object.keys(t);let r;for(let a=0,l=i.length;a<l;a++)if(r=i[a],!(c(t[r])||s&&s.includes(r)))if(p(e[r])&&p(t[r]))n+=f(e[r],t[r],s,o);else{if(o&&o.includes(t[r]))continue;e[r]!==t[r]&&(e[r]=t[r],n+=1)}return n};function v(e){let t,s,o=e;e.length%8!=0&&(o="0".repeat(8-e.length%8)+e);let n="";for(let e=0,{length:i}=o;e<i;e+=8)t=parseInt(o.slice(e,e+4),2),s=parseInt(o.slice(e+4,e+8),2),n+=base16Map.get(t)+base16Map.get(s);return n}const I={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 E=Object.freeze({__proto__:null,ENUM_PLATFORM:I,NOT_NEED_CRC_SERVCMD:S});const C="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),y=C&&"function"==typeof wx.createGamePortal,M="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),A="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),D="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,R="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,L=C&&"object"==typeof wx.miniapp,N="undefined"!=typeof uni,b=C||M||A||O||T||R||D,w="undefined"==typeof window&&!b&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,P="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),U="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),G="undefined"!=typeof uni?!b:"undefined"!=typeof window&&!b&&!P,k=M?qq:A?tt:O?swan:T?my:C?wx:R?uni:D?jd:{},F=G&&window&&window.navigator&&window.navigator.userAgent||"",$=/(micromessenger|webbrowser)/i.test(F),q=function(){let e="WEB";return $?e="WEB":M?e="QQ_MP":A?e="TT_MP":O?e="BAIDU_MP":T?e="ALI_MP":C?e=L?"DONUT_NATIVE_APP":"WX_MP":R?e="UNI_NATIVE_APP":w?e="NS_NATIVE_APP":P&&(e="RN_NATIVE_APP"),I[e]}(),x=/iPad/i.test(F),V=/iPhone/i.test(F)&&!x,B=/iPod/i.test(F),j=V||x||B,W=function(){const e=F.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),K=/Android/i.test(F),H=function(){const e=F.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const t=e[1]&&parseFloat(e[1]),s=e[2]&&parseFloat(e[2]);return t&&s?parseFloat(`${e[1]}.${e[2]}`):t||null}(),Y=/Firefox/i.test(F),z=/Edge/i.test(F),J=!z&&/Chrome/i.test(F),Z=/MSIE/.test(F)||F.indexOf("Trident")>-1&&F.indexOf("rv:11.0")>-1,X=function(){const e=/MSIE\s(\d+)\.\d/.exec(F);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(F)&&/rv:11.0/.test(F)&&(t=11),t}(),Q=/Safari/i.test(F)&&!J&&!K&&!z,ee=/Windows/i.test(F),te=/MAC OS X/i.test(F),se=G&&"undefined"!=typeof Worker&&!Z,oe=K||j,ne=G&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ie=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!j||e||Q)}();function re(){let e="unknown";if(te&&(e="mac"),ee&&(e="windows"),j&&(e="ios"),K&&(e="android"),b)try{const{platform:t}=wx.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}const ae=2800,ce=2801,le=3e3,ue="application/x-www-form-urlencoded;charset=UTF-8";function de(e){return a(this,arguments,void 0,(function*({method:e,url:t,data:s,timeout:o=le}){return new Promise(b?(n,i)=>{k.request({url:t,data:s,method:e,timeout:o,header:{"content-type":ue},success:e=>n(e.data),fail:()=>i(new Error(`{"message":"Network error","code":${ae}}`))})}:(n,i)=>{const r=new XMLHttpRequest,a=setTimeout((()=>{r.abort(),i(new Error(`{"message":"Request timeout","code":${ce}}`))}),o);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(a),200===r.status||304===r.status)try{n(r.responseText?JSON.parse(r.responseText):null)}catch(e){n(r.responseText)}else i(new Error(`{"message":"Network error","code":${ae}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",ue),r.send(s||null)})}))}function he(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(_(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 pe(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(pe(s),pe(e))})),t}if(e instanceof Set){const t=new Set;return e.forEach((e=>{t.add(pe(e))})),t}if(Array.isArray(e))return e.map((e=>pe(e)));const t=Object.getPrototypeOf(e),s=Object.create(t);return[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach((t=>{const o=Object.getOwnPropertyDescriptor(e,t);o&&(o.get||o.set?Object.defineProperty(s,t,o):s[t]=pe(e[t]))})),s}function ge(){let e,t;return{promise:new Promise(((s,o)=>{e=s,t=o})),resolve:e,reject:t}}var _e=Object.freeze({__proto__:null,ANDROID_VERSION:H,IE_VERSION:X,IN_ALIPAY_MINI_APP:T,IN_BAIDU_MINI_APP:O,IN_BROWSER:G,IN_DONUT_NATIVE_APP:L,IN_JD_MINI_APP:D,IN_MINI_APP:b,IN_NS_NATIVE_APP:w,IN_QQ_MINI_APP:M,IN_RN_APP:P,IN_TT_MINI_APP:A,IN_UNI_APP:N,IN_UNI_NATIVE_APP:R,IN_WX_MINI_APP:C,IN_WX_MINI_GAME:y,IN_WX_MINI_PLUGIN:U,IOS_VERSION:W,IS_ANDROID:K,IS_CHROME:J,IS_EDGE:z,IS_FIREFOX:Y,IS_IE:Z,IS_IOS:j,IS_IPAD:x,IS_IPHONE:V,IS_IPOD:B,IS_MAC:te,IS_SAFARI:Q,IS_WECHAT:$,IS_WIN:ee,IS_WORKER_AVAILABLE:se,MINI_APP_NAMESPACE:k,USER_AGENT:F,base16EncodeBinaryString:v,deepCopyWithMethods:pe,deepMerge:f,generatePromise:ge,getPlatformType:re,getType:u,httpRequest:de,isArray:d,isArrayOrObject:p,isEmpty:he,isFlutterWeb:ne,isH5:oe,isIOSWebView:ie,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(e-0)||"object"==typeof e&&e.constructor===Number),isObject:h,isPlainObject:_,isString:l,isUndefined:c,isValidRequestKey:g,platform:q,randomInt:m,randomString:function(){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let t="";for(let s=32;s>0;--s)t+=e[Math.floor(62*Math.random())];return t}});class me{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:o,onError:n,onSendFail:i}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=t,this._socket.onmessage=s,this._socket.onclose=o,this._socket.onerror=n,this._onSendFail=i)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class fe{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:o,onError:n,onSendFail:i}=e;this._socket.onClose(o),this._socket.onOpen(t),this._socket.onMessage(s),this._socket.onError(n),this._onSendFail=i}unbindSocketHandlers(){this._socket&&(this._socket.onClose((()=>{})),this._socket.onOpen((()=>{})),this._socket.onMessage((()=>{})),this._socket.onError((()=>{})))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}const ve="CONNECT",Ie="SEND",Se="DISCONNECT",Ee="OPEN",Ce="MESSAGE",ye="CLOSE",Me="ERROR",Ae="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:ve,url:e})}send(e){var t,s;try{null===(t=this._worker)||void 0===t||t.postMessage({type:Ie,data:e})}catch(e){null===(s=this._onSendFail)||void 0===s||s.call(this,e)}}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:o,onError:n,onSendFail:i}=e;if(this._worker){const e={[Ee]:t,[Ce]:s,[ye]:o,[Me]:n,[Ae]:i};this._onSendFail=i,this._worker.onmessage=t=>{var s;const{type:o}=(null==t?void 0:t.data)||{};"function"==typeof e[o]&&(null===(s=e[o])||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,De=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){if(b){if(T){return my.getStorageSync({key:e}).data}return k.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){b?T?my.setStorageSync({key:e,data:JSON.stringify(t)}):k.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 Re{constructor(t){this._url="",this._readyState=Te.DISCONNECTED,this._url=t,this._id=m(),this._emitter=new e,C?this._socket=new fe:this._canUseWebWorker()?this._socket=new Oe:this._socket=new me,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=De.get("cloudConfig")||{};return(c(e.isWorkerEnabled)||"1"===e.isWorkerEnabled)&&se}}const Le="CHINA",Ne="SINGAPORE",be="KOREA",we="GERMANY",Pe="IND",Ue="JPN",Ge="USA",ke="INDONESIA",Fe={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"}}},$e={[Ne]:[[2e7,3e7],[172e7,173e7]],[be]:[[3e7,4e7],[173e7,174e7]],[we]:[[4e7,5e7],[174e7,175e7]],[Pe]:[[5e7,6e7],[175e7,176e7]],[Ue]:[[6e7,7e7],[176e7,177e7]],[Ge]:[[7e7,8e7],[177e7,178e7]],[ke]:[[8e7,9e7],[178e7,179e7]]};function qe(e){for(const t of Object.keys($e))for(const[s,o]of $e[t])if(e>=s&&e<o)return t;return Le}var xe,Ve="1.2.1";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.ANYCAST="ANYCAST"}(xe||(xe={}));let Be=xe.INITIAL;function je(){const e=Math.random();return 0===e?je():e}function We(e,t){const{isBinary:s=!1}=t||{},o=De.get("instance"),{sdkAppId:n,instanceId:i}=o,r=je(),a=re(),c=function(){const e=re();let t=-1;"ios"===e?t=W||-1:"android"===e&&(t=H||-1);return t}(),l=(u={sdkappid:n,instanceid:i,random:r,platform:q,host:a,version:c,sdkversion:Ve},Object.keys(u).map((e=>`${e}=${u[e]}`)).join("&"));var u;return s?`${e}/binfo?${l}&compress=gzip`:`${e}/info?${l}`}var Ke=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(),o=s-e;this._timeOffsetWithServer=t+o-s}};const He=16;var Ye=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:o,isOnce:n=!1,intervalMs:i=He}=e,r=Math.max(i,He);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:i,callback:s,context:o,isOnce:n}}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 ze(e){const t=[];for(let s=0;s<e.length;s+=1){const o=e.charCodeAt(s);if(o>=55296&&o<=56319){const n=e.charCodeAt(++s)-56320+(o-55296<<10)+65536;t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n)}else o<=127?t.push(o):o<=2047?t.push(192|o>>6,128|63&o):t.push(224|o>>12,128|o>>6&63,128|63&o)}return new Uint8Array(t)}function Je(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&g(s)&&null!=e[s]&&(null===e[s]||"object"!=typeof e[s]?t[s]=e[s]:t[s]=Je(e[s]));return t}function Ze(e,t){if(S.includes(e))return 0;const s=ze(JSON.stringify(t));let o=4294967295;const{length:n}=s;for(let e=0;e<n;e++){o^=s[e];for(let e=0;e<8;e++)1&~o?o>>>=1:o=o>>>1^3988292384}return(4294967295^o)>>>0}function Xe(e){const{servcmd:t,data:s}=e,o=function(e){const t=De.get("login")||{},s=De.get("instance")||{};return{servcmd:e,ver:"v4",platform:q,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:v(""),cappid:t.cappid||0,tjgID:"",seq:st(),cs:0}}(t),n=Je(s);return o.cs=Ze(t,n),{head:o,body:n}}function Qe(e){const{servcmd:t,data:s}=e,o=function(e){const t=De.get("login")||{},s=De.get("instance")||{};return{servcmd:e,ver:"v4",platform:q,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:v(""),cappid:t.cappid||0,seq:st(),cs:0}}(t),n=Je(s);return o.cs=Ze(t,n),{head:o,body:n}}let et=m();function st(){return et=et<2415919103?et+1:m(),et}var ot,nt=Object.freeze({__proto__:null,generateCosSpecifiedData:function(e){const{servcmd:t,data:s}=e,o=function(e){const t=De.get("login")||{},s=De.get("instance")||{};return{servcmd:e,ver:"v4",platform:q,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:v(""),cappid:t.cappid||0,seq:st(),cs:0}}(t),n=Je(s);return o.cs=Ze(t,n),{head:o,body:n}},generateProtocolData:Xe,generateSSOLogProtocolData:Qe,generateSequence:st,taskScheduler:Ye,timeManager:Ke});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(ot||(ot={}));const it={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 rt{constructor(e){this.level=ot.info,this._canSendLog=!0,this._logCreatedAt=Ke.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+=Ke.getTimeOffsetWithServer()}end(e=!1){if(!this._canSendLog)return;const t=Ke.getServerTimeMs();0===this.costTime&&(this.costTime=t-this._logCreatedAt),this.setMoreMessage(`startts:${this._logCreatedAt} endts:${t}`),e?(this._canSendLog=!1,this.timestamp=Ke.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe())):setTimeout((()=>{this._canSendLog=!1,this.timestamp=Ke.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=De.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=ot.error,this}setLogInfo(e){return Object.keys(e).forEach((t=>{Object.keys(it).includes(t)&&(this[t]=e[t])})),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach((t=>{const s=t;it[s]&&(e[it[s]]=this[s])})),e}}var at;function ct(){const e=De.get("login")||{},t=De.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:q,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"}(at||(at={}));var lt=at;const ut=20,dt=6e4,ht=[4,5,6],pt=[],gt=[],_t="report-logger";var mt=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=ut,this._maxThreshold=100,this._waitingTime=dt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,i.subscribeInnerEvent(lt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),Ye.addTask({id:_t,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=ut,evt_rpt_waiting:s=dt,evt_rpt_level:o=ht,evt_rpt_sdkappid_bl:n=pt,evt_rpt_tinyid_wl:i=gt}=e||{};this._sdkAppIdBlackList=n,this._waitingTime=s,this._minThreshold=t,this._reportLevel=o,this._tinyIdWhiteList=i}createSSOLogData(e){const t=new rt(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 a(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:ct(),Event:t};yield function(e){const t="imopenstat.tim_web_report_v2",s=Qe({servcmd:t,data:e}),o=`${s.head.seq}${t}`;Gt.sendPacket(s,{requestId:o})}(s),this._lastReportAt=Date.now()}))}_savePlatFormInfo(){var e,t;if(C){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;De.set("instance",{appId:e,envVersion:t})}}else G&&De.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=De.get("login")||{},{sdkAppId:s}=De.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"),Ye.removeTask(_t),i.unSubscribeInnerEvent(lt.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this._uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=ut,this._maxThreshold=100,this._waitingTime=dt,this._logQueue=[]}};const ft=15e3,vt="Channel",It="channel_schedule_task",St="channel_reconnect_task",Et="connected",Ct="connecting",yt="disconnected",Mt=500,At="network_status_change",Ot="activity_status_change",Tt="send_fail",Dt="reconnect_failed",Rt="socket_error",Lt="socket_close";function Nt(e){return Nt="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},Nt(e)}function bt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var wt,Pt={exports:{}};var Ut=(wt||(wt=1,Pt.exports=function e(t,s,o){function n(r,a){if(!s[r]){if(!t[r]){if(!a&&bt)return bt(r);if(i)return i(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var l=s[r]={exports:{}};t[r][0].call(l.exports,(function(e){return n(t[r][1][e]||e)}),l,l.exports,e,t,s,o)}return s[r].exports}for(var i=bt,r=0;r<o.length;r++)n(o[r]);return n}({1:[function(e,t,s){var o="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;s.assign=function(e){for(var t,s,o=Array.prototype.slice.call(arguments,1);o.length;){var n=o.shift();if(n){if("object"!=Nt(n))throw new TypeError(n+"must be non-object");for(var i in n)t=n,s=i,Object.prototype.hasOwnProperty.call(t,s)&&(e[i]=n[i])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var n={arraySet:function(e,t,s,o,n){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+o),n);else for(var i=0;i<o;i++)e[n+i]=t[s+i]},flattenChunks:function(e){var t,s,o,n,i,r;for(t=o=0,s=e.length;t<s;t++)o+=e[t].length;for(r=new Uint8Array(o),t=n=0,s=e.length;t<s;t++)i=e[t],r.set(i,n),n+=i.length;return r}},i={arraySet:function(e,t,s,o,n){for(var i=0;i<o;i++)e[n+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,n)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,i))},s.setTyped(o)},{}],2:[function(e,t,s){var o=e("./common"),n=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch(e){n=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){i=!1}for(var r=new o.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&&n))return String.fromCharCode.apply(null,o.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,n,i,r,a=e.length,c=0;for(i=0;i<a;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(n-56320),i++),c+=s<128?1:s<2048?2:s<65536?3:4;for(t=new o.Buf8(c),i=r=0;r<c;i++)55296==(64512&(s=e.charCodeAt(i)))&&i+1<a&&56320==(64512&(n=e.charCodeAt(i+1)))&&(s=65536+(s-55296<<10)+(n-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 o.Buf8(e.length),s=0,n=t.length;s<n;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){var s,o,n,i,a=t||e.length,l=new Array(2*a);for(s=o=0;s<a;)if((n=e[s++])<128)l[o++]=n;else if(4<(i=r[n]))l[o++]=65533,s+=i-1;else{for(n&=2===i?31:3===i?15:7;1<i&&s<a;)n=n<<6|63&e[s++],i--;1<i?l[o++]=65533:n<65536?l[o++]=n:(n-=65536,l[o++]=55296|n>>10&1023,l[o++]=56320|1023&n)}return c(l,o)},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,o){for(var n=65535&e,i=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;i=i+(n=n+t[o++]|0)|0,--r;);n%=65521,i%=65521}return n|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 o=function(){for(var e,t=[],s=0;s<256;s++){e=s;for(var o=0;o<8;o++)e=1&e?3988292384^e>>>1:e>>>1;t[s]=e}return t}();t.exports=function(e,t,s,n){var i=o,r=n+s;e^=-1;for(var a=n;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,o,n,i,r,a,c,l,u,d,h,p,g,_,m,f,v,I,S,E,C,y,M,A,O;s=e.state,o=e.next_in,A=e.input,n=o+(e.avail_in-5),i=e.next_out,O=e.output,r=i-(t-e.avail_out),a=i+(e.avail_out-257),c=s.dmax,l=s.wsize,u=s.whave,d=s.wnext,h=s.window,p=s.hold,g=s.bits,_=s.lencode,m=s.distcode,f=(1<<s.lenbits)-1,v=(1<<s.distbits)-1;e:do{g<15&&(p+=A[o++]<<g,g+=8,p+=A[o++]<<g,g+=8),I=_[p&f];t:for(;;){if(p>>>=S=I>>>24,g-=S,0==(S=I>>>16&255))O[i++]=65535&I;else{if(!(16&S)){if(!(64&S)){I=_[(65535&I)+(p&(1<<S)-1)];continue t}if(32&S){s.mode=12;break e}e.msg="invalid literal/length code",s.mode=30;break e}E=65535&I,(S&=15)&&(g<S&&(p+=A[o++]<<g,g+=8),E+=p&(1<<S)-1,p>>>=S,g-=S),g<15&&(p+=A[o++]<<g,g+=8,p+=A[o++]<<g,g+=8),I=m[p&v];s:for(;;){if(p>>>=S=I>>>24,g-=S,!(16&(S=I>>>16&255))){if(!(64&S)){I=m[(65535&I)+(p&(1<<S)-1)];continue s}e.msg="invalid distance code",s.mode=30;break e}if(C=65535&I,g<(S&=15)&&(p+=A[o++]<<g,(g+=8)<S&&(p+=A[o++]<<g,g+=8)),c<(C+=p&(1<<S)-1)){e.msg="invalid distance too far back",s.mode=30;break e}if(p>>>=S,g-=S,(S=i-r)<C){if(u<(S=C-S)&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(M=h,(y=0)===d){if(y+=l-S,S<E){for(E-=S;O[i++]=h[y++],--S;);y=i-C,M=O}}else if(d<S){if(y+=l+d-S,(S-=d)<E){for(E-=S;O[i++]=h[y++],--S;);if(y=0,d<E){for(E-=S=d;O[i++]=h[y++],--S;);y=i-C,M=O}}}else if(y+=d-S,S<E){for(E-=S;O[i++]=h[y++],--S;);y=i-C,M=O}for(;2<E;)O[i++]=M[y++],O[i++]=M[y++],O[i++]=M[y++],E-=3;E&&(O[i++]=M[y++],1<E&&(O[i++]=M[y++]))}else{for(y=i-C;O[i++]=O[y++],O[i++]=O[y++],O[i++]=O[y++],2<(E-=3););E&&(O[i++]=O[y++],1<E&&(O[i++]=O[y++]))}break}}break}}while(o<n&&i<a);o-=E=g>>3,p&=(1<<(g-=E<<3))-1,e.next_in=o,e.next_out=i,e.avail_in=o<n?n-o+5:5-(o-n),e.avail_out=i<a?a-i+257:257-(i-a),s.hold=p,s.bits=g}},{}],8:[function(e,t,s){var o=e("../utils/common"),n=e("./adler32"),i=e("./crc32"),r=e("./inffast"),a=e("./inftrees"),c=1,l=2,u=0,d=-2,h=1,p=852,g=592;function _(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function m(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(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 o.Buf32(p),t.distcode=t.distdyn=new o.Buf32(g),t.sane=1,t.back=-1,u):d}function v(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,f(e)):d}function I(e,t){var s,o;return e&&e.state?(o=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t)?d:(null!==o.window&&o.wbits!==t&&(o.window=null),o.wrap=s,o.wbits=t,v(e))):d}function S(e,t){var s,o;return e?(o=new m,(e.state=o).window=null,(s=I(e,t))!==u&&(e.state=null),s):d}var E,C,y=!0;function M(e){if(y){var t;for(E=new o.Buf32(512),C=new o.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,C,0,e.work,{bits:5}),y=!1}e.lencode=E,e.lenbits=9,e.distcode=C,e.distbits=5}function A(e,t,s,n){var i,r=e.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new o.Buf8(r.wsize)),n>=r.wsize?(o.arraySet(r.window,t,s-r.wsize,r.wsize,0),r.wnext=0,r.whave=r.wsize):(n<(i=r.wsize-r.wnext)&&(i=n),o.arraySet(r.window,t,s-n,i,r.wnext),(n-=i)?(o.arraySet(r.window,t,s-n,n,0),r.wnext=n,r.whave=r.wsize):(r.wnext+=i,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=i))),0}s.inflateReset=v,s.inflateReset2=I,s.inflateResetKeep=f,s.inflateInit=function(e){return S(e,15)},s.inflateInit2=S,s.inflate=function(e,t){var s,p,g,m,f,v,I,S,E,C,y,O,T,D,R,L,N,b,w,P,U,G,k,F,$=0,q=new o.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 d;12===(s=e.state).mode&&(s.mode=13),f=e.next_out,g=e.output,I=e.avail_out,m=e.next_in,p=e.input,v=e.avail_in,S=s.hold,E=s.bits,C=v,y=I,G=u;e:for(;;)switch(s.mode){case h:if(0===s.wrap){s.mode=13;break}for(;E<16;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(2&s.wrap&&35615===S){q[s.check=0]=255&S,q[1]=S>>>8&255,s.check=i(s.check,q,2,0),E=S=0,s.mode=2;break}if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&S)<<8)+(S>>8))%31){e.msg="incorrect header check",s.mode=30;break}if(8!=(15&S)){e.msg="unknown compression method",s.mode=30;break}if(E-=4,U=8+(15&(S>>>=4)),0===s.wbits)s.wbits=U;else if(U>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<U,e.adler=s.check=1,s.mode=512&S?10:12,E=S=0;break;case 2:for(;E<16;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(s.flags=S,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=S>>8&1),512&s.flags&&(q[0]=255&S,q[1]=S>>>8&255,s.check=i(s.check,q,2,0)),E=S=0,s.mode=3;case 3:for(;E<32;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}s.head&&(s.head.time=S),512&s.flags&&(q[0]=255&S,q[1]=S>>>8&255,q[2]=S>>>16&255,q[3]=S>>>24&255,s.check=i(s.check,q,4,0)),E=S=0,s.mode=4;case 4:for(;E<16;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}s.head&&(s.head.xflags=255&S,s.head.os=S>>8),512&s.flags&&(q[0]=255&S,q[1]=S>>>8&255,s.check=i(s.check,q,2,0)),E=S=0,s.mode=5;case 5:if(1024&s.flags){for(;E<16;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}s.length=S,s.head&&(s.head.extra_len=S),512&s.flags&&(q[0]=255&S,q[1]=S>>>8&255,s.check=i(s.check,q,2,0)),E=S=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&(v<(O=s.length)&&(O=v),O&&(s.head&&(U=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),o.arraySet(s.head.extra,p,m,O,U)),512&s.flags&&(s.check=i(s.check,p,O,m)),v-=O,m+=O,s.length-=O),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===v)break e;for(O=0;U=p[m+O++],s.head&&U&&s.length<65536&&(s.head.name+=String.fromCharCode(U)),U&&O<v;);if(512&s.flags&&(s.check=i(s.check,p,O,m)),v-=O,m+=O,U)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===v)break e;for(O=0;U=p[m+O++],s.head&&U&&s.length<65536&&(s.head.comment+=String.fromCharCode(U)),U&&O<v;);if(512&s.flags&&(s.check=i(s.check,p,O,m)),v-=O,m+=O,U)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;E<16;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(S!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}E=S=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(;E<32;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}e.adler=s.check=_(S),E=S=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=f,e.avail_out=I,e.next_in=m,e.avail_in=v,s.hold=S,s.bits=E,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last){S>>>=7&E,E-=7&E,s.mode=27;break}for(;E<3;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}switch(s.last=1&S,E-=1,3&(S>>>=1)){case 0:s.mode=14;break;case 1:if(M(s),s.mode=20,6!==t)break;S>>>=2,E-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}S>>>=2,E-=2;break;case 14:for(S>>>=7&E,E-=7&E;E<32;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if((65535&S)!=(S>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&S,E=S=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(O=s.length){if(v<O&&(O=v),I<O&&(O=I),0===O)break e;o.arraySet(g,p,m,O,f),v-=O,m+=O,I-=O,f+=O,s.length-=O;break}s.mode=12;break;case 17:for(;E<14;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(s.nlen=257+(31&S),S>>>=5,E-=5,s.ndist=1+(31&S),S>>>=5,E-=5,s.ncode=4+(15&S),S>>>=4,E-=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(;E<3;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}s.lens[x[s.have++]]=7&S,S>>>=3,E-=3}for(;s.have<19;)s.lens[x[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,k={bits:s.lenbits},G=a(0,s.lens,0,19,s.lencode,0,s.work,k),s.lenbits=k.bits,G){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(;L=($=s.lencode[S&(1<<s.lenbits)-1])>>>16&255,N=65535&$,!((R=$>>>24)<=E);){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(N<16)S>>>=R,E-=R,s.lens[s.have++]=N;else{if(16===N){for(F=R+2;E<F;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(S>>>=R,E-=R,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}U=s.lens[s.have-1],O=3+(3&S),S>>>=2,E-=2}else if(17===N){for(F=R+3;E<F;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}E-=R,U=0,O=3+(7&(S>>>=R)),S>>>=3,E-=3}else{for(F=R+7;E<F;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}E-=R,U=0,O=11+(127&(S>>>=R)),S>>>=7,E-=7}if(s.have+O>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;O--;)s.lens[s.have++]=U}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,k={bits:s.lenbits},G=a(c,s.lens,0,s.nlen,s.lencode,0,s.work,k),s.lenbits=k.bits,G){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,k={bits:s.distbits},G=a(l,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,k),s.distbits=k.bits,G){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<=v&&258<=I){e.next_out=f,e.avail_out=I,e.next_in=m,e.avail_in=v,s.hold=S,s.bits=E,r(e,y),f=e.next_out,g=e.output,I=e.avail_out,m=e.next_in,p=e.input,v=e.avail_in,S=s.hold,E=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;L=($=s.lencode[S&(1<<s.lenbits)-1])>>>16&255,N=65535&$,!((R=$>>>24)<=E);){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(L&&!(240&L)){for(b=R,w=L,P=N;L=($=s.lencode[P+((S&(1<<b+w)-1)>>b)])>>>16&255,N=65535&$,!(b+(R=$>>>24)<=E);){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}S>>>=b,E-=b,s.back+=b}if(S>>>=R,E-=R,s.back+=R,s.length=N,0===L){s.mode=26;break}if(32&L){s.back=-1,s.mode=12;break}if(64&L){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&L,s.mode=22;case 22:if(s.extra){for(F=s.extra;E<F;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}s.length+=S&(1<<s.extra)-1,S>>>=s.extra,E-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;L=($=s.distcode[S&(1<<s.distbits)-1])>>>16&255,N=65535&$,!((R=$>>>24)<=E);){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}if(!(240&L)){for(b=R,w=L,P=N;L=($=s.distcode[P+((S&(1<<b+w)-1)>>b)])>>>16&255,N=65535&$,!(b+(R=$>>>24)<=E);){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}S>>>=b,E-=b,s.back+=b}if(S>>>=R,E-=R,s.back+=R,64&L){e.msg="invalid distance code",s.mode=30;break}s.offset=N,s.extra=15&L,s.mode=24;case 24:if(s.extra){for(F=s.extra;E<F;){if(0===v)break e;v--,S+=p[m++]<<E,E+=8}s.offset+=S&(1<<s.extra)-1,S>>>=s.extra,E-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===I)break e;if(O=y-I,s.offset>O){if((O=s.offset-O)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}O>s.wnext?(O-=s.wnext,T=s.wsize-O):T=s.wnext-O,O>s.length&&(O=s.length),D=s.window}else D=g,T=f-s.offset,O=s.length;for(I<O&&(O=I),I-=O,s.length-=O;g[f++]=D[T++],--O;);0===s.length&&(s.mode=21);break;case 26:if(0===I)break e;g[f++]=s.length,I--,s.mode=21;break;ca