UNPKG

@tencentcloud/lite-chat

Version:

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

1 lines 227 kB
const e=e=>void 0===e,t=e=>"string"==typeof e,s=e=>{var t;return null===(t=Object.prototype.toString.call(e).match(/^\[object (.*)\]$/))||void 0===t?void 0:t[1].toLowerCase()},n=e=>"function"==typeof Array.isArray?Array.isArray(e):"array"===s(e),i=e=>null!==e&&"object"==typeof e,o=e=>n(e)||i(e),r=e=>{if("string"!=typeof e)return!1;const t=e[0];return!/[^a-zA-Z0-9]/.test(t)},a=e=>{if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s};function c(e=99999999){return Math.round(Math.random()*e)}const l=(t,s,n,i)=>{if(!o(t)||!o(s))return 0;let r=0;const a=Object.keys(s);let c;for(let u=0,d=a.length;u<d;u++)if(c=a[u],!(e(s[c])||n&&n.includes(c)))if(o(t[c])&&o(s[c]))r+=l(t[c],s[c],n,i);else{if(i&&i.includes(s[c]))continue;t[c]!==s[c]&&(t[c]=s[c],r+=1)}return r};function u(e){let t,s,n=e;e.length%8!=0&&(n="0".repeat(8-e.length%8)+e);let i="";for(let e=0,{length:o}=n;e<o;e+=8)t=parseInt(n.slice(e,e+4),2),s=parseInt(n.slice(e+4,e+8),2),i+=base16Map.get(t)+base16Map.get(s);return i}const d={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},_=["heartbeat.alive","im_open_status.wslogin","im_open_status.wslogout","group_open_long_polling_http_svc.get_msg","group_open_long_polling_http_noauth_svc.get_msg"];var h;!function(e){e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e[e.NONE=4]="NONE"}(h||(h={}));const g="LiteChat",p={[h.DEBUG]:console.debug,[h.INFO]:console.info,[h.WARN]:console.warn,[h.ERROR]:console.error},E={[h.INFO]:4,[h.WARN]:5,[h.ERROR]:6},f=1e3,m=2,S=5e3,v=50;var I;!function(e){e[e.CONV_DELETED=1]="CONV_DELETED",e[e.CONV_PINED=2]="CONV_PINED",e[e.CONV_UNPINED=3]="CONV_UNPINED",e[e.CONV_MARK_UPDATED=4]="CONV_MARK_UPDATED",e[e.CONV_GROUP_ADDED=5]="CONV_GROUP_ADDED",e[e.CONV_GROUP_DELETED=6]="CONV_GROUP_DELETED",e[e.CONV_GROUP_UPDATED=7]="CONV_GROUP_UPDATED"}(I||(I={}));var C=Object.freeze({__proto__:null,CONSOLE_METHOD:p,CloudConfigReportLevelMap:E,get ConvModifyPushType(){return I},DEFAULT_GLOBAL_MAX_TOTAL_COUNT:v,DEFAULT_GLOBAL_THROTTLE_TIME:S,DEFAULT_SINGLE_MAX_TOTAL_COUNT:m,DEFAULT_SINGLE_THROTTLE_TIME:f,ENUM_PLATFORM:d,IS_TOPIC_MESSAGE:2,get LogLevel(){return h},NOT_NEED_CRC_SERVCMD:_,SDK_NAME:g});const M="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform)&&"undefined"===wx.getSystemInfoSync().uniPlatform,T="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||M,y=T&&"function"==typeof wx.createGamePortal,O="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),A="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),N=A&&"function"==typeof tt.onShow,R="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),D="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),P="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,b="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=T&&"object"==typeof wx.miniapp,L="undefined"!=typeof uni,k=T||O||A||R||D||b||P,U="undefined"==typeof window&&!k&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,G="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),F="undefined"!=typeof wx&&"function"==typeof wx.getAccountInfoSync&&Boolean(wx.getAccountInfoSync().plugin),B="undefined"!=typeof uni?!k:"undefined"!=typeof window&&!k&&!G,x=O?qq:A?tt:R?swan:D?my:T?wx:b?uni:P?jd:{},V=B&&window&&window.navigator&&window.navigator.userAgent||"",$=/(micromessenger|webbrowser)/i.test(V),q=function(){let e="WEB";return $?e="WEB":O?e="QQ_MP":A?e="TT_MP":R?e="BAIDU_MP":D?e="ALI_MP":T?e=w?"DONUT_NATIVE_APP":"WX_MP":b?e="UNI_NATIVE_APP":U?e="NS_NATIVE_APP":G&&(e="RN_NATIVE_APP"),d[e]}(),W=/iPad/i.test(V),Y=/iPhone/i.test(V)&&!W,K=/iPod/i.test(V),H=Y||W||K,j=function(){const e=V.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),z=/Android/i.test(V),Z=function(){const e=V.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}(),X=/Firefox/i.test(V),J=/Edge/i.test(V),Q=!J&&/Chrome/i.test(V),ee=/MSIE/.test(V)||V.indexOf("Trident")>-1&&V.indexOf("rv:11.0")>-1,te=function(){const e=/MSIE\s(\d+)\.\d/.exec(V);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test(V)&&/rv:11.0/.test(V)&&(t=11),t}(),se=/Safari/i.test(V)&&!Q&&!z&&!J,ne=/Windows/i.test(V),ie=/MAC OS X/i.test(V),oe=B&&"undefined"!=typeof Worker&&!ee,re=z||H,ae=B&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ce=function(){if("undefined"==typeof window||void 0===window.navigator)return!1;const{standalone:e}=window.navigator;return!(!H||e||se)}();function le(){let e="unknown";if(ie&&(e="mac"),ne&&(e="windows"),H&&(e="ios"),z&&(e="android"),k)try{const{platform:t}=x.getSystemInfoSync();void 0!==t&&(e=t)}catch(e){console.error(e)}return e}function ue(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(s[n[i]]=e[n[i]])}return s}function de(e,t,s,n){return new(s||(s=Promise))(function(i,o){function r(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(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 _e=2800,he=2801,ge=3e3,pe="application/x-www-form-urlencoded;charset=UTF-8";function Ee(e){return de(this,arguments,void 0,function*({method:e,url:t,data:s,timeout:n=ge}){return new Promise(k?(i,o)=>{x.request({url:t,data:s,method:e,timeout:n,header:{"content-type":pe},success:e=>i(e.data),fail:()=>o(new Error(`{"message":"Network error","code":${_e}}`))})}:(i,o)=>{const r=new XMLHttpRequest,a=setTimeout(()=>{r.abort(),o(new Error(`{"message":"Request timeout","code":${he}}`))},n);r.onreadystatechange=function(){if(4===r.readyState)if(clearTimeout(a),200===r.status||304===r.status)try{i(r.responseText?JSON.parse(r.responseText):null)}catch(e){i(r.responseText)}else o(new Error(`{"message":"Network error","code":${_e}}`))},r.open(e,t,!0),r.setRequestHeader("Content-type",pe),r.send(s||null)})})}function fe(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(a(e)){for(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 me(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(me(s),me(e))}),t}if(e instanceof Set){const t=new Set;return e.forEach(e=>{t.add(me(e))}),t}if(Array.isArray(e))return e.map(e=>me(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]=me(e[t]))}),s}function Se(e,t,s){const n=new WeakSet,i=(e,s)=>{if(t&&(s=t(e,s)),void 0===s)return"undefined";if(null===s)return null;if(Number.isNaN(s))return"NaN";if(s===1/0)return"Infinity";if(s===-1/0)return"-Infinity";if("function"==typeof s)return`[Function: ${s.name||"anonymous"}]`;if("symbol"==typeof s)return s.toString();if("bigint"==typeof s)return`${s.toString()}n`;if("object"==typeof s&&null!==s){if(n.has(s))return"[Circular]";n.add(s)}return s instanceof Date?s.toISOString():s instanceof Error?{name:s.name,message:s.message,stack:s.stack}:s instanceof Map?{dataType:"Map",value:Array.from(s.entries())}:s instanceof Set?{dataType:"Set",value:Array.from(s.values())}:s};try{return JSON.stringify(e,i,s)}catch(e){return console.error("Failed to stringify:",e),""}}function ve(){let e,t;return{promise:new Promise((s,n)=>{e=s,t=n}),resolve:e,reject:t}}var Ie,Ce=Object.freeze({__proto__:null,ANDROID_VERSION:Z,IE_VERSION:te,IN_ALIPAY_MINI_APP:D,IN_BAIDU_MINI_APP:R,IN_BROWSER:B,IN_DONUT_NATIVE_APP:w,IN_JD_MINI_APP:P,IN_MINI_APP:k,IN_NS_NATIVE_APP:U,IN_QQ_MINI_APP:O,IN_RN_APP:G,IN_TT_MINI_APP:A,IN_TT_MINI_GAME:N,IN_UNI_APP:L,IN_UNI_NATIVE_APP:b,IN_WX_MINI_APP:T,IN_WX_MINI_APP_DESK:M,IN_WX_MINI_GAME:y,IN_WX_MINI_PLUGIN:F,IOS_VERSION:j,IS_ANDROID:z,IS_CHROME:Q,IS_EDGE:J,IS_FIREFOX:X,IS_IE:ee,IS_IOS:H,IS_IPAD:W,IS_IPHONE:Y,IS_IPOD:K,IS_MAC:ie,IS_SAFARI:se,IS_WECHAT:$,IS_WIN:ne,IS_WORKER_AVAILABLE:oe,MINI_APP_NAMESPACE:x,USER_AGENT:V,base16EncodeBinaryString:u,deepCopyWithMethods:me,deepMerge:l,generatePromise:ve,getPlatformType:le,getType:s,httpRequest:Ee,isArray:n,isArrayOrObject:o,isEmpty:fe,isFlutterWeb:ae,isH5:re,isIOSWebView:ce,isNumber:e=>null!==e&&("number"==typeof e&&!Number.isNaN(e-0)||"object"==typeof e&&e.constructor===Number),isObject:i,isPlainObject:a,isString:t,isUndefined:e,isUniIOSApp:function(){return b&&"ios"===uni.getDeviceInfo().platform.toLocaleLowerCase()},isValidRequestKey:r,platform:q,randomInt:c,randomString:function(){const e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";let t="";for(let s=32;s>0;--s)t+=e[Math.floor(62*Math.random())];return t},safeStringify:Se});class Me{constructor(){this.listeners={}}on(e,t,s){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push({fn:t,context:s})}off(e,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,i=!s||e.context===s;return!(n&&i)}))}emit(e,...t){const s=this.listeners[e];s&&s.forEach(s=>{const{fn:n,context:i}=s;try{n.apply(i,t)}catch(t){console.warn(`Error in event handler for ${e} error: ${Se(t)}`)}})}once(e,t,s){const n=(...i)=>{t.apply(s,i),this.off(e,n)};this.on(e,n)}}!function(e){e.BUSINESS_COMMAND="business_command",e.C2C_REALTIME_MESSAGE="c2c_realtime_message",e.C2C_MESSAGE_MODIFIED="c2c_message_modified",e.C2C_REVOKED_MESSAGE="c2c_message_revoked",e.GROUP_REALTIME_MESSAGE="group_realtime_message",e.GROUP_MESSAGE_MODIFIED="group_message_modified",e.GROUP_MESSAGE_REVOKED="group_message_revoked",e.C2C_MESSAGE_READ_RECEIPT="c2c_message_read_receipt",e.MESSAGE_REACTION_UPDATED="message_reaction_updated",e.MESSAGE_REACTION_UPDATED_SYNC="message_reaction_updated_sync",e.GROUP_AT_TIPS="group_at_tips",e.USER_STATUS_UPDATE="user_status_update",e.FRIEND_LIST_MODIFIED="friend_list_modified",e.PROFILE_MODIFIED="profile_modified",e.CONV_MODIFIED="conversation_modified",e.GROUP_TIPS_NOTIFICATION="group_tips_notification",e.GROUP_MESSAGE_READ_RECEIPT="group_message_read_receipt",e.GROUP_MESSAGE_READ_SYNC="group_message_read_sync",e.GROUP_SYSTEM_NOTIFICATION="group_system_notification",e.C2C_MESSAGE_PEER_READ="c2c_message_peer_read",e.C2C_MESSAGE_READ_SYNC="c2c_message_read_sync",e.C2C_REMIND_TYPE_SYNC="c2c_remind_type_sync",e.FOLLOW_LIST_UPDATED="follow_list_updated",e.MESSAGE_EXTENSIONS_UPDATED="message_extensions_updated",e.ALL_MESSAGE_READ="all_message_read",e.CONVERSATION_MARK_UPDATED="conversation_mark_updated",e.CONVERSATION_GROUP_ADD="conversation_group_add",e.CONVERSATION_GROUP_DELETED="conversation_group_deleted",e.CONVERSATION_GROUP_UPDATED="conversation_group_updated",e.ALL_RECEIVE_MESSAGE_OPTION="all_receive_message_option",e.TOPIC_AT_TIPS="topic_at_tips",e.TOPIC_TIPS_NOTIFICATION="topic_tips_notification",e.TOPIC_SYSTEM_NOTIFICATION="topic_system_notification",e.TOPIC_MESSAGE_READ_SYNC="topic_message_read_sync",e.TOPIC_LATEST_MESSAGE="topic_latest_message",e.GROUP_MESSAGE_PINNED="group_message_pinned"}(Ie||(Ie={}));const Te=[16,17];function ye(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{var t;2===e.GroupInfo.MillionGroupFlag?s.push(Ie.TOPIC_TIPS_NOTIFICATION):Te.includes(null===(t=null==e?void 0:e.MsgBody)||void 0===t?void 0:t.OpType)?s.push(Ie.GROUP_MESSAGE_PINNED):s.push(Ie.GROUP_TIPS_NOTIFICATION)}),s}const Oe=[{conditions:[{type:"event",value:100}],subType:Ie.BUSINESS_COMMAND},{conditions:[{type:"event",value:24}],subType:Ie.ALL_RECEIVE_MESSAGE_OPTION},{conditions:[{type:"event",value:26}],subType:Ie.TOPIC_LATEST_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgArray"}],subType:Ie.C2C_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"C2cMsgModNotifys"}],subType:Ie.C2C_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"ProfileDataMod"}],subType:Ie.PROFILE_MODIFIED},{conditions:[{type:"hasKey",value:"UserStatusList"}],subType:Ie.USER_STATUS_UPDATE},{conditions:[{type:"hasKey",value:"FriendListMod"}],subType:Ie.FRIEND_LIST_MODIFIED},{conditions:[{type:"hasKey",value:"GroupMsgArray"}],subType:Ie.GROUP_REALTIME_MESSAGE},{conditions:[{type:"hasKey",value:"GroupMsgModNotifys"}],subType:Ie.GROUP_MESSAGE_MODIFIED},{conditions:[{type:"hasKey",value:"C2cNotifyMsgArray"}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.C2cNotifyMsgArray)||void 0===t||t.forEach(e=>{e.WithdrawC2cMsgNotify&&s.push(Ie.C2C_REVOKED_MESSAGE),e.C2cReadedReceipt&&s.push(Ie.C2C_MESSAGE_PEER_READ),e.ReadC2cMsgNotify&&s.push(Ie.C2C_MESSAGE_READ_SYNC),e.MuteNotificationsSync&&s.push(Ie.C2C_REMIND_TYPE_SYNC)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:4}],subTypeParser:ye},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:5}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{Array.isArray(e.MsgBody.GroupWithdrawInfoArray)?s.push(Ie.GROUP_MESSAGE_REVOKED):Array.isArray(e.MsgBody.GroupMsgReceiptList)?s.push(Ie.GROUP_MESSAGE_READ_RECEIPT):Array.isArray(e.MsgBody.GroupReadInfoArray)?e.MsgBody.GroupReadInfoArray[0].TopicId?s.push(Ie.TOPIC_MESSAGE_READ_SYNC):s.push(Ie.GROUP_MESSAGE_READ_SYNC):2===e.GroupInfo.MillionGroupFlag?s.push(Ie.TOPIC_SYSTEM_NOTIFICATION):s.push(Ie.GROUP_SYSTEM_NOTIFICATION)}),s}},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:6}],subTypeParser:ye},{conditions:[{type:"hasKey",value:"GroupTips"},{type:"event",value:12}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.GroupTips)||void 0===t||t.forEach(e=>{const{GroupAtTips:{TopicId:t}}=e;t?s.push(Ie.TOPIC_AT_TIPS):s.push(Ie.GROUP_AT_TIPS)}),s}},{conditions:[{type:"hasKey",value:"RecentContactMod"}],subTypeParser:function(e){var t;const s=[];return null===(t=null==e?void 0:e.RecentContactMod)||void 0===t||t.forEach(e=>{switch(e.PushType){case I.CONV_MARK_UPDATED:s.push(Ie.CONVERSATION_MARK_UPDATED);break;case I.CONV_GROUP_ADDED:s.push(Ie.CONVERSATION_GROUP_ADD);break;case I.CONV_GROUP_DELETED:s.push(Ie.CONVERSATION_GROUP_DELETED);break;case I.CONV_GROUP_UPDATED:s.push(Ie.CONVERSATION_GROUP_UPDATED);break;default:s.push(Ie.CONV_MODIFIED)}}),s}},{conditions:[{type:"hasKey",value:"MsgReactionNotifyList"}],subType:Ie.MESSAGE_REACTION_UPDATED},{conditions:[{type:"hasKey",value:"MsgReactionNotify"}],subType:Ie.MESSAGE_REACTION_UPDATED_SYNC},{conditions:[{type:"hasKey",value:"C2cMsgInfo"}],subType:Ie.C2C_MESSAGE_READ_RECEIPT},{conditions:[{type:"hasKey",value:"FollowChangeList"}],subType:Ie.FOLLOW_LIST_UPDATED},{conditions:[{type:"hasKey",value:"MsgExtensionNotify"}],subType:Ie.MESSAGE_EXTENSIONS_UPDATED},{conditions:[{type:"hasKey",value:"C2CReadAllMsg"}],subType:Ie.ALL_MESSAGE_READ}];var Ae;function Ne(e){var t;const s=Array.isArray(null===(t=null==e?void 0:e.body)||void 0===t?void 0:t.EventArray)?e.body.EventArray:[],n=[];return s.forEach(t=>{t.Flag=e.body.Flag;const s=Oe.find(e=>e.conditions.every(e=>{switch(e.type){case"event":return t.Event===e.value;case"hasKey":return Object.prototype.hasOwnProperty.call(t,e.value);default:return!1}}));if(!s)return null;let i=[];"function"==typeof s.subTypeParser?i=s.subTypeParser(t):s.subType&&(i=s.subType),Array.isArray(i)?i.forEach(e=>{n.push({type:`${Ae.SERVER_PUSH_MESSAGE}:${e}`,data:t})}):n.push({type:`${Ae.SERVER_PUSH_MESSAGE}:${i}`,data:t})}),n}!function(e){e.SERVER_PUSH_MESSAGE="im_open_push.msg_push",e.SERVER_PUSH_MESSAGE_MULTIPLE="im_open_push.multi_msg_push_ws",e.ERROR="error"}(Ae||(Ae={}));const Re={[Ae.SERVER_PUSH_MESSAGE]:Ne,[Ae.SERVER_PUSH_MESSAGE_MULTIPLE]:Ne,[Ae.ERROR]:function(e){const{errorCode:t}=e;return[{type:`error:${t}`,data:e}]}};const De=new class{constructor(){this._outerEventEmitter=null,this._innerEventEmitter=null,this._filteredCallbackMap=new Map,this._outerEventEmitter=new Me,this._innerEventEmitter=new Me,this.InnerEventSubType=Ie}subscribeInnerEvent(e,t,s,n,i){var o;let r,a,c,l;["string","number"].includes(typeof t)?(c=`${e}:${t}`,l=s,a=n,r=i):(c=e,l=t,a=s,r="function"==typeof n?n:void 0),r?this._subscribeWithFilter(c,l,a,r):null===(o=this._innerEventEmitter)||void 0===o||o.on(c,l,a)}emitInnerEvent(e,t){var s,n;if(null===(s=this._innerEventEmitter)||void 0===s||s.emit(e,t),Object.keys(Re).includes(e)){const s=null===(n=Re[e])||void 0===n?void 0:n.call(Re,t);null==s||s.forEach(e=>{var t;e&&(null===(t=this._innerEventEmitter)||void 0===t||t.emit(e.type,e.data))})}}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)}unSubscribeInnerEvent(e,t,s,n){if(["string","number"].includes(typeof t)){const i=s,o=`${e}:${t}`;this._unsubscribeEvent(o,i,n)}else{const n=t;this._unsubscribeEvent(e,n,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}_subscribeWithFilter(e,t,s,n){var i;const o=e=>{n.call(s,e)&&t.call(s,e)};this._filteredCallbackMap.has(e)||this._filteredCallbackMap.set(e,[]),this._filteredCallbackMap.get(e).push({originalCallback:t,filteredCallback:o,filter:n,context:s}),null===(i=this._innerEventEmitter)||void 0===i||i.on(e,o,s)}_unsubscribeEvent(e,t,s){var n,i;const o=this._filteredCallbackMap.get(e);if(o){const i=o.findIndex(e=>e.originalCallback===t&&e.context===s);if(-1!==i){const{filteredCallback:t}=o[i];return null===(n=this._innerEventEmitter)||void 0===n||n.off(e,t,s),o.splice(i,1),void(0===o.length&&this._filteredCallbackMap.delete(e))}}null===(i=this._innerEventEmitter)||void 0===i||i.off(e,t,s)}};class Pe{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:i,onSendFail:o}=e;this._socket&&(this._socket.binaryType="arraybuffer",this._socket.onopen=t,this._socket.onmessage=s,this._socket.onclose=n,this._socket.onerror=i,this._onSendFail=o)}unbindSocketHandlers(){this._socket&&(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null)}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}class be{connectSocket(e){return this._socket=x.connectSocket({url:e,header:{"content-type":"application/json"},complete:()=>{}}),this._socket}send(e){var t;null===(t=this._socket)||void 0===t||t.send({data:e,fail:this._onSendFail})}bindSocketHandlers(e){const{onOpen:t,onMessage:s,onClose:n,onError:i,onSendFail:o}=e;this._socket.onClose(n),this._socket.onOpen(t),this._socket.onMessage(s),this._socket.onError(i),this._onSendFail=o}unbindSocketHandlers(){this._socket&&(this._socket.onClose(()=>{}),this._socket.onOpen(()=>{}),this._socket.onMessage(()=>{}),this._socket.onError(()=>{}))}disconnect(){this._socket&&(this._socket.close(),this._socket=null)}}const we="CONNECT",Le="SEND",ke="DISCONNECT",Ue="OPEN",Ge="MESSAGE",Fe="CLOSE",Be="ERROR",xe="SEND_FAIL";class Ve{constructor(){this._worker=null,this._blobUrl=null}connectSocket(e){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:we,url:e})}send(e){var t,s;try{null===(t=this._worker)||void 0===t||t.postMessage({type:Le,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:i,onSendFail:o}=e;if(this._worker){const e={[Ue]:t,[Ge]:s,[Fe]:n,[Be]:i,[xe]:o};this._onSendFail=o,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:ke}),this._worker.terminate(),this._worker=null),this._blobUrl&&(URL.revokeObjectURL(this._blobUrl),this._blobUrl=null)}}var $e,qe=new class{constructor(){this._store=new Map}get(e){return this._store.get(e)}getStorage(e){if(k){if(D){return my.getStorageSync({key:e}).data}return x.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){k?D?my.setStorageSync({key:e,data:JSON.stringify(t)}):x.setStorageSync(e,JSON.stringify(t)):this._canUseLocalStorage()&&localStorage.setItem(e,JSON.stringify(t))}clear(e){"string"==typeof e?this._store.set(e,{}):this._store.clear()}clearLocalStorage(e){this._canUseLocalStorage()&&("string"==typeof e?localStorage.setItem(e,""):localStorage.clear())}reset(){this.clear()}_canUseLocalStorage(){return"undefined"!=typeof window&&(navigator&&navigator.cookieEnabled&&localStorage)}};!function(e){e[e.CONNECTED=0]="CONNECTED",e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED"}($e||($e={}));class We{constructor(e){this._url="",this._readyState=$e.DISCONNECTED,this._url=e,this._id=c(),this._emitter=new Me,T||b||N?this._socket=new be:this._canUseWebWorker()?this._socket=new Ve:this._socket=new Pe,this.connect()}connect(){this.doOpen(),this._bindSocketHandlers()}doOpen(){[$e.CONNECTED,$e.CONNECTING].includes(this._readyState)||(this._readyState=$e.CONNECTING,this._ws=this._socket.connectSocket(this._url))}send(e){this._readyState!==$e.CONNECTED?this.reconnect():this._socket.send(e)}reconnect(){[$e.CONNECTED,$e.CONNECTING].includes(this._readyState)||(this.disconnect(),this.doOpen())}getId(){return this._id}on(e,t,s){this._emitter.on(e,t,s)}off(e,t,s){this._emitter.off(e,t,s)}isConnected(){return this._readyState===$e.CONNECTED}disconnect(){this._readyState=$e.DISCONNECTED,this._unbindSocketHandlers(),this._socket.disconnect()}_onOpen(e){this._readyState===$e.CONNECTING&&(this._readyState=$e.CONNECTED,this._emitter.emit("connect",{socketId:this._id,event:e}))}_onMessage(e){this._emitter.emit("message",e)}_onClose(e){this._readyState=$e.DISCONNECTED,this._emitter.emit("close",{socketId:this._id,event:e})}_onError(e){this._readyState=$e.DISCONNECTED,this._emitter.emit("error",{socketId:this._id,error:e})}_onSendFail(e){this._readyState=$e.DISCONNECTED,this._emitter.emit("sendFail",{socketId:this._id,error:e})}_bindSocketHandlers(){this._socket.bindSocketHandlers({onOpen:this._onOpen.bind(this),onMessage:this._onMessage.bind(this),onClose:this._onClose.bind(this),onError:this._onError.bind(this),onSendFail:this._onSendFail.bind(this)})}_unbindSocketHandlers(){this._socket.unbindSocketHandlers()}_canUseWebWorker(){const t=qe.get("cloudConfig")||{};return(e(t.isWorkerEnabled)||"1"===t.isWorkerEnabled)&&oe}}const Ye="CHINA",Ke="OVERSEA",He="SINGAPORE",je="KOREA",ze="GERMANY",Ze="IND",Xe="JPN",Je="USA",Qe="INDONESIA",et={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{INITIAL:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4c.my-cpaas.com",BACKUP_CN:"wss://wss.im.tencent.cn",STAT:"https://api.my-imcloud.com"},SINGAPORE:{INITIAL:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{INITIAL:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{INITIAL:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{INITIAL:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB_ONLY:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{INITIAL:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com",ANYCAST:"wss://162.14.13.254"},USA:{INITIAL:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{INITIAL:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB_ONLY:"wss://*w4y.my-cpaas.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},st={[He]:[[2e7,3e7],[172e7,173e7]],[je]:[[3e7,4e7],[173e7,174e7]],[ze]:[[4e7,5e7],[174e7,175e7]],[Ze]:[[5e7,6e7],[175e7,176e7]],[Xe]:[[6e7,7e7],[176e7,177e7]],[Je]:[[7e7,8e7],[177e7,178e7]],[Qe]:[[8e7,9e7],[178e7,179e7]]};function nt(e){var t;if(null===(t=qe.get("instance"))||void 0===t?void 0:t.oversea)return Ke;for(const t of Object.keys(st))for(const[s,n]of st[t])if(e>=s&&e<n)return t;return Ye}var it,ot="4.2.0";!function(e){e.INITIAL="INITIAL",e.DEFAULT="DEFAULT",e.BACKUP="BACKUP",e.BACKUP_WEB_ONLY="BACKUP_WEB_ONLY",e.BACKUP_CN="BACKUP_CN",e.ANYCAST="ANYCAST",e.IPV6="IPV6"}(it||(it={}));let rt=it.INITIAL;function at(){const e=Math.random();return 0===e?at():e}function ct(e,t){const{isBinary:s=!1}=t||{},n=qe.get("instance"),{sdkAppId:i,instanceId:o}=n,r=at(),a=le(),c=function(){const e=le();let t=-1;"ios"===e?t=j||-1:"android"===e&&(t=Z||-1);return t}(),l=(u={sdkappid:i,instanceid:o,random:r,platform:q,host:a,version:c,sdkversion:ot},Object.keys(u).map(e=>`${e}=${u[e]}`).join("&"));var u;return s?`${e}/binfo?${l}&compress=gzip`:`${e}/info?${l}`}function lt(e){const t=qe.get("instance"),{sdkAppId:s,testEnv:n}=t,i=nt(s);if(n){return ct(et.TEST[i].DEFAULT,{isBinary:e})}const o=et.PRODUCTION[i],r=B&&o.ANYCAST,a=B,c=!!o.BACKUP_CN;return ct({[it.INITIAL]:()=>(rt=it.DEFAULT,o.DEFAULT),[it.DEFAULT]:()=>(rt=it.IPV6,o.IPV6),[it.IPV6]:()=>(rt=it.BACKUP,o.BACKUP),[it.BACKUP]:()=>a?(rt=it.BACKUP_WEB_ONLY,function(e){const t=Math.floor(10001*Math.random())+1e4;return e.replace("*",String(t))}(o.BACKUP_WEB_ONLY)):c?(rt=it.BACKUP_CN,o.BACKUP_CN):r?(rt=it.ANYCAST,o.ANYCAST):o.DEFAULT,[it.BACKUP_WEB_ONLY]:()=>c?(rt=it.BACKUP_CN,o.BACKUP_CN):r?(rt=it.ANYCAST,o.ANYCAST):o.DEFAULT,[it.BACKUP_CN]:()=>(rt=r?it.ANYCAST:it.DEFAULT,o[rt]),[it.ANYCAST]:()=>(rt=it.DEFAULT,o.ANYCAST="",o.DEFAULT)}[rt](),{isBinary:e})}var ut=new class{constructor(){this._timeOffsetWithServer=0}getServerTimeMs(){return Date.now()+this._timeOffsetWithServer}getServerTimeSeconds(){return Math.floor(this.getServerTimeMs()/1e3)}getTimeOffsetWithServer(){return this._timeOffsetWithServer}calculateTimeOffsetWithServer(e,t){const s=Date.now(),n=s-e;this._timeOffsetWithServer=t+n-s}};const dt=16;var _t=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:i=!1,intervalMs:o=dt}=e,r=Math.max(o,dt);return{id:t,nextExecuteTime:Date.now()+r,intervalMs:o,callback:s,context:n,isOnce:i}}addTask(e){const t=this._createTask(e);this._addTaskToScheduler(t)}addOnceTask(e){const t=this._createTask(Object.assign(Object.assign({},e),{isOnce:!0}));this._addTaskToScheduler(t)}removeTask(e){const t=this._tasks.findIndex(t=>t.id===e);t>-1&&(this._tasks.splice(t,1),this._taskMap.delete(e),this._scheduleNextTask())}updateTaskInterval(e,t){const 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 ht(e){const t=[];for(let s=0;s<e.length;s+=1){const n=e.charCodeAt(s);if(n>=55296&&n<=56319){const i=e.charCodeAt(++s)-56320+(n-55296<<10)+65536;t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i)}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 gt(e){const t=Array.isArray(e)?[]:Object.create(null);for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&r(s)&&null!=e[s]&&(null===e[s]||"object"!=typeof e[s]?t[s]=e[s]:t[s]=gt(e[s]));return t}function pt(e,t){if(_.includes(e))return 0;const s=ht(JSON.stringify(t));let n=4294967295;const{length:i}=s;for(let e=0;e<i;e++){n^=s[e];for(let e=0;e<8;e++)1&~n?n>>>=1:n=n>>>1^3988292384}return(4294967295^n)>>>0}function Et(e){const{servcmd:t,data:s}=e,n=function(e){const t=qe.get("login")||{},s=qe.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:u(""),cappid:s.applicationID||0,tjgID:"",seq:St(),cs:0}}(t),i=gt(s);return n.cs=pt(t,i),{head:n,body:i}}function ft(e){const{servcmd:t,data:s}=e,n=function(e){const t=qe.get("login")||{},s=qe.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:u(""),cappid:s.applicationID||0,seq:St(),cs:0}}(t),i=gt(s);return n.cs=pt(t,i),{head:n,body:i}}let mt=c();function St(){return mt=mt<2415919103?mt+1:c(),mt}function vt(){var e;const t=qe.get("login")||{},s=qe.get("instance")||{};return{sdk_type:30,sdk_app_id:s.sdkAppId,sdk_version:"4.2.0",tiny_id:Number(t.tinyID),user_id:t.userId||(null===(e=qe.get("webPush"))||void 0===e?void 0:e.userId),platform:q,instance_id:s.instanceId,trace_id:(new Date).getTime()}}var It,Ct=Object.freeze({__proto__:null,calcBodyCRC:pt,filterProtocolDataInvalidFields:gt,generateCosSpecifiedData:function(e){const{servcmd:t,data:s}=e,n=function(e){const t=qe.get("login")||{},s=qe.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:u(""),cappid:s.applicationID||0,seq:St(),cs:0}}(t),i=gt(s);return n.cs=pt(t,i),{head:n,body:i}},generateProtocolData:Et,generateSSOLogProtocolData:ft,generateSequence:St,getCommonHead:vt,taskScheduler:_t,timeManager:ut});!function(e){e[e.info=4]="info",e[e.warning=5]="warning",e[e.error=6]="error"}(It||(It={}));const Mt={method:"extension",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",uiPlatform:"ui_platform",timestamp:"timestamp"};class Tt{constructor(e){this.level=It.info,this._canSendLog=!0,this._logCreatedAt=ut.getServerTimeMs(),this.timestamp=0,this.networkType=8,this.code=0,this.moreMessage="",this.method="",this.message="",this.costTime=0,this.duplicate=!1,this.eventType=0,this.uiPlatform=this._getUiPlatform(),this._sdkEdition=this._getSDKEdition();const{method:t,eventType:s=0,message:n="",costTime:i=0,error:o,moreMessage:r="",code:a=0}=e||{};this.eventType=s,this.method=t,this.message=n,this.costTime=i,this.moreMessage=r,this.code=a,o&&this.setError(o)}setMoreMessage(e){this.moreMessage=`${this.moreMessage} ${e}`}updateLogCreatedAtByTimeOffset(){this._logCreatedAt+=ut.getTimeOffsetWithServer()}end(e=!1){this._canSendLog&&(this._canSendLog=!1,this.timestamp=ut.getServerTimeMs(),this._ssoLogModule.pushToLogQueue(this._convertSSOLogDataKeyToServe()),e&&this._ssoLogModule.uploadSSOLogData())}setError(e){var t;if(!(e instanceof Error))return console.warn("SSOLogData.setError value not instanceof Error, please check!"),this;if(!this._canSendLog)return this;return(null===(t=qe.get("netWorkMonitor"))||void 0===t?void 0:t.isNetworkOnline)&&(e.errorCode&&(this.code=e.errorCode),e.errorMessage&&this.setMoreMessage(e.errorMessage)),this.level=It.error,this}setLogInfo(e){return Object.keys(e).forEach(t=>{Object.keys(Mt).includes(t)&&(this[t]=e[t])}),this}setSSOLogModule(e){this._ssoLogModule=e}_convertSSOLogDataKeyToServe(){const e={};return Object.keys(this).forEach(t=>{const s=t;Mt[s]&&(e[Mt[s]]=this[s])}),e}_getUiPlatform(){var e;const t=null===(e=qe.get("instance"))||void 0===e?void 0:e.scene;if("string"==typeof t){const e=Number(t);return isNaN(e)?void 0:e}}_getSDKEdition(){var e;return null===(e=qe.get("instance"))||void 0===e?void 0:e.sdkEdition}}var yt;!function(e){e.RECONNECTED="reconnected",e.CLOUD_CONFIG_UPDATE="cloud_config_update",e.SOCKET_DISCONNECTED="socket_disconnected"}(yt||(yt={}));var Ot=yt;const At=20,Nt=6e4,Rt=[4,5,6],Dt=[],Pt=[],bt="report-logger";var wt=new class{constructor(){this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._reportLevel=[4,5,6],this._minThreshold=At,this._maxThreshold=100,this._waitingTime=Nt,this._lastReportAt=Date.now(),this._ssoLogMap=new Map,this._logLevel=h.DEBUG,this._throttleConfig={global:{throttleTime:S,maxCount:v},single:{throttleTime:f,maxCount:m}},this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap=new Map,De.subscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),_t.addTask({id:bt,intervalMs:1e3,callback:this._checkAndReportIfDue,context:this}),this._logQueue=[],this._savePlatFormInfo()}_handleCloudConfigUpdate(e){const{evt_rpt_threshold:t=At,evt_rpt_waiting:s=Nt,evt_rpt_level:n=Rt,evt_rpt_sdkappid_bl:i=Dt,evt_rpt_tinyid_wl:o=Pt,evt_rpt_global_throttle_time:r=S,evt_rpt_global_throttle_count:a=v,evt_rpt_single_throttle_time:c=f,evt_rpt_single_throttle_count:l=m}=e||{};this._sdkAppIdBlackList=i,this._waitingTime=s,this._minThreshold=t,this._reportLevel=n,this._tinyIdWhiteList=o,this._throttleConfig={global:{throttleTime:r,maxCount:a},single:{throttleTime:c,maxCount:l}}}createSSOLogData(e){const t=new Tt(e);return t.setSSOLogModule(this),this._ssoLogMap.set(e.method,t),t}getSSOLogData(e){return this._ssoLogMap.get(e)||{}}pushToLogQueue(e){e&&(this._logQueue.push(e),this._shouldUploadImmediately()&&this.uploadSSOLogData())}setLogLevel(e){[h.DEBUG,h.ERROR,h.INFO,h.NONE,h.WARN].includes(e)&&(this._logLevel=e)}debug(e,t="",s){this._log(h.DEBUG,e,t,s)}info(e,t="",s){this._log(h.INFO,e,t,s)}warn(e,t="",s){this._log(h.WARN,e,t,s)}error(e,t="",s){this._log(h.ERROR,e,t,s)}_shouldUploadImmediately(){return this._logQueue.length>=this._minThreshold}_isReportDue(){return Date.now()>=this._lastReportAt+this._waitingTime}_checkAndReportIfDue(){this._isReportDue()&&this._logQueue.length>0&&this.uploadSSOLogData()}uploadSSOLogData(){return de(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:vt(),Event:t};fe(s.Header.user_id)||(yield function(e){const t="imopenstat.tim_web_report_v2",s=ft({servcmd:t,data:e}),n=`${s.head.seq}${t}`;Qt.sendPacket(s,{requestId:n})}(s)),this._lastReportAt=Date.now()})}_savePlatFormInfo(){var e,t;if(T){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;qe.set("instance",{appId:e,envVersion:t})}}else B&&qe.set("instance",{href:window.location.href})}_filterLogs(e){const{tinyID:t}=qe.get("login")||{},{sdkAppId:s}=qe.get("instance")||{};return this._sdkAppIdBlackList.includes(s)&&!this._tinyIdWhiteList.includes(t)?[]:e.filter(e=>this._reportLevel.includes(e.level))}_checkThrottle(e){return!!this._checkGlobalThrottle()||this._checkSingleThrottle(e)}_checkGlobalThrottle(){const e=Date.now();if(e-this._globalThrottle.startTime>=this._throttleConfig.global.throttleTime)this._globalThrottle.count=1,this._globalThrottle.startTime=e;else if(this._globalThrottle.count++,this._globalThrottle.count>this._throttleConfig.global.maxCount)return!0;return!1}_checkSingleThrottle(e){const t=Date.now(),s=this._singleThrottleMap.get(e);return s?t-s.startTime>=this._throttleConfig.single.throttleTime?(s.count=1,s.startTime=t,!1):s.count>=this._throttleConfig.single.maxCount||(s.count++,!1):(this._singleThrottleMap.set(e,{count:1,startTime:t}),!1)}_shouldLog(e){return e>=this._logLevel&&this._logLevel!==h.NONE}_shouldReport(e){return this._reportLevel.includes(E[e])}_formatLog(e,t,s){const n=new Date,i=`${n.getHours()}:${n.getMinutes()}:${n.getSeconds()}:${n.getMilliseconds()}`,o=`<${h[e]}>`;return ee||k?[`${g} [${i}] ${o} [${t}] ${s}`]:["%c%s%c%s","background:#0abf5b; padding:1px; border-radius:3px; color: #fff",g,"",`[${i}] ${o} [${t}] ${s}`]}_log(e,t,s,n){if(!this._shouldLog(e))return;const i=this._formatLog(e,t,s);if(p[e].apply(console,i),this._shouldReport(e)){const e=this._getThrottleKey(t,s,n);if(!this._checkThrottle(e)){this.createSSOLogData(Object.assign(Object.assign({message:s},n),{method:t})).end()}}}_getThrottleKey(e,t,s){const n=`${e}${t}${Se(Object.assign(Object.assign({},s),{costTime:""}))}`,i=ht(JSON.stringify(n));let o=4294967295;const{length:r}=i;for(let e=0;e<r;e++){o^=i[e];for(let e=0;e<8;e++)1&~o?o>>>=1:o=o>>>1^3988292384}return`${(4294967295^o)>>>0}`}reset(){console.log("SSO_LOG_MODULE.reset"),_t.removeTask(bt),De.unSubscribeInnerEvent(Ot.CLOUD_CONFIG_UPDATE,this._handleCloudConfigUpdate,this),this._lastReportAt=0,this.uploadSSOLogData(),this._sdkAppIdBlackList=[],this._tinyIdWhiteList=[],this._minThreshold=At,this._maxThreshold=100,this._waitingTime=Nt,this._logQueue=[],this._logLevel=h.DEBUG,this._globalThrottle={count:0,startTime:Date.now()},this._singleThrottleMap.clear()}};const Lt=15e3,kt="Channel",Ut="channel_schedule_task",Gt="channel_reconnect_task",Ft="connected",Bt="connecting",xt="disconnected",Vt=1e3,$t="network_status_change",qt="activity_status_change",Wt="send_fail",Yt="reconnect_failed",Kt="socket_error",Ht="socket_close";function jt(e){return jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},jt(e)}function zt(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Zt,Xt={exports:{}};var Jt=(Zt||(Zt=1,Xt.exports=function e(t,s,n){function i(r,a){if(!s[r]){if(!t[r]){if(!a&&zt)return zt(r);if(o)return o(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 i(t[r][1][e]||e)},l,l.exports,e,t,s,n)}return s[r].exports}for(var o=zt,r=0;r<n.length;r++)i(n[r]);return i}({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 i=n.shift();if(i){if("object"!=jt(i))throw new TypeError(i+"must be non-object");for(var o in i)t=i,s=o,Object.prototype.hasOwnProperty.call(t,s)&&(e[o]=i[o])}}return e},s.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,s,n,i){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+n),i);else for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){var t,s,n,i,o,r;for(t=n=0,s=e.length;t<s;t++)n+=e[t].length;for(r=new Uint8Array(n),t=i=0,s=e.length;t<s;t++)o=e[t],r.set(o,i),i+=o.length;return r}},o={arraySet:function(e,t,s,n,i){for(var o=0;o<n;o++)e[i+o]=t[s+o]},flattenChunks:function(e){return[].concat.apply([],e)}};s.setTyped=function(e){e?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,i)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,o))},s.setTyped(n)},{}],2:[function(e,t,s){var n=e("./common"),i=!0,o=!0;try{String.fromCharCode.apply(null,[0])}catch(e){i=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){o=!1}for(var r=new 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&&o||!e.subarray&&i))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,i,o,r,a=e.length,c=0;for(o=0;o<a;o++)55296==(64512&(s=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(s=65536+(s-55296<<10)+(i-56320),o++),c+=s<128?1:s<2048?2:s<65536?3:4;for(t=new n.Buf8(c),o=r=0;r<c;o++)55296==(64512&(s=e.charCodeAt(o)))&&o+1<a&&56320==(64512&(i=e.charCodeAt(o+1)))&&(s=65536+(s-55296<<10)+(i-56320),o++),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,i=t.length;s<i;s++)t[s]=e.charCodeAt(s);return t},s.buf2string=function(e,t){var s,n,i,o,a=t||e.length,l=new Array(2*a);for(s=n=0;s<a;)if((i=e[s++])<128)l[n++]=i;else if(4<(o=r[i]))l[n++]=65533,s+=o-1;else{for(i&=2===o?31:3===o?15:7;1<o&&s<a;)i=i<<6|63&e[s++],o--;1<o?l[n++]=65533:i<65536?l[n++]=i:(i-=65536,l[n++]=55296|i>>10&1023,l[n++]=56320|1023&i)}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 i=65535&e,o=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;o=o+(i=i+t[n++]|0)|0,--r;);i%=65521,o%=65521}return i|o<<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,i){var o=n,r=i+s;e^=-1;for(var a=i;a<r;a++)e=e>>>8^o[255&(e^t[a])];return-1^e}},{}],6:[function(e,t,s){t.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],7:[function(e,t,s){t.exports=function(e,t){var s,n,i,o,r,a,c,l,u,d,_,h,g,p,E,f,m,S,v,I,C,M,T,y,O;s=e.state,n=e.next_in,y=e.input,i=n+(e.avail_in-5),o=e.next_out,O=e.output,r=o-(t-e.avail_out),a=o+(e.avail_out-257),c=s.dmax,l=s.wsize,u=s.whave,d=s.wnext,_=s.window,h=s.hold,g=s.bits,p=s.lencode,E=s.distcode,f=(1<<s.lenbits)-1,m=(1<<s.distbits)-1;e:do{g<15&&(h+=y[n++]<<g,g+=8,h+=y[n++]<<g,g+=8),S=p[h&f];t:for(;;){if(h>>>=v=S>>>24,g-=v,0==(v=S>>>16&255))O[o++]=65535&S;else{if(!(16&v)){if(!(64&v)){S=p[(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+=y[n++]<<g,g+=8),I+=h&(1<<v)-1,h>>>=v,g-=v),g<15&&(h+=y[n++]<<g,g+=8,h+=y[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+=y[n++]<<g,(g+=8)<v&&(h+=y[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=o-r)<C){if(u<(v=C-v)&&s.sane){e.msg="invalid distance too far back",s.mode=30;break e}if(T=_,(M=0)===d){if(M+=l-v,v<I){for(I-=v;O[o++]=_[M++],--v;);M=o-C,T=O}}else if(d<v){if(M+=l+d-v,(v-=d)<I){for(I-=v;O[o++]=_[M++],--v;);if(M=0,d<I){for(I-=v=d;O[o++]=_[M++],--v;);M=o-C,T=O}}}else if(M+=d-v,v<I){for(I-=v;O[o++]=_[M++],--v;);M=o-C,T=O}for(;2<I;)O[o++]=T[M++],O[o++]=T[M++],O[o++]=T[M++],I-=3;I&&(O[o++]=T[M++],1<I&&(O[o++]=T[M++]))}else{for(M=o-C;O[o++]=O[M++],O[o++]=O[M++],O[o++]=O[M++],2<(I-=3););I&&(O[o++]=O[M++],1<I&&(O[o++]=O[M++]))}break}}break}}while(n<i&&o<a);n-=I=g>>3,h&=(1<<(g-=I<<3))-1,e.next_in=n,e.next_out=o,e.avail_in=n<i?i-n+5:5-(n-i),e.avail_out=o<a?a-o+257:257-(o-a),s.hold=h,s.bits=g}},{}],8:[function(e,t,s){var n=e("../utils/common"),i=e("./adler32"),o=e("./crc32"),r=e("./inffast"),a=e("./inftrees"),c=1,l=2,u=0,d=-2,_=1,h=852,g=592;function p(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