function MBHashMap() { this.length = 0, this.maxLength = Number.MAX_VALUE, this.container = {} }MBHashMap.prototype.put = function (e, t) {
  try {
    if (this.length >= this.maxLength)
      throw new Error('[Error HashMap] : Map Datas\' count overflow !'); if (e != '') {
      for (const o in this.container) {
        if (o == e)
          return void (this.container[e] = t)
      } this.container[e] = t, this.length++
    }
  }
  catch (e) { return e }
}, MBHashMap.prototype.get = function (e) {
  try { return this.container[e] ? this.container[e] : null }
  catch (e) { return e }
}, MBHashMap.prototype.contains = function (e) {
  try {
    for (const t in this.container) {
      if (t == e)
        return !0
    } return !1
  }
  catch (e) { return e }
}, MBHashMap.prototype.containsValue = function (e) {
  try {
    for (const t in this.container) {
      if (this.container[t] === e)
        return !0
    } return !1
  }
  catch (e) { return e }
}, MBHashMap.prototype.remove = function (e) {
  try { return this.container[e] ? (delete this.container[e], this.length--, !0) : !1 }
  catch (e) { return e }
}, MBHashMap.prototype.removeAll = function () {
  try { this.clear() }
  catch (e) { return e }
}, MBHashMap.prototype.clear = function () {
  try { delete this.container, this.container = {}, this.length = 0 }
  catch (e) { return e }
}, MBHashMap.prototype.isEmpty = function () { return this.length === 0 }, MBHashMap.prototype.keySet = function () { let e; const t = []; for (e in this.container)t.push(e); return t }, MBHashMap.prototype.size = function () { return this.length }, MBHashMap.prototype.showAll = function (e) {
  if (this.length > 0)
    for (const t in console.log('[hashmap.js_showAll()] 正在输出HashMap内容(列表长度 %d) -------------------\x3E', this.length), this.container)e ? console.log('[hashmap.js_showAll()]       > key=%s, value=%s', t, e(this.container[t])) : console.log('[hashmap.js_showAll()]       > key=%s, value=%s', t, this.container[t]); else console.log('[hashmap.js_showAll()] 列表中长度为：%d !', this.length)
}, (function (n) {
  'use strict'; let s, r, t, i, e; (n
    ? function () {
      let o; const e = n.crypto || n.msCrypto; if (!s && e && e.getRandomValues) {
        try { const t = new Uint8Array(16); i = s = function () { return e.getRandomValues(t), t }, s() }
        catch (e) {}
      }s || (o = Array.from({ length: 16 }), r = s = function () { for (var e, t = 0; t < 16; t++)(3 & t) == 0 && (e = 4294967296 * Math.random()), o[t] = e >>> ((3 & t) << 3) & 255; return o }, typeof console != 'undefined' && console.warn && console.warn('[SECURITY] node-uuid: crypto not usable, falling back to insecure Math.random()'))
    }
    : function () {
      if (typeof require == 'function') {
        try { const e = require('node:crypto').randomBytes; t = s = e && function () { return e(16) }, s() }
        catch (e) {}
      }
    })(); for (var a = typeof Buffer == 'function' ? Buffer : Array, o = [], l = {}, c = 0; c < 256; c++)o[c] = (c + 256).toString(16).substr(1), l[o[c]] = c; function _(e, t) { t = t || 0; return `${o[e[t++]] + o[e[t++]] + o[e[t++]] + o[e[t++]]}-${o[e[t++]]}${o[e[t++]]}-${o[e[t++]]}${o[e[t++]]}-${o[e[t++]]}${o[e[t++]]}-${o[e[t++]]}${o[e[t++]]}${o[e[t++]]}${o[e[t++]]}${o[e[t++]]}${o[e[t++]]}` } const M = s(); const u = [1 | M[0], M[1], M[2], M[3], M[4], M[5]]; let S = 16383 & (M[6] << 8 | M[7]); let d = 0; let E = 0; function g(e, t, o) {
    const n = t && o || 0; typeof e == 'string' && (t = e === 'binary' ? new a(16) : null, e = null); const r = (e = e || {}).random || (e.rng || s)(); if (r[6] = 15 & r[6] | 64, r[8] = 63 & r[8] | 128, t)
      for (let i = 0; i < 16; i++)t[n + i] = r[i]; return t || _(r)
  } const h = g; h.v1 = function (e, t, o) {
    let n = t && o || 0; const r = t || []; let i = (e = e || {}).clockseq != null ? e.clockseq : S; let s = e.msecs != null ? e.msecs : (new Date()).getTime(); let a = e.nsecs != null ? e.nsecs : E + 1; if ((o = s - d + (a - E) / 1e4) < 0 && e.clockseq == null && (i = i + 1 & 16383), (o < 0 || d < s) && e.nsecs == null && (a = 0), a >= 1e4)
      throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); d = s, S = i, a = (1e4 * (268435455 & (s += 122192928e5)) + (E = a)) % 4294967296, r[n++] = a >>> 24 & 255, r[n++] = a >>> 16 & 255, r[n++] = a >>> 8 & 255, r[n++] = 255 & a, s = s / 4294967296 * 1e4 & 268435455, r[n++] = s >>> 8 & 255, r[n++] = 255 & s, r[n++] = s >>> 24 & 15 | 16, r[n++] = s >>> 16 & 255, r[n++] = i >>> 8 | 128, r[n++] = 255 & i; for (let l = e.node || u, c = 0; c < 6; c++)r[n + c] = l[c]; return t || _(r)
  }, h.v4 = g, h.parse = function (e, t, o) { const n = t && o || 0; let r = 0; for (t = t || [], e.toLowerCase().replace(/[0-9a-f]{2}/g, (e) => { r < 16 && (t[n + r++] = l[e]) }); r < 16;)t[n + r++] = 0; return t }, h.unparse = _, h.BufferClass = a, h._rng = s, h._mathRNG = r, h._nodeRNG = t, h._whatwgRNG = i, typeof module != 'undefined' && module.exports ? module.exports = h : typeof define == 'function' && define.amd ? define(() => { return h }) : (e = n.uuid, h.noConflict = function () { return n.uuid = e, h }, n.uuid = h)
}(typeof window != 'undefined' ? window : null)); const MBProtocalType = { FROM_CLIENT_TYPE_OF_LOGIN: 0, FROM_CLIENT_TYPE_OF_KEEP$ALIVE: 1, FROM_CLIENT_TYPE_OF_COMMON$DATA: 2, FROM_CLIENT_TYPE_OF_LOGOUT: 3, FROM_CLIENT_TYPE_OF_RECIVED: 4, FROM_CLIENT_TYPE_OF_ECHO: 5, FROM_SERVER_TYPE_OF_RESPONSE$LOGIN: 50, FROM_SERVER_TYPE_OF_RESPONSE$KEEP$ALIVE: 51, FROM_SERVER_TYPE_OF_RESPONSE$FOR$ERROR: 52, FROM_SERVER_TYPE_OF_RESPONSE$ECHO: 53, FROM_SERVER_TYPE_OF_KICKOUT: 54 }; const MBErrorCode = { COMMON_CODE_OK: 0, COMMON_NO_LOGIN: 1, COMMON_UNKNOW_ERROR: 2, COMMON_DATA_SEND_FAILD: 3, COMMON_INVALID_PROTOCAL: 4, BREOKEN_CONNECT_TO_SERVER: 201, BAD_CONNECT_TO_SERVER: 202, CLIENT_SDK_NO_INITIALED: 203, LOCAL_NETWORK_NOT_WORKING: 204, TO_SERVER_NET_INFO_NOT_SETUP: 205, RESPONSE_FOR_UNLOGIN: 301 }; const MBSocketEvent = { SOCKET_EVENT_ON_LOGIN_RESPONSE: 'onLoginResponse', SOCKET_EVENT_ON_LINK_CLOSE: 'onLinkClose', SOCKET_EVENT_ON_RECIEVE_MESSAGE: 'onRecieveMessage', SOCKET_EVENT_ON_ERROR_RESPONSE: 'onErrorResponse', SOCKET_EVENT_MESSAGE_LOST: 'messagesLost', SOCKET_EVENT_MESSAGE_BE_RECIEVED: 'messagesBeReceived', SOCKET_EVENT_RECONNECT_ATTEMPT: 'reconnect_attempt', SOCKET_EVENT_PING: 'ping', SOCKET_EVENT_PONG: 'pong', SOCKET_EVENT_KICKOUT: 'kickout' }; const MBKickoutCode = { KICKOUT_FOR_DUPLICATE_LOGIN: 1, KICKOUT_FOR_ADMIN: 2 }; const MBSenseMode = { MODE_3S: 1, MODE_5S: 2, MODE_10S: 3, MODE_15S: 4, MODE_30S: 5, MODE_60S: 6, MODE_120S: 7 }; const MBProtocalFactory = (function () { function l(e) { this.type = 0, this.dataContent = null, this.from = '-1', this.to = '-1', this.fp = null, this.QoS = !1, this.typeu = -1, this.retryCount = 0 } function e(e) {} return e.prototype.createProtocal = function (e, t, o, n, r, i, s) { const a = new l(); return a.type = e, a.dataContent = t, a.from = o, a.to = n, a.typeu = s, (a.QoS = r) && (a.fp = i || uuid.v1()), a }, e.prototype.createCommonData = function (e, t, o, n, r, i) { return this.createProtocal(MBProtocalType.FROM_CLIENT_TYPE_OF_COMMON$DATA, e, t, o, n, r, i) }, e.prototype.createCommonDataSimple = function (e, t, o, n) { return this.createCommonData(e, t, o, !0, null, n) }, e.prototype.createPKeepAlive = function (e) { return this.createProtocal(MBProtocalType.FROM_CLIENT_TYPE_OF_KEEP$ALIVE, '{}', e, '0', !1, null, -1) }, e.prototype.createPLoginoutInfo = function (e) { return this.createProtocal(MBProtocalType.FROM_CLIENT_TYPE_OF_LOGOUT, null, e, '0', !1, null, -1) }, e.prototype.createPLoginInfo = function (e, t) { return this.createProtocal(MBProtocalType.FROM_CLIENT_TYPE_OF_LOGIN, JSON.stringify(t), e, '0', !1, null, -1) }, e.prototype.createRecivedBack = function (e, t, o) { return this.createProtocal(MBProtocalType.FROM_CLIENT_TYPE_OF_RECIVED, o, e, t, !1, null, -1) }, new e() }()); const MBCore = (function () { function e(e) { this._socketEvenCallbacks = {}, this._websocketUrl = null, this.DEBUG = !1, this.autoReLogin = !0, this.connectedToServer = !0, this.loginHasInit = !1, this.currenetLoginInfo = { loginUserId: null, loginToken: null, loginExtra: null, firstLoginTime: 0 } } const n = 'MBCore'; return e.prototype.setWebsocketUrl = function (e) { this._websocketUrl = e }, e.prototype.getWebsocketUrl = function () { return this._websocketUrl }, e.prototype.isLoginHasInit = function () { return this.loginHasInit }, e.prototype.setLoginHasInit = function (e) { this.loginHasInit = e }, e.prototype.setAutoRelogin = function (e) { this.autoReLogin = e }, e.prototype.isAutoRelogin = function () { return this.autoReLogin }, e.prototype.isConnectedToServer = function () { return this.connectedToServer }, e.prototype.setConnectedToServer = function (e) { this.connectedToServer = e }, e.prototype.getCurrentLoginInfo = function () { return this.currenetLoginInfo }, e.prototype.setCurrenetLoginInfo = function (e) { this.currenetLoginInfo = e }, e.prototype.setCurrenetLoginInfo_firstLoginTime = function (e) { this.currenetLoginInfo.firstLoginTime = e }, e.prototype.getEventCallback = function (e) { if (e) { const t = this._socketEvenCallbacks[e]; return t || (MBUtils.mblog_d(n, `事件监听者列表中，名称为 eventName=${e}的callback 是空的！`), null) }MBUtils.mblog_w(n, `无效的参数：eventName=${e}`) }, e.prototype.on = function (e, t) { e && t ? this._socketEvenCallbacks[e] = t : MBUtils.mblog_w(n, `无效的参数：eventName=${e}, callback=${t}`) }, e.prototype.emit = function (e, t) { const o = this.getEventCallback(e); o ? o(t) : MBUtils.mblog_w(n, `事件回调列表中没有找到eventName=${e}的callback，本次emit无法进行！`) }, e.prototype.debugEnabled = function () { return this.DEBUG }, e.prototype.setDebugEnabled = function (e) { this.DEBUG = e }, e.prototype.release = function () { MBCore.setConnectedToServer(!1), MBSocketProvider.closeLocalSocket(), MBAutoReLoginDaemon.stop(), MBQoS4SendDaemon.stop(), MBKeepAliveDaemon.stop(), MBQoS4ReciveDaemon.stop(), MBQoS4SendDaemon.clear(), MBQoS4ReciveDaemon.clear(), this.setLoginHasInit(!1), this.setCurrenetLoginInfo(null) }, new e() }()); const MBAutoReLoginDaemon = (function () { function e(e) { this.intervalId = 0, this.AUTO_RE$LOGIN_INTERVAL = 3e3, this._excuting = !1 } const t = 'MBAutoReLoginDaemon'; return e.prototype.setAutoReloginInterval = function (e) { MBUtils.isPositiveInteger(e) ? this.AUTO_RE$LOGIN_INTERVAL = e : MBUtils.mblog_w(t, `无效的AUTO_RE$LOGIN_INTERVAL参数设置：${e}`) }, e.prototype.excute = function () { this._excuting || this.onSendLogin(this.doSendLogin()) }, e.prototype.doSendLogin = function () { this._excuting = !0, MBCore.debugEnabled() && MBUtils.mblog_d(t, `自动重新登陆线程执行中, autoReLogin ? ${MBCore.autoReLogin}...`); let e = -1; return MBCore.isAutoRelogin() && (e = MBDataSender.sendLogin(MBCore.getCurrentLoginInfo())), e }, e.prototype.onSendLogin = function (e) { MBCore.emit(MBSocketEvent.SOCKET_EVENT_RECONNECT_ATTEMPT, e), this._excuting = !1 }, e.prototype.start = function (e) { this.stop(), e && this.excute(); const t = this; this.intervalId = setInterval(() => { t.excute() }, this.AUTO_RE$LOGIN_INTERVAL) }, e.prototype.stop = function () { this.intervalId && this.intervalId !== 0 && clearInterval(this.intervalId) }, new e() }()); const MBKeepAliveDaemon = (function () { function e(e) { this.intervalId = 0, this.KEEP_ALIVE_INTERVAL = 5e3, this.NETWORK_CONNECTION_TIME_OUT = this.KEEP_ALIVE_INTERVAL + 3e3, this.lastGetKeepAliveResponseFromServerTimstamp = 0, this.networkConnectionLostCallback = null, this.keepAliveTaskExcuting = !1, this.keepAliveWillStop = !1 } const o = 'MBKeepAliveDaemon'; return e.prototype.excute = function () { this.keepAliveTaskExcuting || (this.keepAliveWillStop = !1, this.onKeepAlive(this.doKeepAlive())) }, e.prototype.doKeepAlive = function () { return this.keepAliveTaskExcuting = !0, MBCore.debugEnabled() && MBUtils.mblog_d(o, '心跳线程执行中...'), MBDataSender.sendKeepAlive() }, e.prototype.onKeepAlive = function (e) { MBCore.emit(MBSocketEvent.SOCKET_EVENT_PING, null); let t = this.lastGetKeepAliveResponseFromServerTimstamp === 0; t && (this.lastGetKeepAliveResponseFromServerTimstamp = MBUtils.getCurrentUTCTimestamp()), t || (t = MBUtils.getCurrentUTCTimestamp()) - this.lastGetKeepAliveResponseFromServerTimstamp >= this.NETWORK_CONNECTION_TIME_OUT && (MBCore.debugEnabled() && (MBUtils.mblog_d(o, `>>>> t1=${t}, t2=${this.lastGetKeepAliveResponseFromServerTimstamp} -> 差：${t - this.lastGetKeepAliveResponseFromServerTimstamp}`), MBUtils.mblog_d(o, '心跳机制已判定网络断开，将进入断网通知和重连处理逻辑 ...')), this.notifyConnectionLost(), this.keepAliveWillStop = !0), this.keepAliveTaskExcuting = !1, this.keepAliveWillStop && this.stop() }, e.prototype.notifyConnectionLost = function () { this.stop(), this.networkConnectionLostCallback != null && this.networkConnectionLostCallback(null, null) }, e.prototype.start = function (e) { this.stop(), e && this.excute(); const t = this; this.intervalId = setInterval(() => { t.excute() }, this.KEEP_ALIVE_INTERVAL) }, e.prototype.stop = function () { this.intervalId && this.intervalId !== 0 && clearInterval(this.intervalId), this.lastGetKeepAliveResponseFromServerTimstamp = 0 }, e.prototype.updateGetKeepAliveResponseFromServerTimstamp = function () { this.lastGetKeepAliveResponseFromServerTimstamp = MBUtils.getCurrentUTCTimestamp() }, e.prototype.setNetworkConnectionLostCallback = function (e) { this.networkConnectionLostCallback = e }, e.prototype.setSenseMode = function (e) { let t = 0; let o = 0; switch (e) { case MBSenseMode.MODE_3S:t = 3e3, o = +t + 2e3; break; case MBSenseMode.MODE_5S:t = 5e3, o = +t + 3e3; break; case MBSenseMode.MODE_10S:t = 1e4, o = +t + 5e3; break; case MBSenseMode.MODE_15S:t = 15e3, o = +t + 5e3; break; case MBSenseMode.MODE_30S:t = 3e4, o = +t + 5e3; break; case MBSenseMode.MODE_60S:t = 6e4, o = +t + 5e3; break; case MBSenseMode.MODE_120S:t = 12e4, o = +t + 5e3 }t > 0 && (this.KEEP_ALIVE_INTERVAL = t), o > 0 && (this.NETWORK_CONNECTION_TIME_OUT = o) }, new e() }()); const MBQoS4ReciveDaemon = (function () {
  function e(e) { this.intervalId = 0, this.CHECH_INTERVAL = 3e5, this.MESSAGES_VALID_TIME = 6e5, this.recievedMessages = new MBHashMap(), this._excuting = !1 } const r = 'MBQoS4ReciveDaemon'; return e.prototype.excute = function () { if (!this._excuting) { this._excuting = !0, MBCore.debugEnabled() && MBUtils.mblog_d(r, `【QoS接收方】+++++ START 暂存处理线程正在运行中，当前长度${this.recievedMessages.size()}.`); for (let e = this.recievedMessages.keySet(), t = 0; t < e.length; t++) { const o = e[t]; var n = this.recievedMessages.get(o); var n = MBUtils.getCurrentUTCTimestamp() - (n || 0); n >= this.MESSAGES_VALID_TIME && (MBCore.debugEnabled() && MBUtils.mblog_d(r, `【QoS接收方】指纹为${o}的包已生存${n}ms(最大允许${this.MESSAGES_VALID_TIME}ms), 马上将删除之.`), this.recievedMessages.remove(o)) } }MBCore.debugEnabled() && MBUtils.mblog_d(r, `【QoS接收方】+++++ END 暂存处理线程正在运行中，当前长度${this.recievedMessages.size()}.`), this._excuting = !1 }, e.prototype.startup = function (e) {
    if (this.stop(), this.recievedMessages != null && this.recievedMessages.size() > 0)
      for (let t = this.recievedMessages.keySet(), o = 0; o < t.length; o++) { const n = t[o]; this.putImpl(n) }e && this.excute(); const r = this; this.intervalId = setInterval(() => { r.excute() }, this.CHECH_INTERVAL)
  }, e.prototype.stop = function () { this.intervalId && this.intervalId !== 0 && clearInterval(this.intervalId) }, e.prototype.addRecievedProtocal = function (e) { e && e.QoS && this.addRecieved(e.fp) }, e.prototype.addRecieved = function (e) { e ? (this.recievedMessages.contains(e) && MBUtils.mblog_w(r, `【QoS接收方】指纹为${e}的消息已经存在于接收列表中，该消息重复了（原理可能是对方因未收到应答包而错误重传导致），更新收到时间戳哦.`), this.putImpl(e)) : MBUtils.mblog_w(r, '无效的 fingerPrintOfProtocal==null!') }, e.prototype.putImpl = function (e) { e && this.recievedMessages.put(e, MBUtils.getCurrentUTCTimestamp()) }, e.prototype.hasRecieved = function (e) { return this.recievedMessages.contains(e) }, e.prototype.clear = function () { this.recievedMessages.clear() }, e.prototype.size = function () { return this.recievedMessages.size() }, e.prototype.setCheckInterval = function (e) { this.CHECH_INTERVAL = e }, e.prototype.setMessageValidTime = function (e) { this.MESSAGES_VALID_TIME = e }, new e()
}()); const MBQoS4SendDaemon = (function () {
  function e(e) { this.intervalId = 0, this.CHECH_INTERVAL = 5e3, this.MESSAGES_JUST$NOW_TIME = 3e3, this.QOS_TRY_COUNT = 2, this.sentMessages = new MBHashMap(), this.sendMessagesTimestamp = new MBHashMap(), this._excuting = !1 } const s = 'MBQoS4SendDaemon'; return e.prototype.excute = function () { let e; this._excuting || (e = [], this.onRetryCheck(this.doRetryCheck(e))) }, e.prototype.doRetryCheck = function (e) {
    this._excuting = !0; try { MBCore.debugEnabled() && this.sentMessages.size() > 0 && MBUtils.mblog_d(s, `【QoS】====== 消息发送质量保证线程运行中, 当前需要处理的列表长度为${this.sentMessages.size()}...`); for (let t = this.sentMessages.keySet(), o = 0; o < t.length; o++) { var n; const r = t[o]; const i = this.sentMessages.get(r); i && i.QoS ? i.retryCount && i.retryCount >= this.QOS_TRY_COUNT ? (MBCore.debugEnabled() && MBUtils.mblog_d(s, `【QoS】指纹为${i.fp}的消息包重传次数已达${i.retryCount}(最多${this.QOS_TRY_COUNT}次)上限，将判定为丢包！`), e.push(i), this.remove(i.fp)) : (n = this.sendMessagesTimestamp.get(r), (n = MBUtils.getCurrentUTCTimestamp() - (n == null ? 0 : n)) <= this.MESSAGES_JUST$NOW_TIME ? MBCore.debugEnabled() && MBUtils.mblog_w(s, `【QoS】指纹为${r}的包距"刚刚"发出才${n}ms(<=${this.MESSAGES_JUST$NOW_TIME}ms将被认定是"刚刚"), 本次不需要重传哦.`) : MBDataSender.sendCommonData(i) === 0 ? (i.retryCount || (i.retryCount = 0), i.retryCount += 1, MBCore.debugEnabled() && MBUtils.mblog_d(s, `【QoS】指纹为${i.fp}的消息包已成功进行重传，此次之后重传次数已达${i.retryCount}(最多${this.QOS_TRY_COUNT}次).`)) : MBUtils.mblog_w(s, `【QoS】指纹为${i.fp}的消息包重传失败，它的重传次数之前已累计为${i.retryCount}(最多${this.QOS_TRY_COUNT}次).`)) : this.remove(r) } }
    catch (e) { MBUtils.mblog_w(s, '【QoS】消息发送质量保证线程运行时发生异常：', e) } return e
  }, e.prototype.onRetryCheck = function (e) { e && e.length > 0 && this.notifyMessageLost(e), this._excuting = !1 }, e.prototype.notifyMessageLost = function (e) { MBCore.emit(MBSocketEvent.SOCKET_EVENT_MESSAGE_LOST, e) }, e.prototype.startup = function (e) { this.stop(), e && this.excute(); const t = this; this.intervalId = setInterval(() => { t.excute() }, this.CHECH_INTERVAL) }, e.prototype.stop = function () { this.intervalId && this.intervalId !== 0 && clearInterval(this.intervalId) }, e.prototype.exist = function (e) { return this.sentMessages.get(e) != null }, e.prototype.put = function (e) { e ? e.fp ? e.QoS ? (this.sentMessages.get(e.fp) != null && MBUtils.mblog_w(s, `【QoS】指纹为${e.fp}的消息已经放入了发送质量保证队列，该消息为何会重复？（生成的指纹码重复？还是重复put？）`), this.sentMessages.put(e.fp, e), this.sendMessagesTimestamp.put(e.fp, MBUtils.getCurrentUTCTimestamp())) : MBUtils.mblog_w(s, 'This protocal is not QoS pkg, ignore it!') : MBUtils.mblog_w(s, 'Invalid arg p.getFp() == null.') : MBUtils.mblog_w(s, 'Invalid arg p==null.') }, e.prototype.remove = function (e) { this.sendMessagesTimestamp.remove(e); const t = this.sentMessages.get(e); this.sentMessages.remove(e), MBUtils.mblog_w(s, `【QoS】指纹为${e}的消息已成功从发送质量保证队列中移除(可能是收到接收方的应答也可能是达到了重传的次数上限)，重试次数=${t != null ? t.retryCount : 'none呵呵.'}`) }, e.prototype.clear = function () { this.sentMessages.clear(), this.sendMessagesTimestamp.clear() }, e.prototype.size = function () { return this.sentMessages.size() }, e.prototype.setCheckInterval = function (e) { this.CHECH_INTERVAL = e }, e.prototype.setQoSTryCount = function (e) { this.QOS_TRY_COUNT = e }, new e()
}()); const MBDataReciever = (function () {
  function e(e) {} const o = 'MBDataReciever'; return e.prototype.handleProtocal = function (e) {
    if (e) {
      try {
        if (e.QoS) {
          if (e.type === MBProtocalType.FROM_SERVER_TYPE_OF_RESPONSE$LOGIN && JSON.parse(e.dataContent).code !== 0) { MBCore.debugEnabled() && MBUtils.mblog_d(o, '【BugFIX】这是服务端的登陆返回响应包，且服务端判定登陆失败(即code!=0)，本次无需发送ACK应答包！') }
          else {
            if (MBQoS4ReciveDaemon.hasRecieved(e.fp))
              return MBCore.debugEnabled() && MBUtils.mblog_d(o, `【QoS机制】${e.fp}已经存在于发送列表中，这是重复包，通知应用层收到该包罗！`), MBQoS4ReciveDaemon.addRecievedProtocal(e), void this.sendRecievedBack(e); MBQoS4ReciveDaemon.addRecievedProtocal(e), this.sendRecievedBack(e)
          }
        } switch (e.type) { case MBProtocalType.FROM_CLIENT_TYPE_OF_COMMON$DATA:this.onRecievedCommonData(e); break; case MBProtocalType.FROM_SERVER_TYPE_OF_RESPONSE$KEEP$ALIVE:this.onServerResponseKeepAlive(); break; case MBProtocalType.FROM_CLIENT_TYPE_OF_RECIVED:this.onMessageRecievedACK(e); break; case MBProtocalType.FROM_SERVER_TYPE_OF_RESPONSE$LOGIN:this.onServerResponseLogined(e); break; case MBProtocalType.FROM_SERVER_TYPE_OF_RESPONSE$FOR$ERROR:this.onServerResponseError(e); break; case MBProtocalType.FROM_SERVER_TYPE_OF_KICKOUT:this.onKickout(e); break; default:MBUtils.mblog_w(o, `收到的服务端消息类型：${e.getType()}，但目前该类型客户端不支持解析和处理！`) }
      }
      catch (e) { MBUtils.mblog_w(o, '处理消息的过程中发生了错误.', e) }
    }
    else { MBUtils.mblog_d(o, `无效的pFromServer（${e}）！`) }
  }, e.prototype.onRecievedCommonData = function (e) { MBCore.emit(MBSocketEvent.SOCKET_EVENT_ON_RECIEVE_MESSAGE, e) }, e.prototype.onServerResponseKeepAlive = function () { MBCore.debugEnabled() && MBUtils.mblog_d(o, '收到服务端回过来的Keep Alive心跳响应包.'), MBCore.emit(MBSocketEvent.SOCKET_EVENT_PONG, null), MBKeepAliveDaemon.updateGetKeepAliveResponseFromServerTimstamp() }, e.prototype.onMessageRecievedACK = function (e) { const t = e.dataContent; MBCore.debugEnabled() && MBUtils.mblog_d(o, `【QoS】收到${e.from}发过来的指纹为${t}的应答包.`), MBCore.emit(MBSocketEvent.SOCKET_EVENT_MESSAGE_BE_RECIEVED, t), MBQoS4SendDaemon.remove(t) }, e.prototype.onServerResponseLogined = function (e) { e = JSON.parse(e.dataContent); e.code === 0 ? (MBCore.isLoginHasInit() || (MBUtils.mblog_d(o, `首次登陆验证成功，firstLoginTime=${e.firstLoginTime}`), MBCore.setCurrenetLoginInfo_firstLoginTime(e.firstLoginTime)), this.fireConnectedToServer()) : (MBUtils.mblog_d(o, `登陆验证失败，错误码=${e.code}！`), MBSocketProvider.closeLocalSocket(), MBCore.setConnectedToServer(!1)), MBCore.emit(MBSocketEvent.SOCKET_EVENT_ON_LOGIN_RESPONSE, e) }, e.prototype.onServerResponseError = function (e) { e = JSON.parse(e.dataContent); e.errorCode === MBErrorCode.RESPONSE_FOR_UNLOGIN && (MBCore.setLoginHasInit(!1), MBUtils.mblog_e(o, '收到服务端的“尚未登陆”的错误消息，心跳线程将停止，请应用层重新登陆.'), MBKeepAliveDaemon.stop(), MBAutoReLoginDaemon.start(!1)), MBCore.emit(MBSocketEvent.SOCKET_EVENT_ON_ERROR_RESPONSE, e) }, e.prototype.onKickout = function (e) { MBCore.debugEnabled() && MBUtils.mblog_d(o, '收到服务端发过来的“重复登录被踢”消息.'), MBCore.release(); e = JSON.parse(e.dataContent); MBCore.emit(MBSocketEvent.SOCKET_EVENT_KICKOUT, e), MBCore.emit(MBSocketEvent.SOCKET_EVENT_ON_LINK_CLOSE, -1) }, e.prototype.fireConnectedToServer = function () { const e = this; MBCore.setLoginHasInit(!0), MBAutoReLoginDaemon.stop(); MBKeepAliveDaemon.setNetworkConnectionLostCallback(() => { e.fireDisconnectedToServer() }), MBKeepAliveDaemon.start(!1), MBQoS4SendDaemon.startup(!0), MBQoS4ReciveDaemon.startup(!0), MBCore.setConnectedToServer(!0) }, e.prototype.fireDisconnectedToServer = function () { MBCore.setConnectedToServer(!1), MBSocketProvider.closeLocalSocket(), MBQoS4ReciveDaemon.stop(), MBCore.emit(MBSocketEvent.SOCKET_EVENT_ON_LINK_CLOSE, -1), MBAutoReLoginDaemon.start(!0) }, e.prototype.sendRecievedBack = function (e) { let t; e.fp ? (t = MBProtocalFactory.createRecivedBack(e.to, e.from, e.fp), t = MBDataSender.sendCommonData(t), MBCore.debugEnabled() && MBUtils.mblog_d(o, `【QoS】向${e.from}发送${e.fp}包的应答包成功？(code=${t}),from=${e.to}！`)) : MBUtils.mblog_w(o, `【QoS】收到${e.from}发过来需要QoS的包，但它的指纹码却为null！无法发应答包！`) }, new e()
}()); const MBDataSender = (function () {
  function e(e) {} const r = 'MBDataSender'; return e.prototype.sendLogin = function (o) {
    if (MBSocketProvider.isLocalSocketReady())
      return this.sendLoginImpl(o); MBCore.debugEnabled() && MBUtils.mblog_d(r, '发送登陆指令时，socket连接未就绪，首先开始尝试发起连接（登陆指令将在连接成功后的回调中自动发出）。。。。'); const n = this; return MBSocketProvider.setConnectionDoneCallback((e, t) => { e ? n.sendLoginImpl(o) : MBUtils.mblog_w(r, '[来自ws连接结果回调观察者通知]socket连接失败，本次登陆信息未成功发出！') }), MBSocketProvider.resetLocalSocket() != null ? MBErrorCode.COMMON_CODE_OK : MBErrorCode.BAD_CONNECT_TO_SERVER
  }, e.prototype.sendLoginImpl = function (e) { var t = MBProtocalFactory.createPLoginInfo(e.loginUserId, e); var t = this.send(JSON.stringify(t)); return t === 0 && MBCore.setCurrenetLoginInfo(e), t }, e.prototype.sendLoginout = function () { let e = MBErrorCode.COMMON_CODE_OK; let t; return MBCore.isLoginHasInit() && (t = MBProtocalFactory.createPLoginoutInfo(MBCore.getCurrentLoginInfo().loginUserId), e = this.send(JSON.stringify(t)), e), MBCore.release(), e }, e.prototype.sendKeepAlive = function () { const e = MBProtocalFactory.createPKeepAlive(MBCore.getCurrentLoginInfo().loginUserId); return this.send(JSON.stringify(e)) }, e.prototype.sendCommonData = function (e) { if (e) { var t = JSON.stringify(e); var t = this.send(t); return t === 0 && e.QoS && !MBQoS4SendDaemon.exist(e.fp) && MBQoS4SendDaemon.put(e), t } return MBErrorCode.COMMON_INVALID_PROTOCAL }, e.prototype.send = function (e) { const t = MBSocketProvider.getLocalSocket(); return t != null && t.readyState === 1 ? MBUtils.send(t, e) ? MBErrorCode.COMMON_CODE_OK : MBErrorCode.COMMON_DATA_SEND_FAILD : (MBUtils.mblog_d(r, `scocket未连接，无法发送，本条将被忽略（dataWithString=${e}）!`), MBErrorCode.COMMON_CODE_OK) }, new e()
}()); const MBSocketProvider = (function () {
  function e(e) { this.localSocket = null, this.connectionDoneCallback = null } const n = 'MBSocketProvider'; return e.prototype.setConnectionDoneCallback = function (e) { this.connectionDoneCallback = e }, e.prototype.resetLocalSocket = function () {
    try { return this.closeLocalSocket(!0), this.tryConnectToHost(), this.localSocket }
    catch (e) { return MBUtils.mblog_w(n, `重置localSocket时出错，原因是：${e}`), this.closeLocalSocket(!0), null }
  }, e.prototype.tryConnectToHost = function () {
    MBCore.debugEnabled() && MBUtils.mblog_d(n, 'tryConnectToHost并获取connection开始了...'); let e = !1; const t = this; try { window.WebSocket || (window.WebSocket = window.MozWebSocket), window.WebSocket ? (this.localSocket = new WebSocket(MBCore.getWebsocketUrl()), this.localSocket.onopen = function (e) { MBCore.debugEnabled() && MBUtils.mblog_d(n, `WS.onopen - 连接已成功建立！(isLocalSocketReady=${t.isLocalSocketReady()})`), t.connectionDoneCallback && (t.connectionDoneCallback(!0), t.connectionDoneCallback = null) }, this.localSocket.onclose = function (e) { MBCore.debugEnabled() && MBUtils.mblog_d(n, `WS.onclose - 连接已断开。。。。(isLocalSocketReady=${t.isLocalSocketReady()}, MBClientCoreSDK.connectedToServer=${MBCore.isConnectedToServer()})`, e), MBCore.isConnectedToServer() && (MBCore.debugEnabled && MBUtils.mblog_d(n, 'WS.onclose - 连接已断开，立即提前进入框架的“通信通道”断开处理逻辑(而不是等心跳线程探测到，那就已经比较迟了)......'), MBKeepAliveDaemon.notifyConnectionLost()) }, this.localSocket.onerror = function (e) { MBUtils.mblog_e(n, 'WS.onerror - 异常被触发了，原因是：', e), t.closeLocalSocket(!0) }, this.localSocket.onmessage = function (e) { e = e && e.data || null; MBCore.debugEnabled() && MBUtils.mblog_d(n, `WS.onmessage - 收到消息(原始内容)：${e}`); e = e ? JSON.parse(e) : null; MBDataReciever.handleProtocal(e) }, e = !0) : MBUtils.mblog_w(n, 'Your browser does not support Web Socket.') }
    catch (e) { MBUtils.mblog_w(n, `连接Server(${this._websocketUrl})失败：`, e) } return e
  }, e.prototype.isLocalSocketReady = function () { return this.localSocket != null && this.localSocket.readyState === 1 }, e.prototype.getLocalSocket = function () { return this.isLocalSocketReady() ? this.localSocket : this.resetLocalSocket() }, e.prototype.closeLocalSocket = function (e) {
    const t = e ? `silentClose=${e}` : 'silentClose=false'; MBCore.debugEnabled() && MBUtils.mblog_d(n, `正在closeLocalSocket(${t})...`); const o = this.localSocket; if (this.localSocket) {
      try { e && (o.onerror = null, o.onclose = null, o.onopen = null, o.onmessage = null, MBCore.debugEnabled() && MBUtils.mblog_d(this.TAG, `closeLocalSocket(${t})时，清理socket上的回调函数完成.`)), o.close(), Object.is(o, this.localSocket) && (this.localSocket = null) }
      catch (e) { MBUtils.mblog_w(n, '在closeLocalSocket方法中试图释放localSocket资源时：', e) }
    }
    else { MBUtils.mblog_d(n, 'Socket处于未初化状态（可能是您还未登陆），无需关闭。') }
  }, new e()
}()); const MBUtils = (function () {
  function e(e) {} return e.prototype.formatDate = function (e, t) { let o; const n = { 'M+': e.getMonth() + 1, 'd+': e.getDate(), 'h+': e.getHours(), 'm+': e.getMinutes(), 's+': e.getSeconds(), 'q+': Math.floor((e.getMonth() + 3) / 3), 'S': e.getMilliseconds() }; for (o in /(y+)/.test(t) && (t = t.replace(RegExp.$1, (`${e.getFullYear()}`).substr(4 - RegExp.$1.length))), n) new RegExp(`(${o})`).test(t) && (t = t.replace(RegExp.$1, RegExp.$1.length == 1 ? n[o] : (`00${n[o]}`).substr((`${n[o]}`).length))); return t }, e.prototype.parseDate = function (a, e) { const l = { y: 0, M: 1, d: 0, H: 0, h: 0, m: 0, s: 0, S: 0 }; (e = e || 'yyyy-MM-dd').replace(/([^yMdHmsS]*?)(([yMdHmsS])\3*)([^yMdHmsS]*?)/g, (e, t, o, n, r, i, s) => { return a = a.replace(new RegExp(`${t}(\\d{${o.length}})${r}`), (e, t) => { return l[n] = Number.parseInt(t), '' }), '' }), l.M--; e = new Date(l.y, l.M, l.d, l.H, l.m, l.s); return l.S !== 0 && e.setMilliseconds(l.S), e }, e.prototype.mblog = function (e) { let t; const o = `☀ [${this.formatDate(new Date(), 'MM/dd hh:mm:ss.S')}] [CORE] `; const n = arguments.length; n === 1 ? (t = o + e, console.info(t)) : n >= 2 && (t = o + e, console.info(t, arguments[1])) }, e.prototype.mblog_i = function () { const e = arguments.length; e === 1 ? this.mblog(`<INFO> ${arguments[0]}`) : e === 2 ? this.mblog(`<INFO>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`) : e === 3 && this.mblog(`<INFO>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`, arguments[2]) }, e.prototype.mblog_d = function () { const e = arguments.length; e === 1 ? this.mblog(`<DEBUG> ${arguments[0]}`) : e === 2 ? this.mblog(`<DEBUG>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`) : e === 3 && this.mblog(`<DEBUG>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`, arguments[2]) }, e.prototype.mblog_w = function () { const e = arguments.length; e === 1 ? this.mblog(`<WARN> ${arguments[0]}`) : e === 2 ? this.mblog(`<WARN>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`) : e === 3 && this.mblog(`<WARN>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`, arguments[2]) }, e.prototype.mblog_e = function () { const e = arguments.length; e === 1 ? this.mblog(`<ERROR> ${arguments[0]}`) : e === 2 ? this.mblog(`<ERROR>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`) : e === 3 && this.mblog(`<ERROR>${arguments[0] ? `[${arguments[0]}]` : ''} ${arguments[1]}`, arguments[2]) }, e.prototype.isPositiveInteger = function (e) { return !!/(^[1-9]\d*$)/.test(e) }, e.prototype.getCurrentUTCTimestamp = function () { return (new Date()).getTime() }, e.prototype.send = function (e, t) {
    let o = !1; if (e && t) {
      if (MBCore.debugEnabled() && MBUtils.mblog_d('MBUtils', `正在send() websocket数据时，[dataWithString.len=${t.length}] ...`), e.readyState === 1) {
        try { e.send(t), o = !0, MBCore.debugEnabled() && MBUtils.mblog_i('MBUtils', `>> 数据已成功发出[dataLen=${t.length}].`) }
        catch (e) { MBUtils.mblog_w('MBUtils', 'send方法中》》发送TCP数据报文时出错了，原因是：', e) }
      }
      else { MBUtils.mblog_e('MBUtils', `send方法中》》无法发送websocket数据，原因是：skt.readyState=${e.readyState}`) }
    }
    else { MBUtils.mblog_w('MBUtils', 'send方法中》》无效的参数：skt==null || d == null!') } return o
  }, new e()
}()); const hexcase = 0; const b64pad = ''; const chrsz = 8; function hex_md5(e) { return binl2hex(core_md5(str2binl(e), e.length * chrsz)) } function b64_md5(e) { return binl2b64(core_md5(str2binl(e), e.length * chrsz)) } function str_md5(e) { return binl2str(core_md5(str2binl(e), e.length * chrsz)) } function hex_hmac_md5(e, t) { return binl2hex(core_hmac_md5(e, t)) } function b64_hmac_md5(e, t) { return binl2b64(core_hmac_md5(e, t)) } function str_hmac_md5(e, t) { return binl2str(core_hmac_md5(e, t)) } function md5_vm_test() { return hex_md5('abc') == '900150983cd24fb0d6963f7d28e17f72' } function core_md5(e, t) { e[t >> 5] |= 128 << t % 32, e[14 + (t + 64 >>> 9 << 4)] = t; for (var o = 1732584193, n = -271733879, r = -1732584194, i = 271733878, s = 0; s < e.length; s += 16) { const a = o; const l = n; const c = r; const _ = i; var o = md5_ff(o, n, r, i, e[s + 0], 7, -680876936); var i = md5_ff(i, o, n, r, e[s + 1], 12, -389564586); var r = md5_ff(r, i, o, n, e[s + 2], 17, 606105819); var n = md5_ff(n, r, i, o, e[s + 3], 22, -1044525330); o = md5_ff(o, n, r, i, e[s + 4], 7, -176418897), i = md5_ff(i, o, n, r, e[s + 5], 12, 1200080426), r = md5_ff(r, i, o, n, e[s + 6], 17, -1473231341), n = md5_ff(n, r, i, o, e[s + 7], 22, -45705983), o = md5_ff(o, n, r, i, e[s + 8], 7, 1770035416), i = md5_ff(i, o, n, r, e[s + 9], 12, -1958414417), r = md5_ff(r, i, o, n, e[s + 10], 17, -42063), n = md5_ff(n, r, i, o, e[s + 11], 22, -1990404162), o = md5_ff(o, n, r, i, e[s + 12], 7, 1804603682), i = md5_ff(i, o, n, r, e[s + 13], 12, -40341101), r = md5_ff(r, i, o, n, e[s + 14], 17, -1502002290), o = md5_gg(o, n = md5_ff(n, r, i, o, e[s + 15], 22, 1236535329), r, i, e[s + 1], 5, -165796510), i = md5_gg(i, o, n, r, e[s + 6], 9, -1069501632), r = md5_gg(r, i, o, n, e[s + 11], 14, 643717713), n = md5_gg(n, r, i, o, e[s + 0], 20, -373897302), o = md5_gg(o, n, r, i, e[s + 5], 5, -701558691), i = md5_gg(i, o, n, r, e[s + 10], 9, 38016083), r = md5_gg(r, i, o, n, e[s + 15], 14, -660478335), n = md5_gg(n, r, i, o, e[s + 4], 20, -405537848), o = md5_gg(o, n, r, i, e[s + 9], 5, 568446438), i = md5_gg(i, o, n, r, e[s + 14], 9, -1019803690), r = md5_gg(r, i, o, n, e[s + 3], 14, -187363961), n = md5_gg(n, r, i, o, e[s + 8], 20, 1163531501), o = md5_gg(o, n, r, i, e[s + 13], 5, -1444681467), i = md5_gg(i, o, n, r, e[s + 2], 9, -51403784), r = md5_gg(r, i, o, n, e[s + 7], 14, 1735328473), o = md5_hh(o, n = md5_gg(n, r, i, o, e[s + 12], 20, -1926607734), r, i, e[s + 5], 4, -378558), i = md5_hh(i, o, n, r, e[s + 8], 11, -2022574463), r = md5_hh(r, i, o, n, e[s + 11], 16, 1839030562), n = md5_hh(n, r, i, o, e[s + 14], 23, -35309556), o = md5_hh(o, n, r, i, e[s + 1], 4, -1530992060), i = md5_hh(i, o, n, r, e[s + 4], 11, 1272893353), r = md5_hh(r, i, o, n, e[s + 7], 16, -155497632), n = md5_hh(n, r, i, o, e[s + 10], 23, -1094730640), o = md5_hh(o, n, r, i, e[s + 13], 4, 681279174), i = md5_hh(i, o, n, r, e[s + 0], 11, -358537222), r = md5_hh(r, i, o, n, e[s + 3], 16, -722521979), n = md5_hh(n, r, i, o, e[s + 6], 23, 76029189), o = md5_hh(o, n, r, i, e[s + 9], 4, -640364487), i = md5_hh(i, o, n, r, e[s + 12], 11, -421815835), r = md5_hh(r, i, o, n, e[s + 15], 16, 530742520), o = md5_ii(o, n = md5_hh(n, r, i, o, e[s + 2], 23, -995338651), r, i, e[s + 0], 6, -198630844), i = md5_ii(i, o, n, r, e[s + 7], 10, 1126891415), r = md5_ii(r, i, o, n, e[s + 14], 15, -1416354905), n = md5_ii(n, r, i, o, e[s + 5], 21, -57434055), o = md5_ii(o, n, r, i, e[s + 12], 6, 1700485571), i = md5_ii(i, o, n, r, e[s + 3], 10, -1894986606), r = md5_ii(r, i, o, n, e[s + 10], 15, -1051523), n = md5_ii(n, r, i, o, e[s + 1], 21, -2054922799), o = md5_ii(o, n, r, i, e[s + 8], 6, 1873313359), i = md5_ii(i, o, n, r, e[s + 15], 10, -30611744), r = md5_ii(r, i, o, n, e[s + 6], 15, -1560198380), n = md5_ii(n, r, i, o, e[s + 13], 21, 1309151649), o = md5_ii(o, n, r, i, e[s + 4], 6, -145523070), i = md5_ii(i, o, n, r, e[s + 11], 10, -1120210379), r = md5_ii(r, i, o, n, e[s + 2], 15, 718787259), n = md5_ii(n, r, i, o, e[s + 9], 21, -343485551), o = safe_add(o, a), n = safe_add(n, l), r = safe_add(r, c), i = safe_add(i, _) } return [o, n, r, i] } function md5_cmn(e, t, o, n, r, i) { return safe_add(bit_rol(safe_add(safe_add(t, e), safe_add(n, i)), r), o) } function md5_ff(e, t, o, n, r, i, s) { return md5_cmn(t & o | ~t & n, e, t, r, i, s) } function md5_gg(e, t, o, n, r, i, s) { return md5_cmn(t & n | o & ~n, e, t, r, i, s) } function md5_hh(e, t, o, n, r, i, s) { return md5_cmn(t ^ o ^ n, e, t, r, i, s) } function md5_ii(e, t, o, n, r, i, s) { return md5_cmn(o ^ (t | ~n), e, t, r, i, s) } function core_hmac_md5(e, t) { let o = str2binl(e); o.length > 16 && (o = core_md5(o, e.length * chrsz)); for (var n = Array(16), r = Array(16), i = 0; i < 16; i++)n[i] = 909522486 ^ o[i], r[i] = 1549556828 ^ o[i]; t = core_md5(n.concat(str2binl(t)), 512 + t.length * chrsz); return core_md5(r.concat(t), 640) } function safe_add(e, t) { const o = (65535 & e) + (65535 & t); return (e >> 16) + (t >> 16) + (o >> 16) << 16 | 65535 & o } function bit_rol(e, t) { return e << t | e >>> 32 - t } function str2binl(e) { for (var t = [], o = (1 << chrsz) - 1, n = 0; n < e.length * chrsz; n += chrsz)t[n >> 5] |= (e.charCodeAt(n / chrsz) & o) << n % 32; return t } function binl2str(e) { for (var t = '', o = (1 << chrsz) - 1, n = 0; n < 32 * e.length; n += chrsz)t += String.fromCharCode(e[n >> 5] >>> n % 32 & o); return t } function binl2hex(e) { for (var t = hexcase ? '0123456789ABCDEF' : '0123456789abcdef', o = '', n = 0; n < 4 * e.length; n++)o += t.charAt(e[n >> 2] >> n % 4 * 8 + 4 & 15) + t.charAt(e[n >> 2] >> n % 4 * 8 & 15); return o } function binl2b64(e) { for (var t = '', o = 0; o < 4 * e.length; o += 3) for (let n = (e[o >> 2] >> o % 4 * 8 & 255) << 16 | (e[o + 1 >> 2] >> (o + 1) % 4 * 8 & 255) << 8 | e[o + 2 >> 2] >> (o + 2) % 4 * 8 & 255, r = 0; r < 4; r++)8 * o + 6 * r > 32 * e.length ? t += b64pad : t += 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.charAt(n >> 6 * (3 - r) & 63); return t }!(function () { const r = window; r.IMSDK = { _online: !1, _logined: !1, _debugSDKEnable: !1, _debugPingPongEnable: !1, callback_onIMLog: null, callback_onIMData: null, callback_onIMAfterLoginSucess: null, callback_onIMAfterLoginFailed: null, callback_onIMReconnectSucess: null, callback_onIMDisconnected: null, callback_onIMPing: null, callback_onIMPong: null, callback_onIMShowAlert: null, callback_onIMKickout: null, callback_onMessagesLost: null, callback_onMessagesBeReceived: null, isLogined() { return this._logined }, isOnline() { return this._online }, getLoginInfo() { return MBCore.getCurrentLoginInfo() }, sendData(e) { return MBDataSender.sendCommonData(e) }, disconnectSocket() { let e = MBErrorCode.COMMON_UNKNOW_ERROR; MBCore.getCurrentLoginInfo() != null ? (e = MBDataSender.sendLoginout()) === 0 ? r.IMSDK.callback_onIMLog('[SDK]  注销登陆请求已成功发出！', !0) : r.IMSDK.callback_onIMLog(`[SDK]  注销登陆请求发送失败。错误码是：${e}！`, !0) : MBCore.release(), r.IMSDK._logined = !1 }, setDebugCoreEnable(e) { MBCore.setDebugEnabled(e) }, setDebugSDKEnable(e) { r.IMSDK._debugSDKEnable = e }, setDebugPingPongEnable(e) { r.IMSDK._debugPingPongEnable = e }, loginImpl(e, t) { let o, n; e && t ? (MBCore.setWebsocketUrl(t), MBCore.on(MBSocketEvent.SOCKET_EVENT_ON_LOGIN_RESPONSE, (e) => { let t; e ? (e = e.code, r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  本客户端 SOCKET_EVENT_ON_LOGIN_RESPONSE 事件已经触发（code=${e}）`, !0), e === 0 ? (r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  本客户端 SOCKET_EVENT_ON_LOGIN_RESPONSE 事件中：登陆认证成功(${r.IMSDK._logined ? '掉线重连' : '首次登陆'})！【code=${e}】`, !0), r.IMSDK._online = !0, t = '', r.IMSDK._logined ? (t = '[SDK]  ○ ○ ○ ○ ○【已成功重连至 MobileIMSDK 服务器】○ ○ ○ ○ ○', r.IMSDK.callback_onIMLog(t, !0), r.IMSDK.callback_onIMReconnectSucess()) : (r.IMSDK.callback_onIMAfterLoginSucess(), t = '[SDK]  ● ● ● ● ●【已成功登陆至 MobileIMSDK 服务器】● ● ● ● ●', r.IMSDK.callback_onIMLog(t, !0), r.IMSDK._logined = !0)) : (r.IMSDK._logined ? (t = '掉线重连时认证失败，请退出后重新登陆。。。', r.IMSDK.callback_onIMShowAlert ? r.IMSDK.callback_onIMShowAlert(t) : r.alert(t), r.IMSDK.callback_onIMAfterLoginFailed && r.IMSDK.callback_onIMAfterLoginFailed(!0)) : (r.IMSDK.callback_onIMAfterLoginFailed && r.IMSDK.callback_onIMAfterLoginFailed(!1), r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog('[SDK]  登陆认证失败，请检查您的用户名或密码！')), r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  本客户端的 SOCKET_EVENT_ON_LOGIN_RESPONSE 事件中：登陆认证失败【code=${e}】`, !0))) : r.IMSDK.callback_onIMLog('[SDK]  本客户端的 SOCKET_EVENT_ON_LOGIN_RESPONSE 事件成功返回，但返回的loginInfoResponse是空的！', !0) }), MBCore.on(MBSocketEvent.SOCKET_EVENT_ON_LINK_CLOSE, (e) => { r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog('[SDK]  本客户端 SOCKET_EVENT_ON_LINK_CLOSE 事件已经触发【END】!', !0), r.IMSDK._online = !1, r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog('[SDK]  对不起，你与IM服务器的网络连接断开了（掉线罗）...', !0), r.IMSDK.callback_onIMDisconnected && r.IMSDK.callback_onIMDisconnected() }), MBCore.on(MBSocketEvent.SOCKET_EVENT_ON_RECIEVE_MESSAGE, (e) => { r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  >> 收到[聊天消息]：${JSON.stringify(e)}`, !0), r.IMSDK.callback_onIMData(e) }), MBCore.on(MBSocketEvent.SOCKET_EVENT_ON_ERROR_RESPONSE, (e) => { r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  收到服务端错误消息，errorCode=${e.errorCode}, errorMsg=${e.errorMsg}`, !0), e.errorCode, MBErrorCode.RESPONSE_FOR_UNLOGIN }), MBCore.on(MBSocketEvent.SOCKET_EVENT_MESSAGE_LOST, (e) => { e && e.length > 0 && (r.IMSDK.callback_onIMLog(`[SDK]  收到系统的未实时送达事件通知，当前共有${e.length}个包QoS保证机制结束，判定为【无法实时送达】！`, !0), r.IMSDK.callback_onMessagesLost && r.IMSDK.callback_onMessagesLost(e)) }), MBCore.on(MBSocketEvent.SOCKET_EVENT_MESSAGE_BE_RECIEVED, (e) => { e && (r.IMSDK.callback_onIMLog(`[SDK]  收到对方已收到消息事件的通知，fp=${e}`, !0), r.IMSDK.callback_onMessagesBeReceived && r.IMSDK.callback_onMessagesBeReceived(e)) }), MBCore.on(MBSocketEvent.SOCKET_EVENT_RECONNECT_ATTEMPT, (e) => { r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  本客户端 SOCKET_EVENT_RECONNECT_ATTEMPT 事件已触发 (${e})`, !0) }), MBCore.on(MBSocketEvent.SOCKET_EVENT_PING, () => { r.IMSDK._debugSDKEnable && r.IMSDK._debugPingPongEnable && r.IMSDK.callback_onIMLog('[SDK]  心跳请求已发出 →', !0), r.IMSDK.callback_onIMPing && r.IMSDK.callback_onIMPing() }), MBCore.on(MBSocketEvent.SOCKET_EVENT_PONG, () => { r.IMSDK._debugSDKEnable && r.IMSDK._debugPingPongEnable && r.IMSDK.callback_onIMLog('[SDK]  心跳响应已收到 ←', !0), r.IMSDK.callback_onIMPong && r.IMSDK.callback_onIMPong() }), MBCore.on(MBSocketEvent.SOCKET_EVENT_KICKOUT, (e) => { let t; r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  本客户端 SOCKET_EVENT_KICKOUT 事件已触发，kickoutInfo=${JSON.stringify(e)}`, !0), r.IMSDK.callback_onIMKickout ? r.IMSDK.callback_onIMKickout(e) : (t = '', t = e.code === MBKickoutCode.KICKOUT_FOR_DUPLICATE_LOGIN ? '账号已在其它地方登陆，当前会话已断开，请退出后重新登陆！' : e.code === MBKickoutCode.KICKOUT_FOR_ADMIN ? '已被管理员强行踢出聊天，当前会话已断开！' : `你已被踢出聊天，当前会话已断开（kickoutInfo=${JSON.stringify(e)}）！`, r.IMSDK._debugSDKEnable && r.IMSDK.callback_onIMLog(`[SDK]  ${t}`, !1), r.IMSDK.callback_onIMShowAlert ? r.IMSDK.callback_onIMShowAlert(t) : r.alert(t)), r.IMSDK._logined = !1 }), (o = MBDataSender.sendLogin(e)) === 0 ? r.IMSDK.callback_onIMLog('[SDK]  登陆/连接信息已发出（等待底层Socket反馈和服务端响应中...）！', !0) : (r.IMSDK.callback_onIMLog(`[SDK]  数据发送失败。错误码是：${o}！`, !0), n = `数据发送失败。错误码是：${o}！`, r.IMSDK.callback_onIMShowAlert ? r.IMSDK.callback_onIMShowAlert(n) : r.alert(n))) : (n = `无效的参数：varloginInfo=${e}、wsUrl=${t}`, r.IMSDK.callback_onIMShowAlert ? r.IMSDK.callback_onIMShowAlert(n) : r.alert(n)) } } }())

window.MBProtocalType = MBProtocalType
window.MBErrorCode = MBErrorCode
window.MBSocketEvent = MBSocketEvent
window.MBKickoutCode = MBKickoutCode
window.MBSenseMode = MBSenseMode
window.MBProtocalFactory = MBProtocalFactory

window.MBCore = MBCore

window.MBAutoReLoginDaemon = MBAutoReLoginDaemon

window.MBKeepAliveDaemon = MBKeepAliveDaemon

window.MBQoS4ReciveDaemon = MBQoS4ReciveDaemon

window.MBQoS4SendDaemon = MBQoS4SendDaemon

window.MBDataReciever = MBDataReciever

window.MBDataSender = MBDataSender

window.MBSocketProvider = MBSocketProvider

window.MBUtils = MBUtils

window.hexcase = hexcase
window.b64pad = b64pad
window.chrsz = chrsz
window.hex_md5 = hex_md5
window.hex_md5 = hex_md5
window.str_md5 = str_md5
window.hex_hmac_md5 = hex_hmac_md5
window.b64_hmac_md5 = b64_hmac_md5
window.str_hmac_md5 = str_hmac_md5
window.md5_vm_test = md5_vm_test

window.MBHashMap = MBHashMap
