UNPKG

@tencentcloud/lite-chat

Version:

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

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