diff --git a/app.js b/app.js index 19d9cc48e1aaf0bfa4aa50a403d3b4fa91c81e70..724db6be6f586f3ce51d4215858f71404d7882ac 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ //app.js -import GoEasy from './static/lib/goeasy-2.4.7.min'; +import GoEasy from './static/lib/goeasy-2.6.1.esm.min'; App({ onLaunch: function () { diff --git a/static/lib/goeasy-2.4.7.min.js b/static/lib/goeasy-2.4.7.min.js deleted file mode 100644 index 2700d8eb646a9ad95e600ff8d24b4c7104ee57b2..0000000000000000000000000000000000000000 --- a/static/lib/goeasy-2.4.7.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.GoEasy=t():e.GoEasy=t()}(this,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.noop=t.GoEasyDomainNumber=t.goEasyArray=t.UUID=t.calibrator=undefined;var o=n(31),r=n(89),i=n(93),s=n(52);t.calibrator=o.calibrator,t.UUID=r.UUID,t.goEasyArray=i.goEasyArray,t.GoEasyDomainNumber=s.GoEasyDomainNumber,t.noop=function(){}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t["default"]={WRITE:"WRITE",READ:"READ",NONE:"NONE"}},function(e,t,n){"use strict";t.__esModule=!0,t.GoEasyIM=t.PubSub=t.ConversationDTO=t.MessageStatus=t.Scene=t.CallBackOptions=void 0;var o,r=n(12),i=n(66),s=n(0),a=n(98),u=n(6),c=n(160),l=n(161),f=n(162),p=n(163),h=n(165),d=n(167),y=n(16),m=n(8),v=n(10),g=function(){return function(){}}();t.CallBackOptions=g,function(e){e.PRIVATE="private",e.GROUP="group",e.SYSTEM="system"}(o=t.Scene||(t.Scene={})),function(e){e.NEW="new",e.SENDING="sending",e.SUCCESS="success",e.FAIL="fail"}(t.MessageStatus||(t.MessageStatus={}));var b=function(){return function(){}}();t.ConversationDTO=b;var E=function(){function e(e){this.neverConnect=!0,this.options=e}return e.prototype.initialGoEasySocket=function(e){this.goEasySocket=e,this.subscriber.initialGoEasySocket(),this.presence.initialGoEasySocket()},e.prototype.initialBeforeConnect=function(){this.neverConnect=!1,this.publisher=new f["default"](this),this.subscriber=new p["default"](this),this.histories=new c["default"](this),this.presence=new h["default"](this),this.hereNows=new l["default"](this)},e.prototype.validateOptions=function(){var e=this.options;if(!e.modules||!e.modules.includes(a.ModuleTypes.PUBSUB))throw{code:400,content:"Invalid options: module '"+a.ModuleTypes.PUBSUB+"' is not enabled"}},e.prototype.publish=function(e){this.validateOptions(),this.publisher.publish(e)},e.prototype.subscribe=function(e){this.validateOptions(),this.subscriber.subscribe(e)},e.prototype.unsubscribe=function(e){this.validateOptions(),this.subscriber.unsubscribe(e)},e.prototype.subscribePresence=function(e){this.validateOptions(),this.presence.subscribePresence(e)},e.prototype.unsubscribePresence=function(e){this.validateOptions(),this.presence.unsubscribePresence(e)},e.prototype.history=function(e){this.validateOptions(),this.histories.get(e)},e.prototype.hereNow=function(e){this.validateOptions(),this.hereNows.byChannel(e)},e.prototype.hereNowByUserIds=function(e){this.validateOptions(),this.hereNows.byUserId(e)},e}();t.PubSub=E;var _=function(){function e(e){this.options=e}return e.prototype.initialBeforeConnect=function(e){u.im.initialBeforeConnect(e)},e.prototype.initialAfterConnect=function(){u.im.initialAfterConnect()},e.prototype.initialGoEasySocket=function(e){u.im.initialGoEasySocket(e)},e.prototype.validateOptions=function(){var e=this.options;if(!e.modules||!e.modules.includes(a.ModuleTypes.IM))throw Error("Invalid options: module '"+a.ModuleTypes.IM+"' is not enabled")},e.prototype.validateMessageToData=function(e){if(!s.calibrator.isObject(e.to))throw{code:400,content:"TypeError: to requires an object."};if(!s.calibrator.isObject(e.to.data))throw{code:400,content:"TypeError: to.data requires an object."}},e.prototype.on=function(e,t){this.validateOptions(),u.im.on(e,t)},e.prototype.createTextMessage=function(e){return this.validateOptions(),this.validateMessageToData(e),u.im.createTextMessage(e)},e.prototype.createImageMessage=function(e){return this.validateOptions(),this.validateMessageToData(e),u.im.createImageMessage(e)},e.prototype.createFileMessage=function(e){return this.validateOptions(),this.validateMessageToData(e),u.im.createFileMessage(e)},e.prototype.createAudioMessage=function(e){return this.validateOptions(),this.validateMessageToData(e),u.im.createAudioMessage(e)},e.prototype.createVideoMessage=function(e){return this.validateOptions(),this.validateMessageToData(e),u.im.createVideoMessage(e)},e.prototype.createCustomMessage=function(e){return this.validateOptions(),this.validateMessageToData(e),u.im.createCustomMessage(e)},e.prototype.sendMessage=function(e){this.validateOptions(),u.im.sendMessage(e)},e.prototype.recallMessage=function(e){this.validateOptions(),u.im.recallMessage(e)},e.prototype.deleteMessage=function(e){this.validateOptions(),u.im.deleteMessage(e)},e.prototype.markGroupMessageAsRead=function(e){this.validateOptions(),u.im.groupMarkAsRead(e)},e.prototype.markPrivateMessageAsRead=function(e){this.validateOptions(),u.im.privateMarkAsRead(e)},e.prototype.latestConversations=function(e){this.validateOptions(),u.im.latestConversations().then(function(t){m.CallbackUtils.onSuccess(e,t)})["catch"](function(t){m.CallbackUtils.onFailed(e,t)})},e.prototype.removePrivateConversation=function(e){this.validateOptions(),u.im.removePrivateConversation(e)},e.prototype.removeGroupConversation=function(e){this.validateOptions(),u.im.removeGroupConversation(e)},e.prototype.topPrivateConversation=function(e){this.validateOptions(),u.im.topPrivateConversation(e)},e.prototype.topGroupConversation=function(e){this.validateOptions(),u.im.topGroupConversation(e)},e.prototype.history=function(e){this.validateOptions(),u.im.history(e)},e.prototype.subscribeUserPresence=function(e){this.validateOptions(),u.im.subscribeUserPresence(e.userIds).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.unsubscribeUserPresence=function(e){this.validateOptions(),u.im.unsubscribeUserPresence(e.userId).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.hereNow=function(e){this.validateOptions(),u.im.hereNow(e).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.subscribeGroup=function(e){this.validateOptions(),u.im.subscribeGroup(e).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.unsubscribeGroup=function(e){this.validateOptions(),u.im.unsubscribeGroup(e.groupId).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.subscribeGroupPresence=function(e){this.validateOptions(),u.im.subscribeGroupPresence(e.groupIds).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.unsubscribeGroupPresence=function(e){this.validateOptions(),u.im.unsubscribeGroupPresence(e.groupId).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.groupHereNow=function(e){this.validateOptions(),u.im.groupHereNow(e.groupId).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.groupOnlineCount=function(e){this.validateOptions(),u.im.groupOnlineCount(e.groupId).then(function(t){s.calibrator.isFunction(e.onSuccess)&&e.onSuccess(t)})["catch"](function(t){s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e}();t.GoEasyIM=_;var S=function(){function e(t){if(s.calibrator.isDef(e.instance)&&e.instance.getConnectionStatus()!==r["default"].DISCONNECTED)return e.instance;this.validateOptions(t),this.options=t,this.pubsub=new E(this.options),this.im=new _(this.options),this.notification=new d.GoEasyNotification(this.options.allowNotification)}return e.getInstance=function(t){return s.calibrator.isUndef(e.instance)&&(e.instance=new e(t)),e.instance},e.prototype.connect=function(e){this.getConnectionStatus()!==r["default"].DISCONNECTED&&s.calibrator.isObject(e)&&s.calibrator.isFunction(e.onFailed)?e.onFailed({code:408,content:"It is already connected, don't try again until disconnect() is called. "}):(this.confirmUserId(e),v.GoEasyEventCenter.initial(),this.notification.listenNewMessage(),this.pubsub.initialBeforeConnect(),this.im.initialBeforeConnect({id:e.id,data:e.data}),this.goEasySocket=new i["default"](this.options,e),this.im.initialGoEasySocket(this.goEasySocket),this.goEasySocket.connect(this.notification),this.pubsub.initialGoEasySocket(this.goEasySocket),this.im.initialAfterConnect())},e.prototype.disconnect=function(e){this.goEasySocket.disconnect(e).then(function(){s.calibrator.isObject(e)&&s.calibrator.isFunction(e.onSuccess)&&e.onSuccess()})["catch"](function(t){s.calibrator.isObject(e)&&s.calibrator.isFunction(e.onFailed)&&e.onFailed(t)})},e.prototype.getConnectionStatus=function(){return this.goEasySocket?this.goEasySocket.getStatus():r["default"].DISCONNECTED},e.prototype.validateOptions=function(e){var t="";if(!s.calibrator.isObject(e))throw t="options is require an object.",Error(t);if(!s.calibrator.isPrimitive(e.appkey)||0==e.appkey.length)throw t="Invalid options:'host' is empty.",Error(t);if(!s.calibrator.isPrimitive(e.host)||0==e.host.length)throw t="Invalid options:'host' is empty.",Error(t);if(!s.calibrator.isArray(e.modules))throw t="Invalid options: 'modules' must be nonempty array",Error(t);var n=[a.ModuleTypes.IM,a.ModuleTypes.PUBSUB],o=e.modules.map(function(e){var o=e.toUpperCase();if(!n.includes(o))throw t="Invalid options: module '"+e+"' is not support",Error(t);return o});e.modules=o},e.prototype.onClickNotification=function(e){this.notification.onClickNotification(e)},e.prototype.confirmUserId=function(e){if(this.options.modules.includes(a.ModuleTypes.IM)&&(s.calibrator.isEmpty(e.id)||!s.calibrator.isStringOrNumber(e.id)))throw{code:400,content:"TypeError: id requires number or string."};if("string"==typeof e.id&&e.id.length>60)throw{code:400,content:"id over max length 60"}},e.version="2.4.7",e.IM_EVENT=y.ImApiEvents,e.IM_SCENE=o,e}();t["default"]=S},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=function(){function e(e,t){for(var n=0;n1?{type:u[o],data:e.substring(1)}:{type:u[o]}:c}o=new Uint8Array(e)[0];var r=sliceBuffer(e,1);return l&&"blob"===t&&(r=new l([r])),{type:u[o],data:r}},t.encodePayload=function(e,n,o){"function"==typeof n&&(o=n,n=null);var s=r(e);if(!e.length)return o("0:");!function(e,t,n){for(var o=new Array(e.length),r=i(e.length,n),s=function(e,n,r){t(n,function(t,n){o[e]=n,r(t,o)})},a=0;a=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};t.__esModule=!0,t.FrameworkDetector=t.Framework=void 0;var r,i=n(23);!function(e){e.UNIAPP="UNIAPP",e.REACT_NATIVE="REACT_NATIVE",e.TARO="TARO",e.IONIC="IONIC",e.NATIVE_APPLET_WX="NATIVE_APPLET_WX",e.NATIVE_APPLET_ALIPAY="NATIVE_APPLET_ALIPAY",e.UNKNOWN="UNKNOWN"}(r=t.Framework||(t.Framework={}));var s=function(){function t(){var e,t,n;this.framework=null,this.methods=((e={})[r.UNIAPP]=this.isUniApp,e[r.REACT_NATIVE]=this.isReactNative,e[r.NATIVE_APPLET_WX]=this.isWXApplet,e);var i=this.methods,s=Object.keys(i);try{for(var a=o(s),u=a.next();!u.done;u=a.next()){var c=u.value;if((0,i[c])()){this.framework=c;break}}}catch(l){t={error:l}}finally{try{u&&!u.done&&(n=a["return"])&&n.call(a)}finally{if(t)throw t.error}}this.framework=this.framework||r.UNKNOWN,this.framework}return t.currentFramework=function(){return this.instance.framework},t.prototype.isUniApp=function(){return"object"==typeof uni&&!!uni.getSystemInfoSync},t.prototype.isReactNative=function(){return void 0!==e&&e.__fbGenNativeModule},t.prototype.isTaro=function(){return!1},t.prototype.isWXApplet=function(){return i.PlatformDetector.currentPlatform()===i.Platform.APPLET_WX&&"undefined"==typeof uni},t.instance=new t,t}();t.FrameworkDetector=s}).call(this,n(28))},function(e,t,n){"use strict";t.__esModule=!0,t.MessageType=void 0,function(e){e.TEXT="text",e.IMAGE="image",e.FILE="file",e.VIDEO="video",e.AUDIO="audio"}(t.MessageType||(t.MessageType={}))},function(e,t,n){"use strict";t.__esModule=!0,t.IM_INTERNAL_EVENTS=void 0,function(e){e.MESSAGE_SENDING="IM_INTERNAL_MESSAGE_SENDING",e.MESSAGE_SEND_SUCCESS="IM_INTERNAL_MESSAGE_SEND_SUCCESS",e.MESSAGE_RECEIVED="IM_INTERNAL_MESSAGE_RECEIVED",e.REMOTE_MESSAGE_READ="IM_INTERNAL_REMOTE_MESSAGE_READ",e.REMOTE_MESSAGE_DELETED="IM_INTERNAL_REMOTE_MESSAGE_DELETED",e.MAX_MESSAGE_CHANGED="IM_INTERNAL_MAX_MESSAGE_CHANGED",e.UNREAD_MESSAGE_CHANGED="IM_INTERNAL_UNREAD_MESSAGE_CHANGED",e.REMOTE_MESSAGE_RECALLED="IM_INTERNAL_REMOTE_MESSAGE_RECALLED"}(t.IM_INTERNAL_EVENTS||(t.IM_INTERNAL_EVENTS={}))},function(e,t,n){"use strict";t.__esModule=!0,t.AbstractMessage=void 0;var o=function(){function e(){}return e.prototype.clearUseLessAttribute=function(){delete this.buildOptions},e}();t.AbstractMessage=o},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.FileMessagePayload=void 0;var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.contentType="",t.name="",t.size=0,t.url="",t}return r(t,e),t}(n(25).AbstractMessagePayload);t.FileMessagePayload=i},function(e,t,n){"use strict";var o,r=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};t.__esModule=!0,t.PlatformDetector=t.Platform=void 0,function(e){e.BROWSER="BROWSER",e.UNKNOWN="UNKNOWN",e.APP_IOS="APP_IOS",e.APP_ANDROID="APP_ANDROID",e.APPLET_WX="APPLET_WX",e.APPLET_WX_GAME="APPLET_WX_GAME",e.APPLET_ALIPAY="APPLET_ALIPAY",e.APPLET_BYTEDANCE="APPLET_BYTEDANCE"}(o=t.Platform||(t.Platform={}));var i=function(){function e(){var e,t,n;this.platform=null,this.methods=((e={})[o.BROWSER]=this.isBrowser,e[o.APP_IOS]=this.isAppiOS,e[o.APP_ANDROID]=this.isAppAndroid,e[o.APPLET_WX]=this.isWXApplet,e[o.APPLET_WX_GAME]=this.isWXGameApplet,e);var i=this.methods,s=Object.keys(i);try{for(var a=r(s),u=a.next();!u.done;u=a.next()){var c=u.value;if((0,i[c])()){this.platform=c;break}}}catch(l){t={error:l}}finally{try{u&&!u.done&&(n=a["return"])&&n.call(a)}finally{if(t)throw t.error}}this.platform=this.platform||o.UNKNOWN,this.platform}return e.currentPlatform=function(){return e.instance.platform},e.prototype.isBrowser=function(){return"undefined"!=typeof navigator&&"undefined"!=typeof document&&!!document.getElementById&&"undefined"==typeof GameGlobal},e.prototype.isAppiOS=function(){return"object"==typeof uni&&!!uni.getSystemInfoSync&&"ios"===uni.getSystemInfoSync().platform&&"object"==typeof plus},e.prototype.isAppAndroid=function(){return"object"==typeof uni&&!!uni.getSystemInfoSync&&"android"===uni.getSystemInfoSync().platform&&"object"==typeof plus},e.prototype.isWXApplet=function(){return"object"==typeof wx&&!!wx.getSystemInfoSync&&"undefined"==typeof WebSocket&&"undefined"==typeof XMLHttpRequest&&"undefined"==typeof plus},e.prototype.isWXGameApplet=function(){return"object"==typeof GameGlobal},e.prototype.isAlipayApplet=function(){return!1},e.prototype.isBytedanceApplet=function(){return!1},e.prototype.isQQApplet=function(){return!1},e.prototype.isBaiduApplet=function(){return!1},e.instance=new e,e}();t.PlatformDetector=i},function(e,t){t.encode=function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},t.decode=function(e){for(var t={},n=e.split("&"),o=0,r=n.length;o=0&&Math.floor(t)===t&&isFinite(e)}},{key:"isStringOrNumber",value:function(e){return"string"==typeof e||"number"==typeof e}},{key:"isString",value:function(e){return"string"==typeof e}},{key:"isNumber",value:function(e){return"number"==typeof e}},{key:"isArray",value:function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{key:"isEmpty",value:function(e){return this.isArray(e)?0==e.length:this.isObject(e)?!this.isDef(e):!this.isNumber(e)&&(this.isString(e)?""==e.trim():!this.isDef(e))}},{key:"isNative",value:function(e){return"function"==typeof e&&/native code/.test(e.toString())}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isBoolean",value:function(e){return"boolean"==typeof e}}]),e}());t.calibrator=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n31457280)throw Error("message-length limit 30mib")},t}(i.AbstractPayloadBuilder);t["default"]=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},y.prototype.cleanup=function(){for(var e=this.subs.length,t=0;t=this._reconnectionAttempts)this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();this.reconnecting=!0;var n=setTimeout(function(){e.skipReconnect||(e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||(m()?(e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error","Uniapp running backend, skipped reconnect...")):e.open(function(t){t?(e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):e.onreconnect()})))},t);this.subs.push({destroy:function(){clearTimeout(n)}})}},y.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)}},function(e,t,n){"use strict";var o=n(72),r=n(83);t.polling=function(e){var t=!1,n=!1;e.jsonp;if("undefined"!=typeof location){var r="https:"===location.protocol,i=location.port;i||(i=r?443:80),t=e.hostname!==location.hostname||i!==e.port,n=e.secure!==r}return e.xdomain=t,e.xscheme=n,new o(e)},t.websocket=r},function(e,t,n){(function(t){var o=n(42),r=Object.prototype.toString,i="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===r.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===r.call(File);e.exports=function a(e){if(!e||"object"!=typeof e)return!1;if(o(e)){for(var n=0,r=e.length;n=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function d(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case undefined:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return L(e).length;default:if(o)return G(e).length;t=(""+t).toLowerCase(),o=!0}}function y(e,t,n){var o=e[t];e[t]=e[n],e[n]=o}function m(e,t,n,o,r){if(0===e.length)return-1;if("string"==typeof n?(o=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=r?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(r)return-1;n=e.length-1}else if(n<0){if(!r)return-1;n=0}if("string"==typeof t&&(t=u.from(t,o)),u.isBuffer(t))return 0===t.length?-1:v(e,t,n,o,r);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?r?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):v(e,[t],n,o,r);throw new TypeError("val must be string, number or Buffer")}function v(e,t,n,o,r){var i,s=1,a=e.length,u=t.length;if(o!==undefined&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s=2,a/=2,u/=2,n/=2}function c(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(r){var l=-1;for(i=n;ia&&(n=a-u),i=n;i>=0;i--){for(var f=!0,p=0;pr&&(o=r):o=r;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");o>i/2&&(o=i/2);for(var s=0;s>8,r=n%256,i.push(r),i.push(o);return i}(t,e.length-n),e,n,o)}function O(e,t,n){return 0===t&&n===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(t,n))}function M(e,t,n){n=Math.min(e.length,n);for(var o=[],r=t;r239?4:c>223?3:c>191?2:1;if(r+f<=n)switch(f){case 1:c<128&&(l=c);break;case 2:128==(192&(i=e[r+1]))&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=e[r+1],s=e[r+2],128==(192&i)&&128==(192&s)&&(u=(15&c)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=e[r+1],s=e[r+2],a=e[r+3],128==(192&i)&&128==(192&s)&&128==(192&a)&&(u=(15&c)<<18|(63&i)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(l=u)}null===l?(l=65533,f=1):l>65535&&(l-=65536,o.push(l>>>10&1023|55296),l=56320|1023&l),o.push(l),r+=f}return function(e){var t=e.length;if(t<=T)return String.fromCharCode.apply(String,e);var n="",o=0;for(;othis.length)return"";if((n===undefined||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return P(this,t,n);case"utf8":case"utf-8":return M(this,t,n);case"ascii":return k(this,t,n);case"latin1":case"binary":return I(this,t,n);case"base64":return O(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,n);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",n=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},u.prototype.compare=function(e,t,n,o,r){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(t===undefined&&(t=0),n===undefined&&(n=e?e.length:0),o===undefined&&(o=0),r===undefined&&(r=this.length),t<0||n>e.length||o<0||r>this.length)throw new RangeError("out of range index");if(o>=r&&t>=n)return 0;if(o>=r)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,o>>>=0,r>>>=0,this===e)return 0;for(var i=r-o,s=n-t,a=Math.min(i,s),c=this.slice(o,r),l=e.slice(t,n),f=0;fr)&&(n=r),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var i=!1;;)switch(o){case"hex":return g(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return E(this,e,t,n);case"latin1":case"binary":return _(this,e,t,n);case"base64":return S(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return w(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function k(e,t,n){var o="";n=Math.min(e.length,n);for(var r=t;ro)&&(n=o);for(var r="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function R(e,t,n,o,r,i){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>r||te.length)throw new RangeError("Index out of range")}function N(e,t,n,o){t<0&&(t=65535+t+1);for(var r=0,i=Math.min(e.length-n,2);r>>8*(o?r:1-r)}function D(e,t,n,o){t<0&&(t=4294967295+t+1);for(var r=0,i=Math.min(e.length-n,4);r>>8*(o?r:3-r)&255}function x(e,t,n,o,r,i){if(n+o>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function U(e,t,n,o,i){return i||x(e,0,n,4),r.write(e,t,n,o,23,4),n+4}function j(e,t,n,o,i){return i||x(e,0,n,8),r.write(e,t,n,o,52,8),n+8}u.prototype.slice=function(e,t){var n,o=this.length;if(e=~~e,t=t===undefined?o:~~t,e<0?(e+=o)<0&&(e=0):e>o&&(e=o),t<0?(t+=o)<0&&(t=0):t>o&&(t=o),t0&&(r*=256);)o+=this[e+--t]*r;return o},u.prototype.readUInt8=function(e,t){return t||C(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||C(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||C(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||C(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||C(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||C(e,t,this.length);for(var o=this[e],r=1,i=0;++i=(r*=128)&&(o-=Math.pow(2,8*t)),o},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||C(e,t,this.length);for(var o=t,r=1,i=this[e+--o];o>0&&(r*=256);)i+=this[e+--o]*r;return i>=(r*=128)&&(i-=Math.pow(2,8*t)),i},u.prototype.readInt8=function(e,t){return t||C(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||C(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||C(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt32LE=function(e,t){return t||C(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||C(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||C(e,4,this.length),r.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||C(e,4,this.length),r.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||C(e,8,this.length),r.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||C(e,8,this.length),r.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,n,o){(e=+e,t|=0,n|=0,o)||R(this,e,t,n,Math.pow(2,8*n)-1,0);var r=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+r]=e/i&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):D(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);R(this,e,t,n,r-1,-r)}var i=0,s=1,a=0;for(this[t]=255&e;++i>0)-a&255;return t+n},u.prototype.writeIntBE=function(e,t,n,o){if(e=+e,t|=0,!o){var r=Math.pow(2,8*n-1);R(this,e,t,n,r-1,-r)}var i=n-1,s=1,a=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===a&&0!==this[t+i+1]&&(a=1),this[t+i]=(e/s>>0)-a&255;return t+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):D(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||R(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):D(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return U(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return U(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return j(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return j(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,o){if(n||(n=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t=0;--r)e[r+t]=this[r+n];else if(i<1e3||!u.TYPED_ARRAY_SUPPORT)for(r=0;r>>=0,n=n===undefined?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&n<57344){if(!r){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(t-=3)>-1&&i.push(239,191,189);continue}r=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),r=n;continue}n=65536+(r-55296<<10|n-56320)}else r&&(t-=3)>-1&&i.push(239,191,189);if(r=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function L(e){return o.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(F,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,n,o){for(var r=0;r=t.length||r>=e.length);++r)t[r+n]=e[r];return r}}).call(this,n(28))},function(e,t,n){"use strict";var o,r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),i=64,s={},a=0,u=0;function c(e){var t="";do{t=r[e%i]+t,e=Math.floor(e/i)}while(e>0);return t}function l(){var e=c(+new Date);return e!==o?(a=0,o=e):e+"."+c(a++)}for(;u0&&o=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};t.__esModule=!0,t.LocalStorageDispatcher=void 0;var r=n(88),i=function(){function e(){this.domain=null;this.domain="undefined"!=typeof location&&/^(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/.test(location.host)?location.host.split(".").slice(-2).join("."):null}return e.prototype.get=function(e){var t=r.Cookie.get(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){var n=new Date(2030,12,31,0,0,0,0),o=this.domain;r.Cookie.set(e,JSON.stringify(t),n,o)},e.prototype.remove=function(e){var t=this.domain;r.Cookie.remove(e,t)},e.prototype.support=function(){return"undefined"!=typeof navigator&&!0===navigator.cookieEnabled},e}(),s=function(){function e(){}return e.prototype.get=function(e){var t=localStorage.getItem(e);return JSON.parse(t)},e.prototype.put=function(e,t){var n=localStorage.setItem(e,JSON.stringify(t));JSON.stringify(n)},e.prototype.remove=function(e){localStorage.removeItem(e)},e.prototype.support=function(){return!("undefined"!=typeof GameGlobal||"undefined"==typeof localStorage||!localStorage.setItem)},e}(),a=function(){function e(){}return e.prototype.get=function(e){var t=uni.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){uni.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){uni.removeStorageSync(e)},e.prototype.support=function(){return!("object"!=typeof uni||!uni.getStorageSync)},e}(),u=function(){function e(){}return e.prototype.get=function(e){var t=wx.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){wx.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){wx.removeStorageSync(e)},e.prototype.support=function(){return!("object"!=typeof wx||!wx.getStorageSync)},e}(),c=(function(){function e(){}e.prototype.get=function(e){var t=my.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){my.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){my.removeStorageSync(e)},e.prototype.support=function(){return!("undefined"==typeof my||!my.getStorageSync)}}(),function(){function e(){}e.prototype.get=function(e){var t=qq.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){qq.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){qq.removeStorageSync(e)},e.prototype.support=function(){return!("undefined"==typeof qq||!qq.getStorageSync)}}(),function(){function e(){}e.prototype.get=function(e){var t=tt.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){tt.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){tt.removeStorageSync(e)},e.prototype.support=function(){return!("object"!=typeof tt||!tt.getStorageSync)}}(),function(){function e(){}e.prototype.get=function(e){var t=swan.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){swan.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){swan.removeStorageSync(e)},e.prototype.support=function(){return!("undefined"==typeof swan||!swan.getStorageSync)}}(),function(){function e(){this.api=e.dispatch(),this.api}e.dispatch=function(){var e=new s,t=new i;return e.support()?e:t},e.prototype.get=function(e){return this.api.get(e)},e.prototype.put=function(e,t){this.api.put(e,t)},e.prototype.remove=function(e){this.api.remove(e)},e.prototype.support=function(){return"undefined"!=typeof localStorage}}(),function(){function e(){this.supportedStorage=null;var t=e.storages;t.push(new a),t.push(new s),t.push(new u),t.push(new i),this.dispatch(),this.supportedStorage}return e.localStorage=function(){return this.instance.supportedStorage},e.prototype.dispatch=function(){var t,n;try{for(var r=o(e.storages),i=r.next();!i.done;i=r.next()){var s=i.value;if(s.support()){this.supportedStorage=s;break}}}catch(a){t={error:a}}finally{try{i&&!i.done&&(n=r["return"])&&n.call(r)}finally{if(t)throw t.error}}},e.storages=new Array,e.instance=new e,e}());t.LocalStorageDispatcher=c},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=function(){function e(e,t){for(var n=0;n=0)e.splice(n,1,t);else{var o=-n-1;e.splice(o,0,t)}},e.prototype.binarySearch=function(e,t){for(var n=0,o=e.length-1;n<=o;){var r=o+n>>1,i=this.compare(t,e[r]);if(i>0)n=r+1;else{if(!(i<0))return r;o=r-1}}return-n-1},e}();t.SortedInserter=o},function(e,t,n){"use strict";t.__esModule=!0;var o=n(6),r=n(21),i=n(0),s=n(2),a=n(149),u=n(3),c=n(1),l=n(4),f=n(5),p=n(8),h=n(17),d=function(){function e(){}return e.deleteServerMessages=function(e){var t=new a.DeleteMessageRequest(e);return t.times.length<0?Promise.resolve():new Promise(function(e,n){var r=new u["default"]({name:f.RocketTypes.IM_DELETE_MESSAGE,params:t,permission:c["default"].WRITE,singleTimeout:l.SocketTimeout.commonQuerySingle,totalTimeout:l.SocketTimeout.commonQueryTotal,success:function(t){200===t.code?e(t):n(t)},fail:function(e){n(e)}});o.im._goEasySocket.emit(r)})},e.validate=function(e){if(p.CallbackUtils.validateCallbackOptions(e),!i.calibrator.isArray(e.messages)||i.calibrator.isEmpty(e.messages))throw{code:400,content:"messages requires non empty array"};var t=e.messages;if(t.length>50)throw{code:400,content:"a maximum of 50 messages can be deleted at a time"};for(var n=h.Target.byIMMessage(t[0]),o=0;o0){var u=h.Target.byIMMessage(a);if(u.scene!==n.scene||u.id!==n.id)throw{code:400,content:"each message must be from the same friend or group"}}}},e}();t["default"]=d},function(e,t,n){"use strict";t.__esModule=!0;var o=n(2),r=n(6),i=function(){function e(){}return e.conversationId=function(e,t,n){var r=n;return e===o.Scene.PRIVATE&&(r=t+":"+n),r},e.targetId=function(e,t){if(e===o.Scene.PRIVATE){var n=t.split(":",2);return n[0]===r.IM.userId?n[1]:n[0]}return t},e}();t["default"]=i},function(e,t,n){"use strict";t.__esModule=!0;var o=n(6),r=n(2),i=n(155),s=n(3),a=n(1),u=n(4),c=n(21),l=n(0),f=n(5),p=n(8),h=n(17),d=function(){function e(){}return e.recallServerMessages=function(e){var t=new i.RecallMessageRequest(e);return 0===t.times.length?Promise.resolve():new Promise(function(e,n){var r=new s["default"]({name:f.RocketTypes.IM_RECALL_MESSAGE,params:t,permission:a["default"].WRITE,singleTimeout:u.SocketTimeout.commonRequestSingle,totalTimeout:u.SocketTimeout.commonRequestTotal,fail:function(e){n(e)},success:function(t){200===t.code?e(t):n(t)}});o.im._goEasySocket.emit(r)})},e.validate=function(e){p.CallbackUtils.validateCallbackOptions(e);var t,n=e.messages;if(!l.calibrator.isArray(n)||l.calibrator.isEmpty(n))throw{code:400,content:"messages requires non empty array"};if(n.length>50)throw{code:400,content:"a maximum of 50 messages can be recalled at a time"};for(var i=0;i0){var a=h.Target.byIMMessage(s);if(a.scene!==t.scene||a.id!==t.id)throw{code:400,content:"each message must be from the same friend or group"}}else t=h.Target.byIMMessage(s)}},e}();t["default"]=d},function(e,t,n){"use strict";t.__esModule=!0,t.PUBSUB_INTERNAL_EVENTS=void 0,function(e){e.MESSAGE_RECEIVED="PUBSUB_INTERNAL_MESSAGE_RECEIVED"}(t.PUBSUB_INTERNAL_EVENTS||(t.PUBSUB_INTERNAL_EVENTS={}))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n300){if(f.calibrator.isObject(e)&&f.calibrator.isFunction(e.onFailed))throw{code:400,content:"user.data-length limit 300 byte."}}else this.userData=e.data;this.otp=e.otp||null}},{key:"setUriAndOpts",value:function(e){var t=!0;if(d.PlatformDetector.currentPlatform()===d.Platform.BROWSER){var n="://"+f.GoEasyDomainNumber.refreshNumber()+e.host,o=void 0;!0===e.supportOldBrowser?(o=["polling","websocket"],t=!1):o=["websocket"],!1!==e.forceTLS&&t?this.uri="https"+n+":443":this.uri="http"+n+":80",this.ioOpts={transports:o,timeout:p.SocketTimeout.connect}}else this.uri="https://wx-"+e.host+":443",this.ioOpts={transports:["websocket"],reconnectionDelayMax:p.SocketTimeout.reconnectionDelayMax}}},{key:"onIoReconnected",value:function(){this.status===c["default"].RECONNECTING&&this.authorize()}},{key:"emit",value:function(e){r(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"emit",this).call(this,e)}},{key:"doEmit",value:function(e,t,n){t.sid=this.sid,this.ioSocket.doEmit(e,t,n)}},{key:"sendAck",value:function(e,t){this.ioSocket.io.emit(e,t)}},{key:"connect",value:function(e){var n=this;r(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"connect",this).call(this),this.onConnecting(this.reconnectingTimes),this.ioSocket.connect({uri:this.uri,opts:this.ioOpts}),e&&e.supportNotification()&&e.getRegIdPromise()?e.getRegIdPromise().then(function(e){n.regId=e,n.authorize()})["catch"](function(e){console.warn("Failed to register the Manufacturers Push service:"+JSON.stringify(e)),n.authorize()}):this.authorize()}},{key:"disconnect",value:function(){var e=this;return new Promise(function(t,n){var o=function(){e.status=c["default"].DISCONNECTED,e.ioSocket.disconnect(),t()};if(e.allowNotification){var r=new a["default"]({name:v.RocketTypes.manualDisconnect,params:{},permission:u["default"].READ,singleTimeout:p.SocketTimeout.commonRequestSingle,totalTimeout:p.SocketTimeout.commonRequestTotal,fail:function(e){n(e)},success:o});e.emit(r)}else o()})}},{key:"authorize",value:function(){var e={appkey:this.appKey,userId:this.userId,userData:JSON.stringify(this.userData),otp:this.otp,artifactVersion:this.artifactVersion,sid:this.sid,allowNT:this.allowNotification,regId:this.regId,modules:this.modules,a:this.anonymous,z:m.clientInfo.z};JSON.stringify(e);var t=new a["default"]({name:v.RocketTypes.authorize,params:e,permission:u["default"].NONE,singleTimeout:p.SocketTimeout.commonInfiniteSingle,totalTimeout:p.SocketTimeout.commonInfiniteTotal,success:this.onAuthorizeSuccess.bind(this),fail:this.onAuthorizeFailed.bind(this)});this.ioSocket.emit(t)}},{key:"onConnecting",value:function(){this.notify(this.connectingObservers,this.reconnectingTimes)}},{key:"onIoReconnecting",value:function(){this.reconnectingTimes++,this.status==c["default"].CONNECTED||this.status==c["default"].EXPIRED_RECONNECTED||this.status==c["default"].RECONNECTING?this.status=c["default"].RECONNECTING:this.status=c["default"].CONNECTING,this.onConnecting()}},{key:"onIoDisconnected",value:function(){this.status==c["default"].DISCONNECTING&&(this.status=c["default"].DISCONNECTED,this.notify(this.disconnectedObservers)),this.notify(this.disconnectedObservers)}},{key:"onAuthorizeSuccess",value:function(e){(!0===this.anonymous&&e.u&&(y.AnonymousUserIdRepository.put(e.u),this.userId=e.u),this.status===c["default"].RECONNECTING)?this.sid!==e.sid?(this.status=c["default"].EXPIRED_RECONNECTED,this.notify(this.expiredReconnectedObservers)):this.status=c["default"].RECONNECTED:(this.status=c["default"].CONNECTED,this.sid=e.sid);e.enablePublish&&(this.permissions.find(function(e){return e==u["default"].WRITE})||this.permissions.push(u["default"].WRITE)),e.enableSubscribe&&(this.permissions.find(function(e){return e==u["default"].READ})||this.permissions.push(u["default"].READ)),this.reconnectingTimes=0,this.notify(this.connectedObservers)}},{key:"onAuthorizeFailed",value:function(e){this.ioSocket.disconnect(),this.status=c["default"].CONNECT_FAILED;var t={code:e.resultCode||408,content:e.content||"Host unreachable or timeout"};this.notify(this.connectFailedObservers,t)}},{key:"addConnectingObserver",value:function(e){f.calibrator.isFunction(e)&&this.connectingObservers.push(e)}},{key:"addConnectFailedObserver",value:function(e){f.calibrator.isFunction(e)&&this.connectFailedObservers.push(e)}},{key:"addExpiredReconnectedObserver",value:function(e){f.calibrator.isFunction(e)&&this.expiredReconnectedObservers.push(e)}},{key:"addMessageObserver",value:function(e,t){var n=this;this.ioSocket.io.on(e,function(t){n.notifyMessageObservers(e,t)}),this.messageObservers[e]||(this.messageObservers[e]=[]),this.messageObservers[e].push(new l["default"](t))}},{key:"notifyMessageObservers",value:function(e,t){for(var n=this.messageObservers[e],o=0;o0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}e.exports=l,l.priorWebsocketSuccess=!1,i(l.prototype),l.protocol=a.protocol,l.Socket=l,l.Transport=n(29),l.transports=n(44),l.parser=n(14),l.prototype.createTransport=function(e){var t=function(e){var t={};for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}(this.query);t.EIO=a.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new r[e]({query:t,socket:this,agent:n.agent||this.agent,hostname:n.hostname||this.hostname,port:n.port||this.port,secure:n.secure||this.secure,path:n.path||this.path,forceJSONP:n.forceJSONP||this.forceJSONP,jsonp:n.jsonp||this.jsonp,forceBase64:n.forceBase64||this.forceBase64,enablesXDR:n.enablesXDR||this.enablesXDR,timestampRequests:n.timestampRequests||this.timestampRequests,timestampParam:n.timestampParam||this.timestampParam,policyPort:n.policyPort||this.policyPort,pfx:n.pfx||this.pfx,key:n.key||this.key,passphrase:n.passphrase||this.passphrase,cert:n.cert||this.cert,ca:n.ca||this.ca,ciphers:n.ciphers||this.ciphers,rejectUnauthorized:n.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:n.perMessageDeflate||this.perMessageDeflate,extraHeaders:n.extraHeaders||this.extraHeaders,forceNode:n.forceNode||this.forceNode,localAddress:n.localAddress||this.localAddress,requestTimeout:n.requestTimeout||this.requestTimeout,protocols:n.protocols||void 0,isReactNative:this.isReactNative})},l.prototype.open=function(){var e;if(this.rememberUpgrade&&l.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout(function(){t.emit("error","No transports available")},0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(n){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},l.prototype.setTransport=function(e){e.name;var t=this;this.transport&&(this.transport.name,this.transport.removeAllListeners()),this.transport=e,e.on("drain",function(){t.onDrain()}).on("packet",function(e){t.onPacket(e)}).on("error",function(e){t.onError(e)}).on("close",function(){t.onClose("transport close")})},l.prototype.probe=function(e){var t=this.createTransport(e,{probe:1}),n=!1,o=this;function r(){if(o.onlyBinaryUpgrades){var e=!this.supportsBinary&&o.transport.supportsBinary;n=n||e}n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",function(e){if(!n)if("pong"===e.type&&"probe"===e.data){if(o.upgrading=!0,o.emit("upgrading",t),!t)return;l.priorWebsocketSuccess="websocket"===t.name,o.transport.name,o.transport.pause(function(){n||"closed"!==o.readyState&&(f(),o.setTransport(t),t.send([{type:"upgrade"}]),o.emit("upgrade",t),t=null,o.upgrading=!1,o.flush())})}else{var r=new Error("probe error");r.transport=t.name,o.emit("upgradeError",r)}}))}function i(){n||(n=!0,f(),t.close(),t=null)}function s(e){var n=new Error("probe error: "+e);n.transport=t.name,i(),o.emit("upgradeError",n)}function a(){s("transport closed")}function u(){s("socket closed")}function c(e){t&&e.name!==t.name&&(e.name,t.name,i())}function f(){t.removeListener("open",r),t.removeListener("error",s),t.removeListener("close",a),o.removeListener("close",u),o.removeListener("upgrading",c)}l.priorWebsocketSuccess=!1,t.once("open",r),t.once("error",s),t.once("close",a),this.once("close",u),this.once("upgrading",c),t.open()},l.prototype.onOpen=function(){if(this.readyState="open",l.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause)for(var e=0,t=this.upgrades.length;e';o=document.createElement(e)}catch(t){(o=document.createElement("iframe")).name=n.iframeId,o.src="javascript:0"}o.id=n.iframeId,n.form.appendChild(o),n.iframe=o}this.form.action=this.uri(),l(),e=e.replace(a,"\\\n"),this.area.value=e.replace(s,"\\n");try{this.form.submit()}catch(f){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&c()}:this.iframe.onload=c}}).call(this,n(28))},function(e,t,n){"use strict";var o=n(29),r=n(24),i=n(14),s=n(30),a=n(47);n(9)("engine.io-client:polling");e.exports=c;var u=null!=new(n(81))({xdomain:!1}).responseType;function c(e){var t=e&&e.forceBase64;u&&!t||(this.supportsBinary=!1),o.call(this,e)}s(c,o),c.prototype.name="polling",c.prototype.doOpen=function(){this.poll()},c.prototype.pause=function(e){var t=this;function n(){t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var o=0;this.polling&&(o++,this.once("pollComplete",function(){--o||n()})),this.writable||(o++,this.once("drain",function(){--o||n()}))}else n()},c.prototype.poll=function(){this.polling=!0,this.doPoll(),this.emit("poll")},c.prototype.onData=function(e){var t=this;i.decodePayload(e,this.socket.binaryType,function(e,n,o){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():this.readyState)},c.prototype.doClose=function(){var e=this;function t(){e.write([{type:"close"}])}"open"===this.readyState?t():this.once("open",t)},c.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};i.encodePayload(e,this.supportsBinary,function(e){t.doWrite(e,n)})},c.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=a()),this.supportsBinary||e.sid||(e.b64=1),e=r.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(n=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e}},function(e,t,n){"use strict";e.exports=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var o in e)n.call(e,o)&&t.push(o);return t}},function(e,t,n){"use strict";t.byteLength=function(e){var t=c(e),n=t[0],o=t[1];return 3*(n+o)/4-o},t.toByteArray=function(e){var t,n,o=c(e),s=o[0],a=o[1],u=new i(function(e,t,n){return 3*(t+n)/4-n}(0,s,a)),l=0,f=a>0?s-4:s;for(n=0;n>16&255,u[l++]=t>>8&255,u[l++]=255&t;2===a&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,u[l++]=255&t);1===a&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,u[l++]=t>>8&255,u[l++]=255&t);return u},t.fromByteArray=function(e){for(var t,n=e.length,r=n%3,i=[],s=0,a=n-r;sa?a:s+16383));1===r?(t=e[n-1],i.push(o[t>>2]+o[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],i.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"="));return i.join("")};for(var o=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,u=s.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function l(e,t,n){for(var r,i,s=[],a=t;a>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,n,o,r){var i,s,a=8*r-o-1,u=(1<>1,l=-7,f=n?r-1:0,p=n?-1:1,h=e[t+f];for(f+=p,i=h&(1<<-l)-1,h>>=-l,l+=a;l>0;i=256*i+e[t+f],f+=p,l-=8);for(s=i&(1<<-l)-1,i>>=-l,l+=o;l>0;s=256*s+e[t+f],f+=p,l-=8);if(0===i)i=1-c;else{if(i===u)return s?NaN:(h?-1:1)*Infinity;s+=Math.pow(2,o),i-=c}return(h?-1:1)*s*Math.pow(2,i-o)},t.write=function(e,t,n,o,r,i){var s,a,u,c=8*i-r-1,l=(1<>1,p=23===r?Math.pow(2,-24)-Math.pow(2,-77):0,h=o?0:i-1,d=o?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===Infinity?(a=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+f>=1?p/u:p*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(t*u-1)*Math.pow(2,r),s+=f):(a=t*Math.pow(2,f-1)*Math.pow(2,r),s=0));r>=8;e[n+h]=255&a,h+=d,a/=256,r-=8);for(s=s<0;e[n+h]=255&s,h+=d,s/=256,c-=8);e[n+h-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t){function n(){}e.exports=function(e,t,o){var r=!1;return o=o||n,i.count=e,0===e?t():i;function i(e,n){if(i.count<=0)throw new Error("after called too many times");--i.count,e?(r=!0,t(e),t=o):0!==i.count||r||t(null,n)}}},function(e,t,n){"use strict";var o,r,i,s=String.fromCharCode;function a(e){for(var t,n,o=[],r=0,i=e.length;r=55296&&t<=56319&&r=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function c(e,t){return s(e>>t&63|128)}function l(e,t){if(0==(4294967168&e))return s(e);var n="";return 0==(4294965248&e)?n=s(e>>6&31|192):0==(4294901760&e)?(u(e,t)||(e=65533),n=s(e>>12&15|224),n+=c(e,6)):0==(4292870144&e)&&(n=s(e>>18&7|240),n+=c(e,12),n+=c(e,6)),n+=s(63&e|128)}function f(){if(i>=r)throw Error("Invalid byte index");var e=255&o[i];if(i++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function p(e){var t,n;if(i>r)throw Error("Invalid byte index");if(i==r)return!1;if(t=255&o[i],i++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|f())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|f()<<6|f())>=2048)return u(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|f()<<12|f()<<6|f())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}e.exports={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,o=a(e),r=o.length,i=-1,s="";++i65535&&(r+=s((t-=65536)>>>10&1023|55296),t=56320|1023&t),r+=s(t);return r}(c)}}},function(e,t){var n=void 0!==n?n:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,o=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),r=o&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),i=n&&n.prototype.append&&n.prototype.getBlob;function s(e){return e.map(function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var n=new Uint8Array(e.byteLength);n.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=n.buffer}return t}return e})}function a(e,t){t=t||{};var o=new n;return s(e).forEach(function(e){o.append(e)}),t.type?o.getBlob(t.type):o.getBlob()}function u(e,t){return new Blob(s(e),t||{})}"undefined"!=typeof Blob&&(a.prototype=Blob.prototype,u.prototype=Blob.prototype),e.exports=o?r?Blob:u:i?a:undefined},function(e,t,n){"use strict";var o=n(82);e.exports=function(e){var t=e.xdomain,n=e.xscheme,r=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||o))return new XMLHttpRequest}catch(i){}try{if("undefined"!=typeof XDomainRequest&&!n&&r)return new XDomainRequest}catch(i){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(i){}}},function(e,t){try{e.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(n){e.exports=!1}},function(e,t,n){"use strict";(function(t){var o,r,i="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},s=n(29),a=n(14),u=n(24),c=n(30),l=n(47);n(9)("engine.io-client:websocket");if("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)if("undefined"!=typeof WebSocket)o=WebSocket;else if("undefined"!=typeof self)o=self.WebSocket||self.MozWebSocket;else try{r=n(84)}catch(h){}var f=o||r;function p(e){e&&e.forceBase64&&(this.supportsBinary=!1),("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&(this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=o&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(f=r)),s.call(this,e)}("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&"undefined"==typeof GameGlobal||(f=function(e){var t=this;if(t.onopen=function(){},t.onclose=function(){},t.onmessage=function(e){},t.onerror=function(e){},"object"===("undefined"==typeof tt?"undefined":i(tt))&&tt.getSystemInfo){var n=tt.connectSocket({url:e});t.send=function(e){n.send({data:e})},t.close=function(){n.close()},n.onOpen(function(){t.onopen()}),n.onError(function(e){t.onerror(e)}),n.onMessage(function(e){t.onmessage(e)}),n.onClose(function(){t.onclose()})}else if("undefined"!=typeof uni){var o=uni.connectSocket({url:e,complete:function(){}});t.send=function(e){o.send({data:e})},t.close=function(){o.close()},o.onOpen(function(e){t.onopen()}),o.onError(function(e){t.onerror(e)}),o.onMessage(function(e){t.onmessage(e)}),o.onClose(function(e){t.onclose()})}else{var r=wx.connectSocket({url:e});t.send=function(e){r.send({data:e})},t.close=function(e){r.close({code:1e3})},r.onOpen(function(){t.onopen()}),r.onError(function(e){t.onerror(e)}),r.onMessage(function(e){t.onmessage(e)}),r.onClose(function(e){t.onclose(e)})}}),e.exports=p,c(p,s),p.prototype.name="websocket",p.prototype.supportsBinary=!1,p.prototype.doOpen=function(){if(this.check()){var e,t,n=this.uri();("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&(e=this.protocols),(t="undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket?{agent:this.agent,perMessageDeflate:this.perMessageDeflate}:{agent:this.agent}).pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(t.headers=this.extraHeaders),this.localAddress&&(t.localAddress=this.localAddress);try{"undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket?this.ws=this.usingBrowserWebSocket&&!this.isReactNative?e?new f(n,e):new f(n):new f(n,e,t):this.ws=new f(n)}catch(o){return this.emit("error",o)}this.ws.binaryType===undefined&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},p.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},p.prototype.write=function(e){var n=this;this.writable=!1;for(var o=e.length,r=0,i=o;r0&&e.jitter<=1?e.jitter:0,this.attempts=0}e.exports=n,n.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(e){this.ms=e},n.prototype.setMax=function(e){this.max=e},n.prototype.setJitter=function(e){this.jitter=e}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t["default"]={maxNumber:5}},function(e,t,n){"use strict";var o=this&&this.__values||function(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],o=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&o>=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};t.__esModule=!0,t.Cookie=void 0;var r=function(){function e(){}return e.get=function(e){var t,n,r=encodeURIComponent(e)+"=",i=document.cookie.split("; ");try{for(var s=o(i),a=s.next();!a.done;a=s.next()){var u=a.value;if(u.startsWith(r))return decodeURIComponent(u.substring(r.length))}}catch(c){t={error:c}}finally{try{a&&!a.done&&(n=s["return"])&&n.call(s)}finally{if(t)throw t.error}}return null},e.set=function(e,t,n,o,r,i){void 0===r&&(r="/"),void 0===i&&(i=!1);var s=encodeURIComponent(e)+"="+encodeURIComponent(t);n instanceof Date&&(s+="; expires="+n.toGMTString()),r&&(s+="; path="+r),o&&(s+="; domain="+o),i&&(s+="; secure"),document.cookie=s},e.remove=function(t,n,o,r){void 0===o&&(o="/"),void 0===r&&(r=!1),e.set(t,"",new Date(0),n,o,r)},e}();t.Cookie=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.UUID=undefined;var o,r=function(){function e(e,t){for(var n=0;na)&&e.nsecs===undefined&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");a=d,u=y,r=p;var v=(1e4*(268435455&(d+=122192928e5))+y)%4294967296;l[c++]=v>>>24&255,l[c++]=v>>>16&255,l[c++]=v>>>8&255,l[c++]=255&v;var g=d/4294967296*1e4&268435455;l[c++]=g>>>8&255,l[c++]=255&g,l[c++]=g>>>24&15|16,l[c++]=g>>>16&255,l[c++]=p>>>8|128,l[c++]=255&p;for(var b=0;b<6;++b)l[c+b]=f[b];return t||s(l)}},function(e,t){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var o=new Uint8Array(16);e.exports=function(){return n(o),o}}else{var r=new Array(16);e.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),r[t]=e>>>((3&t)<<3)&255;return r}}},function(e,t){for(var n=[],o=0;o<256;++o)n[o]=(o+256).toString(16).substr(1);e.exports=function(e,t){var o=t||0,r=n;return[r[e[o++]],r[e[o++]],r[e[o++]],r[e[o++]],"-",r[e[o++]],r[e[o++]],"-",r[e[o++]],r[e[o++]],"-",r[e[o++]],r[e[o++]],"-",r[e[o++]],r[e[o++]],r[e[o++]],r[e[o++]],r[e[o++]],r[e[o++]]].join("")}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n-1&&e.splice(o,1)}},{key:"unshiftGuid",value:function(e){var t=!1,n=this.findIndex(function(t){return t==e});for(n>-1&&(t=!0,this.splice(n,1)),this.unshift(e);this.length>300;)this.pop();return t}}]),t}());t.goEasyArray=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n-1)return;this.guidList.unshift(t.i),this.guidList.length>300&&this.guidList.pop()}this.callback(t)}}]),e}();t["default"]=i},function(e,t,n){"use strict";t.__esModule=!0,t.AnonymousUserIdRepository=void 0;var o=n(0),r=n(53),i=function(){function e(){}return e.get=function(){var t=e.storage;if(null!==t){var n=t.get(e.ANONYMOUS_USER_ID_KEY);if(!o.calibrator.isEmpty(n))return n.toString()}return null},e.put=function(t){var n=e.storage;null!==n&&n.put(e.ANONYMOUS_USER_ID_KEY,t.toString())},e.storage=r.LocalStorageDispatcher.localStorage(),e.ANONYMOUS_USER_ID_KEY="goeasy-anonymous-user-id",e}();t.AnonymousUserIdRepository=i},function(e,t,n){"use strict";t.__esModule=!0,t.clientInfo=void 0;var o=n(23),r=n(18),i=new(function(){function e(){this.platform=o.PlatformDetector.currentPlatform(),this.framework=r.FrameworkDetector.currentFramework(),this.z=this.toZ()}return e.prototype.toZ=function(){for(var e=JSON.stringify({platform:this.platform,framework:this.framework}),t="",n=0;n=200&&r.status<300||304==r.status){var t=e.payload;t.message=r.responseText,n({code:200,content:t})}else o({code:r.status,content:r.responseText})}})}catch(n){return new Promise(function(e,t){t({code:500,content:n})})}}}]),t}());t.htmlFileUploader=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n32)throw Error("notification's title over max length 32");if(e.body.length>50)throw Error("notification's body over max length 50")}},e}());t.iMMessageBuilder=O},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(7),s=n(0),a=n(34),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new a.ImageMessagePayload},t.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var o=t.createOptions.file,r=n,a=o.path||o.tempFilePath,u=s.calibrator.isEmpty(o.name)||o.name===undefined?a:o.name;r.name="wx-image."+i.str.fileExtension(u,"."),r.contentType="image/"+i.str.fileExtension(u,"."),r.url=a,r.size=o.size,t.complete=new Promise(function(e,t){wx.getImageInfo({src:r.url,success:function(t){r.width=t.width,r.height=t.height,e()},fail:function(e){t(e)}})})},t.prototype.validate=function(t){e.prototype.validate.call(this,t)},t}(n(35)["default"]);t["default"]=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(36),s=n(0),a=n(7),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new i.AudioMessagePayload},t.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var o=t.createOptions.file,r=n,i=o.tempFilePath,u=s.calibrator.isEmpty(o.name)||o.name==undefined?i:o.name,c=o.duration,l=o.fileSize;r.url=i,r.size=l,r.duration=c/1e3,r.name="wx-audio."+a.str.fileExtension(u,"."),r.contentType="audio/"+a.str.fileExtension(u,"."),t.complete=Promise.resolve()},t.prototype.validate=function(t){e.prototype.validate.call(this,t)},t}(n(35)["default"]);t["default"]=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.TextPayloadBuilder=void 0;var i=n(11),s=n(123),a=n(0),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new s.TextMessagePayload},t.prototype.setPayload=function(e,t){var n=t,o=e.createOptions;n.text=o.text,e.complete=Promise.resolve()},t.prototype.validate=function(e){if(a.calibrator.isEmpty(e.text))throw{code:400,content:"text is empty"};if(!a.calibrator.isString(e.text))throw{code:400,content:"TypeError: text requires string."};if(""===e.text.trim())throw{code:400,content:"text is empty"};if(e.text.length>2500)throw{code:400,content:"Message text over max length 2500"}},t}(i.AbstractPayloadBuilder);t.TextPayloadBuilder=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.TextMessagePayload=void 0;var i=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.text="",t}return r(t,e),t}(n(25).AbstractMessagePayload);t.TextMessagePayload=i},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(37),s=n(0),a=n(7),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new i.VideoMessagePayload},t.prototype.setPayload=function(e,t){var n=e.createOptions.file,o=t,r=o.video,i=o.thumbnail,u=n.duration,c=n.height,l=n.size,f=n.tempFilePath,p=n.thumbTempFilePath,h=n.width,d=n.name,y=void 0===d?"":d,m=s.calibrator.isEmpty(y)?f:y;r.contentType="video/"+a.str.fileExtension(m,"."),r.name="wx-video."+a.str.fileExtension(m,"."),r.url=f,r.width=i.width=h,r.height=i.height=c,r.size=l,r.duration=u,i.url=p,i.contentType="image/jpg",i.name="wx-thumbnail.jpg",e.complete=Promise.resolve()},t.prototype.validate=function(e){if(!s.calibrator.isObject(e))throw Error("it is an empty message.");if(!s.calibrator.isDef(e.file))throw Error("file is empty.")},t}(n(11).AbstractPayloadBuilder);t["default"]=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(7),s=n(0),a=n(34),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new a.ImageMessagePayload},t.prototype.setPayload=function(e,t){var n=t,o=e.createOptions.file;n.url=o.path,n.size=o.size;var r=s.calibrator.isEmpty(o.name)||o.name===undefined?o.path:o.name;n.contentType="image/"+i.str.fileExtension(r,"."),n.name="uni-image."+i.str.fileExtension(r,"."),e.complete=new Promise(function(e,t){uni.getImageInfo({src:o.path,success:function(t){n.width=t.width,n.height=t.height,e()},fail:function(e){t(e)}})})},t.prototype.validate=function(t){e.prototype.validate.call(this,t)},t}(n(38)["default"]);t["default"]=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(0),s=n(7),a=n(36),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new a.AudioMessagePayload},t.prototype.setPayload=function(e,t){var n=e.createOptions,o=t,r=n.file,a=r.tempFilePath,u=i.calibrator.isEmpty(r.name)||r.name==undefined?a:r.name;o.url=a,o.name="uni-audio."+s.str.fileExtension(u,"."),o.contentType="audio/"+s.str.fileExtension(u,"."),e.complete=new Promise(function(e,t){uni.getFileInfo({filePath:a,success:function(r){var s=r.size;if(o.size=s,0===s)e();else if(i.calibrator.isDef(n.file.duration))o.duration=n.file.duration/1e3,e();else{var u=uni.createInnerAudioContext();u.src=a,u.onCanplay(function(n){n.errCode?(u.destroy(),t(n)):(o.duration=u.duration,u.destroy(),e())}),u.onError(function(n){u.destroy(),-99===n.errCode?e():t(n)})}},fail:function(e){t(e)}})})},t.prototype.validate=function(t){e.prototype.validate.call(this,t)},t}(n(38)["default"]);t["default"]=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(0),s=n(7),a=n(37),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new a.VideoMessagePayload},t.prototype.setPayload=function(e,t){var n=e.createOptions.file,o=t,r=o.video,a=o.thumbnail,u=n.duration,c=n.height,l=n.size,f=n.tempFilePath,p=n.width,h=n.name,d=void 0===h?"":h,y=i.calibrator.isEmpty(d)?f:d;r.size=l,r.width=p,r.height=c,r.url=f,r.duration=u,r.contentType="video/"+s.str.fileExtension(y,"."),r.name="uni-video."+s.str.fileExtension(y,"."),a.url=f,a.width=p,a.height=c,a.contentType="image/jpg",a.name="uni-thumbnail.jpg",e.complete=Promise.resolve()},t.prototype.validate=function(e){if(!i.calibrator.isObject(e))throw Error("it is an empty message.");if(!i.calibrator.isDef(e.file))throw Error("file is empty.")},t}(n(11).AbstractPayloadBuilder);t["default"]=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(34),s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new i.ImageMessagePayload},t.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var o=t.createOptions.file,r=n,i=window.URL||window.webkitURL,s=new Image;s.src=i.createObjectURL(o),t.complete=new Promise(function(e,t){s.onload=function(){r.width=s.width,r.height=s.height,i.revokeObjectURL(s.src),e()},s.onerror=function(e){i.revokeObjectURL(s.src),t(e)}})},t.prototype.validate=function(t){e.prototype.validate.call(this,t);var n=["gif","jpg","png","jpeg"];if(!n.find(function(e){return e===t.file.type.split("/")[1].toLowerCase()}))throw Error("Only "+n.join(",")+" is supported image.")},t}(n(39)["default"]);t["default"]=s},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(36),s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new i.AudioMessagePayload},t.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var o=t.createOptions.file,r=n,i=window.URL||window.webkitURL,s=document.createElement("audio");s.src=i.createObjectURL(o),t.complete=new Promise(function(e,t){s.onloadedmetadata=function(){r.duration=s.duration,i.revokeObjectURL(s.src),e()},s.onerror=function(e){i.revokeObjectURL(s.src),t(e)}})},t.prototype.validate=function(t){e.prototype.validate.call(this,t);var n=["mp3","ogg","wav","wma","ape","acc","mpeg"];if(!n.find(function(e){return e===t.file.type.split("/")[1].toLowerCase()}))throw Error("Only "+n.join(",")+" is supported audio.")},t}(n(39)["default"]);t["default"]=s},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=n(37),s=n(11),a=n(7),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new i.VideoMessagePayload},t.prototype.setPayload=function(e,t){var n=this,o=e.createOptions.file,r=t,i=r.video,s=r.thumbnail,a=window.URL||window.webkitURL,u=document.createElement("video");u.src=a.createObjectURL(o),i.size=o.size,i.name=o.name,i.contentType=o.type,i.url=u.src,s.name=o.name,s.contentType="image/jpg",e.complete=new Promise(function(e,t){u.onloadedmetadata=function(){i.duration=u.duration,i.width=u.videoWidth,i.height=u.videoHeight,s.width=u.videoWidth,s.height=u.videoHeight,s.url=n.getThumbnailUrl(u),a.revokeObjectURL(u.src),e()},u.onerror=function(e){a.revokeObjectURL(u.src),t(e)}})},t.prototype.getThumbnailUrl=function(e){var t=document.createElement("canvas");return t.width=e.videoWidth,t.height=e.videoHeight,t.getContext("2d").drawImage(e,0,0,t.width,t.height),t.toDataURL("image/png")},t.prototype.validate=function(e){if(!a.calibrator.isObject(e))throw Error("it is an empty message.");if(!(e.file instanceof File))throw Error("wrong file type.");if(0==e.file.size)throw Error("File size is 0.");if(e.file.size>31457280)throw Error("message-length limit 30mib");var t=["avi","mov","rmvb","rm","flv","mp4","3gp","quicktime"];if(!t.find(function(t){return t===e.file.type.split("/")[1].toLowerCase()}))throw Error("Only "+t.join(",")+" is supported video.")},t}(s.AbstractPayloadBuilder);t["default"]=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.CustomPayloadBuilder=void 0;var i=n(11),s=n(132),a=n(0),u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.create=function(){return new s["default"]},t.prototype.setPayload=function(e,t){var n=e.createOptions;t.payload=n.payload,e.complete=Promise.resolve()},t.prototype.validate=function(e){var t=e.type,n=e.payload;if(a.calibrator.isEmpty(t))throw Error("type is empty.");if(!a.calibrator.isString(t))throw Error("type require a string");if(a.calibrator.isEmpty(n))throw Error("payload is empty.");if(!a.calibrator.isPlainObject(n)&&!a.calibrator.isStringOrNumber(n))throw Error("payload require object | string | number.")},t}(i.AbstractPayloadBuilder);t.CustomPayloadBuilder=u},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0;var i=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t}(n(25).AbstractMessagePayload);t["default"]=i},function(e,t,n){"use strict";t.__esModule=!0,t.LocalIMMessageBuildOptions=void 0;var o=function(){return function(e,t){this.type=e,this.createOptions=t}}();t.LocalIMMessageBuildOptions=o},function(e,t,n){"use strict";t.__esModule=!0;var o=n(3),r=n(1),i=n(4),s=n(135),a=n(6),u=n(138),c=n(0),l=n(10),f=n(20),p=n(2),h=n(21),d=n(5),y=function(){function e(){this.payloadImprover=new s.PayloadImprover}return e.prototype.send=function(e){var t=this;this.validate(e);var n=e.message,o=e.accessToken,r=n.buildOptions,i=r.createOptions,s=i.notification,u=i.to;u.data||(u.data={}),a.im._dataCache.putData(u.type,u.id.toString(),u.data),n.status=p.MessageStatus.SENDING;var c=r.complete,l=this.payloadImprover.improve(e);Promise.all([c,l]).then(function(){t.doSend(n,u,s,o,e)})["catch"](function(t){n.status=p.MessageStatus.FAIL,e.onFailed({code:t.code||400,content:t.content||t})})},e.prototype.doSend=function(e,t,n,s,c){var h=new u["default"](e,t,n,s);l.GoEasyEventCenter.fire(f.IM_INTERNAL_EVENTS.MESSAGE_SENDING,e);var y=new o["default"]({name:d.RocketTypes.publishIM,params:h,unique:!0,permission:r["default"].WRITE,singleTimeout:i.SocketTimeout.commonRequestSingle,totalTimeout:i.SocketTimeout.commonRequestTotal,fail:function(t){e.status=p.MessageStatus.FAIL,c.onFailed({code:t.resultCode||408,content:t.content||"Failed to send message."})},success:function(t){200==t.resultCode?(e.status=p.MessageStatus.SUCCESS,e.timestamp=t.content.timestamp,e.clearUseLessAttribute(),l.GoEasyEventCenter.fire(f.IM_INTERNAL_EVENTS.MESSAGE_SEND_SUCCESS,e),c.onSuccess(e)):(e.status=p.MessageStatus.FAIL,c.onFailed(t))}});a.im._goEasySocket.emit(y)},e.prototype.validate=function(e){var t=e.message,n=t.buildOptions.createOptions;if(!(t instanceof h.AbstractMessage))throw new Error("it is invalid message");if(t.status!==p.MessageStatus.NEW)throw new Error("Please create a new message, a message can only be sent once");var o=n.to;if(!o)throw new Error("message require property to.");if(!o.type||o.type!=p.Scene.GROUP&&o.type!=p.Scene.PRIVATE)throw new Error("message require property to.type");if(c.calibrator.isEmpty(o.id))throw new Error("message require property to.id");if(!c.calibrator.isStringOrNumber(o.id))throw new Error("to.id should be a string or number.");if(a.IM.userId===o.id)throw new Error("to.id can not be the same as your id.");if(o.data&&c.calibrator.isFunction(o.data))throw new Error("to.data can not be function");var r=n.notification;if(r)if(c.calibrator.isObject(r)){if(c.calibrator.isEmpty(r.title))throw new Error("notification title is required");if(!c.calibrator.isString(r.title))throw new Error("notification title must be string");if(c.calibrator.isEmpty(r.body))throw new Error("notification body is required");if(!c.calibrator.isString(r.body))throw new Error("notification body must be string")}else if(c.calibrator.isPrimitive(r))throw new Error("notification must be an json object")},e}();t["default"]=y},function(e,t,n){"use strict";t.__esModule=!0,t.PayloadImprover=void 0;var o=n(60),r=n(137),i=n(19),s=function(){function e(){var e;this.improvers=((e={})[i.MessageType.FILE]=new o.FileMessagePayloadImprover,e[i.MessageType.AUDIO]=new o.FileMessagePayloadImprover,e[i.MessageType.IMAGE]=new o.FileMessagePayloadImprover,e[i.MessageType.VIDEO]=new r.VideoMessagePayloadImprover,e)}return e.prototype.improve=function(e){var t=this.improvers[e.message.type];return t?t.improve(e):Promise.resolve()},e}();t.PayloadImprover=s},function(e,t,n){"use strict";t.__esModule=!0,t.AbstractPayloadImprover=void 0;var o=function(){return function(){}}();t.AbstractPayloadImprover=o},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});t.__esModule=!0,t.VideoMessagePayloadImprover=void 0;var i=function(e){function t(){return e.call(this)||this}return r(t,e),t.prototype.setPayload=function(e,t){e.content;var n=t.payload,o="?x-oss-process=video/snapshot,t_0000,f_jpg,w_"+n.video.width+",m_fast,ar_auto";n.video.url=e.content.url,n.thumbnail.url=e.content.url+o,n.video.name=e.content.newFileName},t}(n(60).FileMessagePayloadImprover);t.VideoMessagePayloadImprover=i},function(e,t,n){"use strict";t.__esModule=!0;var o=n(19),r=function(){function e(e,t,n,o){this.validate(e),this.mt=e.type,this.to=t.id.toString(),this.d=JSON.stringify(t.data),this.p=JSON.stringify(e.payload),n&&(this.nt=n),o&&(this.at=o),this.t=t.type,this.guid=e.messageId}return e.prototype.validate=function(e){if(e.type===o.MessageType.TEXT&&JSON.stringify(e.payload).length>3072)throw Error("message-length limit 3kb")},e}();t["default"]=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.eventCenter=undefined;var o=function(){function e(e,t){for(var n=0;n0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]30&&(e.limit=30),p.calibrator.isDef(e.userId)?p.calibrator.isStringOrNumber(e.userId)||h.CallbackUtils.onFailed(e,{code:400,content:"Failed to query history: userId require string or number"}):p.calibrator.isStringOrNumber(e.groupId)||h.CallbackUtils.onFailed(e,{code:400,content:"Failed to query history: groupId require string or number"})},e.prototype.validateTarget=function(e){var t=e.scene===f.Scene.PRIVATE?"userId":"groupId";if(p.calibrator.isUndef(e.id)||p.calibrator.isEmpty(e.id)||!p.calibrator.isStringOrNumber(e.id))throw{code:400,content:t+" requires string or number"}},e.prototype.onUnreadMessageChanged=function(){this.conversations.onUpdated()},e.prototype.onMaxMessageChanged=function(e){var t=this.conversations.findConversation(e.scene,e.id);this.conversations.correctPosition(t),this.conversations.onUpdated()},e}();t["default"]=g},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{u(o.next(e))}catch(t){i(t)}}function a(e){try{u(o["throw"](e))}catch(t){i(t)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((o=o.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),"throw":a(1),"return":a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o["return"]:i[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]e.CONVERSATIONS_MAX_LENGTH&&(this.list=this.list.slice(0,e.CONVERSATIONS_MAX_LENGTH))},e.prototype.correctPosition=function(e){this.removeLocalConversation(e),this.insertOne(e)},e.prototype.expireAllMessageCaches=function(){this.list.forEach(function(e){e.history.expire()})},e.CONVERSATIONS_MAX_LENGTH=200,e.sortedInserter=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.compare=function(e,t){var n;if(e.top==t.top){var o=e.maxMessageTime();n=t.maxMessageTime()-o}else n=e.top?-1:1;return 0===n?0:n>0?1:-1},t}(v.SortedInserter)),e}();t.Conversations=g},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{u(o.next(e))}catch(t){i(t)}}function a(e){try{u(o["throw"](e))}catch(t){i(t)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((o=o.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),"throw":a(1),"return":a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o["return"]:i[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]0)||this.messageCache.isEmpty())return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.updateByServerChange()];case 2:return n.sent(),[3,4];case 3:return t=n.sent(),a.CallbackUtils.onFailed(e,t),[3,4];case 4:return[4,this.messageCache.loadHistory(e)];case 5:return n.sent(),[2]}})})},e.prototype.saveMessage=function(e){this.messageCache.saveMessage(e)},e.prototype.deleteMessages=function(e){return o(this,void 0,void 0,function(){var t,n;return r(this,function(o){switch(o.label){case 0:return t=this.messageCache.getMaxMessage(),n=e.messages,[4,h["default"].deleteServerMessages(n)];case 1:return o.sent(),this.messageCache.deleteMessages(n),a.CallbackUtils.onSuccess(e),n.includes(t)&&c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,this.target),[2]}})})},e.prototype.syncDeletedMessage=function(e,t){if(e===i.IM.userId){var n=this.messageCache.getMaxMessage(),o=this.messageCache.findMessagesByTimes(t);this.messageCache.deleteMessages(o),i.im._event.notify(u.ImApiEvents.MESSAGE_DELETED,o),o.includes(n)&&c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,this.target)}},e.prototype.recallMessage=function(e){return o(this,void 0,void 0,function(){var t,n;return r(this,function(o){switch(o.label){case 0:return t=this.messageCache.getMaxMessage(),n=e.messages,[4,y["default"].recallServerMessages(n)];case 1:return o.sent(),this.messageCache.recallMessages(n),a.CallbackUtils.onSuccess(e),n.includes(t)&&c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,this.target),[2]}})})},e.prototype.syncRecalledMessage=function(e){var t=this.messageCache.getMaxMessage(),n=this.messageCache.findMessagesByTimes(e);n.length>0&&(this.messageCache.recallMessages(n),i.im._event.notify(u.ImApiEvents.MESSAGE_RECALLED,n),this.existsUnreadMessage(n)?c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.UNREAD_MESSAGE_CHANGED):n.includes(t)&&c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,this.target))},e.prototype.existsUnreadMessage=function(e){for(var t=this.userOffsetService.myOffset(),n=0;n0&&i.im._event.notify(u.ImApiEvents.MESSAGE_READ,t),e===this.messageCache.maxSuccessMessageTime()&&c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,this.target)}},e.prototype.onMessageSendSuccess=function(e){if(this.target.scene===s.Scene.PRIVATE){var t=e;t.read||(t.read=this.userOffsetService.isRead(t),t.read&&i.im._event.notify(u.ImApiEvents.MESSAGE_READ,[t]))}this.messageCache.correctPosition(e),this.userOffsetService.updateMyOffset(e.timestamp)},e.prototype.onMessageReceived=function(e){if(!this.messageCache.existsMessage(e.messageId)){this.saveMessage(e);var t=e.timestamp;if(e.senderId==i.IM.userId)this.userOffsetService.updateMyOffset(t)&&this.messageCache.markOthersSentRead(t);else if(this.target.scene===s.Scene.PRIVATE){this.userOffsetService.updateOffset(this.target.id,t);var n=this.messageCache.markMySentRead(t);n.length>0&&i.im._event.notify(u.ImApiEvents.MESSAGE_READ,n)}var o=this.target.scene;return o===s.Scene.PRIVATE?i.im._event.notify(u.ImApiEvents.PRIVATE_MESSAGE_RECEIVED,e):o===s.Scene.GROUP&&i.im._event.notify(u.ImApiEvents.GROUP_MESSAGE_RECEIVED,e),!0}return!1},e}();t["default"]=m},function(e,t,n){"use strict";var o,r=this&&this.__extends||(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{u(o.next(e))}catch(t){i(t)}}function a(e){try{u(o["throw"](e))}catch(t){i(t)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((o=o.apply(e,t||[])).next())})},s=this&&this.__generator||function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),"throw":a(1),"return":a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o["return"]:i[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};t.__esModule=!0;var u=n(3),c=n(1),l=n(4),f=n(6),p=n(2),h=n(33),d=n(145),y=n(5),m=n(8),v=n(7),g=n(61),b=function(){function e(e,t){this.builder=new h.RemoteAbbrMessageBuilder,this.messages=new Array,this.allLoaded=!1,this.target=e,this.userOffsetService=t}return e.prototype.sliceOverlengthMessages=function(){this.messages.length>e.CACHE_MAX_LENGTH&&(this.messages=this.messages.slice(-e.CACHE_MAX_LENGTH),!0===this.allLoaded&&(this.allLoaded=!1))},e.prototype.unreadAmount=function(){var e,t,n=0,o=this.userOffsetService.myOffset();try{for(var r=a(this.messages),i=r.next();!i.done;i=r.next()){var s=i.value;s.senderId!==f.IM.userId&&s.timestamp>o&&!s.recalled&&(n+=1)}}catch(u){e={error:u}}finally{try{i&&!i.done&&(t=r["return"])&&t.call(r)}finally{if(e)throw e.error}}return n},e.prototype.maxTime=function(){var e=this.getMaxMessage();return v.calibrator.isDef(e)?e.timestamp:0},e.prototype.getMaxMessage=function(){return this.messages[this.messages.length-1]},e.prototype.loadHistory=function(e){return i(this,void 0,void 0,function(){var t,n,o,r,i,a,u,c;return s(this,function(s){switch(s.label){case 0:if(t=e.limit,n=e.lastTimestamp,o=this.loadLocalMessages(t,n),!1!==this.allLoaded||o.length===t)return[3,4];r=t-o.length,i=o[0]?o[0].timestamp:n,a={userId:e.userId,groupId:e.groupId,lastTimestamp:i,limit:r},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.loadServerMessages(a)];case 2:return u=s.sent(),o=u.concat(o),[3,4];case 3:return c=s.sent(),m.CallbackUtils.onFailed(e,c),[3,4];case 4:return m.CallbackUtils.onSuccess(e,{code:200,content:o}),[2]}})})},e.prototype.loadLocalMessages=function(e,t){var n=[],o=this.messages.length;if(t){if(o>0){var r=this.messages[0].timestamp,i=this.messages[o-1].timestamp;if(t>=r&&t<=i)for(var s=o-1;s>=0;s--){var a=this.messages[s];if(a.timestamp0&&n.timestamp===e.lastTimestamp)&&(this.messages=t.concat(this.messages))},e.prototype.findMessageByTime=function(e){return this.messages.find(function(t){return e===t.timestamp})},e.prototype.findMessagesByTimes=function(e){var t=this,n=[];return e.forEach(function(e){var o=t.findMessageByTime(e);v.calibrator.isDef(o)&&n.push(o)}),n},e.prototype.existsMessage=function(e){return this.findMessageIndexById(e)>-1},e.prototype.findMessageIndexById=function(e){return this.messages.findIndex(function(t){return e===t.messageId})},e.prototype.deleteMessage=function(e){var t=this.findMessageIndexById(e);t>=0&&this.messages.splice(t,1)},e.prototype.recallMessages=function(e){var t=this;e.forEach(function(e){var n=t.findMessageByTime(e.timestamp);v.calibrator.isDef(n)&&(n.recalled=!0),e.recalled=!0})},e.prototype.isEmpty=function(){return 0===this.messages.length},e.prototype.deleteMessages=function(e){var t=this;e.forEach(function(e){t.deleteMessage(e.messageId)})},e.prototype.convertServerMessages=function(e){var t=this,n=[];return e.forEach(function(e){t.target.scene===p.Scene.PRIVATE?(e.t=p.Scene.PRIVATE,e.r=e.s===f.IM.userId?t.target.id:f.IM.userId):(e.t=p.Scene.GROUP,e.r=t.target.id);var o=t.builder.build(e);if(!t.existsMessage(o.messageId)){if(o.scene()===p.Scene.PRIVATE){var r=o;r.read=t.userOffsetService.isRead(r)}n.push(o)}}),n},e.prototype.markOthersSentRead=function(e){if(this.target.scene===p.Scene.PRIVATE)for(var t=this.messages.length-1;t>=0;t--){var n=this.messages[t];if(n.senderId!==f.IM.userId&&n.timestamp<=e){if(n.read)break;n.read=!0}}},e.prototype.markMySentRead=function(e){for(var t=new Array,n=this.messages.length-1;n>=0;n--){var o=this.messages[n],r=o;if(r.senderId===f.IM.userId&&o.timestamp<=e&&o.status===p.MessageStatus.SUCCESS){if(r.read)break;r.read=!0,t.push(r)}}return t},e.prototype.saveMessage=function(t){e.sortedInserter.insert(this.messages,t),this.sliceOverlengthMessages()},e.prototype.maxSuccessMessageTime=function(){for(var e=this.messages.length-1;e>=0;e--)if(this.messages[e].status===p.MessageStatus.SUCCESS)return this.messages[e].timestamp;return 0},e.prototype.minTime=function(){return this.isEmpty()?0:this.messages[0].timestamp},e.prototype.correctPosition=function(e){this.deleteMessage(e.messageId),this.saveMessage(e)},e.CACHE_MAX_LENGTH=200,e.sortedInserter=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.compare=function(e,t){var n=e.timestamp-t.timestamp;return n>0?1:0===n?0:-1},t}(g.SortedInserter)),e}();t["default"]=b},function(e,t,n){"use strict";t.__esModule=!0;var o=n(2),r=n(7),i=function(){return function(e){r.calibrator.isDef(e.userId)?(this.scene=o.Scene.PRIVATE,this.id=e.userId):(this.scene=o.Scene.GROUP,this.id=e.groupId),this.id=this.id.toString(),this.lastTimestamp=e.lastTimestamp,this.limit=e.limit}}();t["default"]=i},function(e,t,n){"use strict";var o=this&&this.__awaiter||function(e,t,n,o){return new(n||(n=Promise))(function(r,i){function s(e){try{u(o.next(e))}catch(t){i(t)}}function a(e){try{u(o["throw"](e))}catch(t){i(t)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(s,a)}u((o=o.apply(e,t||[])).next())})},r=this&&this.__generator||function(e,t){var n,o,r,i,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:a(0),"throw":a(1),"return":a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,o&&(r=2&i[0]?o["return"]:i[0]?o["throw"]||((r=o["return"])&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,o=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]=t:this.userOffsets.myOffset()>=t},e.prototype.manualMark=function(e){return o(this,void 0,void 0,function(){var t;return r(this,function(n){switch(n.label){case 0:return this.userOffsets.markingTime=e,t=this.userOffsets.myOffset(),e>t?[4,this.updateServerOffsets(e)]:[3,2];case 1:if(n.sent(),e===this.userOffsets.markingTime)return this.userOffsets.updateMyOffset(e),[2,!0];n.label=2;case 2:return[2,!1]}})})},e.prototype.updateMyOffset=function(e){return this.userOffsets.updateMyOffset(e)},e.prototype.updateOffset=function(e,t){this.userOffsets.updateOffset(e,t)},e.prototype.updateServerOffsets=function(e){return o(this,void 0,void 0,function(){var t,n;return r(this,function(o){return(t=new l.ReadMessageMarkRequest).lastTimestamp=e,t.lastConsumedTimestamp=this.userOffsets.myOffset(),n=f.RocketTypes.markGroupMessageAsRead,this.target.scene===c.Scene.PRIVATE?(t.friendId=this.target.id,n=f.RocketTypes.markPrivateMessageAsRead):t.groupId=this.target.id,[2,new Promise(function(e,o){var r=new s["default"]({name:n,params:t,permission:a["default"].WRITE,singleTimeout:u.SocketTimeout.commonRequestSingle,totalTimeout:u.SocketTimeout.commonRequestTotal,success:function(t){200===t.code?e(t):o(t)},fail:function(e){o(e)}});i.im._goEasySocket.emit(r)})]})})},e.prototype.updateUserOffsets=function(e){this.userOffsets.updateUserOffsets(e)},e.prototype.myOffset=function(){return this.userOffsets.myOffset()},e}();t["default"]=h},function(e,t,n){"use strict";t.__esModule=!0,t.ReadMessageMarkRequest=void 0;var o=function(){return function(){}}();t.ReadMessageMarkRequest=o},function(e,t,n){"use strict";t.__esModule=!0,t.UserOffsets=void 0;var o=n(7),r=n(6),i=function(){function e(){this.offsetMap=new Map,this.markingTime=0}return e.prototype.updateOffset=function(e,t){var n=this.offsetMap.get(e);return o.calibrator.isDef(n)?t>n&&(this.offsetMap.set(e,t),!0):(this.offsetMap.set(e,t),!0)},e.prototype.updateUserOffsets=function(e){var t=this;e.forEach(function(e){var n=e.userId,o=e.offset;t.updateOffset(n,o)})},e.prototype.updateMyOffset=function(e){return this.updateOffset(r.IM.userId,e)},e.prototype.myOffset=function(){return this.getOffset(r.IM.userId)},e.prototype.getOffset=function(e){var t=this.offsetMap.get(e);return t||0},e}();t.UserOffsets=i},function(e,t,n){"use strict";t.__esModule=!0,t.DeleteMessageRequest=void 0;var o=n(2),r=n(17),i=function(){return function(e){var t=this;this.times=new Array;var n=e[0],i=r.Target.byIMMessage(n);this.scene=i.scene,this.targetId=i.id,e.forEach(function(e){e.status===o.MessageStatus.SUCCESS&&t.times.push(e.timestamp)}),this.times.sort(function(e,t){return e0){var a=new f.MessageDeletedRemoteEvent(e,p.IM.userId,t,s);c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.REMOTE_MESSAGE_DELETED,a)}if(i.recalled.length>0){var y=d["default"].conversationId(e,p.IM.userId,t),m=new h.MessageRecalledRemoteEvent(e,y,i.recalled);c.GoEasyEventCenter.fire(l.IM_INTERNAL_EVENTS.REMOTE_MESSAGE_RECALLED,m)}n(r)}else o(r)}});p.im._goEasySocket.emit(y)})},e}();t.ChangeSynchronizer=y},function(e,t,n){"use strict";t.__esModule=!0;var o=function(){return function(e,t,n,o){this.scene=e,this.id=t,this.after=n,this.min=o}}();t["default"]=o},function(e,t,n){"use strict";t.__esModule=!0,t.ReadMessageMarkedRemoteEvent=void 0;var o=function(){return function(e,t,n,o){this.scene=e,this.markerId=t,this.targetId=n,this.time=o}}();t.ReadMessageMarkedRemoteEvent=o},function(e,t,n){"use strict";t.__esModule=!0,t.MessageDeletedRemoteEvent=void 0;var o=function(){return function(e,t,n,o){this.scene=e,this.deleterId=t,this.targetId=n,this.times=o}}();t.MessageDeletedRemoteEvent=o},function(e,t,n){"use strict";t.__esModule=!0,t.MessageRecalledRemoteEvent=void 0;var o=function(){return function(e,t,n){this.scene=e,this.conversationId=t,this.times=n}}();t.MessageRecalledRemoteEvent=o},function(e,t,n){"use strict";t.__esModule=!0,t.RecallMessageRequest=void 0;var o=n(17),r=function(){return function(e){var t=this;this.times=new Array;var n=e[0],r=o.Target.byIMMessage(n);this.scene=r.scene,this.targetId=r.id,e.forEach(function(e){t.times.push(e.timestamp)}),this.times.sort(function(e,t){return e0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]0&&r[r.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]500)e.onFailed({code:400,content:"userIds is over max length 500"});else{var n=new i["default"]({name:u.RocketTypes.hereNowByUserIds,permission:s["default"].READ,params:t,singleTimeout:a.SocketTimeout.commonQuerySingle,totalTimeout:a.SocketTimeout.commonQueryTotal,success:function(t){var n=t.content;n=n.map(function(e){var t={};return t.id=e.userId,t.data=e.userData?JSON.parse(e.userData):{},t}),e.onSuccess({code:t.resultCode||t.code||200,content:n})},fail:function(t){e.onFailed({code:t.resultCode||t.code||200,content:t.content})}});this.pubSub.goEasySocket.emit(n)}}}]),e}();t["default"]=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n2500)throw{code:400,content:"Message over max length 2500."};if(r.calibrator.isObject(e.notification)){if(r.calibrator.isEmpty(e.notification.title))throw{code:400,content:"notification.title is required."};if(!r.calibrator.isString(e.notification.title))throw{code:400,content:"TypeError: notification.title requires string."};if(e.notification.title.length>32)throw{code:400,content:"TypeError: notification.title over max length 32."};if(r.calibrator.isEmpty(e.notification.body))throw{code:400,content:"notification.body is required."};if(!r.calibrator.isString(e.notification.body))throw{code:400,content:"TypeError: notification.body must be string."};if(e.notification.body.length>50)throw{code:400,content:"notification.body over max length 50."}}else if(r.calibrator.isPrimitive(e.notification))throw{code:400,content:"TypeError: notification requires an object."};var t={channel:e.channel,content:e.message,nt:e.notification,at:e.accessToken,guid:r.UUID.get()},n=new i["default"]({name:u.RocketTypes.publish,params:t,unique:!0,singleTimeout:a.SocketTimeout.commonRequestSingle,totalTimeout:a.SocketTimeout.commonRequestTotal,permission:s["default"].WRITE,success:function(t){e.onSuccess({code:200,content:"ok"})},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});this.pubSub.goEasySocket.emit(n)}}]),e}();t["default"]=l},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n-1)){e.a&&this.pubSub.goEasySocket.sendAck("ack",{publishGuid:e.i});var t={time:e.t,channel:e.n,content:e.c};l.GoEasyEventCenter.fire(f.PUBSUB_INTERNAL_EVENTS.MESSAGE_RECEIVED,e),this.findSubscriptionByChannel(t.channel).onMessage(t)}}},{key:"formatOptions",value:function(e){var t=!r.calibrator.isEmpty(e.channel),n=!r.calibrator.isEmpty(e.channels);if(this.formatCallback(e),r.calibrator.isFunction(e.onMessage)||(e.onMessage=r.noop),!t&&!n)return e.onFailed({code:400,content:"channel is required"}),!1;if(!t||!n){if(t&&(r.calibrator.isNumber(e.channel)&&(e.channel=e.channel.toString()),e.channels=[e.channel]),n){if(!Array.isArray(e.channels)||0==e.channels.length)return void e.onFailed({code:400,content:"channels must be an array"});if(e.channels.length>500)return e.onFailed({code:400,content:"channels over max length:500"}),!1;for(var o=0,i=e.channels.length;o=0;o--){for(var r=this.subscriptions[o].channels,i=0;i500)return e.onFailed({code:400,content:"channels over max length:500"}),!1;for(var o=0,i=e.channels.length;o=0;o--){for(var r=this.presenters[o].channels,i=0;i0)&&!(o=i.next()).done;)s.push(o.value)}catch(a){r={error:a}}finally{try{o&&!o.done&&(n=i["return"])&&n.call(i)}finally{if(r)throw r.error}}return s};t.__esModule=!0,t.GoEasyNotification=void 0;var r=n(27),i=n(0),s=n(10),a=n(65),u=n(18),c=n(23),l=n(6),f=n(2),p=n(57),h=function(){function e(e){this.uniappPlugin=null,this.regIdPromise=null,this.onClickNotificationCallback=null,this.allowNotification=e,this.supportNotification()&&(this.uniappPlugin=uni.requireNativePlugin("GoEasy-Uniapp"),this.uniappPlugin?this.regIdPromise=this.askRegId():console.warn("No GoEasy-Uniapp Native Plugin."))}return e.prototype.listenNewMessage=function(){var e=this;this.supportNotification()&&(s.GoEasyEventCenter.on(p.SocketEvents.IM_MESSAGE_RECEIVED,function(t){return e.onReceivedIMMessage(t)}),s.GoEasyEventCenter.on(a.PUBSUB_INTERNAL_EVENTS.MESSAGE_RECEIVED,function(t){return e.onReceivedPubSubMessage(t)}))},e.prototype.onReceivedIMMessage=function(e){var t=this,n=e.nt;if(i.calibrator.isObject(n)&&r.uniApp.runningBackend()&&e.s!==l.IM.userId){var s=e.i,a=e.ts,u=e.mt,c=e.s,p=e.r,h=e.r,d=e.t,y={id:s,tm:a,t:u,sid:c,rid:p,gid:h,tt:d,nt:n,sd:null,gd:null};d===f.Scene.PRIVATE?l.im._dataCache.loadData(c,d).then(function(e){y.sd=JSON.stringify(e),t.createLocalNotification(y)})["catch"](function(e){t.createLocalNotification(y)}):d===f.Scene.GROUP?Promise.all([l.im._dataCache.loadData(c,f.Scene.PRIVATE),l.im._dataCache.loadData(h,f.Scene.GROUP)]).then(function(e){var n=o(e,2),r=n[0],i=n[1];y.sd=JSON.stringify(r),y.gd=JSON.stringify(i),t.createLocalNotification(y)})["catch"](function(e){t.createLocalNotification(y)}):this.createLocalNotification(y)}},e.prototype.onReceivedPubSubMessage=function(e){if(i.calibrator.isObject(e.nt)&&r.uniApp.runningBackend()){var t={tm:e.t,ch:e.n,ctt:e.c,nt:e.nt};this.createLocalNotification(t)}},e.prototype.createLocalNotification=function(e){JSON.stringify(e);var t=e.nt.t,n=e.nt.c,o=Object.assign({title:t,body:n},e,{g:1});JSON.stringify(o),delete o.nt,i.calibrator.isObject(o)&&o.body&&o.title?"undefined"!=typeof plus&&plus.push.createMessage(o.body,JSON.stringify(o),{title:o.title}):console.warn("The notification message must contain the and <body> fields")},e.prototype.askRegId=function(){var e=this,t=null,n=0,o=function(){return new Promise(function(r,i){e.uniappPlugin.regId(function(e){r(e)},function(r){if(!(1e6===r.data.code&&n<=10))return clearTimeout(t),i(r);t=setTimeout(function(){n++,e.regIdPromise=o()},3500)})})};return o()},e.prototype.getRegIdPromise=function(){return this.regIdPromise},e.prototype.supportNotification=function(){var e=c.PlatformDetector.currentPlatform(),t=u.FrameworkDetector.currentFramework();return this.allowNotification&&t===u.Framework.UNIAPP&&(e===c.Platform.APP_ANDROID||e===c.Platform.APP_IOS)},e.prototype.parseMessage=function(e){return e.ch?{channel:e.ch,content:e.ctt}:{messageId:e.id,timestamp:e.tm,type:e.t,senderId:e.sid,senderData:e.sd?JSON.parse(e.sd):undefined,toType:e.tt,groupId:e.gid,groupData:e.gd?JSON.parse(e.gd):undefined}},e.prototype.listenPlusClickNotification=function(){var e=this;plus.push.addEventListener("click",function(t){if(t&&t.payload)try{var n="string"==typeof t.payload?JSON.parse(t.payload):t.payload,o=e.parseMessage(n);plus.push.clear(),e.onClickNotificationCallback(o)}catch(r){}})},e.prototype.availableIntent=function(e){return e&&Object.keys(e).length&&e.g&&1===parseInt(e.g)},e.prototype.extactIntentIfXiaoMi=function(e){var t=/content=\{(\{.*\})\},/;if(e.key_message&&t.exec(e.key_message)){var n=e.key_message.match(t);e=n.length?JSON.parse(n[1]):null}return e},e.prototype.getIntentData=function(){var e=this;this.uniappPlugin.getIntentData(function(t){if(e.availableIntent(t)){var n=e.parseMessage(t),o=c.PlatformDetector.currentPlatform();plus.push.clear(),o===c.Platform.APP_ANDROID&&e.uniappPlugin.clearAll(),e.onClickNotificationCallback(n)}})},e.prototype.onClickNotification=function(e){if(this.supportNotification()){if(!i.calibrator.isFunction(e))throw new Error("The arguments must be a function.");null===this.onClickNotificationCallback?(this.onClickNotificationCallback=e,this.listenPlusClickNotification(),this.uniappPlugin&&this.getIntentData()):console.warn("The onClickNotification event has been listened on. Please do not listen to it more than once.")}else console.warn("The current environment doesn't support or allowNotification is false.")},e}();t.GoEasyNotification=h}])["default"]}); \ No newline at end of file diff --git a/static/lib/goeasy-2.6.1.esm.min.js b/static/lib/goeasy-2.6.1.esm.min.js new file mode 100644 index 0000000000000000000000000000000000000000..96c72dd8b27dd12b09773318e81b8485352602bb --- /dev/null +++ b/static/lib/goeasy-2.6.1.esm.min.js @@ -0,0 +1 @@ +var e;!function(e){e.DISCONNECTED="disconnected",e.DISCONNECTING="disconnecting",e.CONNECTING="connecting",e.CONNECTED="connected",e.RECONNECTING="reconnecting",e.RECONNECTED="reconnected",e.EXPIRED_RECONNECTED="reconnected",e.CONNECT_FAILED="connect_failed"}(e||(e={}));var t=function(e,s){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])},t(e,s)};var s=function(){return s=Object.assign||function(e){for(var t,s=1,n=arguments.length;s<n;s++)for(var i in t=arguments[s])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};function n(e,t,s,n){return new(s||(s=Promise))((function(i,o){function r(e){try{c(n.next(e))}catch(e){o(e)}}function a(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(r,a)}c((n=n.apply(e,t||[])).next())}))}var i=Object.create?function(e,t,s,n){void 0===n&&(n=s);var i=Object.getOwnPropertyDescriptor(t,s);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,n,i)}:function(e,t,s,n){void 0===n&&(n=s),e[n]=t[s]};function o(e){var t="function"==typeof Symbol&&Symbol.iterator,s=t&&e[t],n=0;if(s)return s.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function r(e,t){var s="function"==typeof Symbol&&e[Symbol.iterator];if(!s)return e;var n,i,o=s.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)r.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(s=o.return)&&s.call(o)}finally{if(i)throw i.error}}return r}function a(e){return this instanceof a?(this.v=e,this):new a(e)}var c=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};var u=Object.freeze({__proto__:null,__extends:function(e,s){if("function"!=typeof s&&null!==s)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");function n(){this.constructor=e}t(e,s),e.prototype=null===s?Object.create(s):(n.prototype=s.prototype,new n)},get __assign(){return s},__rest:function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(s[n[i]]=e[n[i]])}return s},__decorate:function(e,t,s,n){var i,o=arguments.length,r=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,s):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,s,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(r=(o<3?i(r):o>3?i(t,s,r):i(t,s))||r);return o>3&&r&&Object.defineProperty(t,s,r),r},__param:function(e,t){return function(s,n){t(s,n,e)}},__metadata:function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter:n,__generator:function(e,t){var s,n,i,o,r={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(s)throw new TypeError("Generator is already executing.");for(;r;)try{if(s=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return r.label++,{value:o[1],done:!1};case 5:r.label++,n=o[1],o=[0];continue;case 7:o=r.ops.pop(),r.trys.pop();continue;default:if(!(i=r.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){r=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){r.label=o[1];break}if(6===o[0]&&r.label<i[1]){r.label=i[1],i=o;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(o);break}i[2]&&r.ops.pop(),r.trys.pop();continue}o=t.call(e,r)}catch(e){o=[6,e],n=0}finally{s=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}},__createBinding:i,__exportStar:function(e,t){for(var s in e)"default"===s||Object.prototype.hasOwnProperty.call(t,s)||i(t,e,s)},__values:o,__read:r,__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(r(arguments[t]));return e},__spreadArrays:function(){for(var e=0,t=0,s=arguments.length;t<s;t++)e+=arguments[t].length;var n=Array(e),i=0;for(t=0;t<s;t++)for(var o=arguments[t],r=0,a=o.length;r<a;r++,i++)n[i]=o[r];return n},__spreadArray:function(e,t,s){if(s||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},__await:a,__asyncGenerator:function(e,t,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=s.apply(e,t||[]),o=[];return n={},r("next"),r("throw"),r("return"),n[Symbol.asyncIterator]=function(){return this},n;function r(e){i[e]&&(n[e]=function(t){return new Promise((function(s,n){o.push([e,t,s,n])>1||c(e,t)}))})}function c(e,t){try{(s=i[e](t)).value instanceof a?Promise.resolve(s.value.v).then(u,l):d(o[0][2],s)}catch(e){d(o[0][3],e)}var s}function u(e){c("next",e)}function l(e){c("throw",e)}function d(e,t){e(t),o.shift(),o.length&&c(o[0][0],o[0][1])}},__asyncDelegator:function(e){var t,s;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,i){t[n]=e[n]?function(t){return(s=!s)?{value:a(e[n](t)),done:"return"===n}:i?i(t):t}:i}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,s=e[Symbol.asyncIterator];return s?s.call(e):(e=o(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(s){t[s]=e[s]&&function(t){return new Promise((function(n,i){(function(e,t,s,n){Promise.resolve(n).then((function(t){e({value:t,done:s})}),t)})(n,i,(t=e[s](t)).done,t.value)}))}}},__makeTemplateObject:function(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e},__importStar:function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)"default"!==s&&Object.prototype.hasOwnProperty.call(e,s)&&i(t,e,s);return c(t,e),t},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__classPrivateFieldGet:function(e,t,s,n){if("a"===s&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?n:"a"===s?n.call(e):n?n.value:t.get(e)},__classPrivateFieldSet:function(e,t,s,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,s):i?i.value=s:t.set(e,s),s},__classPrivateFieldIn:function(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}}),l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(s){var n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,n.get?n:{enumerable:!0,get:function(){return e[s]}})})),t}var h={exports:{}},p=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,f=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],m=function(e){var t=e,s=e.indexOf("["),n=e.indexOf("]");-1!=s&&-1!=n&&(e=e.substring(0,s)+e.substring(s,n).replace(/:/g,";")+e.substring(n,e.length));for(var i=p.exec(e||""),o={},r=14;r--;)o[f[r]]=i[r]||"";return-1!=s&&-1!=n&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o},g={exports:{}},y={exports:{}},v=6e4,E=36e5,S=24*E,C=function(e,t){t=t||{};var s=typeof e;if("string"===s&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"days":case"day":case"d":return s*S;case"hours":case"hour":case"hrs":case"hr":case"h":return s*E;case"minutes":case"minute":case"mins":case"min":case"m":return s*v;case"seconds":case"second":case"secs":case"sec":case"s":return 1e3*s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===s&&!1===isNaN(e))return t.long?function(e){return b(e,S,"day")||b(e,E,"hour")||b(e,v,"minute")||b(e,1e3,"second")||e+" ms"}(e):function(e){if(e>=S)return Math.round(e/S)+"d";if(e>=E)return Math.round(e/E)+"h";if(e>=v)return Math.round(e/v)+"m";if(e>=1e3)return Math.round(e/1e3)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function b(e,t,s){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+s:Math.ceil(e/t)+" "+s+"s"}!function(e,t){function s(e){var s;function i(){if(i.enabled){var e=i,n=+new Date,o=n-(s||n);e.diff=o,e.prev=s,e.curr=n,s=n;for(var r=new Array(arguments.length),a=0;a<r.length;a++)r[a]=arguments[a];r[0]=t.coerce(r[0]),"string"!=typeof r[0]&&r.unshift("%O");var c=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,(function(s,n){if("%%"===s)return s;c++;var i=t.formatters[n];if("function"==typeof i){var o=r[c];s=i.call(e,o),r.splice(c,1),c--}return s})),t.formatArgs.call(e,r);var u=i.log||t.log||console.log.bind(console);u.apply(e,r)}}return i.namespace=e,i.enabled=t.enabled(e),i.useColors=t.useColors(),i.color=function(e){var s,n=0;for(s in e)n=(n<<5)-n+e.charCodeAt(s),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),i.destroy=n,"function"==typeof t.init&&t.init(i),t.instances.push(i),i}function n(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=y.exports=s.debug=s.default=s).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var s;t.save(e),t.names=[],t.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(s=0;s<i;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(s=0;s<t.instances.length;s++){var o=t.instances[s];o.enabled=t.enabled(o.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return!1;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=C,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(0,y.exports),function(e,t){function s(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=y.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var s=this.useColors;if(e[0]=(s?"%c":"")+this.namespace+(s?" %c":" ")+e[0]+(s?"%c ":" ")+"+"+t.humanize(this.diff),!s)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))})),e.splice(o,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=s,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(s())}(g,g.exports);var w=m,I=g.exports("socket.io-client:url"),M=function(e,t){var s=e;t=t||"undefined"!=typeof location&&location,null==e&&(e=t.protocol+"//"+t.host);"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?t.protocol+e:t.host+e),/^(https?|wss?):\/\//.test(e)||(I("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),I("parse %s",e),s=w(e));s.port||(/^(http|ws)$/.test(s.protocol)?s.port="80":/^(http|ws)s$/.test(s.protocol)&&(s.port="443"));s.path=s.path||"/";var n=-1!==s.host.indexOf(":")?"["+s.host+"]":s.host;return s.id=s.protocol+"://"+n+":"+s.port,s.href=s.protocol+"://"+n+(t&&t.port===s.port?"":":"+s.port),s};var A={},N={exports:{}};!function(e){function t(e){if(e)return function(e){for(var s in t.prototype)e[s]=t.prototype[s];return e}(e)}N.exports=t,t.prototype.on=t.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},t.prototype.once=function(e,t){function s(){this.off(e,s),t.apply(this,arguments)}return s.fn=t,this.on(e,s),this},t.prototype.off=t.prototype.removeListener=t.prototype.removeAllListeners=t.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var s,n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<n.length;i++)if((s=n[i])===t||s.fn===t){n.splice(i,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),s=this._callbacks["$"+e];if(s)for(var n=0,i=(s=s.slice(0)).length;n<i;++n)s[n].apply(this,t);return this},t.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},t.prototype.hasListeners=function(e){return!!this.listeners(e).length}}();var T={}.toString,O=Array.isArray||function(e){return"[object Array]"==T.call(e)};!function(e){g.exports("socket.io-parser");var t=N.exports,s=O;function n(){}e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=n,e.Decoder=o;var i=e.ERROR+'"encode error"';function o(){this.reconstructor=null}function r(t){return{type:e.ERROR,data:"parser error: "+t}}n.prototype.encode=function(t,s){var n=function(t){var s=""+t.type;e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(s+=t.attachments+"-");t.nsp&&"/"!==t.nsp&&(s+=t.nsp+",");null!=t.id&&(s+=t.id);if(null!=t.data){var n=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(t.data);if(!1===n)return i;s+=n}return s}(t);s([n])},t(o.prototype),o.prototype.add=function(t){var n;if("string"!=typeof t)throw new Error("Unknown type: "+t);n=function(t){var n=0,i={type:Number(t.charAt(0))};if(null==e.types[i.type])return r("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var o="";"-"!==t.charAt(++n)&&(o+=t.charAt(n),n!=t.length););if(o!=Number(o)||"-"!==t.charAt(n))throw new Error("Illegal attachments");i.attachments=Number(o)}if("/"===t.charAt(n+1))for(i.nsp="";++n;){if(","===(c=t.charAt(n)))break;if(i.nsp+=c,n===t.length)break}else i.nsp="/";var a=t.charAt(n+1);if(""!==a&&Number(a)==a){for(i.id="";++n;){var c;if(null==(c=t.charAt(n))||Number(c)!=c){--n;break}if(i.id+=t.charAt(n),n===t.length)break}i.id=Number(i.id)}if(t.charAt(++n)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(t.substr(n));if(!(!1!==u&&(i.type===e.ERROR||s(u))))return r("invalid payload");i.data=u}return i}(t),this.emit("decoded",n)},o.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}(A);var _={exports:{}},R={},P={},k=Object.keys||function(e){var t=[],s=Object.prototype.hasOwnProperty;for(var n in e)s.call(e,n)&&t.push(n);return t},D=O,x=Object.prototype.toString,F="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===x.call(Blob),U="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===x.call(File),L=function e(t){if(!t||"object"!=typeof t)return!1;if(D(t)){for(var s=0,n=t.length;s<n;s++)if(e(t[s]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||F&&t instanceof Blob||U&&t instanceof File)return!0;if(t.toJSON&&"function"==typeof t.toJSON&&1===arguments.length)return e(t.toJSON(),!0);for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)&&e(t[i]))return!0;return!1};var G=function(e,t,s){var n=!1;return s=s||B,i.count=e,0===e?t():i;function i(e,o){if(i.count<=0)throw new Error("after called too many times");--i.count,e?(n=!0,t(e),t=s):0!==i.count||n||t(null,o)}};function B(){}var j,q,W,V=String.fromCharCode;function H(e){for(var t,s,n=[],i=0,o=e.length;i<o;)(t=e.charCodeAt(i++))>=55296&&t<=56319&&i<o?56320==(64512&(s=e.charCodeAt(i++)))?n.push(((1023&t)<<10)+(1023&s)+65536):(n.push(t),i--):n.push(t);return n}function z(e,t){if(e>=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function X(e,t){return V(e>>t&63|128)}function J(e,t){if(0==(4294967168&e))return V(e);var s="";return 0==(4294965248&e)?s=V(e>>6&31|192):0==(4294901760&e)?(z(e,t)||(e=65533),s=V(e>>12&15|224),s+=X(e,6)):0==(4292870144&e)&&(s=V(e>>18&7|240),s+=X(e,12),s+=X(e,6)),s+=V(63&e|128)}function Y(){if(W>=q)throw Error("Invalid byte index");var e=255&j[W];if(W++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function K(e){var t,s;if(W>q)throw Error("Invalid byte index");if(W==q)return!1;if(t=255&j[W],W++,0==(128&t))return t;if(192==(224&t)){if((s=(31&t)<<6|Y())>=128)return s;throw Error("Invalid continuation byte")}if(224==(240&t)){if((s=(15&t)<<12|Y()<<6|Y())>=2048)return z(s,e)?s:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(s=(7&t)<<18|Y()<<12|Y()<<6|Y())>=65536&&s<=1114111)return s;throw Error("Invalid UTF-8 detected")}var Q={version:"2.1.2",encode:function(e,t){for(var s=!1!==(t=t||{}).strict,n=H(e),i=n.length,o=-1,r="";++o<i;)r+=J(n[o],s);return r},decode:function(e,t){var s=!1!==(t=t||{}).strict;j=H(e),q=j.length,W=0;for(var n,i=[];!1!==(n=K(s));)i.push(n);return function(e){for(var t,s=e.length,n=-1,i="";++n<s;)(t=e[n])>65535&&(i+=V((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=V(t);return i}(i)}},$=void 0!==$?$:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,Z=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),ee=Z&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),te=$&&$.prototype.append&&$.prototype.getBlob;function se(e){return e.map((function(e){if(e.buffer instanceof ArrayBuffer){var t=e.buffer;if(e.byteLength!==t.byteLength){var s=new Uint8Array(e.byteLength);s.set(new Uint8Array(t,e.byteOffset,e.byteLength)),t=s.buffer}return t}return e}))}function ne(e,t){t=t||{};var s=new $;return se(e).forEach((function(e){s.append(e)})),t.type?s.getBlob(t.type):s.getBlob()}function ie(e,t){return new Blob(se(e),t||{})}"undefined"!=typeof Blob&&(ne.prototype=Blob.prototype,ie.prototype=Blob.prototype);var oe=Z?ee?Blob:ie:te?ne:void 0;!function(e){var t=k,s=L,n=G,i=Q;"undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),"undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),e.protocol=3;var o=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},r=t(o),a={type:"error",data:"parser error"},c=oe;e.encodePacket=function(e,t,s,n){"function"==typeof t&&(n=t,t=!1),"function"==typeof s&&(n=s,s=null),void 0===e.data||e.data.buffer||e.data;var r=o[e.type];return void 0!==e.data&&(r+=s?i.encode(String(e.data),{strict:!1}):String(e.data)),n(""+r)},e.decodePacket=function(e,t,s){if(void 0===e)return a;if("string"==typeof e){if(s&&!1===(e=function(e){try{e=i.decode(e,{strict:!1})}catch(e){return!1}return e}(e)))return a;var n=e.charAt(0);return Number(n)==n&&r[n]?e.length>1?{type:r[n],data:e.substring(1)}:{type:r[n]}:a}n=new Uint8Array(e)[0];var o=sliceBuffer(e,1);return c&&"blob"===t&&(o=new c([o])),{type:r[n],data:o}},e.encodePayload=function(t,i,o){"function"==typeof i&&(o=i,i=null);var r=s(t);if(!t.length)return o("0:");!function(e,t,s){for(var i=new Array(e.length),o=n(e.length,s),r=function(e,s,n){t(s,(function(t,s){i[e]=s,n(t,i)}))},a=0;a<e.length;a++)r(a,e[a],o)}(t,(function(t,s){e.encodePacket(t,!!r&&i,!0,(function(e){s(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return o(t.join(""))}))},e.decodePayload=function(t,s,n){var i;if("function"==typeof s&&(n=s,s=null),""===t)return n(a,0,1);for(var o,r,c="",u=0,l=t.length;u<l;u++){var d=t.charAt(u);if(":"===d){if(""===c||c!=(o=Number(c)))return n(a,0,1);if(c!=(r=t.substr(u+1,o)).length)return n(a,0,1);if(r.length){if(i=e.decodePacket(r,s,!0),a.type===i.type&&a.data===i.data)return n(a,0,1);if(!1===n(i,u+o,l))return}u+=o,c=""}else c+=d}return""!==c?n(a,0,1):void 0}}(P);var re=P,ae=ce;function ce(e){this.path=e.path,this.hostname=e.hostname,this.port=e.port,this.secure=e.secure,this.query=e.query,this.timestampParam=e.timestampParam,this.timestampRequests=e.timestampRequests,this.readyState="",this.agent=e.agent||!1,this.socket=e.socket,this.enablesXDR=e.enablesXDR,this.pfx=e.pfx,this.key=e.key,this.passphrase=e.passphrase,this.cert=e.cert,this.ca=e.ca,this.ciphers=e.ciphers,this.rejectUnauthorized=e.rejectUnauthorized,this.forceNode=e.forceNode,this.isReactNative=e.isReactNative,this.extraHeaders=e.extraHeaders,this.localAddress=e.localAddress}(0,N.exports)(ce.prototype),ce.prototype.onError=function(e,t){var s=new Error(e);return s.type="TransportError",s.description=t,this.emit("error",s),this},ce.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},ce.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},ce.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},ce.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},ce.prototype.onData=function(e){var t=re.decodePacket(e,this.socket.binaryType);this.onPacket(t)},ce.prototype.onPacket=function(e){this.emit("packet",e)},ce.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var ue,le={encode:function(e){var t="";for(var s in e)e.hasOwnProperty(s)&&(t.length&&(t+="&"),t+=encodeURIComponent(s)+"="+encodeURIComponent(e[s]));return t},decode:function(e){for(var t={},s=e.split("&"),n=0,i=s.length;n<i;n++){var o=s[n].split("=");t[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return t}},de=function(e,t){var s=function(){};s.prototype=t.prototype,e.prototype=new s,e.prototype.constructor=e},he="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),pe={},fe=0,me=0;function ge(e){var t="";do{t=he[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function ye(){var e=ge(+new Date);return e!==ue?(fe=0,ue=e):e+"."+ge(fe++)}for(;me<64;me++)pe[he[me]]=me;ye.encode=ge,ye.decode=function(e){var t=0;for(me=0;me<e.length;me++)t=64*t+pe[e.charAt(me)];return t};var ve=ye,Ee={exports:{}},Se={exports:{}},Ce=1e3,be=60*Ce,we=60*be,Ie=24*we,Me=365.25*Ie,Ae=function(e,t){t=t||{};var s=typeof e;if("string"===s&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var s=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return s*Me;case"days":case"day":case"d":return s*Ie;case"hours":case"hour":case"hrs":case"hr":case"h":return s*we;case"minutes":case"minute":case"mins":case"min":case"m":return s*be;case"seconds":case"second":case"secs":case"sec":case"s":return s*Ce;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}(e);if("number"===s&&!1===isNaN(e))return t.long?function(e){return Ne(e,Ie,"day")||Ne(e,we,"hour")||Ne(e,be,"minute")||Ne(e,Ce,"second")||e+" ms"}(e):function(e){if(e>=Ie)return Math.round(e/Ie)+"d";if(e>=we)return Math.round(e/we)+"h";if(e>=be)return Math.round(e/be)+"m";if(e>=Ce)return Math.round(e/Ce)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ne(e,t,s){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+s:Math.ceil(e/t)+" "+s+"s"}!function(e,t){function s(e){var s;function i(){if(i.enabled){var e=i,n=+new Date,o=n-(s||n);e.diff=o,e.prev=s,e.curr=n,s=n;for(var r=new Array(arguments.length),a=0;a<r.length;a++)r[a]=arguments[a];r[0]=t.coerce(r[0]),"string"!=typeof r[0]&&r.unshift("%O");var c=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,(function(s,n){if("%%"===s)return s;c++;var i=t.formatters[n];if("function"==typeof i){var o=r[c];s=i.call(e,o),r.splice(c,1),c--}return s})),t.formatArgs.call(e,r);var u=i.log||t.log||console.log.bind(console);u.apply(e,r)}}return i.namespace=e,i.enabled=t.enabled(e),i.useColors=t.useColors(),i.color=function(e){var s,n=0;for(s in e)n=(n<<5)-n+e.charCodeAt(s),n|=0;return t.colors[Math.abs(n)%t.colors.length]}(e),i.destroy=n,"function"==typeof t.init&&t.init(i),t.instances.push(i),i}function n(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=Se.exports=s.debug=s.default=s).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var s;t.save(e),t.names=[],t.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),i=n.length;for(s=0;s<i;s++)n[s]&&("-"===(e=n[s].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(s=0;s<t.instances.length;s++){var o=t.instances[s];o.enabled=t.enabled(o.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var s,n;for(s=0,n=t.skips.length;s<n;s++)if(t.skips[s].test(e))return!1;for(s=0,n=t.names.length;s<n;s++)if(t.names[s].test(e))return!0;return!1},t.humanize=Ae,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(0,Se.exports),function(e,t){function s(){var e;try{e=t.storage.debug}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e}(t=e.exports=Se.exports).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var s=this.useColors;if(e[0]=(s?"%c":"")+this.namespace+(s?" %c":" ")+e[0]+(s?"%c ":" ")+"+"+t.humanize(this.diff),!s)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))})),e.splice(o,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=s,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(s())}(Ee,Ee.exports);var Te={exports:{}};try{Te.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){Te.exports=!1}var Oe=Te.exports,_e=function(e){var t=e.xdomain,s=e.xscheme,n=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||Oe))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!s&&n)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},Re=ae,Pe=le,ke=P,De=de,xe=ve,Fe=Ee.exports("engine.io-client:polling"),Ue=Ge,Le=null!=new _e({xdomain:!1}).responseType;function Ge(e){var t=e&&e.forceBase64;Le&&!t||(this.supportsBinary=!1),Re.call(this,e)}De(Ge,Re),Ge.prototype.name="polling",Ge.prototype.doOpen=function(){this.poll()},Ge.prototype.pause=function(e){var t=this;function s(){Fe("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var n=0;this.polling&&(Fe("we are currently polling - waiting to pause"),n++,this.once("pollComplete",(function(){Fe("pre-pause polling complete"),--n||s()}))),this.writable||(Fe("we are currently writing - waiting to pause"),n++,this.once("drain",(function(){Fe("pre-pause writing complete"),--n||s()})))}else s()},Ge.prototype.poll=function(){Fe("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},Ge.prototype.onData=function(e){var t=this;Fe("polling got data %s",e);ke.decodePayload(e,this.socket.binaryType,(function(e,s,n){if("opening"===t.readyState&&t.onOpen(),"close"===e.type)return t.onClose(),!1;t.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():Fe('ignoring poll - transport state "%s"',this.readyState))},Ge.prototype.doClose=function(){var e=this;function t(){Fe("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Fe("transport open - closing"),t()):(Fe("transport not open - deferring close"),this.once("open",t))},Ge.prototype.write=function(e){var t=this;this.writable=!1;var s=function(){t.writable=!0,t.emit("drain")};ke.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,s)}))},Ge.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",s="";return!1!==this.timestampRequests&&(e[this.timestampParam]=xe()),this.supportsBinary||e.sid||(e.b64=1),e=Pe.encode(e),this.port&&("https"===t&&443!==Number(this.port)||"http"===t&&80!==Number(this.port))&&(s=":"+this.port),e.length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+s+this.path+e};var Be,je=Ue,qe=Xe,We=/\n/g,Ve=/\\n/g;function He(){}function ze(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==l?l:{}}function Xe(e){if(je.call(this,e),this.query=this.query||{},!Be){var t=ze();Be=t.___eio=t.___eio||[]}this.index=Be.length;var s=this;Be.push((function(e){s.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){s.script&&(s.script.onerror=He)}),!1)}de(Xe,je),Xe.prototype.supportsBinary=!1,Xe.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),je.prototype.doClose.call(this)},Xe.prototype.doPoll=function(){var e=this,t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=function(t){e.onError("jsonp poll error",t)};var s=document.getElementsByTagName("script")[0];s?s.parentNode.insertBefore(t,s):(document.head||document.body).appendChild(t),this.script=t,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var e=document.createElement("iframe");document.body.appendChild(e),document.body.removeChild(e)}),100)},Xe.prototype.doWrite=function(e,t){var s=this;if(!this.form){var n,i=document.createElement("form"),o=document.createElement("textarea"),r=this.iframeId="eio_iframe_"+this.index;i.className="socketio",i.style.position="absolute",i.style.top="-1000px",i.style.left="-1000px",i.target=r,i.method="POST",i.setAttribute("accept-charset","utf-8"),o.name="d",i.appendChild(o),document.body.appendChild(i),this.form=i,this.area=o}function a(){c(),t()}function c(){if(s.iframe)try{s.form.removeChild(s.iframe)}catch(e){s.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+s.iframeId+'">';n=document.createElement(e)}catch(e){(n=document.createElement("iframe")).name=s.iframeId,n.src="javascript:0"}n.id=s.iframeId,s.form.appendChild(n),s.iframe=n}this.form.action=this.uri(),c(),e=e.replace(Ve,"\\\n"),this.area.value=e.replace(We,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===s.iframe.readyState&&a()}:this.iframe.onload=a};var Je,Ye=ae,Ke=P,Qe=le,$e=de,Ze=ve,et=Ee.exports("engine.io-client:websocket");("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&("undefined"!=typeof WebSocket?Je=WebSocket:"undefined"!=typeof self&&(Je=self.WebSocket||self.MozWebSocket));var st=Je||undefined;("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&"undefined"==typeof GameGlobal||(st=function(e){var t=this;if(t.onopen=function(){},t.onclose=function(){},t.onmessage=function(e){},t.onerror=function(e){},"object"==typeof tt&&tt.getSystemInfo){let s=tt.connectSocket({url:e});t.send=function(e){s.send({data:e})},t.close=function(){s.close()},s.onOpen((function(){t.onopen()})),s.onError((function(e){t.onerror(e)})),s.onMessage((function(e){t.onmessage(e)})),s.onClose((function(){t.onclose()}))}else if("undefined"!=typeof uni)if("undefined"!=typeof my)my.connectSocket({url:e}),t.send=function(e){my.sendSocketMessage({data:e})},t.close=function(e){my.closeSocket()},my.onSocketOpen((function(e){t.onopen()})),my.onSocketError((function(e){t.onerror(e)})),my.onSocketMessage((function(e){t.onmessage(e)})),my.onSocketClose((e=>{t.onclose(e)}));else{var s=uni.connectSocket({url:e,complete:()=>{}});t.send=function(e){s.send({data:e})},t.close=function(){s.close()},s.onOpen((function(e){t.onopen()})),s.onError((function(e){t.onerror(e)})),s.onMessage((function(e){t.onmessage(e)})),s.onClose((function(e){t.onclose()}))}else{var n=wx.connectSocket({url:e});t.send=function(e){n.send({data:e})},t.close=function(e){n.close({code:1e3})},n.onOpen((function(){t.onopen()})),n.onError((function(e){t.onerror(e)})),n.onMessage((function(e){t.onmessage(e)})),n.onClose((function(e){t.onclose(e)}))}});var nt=it;function it(e){e&&e.forceBase64&&(this.supportsBinary=!1),("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&(this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=Je&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(st=undefined)),Ye.call(this,e)}$e(it,Ye),it.prototype.name="websocket",it.prototype.supportsBinary=!1,it.prototype.doOpen=function(){if(this.check()){var e,t,s=this.uri();("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&(e=this.protocols),(t="undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket?{agent:this.agent,perMessageDeflate:this.perMessageDeflate}:{agent:this.agent}).pfx=this.pfx,t.key=this.key,t.passphrase=this.passphrase,t.cert=this.cert,t.ca=this.ca,t.ciphers=this.ciphers,t.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(t.headers=this.extraHeaders),this.localAddress&&(t.localAddress=this.localAddress);try{"undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket?this.ws=this.usingBrowserWebSocket&&!this.isReactNative?e?new st(s,e):new st(s):new st(s,e,t):this.ws=new st(s)}catch(e){return this.emit("error",e)}void 0===this.ws.binaryType&&(this.supportsBinary=!1),this.ws.supports&&this.ws.supports.binary?(this.supportsBinary=!0,this.ws.binaryType="nodebuffer"):this.ws.binaryType="arraybuffer",this.addEventListeners()}},it.prototype.addEventListeners=function(){var e=this;this.ws.onopen=function(){e.onOpen()},this.ws.onclose=function(){e.onClose()},this.ws.onmessage=function(t){e.onData(t.data)},this.ws.onerror=function(t){e.onError("websocket error",t)}},it.prototype.write=function(e){var t=this;this.writable=!1;for(var s=e.length,n=0,i=s;n<i;n++)!function(e){Ke.encodePacket(e,t.supportsBinary,(function(n){if("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket){if(!t.usingBrowserWebSocket){var i={};if(e.options&&(i.compress=e.options.compress),t.perMessageDeflate)("string"==typeof n?Buffer.byteLength(n):n.length)<t.perMessageDeflate.threshold&&(i.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(n):t.ws.send(n,i)}catch(e){et("websocket closed before onclose event")}}else try{t.ws.send(n)}catch(e){et("websocket closed before onclose event")}--s||o()}))}(e[n]);function o(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},it.prototype.onClose=function(){Ye.prototype.onClose.call(this)},it.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},it.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",s="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(s=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=Ze()),this.supportsBinary||(e.b64=1),(e=Qe.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+s+this.path+e},it.prototype.check=function(){return!(!st||"__initialize"in st&&this.name===it.prototype.name)};var ot=qe,rt=nt;R.polling=function(e){var t=!1,s=!1;if(e.jsonp,"undefined"!=typeof location){var n="https:"===location.protocol,i=location.port;i||(i=n?443:80),t=e.hostname!==location.hostname||i!==e.port,s=e.secure!==n}return e.xdomain=t,e.xscheme=s,new ot(e)},R.websocket=rt;var at=[].indexOf,ct=function(e,t){if(at)return e.indexOf(t);for(var s=0;s<e.length;++s)if(e[s]===t)return s;return-1},ut=R,lt=N.exports,dt=Ee.exports("engine.io-client:socket"),ht=ct,pt=P,ft=m,mt=le,gt=yt;function yt(e,t){if(!(this instanceof yt))return new yt(e,t);t=t||{},e&&"object"==typeof e&&(t=e,e=null),e?(e=ft(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=ft(t.host).host),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.agent=t.agent||!1,this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=t.query||{},"string"==typeof this.query&&(this.query=mt.decode(this.query)),this.upgrade=!1!==t.upgrade,this.path=(t.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!t.forceJSONP,this.jsonp=!1!==t.jsonp,this.forceBase64=!!t.forceBase64,this.enablesXDR=!!t.enablesXDR,this.timestampParam=t.timestampParam||"t",this.timestampRequests=t.timestampRequests,this.transports=t.transports||["polling","websocket"],this.transportOptions=t.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=t.policyPort||843,this.rememberUpgrade=t.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=t.onlyBinaryUpgrades,this.perMessageDeflate=!1!==t.perMessageDeflate&&(t.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=t.pfx||null,this.key=t.key||null,this.passphrase=t.passphrase||null,this.cert=t.cert||null,this.ca=t.ca||null,this.ciphers=t.ciphers||null,this.rejectUnauthorized=void 0===t.rejectUnauthorized||t.rejectUnauthorized,this.forceNode=!!t.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(t.extraHeaders&&Object.keys(t.extraHeaders).length>0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}yt.priorWebsocketSuccess=!1,lt(yt.prototype),yt.protocol=pt.protocol,yt.Socket=yt,yt.Transport=ae,yt.transports=R,yt.parser=P,yt.prototype.createTransport=function(e){dt('creating transport "%s"',e);var t=function(e){var t={};for(var s in e)e.hasOwnProperty(s)&&(t[s]=e[s]);return t}(this.query);t.EIO=pt.protocol,t.transport=e;var s=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new ut[e]({query:t,socket:this,agent:s.agent||this.agent,hostname:s.hostname||this.hostname,port:s.port||this.port,secure:s.secure||this.secure,path:s.path||this.path,forceJSONP:s.forceJSONP||this.forceJSONP,jsonp:s.jsonp||this.jsonp,forceBase64:s.forceBase64||this.forceBase64,enablesXDR:s.enablesXDR||this.enablesXDR,timestampRequests:s.timestampRequests||this.timestampRequests,timestampParam:s.timestampParam||this.timestampParam,policyPort:s.policyPort||this.policyPort,pfx:s.pfx||this.pfx,key:s.key||this.key,passphrase:s.passphrase||this.passphrase,cert:s.cert||this.cert,ca:s.ca||this.ca,ciphers:s.ciphers||this.ciphers,rejectUnauthorized:s.rejectUnauthorized||this.rejectUnauthorized,perMessageDeflate:s.perMessageDeflate||this.perMessageDeflate,extraHeaders:s.extraHeaders||this.extraHeaders,forceNode:s.forceNode||this.forceNode,localAddress:s.localAddress||this.localAddress,requestTimeout:s.requestTimeout||this.requestTimeout,protocols:s.protocols||void 0,isReactNative:this.isReactNative})},yt.prototype.open=function(){var e;if(this.rememberUpgrade&&yt.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length){var t=this;return void setTimeout((function(){t.emit("error","No transports available")}),0)}e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)},yt.prototype.setTransport=function(e){dt("setting transport %s",e.name);var t=this;this.transport&&(dt("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",(function(){t.onDrain()})).on("packet",(function(e){t.onPacket(e)})).on("error",(function(e){t.onError(e)})).on("close",(function(){t.onClose("transport close")}))},yt.prototype.probe=function(e){dt('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),s=!1,n=this;function i(){if(n.onlyBinaryUpgrades){var i=!this.supportsBinary&&n.transport.supportsBinary;s=s||i}s||(dt('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(i){if(!s)if("pong"===i.type&&"probe"===i.data){if(dt('probe transport "%s" pong',e),n.upgrading=!0,n.emit("upgrading",t),!t)return;yt.priorWebsocketSuccess="websocket"===t.name,dt('pausing current transport "%s"',n.transport.name),n.transport.pause((function(){s||"closed"!==n.readyState&&(dt("changing transport and sending upgrade packet"),l(),n.setTransport(t),t.send([{type:"upgrade"}]),n.emit("upgrade",t),t=null,n.upgrading=!1,n.flush())}))}else{dt('probe transport "%s" failed',e);var o=new Error("probe error");o.transport=t.name,n.emit("upgradeError",o)}})))}function o(){s||(s=!0,l(),t.close(),t=null)}function r(s){var i=new Error("probe error: "+s);i.transport=t.name,o(),dt('probe transport "%s" failed because of error: %s',e,s),n.emit("upgradeError",i)}function a(){r("transport closed")}function c(){r("socket closed")}function u(e){t&&e.name!==t.name&&(dt('"%s" works - aborting "%s"',e.name,t.name),o())}function l(){t.removeListener("open",i),t.removeListener("error",r),t.removeListener("close",a),n.removeListener("close",c),n.removeListener("upgrading",u)}yt.priorWebsocketSuccess=!1,t.once("open",i),t.once("error",r),t.once("close",a),this.once("close",c),this.once("upgrading",u),t.open()},yt.prototype.onOpen=function(){if(dt("socket open"),this.readyState="open",yt.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){dt("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},yt.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(dt('socket receive: type "%s", data "%s"',e.type,e.data),this.emit("packet",e),this.emit("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emit("data",e.data),this.emit("message",e.data)}else dt('packet received with socket readyState "%s"',this.readyState)},yt.prototype.onHandshake=function(e){this.emit("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},yt.prototype.onHeartbeat=function(e){clearTimeout(this.pingTimeoutTimer);var t=this;t.pingTimeoutTimer=setTimeout((function(){"closed"!==t.readyState&&t.onClose("ping timeout")}),e||t.pingInterval+t.pingTimeout)},yt.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){dt("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},yt.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},yt.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},yt.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(dt("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},yt.prototype.write=yt.prototype.send=function(e,t,s){return this.sendPacket("message",e,t,s),this},yt.prototype.sendPacket=function(e,t,s,n){if("function"==typeof t&&(n=t,t=void 0),"function"==typeof s&&(n=s,s=null),"closing"!==this.readyState&&"closed"!==this.readyState){(s=s||{}).compress=!1!==s.compress;var i={type:e,data:t,options:s};this.emit("packetCreate",i),this.writeBuffer.push(i),n&&this.once("flush",n),this.flush()}},yt.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var e=this;this.writeBuffer.length?this.once("drain",(function(){this.upgrading?n():t()})):this.upgrading?n():t()}function t(){e.onClose("forced close"),dt("socket closing - telling transport to close"),e.transport.close()}function s(){e.removeListener("upgrade",s),e.removeListener("upgradeError",s),t()}function n(){e.once("upgrade",s),e.once("upgradeError",s)}return this},yt.prototype.onError=function(e){dt("socket error %j",e),yt.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},yt.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){dt('socket close with reason: "%s"',e);clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",e,t),this.writeBuffer=[],this.prevBufferLen=0}},yt.prototype.filterUpgrades=function(e){for(var t=[],s=0,n=e.length;s<n;s++)~ht(this.transports,e[s])&&t.push(e[s]);return t},_.exports=gt,_.exports.parser=P;var vt={exports:{}},Et=function(e,t){for(var s=[],n=(t=t||0)||0;n<e.length;n++)s[n-t]=e[n];return s};var St=function(e,t,s){return e.on(t,s),{destroy:function(){e.removeListener(t,s)}}};var Ct=[].slice,bt=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var s=Ct.call(arguments,2);return function(){return t.apply(e,s.concat(Ct.call(arguments)))}};!function(e,t){var s=A,n=N.exports,i=Et,o=St,r=bt,a=(g.exports("socket.io-client:socket"),le),c=L;e.exports=d;var u={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},l=n.prototype.emit;function d(e,t,s){this.io=e,this.nsp=t,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},s&&s.query&&(this.query=s.query),this.io.autoConnect&&this.open()}n(d.prototype),d.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[o(e,"open",r(this,"onopen")),o(e,"packet",r(this,"onpacket")),o(e,"close",r(this,"onclose"))]}},d.prototype.open=d.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},d.prototype.send=function(){var e=i(arguments);return e.unshift("message"),this.emit.apply(this,e),this},d.prototype.emit=function(e){if(u.hasOwnProperty(e))return l.apply(this,arguments),this;var t=i(arguments),n={type:(void 0!==this.flags.binary?this.flags.binary:c(t))?s.BINARY_EVENT:s.EVENT,data:t,options:{}};return n.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(this.ids,this.acks[this.ids]=t.pop(),n.id=this.ids++),this.connected?this.packet(n):this.sendBuffer.push(n),this.flags={},this},d.prototype.packet=function(e){e.nsp=this.nsp,this.io.packet(e)},d.prototype.onopen=function(){if("/"!==this.nsp)if(this.query){var e="object"==typeof this.query?a.encode(this.query):this.query;this.packet({type:s.CONNECT,query:e})}else this.packet({type:s.CONNECT})},d.prototype.onclose=function(e){this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",e)},d.prototype.onpacket=function(e){var t=e.nsp===this.nsp,n=e.type===s.ERROR&&"/"===e.nsp;if(t||n)switch(e.type){case s.CONNECT:this.onconnect();break;case s.EVENT:case s.BINARY_EVENT:this.onevent(e);break;case s.ACK:case s.BINARY_ACK:this.onack(e);break;case s.DISCONNECT:this.ondisconnect();break;case s.ERROR:this.emit("error",e.data)}},d.prototype.onevent=function(e){var t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?l.apply(this,t):this.receiveBuffer.push(t)},d.prototype.ack=function(e){var t=this,n=!1;return function(){if(!n){n=!0;var o=i(arguments);t.packet({type:c(o)?s.BINARY_ACK:s.ACK,id:e,data:o})}}},d.prototype.onack=function(e){var t=this.acks[e.id];"function"==typeof t?(e.id,e.data,t.apply(this,e.data),delete this.acks[e.id]):e.id},d.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},d.prototype.emitBuffered=function(){var e;for(e=0;e<this.receiveBuffer.length;e++)l.apply(this,this.receiveBuffer[e]);for(this.receiveBuffer=[],e=0;e<this.sendBuffer.length;e++)this.packet(this.sendBuffer[e]);this.sendBuffer=[]},d.prototype.ondisconnect=function(){this.nsp,this.destroy(),this.onclose("io server disconnect")},d.prototype.destroy=function(){if(this.subs){for(var e=0;e<this.subs.length;e++)this.subs[e].destroy();this.subs=null}this.io.destroy(this)},d.prototype.close=d.prototype.disconnect=function(){return this.connected&&(this.nsp,this.packet({type:s.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},d.prototype.compress=function(e){return this.flags.compress=e,this},d.prototype.binary=function(e){return this.flags.binary=e,this}}(vt);var wt=It;function It(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}It.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),s=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-s:e+s}return 0|Math.min(e,this.max)},It.prototype.reset=function(){this.attempts=0},It.prototype.setMin=function(e){this.ms=e},It.prototype.setMax=function(e){this.max=e},It.prototype.setJitter=function(e){this.jitter=e};var Mt={},At={},Nt=d(u),Tt={};!function(e){e.__esModule=!0,e.PlatformDetector=e.Platform=void 0;var t,s=Nt;!function(e){e.BROWSER="BROWSER",e.UNKNOWN="UNKNOWN",e.APP_IOS="APP_IOS",e.APP_ANDROID="APP_ANDROID",e.APPLET_WX="APPLET_WX",e.APPLET_WX_GAME="APPLET_WX_GAME",e.APPLET_ALIPAY="APPLET_ALIPAY",e.APPLET_BYTEDANCE="APPLET_BYTEDANCE"}(t=e.Platform||(e.Platform={}));var n=function(){function e(){var e,n,i;this.platform=null,this.methods=((e={})[t.BROWSER]=this.isBrowser,e[t.APP_IOS]=this.isAppiOS,e[t.APP_ANDROID]=this.isAppAndroid,e[t.APPLET_WX]=this.isWXApplet,e[t.APPLET_WX_GAME]=this.isWXGameApplet,e);var o=this.methods,r=Object.keys(o);try{for(var a=s.__values(r),c=a.next();!c.done;c=a.next()){var u=c.value;if((0,o[u])()){this.platform=u;break}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}this.platform=this.platform||t.UNKNOWN,this.platform}return e.currentPlatform=function(){return e.instance.platform},e.prototype.isBrowser=function(){return"undefined"!=typeof navigator&&"Taro"!==navigator.product&&"undefined"==typeof GameGlobal&&("undefined"==typeof cc||null!==cc.sys.browserType)},e.prototype.isAppiOS=function(){return"undefined"!=typeof cc&&cc.sys.isNative&&cc.sys.isMobile&&"iOS"===cc.sys.os||"object"==typeof uni&&!!uni.getSystemInfoSync&&"ios"===uni.getSystemInfoSync().platform&&"object"==typeof plus},e.prototype.isAppAndroid=function(){return"undefined"!=typeof cc&&cc.sys.isNative&&cc.sys.isMobile&&"Android"===cc.sys.os||"object"==typeof uni&&!!uni.getSystemInfoSync&&"android"===uni.getSystemInfoSync().platform&&"object"==typeof plus},e.prototype.isWXApplet=function(){return"object"==typeof wx&&!!wx.getSystemInfoSync&&"undefined"==typeof WebSocket&&"undefined"==typeof XMLHttpRequest&&"undefined"==typeof plus},e.prototype.isWXGameApplet=function(){return"object"==typeof GameGlobal},e.prototype.isAlipayApplet=function(){return!1},e.prototype.isBytedanceApplet=function(){return!1},e.prototype.isQQApplet=function(){return!1},e.prototype.isBaiduApplet=function(){return!1},e.instance=new e,e}();e.PlatformDetector=n}(Tt),function(e){e.__esModule=!0,e.FrameworkDetector=e.Framework=void 0;var t,s=Nt,n=Tt;!function(e){e.UNIAPP="UNIAPP",e.REACT_NATIVE="REACT_NATIVE",e.COCOS="COCOS",e.TARO="TARO",e.IONIC="IONIC",e.NATIVE_APPLET_WX="NATIVE_APPLET_WX",e.NATIVE_APPLET_ALIPAY="NATIVE_APPLET_ALIPAY",e.UNKNOWN="UNKNOWN"}(t=e.Framework||(e.Framework={}));var i=function(){function e(){var e,n,i;this.framework=null,this.methods=((e={})[t.UNIAPP]=this.isUniApp,e[t.REACT_NATIVE]=this.isReactNative,e[t.TARO]=this.isTaro,e[t.NATIVE_APPLET_WX]=this.isWXApplet,e[t.COCOS]=this.isCocos,e);var o=this.methods,r=Object.keys(o);try{for(var a=s.__values(r),c=a.next();!c.done;c=a.next()){var u=c.value;if((0,o[u])()){this.framework=u;break}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}this.framework=this.framework||t.UNKNOWN,this.framework}return e.currentFramework=function(){return this.instance.framework},e.prototype.isUniApp=function(){return"object"==typeof uni&&!!uni.getSystemInfoSync},e.prototype.isReactNative=function(){return void 0!==l&&l.__fbGenNativeModule},e.prototype.isTaro=function(){return"undefined"!=typeof process&&void 0!==process.env.TARO_ENV},e.prototype.isWXApplet=function(){return n.PlatformDetector.currentPlatform()===n.Platform.APPLET_WX&&"undefined"==typeof uni},e.prototype.isCocos=function(){try{return void 0!==cc.sys.localStorage}catch(e){return!1}},e.instance=new e,e}();e.FrameworkDetector=i}(At),Mt.__esModule=!0,Mt.uniApp=void 0;var Ot=At,_t=function(){function e(){this.uniAppRunningBackend=!1,this.listenAppRunning()}return e.prototype.listenAppRunning=function(){var e=this;Ot.FrameworkDetector.currentFramework()===Ot.Framework.UNIAPP&&"object"==typeof plus&&(plus.globalEvent.addEventListener("resume",(function(){e.uniAppRunningBackend=!1,e.uniAppRunningBackend}),!1),plus.globalEvent.addEventListener("pause",(function(){e.uniAppRunningBackend=!0,e.uniAppRunningBackend}),!1))},e.prototype.runningBackend=function(){return this.uniAppRunningBackend},e}(),Rt=new _t;Mt.uniApp=Rt;var Pt,kt={},Dt={};(Pt=Dt).__esModule=!0,Pt.default={maxNumber:5};var xt={},Ft={__esModule:!0,Cookie:void 0},Ut=Nt,Lt=function(){function e(){}return e.get=function(e){var t,s,n=encodeURIComponent(e)+"=",i=document.cookie.split("; ");try{for(var o=Ut.__values(i),r=o.next();!r.done;r=o.next()){var a=r.value;if(a.startsWith(n))return decodeURIComponent(a.substring(n.length))}}catch(e){t={error:e}}finally{try{r&&!r.done&&(s=o.return)&&s.call(o)}finally{if(t)throw t.error}}return null},e.set=function(e,t,s,n,i,o){void 0===i&&(i="/"),void 0===o&&(o=!1);var r=encodeURIComponent(e)+"="+encodeURIComponent(t);s instanceof Date&&(r+="; expires="+s.toGMTString()),i&&(r+="; path="+i),n&&(r+="; domain="+n),o&&(r+="; secure"),document.cookie=r},e.remove=function(t,s,n,i){void 0===n&&(n="/"),void 0===i&&(i=!1),e.set(t,"",new Date(0),s,n,i)},e}();Ft.Cookie=Lt,xt.__esModule=!0,xt.LocalStorageDispatcher=void 0;var Gt=Nt,Bt=Ft,jt=function(){function e(){this.domain=null;this.domain="undefined"!=typeof location&&/^(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/.test(location.host)?location.host.split(".").slice(-2).join("."):null}return e.prototype.get=function(e){var t=Bt.Cookie.get(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){var s=new Date(2030,12,31,0,0,0,0),n=this.domain;Bt.Cookie.set(e,JSON.stringify(t),s,n)},e.prototype.remove=function(e){var t=this.domain;Bt.Cookie.remove(e,t)},e.prototype.support=function(){return"undefined"!=typeof navigator&&!0===navigator.cookieEnabled},e}(),qt=function(){function e(){}return e.prototype.get=function(e){var t=localStorage.getItem(e);return JSON.parse(t)},e.prototype.put=function(e,t){var s=localStorage.setItem(e,JSON.stringify(t));JSON.stringify(s)},e.prototype.remove=function(e){localStorage.removeItem(e)},e.prototype.support=function(){return!("undefined"!=typeof GameGlobal||"undefined"==typeof localStorage||!localStorage.setItem)},e}(),Wt=function(){function e(){}return e.prototype.get=function(e){var t=uni.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){uni.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){uni.removeStorageSync(e)},e.prototype.support=function(){return!("object"!=typeof uni||!uni.getStorageSync)},e}(),Vt=function(){function e(){}return e.prototype.get=function(e){var t=cc.sys.localStorage.getItem(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){cc.sys.localStorage.setItem(e,JSON.stringify(t))},e.prototype.remove=function(e){cc.sys.localStorage.removeItem(e)},e.prototype.support=function(){return"undefined"!=typeof cc&&void 0!==cc.sys.localStorage},e}(),Ht=function(){function e(){}return e.prototype.get=function(e){var t=wx.getStorageSync(e)||null;return JSON.parse(t)},e.prototype.put=function(e,t){wx.setStorageSync(e,JSON.stringify(t))},e.prototype.remove=function(e){wx.removeStorageSync(e)},e.prototype.support=function(){return!("object"!=typeof wx||!wx.getStorageSync)},e}(),zt=function(){function e(){this.supportedStorage=null;var t=e.storages;t.push(new Wt),t.push(new Vt),t.push(new qt),t.push(new Ht),t.push(new jt),this.dispatch(),this.supportedStorage}return e.localStorage=function(){return this.instance.supportedStorage},e.prototype.dispatch=function(){var t,s;try{for(var n=Gt.__values(e.storages),i=n.next();!i.done;i=n.next()){var o=i.value;if(o.support()){this.supportedStorage=o;break}}}catch(e){t={error:e}}finally{try{i&&!i.done&&(s=n.return)&&s.call(n)}finally{if(t)throw t.error}}},e.storages=new Array,e.instance=new e,e}();xt.LocalStorageDispatcher=zt,kt.__esModule=!0,kt.goEasyDomainNumber=void 0;var Xt=Dt,Jt=xt,Yt=function(){function e(){}return e.prototype.refreshNumber=function(){var t=e.GOEASY_DOMAIN_NUMBER,s=Jt.LocalStorageDispatcher.localStorage(),n=Math.floor(Math.random()*(Xt.default.maxNumber-1)+1);return null!==s&&(n=parseInt(s.get(t))||n),n>0&&n<Xt.default.maxNumber?n+=1:n===Xt.default.maxNumber&&(n=1),null!==s&&s.put(t,n),n},e.GOEASY_DOMAIN_NUMBER="GOEASY_DOMAIN_NUMBER",e}(),Kt=new Yt;kt.goEasyDomainNumber=Kt;var Qt,$t=_.exports,Zt=vt.exports,es=N.exports,ts=A,ss=St,ns=bt,is=(g.exports("socket.io-client:manager"),ct),os=wt,rs=Mt.uniApp,as=kt.goEasyDomainNumber,cs=Object.prototype.hasOwnProperty,us=ls;function ls(e,t){if(!(this instanceof ls))return new ls(e,t);e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.nsps={},this.subs=[],this.opts=t,this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor||.5),this.backoff=new os({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this.readyState="closed",this.uri=e,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var s=t.parser||ts;this.encoder=new s.Encoder,this.decoder=new s.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}function ds(){var e=!1;return"object"==typeof uni&&uni.getSystemInfo&&(e=!0),e&&rs.runningBackend()}ls.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)cs.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},ls.prototype.updateSocketIds=function(){for(var e in this.nsps)cs.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},ls.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},es(ls.prototype),ls.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},ls.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},ls.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},ls.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},ls.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},ls.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},ls.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},ls.prototype.open=ls.prototype.connect=function(e,t){if(this.readyState,~this.readyState.indexOf("open"))return this;this.uri,this.engine=$t(this.uri,this.opts);var s=this.engine,n=this;this.readyState="opening",this.skipReconnect=!1;var i=ss(s,"open",(function(){n.onopen(),e&&e()})),o=ss(s,"error",(function(t){if("undefined"!=typeof window){var s=parseInt(n.uri.match(/[1-9][0-9]*/g)[0]),i=as.refreshNumber();n.uri=n.uri.replace(s,i)}if(n.cleanup(),n.readyState="closed",n.emitAll("connect_error",t),e){var o=new Error("Connection error");o.data=t,e(o)}else n.maybeReconnectOnOpen()}));if(!1!==this._timeout){var r=this._timeout,a=setTimeout((function(){i.destroy(),s.close(),s.emit("error","timeout"),n.emitAll("connect_timeout",r)}),r);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(i),this.subs.push(o),this},ls.prototype.onopen=function(){this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(ss(e,"data",ns(this,"ondata"))),this.subs.push(ss(e,"ping",ns(this,"onping"))),this.subs.push(ss(e,"pong",ns(this,"onpong"))),this.subs.push(ss(e,"error",ns(this,"onerror"))),this.subs.push(ss(e,"close",ns(this,"onclose"))),this.subs.push(ss(this.decoder,"decoded",ns(this,"ondecoded")))},ls.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},ls.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},ls.prototype.ondata=function(e){this.decoder.add(e)},ls.prototype.ondecoded=function(e){this.emit("packet",e)},ls.prototype.onerror=function(e){this.emitAll("error",e)},ls.prototype.socket=function(e,t){var s=this.nsps[e];if(!s){s=new Zt(this,e,t),this.nsps[e]=s;var n=this;s.on("connecting",i),s.on("connect",(function(){s.id=n.generateId(e)})),this.autoConnect&&i()}function i(){~is(n.connecting,s)||n.connecting.push(s)}return s},ls.prototype.destroy=function(e){var t=is(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},ls.prototype.packet=function(e){var t=this;e.query&&0===e.type&&(e.nsp+="?"+e.query),t.encoding?t.packetBuffer.push(e):(t.encoding=!0,this.encoder.encode(e,(function(s){for(var n=0;n<s.length;n++)t.engine.write(s[n],e.options);t.encoding=!1,t.processPacketQueue()})))},ls.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},ls.prototype.cleanup=function(){for(var e=this.subs.length,t=0;t<e;t++){this.subs.shift().destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},ls.prototype.close=ls.prototype.disconnect=function(){this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},ls.prototype.onclose=function(e){this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},ls.prototype.reconnect=function(){if(ds(),this.reconnecting||this.skipReconnect)return this;var e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();this.reconnecting=!0;var s=setTimeout((function(){e.skipReconnect||(e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||(ds()?(e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error","Uniapp running backend, skipped reconnect...")):e.open((function(t){t?(e.reconnecting=!1,e.reconnect(),e.emitAll("reconnect_error",t.data)):e.onreconnect()}))))}),t);this.subs.push({destroy:function(){clearTimeout(s)}})}},ls.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)},function(e,t){var s=M,n=A,i=us;g.exports("socket.io-client");e.exports=t=r;var o=t.managers={};function r(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var n,r=s(e),a=r.source,c=r.id,u=r.path,l=o[c]&&u in o[c].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||l?n=i(a,t):(o[c]||(o[c]=i(a,t)),n=o[c]),r.query&&!t.query&&(t.query=r.query),n.socket(r.path,t)}t.protocol=n.protocol,t.connect=r,t.Manager=us,t.Socket=vt.exports}(h,h.exports),function(e){e.WRITE="WRITE",e.READ="READ",e.NONE="NONE"}(Qt||(Qt={}));class hs{constructor(e){this.socket=e}emit(t){this.socket.status!==e.CONNECT_FAILED&&this.socket.status!==e.DISCONNECTED?(t.start(),this.doEmit(t)):t.fail({resultCode:"409",content:"Please connect first"})}doEmit(t){if(t.isTimeout())t.fail({resultCode:408,content:"Host unreachable or timeout"});else if(this.socket.status!==e.CONNECT_FAILED)if(this.authenticated())if(this.hasPermission(t)){if([e.CONNECTED,e.RECONNECTED,e.EXPIRED_RECONNECTED].includes(this.socket.status)){if(!t.complete){let e=setTimeout((()=>{this.doEmit(t)}),t.singleTimeout);t.unique&&(t.params.retried=t.retried),this.socket.doEmit(t.name,t.params,(s=>{clearTimeout(e),200===s.resultCode||200==s.code?t.success(s):t.fail(s)})),t.retried++}}else this.socket.connectedPromise.then((()=>{this.doEmit(t)}))}else t.fail({resultCode:401,content:"No permission"});else this.socket.connectedPromise.then((()=>{this.doEmit(t)}));else t.fail({resultCode:408,content:"Failed to connect GoEasy."})}hasPermission(e){return!!this.socket.permissions.find((t=>t===e.permission))}authenticated(){return[e.CONNECTED,e.RECONNECTING,e.RECONNECTED,e.EXPIRED_RECONNECTED].includes(this.socket.status)}}let ps=new class{isDef(e){return!this.isUndef(e)}isUndef(e){return null==e}isPrimitive(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}isObject(e){return null!==e&&"object"==typeof e}isPlainObject(e){return"[object Object]"===Object.prototype.toString.call(e)}isRegExp(e){return"[object RegExp]"===Object.prototype.toString.call(e)}isValidArrayIndex(e){let t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}isString(e){return"string"==typeof e}isNumber(e){return"number"==typeof e}isStringOrNumber(e){return this.isString(e)||this.isNumber(e)}isArray(e){return"[object Array]"===Object.prototype.toString.call(e)}isEmpty(e){return this.isArray(e)?0===e.length:this.isObject(e)?!this.isDef(e):!this.isNumber(e)&&(this.isString(e)?""===e.trim():!this.isDef(e))}isNative(e){return"function"==typeof e&&/native code/.test(e.toString())}isFunction(e){return"function"==typeof e}isBoolean(e){return"boolean"==typeof e}isTrue(e){return!0===e}isFalse(e){return!1===e}};const fs=h.exports;class ms{constructor(){this.io=fs,this.status=e.DISCONNECTED,this.permissions=[Qt.NONE],this.connectedObservers=[],this.disconnectedObservers=[],this.connectedPromise=null,this.emitter=new hs(this)}connect(){this.status=e.CONNECTING}emit(e){this.emitter.emit(e)}doEmit(e,t,s){}on(e,t){this.io.on(e,t)}disconnect(){this.io.disconnect()}getStatus(){return this.status}addConnectedObserver(e){ps.isFunction(e)&&this.connectedObservers.push(e)}addDisconnectedObserver(e){ps.isFunction(e)&&this.disconnectedObservers.push(e)}notify(e,t){for(let s=0;s<e.length;s++)e[s](t)}}class gs extends ms{constructor(e){super(),this.reconnectingObservers=[],this.addReconnectingObserver(e.onReconnecting),this.addDisconnectedObserver(e.onDisconnected)}connect(e){super.connect(),this.io=this.io.connect(e.uri,e.opts),this.initListener()}doEmit(e,t,s){this.io.emit(e,t,s)}initListener(){this.connectedPromise=new Promise(((t,s)=>{this.io.on("connect",(()=>{this.status=e.CONNECTED,this.notify(this.connectedObservers),t()}))})),this.io.on("reconnecting",(t=>{this.status=e.CONNECTING,this.notify(this.reconnectingObservers,t)})),this.io.on("disconnect",(()=>{this.status=e.DISCONNECTED,this.notify(this.disconnectedObservers)})),this.io.on("connect_error",(function(e){}))}addReconnectingObserver(e){this.reconnectingObservers.push(e)}}var ys={exports:{}},vs="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(vs){var Es=new Uint8Array(16);ys.exports=function(){return vs(Es),Es}}else{var Ss=new Array(16);ys.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),Ss[t]=e>>>((3&t)<<3)&255;return Ss}}for(var Cs=[],bs=0;bs<256;++bs)Cs[bs]=(bs+256).toString(16).substr(1);var ws,Is,Ms=function(e,t){var s=t||0,n=Cs;return[n[e[s++]],n[e[s++]],n[e[s++]],n[e[s++]],"-",n[e[s++]],n[e[s++]],"-",n[e[s++]],n[e[s++]],"-",n[e[s++]],n[e[s++]],"-",n[e[s++]],n[e[s++]],n[e[s++]],n[e[s++]],n[e[s++]],n[e[s++]]].join("")},As=ys.exports,Ns=Ms,Ts=0,Os=0;var _s=function(e,t,s){var n=t&&s||0,i=t||[],o=(e=e||{}).node||ws,r=void 0!==e.clockseq?e.clockseq:Is;if(null==o||null==r){var a=As();null==o&&(o=ws=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==r&&(r=Is=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:Os+1,l=c-Ts+(u-Os)/1e4;if(l<0&&void 0===e.clockseq&&(r=r+1&16383),(l<0||c>Ts)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Ts=c,Os=u,Is=r;var d=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=255&d;var h=c/4294967296*1e4&268435455;i[n++]=h>>>8&255,i[n++]=255&h,i[n++]=h>>>24&15|16,i[n++]=h>>>16&255,i[n++]=r>>>8|128,i[n++]=255&r;for(var p=0;p<6;++p)i[n+p]=o[p];return t||Ns(i)},Rs=ys.exports,Ps=Ms;var ks=function(e,t,s){var n=t&&s||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Rs)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;++o)t[n+o]=i[o];return t||Ps(i)},Ds=_s,xs=ks,Fs=xs;Fs.v1=Ds,Fs.v4=xs;const Us=Fs;class Ls{static get(){return Us.v1().replace(/-/g,"")}}class Gs{constructor(e){this.permission=Qt.NONE,this.singleTimeout=0,this.totalTimeout=0,this.startTime=0,this.complete=!1,this.retried=0,this.unique=!1,this.uuid=Ls.get(),this.name=e.name,this.params=e.params,this.permission=e.permission,this.totalTimeout=e.totalTimeout,this.singleTimeout=e.singleTimeout,e.unique&&(this.unique=e.unique),this.success=t=>{this.complete||(this.complete=!0,e.success(t))},this.fail=t=>{this.complete||(this.complete=!0,e.fail(t))}}start(){this.startTime=Date.now()}isTimeout(){return this.startTime+this.totalTimeout<Date.now()}}function Bs(...e){}class js{constructor(e){this.callback=Bs,this.guidList=[],this.callback=e}onMessage(e,t){if("string"==typeof t&&(t=JSON.parse(t)),t.i){if(this.guidList.findIndex((e=>e===t.i))>-1)return;this.guidList.unshift(t.i),this.guidList.length>300&&this.guidList.pop()}this.callback(t)}}var qs=5;class Ws{static get(e){const t=encodeURIComponent(e)+"=",s=document.cookie.split("; ");for(const e of s)if(e.startsWith(t))return decodeURIComponent(e.substring(t.length));return null}static set(e,t,s,n,i="/",o=!1){let r=encodeURIComponent(e)+"="+encodeURIComponent(t);s instanceof Date&&(r+="; expires="+s.toGMTString()),i&&(r+="; path="+i),n&&(r+="; domain="+n),o&&(r+="; secure"),document.cookie=r}static remove(e,t,s="/",n=!1){Ws.set(e,"",new Date(0),t,s,n)}}class Vs{constructor(){this.domain=null;this.domain="undefined"!=typeof location&&/^(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/.test(location.host)?location.host.split(".").slice(-2).join("."):null}get(e){const t=Ws.get(e)||null;return JSON.parse(t)}put(e,t){const s=new Date(2030,12,31,0,0,0,0),n=this.domain;Ws.set(e,JSON.stringify(t),s,n)}remove(e){const t=this.domain;Ws.remove(e,t)}support(){return"undefined"!=typeof navigator&&!0===navigator.cookieEnabled}}class Hs{get(e){const t=localStorage.getItem(e);return JSON.parse(t)}put(e,t){const s=localStorage.setItem(e,JSON.stringify(t));JSON.stringify(s)}remove(e){localStorage.removeItem(e)}support(){return!("undefined"!=typeof GameGlobal||"undefined"==typeof localStorage||!localStorage.setItem)}}class zs{get(e){const t=uni.getStorageSync(e)||null;return JSON.parse(t)}put(e,t){uni.setStorageSync(e,JSON.stringify(t))}remove(e){uni.removeStorageSync(e)}support(){return!("object"!=typeof uni||!uni.getStorageSync)}}class Xs{get(e){const t=cc.sys.localStorage.getItem(e)||null;return JSON.parse(t)}put(e,t){cc.sys.localStorage.setItem(e,JSON.stringify(t))}remove(e){cc.sys.localStorage.removeItem(e)}support(){return"undefined"!=typeof cc&&void 0!==cc.sys.localStorage}}class Js{get(e){const t=wx.getStorageSync(e)||null;return JSON.parse(t)}put(e,t){wx.setStorageSync(e,JSON.stringify(t))}remove(e){wx.removeStorageSync(e)}support(){return!("object"!=typeof wx||!wx.getStorageSync)}}class Ys{constructor(){this.supportedStorage=null;const e=Ys.storages;e.push(new zs),e.push(new Xs),e.push(new Hs),e.push(new Js),e.push(new Vs),this.dispatch(),this.supportedStorage}static localStorage(){return this.instance.supportedStorage}dispatch(){for(let e of Ys.storages)if(e.support()){this.supportedStorage=e;break}}}Ys.storages=new Array,Ys.instance=new Ys;class Ks{refreshNumber(){const e=Ks.GOEASY_DOMAIN_NUMBER,t=Ys.localStorage();let s=Math.floor(Math.random()*(qs-1)+1);return null!==t&&(s=parseInt(t.get(e))||s),s>0&&s<qs?s+=1:s===qs&&(s=1),null!==t&&t.put(e,s),s}}Ks.GOEASY_DOMAIN_NUMBER="GOEASY_DOMAIN_NUMBER";let Qs=new Ks;var $s,Zs,en;!function(e){e[e.connect=1500]="connect",e[e.reconnectionDelayMax=3e3]="reconnectionDelayMax",e[e.commonQuerySingle=2500]="commonQuerySingle",e[e.commonQueryTotal=12e3]="commonQueryTotal",e[e.commonRequestSingle=1700]="commonRequestSingle",e[e.commonRequestTotal=12e3]="commonRequestTotal",e[e.commonInfiniteSingle=1700]="commonInfiniteSingle",e[e.commonInfiniteTotal=864e5]="commonInfiniteTotal"}($s||($s={})),function(e){e.BROWSER="BROWSER",e.UNKNOWN="UNKNOWN",e.APP_IOS="APP_IOS",e.APP_ANDROID="APP_ANDROID",e.APPLET_WX="APPLET_WX",e.APPLET_WX_GAME="APPLET_WX_GAME",e.APPLET_ALIPAY="APPLET_ALIPAY",e.APPLET_BYTEDANCE="APPLET_BYTEDANCE"}(Zs||(Zs={}));class tn{constructor(){this.platform=null,this.methods={[Zs.BROWSER]:this.isBrowser,[Zs.APP_IOS]:this.isAppiOS,[Zs.APP_ANDROID]:this.isAppAndroid,[Zs.APPLET_WX]:this.isWXApplet,[Zs.APPLET_WX_GAME]:this.isWXGameApplet};const e=this.methods,t=Object.keys(e);for(const s of t){if((0,e[s])()){this.platform=s;break}}this.platform=this.platform||Zs.UNKNOWN,this.platform}static currentPlatform(){return tn.instance.platform}isBrowser(){return"undefined"!=typeof navigator&&"Taro"!==navigator.product&&"undefined"==typeof GameGlobal&&("undefined"==typeof cc||null!==cc.sys.browserType)}isAppiOS(){return"undefined"!=typeof cc&&cc.sys.isNative&&cc.sys.isMobile&&"iOS"===cc.sys.os||"object"==typeof uni&&!!uni.getSystemInfoSync&&"ios"===uni.getSystemInfoSync().platform&&"object"==typeof plus}isAppAndroid(){return"undefined"!=typeof cc&&cc.sys.isNative&&cc.sys.isMobile&&"Android"===cc.sys.os||"object"==typeof uni&&!!uni.getSystemInfoSync&&"android"===uni.getSystemInfoSync().platform&&"object"==typeof plus}isWXApplet(){return"object"==typeof wx&&!!wx.getSystemInfoSync&&"undefined"==typeof WebSocket&&"undefined"==typeof XMLHttpRequest&&"undefined"==typeof plus}isWXGameApplet(){return"object"==typeof GameGlobal}isAlipayApplet(){return!1}isBytedanceApplet(){return!1}isQQApplet(){return!1}isBaiduApplet(){return!1}}tn.instance=new tn;class sn{static get(){let e=sn.storage;if(null!==e){const t=e.get(sn.ANONYMOUS_USER_ID_KEY);if(!ps.isEmpty(t))return t.toString()}return null}static put(e){var t=sn.storage;null!==t&&t.put(sn.ANONYMOUS_USER_ID_KEY,e.toString())}}sn.storage=Ys.localStorage(),sn.ANONYMOUS_USER_ID_KEY="goeasy-anonymous-user-id",function(e){e.UNIAPP="UNIAPP",e.REACT_NATIVE="REACT_NATIVE",e.COCOS="COCOS",e.TARO="TARO",e.IONIC="IONIC",e.NATIVE_APPLET_WX="NATIVE_APPLET_WX",e.NATIVE_APPLET_ALIPAY="NATIVE_APPLET_ALIPAY",e.UNKNOWN="UNKNOWN"}(en||(en={}));class nn{constructor(){this.framework=null,this.methods={[en.UNIAPP]:this.isUniApp,[en.REACT_NATIVE]:this.isReactNative,[en.TARO]:this.isTaro,[en.NATIVE_APPLET_WX]:this.isWXApplet,[en.COCOS]:this.isCocos};const e=this.methods,t=Object.keys(e);for(const s of t){if((0,e[s])()){this.framework=s;break}}this.framework=this.framework||en.UNKNOWN,this.framework}static currentFramework(){return this.instance.framework}isUniApp(){return"object"==typeof uni&&!!uni.getSystemInfoSync}isReactNative(){return"undefined"!=typeof global&&global.__fbGenNativeModule}isTaro(){return"undefined"!=typeof process&&void 0!==process.env.TARO_ENV}isWXApplet(){return tn.currentPlatform()===Zs.APPLET_WX&&"undefined"==typeof uni}isCocos(){try{return void 0!==cc.sys.localStorage}catch(e){return!1}}}nn.instance=new nn;const on=new class{constructor(){this.platform=tn.currentPlatform(),this.framework=nn.currentFramework(),this.z=this.toZ()}toZ(){var e=JSON.stringify({platform:this.platform,framework:this.framework});let t="";for(var s=0;s<e.length;s++){let n=e.charCodeAt(s);t+=String.fromCharCode(n+5)}return t}};var rn;!function(e){e.authorize="authorize",e.manualDisconnect="manualDisconnect",e.subscribe="subscribe",e.unsubscribe="unsubscribe",e.publish="publish",e.ack="ack",e.historyMessages="historyMessages",e.hereNow="hereNow",e.hereNowByUserIds="hereNowByUserIds",e.imLastConversations="imLastConversations",e.markPrivateMessageAsRead="markPrivateMessageAsRead",e.markGroupMessageAsRead="markGroupMessageAsRead",e.imGroupOnlineCount="imGroupOnlineCount",e.imHereNow="imHereNow",e.imGroupHereNow="imGroupHereNow",e.publishIM="publishIM",e.subscribeUserPresence="subscribeUserPresence",e.unsubscribeUserPresence="unsubscribeUserPresence",e.subscribeGroupPresence="subscribeGroupPresence",e.unsubscribeGroupPresence="unsubscribeGroupPresence",e.removeConversation="removeConversation",e.topConversation="topConversation",e.imData="imData",e.subscribeGroups="subscribeGroups",e.unsubscribeGroup="unsubscribeGroup",e.IM_DELETE_MESSAGE="IM_DELETE_MESSAGE",e.IM_HISTORY="IM_HISTORY",e.IM_HISTORY_CHANGE="IM_HISTORY_CHANGE",e.IM_RECALL_MESSAGE="IM_RECALL_MESSAGE",e.IM_MARK_AS_READ="IM_MARK_AS_READ",e.RTC_ASK_NEW_TOKEN="RTC_ASK_NEW_TOKEN",e.RTC_DIAL="RTC_DIAL",e.RTC_ACCEPT="RTC_ACCEPT",e.RTC_ACCEPT_FAILED="RTC_ACCEPT_FAILED",e.RTC_MANUAL_END="RTC_MANUAL_END",e.RTC_CLIENT_BUSY="RTC_CLIENT_BUSY",e.RTC_TIMEOUT="RTC_TIMEOUT",e.RTC_CALL_DATA="RTC_CALL_DATA",e.CS_PENDING_CONVERSATION="CS_PENDING_CONVERSATION",e.CS_ACCEPT="CS_ACCEPT",e.CS_END="CS_END",e.CS_TRANSFER="CS_TRANSFER",e.CS_AGENTS="CS_AGENTS",e.CS_CUSTOMER_STATUS="CS_CUSTOMER_STATUS",e.CS_MY_TEAMS="CS_MY_TEAMS",e.CS_ONLINE="CS_ONLINE",e.CS_OFFLINE="CS_OFFLINE",e.CS_LIVE_SESSION="CS_LIVE_SESSION",e.CS_QUIT_LIVE="CS_QUIT_LIVE"}(rn||(rn={}));const an=new class{constructor(){this.uniAppRunningBackend=!1,this.listenAppRunning()}listenAppRunning(){nn.currentFramework()===en.UNIAPP&&"object"==typeof plus&&(plus.globalEvent.addEventListener("resume",(()=>{this.uniAppRunningBackend=!1,this.uniAppRunningBackend}),!1),plus.globalEvent.addEventListener("pause",(()=>{this.uniAppRunningBackend=!0,this.uniAppRunningBackend}),!1))}runningBackend(){return this.uniAppRunningBackend}};class cn{constructor(e){this.uniappPlugin=null,this.regIdPromise=null,this.onClickNotificationCallback=null,this.payloadAssemblers=new Array,this.allowNotification=e,this.supportNotification()&&(this.uniappPlugin=uni.requireNativePlugin("GoEasy-Uniapp"),this.uniappPlugin?this.regIdPromise=this.askRegId():console.warn("No GoEasy-Uniapp Native Plugin."))}static init(e){this.instance=new cn(e)}addAssembler(e){this.payloadAssemblers.push(e)}assemblePayload(e){let t=this.payloadAssemblers.find((t=>t.support(e)));return t?t.assemble(e):e}createLocalNotification(e,t,s){an.runningBackend()&&(s.g=1,"undefined"!=typeof plus&&plus.push.createMessage(t,JSON.stringify(s),{title:e}))}askRegId(){let e=null,t=0;const s=()=>new Promise(((n,i)=>{this.uniappPlugin.regId((e=>{n(e)}),(n=>{if(!(1e6===n.data.code&&t<=10))return clearTimeout(e),i(n);e=setTimeout((()=>{t++,this.regIdPromise=s()}),3500)}))}));return s()}getRegIdPromise(){return this.regIdPromise}supportNotification(){const e=tn.currentPlatform(),t=nn.currentFramework();return this.allowNotification&&t===en.UNIAPP&&(e===Zs.APP_ANDROID||e===Zs.APP_IOS)}listenPlusClickNotification(){plus.push.addEventListener("click",(e=>{try{if(e){const t="string"==typeof e.payload?JSON.parse(e.payload):e.payload;if(this.availableIntent(t)){let e=this.assemblePayload(t);plus.push.clear(),this.onClickNotificationCallback(e)}}}catch(e){}}))}availableIntent(e){return e&&Object.keys(e).length&&e.g&&1===parseInt(e.g)}getIntentData(){this.uniappPlugin.getIntentData((e=>{if(!this.availableIntent(e))return;let t=this.assemblePayload(e);const s=tn.currentPlatform();plus.push.clear(),s===Zs.APP_ANDROID&&this.uniappPlugin.clearAll(),this.onClickNotificationCallback(t)}))}listenClick(){this.listenPlusClickNotification();const e=tn.currentPlatform();this.uniappPlugin&&e===Zs.APP_ANDROID&&this.getIntentData()}onClickNotification(e){if(this.supportNotification()){if(!ps.isFunction(e))throw new Error("The arguments must be a function.");null===this.onClickNotificationCallback?(this.onClickNotificationCallback=e,this.listenClick()):console.warn("The onClickNotification event has been listened on. Please do not listen to it more than once.")}else console.warn("The current environment doesn't support or allowNotification is false.")}}const un=N.exports;class ln{constructor(){this.emitter=new un}on(e,t){return this.emitter.on(e,t),this}once(e,t){return this.emitter.once(e,t),this}off(e,t){return this.emitter.off(e,t),this}fire(e,t){return this.emitter.emit(e,t),this}}class dn{static initial(){this.eventDriver=new ln}static on(e,t){this.eventDriver.on(e,t)}static off(e,t){this.eventDriver.off(e,t)}static once(e,t){this.eventDriver.once(e,t)}static fire(e,t){this.eventDriver.fire(e,t)}}var hn;!function(e){e.MANUAL_DISCONNECTED="MANUAL_DISCONNECTED"}(hn||(hn={}));class pn{static get(){let e=Ys.localStorage();return null!==e?e.get(pn.SM_KEY):null}static put(e){var t=Ys.localStorage();let s=e.sm;null!==t&&s&&t.put(pn.SM_KEY,s)}}pn.SM_KEY="GE-SM";class fn extends ms{constructor(e,t){super(),this.ioSocket=null,this.sid=null,this.appKey=null,this.anonymous=!1,this.userId=null,this.userData=null,this.otp=null,this.artifactVersion="0.0.0",this.uri=null,this.ioOpts=null,this.allowNotification=!1,this.reconnectingTimes=0,this.messageObservers={},this.connectFailedObservers=[],this.connectingObservers=[],this.expiredReconnectedObservers=[],this.onConnectSuccess=Bs,this.onConnectFailed=Bs,this.onConnectProgress=Bs,this.setUriAndOpts(e),this.extendOptions(t),this.ioSocket=new gs({onDisconnected:this.onIoDisconnected.bind(this),onReconnecting:this.onIoReconnecting.bind(this)}),this.ioSocket.addConnectedObserver(this.onIoReconnected.bind(this)),this.appKey=e.appkey,this.allowNotification=e.allowNotification,this.modules=e.modules,ps.isEmpty(t.id)?(this.anonymous=!0,this.userId=sn.get()):this.userId=t.id.toString(),this.artifactVersion=Wo.version,this.addConnectedObserver(this.onConnectSuccess),this.addConnectFailedObserver(this.onConnectFailed),this.addConnectingObserver(this.onConnectProgress)}extendOptions(e){if(ps.isFunction(e.onSuccess)&&(this.onConnectSuccess=e.onSuccess),ps.isFunction(e.onFailed)&&(this.onConnectFailed=e.onFailed),ps.isFunction(e.onProgress)&&(this.onConnectProgress=e.onProgress),ps.isDef(e.data)&&!ps.isObject(e.data))throw{code:400,content:"TypeError: data requires an object."};if((ps.isDef(e.data)?String(e.data).length:0)>300){if(ps.isObject(e)&&ps.isFunction(e.onFailed))throw{code:400,content:"user.data-length limit 300 byte."}}else this.userData=e.data;if(ps.isObject(e.wxmpId)){if(ps.isEmpty(e.wxmpId.appid))throw{code:400,content:"wxmpId.appid is required."};if(ps.isEmpty(e.wxmpId.openid))throw{code:400,content:"wxmpId.openid is required. requires string."}}else if(ps.isPrimitive(e.wxmpId))throw{code:400,content:"TypeError: wxmpId requires an object."};ps.isDef(e.wxmpId)&&(this.wxmpId=e.wxmpId),this.otp=e.otp||null}setUriAndOpts(e){let t=!0;if(tn.currentPlatform()===Zs.BROWSER){let s,n="://"+Qs.refreshNumber()+e.host;!0===e.supportOldBrowser?(s=["polling","websocket"],t=!1):s=["websocket"],!1!==e.forceTLS&&t?this.uri="https"+n+":443":this.uri="http"+n+":80",this.ioOpts={transports:s,timeout:$s.connect}}else this.uri="https://wx-"+e.host+":443",this.ioOpts={transports:["websocket"],reconnectionDelayMax:$s.reconnectionDelayMax}}onIoReconnected(){this.status===e.RECONNECTING&&this.authorize()}emit(e){super.emit(e)}doEmit(e,t,s){t.sid=this.sid,this.ioSocket.doEmit(e,t,s)}sendAck(e,t){this.ioSocket.io.emit(e,t)}connect(){super.connect(),this.onConnecting(),this.ioSocket.connect({uri:this.uri,opts:this.ioOpts}),this.authorize()}disconnect(){return new Promise(((t,s)=>{let n=()=>{this.status=e.DISCONNECTED,this.ioSocket.disconnect(),dn.fire(hn.MANUAL_DISCONNECTED),t()};if(this.allowNotification){let e=e=>{s(e)},t=new Gs({name:rn.manualDisconnect,params:{},permission:Qt.READ,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e,success:n});this.emit(t)}else n()}))}initRegId(){return n(this,void 0,void 0,(function*(){let e=cn.instance;if(e&&e.supportNotification()&&e.getRegIdPromise())try{this.regId=yield e.getRegIdPromise(),this.regId}catch(e){console.warn("Failed to register the Manufacturers Push service:"+JSON.stringify(e))}}))}authorize(){this.connectedPromise=new Promise(((e,t)=>{this.initRegId().then((()=>{let s={appkey:this.appKey,userId:this.userId,userData:JSON.stringify(this.userData),otp:this.otp,artifactVersion:this.artifactVersion,sid:this.sid,allowNT:this.allowNotification,regId:this.regId,wxmpId:this.wxmpId,modules:this.modules,a:this.anonymous,z:on.z,sm:pn.get()};JSON.stringify(s);let n=new Gs({name:rn.authorize,params:s,permission:Qt.NONE,singleTimeout:$s.commonInfiniteSingle,totalTimeout:$s.commonInfiniteTotal,success:t=>{this.onAuthorizeSuccess(t),e(t)},fail:e=>{this.onAuthorizeFailed(e),t(e)}});this.ioSocket.emit(n)}))}))}onConnecting(){this.notify(this.connectingObservers,this.reconnectingTimes)}onIoReconnecting(){this.reconnectingTimes++,this.status==e.CONNECTED||this.status==e.EXPIRED_RECONNECTED||this.status==e.RECONNECTING?this.status=e.RECONNECTING:this.status=e.CONNECTING,this.onConnecting()}onIoDisconnected(){this.status==e.DISCONNECTING&&(this.status=e.DISCONNECTED,this.notify(this.disconnectedObservers)),this.notify(this.disconnectedObservers)}onAuthorizeSuccess(t){if(!0===this.anonymous&&t.u&&(sn.put(t.u),this.userId=t.u),pn.put(t),this.status===e.RECONNECTING){this.sid!==t.sid?(this.status=e.EXPIRED_RECONNECTED,this.notify(this.expiredReconnectedObservers)):this.status=e.RECONNECTED}else this.status=e.CONNECTED,this.sid=t.sid;t.enablePublish&&(this.permissions.find((e=>e==Qt.WRITE))||this.permissions.push(Qt.WRITE)),t.enableSubscribe&&(this.permissions.find((e=>e==Qt.READ))||this.permissions.push(Qt.READ)),this.reconnectingTimes=0,this.notify(this.connectedObservers)}onAuthorizeFailed(t){pn.put(t),this.ioSocket.disconnect(),this.status=e.CONNECT_FAILED;let s={code:t.resultCode||408,content:t.content||"Host unreachable or timeout"};this.notify(this.connectFailedObservers,s)}addConnectingObserver(e){ps.isFunction(e)&&this.connectingObservers.push(e)}addConnectFailedObserver(e){ps.isFunction(e)&&this.connectFailedObservers.push(e)}addExpiredReconnectedObserver(e){ps.isFunction(e)&&this.expiredReconnectedObservers.push(e)}addMessageObserver(e,t){this.messageObservers[e]||(this.messageObservers[e]=[],this.ioSocket.io.on(e,(t=>{this.notifyMessageObservers(e,t)}))),this.messageObservers[e].push(new js(t))}notifyMessageObservers(e,t){let s=this.messageObservers[e];for(let n=0;n<s.length;n++)s[n].onMessage(e,t)}}const mn="IM",gn="PUBSUB";const yn=new class{validateId(e,t){if(ps.isEmpty(e))throw{code:400,content:` ${t} is required.`};if(!ps.isStringOrNumber(e))throw{code:400,content:`TypeError: ${t} require string or number.`}}validateIdArray(e,t){if(!Array.isArray(e)||0===e.length)throw{code:400,content:`TypeError: ${t} require array.`};if(e.length>300)throw{code:400,content:`${t} is over max length 500.`};for(let s=0;s<e.length;s++){if(!ps.isStringOrNumber(e[s]))throw{code:400,content:`TypeError: ${t} item require string or number.`};if(ps.isNumber(e[s])&&(e[s]=e[s].toString()),0==e[s].length)throw{code:400,content:`${t} has empty item.`}}if(Array.from(new Set(e)).length<e.length)throw{code:400,content:`Duplicate element in ${t}`}}validateChannel(e,t){this.validateId(e,t)}validateChannelArray(e,t){this.validateIdArray(e,t)}validateChannelAndChannels(e,t){let s=!ps.isEmpty(e),n=!ps.isEmpty(t);if(!s&&!n)throw{code:400,content:"channel is required."};if(s&&n)throw{code:400,content:"subscribe to either channel or channels, not both."};s&&this.validateId(e,"channel"),n&&this.validateIdArray(t,"channels")}validateCallbackOptions(e){if(!ps.isObject(e))throw{code:400,content:"bad parameters"}}validateNotification(e){if(ps.isObject(e)){if(ps.isEmpty(e.title))throw{code:400,content:"notification.title is required."};if(!ps.isString(e.title))throw{code:400,content:"TypeError: notification.title requires string."};if(e.title.length>32)throw{code:400,content:"TypeError: notification.title over max length 32."};if(ps.isEmpty(e.body))throw{code:400,content:"notification.body is required."};if(!ps.isString(e.body))throw{code:400,content:"TypeError: notification.body must be string."};if(e.body.length>50)throw{code:400,content:"notification.body over max length 50."}}else if(ps.isPrimitive(e))throw{code:400,content:"TypeError: notification requires an object."}}validateValIsEmpty(e,t){if(ps.isUndef(e)||ps.isEmpty(e))throw{code:400,content:`${t} is empty`}}validateWXMPTemplateMsg(e){if(ps.isObject(e)){if(!ps.isString(e.template_id))throw{code:400,content:"template_id must be string."};if(!ps.isEmpty(e.url)&&!ps.isString(e.url))throw{code:400,content:"url must be string"};if(!(ps.isEmpty(e.miniprogram)||ps.isString(e.miniprogram.appid)&&ps.isString(e.miniprogram.pagepath)))throw{code:400,content:"miniprogram.appid and miniprogram.pagepath must be strings."};if(!ps.isObject(e.data))throw{code:400,content:"data requires an object."}}else if(ps.isPrimitive(e))throw{code:400,content:"wxmpTemplateMsg must be an object."}}};class vn{static i(e){this.socket=e}static s(){if(this.socket)return this.socket;throw new Error("Please connect first.")}static u(){return this.s().userId}static ud(){return this.s().userData}static supportIM(){return this.s().modules.includes(mn)}}function En(e){if(null===e||"object"!=typeof e||"isActiveClone"in e)return e;let t=e instanceof Array?[]:{};for(let s in e)"object"==typeof e[s]?t[s]=En(e[s]):t[s]=e[s];return t}class Sn{publish(e){ps.isFunction(e.onFailed)||(e.onFailed=Bs),ps.isFunction(e.onSuccess)||(e.onSuccess=Bs),this.validate(e),e.channel=e.channel.toString();let t={channel:e.channel,content:e.message,nt:e.notification,at:e.accessToken,guid:Ls.get()};e.wxmpTemplateMsg&&(t.wxmpTemplateMsg=En(e.wxmpTemplateMsg),t.wxmpTemplateMsg.data=JSON.stringify(t.wxmpTemplateMsg.data));let s=new Gs({name:rn.publish,params:t,unique:!0,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,permission:Qt.WRITE,success:function(t){e.onSuccess({code:200,content:"ok"})},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});vn.s().emit(s)}validate(e){if(yn.validateChannel(e.channel,"channel"),ps.isEmpty(e.message))throw{code:400,content:"message is required."};if(!ps.isString(e.message))throw{code:400,content:"TypeError: message requires string."};if(e.message.length>1e4)throw{code:400,content:"Message over max length 10000."};e.wxmpTemplateMsg&&yn.validateWXMPTemplateMsg(e.wxmpTemplateMsg),e.notification&&yn.validateNotification(e.notification)}}class Cn{constructor(e){this.channels=e.channels,this.accessToken=e.accessToken,this.onSuccess=e.onSuccess,this.onFailed=e.onFailed,this.onMessage=e.onMessage}empty(){}}var bn,wn,In;!function(e){e.message="message",e.imMessage="imMessage",e.userPresence="userPresence",e.groupPresence="groupPresence",e.IM_MSG_READ="IM_MSG_READ",e.IM_MSG_DELETED="IM_MSG_DELETED",e.IM_MSG_RECALLED="IM_MSG_RECALLED",e.RTC_RING_EVENT="RTC_RING_EVENT",e.RTC_CANCEL_RING="RTC_CANCEL_RING",e.RTC_REMOTE_USER_LEFT="RTC_REMOTE_USER_LEFT",e.RTC_CALL_END="RTC_CALL_END",e.CS_ONLINE_CHANGED="CS_ONLINE_CHANGED"}(bn||(bn={}));class Mn{constructor(){this.subscriptions=[],cn.instance.addAssembler(new class{assemble(e){return{channel:e.ch,content:e.ctt}}support(e){return!!e.ch}})}initialGoEasySocket(){vn.s().addMessageObserver(bn.message,this.onNewMessage.bind(this)),vn.s().addExpiredReconnectedObserver(this.onExpiredReconnected.bind(this))}resubscribe(){let e=this.subscriptions.slice(0);this.subscriptions=[];for(let t=0;t<e.length;t++)0!=e[t].channels.length&&this.subscribe(e[t])}clearSubscriptions(){this.subscriptions=[]}onExpiredReconnected(){this.resubscribe()}onNewMessage(e){if(e.n.indexOf("_presence")>-1)return;e.a&&vn.s().sendAck("ack",{publishGuid:e.i});let t={time:e.t,channel:e.n,content:e.c};this.createNotification(e),this.findSubscriptionByChannel(t.channel).onMessage(t)}createNotification(e){const t=cn.instance.supportNotification();if(!ps.isObject(e.nt)||!t)return;const s={ch:e.n,ctt:e.c};cn.instance.createLocalNotification(e.nt.t,e.nt.c,s)}formatOptions(e){this.formatCallback(e),ps.isFunction(e.onMessage)||(e.onMessage=Bs),e.channel&&(e.channel=e.channel.toString(),e.channels=[e.channel]),e.channels&&(e.channels=e.channels.toString().split(","))}formatCallback(e){ps.isFunction(e.onSuccess)||(e.onSuccess=Bs),ps.isFunction(e.onFailed)||(e.onFailed=Bs)}subscribe(e){yn.validateChannelAndChannels(e.channel,e.channels),this.formatOptions(e);let t=new Gs({name:rn.subscribe,permission:Qt.READ,singleTimeout:$s.commonInfiniteSingle,totalTimeout:$s.commonInfiniteTotal,params:{channels:e.channels,accessToken:e.accessToken},success:()=>{let t=new Cn({channels:e.channels,accessToken:e.accessToken,onSuccess:e.onSuccess,onFailed:e.onFailed,onMessage:e.onMessage});this.subscriptions.push(t),e.onSuccess({code:200,content:"ok"})},fail:t=>{e.onFailed({code:t.resultCode,content:t.content})}});vn.s().emit(t)}unsubscribe(e){if(yn.validateChannel(e.channel,"channel"),e.channel=e.channel.toString(),!this.findSubscriptionByChannel(e.channel))return void e.onFailed({code:400,content:"channel["+e.channel+"] is not subscribed"});let t=new Gs({name:rn.unsubscribe,params:{channel:e.channel},permission:Qt.READ,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,success:()=>{e.onSuccess({code:200,content:"ok"}),this.removeChannel(e.channel)},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});vn.s().emit(t)}removeChannel(e){for(let t=0;t<this.subscriptions.length;t++){let s=this.subscriptions[t].channels;for(let n=0;n<s.length;n++)if(s[n]==e){this.subscriptions[t].channels.splice(n,1);break}}}findSubscriptionByChannel(e){let t=!1,s=null;for(let n=this.subscriptions.length-1;n>=0;n--){let i=this.subscriptions[n].channels;for(let o=0;o<i.length;o++)if(i[o]==e){t=!0,s=this.subscriptions[n];break}if(t)break}return s}}class An{get(e){ps.isFunction(e.onSuccess)||(e.onSuccess=Bs),ps.isFunction(e.onFailed)||(e.onFailed=Bs),yn.validateChannel(e.channel,"channel"),e.channel=e.channel.toString();let t=new Gs({name:rn.historyMessages,permission:Qt.READ,params:e,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,success:t=>{e.onSuccess({code:t.resultCode||t.code||200,content:t.content})},fail:t=>{e.onFailed({code:t.resultCode||t.code,content:t.content})}});vn.s().emit(t)}}class Nn{constructor(e){this.channels=e.channels,this.onSuccess=e.onSuccess,this.onFailed=e.onFailed,this.onPresence=e.onPresence}}class Tn{constructor(){this.presenters=[]}initialGoEasySocket(){vn.s().addMessageObserver(bn.message,this.onNewMessage.bind(this)),vn.s().addExpiredReconnectedObserver(this.onExpiredReconnected.bind(this))}resubscribe(){let e=this.presenters.slice(0);this.presenters=[];for(let t=0;t<e.length;t++){for(let s=0;s<e[t].channels.length;s++){let n=e[t].channels[s].split("_presence");e[t].channels[s]=n[0]}0!=e[t].channels.length&&this.subscribePresence(e[t])}}onExpiredReconnected(){this.resubscribe()}onNewMessage(e){if(-1==e.n.indexOf("_presence"))return;let t=this.findPresenceByChannel(e.n);if(t){let s=JSON.parse(e.c);s.events=s.events.map((e=>{let t=e.userData?JSON.parse(e.userData):{};return{time:e.time,action:e.action,id:e.userId,data:t}})),t.onPresence(s)}}formatOptions(e){this.formatCallback(e),ps.isFunction(e.onPresence)||(e.onPresence=Bs),e.channel&&(e.channel=e.channel.toString(),e.channels=[e.channel]),e.channels&&(e.channels=e.channels.toString().split(","))}formatCallback(e){ps.isFunction(e.onSuccess)||(e.onSuccess=Bs),ps.isFunction(e.onFailed)||(e.onFailed=Bs)}subscribePresence(e){yn.validateChannelAndChannels(e.channel,e.channels),this.formatOptions(e),Array.isArray(e.channels)&&(e.channels=e.channels.map((e=>e+="_presence")));let t=new Gs({name:rn.subscribe,permission:Qt.READ,singleTimeout:$s.commonInfiniteSingle,totalTimeout:$s.commonInfiniteTotal,params:{channels:e.channels},success:()=>{let t=new Nn({channels:e.channels,onSuccess:e.onSuccess,onFailed:e.onFailed,onPresence:e.onPresence});this.presenters.push(t),e.onSuccess({code:200,content:"ok"})},fail:t=>{e.onFailed({code:t.resultCode,content:t.content})}});vn.s().emit(t)}unsubscribePresence(e){if(this.formatCallback(e),!ps.isDef(e.channel))return void e.onFailed({code:400,content:"channel is required"});if(e.channel+="_presence",!this.findPresenceByChannel(e.channel))return void e.onFailed({code:400,content:"channel["+e.channel+"] is not subscribed"});let t=new Gs({name:rn.unsubscribe,params:{channel:e.channel},permission:Qt.READ,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,success:()=>{e.onSuccess({code:200,content:"ok"}),this.removeChannel(e.channel)},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});vn.s().emit(t)}removeChannel(e){for(let t=0;t<this.presenters.length;t++){let s=this.presenters[t].channels;for(let n=0;n<s.length;n++)if(s[n]==e){this.presenters[t].channels.splice(n,1);break}}}findPresenceByChannel(e){let t=!1,s=null;for(let n=this.presenters.length-1;n>=0;n--){let i=this.presenters[n].channels;for(let o=0;o<i.length;o++)if(i[o]==e){t=!0,s=this.presenters[n];break}if(t)break}return s}}class On{byChannel(e){let t={channels:[],includeUsers:!1,distinct:!1};ps.isFunction(e.onSuccess)||(e.onSuccess=Bs),ps.isFunction(e.onFailed)||(e.onFailed=Bs),yn.validateChannelArray(e.channels,"channels"),t.channels=e.channels.toString().split(","),t.includeUsers=e.includeUsers||!1,t.distinct=e.distinct||!1;let s=new Gs({name:rn.hereNow,permission:Qt.READ,params:t,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,success:function(t){let s=t.content,n=s.channels;for(let e in n)if(n.hasOwnProperty(e)){let t=n[e];t.users&&(t.users=t.users.map((e=>(e.data=e.data?JSON.parse(e.data):{},e))))}e.onSuccess({code:t.resultCode||t.code||200,content:s})},fail:function(t){e.onFailed({code:t.resultCode||t.code||200,content:t.content})}});vn.s().emit(s)}byUserId(e){let t={userIds:[],distinct:!0};ps.isFunction(e.onSuccess)||(e.onSuccess=Bs),ps.isFunction(e.onFailed)||(e.onFailed=Bs),yn.validateIdArray(e.userIds,"userIds"),t.userIds=e.userIds.toString().split(","),0==e.distinct&&(t.distinct=!1);let s=new Gs({name:rn.hereNowByUserIds,permission:Qt.READ,params:t,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,success:function(t){let s=t.content;s=s.map((e=>({id:e.userId,data:e.userData?JSON.parse(e.userData):{}}))),e.onSuccess({code:t.resultCode||t.code||200,content:s})},fail:function(t){e.onFailed({code:t.resultCode||t.code||200,content:t.content})}});vn.s().emit(s)}}class _n{static onSuccess(e,t){ps.isFunction(e.onSuccess)&&e.onSuccess(t)}static onFailed(e,t){if(!ps.isObject(e)||!ps.isFunction(e.onFailed))throw t;e.onFailed(t)}}class Rn{constructor(e){this.subscriber=new Mn,this.options=e}static init(e){Rn.instance=new Rn(e)}initialGoEasySocket(){this.publisher=new Sn,this.histories=new An,this.presence=new Tn,this.hereNows=new On,this.subscriber.initialGoEasySocket(),this.presence.initialGoEasySocket()}initialBeforeConnect(){this.subscriber.clearSubscriptions()}catch(e,t){try{this.validateOptions(),e()}catch(e){_n.onFailed(t,e)}}validateOptions(){if(!vn.s()||vn.s().getStatus()!==e.CONNECTED)throw Error("Please call connect() first.");if(!this.options.modules||!this.options.modules.includes(gn))throw{code:400,content:`Invalid options: module '${gn}' is not enabled`}}publish(e){this.catch((()=>{this.publisher.publish(e)}),e)}subscribe(e){this.catch((()=>{this.subscriber.subscribe(e)}),e)}unsubscribe(e){this.catch((()=>{this.subscriber.unsubscribe(e)}),e)}subscribePresence(e){this.catch((()=>{this.presence.subscribePresence(e)}),e)}unsubscribePresence(e){this.catch((()=>{this.presence.unsubscribePresence(e)}),e)}history(e){this.catch((()=>{this.histories.get(e)}),e)}hereNow(e){this.catch((()=>{this.hereNows.byChannel(e)}),e)}hereNowByUserIds(e){this.catch((()=>{this.hereNows.byUserId(e)}),e)}}!function(e){e.PRIVATE_MESSAGE_RECEIVED="PRIVATE_MESSAGE_RECEIVED",e.GROUP_MESSAGE_RECEIVED="GROUP_MESSAGE_RECEIVED",e.SYSTEM_MESSAGE_RECEIVED="SYSTEM_MESSAGE_RECEIVED",e.CONVERSATIONS_UPDATED="CONVERSATIONS_UPDATED",e.USER_PRESENCE="USER_PRESENCE",e.GROUP_PRESENCE="GROUP_PRESENCE",e.MESSAGE_DELETED="MESSAGE_DELETED",e.MESSAGE_READ="MESSAGE_READ",e.MESSAGE_RECALLED="MESSAGE_RECALLED",e.CS_MESSAGE_RECEIVED="CS_MESSAGE_RECEIVED",e.PENDING_CONVERSATIONS_UPDATED="PENDING_CONVERSATIONS_UPDATED"}(wn||(wn={})),function(e){e.RING="RING",e.USER_ACCEPTED="USER_ACCEPTED",e.CALL_ENDED="CALL_ENDED",e.USER_QUITED="USER_QUITED"}(In||(In={}));const Pn=N.exports;class kn{constructor(){this.emitter=new Pn}on(e,t){if(!ps.isString(e))throw Error("event require a string.");if(!ps.isDef(wn[e])&&!ps.isDef(In[e]))throw Error("An event that is not defined");if(!ps.isFunction(t))throw Error("callback must be a function");this.emitter.on(e,t)}fire(e,t){this.emitter.emit(e,t)}off(e,t){this.emitter.off(e,t)}}class Dn{constructor(){}upload(e,t){throw Error("Not implementation yet.")}}let xn=new class extends Dn{constructor(){super()}upload(e,t){try{return delete e.parameters.fileRes,new Promise(((s,n)=>{uni.uploadFile({url:e.host,filePath:this.getTempFilePath(e),name:"file",formData:e.parameters,success(t){if(200===t.statusCode){let n=e.payload;n.message=t.errMsg,s({code:200,content:n})}else n({code:t.statusCode,content:t.errMsg})},fail(e){n({code:500,content:e.errMsg})}}).onProgressUpdate((e=>{t&&t(e)}))}))}catch(e){return new Promise(((t,s)=>{s({code:500,content:e})}))}}getTempFilePath(e){let t=e.file;return t.tempFilePath||t.fullPath||t.path}};const Fn=new class extends Dn{upload(e,t){try{return new Promise(((s,n)=>{wx.uploadFile({url:e.host,filePath:this.getTempFilePath(e),name:"file",formData:e.parameters,success(t){if(200===t.statusCode){let n=e.payload;n.message=t.errMsg,s({code:200,content:n})}else n({code:t.statusCode,content:t.errMsg})},fail(e){n({code:500,content:e.errMsg})}}).onProgressUpdate((e=>{t&&t(e)}))}))}catch(e){return new Promise(((t,s)=>{s({code:500,content:e})}))}}getTempFilePath(e){let t=e.file||e.fileRes;return t.path||t.tempFilePath}};const Un=new class extends Dn{constructor(){super()}upload(e,t){try{return new Promise(((s,n)=>{let i=new XMLHttpRequest;i.open("post",e.host,!0);for(let t in e.headers)i.setRequestHeader(t,e.headers[t]);i.upload.onprogress=function(e){t&&t(e)},i.upload.onloadstart=function(e){t&&t(e)},i.upload.onloadend=function(e){t&&t(e)};let o=new FormData;for(let t in e.parameters)"fileRes"==t?o.append("file",e.parameters[t]):o.append(t,e.parameters[t]);i.send(o),i.onreadystatechange=function(){if(4==i.readyState)if(i.status>=200&&i.status<300||304==i.status){let t=e.payload;t.message=i.responseText,s({code:200,content:t})}else n({code:i.status,content:i.responseText})}}))}catch(e){return new Promise(((t,s)=>{s({code:500,content:e})}))}}};const Ln=new class{constructor(){this.uploader={[en.UNIAPP]:xn,[en.NATIVE_APPLET_WX]:Fn,[en.TARO]:tn.currentPlatform()===Zs.APPLET_WX?Fn:Un,[en.UNKNOWN]:Un}}upload(e,t){const s=nn.currentFramework();return this.uploader[s].upload(e,t)}};var Gn,Bn;!function(e){e.aliYun="ALI",e.qiNiu="QN",e.tencent="TX"}(Gn||(Gn={}));class jn{constructor(e,t,s,n,i){this.host=e,this.headers=t,this.parameters=s,this.file=n,this.payload=i}}class qn{constructor(){}build(e,t,s){}newFileName(e){return e&&e.newFilename||""}}!function(e){e.TEXT="text",e.IMAGE="image",e.FILE="file",e.VIDEO="video",e.AUDIO="audio"}(Bn||(Bn={}));let Wn=new class extends qn{constructor(){super()}url(e){return e.host+"/"+e.dir+"/"+this.newFileName(e)}build(e,t,s){let n;n={key:e.dir+"/"+this.newFileName(e),OSSAccessKeyId:e.accessKeyId,policy:e.policy,signature:e.signature,success_action_status:"200",fileRes:t},Bn.FILE===s&&(n={key:e.dir+"/"+this.newFileName(e),OSSAccessKeyId:e.accessKeyId,policy:e.policy,signature:e.signature,success_action_status:"200","Content-Disposition":"attachment;filename="+t.name,fileRes:t});let i={newFileName:this.newFileName(e),url:this.url(e)};return new jn(e.host,null,n,t,i)}};const Vn=new class extends qn{constructor(){super()}url(e){return e.downloadUrl}build(e,t){let s={key:this.newFileName(e),token:e.token,file:t},n={newFileName:this.newFileName(e),url:this.url(e)};return new jn(e.host,null,s,t,n)}};let Hn=new class extends qn{constructor(){super()}url(e){return e.host+"/"+e.key}build(e,t,s){let n={"q-sign-algorithm":e.qSignAlgorithm,"q-ak":e.qAk,"q-key-time":e.qKeyTime,"q-signature":e.qSignature,policy:e.policy,"x-cos-security-token":e.xCosSecurityToken,success_action_status:"200",key:e.key,fileRes:t};Bn.FILE===s&&(n={"q-sign-algorithm":e.qSignAlgorithm,"q-ak":e.qAk,"q-key-time":e.qKeyTime,"q-signature":e.qSignature,policy:e.policy,"x-cos-security-token":e.xCosSecurityToken,success_action_status:"200",key:e.key,"Content-Disposition":`attachment;filename=${t.name}`,fileRes:t});let i={newFileName:e.key,url:this.url(e)};return new jn(e.host,null,n,t,i)}};class zn{constructor(e){return e===Gn.aliYun?Wn:e===Gn.tencent?Hn:Vn}build(e,t,s){}}class Xn{resolve(e){return new Promise(((t,s)=>{let n=new Gs({name:"uploadToken",params:{filename:e},permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail(e){s(e)},success(e){200===e.code?t(e):s(e)}});vn.s().emit(n)}))}}class Jn{constructor(){this.uploadTokenResolver=new Xn}build(e,t,s){return new Promise(((n,i)=>{this.uploadTokenResolver.resolve(t).then((t=>{let i=t.content;n(new zn(i.vendor).build(i,e,s))})).catch((e=>{i(e)}))}))}}class Yn{constructor(){this.requestBuilder=new Jn,this.fileUploader=Ln}upload(e,t,s,n){return new Promise(((i,o)=>{this.requestBuilder.build(e,t,n).then((e=>{i(this.doUpload(e,s))})).catch((e=>{o(e)}))}))}customizeUpload(e,t){this.doUpload(e,t)}doUpload(e,t){return this.fileUploader.upload(e,t)}}class Kn extends class{}{constructor(){super(...arguments),this.goEasyUploader=new Yn}improve(e){let t=e.message;return new Promise(((e,s)=>{let n,i,o=t.buildOptions.createOptions;t.type===Bn.VIDEO?(i=t.payload,n=i.video.name):(i=t.payload,n=i.name),this.goEasyUploader.upload(o.file,n,o.onProgress,t.type).then((s=>{this.setPayload(s,t),e()})).catch((e=>{s(e)}))}))}setPayload(e,t){let{content:s={}}=e;t.payload.url=s.url}}class Qn extends Kn{setPayload(e,t){let s=t.payload,n="?x-oss-process=video/snapshot,t_0000,f_jpg,h_"+s.thumbnail.height+",m_fast,ar_auto";s.video.url=e.content.url,s.thumbnail.url=e.content.url+n,s.video.name=e.content.newFileName}}class $n{constructor(){this.improvers={[Bn.FILE]:new Kn,[Bn.AUDIO]:new Kn,[Bn.IMAGE]:new Kn,[Bn.VIDEO]:new Qn}}improve(e){let t=this.improvers[e.message.type];return t?t.improve(e):Promise.resolve()}}class Zn{constructor(e,t,s,n,i){this.validate(e),this.mt=e.type,this.to=t.id.toString(),this.d=JSON.stringify(t.data),this.p=JSON.stringify(e.payload),s&&(this.nt=s),i&&(this.at=i),n&&(this.wxmpTemplateMsg=En(n),this.wxmpTemplateMsg.data=JSON.stringify(this.wxmpTemplateMsg.data));let o=t.type;if(this.t=o,o===xo.CS){let t=e;this.tid=t.teamId}this.guid=e.messageId}validate(e){if(e.type===Bn.TEXT){if(JSON.stringify(e.payload).length>3072)throw Error("message-length limit 3kb")}}}var ei,ti;!function(e){e.MESSAGE_SENDING="IM_INTERNAL_MESSAGE_SENDING",e.MESSAGE_SEND_SUCCESS="IM_INTERNAL_MESSAGE_SEND_SUCCESS",e.MESSAGE_SEND_FAILED="IM_INTERNAL_MESSAGE_SEND_FAILED",e.MESSAGE_RECEIVED="IM_INTERNAL_MESSAGE_RECEIVED",e.MAX_MESSAGE_CHANGED="IM_INTERNAL_MAX_MESSAGE_CHANGED",e.MAX_MESSAGE_DELETED="IM_INTERNAL_MAX_MESSAGE_DELETED",e.UNREAD_AMOUNT_CHANGED="IM_INTERNAL_UNREAD_MESSAGE_CHANGED",e.CS_ONLINE_SUCCESS="CS_ONLINE_SUCCESS",e.CS_OFFLINE_SUCCESS="CS_OFFLINE_SUCCESS",e.CS_ACCEPTED="CS_ACCEPTED",e.CS_ENDED="CS_ENDED",e.CS_TRANSFER="CS_TRANSFER",e.CS_AGENT_MESSAGE_RECEIVED="CS_AGENT_MESSAGE_RECEIVED"}(ei||(ei={}));class si{clearUseLessAttribute(){delete this.buildOptions}isOtherSent(){return this.senderId!==vn.u()}getToData(){return this.buildOptions.createOptions.to.data}}class ni{constructor(){this.payloadImprover=new $n}send(e){this.validate(e);let t=e.message,s=e.accessToken,n=t.buildOptions,i=n.createOptions,o=i.notification,r=i.wxmpTemplateMsg,a=i.to;a.data||(a.data={}),t.status=Fo.SENDING;let c=n.complete,u=this.payloadImprover.improve(e);Promise.all([c,u]).then((()=>{this.doSend(t,a,o,r,s,e)})).catch((s=>{t.status=Fo.FAIL,_n.onFailed(e,{code:s.code||400,content:s.content||s})}))}doSend(e,t,s,n,i,o){let r=new Zn(e,t,s,n,i);dn.fire(ei.MESSAGE_SENDING,e);let a=new Gs({name:rn.publishIM,params:r,unique:!0,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:t=>{e.status=Fo.FAIL,dn.fire(ei.MESSAGE_SEND_FAILED,e),_n.onFailed(o,{code:t.resultCode,content:t.content})},success:t=>{if(e.status=Fo.SUCCESS,e.timestamp=t.content.timestamp,e.scene()===xo.CS){let s=e;s.customerId()!==vn.u()&&(s.sessionId=t.content.sessionId)}e.clearUseLessAttribute(),dn.fire(ei.MESSAGE_SEND_SUCCESS,e),_n.onSuccess(o,e)}});vn.s().emit(a)}validate(e){let t=e.message;if(!(t instanceof si))throw new Error("it is invalid message");if(t.status!==Fo.NEW)throw new Error("Please create a new message, a message can only be sent once")}}class ii{insert(e,t){let s=this.binarySearch(e,t);if(s>=0)e.splice(s,1,t);else{let n=-s-1;e.splice(n,0,t)}}binarySearch(e,t){let s=0,n=e.length-1;for(;s<=n;){let i=n+s>>1,o=this.compare(t,e[i]);if(o>0)s=i+1;else{if(!(o<0))return i;n=i-1}}return-s-1}}class oi{constructor(e){this.messages=new Array,this.allLoaded=!1,this.target=e}all(){return this.messages}sliceOverLengthMessages(){this.messages.length>oi.CACHE_MAX_LENGTH&&(this.messages=this.messages.slice(-oi.CACHE_MAX_LENGTH),!0===this.allLoaded&&(this.allLoaded=!1))}getMaxMessage(){return this.messages[this.messages.length-1]}loadLocalMessages(e,t){let s=[],n=this.messages.length;if(t){if(n>0){let i=this.messages[0].timestamp,o=this.messages[n-1].timestamp;if(t>=i&&t<=o)for(let i=n-1;i>=0;i--){let n=this.messages[i];if(n.timestamp<t){if(!(s.length<e))break;s.unshift(n)}}}}else s=this.messages.slice(-e);return s}cacheServerMessages(e,t){let s=this.messages[0];this.messages.length<oi.CACHE_MAX_LENGTH&&(!e.lastTimestamp||this.messages.length>0&&s.timestamp===e.lastTimestamp)&&(t.forEach((e=>{oi.sortedInserter.insert(this.messages,e)})),t.length<e.limit&&(this.allLoaded=!0))}findMessageByTime(e){return this.messages.find((t=>e===t.timestamp))}findMessagesByTimes(e){let t=[];return e.forEach((e=>{let s=this.findMessageByTime(e);ps.isDef(s)&&t.push(s)})),t}existsMessage(e){return this.findMessageIndexById(e)>-1}findMessageIndexById(e){return this.messages.findIndex((t=>e===t.messageId))}deleteMessage(e){let t=this.findMessageIndexById(e);t>=0&&this.messages.splice(t,1)}recallMessages(e){e.forEach((e=>{let t=this.findMessageByTime(e.timestamp);ps.isDef(t)&&(t.recalled=!0),e.recalled=!0}))}isEmpty(){return 0===this.messages.length}deleteMessages(e){e.forEach((e=>{this.deleteMessage(e.messageId)}))}saveMessage(e){oi.sortedInserter.insert(this.messages,e),this.sliceOverLengthMessages()}maxSuccessMessageTime(){for(let e=this.messages.length-1;e>=0;e--)if(this.messages[e].status===Fo.SUCCESS)return this.messages[e].timestamp;return 0}minTime(){return this.isEmpty()?0:this.messages[0].timestamp}correctPosition(e){this.deleteMessage(e.messageId),this.saveMessage(e)}}oi.CACHE_MAX_LENGTH=200,oi.sortedInserter=new class extends ii{compare(e,t){let s=e.timestamp-t.timestamp;return s>0?1:0===s?0:-1}};class ri{constructor(e,t,s){this.scene=e,this.id=t,ps.isDef(s)&&(this.teamId=s)}toString(){return xo.PRIVATE===this.scene||xo.GROUP===this.scene?this.scene+"#"+this.id:this.scene+"#"+this.id+"#"+this.teamId}customerId(){if(xo.CS===this.scene)return this.id===this.teamId?vn.u():this.id}static byScene(e,t,s){return new ri(e,t,s)}static byIMMessage(e){let t,s,n=e.scene();if(n===xo.PRIVATE){let t=e.senderId,n=e.targetId();s=vn.u()===t?n:t}else if(n===xo.GROUP)s=e.targetId();else{if(n!==xo.CS)throw{code:400,content:`scene ${n} not exists`};s=e.targetId(),t=e.teamId}return new ri(n,s,t)}static byMessageReadRemoteEvent(e){let t,s=e.scene,n=e.targetId,i=e.markerId,o=e.teamId;return s===xo.PRIVATE?t=vn.u()===i?n:i:s===xo.GROUP?t=n:s===xo.CS&&(t=n===o?i===vn.u()?o:i:i===vn.u()?n:o),new ri(s,t,o)}static byIMMessageDeletedEvent(e){let t=e.scene,s=e.deleterId;if(t===xo.PRIVATE){let n=vn.u()===s?e.targetId:s;return new ri(t,n)}if(t===xo.GROUP)return new ri(t,e.targetId)}static byConversationDTO(e){let t=e.lastMessage;return this.byIMMessage(t)}static byRemoteRecallEvent(e){let t;if(e.scene===xo.PRIVATE){let s=e.conversationId.split(":",2);t=s[0]===vn.u()?s[1]:s[0]}else t=e.conversationId;return new ri(e.scene,t)}}class ai{constructor(e){this.times=new Array;let t=e[0],s=ri.byIMMessage(t);this.scene=s.scene,this.targetId=s.id,e.forEach((e=>{e.status===Fo.SUCCESS&&this.times.push(e.timestamp)})),this.times.sort(((e,t)=>e<t?-1:e==t?0:1))}}class ci{static deleteServerMessages(e){let t=new ai(e);return t.times.length<0?Promise.resolve():new Promise(((e,s)=>{let n=new Gs({name:rn.IM_DELETE_MESSAGE,params:t,permission:Qt.WRITE,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,success:t=>{200===t.code?e(t):s(t)},fail:e=>{s(e)}});vn.s().emit(n)}))}static validate(e){let t=e.messages;for(let e=0;e<t.length;e++){let s=t[e];if(s.status===Fo.SENDING)throw{code:400,content:"message["+e+"] is '"+s.status+"' and cannot be deleted"}}}}class ui{constructor(e){this.times=new Array;let t=e[0],s=ri.byIMMessage(t);this.scene=s.scene,this.targetId=s.id,e.forEach((e=>{this.times.push(e.timestamp)})),this.times.sort(((e,t)=>e<t?-1:e==t?0:1))}}class li{static recallServerMessages(e){let t=new ui(e);return 0===t.times.length?Promise.resolve():new Promise(((e,s)=>{let n=new Gs({name:rn.IM_RECALL_MESSAGE,params:t,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e=>{s(e)},success:t=>{200===t.code?e(t):s(t)}});vn.s().emit(n)}))}static validate(e){let t=e.messages;for(let e=0;e<t.length;e++){let s=t[e];if(s.status!==Fo.SUCCESS)throw{code:400,content:"message["+e+"] is '"+s.status+"' and cannot be recalled"};if(s.recalled)throw{code:400,content:"message["+e+"] has been recalled"};if(s.senderId!==vn.u())throw{code:400,content:"it is not allowed to recall messages sent by others"}}}}class di{constructor(e,t,s,n,i){this.scene=e,this.id=t,this.after=s,this.min=n,this.teamId=i}}class hi{constructor(e,t,s,n){this.id=e,this.scene=t,this.lastTimestamp=s,this.teamId=n}}class pi extends si{constructor(){super(...arguments),this.read=!1}scene(){return xo.PRIVATE}targetId(){return this.receiverId}}class fi extends si{scene(){return xo.GROUP}targetId(){return this.groupId}}class mi extends si{constructor(){super(...arguments),this.accepted=!1}scene(){return xo.CS}targetId(){return vn.u()===this.customerId()?this.teamId:this.customerId()}sendByCustomer(){return this.to===this.teamId}customerId(){return this.sendByCustomer()?this.senderId:this.to}isOtherSent(){return vn.u()===this.customerId()?this.senderId!==vn.u():this.senderId===this.customerId()}}!function(e){e.ACCEPT="CS_ACCEPT",e.END="CS_END",e.TRANSFER="CS_TRANSFER"}(ti||(ti={}));class gi{build(e){let t,s=e.t;s===xo.PRIVATE?(t=new pi,t.read=!1,t.receiverId=e.r):s===xo.GROUP?(t=new fi,t.groupId=e.r,t.senderData=e.d?JSON.parse(e.d):{}):s===xo.CS&&(t=new mi,t.to=e.r,t.teamId=e.tid,t.senderData=e.d?JSON.parse(e.d):{},t.accepted=e.accepted,t.customerId()!==vn.u()&&(t.sessionId=e.sessionId)),t.senderId=e.s,t.messageId=e.i,t.timestamp=e.ts,t.type=e.mt;let n=e.p;if(ps.isDef(n))if(s===xo.CS&&t.type===ti.TRANSFER){let e=JSON.parse(n);e.transferTo.data=JSON.parse(e.transferTo.data),t.payload=e}else t.payload=JSON.parse(n);return t.recalled=e.rc,t.status=Fo.SUCCESS,t}}class yi{constructor(){this.builder=new gi}sync(e,t,s,n,i){let o=new di(e,t,s,n,i);return new Promise(((e,t)=>{let s=new Gs({name:rn.IM_HISTORY_CHANGE,params:o,permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:e=>{t(e)},success:t=>{let s=t.content;e(s)}});vn.s().emit(s)}))}loadServerMessages(e,t){return new Promise(((s,n)=>{let i=new Gs({name:rn.IM_HISTORY,params:t,permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:e=>{n(e)},success:t=>{let n=t.content;n.messages=this.convertServerMessages(e,n.messages),s(n)}});vn.s().emit(i)}))}convertServerMessages(e,t){let s=[],n=e.scene,i=e.id;return t.forEach((t=>{if(t.t=n,xo.PRIVATE===n)t.r=t.s===vn.u()?i:vn.u();else if(xo.GROUP===n)t.r=i;else if(xo.CS===n){let s=e.customerId(),n=e.teamId;s===vn.u()?t.r=n:t.r=s}let o=this.builder.build(t);s.push(o)})),s}updateServerOffsets(e,t){return n(this,void 0,void 0,(function*(){let s=new hi(t.id,t.scene,e,t.teamId);return new Promise(((e,t)=>{let n=new Gs({name:rn.IM_MARK_AS_READ,params:s,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,success:t=>{e(t)},fail:e=>{t(e)}});vn.s().emit(n)}))}))}}yi.instance=new yi;class vi{constructor(){this.offsetMap=new Map,this.markingTime=0,this.userId=vn.u()}updateOffset(e,t){let s=this.offsetMap.get(e);return ps.isDef(s)?t>s&&(this.offsetMap.set(e,t),!0):(this.offsetMap.set(e,t),!0)}updateUserOffsets(e){e.forEach((e=>{let t=e.userId,s=e.offset;this.updateOffset(t,s)}))}updateMyOffset(e){return this.updateOffset(this.userId,e)}myOffset(){return this.getOffset(this.userId)}getOffset(e){let t=this.offsetMap.get(e);return t||0}}class Ei{constructor(e,t,s,n,i){this.id=e,this.scene=t,this.lastTimestamp=s,this.limit=n,this.teamId=i}}class Si{constructor(e){this.history=e}pre(){this.oldLastMessage=this.history.getMaxMessage(),this.oldUnreadAmount=this.history.unreadAmount(),this.oldLastMessage&&(this.oldLastMessageRecalled=this.oldLastMessage.recalled,this.oldLastMessageRead=this.oldLastMessage.read,this.oldLastMessageStatus=this.oldLastMessage.status)}post(){let e,t,s,n=this.history.unreadAmount(),i=this.history.getMaxMessage();i&&(s=i.status,e=i.read,t=i.recalled);let o=this.history.target;this.oldLastMessage!==i||this.oldLastMessageRead!==e||this.oldLastMessageRecalled!==t||this.oldLastMessageStatus!==s?i?dn.fire(ei.MAX_MESSAGE_CHANGED,i):dn.fire(ei.MAX_MESSAGE_DELETED,o):this.oldUnreadAmount!==n&&dn.fire(ei.UNREAD_AMOUNT_CHANGED,o)}}class Ci{constructor(e){this.expiredTime=0,this.remoteHistory=yi.instance,this.target=e,this.userOffsets=new vi,this.messageCache=new oi(e)}initMaxMessageAndOffsets(e,t){this.existsMessage(e)||(this.messageCache.saveMessage(e),t.forEach((e=>{this.markLocalMessagesRead(this.messageCache.all(),e.userId,e.offset,!1)})))}existsMessage(e){return this.messageCache.existsMessage(e.messageId)}loadHistory(e,t){return n(this,void 0,void 0,(function*(){return this.expiredTime>0&&!this.messageCache.isEmpty()&&(yield this.updateByServerChange()),ps.isUndef(t)?t=10:t>30&&(t=30),yield this.loadServerMessages(e,t)}))}loadServerMessages(e,t){return n(this,void 0,void 0,(function*(){let s=this.messageCache.loadLocalMessages(t,e);if(!1===this.messageCache.allLoaded&&s.length!==t){let n=t-s.length,i=s[0]?s[0].timestamp:e,o=new Ei(this.target.id.toString(),this.target.scene,i,n,this.target.teamId),r=yield this.remoteHistory.loadServerMessages(this.target,o),a=r.messages;s=a.concat(s),this.messageCache.cacheServerMessages(o,a),r.userOffsets.forEach((e=>{this.userOffsets.updateOffset(e.userId,e.offset)})),this.userOffsets.offsetMap.forEach(((e,t)=>{this.markLocalMessagesRead(a,t,e,!1)}))}return s}))}deleteMessages(e){return n(this,void 0,void 0,(function*(){yield this.aopUnreadAmountMaxMessage((()=>n(this,void 0,void 0,(function*(){let t=e.messages;yield ci.deleteServerMessages(t),this.messageCache.deleteMessages(t),_n.onSuccess(e)}))))}))}syncDeletedMessage(e,t){this.aopUnreadAmountMaxMessage((()=>{this.doSyncDeletedMessage(e,t)}))}doSyncDeletedMessage(e,t){if(e===vn.u()){let e=this.messageCache.findMessagesByTimes(t);this.messageCache.deleteMessages(e),e.length>0&&Io.aec.fire(wn.MESSAGE_DELETED,e)}}recallMessage(e){return n(this,void 0,void 0,(function*(){yield this.aopUnreadAmountMaxMessage((()=>n(this,void 0,void 0,(function*(){let t=e.messages;yield li.recallServerMessages(t),this.messageCache.recallMessages(t),_n.onSuccess(e)}))))}))}syncRecalledMessage(e){this.aopUnreadAmountMaxMessage((()=>n(this,void 0,void 0,(function*(){this.doSyncRecalledMessage(e)}))))}doSyncRecalledMessage(e){let t=this.messageCache.findMessagesByTimes(e);t.length>0&&(this.messageCache.recallMessages(t),Io.aec.fire(wn.MESSAGE_RECALLED,t))}expire(){this.messageCache.isEmpty()||(this.expiredTime=this.messageCache.maxSuccessMessageTime())}updateByServerChange(){return n(this,void 0,void 0,(function*(){yield this.aopUnreadAmountMaxMessage((()=>n(this,void 0,void 0,(function*(){let e=yield this.remoteHistory.sync(this.target.scene,this.target.id,this.expiredTime,this.messageCache.minTime(),this.target.teamId);e.userOffsets.forEach((e=>{this.markLocalMessagesRead(this.messageCache.all(),e.userId,e.offset,!0)}));let t=e.deletedMessageTimes;t.length>0&&this.doSyncDeletedMessage(vn.u(),t);let s=e.recalled;s.length>0&&this.doSyncRecalledMessage(s),this.expiredTime=0}))))}))}markRead(){return n(this,void 0,void 0,(function*(){yield this.aopUnreadAmountMaxMessage((()=>n(this,void 0,void 0,(function*(){let e=this.messageCache.maxSuccessMessageTime();e>this.userOffsets.myOffset()&&(this.userOffsets.markingTime=e,yield this.remoteHistory.updateServerOffsets(e,this.target),e===this.userOffsets.markingTime&&this.markLocalMessagesRead(this.messageCache.all(),vn.u(),e,!0))}))))}))}syncMarkedMessage(e){this.aopUnreadAmountMaxMessage((()=>{this.markLocalMessagesRead(this.messageCache.all(),e.markerId,e.time,!0)}))}onMessageSending(e){this.aopUnreadAmountMaxMessage((()=>{this.messageCache.saveMessage(e)}))}onMessageSendSuccess(e){this.aopUnreadAmountMaxMessage((()=>{this.messageCache.correctPosition(e),this.markLocalMessagesRead(this.messageCache.all(),vn.u(),e.timestamp,!0)}))}onMessageSendFailed(e){this.getMaxMessage()===e&&dn.fire(ei.MAX_MESSAGE_CHANGED,e)}onMessageReceived(e){this.aopUnreadAmountMaxMessage((()=>{this.messageCache.saveMessage(e),this.markLocalMessagesRead(this.messageCache.all(),e.senderId,e.timestamp,!0)}))}aopUnreadAmountMaxMessage(e,t){return n(this,void 0,void 0,(function*(){try{let t=new Si(this);t.pre(),yield e(),t.post()}catch(e){_n.onFailed(t,e)}}))}markLocalMessagesRead(e,t,s,n){if(this.userOffsets.updateOffset(t,s),this.isOtherUserId(t)){let t=this.markMySentRead(e,s);n&&t.length>0&&Io.aec.fire(wn.MESSAGE_READ,t)}else t===vn.u()&&this.markOthersSentRead(e,s)}markOthersSentRead(e,t){if(this.target.scene===xo.PRIVATE)for(let s=e.length-1;s>=0;s--){let n=e[s];if(n.isOtherSent()&&n.timestamp<=t){if(n.read)break;n.read=!0}}}markMySentRead(e,t){let s=new Array;if(this.target.scene===xo.PRIVATE)for(let n=e.length-1;n>=0;n--){let i=e[n];if(!i.isOtherSent()&&i.timestamp<=t&&i.status===Fo.SUCCESS){if(i.read)break;i.read=!0,s.push(i)}}return s}isOtherUserId(e){if(this.target.scene===xo.CS){let t=this.target.customerId();return vn.u()===t?e!==vn.u():e===t}return e!==vn.u()}unreadAmount(e){let t=0,s=this.userOffsets.myOffset(),n=this.messageCache.all();for(const e of n)e.isOtherSent()&&!1===e.recalled&&e.timestamp>s&&(t+=1);return t}getMaxMessage(e){return this.messageCache.getMaxMessage()}maxTime(e){let t=this.getMaxMessage();return ps.isDef(t)?t.timestamp:0}}class bi{constructor(e,t){this.teamId=e,this.customerId=t}}class wi{}class Ii{constructor(e,t,s){this.teamId=e,this.teamData=JSON.stringify(t),this.agentData=JSON.stringify(s)}}class Mi{constructor(e){this.teamId=e}}class Ai{constructor(e){this.teamId=e}}class Ni{constructor(){this.synchronized=!0,vn.s().addDisconnectedObserver(this.onDisconnected.bind(this)),vn.s().addConnectedObserver(this.onConnected.bind(this)),vn.s().addMessageObserver(bn.CS_ONLINE_CHANGED,this.onlineChanged.bind(this))}static getInstance(){return Ni.instance||(Ni.instance=new Ni),Ni.instance}queryTeams(){return this.queryMyTeamPromise||(this.queryMyTeamPromise=new Promise(((e,t)=>{let s=new Gs({name:rn.CS_MY_TEAMS,params:{},permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:e=>{t(e)},success:t=>{this.teamIds=new Set(t.content),this.synchronized=!0,e(this.teamIds)}});vn.s().emit(s)}))),this.queryMyTeamPromise}myTeams(){if(this.synchronized&&this.queryMyTeamPromise)return this.teamIds;throw"please query team first."}isOnline(e,t){return n(this,void 0,void 0,(function*(){yield this.queryTeams(),_n.onSuccess(t,this.teamIds.has(e))}))}online(e,t){if(!ps.isObject(t.agentData)||!ps.isObject(t.teamData))throw{code:400,content:"agentData and teamData require an object"};let s=new Ii(e,t.teamData,t.agentData),n=new Gs({name:rn.CS_ONLINE,params:s,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e=>{_n.onFailed(t,e)},success:s=>{this.teamIds.add(e),_n.onSuccess(t),dn.fire(ei.CS_ONLINE_SUCCESS)}});vn.s().emit(n)}offline(e,t){let s=new Mi(e),n=new Gs({name:rn.CS_OFFLINE,params:s,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e=>{_n.onFailed(t,e)},success:s=>{this.teamIds.delete(e),_n.onSuccess(t),dn.fire(ei.CS_OFFLINE_SUCCESS)}});vn.s().emit(n)}agents(e,t){let s=new Ai(e),n=new Gs({name:rn.CS_AGENTS,params:s,permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:e=>{_n.onFailed(t,e)},success:e=>{e.content.forEach((e=>{e.data=JSON.parse(e.data)})),_n.onSuccess(t,e)}});vn.s().emit(n)}onlineChanged(e){e.online?this.teamIds.add(e.teamId):this.teamIds.delete(e.teamId)}onDisconnected(){this.queryMyTeamPromise=null,this.teamIds=null}onConnected(){this.synchronized&&(this.queryMyTeamPromise=this.queryTeams())}}class Ti{constructor(e){this.teamId=e,dn.on(ei.CS_AGENT_MESSAGE_RECEIVED,this.onMessageReceived),dn.on(ei.CS_ACCEPTED,this.onMessageReceived),dn.on(ei.CS_ENDED,this.onMessageReceived),dn.on(ei.CS_TRANSFER,this.onMessageReceived),dn.on(hn.MANUAL_DISCONNECTED,Ti.destroy)}static live(e,t){return n(this,void 0,void 0,(function*(){let s=t.customerId;yn.validateId(s,"customerId");let n=new bi(e,s);yield Ni.getInstance().queryTeams();let i=new Gs({name:rn.CS_LIVE_SESSION,params:n,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e=>{_n.onFailed(t,e)},success:s=>{Ti.destroy(),this.session=new Ti(e),this.session.liveOptions=t;let n=s.content.customerStatus;"ACCEPTED"===n.status&&(n.agent.data=JSON.parse(n.agent.data)),this.session.status=n,this.session.liveOptions.onStatusUpdated(this.session.status),_n.onSuccess(t)}});vn.s().emit(i)}))}customerId(){return this.liveOptions.customerId}static isMyCustomer(e){let t=Ti.session;if(t&&t.teamId===e.teamId&&t.customerId()===e.customerId()){let s=Ni.getInstance().myTeams(),n=t.status.agent;return s.has(e.teamId)&&(!n||n.id===vn.u())}return!0}static isMyMessage(e){let t=ri.byIMMessage(e);return e.type===ti.TRANSFER&&e.payload.transferTo.id===vn.u()||this.isMyCustomer(t)}static quit(e){let t=Ti.session;if(t){let s=t.liveOptions.customerId;yn.validateId(s,"customerId");let n=new bi(t.teamId,s),i=new Gs({name:rn.CS_QUIT_LIVE,params:n,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:t=>{_n.onFailed(e,t)},success:t=>{Ti.destroy(),_n.onSuccess(e)}});vn.s().emit(i)}}static destroy(){let e=Ti.session;e&&(dn.off(ei.CS_AGENT_MESSAGE_RECEIVED,e.onMessageReceived),dn.off(ei.CS_ACCEPTED,e.onMessageReceived),dn.off(ei.CS_ENDED,e.onMessageReceived),dn.off(ei.CS_TRANSFER,e.onMessageReceived),dn.off(hn.MANUAL_DISCONNECTED,Ti.destroy),Ti.session=null)}onMessageReceived(e){let t=Ti.session;if(e.scene()===xo.CS&&t.liveOptions){let s=e,n=t.liveOptions.customerId;t.teamId===s.teamId&&s.customerId()===n&&(t.tryUpdateStatus(s),t.liveOptions.onNewMessage(s))}}tryUpdateStatus(e){if("FREE"!==this.status.status&&this.status.sessionId>e.sessionId)return;let t;switch(e.type){case ti.ACCEPT:t=new wi,t.status="ACCEPTED",t.start=e.payload.sessionStart,t.sessionId=e.sessionId,t.agent=new Go(e.senderId,e.senderData);break;case ti.END:t=new wi,t.status="FREE";break;case ti.TRANSFER:t=new wi,t.status="ACCEPTED",t.start=e.payload.sessionStart,t.sessionId=e.sessionId,t.agent=e.payload.transferTo;break;default:"FREE"===this.status.status&&(t=new wi,t.status="PENDING",t.start=e.timestamp,t.sessionId=e.sessionId)}t&&(this.status=t,this.liveOptions.onStatusUpdated(t))}}class Oi extends Ci{constructor(e){super(e),this.unread=0,this.markingAmount=0}loadHistory(e,t){return n(this,void 0,void 0,(function*(){return ps.isUndef(t)?t=10:t>30&&(t=30),yield this.loadServerMessages(e,t)}))}loadServerMessages(e,t){return n(this,void 0,void 0,(function*(){let s=new Ei(this.target.id.toString(),this.target.scene,e,t,this.target.teamId),n=yield this.remoteHistory.loadServerMessages(this.target,s);return n.userOffsets.forEach((e=>{this.userOffsets.updateOffset(e.userId,e.offset)})),n.messages}))}deleteMessages(e){return n(this,void 0,void 0,(function*(){_n.onFailed(e,"Delete CS message is not supported yet")}))}recallMessage(e){return n(this,void 0,void 0,(function*(){_n.onFailed(e,"Recall CS message is not supported yet")}))}initMaxMessageAndOffsets(e,t){t.forEach((e=>{this.userOffsets.updateOffset(e.userId,e.offset)})),(ps.isUndef(this.acceptedMaxMessage)||this.acceptedMaxMessage.timestamp<e.timestamp)&&this.increaseUnreadAmount(e),this.saveAcceptedMessage(e)}initPendingMaxMessageAndOffsets(e,t){t.forEach((e=>{this.userOffsets.updateOffset(e.userId,e.offset)})),this.savePendingMessage(e)}savePendingMessage(e){this.pendingMaxMessage?this.pendingMaxMessage.timestamp<e.timestamp&&(this.pendingMaxMessage=e):this.pendingMaxMessage=e}saveAcceptedMessage(e){this.acceptedMaxMessage?this.acceptedMaxMessage.timestamp<e.timestamp&&(this.acceptedMaxMessage=e):this.acceptedMaxMessage=e}onMessageSending(e){this.saveAcceptedMessage(e),dn.fire(ei.MAX_MESSAGE_CHANGED,e)}onMessageSendSuccess(e){this.saveAcceptedMessage(e),this.userOffsets.updateOffset(e.senderId,e.timestamp),this.acceptedMaxMessage===e&&dn.fire(ei.MAX_MESSAGE_CHANGED,e)}onMessageSendFailed(e){this.acceptedMaxMessage===e&&dn.fire(ei.MAX_MESSAGE_CHANGED,e)}onMessageReceived(e){Ti.isMyMessage(e)&&(!e.accepted||e.senderId!==vn.u()&&e.type===ti.ACCEPT?this.savePendingMessage(e):this.saveAcceptedMessage(e),this.userOffsets.updateOffset(e.senderId,e.timestamp),this.increaseUnreadAmount(e),dn.fire(ei.MAX_MESSAGE_CHANGED,e))}increaseUnreadAmount(e){if(e.sendByCustomer()||e.type===ti.TRANSFER&&e.senderId!==vn.u()){this.userOffsets.myOffset()<e.timestamp&&e.accepted&&(this.unread+=1)}}markRead(){return n(this,void 0,void 0,(function*(){let e=this.maxAcceptedMessageTime();Ti.isMyCustomer(this.target)&&this.preMark(e)&&(yield this.remoteHistory.updateServerOffsets(e,this.target),this.postMark(e))}))}preMark(e){let t=this.userOffsets.myOffset();return e>this.userOffsets.markingTime&&e>t&&(this.userOffsets.markingTime=e,this.markingAmount=this.unread,!0)}postMark(e){e===this.userOffsets.markingTime&&(this.unread-=this.markingAmount,this.markingAmount=0,this.userOffsets.updateOffset(vn.u(),e),dn.fire(ei.UNREAD_AMOUNT_CHANGED,this.target))}syncMarkedMessage(e){}getMaxMessage(e){return e?this.acceptedMaxMessage:this.pendingMaxMessage}unreadAmount(e){return e?this.unread:0}existsMessage(e){return this.acceptedMaxMessage&&this.acceptedMaxMessage.messageId===e.messageId||this.pendingMaxMessage&&this.pendingMaxMessage.messageId===e.messageId}maxAcceptedMessageTime(){return this.acceptedMaxMessage?this.acceptedMaxMessage.timestamp:0}maxTime(e){let t=this.getMaxMessage(e);return t?t.timestamp:0}}class _i extends Ci{constructor(e){super(e)}deleteMessages(e){return n(this,void 0,void 0,(function*(){_n.onFailed(e,"Delete CS message is not supported yet")}))}recallMessage(e){return n(this,void 0,void 0,(function*(){_n.onFailed(e,"Recall CS message is not supported yet")}))}}class Ri{static init(){return Ri.instance||(Ri.instance=new Ri),Ri.instance.map=new Map,Ri.instance}initialListeners(){dn.on(ei.MESSAGE_SENDING,(e=>this.onMessageSending(e))),dn.on(ei.MESSAGE_SEND_SUCCESS,(e=>this.onMessageSendSuccess(e))),dn.on(ei.MESSAGE_SEND_FAILED,(e=>this.onMessageSendFailed(e))),dn.on(ei.MESSAGE_RECEIVED,(e=>this.onMessageReceived(e))),dn.on(ei.CS_AGENT_MESSAGE_RECEIVED,(e=>this.onMessageReceived(e))),dn.on(ei.CS_ACCEPTED,(e=>this.onMessageReceived(e))),dn.on(ei.CS_ENDED,(e=>this.onMessageReceived(e))),dn.on(ei.CS_TRANSFER,(e=>this.onMessageReceived(e))),vn.s().addMessageObserver(bn.IM_MSG_READ,this.onRemoteMarkRead.bind(this)),vn.s().addMessageObserver(bn.IM_MSG_DELETED,this.onRemoteMessageDeleted.bind(this)),vn.s().addMessageObserver(bn.IM_MSG_RECALLED,this.onRemoteMessageRecalled.bind(this)),vn.s().addDisconnectedObserver(this.onDisconnected.bind(this))}loadHistory(e,t){return n(this,void 0,void 0,(function*(){let s=this.queryToTarget(e,t),n=this.findOrCreateHistory(s),i=yield n.loadHistory(e.lastTimestamp,e.limit);_n.onSuccess(e,{code:200,content:i})}))}queryToTarget(e,t){if(ps.isDef(e.userId))return new ri(xo.PRIVATE,e.userId);if(ps.isDef(e.groupId))return new ri(xo.GROUP,e.groupId);if(ps.isDef(e.type)){if(!Object.values(xo).includes(e.type))throw new Error("incorrect type, must be: "+Object.values(xo));if(ps.isUndef(e.id))throw new Error("If type is not empty, id is required.");return xo.CS==e.type&&ps.isUndef(t)&&(t=e.id),new ri(e.type,e.id,t)}throw new Error("incorrect query options.")}onMessageSending(e){let t=ri.byIMMessage(e);this.findOrCreateHistory(t).onMessageSending(e)}onMessageSendSuccess(e){let t=ri.byIMMessage(e);this.findHistory(t).onMessageSendSuccess(e)}onMessageSendFailed(e){let t=ri.byIMMessage(e);this.findHistory(t).onMessageSendFailed(e)}onMessageReceived(e){let t=ri.byIMMessage(e);this.findOrCreateHistory(t).onMessageReceived(e)}privateMarkAsRead(e){return n(this,void 0,void 0,(function*(){if(ps.isUndef(e.userId))throw new Error("userId could not be empty.");let t=ri.byScene(xo.PRIVATE,e.userId);yield this.markAsRead(t,e)}))}groupMarkAsRead(e){return n(this,void 0,void 0,(function*(){if(ps.isUndef(e.groupId))throw new Error("groupId could not be empty.");let t=ri.byScene(xo.GROUP,e.groupId);yield this.markAsRead(t,e)}))}markMessageAsRead(e,t){return n(this,void 0,void 0,(function*(){if(ps.isUndef(e.id))throw new Error("id could not be empty.");if(!Object.values(xo).includes(e.type))throw new Error("incorrect type, must be: "+Object.values(xo));xo.CS==e.type&&ps.isUndef(t)&&(t=e.id);let s=ri.byScene(e.type,e.id,t);yield this.markAsRead(s,e)}))}markAsRead(e,t){return n(this,void 0,void 0,(function*(){let s=this.findHistory(e);s&&(yield s.markRead()),_n.onSuccess(t)}))}onRemoteMarkRead(e){let t=ri.byMessageReadRemoteEvent(e),s=this.findHistory(t);s&&s.syncMarkedMessage(e)}deleteMessage(e){return n(this,void 0,void 0,(function*(){this.validateMessageArray(e.messages),ci.validate(e);let t=e.messages[0],s=ri.byIMMessage(t),n=this.findHistory(s);if(!n)throw{code:400,content:"No message that could be deleted"};yield n.deleteMessages(e)}))}onRemoteMessageDeleted(e){let t=ri.byIMMessageDeletedEvent(e),s=this.findHistory(t);s&&s.syncDeletedMessage(e.deleterId,e.times)}recallMessage(e){return n(this,void 0,void 0,(function*(){this.validateMessageArray(e.messages),li.validate(e);let t=e.messages[0],s=ri.byIMMessage(t),n=this.findHistory(s);if(!n)throw{code:400,content:"No message that could be recalled"};yield n.recallMessage(e)}))}onRemoteMessageRecalled(e){let t=ri.byRemoteRecallEvent(e),s=this.findHistory(t);s&&s.syncRecalledMessage(e.times)}onDisconnected(){this.map.forEach(((e,t)=>{e.expire()}))}findOrCreateHistory(e){let t=this.findHistory(e);return t||(t=e.scene===xo.CS?vn.u()===e.customerId()?new _i(e):new Oi(e):new Ci(e),this.map.set(e.toString(),t),t)}static get(e){return Ri.instance.findOrCreateHistory(e)}findHistory(e){return this.map.get(e.toString())}validateMessageArray(e){if(!ps.isArray(e)||ps.isEmpty(e))throw{code:400,content:"messages requires non empty array"};if(e.length>50)throw{code:400,content:"The maximum number of messages is 50"};let t=ri.byIMMessage(e[0]);for(let s=0;s<e.length;s++){let n=e[s];if(!(n instanceof si))throw{code:400,content:"message["+s+"] is not a correct message"};if(s>0){let e=ri.byIMMessage(n);if(e.scene!==t.scene||e.id!==t.id)throw{code:400,content:"each message must be from the same friend or group"}}}}}class Pi{constructor(e){this.top=!1,this.data=null,this.dataLoaded=!1,this.target=e}toDto(){let e=this.target.scene,t=this.target.id,s=new Uo;return e===xo.PRIVATE?s.userId=t:e===xo.GROUP?s.groupId=t:e===xo.CS&&(s.id=this.target.teamId),s.type=e,s.lastMessage=this.getMaxMessage(),s.unread=this.getUnreadAmount(),s.top=this.top,s.data=this.data,s}getMaxMessage(){return Ri.get(this.target).getMaxMessage()}getUnreadAmount(){return Ri.get(this.target).unreadAmount()}maxMessageTime(){return Ri.get(this.target).maxTime()}}class ki extends Pi{constructor(e){super(e),this.accepted=!1}toDto(){let e=new Uo,t=this.target.scene,s=this.target.id,n=this.target.teamId;return e.id=s,e.teamId=n,e.type=t,e.lastMessage=this.getMaxMessage(),e.unread=this.getUnreadAmount(),e.top=this.top,e.data=this.data,e.ended=this.isEnded(),e}isEnded(){let e=this.getMaxMessage(),t=e.type,s=e.payload;return t===ti.END||t===ti.TRANSFER&&s.transferTo.id!==vn.u()}getMaxMessage(){return Ri.get(this.target).getMaxMessage(this.accepted)}getUnreadAmount(){return Ri.get(this.target).unreadAmount(this.accepted)}maxMessageTime(){return Ri.get(this.target).maxTime(this.accepted)}}class Di{constructor(e,t,s,n){this.type=e,this.top=t,this.targetId=s,this.teamId=n}}class xi{constructor(e,t,s){this.type=e,this.targetId=t,this.teamId=s}}class Fi{constructor(e,t,s){this.type=e,this.targetId=t,this.teamId=s}}class Ui{top(e,t){let s=new Di(e.scene,t,e.id,e.teamId);return new Promise(((e,t)=>{let n=new Gs({name:rn.topConversation,params:s,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,success:s=>{200===s.code?e(s):t(s)},fail:e=>{t(e)}});vn.s().emit(n)}))}remove(e){let t=new xi(e.scene,e.id,e.teamId);return new Promise(((e,s)=>{let n=new Gs({name:rn.removeConversation,params:t,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,success:t=>{200==t.code?e(t):s(t)},fail:e=>{s(e)}});vn.s().emit(n)}))}query(e){return new Promise(((t,s)=>{let i=new Gs({name:e,params:{},permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:e=>{s(e)},success:e=>n(this,void 0,void 0,(function*(){t(e)}))});vn.s().emit(i)}))}loadData(e){let t=new Fi(e.scene,e.id,e.teamId);return new Promise(((e,s)=>{let n=new Gs({name:rn.imData,params:t,permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,success:t=>{let s=JSON.parse(t.content);e(s)},fail:e=>{s(e)}});vn.s().emit(n)}))}}Ui.instance=new Ui;class Li{constructor(){this.list=new Array,this.builder=new gi,this.remoteConversations=Ui.instance,this.synchronized=!1,dn.on(ei.MAX_MESSAGE_CHANGED,(e=>this.onMaxMessageChanged(e))),dn.on(ei.UNREAD_AMOUNT_CHANGED,(e=>this.onUnreadMessageChanged(e))),dn.on(ei.MAX_MESSAGE_DELETED,(e=>this.onMaxMessageDeleted(e)))}onUnreadMessageChanged(e){this.findConversation(e)&&this.fireUpdated()}fireUpdated(){let e=this.loadLocalConversations(),t=this.getUpdatedEventName();Io.aec.fire(t,{unreadTotal:e.content.unreadTotal,conversations:e.content.conversations})}getUpdatedEventName(){return wn.CONVERSATIONS_UPDATED}latestConversations(e){return n(this,void 0,void 0,(function*(){this.synchronized||(yield this.loadServerConversations());let t=this.loadLocalConversations();_n.onSuccess(e,t)}))}loadServerConversations(){return n(this,void 0,void 0,(function*(){let e=this.rocketName(),t=yield this.remoteConversations.query(e);this.convertAbbrConversation(t.content),this.synchronized=!0}))}rocketName(){return rn.imLastConversations}convertAbbrConversation(e){let t=e;for(const e of t){let t=e.t,s=e.top,n=e.d?JSON.parse(e.d):{},i=e.userOffsets;e.lmsg.t=t;let o=e.lmsg,r=this.builder.build(o),a=ri.byIMMessage(r),c=this.findConversation(a);ps.isUndef(c)?(c=this.buildByAbbr(e,r),this.insertOne(c)):(c.top=s,c.data=n),Ri.get(a).initMaxMessageAndOffsets(r,i),this.correctPosition(c)}}onMaxMessageDeleted(e){this.removeConversation(e)}onMaxMessageChanged(e){return n(this,void 0,void 0,(function*(){if(e.scene()===xo.CS){let t=e;if(vn.u()!=t.customerId()&&(!1===t.accepted||t.type===ti.ACCEPT&&t.senderId!=vn.u()))return}yield this.saveOrUpdateConversation(e)}))}saveOrUpdateConversation(e){return n(this,void 0,void 0,(function*(){let t=e.status,s=ri.byIMMessage(e),n=this.findConversation(s);ps.isUndef(n)&&t!==Fo.FAIL&&(n=this.buildByMessage(e),this.insertOne(n),t===Fo.SUCCESS&&(n.data=yield this.remoteConversations.loadData(s),n.dataLoaded=!0)),t===Fo.SENDING&&(n.data=e.getToData(),n.dataLoaded=!0),n&&n.dataLoaded&&(this.correctPosition(n),this.fireUpdated())}))}loadLocalConversations(){let e=0,t=new Array;for(const s of this.list)if(s.dataLoaded&&s.getMaxMessage()){e+=s.getUnreadAmount();let n=s.toDto();t.push(n)}return{code:200,content:{unreadTotal:e,conversations:t}}}findConversationIndex(e){return this.list.findIndex((t=>e.toString()===t.target.toString()))}findConversation(e){let t=this.findConversationIndex(e);return this.list[t]}removeLocalConversation(e){let t=this.findConversationIndex(e.target);this.list.splice(t,1)}insertOne(e){Li.sortedInserter.insert(this.list,e),this.list.length>Li.CONVERSATIONS_MAX_LENGTH&&(this.list=this.list.slice(0,Li.CONVERSATIONS_MAX_LENGTH))}correctPosition(e){this.removeLocalConversation(e),this.insertOne(e)}removeConversation(e){let t=this.findConversation(e);t&&(this.removeLocalConversation(t),this.fireUpdated())}top(e,t,s){return n(this,void 0,void 0,(function*(){if(!ps.isBoolean(t))throw new Error("top must be boolean.");let n=this.findConversation(e);if(!n)throw new Error("conversation does not exist.");n.top!=t&&(yield this.remoteConversations.top(e,t),n.top=t,this.correctPosition(n)),this.fireUpdated(),_n.onSuccess(s)}))}remove(e,t){return n(this,void 0,void 0,(function*(){let s=this.findConversation(e);if(!s)throw new Error("conversation does not exist.");if(s instanceof ki&&!s.isEnded())throw new Error("CS conversation can only be deleted after it ends");yield this.remoteConversations.remove(e),this.removeLocalConversation(s),this.fireUpdated(),_n.onSuccess(t)}))}buildByAbbr(e,t){let s,n=ri.byIMMessage(t);if(e.t===xo.CS){let e=t;vn.u()===e.customerId()?s=new Pi(n):(s=new ki(n),s.accepted=e.accepted)}else s=new Pi(n);return s.dataLoaded=!0,s.top=e.top,s.data=e.d?JSON.parse(e.d):{},s}buildByMessage(e){let t,s=ri.byIMMessage(e);if(e.scene()===xo.CS){let n=e;vn.u()===n.customerId()?t=new Pi(s):(t=new ki(s),t.accepted=n.accepted)}else t=new Pi(s);return t}}Li.CONVERSATIONS_MAX_LENGTH=200,Li.sortedInserter=new class extends ii{compare(e,t){let s;if(e.top==t.top){let n=e.maxMessageTime();s=t.maxMessageTime()-n}else s=e.top?-1:1;return 0===s?0:s>0?1:-1}};class Gi extends Li{constructor(){super(),this.expired=!1,dn.on(ei.CS_ONLINE_SUCCESS,(()=>this.onCSOnlineSuccess())),dn.on(ei.CS_OFFLINE_SUCCESS,(()=>this.onCSOfflineSuccess())),vn.s().addDisconnectedObserver(this.onDisconnected.bind(this)),vn.s().addConnectedObserver(this.onConnected.bind(this))}onMaxMessageChanged(e){return n(this,void 0,void 0,(function*(){if(e.scene()===xo.CS){let t=e;if(t.customerId()!=vn.u()&&(!1===t.accepted||t.type===ti.ACCEPT))if(ti.ACCEPT===e.type){let t=ri.byIMMessage(e);this.removeConversation(t)}else yield this.saveOrUpdateConversation(e)}}))}latestConversations(e){const t=Object.create(null,{latestConversations:{get:()=>super.latestConversations}});return n(this,void 0,void 0,(function*(){let s=this.synchronized;yield t.latestConversations.call(this,e),this.list.length>0&&!s&&this.fireUpdated()}))}onUnreadMessageChanged(e){}onCSOnlineSuccess(){return n(this,void 0,void 0,(function*(){yield this.loadServerConversations(),this.fireUpdated()}))}onCSOfflineSuccess(){this.list=[],this.fireUpdated()}getUpdatedEventName(){return wn.PENDING_CONVERSATIONS_UPDATED}rocketName(){return rn.CS_PENDING_CONVERSATION}convertAbbrConversation(e){return n(this,void 0,void 0,(function*(){let t=e;for(const e of t){e.lastMessage.t=xo.CS;let t=e.customerData,s=e.lastMessage,n=e.userOffsets,i=t?JSON.parse(t):{},o=this.builder.build(s),r=ri.byIMMessage(o),a=this.findConversation(r);ps.isUndef(a)&&(a=new ki(r),a.accepted=o.accepted,a.dataLoaded=!0,this.insertOne(a)),a.top=!1,a.data=i,Ri.get(r).initPendingMaxMessageAndOffsets(o,n),this.correctPosition(a)}}))}onDisconnected(){this.expired=!0}onConnected(){return n(this,void 0,void 0,(function*(){let e=vn.supportIM();this.expired&&e&&(this.expired=!1,this.list=[],yield this.loadServerConversations(),this.fireUpdated())}))}}class Bi{constructor(){this.conversations=new Li,this.pendingConversations=new Gi}latestConversations(e){this.conversations.latestConversations(e)}latestPendingConversations(e){this.pendingConversations.latestConversations(e)}topPrivateConversation(e){let t=ri.byScene(xo.PRIVATE,e.userId);this.conversations.top(t,e.top,e)}topGroupConversation(e){let t=ri.byScene(xo.GROUP,e.groupId);this.conversations.top(t,e.top,e)}topConversation(e){let t=e.conversation;this.validateConversationDTO(t);let s=ri.byConversationDTO(t);this.conversations.top(s,e.top,e)}removePrivateConversation(e){let t=ri.byScene(xo.PRIVATE,e.userId);this.conversations.remove(t,e)}removeGroupConversation(e){let t=ri.byScene(xo.GROUP,e.groupId);this.conversations.remove(t,e)}removeConversation(e){let t=e.conversation;this.validateConversationDTO(t);let s=ri.byConversationDTO(t);this.conversations.remove(s,e)}validateConversationDTO(e){if(!(e instanceof Uo))throw new Error("Incorrect conversation object.");{let t=e.lastMessage;if(t instanceof mi&&t.customerId()!==vn.u()&&!1===t.accepted)throw new Error("pending conversation cannot be topped or removed.")}}}class ji{constructor(){this.builder=new gi,cn.instance.addAssembler(new class{assemble(e){let t={messageId:e.id,timestamp:e.tm,type:e.t,senderId:e.sid,toType:e.tt};return e.tt===xo.GROUP&&(t.groupId=e.gid),t}support(e){return!!e.sid}})}initialGoEasySocket(){vn.s().addMessageObserver(bn.imMessage,this.onMessageReceived.bind(this))}onMessageReceived(e){if(e.t!==xo.CS){let t=this.builder.build(e);this.sendAck(t);let s=ri.byIMMessage(t),n=s.scene;Ri.get(s).existsMessage(t)||(this.createNotification(e),dn.fire(ei.MESSAGE_RECEIVED,t),n===xo.PRIVATE?Io.aec.fire(wn.PRIVATE_MESSAGE_RECEIVED,t):n===xo.GROUP&&Io.aec.fire(wn.GROUP_MESSAGE_RECEIVED,t))}}sendAck(e){vn.s().sendAck("imAck",{publishGuid:e.messageId})}createNotification(e){const t=cn.instance.supportNotification();if(!ps.isObject(e.nt)||e.s===vn.u()||!t)return;let s={id:e.i,tm:e.ts,t:e.mt,sid:e.s,tt:e.t};s.tt===xo.GROUP&&(s.gid=e.r),cn.instance.createLocalNotification(e.nt.t,e.nt.c,s)}}class qi{subscribe(e){yn.validateIdArray(e.groupIds,"groupIds"),e.groupIds=e.groupIds.toString().split(",");let t=new Gs({name:rn.subscribeGroups,params:{groupIds:e.groupIds,at:e.accessToken},permission:Qt.WRITE,singleTimeout:$s.commonInfiniteSingle,totalTimeout:$s.commonInfiniteTotal,success:function(){_n.onSuccess(e,{code:200,content:"ok"})},fail:function(t){_n.onFailed(e,{code:t.resultCode||408,content:t.content||"Failed to subscribe group message"})}});vn.s().emit(t)}unsubscribe(e){yn.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();let t=new Gs({name:rn.unsubscribeGroup,params:{groupId:e.groupId},permission:Qt.READ,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,success:()=>{_n.onSuccess(e,{code:200,content:"ok"})},fail:t=>{_n.onFailed(e,{code:t.resultCode||408,content:t.content||"Failed to unsubscribe group message"})}});vn.s().emit(t)}}class Wi{constructor(){vn.s().addMessageObserver(bn.groupPresence,this.newMessageReceived.bind(this))}presence(e){yn.validateIdArray(e.groupIds,"groupIds"),e.groupIds.toString().split(",");let t={groupIds:e.groupIds};this.emitRocket(rn.subscribeGroupPresence,t,(()=>{_n.onSuccess(e,{code:200,content:"ok"})}),(t=>{_n.onFailed(e,{code:t.code||408,content:t.content||"Failed to subscribe group message"})}),$s.commonInfiniteSingle,$s.commonInfiniteTotal)}unPresence(e){yn.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();let t={groupId:e.groupId};this.emitRocket(rn.unsubscribeGroupPresence,t,(()=>{_n.onSuccess(e,{code:200,content:"ok"})}),(t=>{_n.onFailed(e,{code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}),$s.commonRequestSingle,$s.commonRequestTotal)}emitRocket(e,t,s,n,i,o){let r=new Gs({name:e,params:t,singleTimeout:i,totalTimeout:o,permission:Qt.WRITE,success:s,fail:n});vn.s().emit(r)}newMessageReceived(e){let t=null;e.c&&(t=JSON.parse(e.c)),t&&t.events&&t.events.map((e=>{let s=e.userData?JSON.parse(e.userData):{},n={time:e.time,action:e.action,groupOnlineCount:t.userAmount,groupId:t.groupId,id:e.userId,data:s};Io.aec.fire(wn.GROUP_PRESENCE,n)}))}}class Vi{get(e){yn.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();let t=new Gs({name:rn.imGroupOnlineCount,params:{groupId:e.groupId},permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:function(t){_n.onFailed(e,t||{code:408,content:"Failed to query online group users"})},success:function(t){200==t.code?_n.onSuccess(e,t):_n.onFailed(e,t)}});vn.s().emit(t)}}class Hi{doHereNow(e,t,s){let n=new Gs({name:e,params:t,permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:e=>{_n.onFailed(s,e)},success:e=>{let t=e.content;e.content=t.map((e=>{let t=e.userData?JSON.parse(e.userData):{};return{id:e.userId,data:t}})),_n.onSuccess(s,e)}});vn.s().emit(n)}}class zi extends Hi{hereNow(e){yn.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();let t={groupId:e.groupId};this.doHereNow(rn.imGroupHereNow,t,e)}}class Xi{constructor(){vn.s().addMessageObserver(bn.userPresence,this.newMessageReceived.bind(this))}presence(e){yn.validateIdArray(e.userIds,"userIds"),e.userIds.toString().split(",");let t={userIds:e.userIds};this.emitRocket(rn.subscribeUserPresence,t,(()=>{_n.onSuccess(e,{code:200,content:"ok"})}),(t=>{_n.onFailed(e,{code:t.code||408,content:t.content||"Failed to subscribe group message"})}),$s.commonInfiniteSingle,$s.commonInfiniteTotal)}unPresence(e){yn.validateId(e.userId,"userId"),e.userId=e.userId.toString();let t={userId:e.userId};this.emitRocket(rn.unsubscribeUserPresence,t,(()=>{_n.onSuccess(e,{code:200,content:"ok"})}),(t=>{_n.onFailed(e,{code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}),$s.commonRequestSingle,$s.commonRequestTotal)}emitRocket(e,t,s,n,i,o){let r=new Gs({name:e,params:t,singleTimeout:i,totalTimeout:o,permission:Qt.WRITE,success:s,fail:n});vn.s().emit(r)}newMessageReceived(e){let t=[];e.c&&(t=JSON.parse(e.c).events||[]),t.map((e=>{let t=e.userData?JSON.parse(e.userData):{},s={time:e.time,action:e.action,id:e.userId,data:t};Io.aec.fire(wn.USER_PRESENCE,s)}))}}class Ji extends Hi{hereNow(e){let t=e.userIds;yn.validateIdArray(t,"userIds"),t.toString().split(","),this.doHereNow(rn.imHereNow,e,e)}}const Yi=new class{fileExtension(e,t){if(ps.isString(e))try{let s=e.split(t);return s[s.length-1]}catch(e){throw Error(e)}}};class Ki{}class Qi extends Ki{constructor(){super(...arguments),this.contentType="",this.name="",this.size=0,this.url=""}}class $i extends Qi{constructor(){super(...arguments),this.width=0,this.height=0}}class Zi{build(e){this.validate(e.createOptions);let t=this.create();return this.setPayload(e,t),t}}class eo extends Zi{create(){return new Qi}setPayload(e,t){let s=t,n=e.createOptions.file;s.url=n.path,s.name=n.name,s.size=n.size,s.contentType=n.type,e.complete=Promise.resolve()}validate(e){if(!ps.isObject(e))throw Error("it is an empty message.");if(!ps.isDef(e.file))throw Error("file is empty.")}}class to extends eo{create(){return new $i}setPayload(e,t){super.setPayload(e,t);let s=e.createOptions.file,n=t,i=s.path||s.tempFilePath,o=ps.isEmpty(s.name)||void 0===s.name?i:s.name;n.name="wx-image."+Yi.fileExtension(o,"."),n.contentType="image/"+Yi.fileExtension(o,"."),n.url=i,n.size=s.size,e.complete=new Promise(((e,t)=>{wx.getImageInfo({src:n.url,success(t){n.width=t.width,n.height=t.height,e()},fail(e){t(e)}})}))}validate(e){super.validate(e)}}class so extends Qi{constructor(){super(...arguments),this.duration=0}}class no extends eo{create(){return new so}setPayload(e,t){super.setPayload(e,t);let s=e.createOptions.file,n=t,i=s.tempFilePath,o=ps.isEmpty(s.name)||null==s.name?i:s.name,r=s.duration,a=s.fileSize;n.url=i,n.size=a,n.duration=r/1e3,n.name="wx-audio."+Yi.fileExtension(o,"."),n.contentType="audio/"+Yi.fileExtension(o,"."),e.complete=Promise.resolve()}validate(e){super.validate(e)}}class io extends Ki{constructor(){super(...arguments),this.text=""}}class oo extends Zi{create(){return new io}setPayload(e,t){let s=t,n=e.createOptions;s.text=n.text,e.complete=Promise.resolve()}validate(e){if(ps.isEmpty(e.text))throw{code:400,content:"text is empty"};if(!ps.isString(e.text))throw{code:400,content:"TypeError: text requires string."};if(""===e.text.trim())throw{code:400,content:"text is empty"};if(e.text.length>2500)throw{code:400,content:"Message text over max length 2500"}}}class ro extends Ki{constructor(){super(...arguments),this.video=new co,this.thumbnail=new ao}}class ao{constructor(){this.name="",this.url="",this.width=0,this.height=0,this.contentType=""}initURL(e){let t=tn.currentPlatform();[Zs.APP_IOS,Zs.APP_ANDROID].includes(t)?this.appUrl(e):[Zs.APPLET_WX,Zs.APPLET_WX_GAME].includes(t)?this.wxUrl(e):this.htmlUrl(e)}htmlUrl(e){let t=document.createElement("canvas");t.width=e.videoWidth,t.height=e.videoHeight,t.getContext("2d").drawImage(e,0,0,t.width,t.height),this.url=t.toDataURL("image/png")}wxUrl(e){}appUrl(e){}}class co{constructor(){this.name="",this.url="",this.width=0,this.height=0,this.contentType="",this.size=0,this.duration=0}}class uo extends Zi{create(){return new ro}setPayload(e,t){let s=e.createOptions.file,n=t,i=n.video,o=n.thumbnail,{duration:r,height:a,size:c,tempFilePath:u,thumbTempFilePath:l,width:d,name:h=""}=s,p=ps.isEmpty(h)?u:h;i.contentType="video/"+Yi.fileExtension(p,"."),i.name="wx-video."+Yi.fileExtension(p,"."),i.url=u,i.width=o.width=d,i.height=o.height=a,i.size=c,i.duration=r,o.url=l,o.contentType="image/jpg",o.name="wx-thumbnail.jpg",e.complete=Promise.resolve()}validate(e){if(!ps.isObject(e))throw Error("it is an empty message.");if(!ps.isDef(e.file))throw Error("file is empty.")}}class lo extends Zi{create(){return new Qi}setPayload(e,t){let s=t,n=e.createOptions.file;s.url=n.fullPath,s.name=n.name,s.size=n.size,s.contentType=n.type,n.type,e.complete=Promise.resolve()}validate(e){if(!ps.isObject(e))throw Error("it is an empty message.");if(!ps.isDef(e.file))throw Error("file is empty.")}}class ho extends lo{create(){return new $i}setPayload(e,t){let s=t,n=e.createOptions.file;s.url=n.path,s.size=n.size;let i=ps.isEmpty(n.name)||void 0===n.name?n.path:n.name;s.contentType="image/"+Yi.fileExtension(i,"."),s.name="uni-image."+Yi.fileExtension(i,"."),e.complete=new Promise(((e,t)=>{uni.getImageInfo({src:n.path,success(t){s.width=t.width,s.height=t.height,e()},fail(e){t(e)}})}))}validate(e){super.validate(e)}}class po extends lo{create(){return new so}setPayload(e,t){let s=e.createOptions,n=t,i=s.file,o=i.tempFilePath,r=ps.isEmpty(i.name)||null==i.name?o:i.name;n.url=o,n.name="uni-audio."+Yi.fileExtension(r,"."),n.contentType="audio/"+Yi.fileExtension(r,"."),e.complete=new Promise(((e,t)=>{uni.getFileInfo({filePath:o,success:i=>{let r=i.size;if(n.size=r,0===r)e();else if(ps.isDef(s.file.duration))n.duration=s.file.duration/1e3,e();else{const s=uni.createInnerAudioContext();s.src=o,s.onCanplay((function(i){i.errCode?(s.destroy(),t(i)):(n.duration=s.duration,s.destroy(),e())})),s.onError((n=>{s.destroy(),-99===n.errCode?e():t(n)}))}},fail(e){t(e)}})}))}validate(e){super.validate(e)}}class fo extends Zi{create(){return new ro}setPayload(e,t){let s=e.createOptions.file,n=t,i=n.video,o=n.thumbnail,{duration:r,height:a,size:c,tempFilePath:u,width:l,name:d=""}=s,h=ps.isEmpty(d)?u:d;i.size=c,i.width=l,i.height=a,i.url=u,i.duration=r,i.contentType="video/"+Yi.fileExtension(h,"."),i.name="uni-video."+Yi.fileExtension(h,"."),o.url=u,o.height=200,o.width=Number((i.width*o.height/i.height).toFixed(0)),o.contentType="image/jpg",o.name="uni-thumbnail.jpg",e.complete=Promise.resolve()}validate(e){if(!ps.isObject(e))throw Error("it is an empty message.");if(!ps.isDef(e.file))throw Error("file is empty.")}}class mo extends Zi{create(){return new Qi}setPayload(e,t){let s=t,n=e.createOptions.file,i=window.URL||window.webkitURL;s.url=i.createObjectURL(n),s.name=n.name,s.size=n.size,s.contentType=n.type,e.complete=Promise.resolve()}validate(e){if(!ps.isObject(e))throw Error("it is an empty message.");if(!(e.file instanceof File))throw Error("wrong file type.");if(0==e.file.size)throw Error("File size is 0.");if(e.file.size>524288e3)throw Error("message-length limit 30mib")}}class go extends mo{create(){return new $i}setPayload(e,t){super.setPayload(e,t);let s=e.createOptions.file,n=t,i=window.URL||window.webkitURL,o=new Image;o.src=i.createObjectURL(s),e.complete=new Promise(((e,t)=>{o.onload=function(){n.width=o.width,n.height=o.height,i.revokeObjectURL(o.src),e()},o.onerror=function(e){i.revokeObjectURL(o.src),t(e)}}))}validate(e){super.validate(e);let t=["gif","jpg","png","jpeg"];if(!t.find((t=>t===e.file.type.split("/")[1].toLowerCase())))throw Error("Only "+t.join(",")+" is supported image.")}}class yo extends mo{create(){return new so}setPayload(e,t){super.setPayload(e,t);let s=e.createOptions.file,n=t,i=window.URL||window.webkitURL,o=document.createElement("audio");o.src=i.createObjectURL(s),e.complete=new Promise(((e,t)=>{o.onloadedmetadata=()=>{n.duration=o.duration,i.revokeObjectURL(o.src),e()},o.onerror=e=>{i.revokeObjectURL(o.src),t(e)}}))}validate(e){super.validate(e);let t=["mp3","ogg","wav","wma","ape","acc","mpeg"];if(!t.find((t=>t===e.file.type.split("/")[1].toLowerCase())))throw Error("Only "+t.join(",")+" is supported audio.")}}class vo extends Zi{create(){return new ro}setPayload(e,t){let s=e.createOptions.file,n=t,i=n.video,o=n.thumbnail,r=window.URL||window.webkitURL,a=document.createElement("video");a.src=r.createObjectURL(s),i.size=s.size,i.name=s.name,i.contentType=s.type,i.url=a.src,o.name=s.name,o.contentType="image/jpg",e.complete=new Promise(((e,t)=>{a.onloadedmetadata=()=>{i.duration=a.duration,i.width=a.videoWidth,i.height=a.videoHeight,o.width=a.videoWidth,o.height=a.videoHeight,o.url=this.getThumbnailUrl(a),r.revokeObjectURL(a.src),e()},a.onerror=function(e){r.revokeObjectURL(a.src),t(e)}}))}getThumbnailUrl(e){let t=document.createElement("canvas");return t.width=e.videoWidth,t.height=e.videoHeight,t.getContext("2d").drawImage(e,0,0,t.width,t.height),t.toDataURL("image/png")}validate(e){if(!ps.isObject(e))throw Error("it is an empty message.");if(!(e.file instanceof File))throw Error("wrong file type.");if(0==e.file.size)throw Error("File size is 0.");if(e.file.size>31457280)throw Error("message-length limit 30mib");let t=["avi","mov","rmvb","rm","flv","mp4","3gp","quicktime"];if(!t.find((t=>t===e.file.type.split("/")[1].toLowerCase())))throw Error("Only "+t.join(",")+" is supported video.")}}class Eo extends Ki{}class So extends Zi{create(){return new Eo}setPayload(e,t){let s=e.createOptions;t.payload=s.payload,e.complete=Promise.resolve()}validate(e){let t=e.type,s=e.payload;if(ps.isEmpty(t))throw Error("type is empty.");if(!ps.isString(t))throw Error("type require a string");if(ps.isEmpty(s))throw Error("payload is empty.");if(!ps.isPlainObject(s)&&!ps.isStringOrNumber(s))throw Error("payload require object | string | number.")}}class Co{constructor(e,t){this.type=e,this.createOptions=t}}class bo{constructor(){this.framework=nn.currentFramework();const e=tn.currentPlatform()===Zs.APPLET_WX;this.payloadBuilders={[en.UNIAPP]:{image:new ho,file:new lo,audio:new po,video:new fo,text:new oo},[en.NATIVE_APPLET_WX]:{image:new to,file:new eo,audio:new no,video:new uo,text:new oo},[en.UNKNOWN]:{image:new go,file:new mo,audio:new yo,video:new vo,text:new oo},[en.TARO]:{image:e?new to:new go,file:e?new eo:new mo,audio:e?new no:new yo,video:e?new uo:new vo,text:new oo}}}buildMessage(e,t){let s=this.payloadBuilders[this.framework][e],n=new Co(e,t);if(s){let e=s.build(n);n.payload=e}else{let e=(new So).build(n);n.payload=e.payload}let i=this.build(n);return n.complete.then((()=>{_n.onSuccess(t,i)})).catch((e=>{_n.onFailed(t,e)})),i}build(e){let t,s=e.type,n=e.payload,i=e.createOptions,o=i.to,r=o.type;return this.validate(i),r===xo.GROUP?(t=new fi,t.groupId=o.id.toString(),t.senderData=vn.ud()):r===xo.PRIVATE?(t=new pi,t.read=!1,t.receiverId=o.id.toString()):r===xo.CS&&(t=new mi,t.to=o.id.toString(),t.teamId=o.id.toString(),t.senderData=vn.ud()),t.senderId=vn.u(),t.messageId=Ls.get(),t.payload=n,t.timestamp=Date.now(),t.type=s,t.recalled=!1,t.status=Fo.NEW,t.buildOptions=e,t}validate(e){const t=e.to;if(!t)throw new Error("message require property to.");if(!ps.isObject(t))throw new Error("TypeError: to requires an object.");if(!ps.isObject(t.data))throw new Error("TypeError: to.data requires an object.");if(!t.type||t.type!==xo.GROUP&&t.type!==xo.PRIVATE&&t.type!==xo.CS)throw new Error("message require property to.type");if(ps.isEmpty(t.id))throw new Error("message require property to.id");if(!ps.isStringOrNumber(t.id))throw new Error("to.id should be a string or number.");if(vn.u()===t.id)throw new Error("to.id can not be the same as your id.");e.notification&&yn.validateNotification(e.notification),e.wxmpTemplateMsg&&yn.validateWXMPTemplateMsg(e.wxmpTemplateMsg)}}class wo extends ji{onMessageReceived(e){if(e.t===xo.CS){let t=this.builder.build(e);this.sendAck(t);let s=ri.byIMMessage(t);if(!Ri.get(s).existsMessage(t)){if(t.customerId()===vn.u())this.createNotification(e),dn.fire(ei.MESSAGE_RECEIVED,t),Io.aec.fire(wn.CS_MESSAGE_RECEIVED,t);else{Ni.getInstance().queryTeams().then((()=>{Ti.isMyMessage(t)&&this.createNotification(e),dn.fire(ei.CS_AGENT_MESSAGE_RECEIVED,t)}))}}}}}class Io{constructor(e){this._iMReceiver=new ji,this.csMessageReceiver=new wo,this.options=e,Io.aec=new kn,this._userHereNow=new Ji,this.goEasyUploader=new Yn,this._groupHereNow=new zi,this._groupOnlineCount=new Vi,this.groupMessageSubscriber=new qi}static init(e){Io.instance=new Io(e)}afterConnect(){this._iMReceiver.initialGoEasySocket(),this.csMessageReceiver.initialGoEasySocket(),this.messageBuilder=new bo,this.messageSender=new ni,this.histories=Ri.init(),this.histories.initialListeners(),this.conversations=new Bi,this._groupPresenceSubscriber=new Wi,this._userPresenceSubscriber=new Xi}validateModules(){if(ps.isUndef(vn.s()))throw Error("Please call connect() first.");if(!this.options.modules||!this.options.modules.includes(mn))throw Error(`Invalid options: module '${mn}' is not enabled`)}catch(e,t){return n(this,void 0,void 0,(function*(){try{this.validateModules(),yn.validateCallbackOptions(t),yield e()}catch(e){_n.onFailed(t,e)}}))}on(e,t){Io.aec.on(e,t)}off(e,t){Io.aec.off(e,t)}createTextMessage(e){return this.validateModules(),this.messageBuilder.buildMessage(Bn.TEXT,e)}createImageMessage(e){return this.validateModules(),this.messageBuilder.buildMessage(Bn.IMAGE,e)}createFileMessage(e){return this.validateModules(),this.messageBuilder.buildMessage(Bn.FILE,e)}createAudioMessage(e){return this.validateModules(),this.messageBuilder.buildMessage(Bn.AUDIO,e)}createVideoMessage(e){return this.validateModules(),this.messageBuilder.buildMessage(Bn.VIDEO,e)}createCustomMessage(e){return this.validateModules(),this.messageBuilder.buildMessage(e.type,e)}sendMessage(e){this.catch((()=>{this.messageSender.send(e)}),e)}recallMessage(e){this.catch((()=>{this.histories.recallMessage(e)}),e)}deleteMessage(e){this.catch((()=>{this.histories.deleteMessage(e)}),e)}markGroupMessageAsRead(e){this.catch((()=>n(this,void 0,void 0,(function*(){yield this.histories.groupMarkAsRead(e)}))),e)}markPrivateMessageAsRead(e){this.catch((()=>n(this,void 0,void 0,(function*(){yield this.histories.privateMarkAsRead(e)}))),e)}markMessageAsRead(e,t){this.catch((()=>n(this,void 0,void 0,(function*(){yield this.histories.markMessageAsRead(e,t)}))),e)}latestConversations(e){this.validateModules(),this.conversations.latestConversations(e)}removePrivateConversation(e){this.catch((()=>this.conversations.removePrivateConversation(e)),e)}removeGroupConversation(e){this.catch((()=>this.conversations.removeGroupConversation(e)),e)}topPrivateConversation(e){this.catch((()=>this.conversations.topPrivateConversation(e)),e)}topGroupConversation(e){this.catch((()=>this.conversations.topGroupConversation(e)),e)}history(e,t){this.catch((()=>{this.histories.loadHistory(e,t)}),e)}subscribeUserPresence(e){this.catch((()=>this._userPresenceSubscriber.presence(e)),e)}unsubscribeUserPresence(e){this.catch((()=>this._userPresenceSubscriber.unPresence(e)),e)}hereNow(e){this.catch((()=>this._userHereNow.hereNow(e)),e)}subscribeGroup(e){this.catch((()=>this.groupMessageSubscriber.subscribe(e)),e)}unsubscribeGroup(e){this.catch((()=>this.groupMessageSubscriber.unsubscribe(e)),e)}subscribeGroupPresence(e){this.catch((()=>this._groupPresenceSubscriber.presence(e)),e)}unsubscribeGroupPresence(e){this.catch((()=>this._groupPresenceSubscriber.unPresence(e)),e)}groupHereNow(e){this.catch((()=>this._groupHereNow.hereNow(e)),e)}groupOnlineCount(e){this.catch((()=>this._groupOnlineCount.get(e)),e)}latestPendingConversations(e){this.validateModules(),this.conversations.latestPendingConversations(e)}topConversation(e){this.validateModules(),this.conversations.topConversation(e)}removeConversation(e){this.validateModules(),this.conversations.removeConversation(e)}}var Mo;!function(e){e.VIDEO="VIDEO",e.VOICE="VOICE"}(Mo||(Mo={}));class Ao{constructor(e,t){this.customerId=e,this.teamId=t}}class No{constructor(e,t){this.teamId=e;let s=new Go(t.id.toString(),JSON.stringify(t.data));this.customer=s}}class To{constructor(e,t,s){this.customerId=e,this.teamId=t,this.agentId=s}}class Oo{constructor(e,t){this.customerId=e,this.teamId=t}}class _o{constructor(e){this.builder=new gi,this.teamId=e}accept(e,t){let s=t.customer;if(ps.isUndef(s))throw{code:400,content:"customer is required."};yn.validateId(s.id,"customer.id");let n=s.data;if(ps.isUndef(n)||!ps.isObject(n))throw{code:400,content:"customer data must be non-empty object."};let i=new No(e,s),o=new Gs({name:rn.CS_ACCEPT,params:i,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e=>{_n.onFailed(t,e)},success:e=>{let s=this.builder.build(e.content.message);dn.fire(ei.CS_ACCEPTED,s),_n.onSuccess(t)}});vn.s().emit(o)}end(e,t){yn.validateId(t.id,"id");let s=t.id.toString(),n=new Oo(s,e),i=new Gs({name:rn.CS_END,params:n,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e=>{_n.onFailed(t,e)},success:e=>{let s=this.builder.build(e.content.message);dn.fire(ei.CS_ENDED,s),_n.onSuccess(t)}});vn.s().emit(i)}queryCustomerStatus(e,t){return n(this,void 0,void 0,(function*(){yn.validateId(t.id,"id");let s=yield this.doCustomerStatus(e,t.id);this.activeCustomerStatus=s,this.activeCustomerStatusOptions=t,_n.onSuccess(t,s)}))}doCustomerStatus(e,t){let s=t.toString(),n=new Ao(s,e);return new Promise(((e,t)=>{let s=new Gs({name:rn.CS_CUSTOMER_STATUS,params:n,permission:Qt.READ,singleTimeout:$s.commonQuerySingle,totalTimeout:$s.commonQueryTotal,fail:e=>{t(e)},success:t=>{let s=t.content;s.agent&&(s.agent.data=JSON.parse(s.agent.data)),e(s)}});vn.s().emit(s)}))}transfer(e,t){yn.validateId(t.customerId,"customerId"),yn.validateId(t.agentId,"agentId");let s=t.customerId.toString(),n=t.agentId.toString(),i=new To(s,e,n),o=new Gs({name:rn.CS_TRANSFER,params:i,permission:Qt.WRITE,singleTimeout:$s.commonRequestSingle,totalTimeout:$s.commonRequestTotal,fail:e=>{_n.onFailed(t,e)},success:e=>{let s=this.builder.build(e.content.message);dn.fire(ei.CS_TRANSFER,s),_n.onSuccess(t)}});vn.s().emit(o)}}class Ro{static getInstance(){return Ro.instance||(Ro.instance=new Ro),Ro.instance}createTextMessage(e,t){let s=Io.instance.createTextMessage(t);this.extendProps(e,s)}createImageMessage(e,t){let s=Io.instance.createImageMessage(t);this.extendProps(e,s)}createFileMessage(e,t){let s=Io.instance.createFileMessage(t);this.extendProps(e,s)}createAudioMessage(e,t){let s=Io.instance.createAudioMessage(t);this.extendProps(e,s)}createVideoMessage(e,t){let s=Io.instance.createVideoMessage(t);this.extendProps(e,s)}createCustomMessage(e,t){let s=Io.instance.createCustomMessage(t);this.extendProps(e,s)}extendProps(e,t){if(t.scene()===xo.CS){let s=t;s.teamId=e,s.accepted=!0}}}class Po{constructor(e){this.teamId=e,this.agentStatus=Ni.getInstance(),this.conversationHandler=new _o(e),this.messageCreator=Ro.getInstance()}catch(e,t){return n(this,void 0,void 0,(function*(){try{yn.validateCallbackOptions(t),yield e()}catch(e){_n.onFailed(t,e)}}))}isOnline(e){this.catch((()=>{this.agentStatus.isOnline(this.teamId,e)}),e)}online(e){this.catch((()=>{this.agentStatus.online(this.teamId,e)}),e)}offline(e){this.catch((()=>{this.agentStatus.offline(this.teamId,e)}),e)}customerStatus(e){this.catch((()=>{this.conversationHandler.queryCustomerStatus(this.teamId,e)}),e)}accept(e){this.catch((()=>{this.conversationHandler.accept(this.teamId,e)}),e)}end(e){this.catch((()=>{this.conversationHandler.end(this.teamId,e)}),e)}history(e){Io.instance.history(e,this.teamId)}markMessageAsRead(e){Io.instance.markMessageAsRead(e,this.teamId)}createTextMessage(e){this.messageCreator.createTextMessage(this.teamId,e)}createImageMessage(e){this.messageCreator.createImageMessage(this.teamId,e)}createFileMessage(e){this.messageCreator.createFileMessage(this.teamId,e)}createAudioMessage(e){this.messageCreator.createAudioMessage(this.teamId,e)}createVideoMessage(e){this.messageCreator.createVideoMessage(this.teamId,e)}createCustomMessage(e){this.messageCreator.createCustomMessage(this.teamId,e)}transfer(e){this.catch((()=>{this.conversationHandler.transfer(this.teamId,e)}),e)}agents(e){this.catch((()=>{this.agentStatus.agents(this.teamId,e)}),e)}liveSession(e){this.catch((()=>{Ti.live(this.teamId,e)}),e)}quitLiveSession(e){this.catch((()=>{Ti.quit(e)}),e)}listenCustomer(e){let t={customerId:e.id,onNewMessage:e.onNewMessage,onStatusUpdated:e.onStatusUpdated,onFailed:e.onFailed,onSuccess:e.onSuccess};this.catch((()=>{Ti.live(this.teamId,t)}),e)}cancelListenCustomer(e){this.catch((()=>{Ti.quit(e)}),e)}}class ko{static team(e){yn.validateId(e,"teamId");let t=this.teams.get(e);return t||(t=new Po(e.toString()),this.teams.set(e.toString(),t)),t}}ko.teams=new Map;class Do{}var xo,Fo;!function(e){e.PRIVATE="private",e.GROUP="group",e.SYSTEM="system",e.CS="cs"}(xo||(xo={})),function(e){e.NEW="new",e.SENDING="sending",e.SUCCESS="success",e.FAIL="fail"}(Fo||(Fo={}));class Uo{}class Lo extends Do{}class Go{constructor(e,t){this.id=e,this.data=t}}class Bo extends Do{}class jo{constructor(e){Rn.init(e)}initialGoEasySocket(){Rn.instance.initialGoEasySocket()}initialBeforeConnect(){Rn.instance.initialBeforeConnect()}publish(e){Rn.instance.publisher.publish(e)}subscribe(e){Rn.instance.subscriber.subscribe(e)}unsubscribe(e){Rn.instance.subscriber.unsubscribe(e)}subscribePresence(e){Rn.instance.presence.subscribePresence(e)}unsubscribePresence(e){Rn.instance.presence.unsubscribePresence(e)}history(e){Rn.instance.histories.get(e)}hereNow(e){Rn.instance.hereNows.byChannel(e)}hereNowByUserIds(e){Rn.instance.hereNows.byUserId(e)}}class qo{constructor(e){Io.init(e)}afterConnect(){Io.instance.afterConnect()}on(e,t){Io.instance.on(e,t)}off(e,t){Io.instance.off(e,t)}createTextMessage(e){return Io.instance.createTextMessage(e)}createImageMessage(e){return Io.instance.createImageMessage(e)}createFileMessage(e){return Io.instance.createFileMessage(e)}createAudioMessage(e){return Io.instance.createAudioMessage(e)}createVideoMessage(e){return Io.instance.createVideoMessage(e)}createCustomMessage(e){return Io.instance.createCustomMessage(e)}sendMessage(e){Io.instance.sendMessage(e)}recallMessage(e){Io.instance.recallMessage(e)}deleteMessage(e){Io.instance.deleteMessage(e)}markGroupMessageAsRead(e){Io.instance.markGroupMessageAsRead(e)}markPrivateMessageAsRead(e){Io.instance.markPrivateMessageAsRead(e)}latestConversations(e){Io.instance.latestConversations(e)}removePrivateConversation(e){Io.instance.removePrivateConversation(e)}removeGroupConversation(e){Io.instance.removeGroupConversation(e)}topPrivateConversation(e){Io.instance.topPrivateConversation(e)}topGroupConversation(e){Io.instance.topGroupConversation(e)}history(e){Io.instance.history(e)}subscribeUserPresence(e){Io.instance.subscribeUserPresence(e)}unsubscribeUserPresence(e){Io.instance.unsubscribeUserPresence(e)}hereNow(e){Io.instance.hereNow(e)}subscribeGroup(e){Io.instance.subscribeGroup(e)}unsubscribeGroup(e){Io.instance.unsubscribeGroup(e)}subscribeGroupPresence(e){Io.instance.subscribeGroupPresence(e)}unsubscribeGroupPresence(e){Io.instance.unsubscribeGroupPresence(e)}groupHereNow(e){Io.instance.groupHereNow(e)}groupOnlineCount(e){Io.instance.groupOnlineCount(e)}markMessageAsRead(e){Io.instance.markMessageAsRead(e)}csteam(e){return new Vo(e)}pendingConversations(e){Io.instance.latestPendingConversations(e)}topConversation(e){Io.instance.topConversation(e)}removeConversation(e){Io.instance.removeConversation(e)}}class Wo{constructor(t){if(ps.isDef(Wo.instance)&&Wo.instance.getConnectionStatus()!==e.DISCONNECTED)return Wo.instance;this.validateOptions(t),this.options=t,cn.init(t.allowNotification),this.pubsub=new jo(this.options),this.im=new qo(this.options)}static getInstance(e){return ps.isUndef(Wo.instance)&&(Wo.instance=new Wo(e)),Wo.instance}connect(t){this.getConnectionStatus()!==e.DISCONNECTED&&ps.isObject(t)&&ps.isFunction(t.onFailed)?t.onFailed({code:408,content:"It is already connected, don't try again until disconnect() is called. "}):(this.confirmUserId(t),dn.initial(),this.pubsub.initialBeforeConnect(),this.goEasySocket=new fn(this.options,t),this.goEasySocket.connect(),vn.i(this.goEasySocket),this.im.afterConnect(),this.pubsub.initialGoEasySocket())}disconnect(e){this.goEasySocket.disconnect().then((()=>{ps.isObject(e)&&ps.isFunction(e.onSuccess)&&e.onSuccess()})).catch((t=>{ps.isObject(e)&&ps.isFunction(e.onFailed)&&e.onFailed(t)}))}getConnectionStatus(){return this.goEasySocket?this.goEasySocket.getStatus():e.DISCONNECTED}validateOptions(e){let t="";if(!ps.isObject(e))throw t="options is require an object.",Error(t);if(!ps.isPrimitive(e.appkey)||0==e.appkey.length)throw t="Invalid options:'appkey' is empty.",Error(t);if(!ps.isPrimitive(e.host)||0==e.host.length)throw t="Invalid options:'host' is empty.",Error(t);if(!ps.isArray(e.modules))throw t="Invalid options: 'modules' must be nonempty array",Error(t);const s=[mn,gn],n=e.modules.map((e=>{const n=e.toUpperCase();if(!s.includes(n))throw t=`Invalid options: module '${e}' is not support`,Error(t);return n}));e.modules=n}onClickNotification(e){cn.instance.onClickNotification(e)}confirmUserId(e){if(this.options.modules.includes(mn)&&(ps.isEmpty(e.id)||!ps.isStringOrNumber(e.id)))throw{code:400,content:"TypeError: id requires number or string."};if("string"==typeof e.id&&e.id.length>60)throw{code:400,content:"id over max length 60"}}}Wo.version="2.6.1",Wo.IM_EVENT=wn,Wo.IM_SCENE=xo,Wo.MEDIA_TYPE=Mo;class Vo{constructor(e){this.id=e}isOnline(e){ko.team(this.id).isOnline(e)}online(e){ko.team(this.id).online(e)}offline(e){ko.team(this.id).offline(e)}customerStatus(e){ko.team(this.id).customerStatus(e)}accept(e){ko.team(this.id).accept(e)}end(e){ko.team(this.id).end(e)}history(e){ko.team(this.id).history(e)}markMessageAsRead(e){ko.team(this.id).markMessageAsRead(e)}createTextMessage(e){ko.team(this.id).createTextMessage(e)}createImageMessage(e){ko.team(this.id).createImageMessage(e)}createFileMessage(e){ko.team(this.id).createFileMessage(e)}createAudioMessage(e){ko.team(this.id).createAudioMessage(e)}createVideoMessage(e){ko.team(this.id).createVideoMessage(e)}createCustomMessage(e){ko.team(this.id).createCustomMessage(e)}transfer(e){ko.team(this.id).transfer(e)}agents(e){ko.team(this.id).agents(e)}liveSession(e){ko.team(this.id).liveSession(e)}quitLiveSession(e){ko.team(this.id).quitLiveSession(e)}listenCustomer(e){ko.team(this.id).listenCustomer(e)}cancelListenCustomer(e){ko.team(this.id).cancelListenCustomer(e)}}export{Lo as AgentOnlineOptions,Vo as CSTeam,Do as CallBackOptions,Uo as ConversationDTO,Bo as CustomerStatusOptions,qo as GoEasyIM,jo as GoEasyPubSub,Fo as MessageStatus,xo as Scene,Go as User,Wo as default};