goeasy-2.5.13.min.js 223 KB

1
  1. !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).GoEasy=t()}(this,(function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})})),t}var o={};function s(e){return s="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(e)}var i=function(e,t){return i=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])},i(e,t)};var r=function(){return r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},r.apply(this,arguments)};var a=Object.create?function(e,t,n,o){void 0===o&&(o=n);var s=Object.getOwnPropertyDescriptor(t,n);s&&!("get"in s?!t.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,o,s)}:function(e,t,n,o){void 0===o&&(o=n),e[o]=t[n]};function c(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.")}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,s,i=n.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)r.push(o.value)}catch(e){s={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(s)throw s.error}}return r}function l(e){return this instanceof l?(this.v=e,this):new l(e)}var p=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};var d=Object.freeze({__proto__:null,__extends: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}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)},get __assign(){return r},__rest:function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var s=0;for(o=Object.getOwnPropertySymbols(e);s<o.length;s++)t.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(e,o[s])&&(n[o[s]]=e[o[s]])}return n},__decorate:function(e,t,n,o){var i,r=arguments.length,a=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"===("undefined"==typeof Reflect?"undefined":s(Reflect))&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,o);else for(var c=e.length-1;c>=0;c--)(i=e[c])&&(a=(r<3?i(a):r>3?i(t,n,a):i(t,n))||a);return r>3&&a&&Object.defineProperty(t,n,a),a},__param:function(e,t){return function(n,o){t(n,o,e)}},__metadata:function(e,t){if("object"===("undefined"==typeof Reflect?"undefined":s(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter:function(e,t,n,o){return new(n||(n=Promise))((function(s,i){function r(e){try{c(o.next(e))}catch(e){i(e)}}function a(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(r,a)}c((o=o.apply(e,t||[])).next())}))},__generator:function(e,t){var n,o,s,i,r={label:0,sent:function(){if(1&s[0])throw s[1];return s[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(;r;)try{if(n=1,o&&(s=2&i[0]?o.return:i[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,i[1])).done)return s;switch(o=0,s&&(i=[2&i[0],s.value]),i[0]){case 0:case 1:s=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,o=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(!(s=r.trys,(s=s.length>0&&s[s.length-1])||6!==i[0]&&2!==i[0])){r=0;continue}if(3===i[0]&&(!s||i[1]>s[0]&&i[1]<s[3])){r.label=i[1];break}if(6===i[0]&&r.label<s[1]){r.label=s[1],s=i;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(i);break}s[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(e){i=[6,e],o=0}finally{n=s=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},__createBinding:a,__exportStar:function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||a(t,e,n)},__values:c,__read:u,__spread:function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e},__spreadArrays:function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var o=Array(e),s=0;for(t=0;t<n;t++)for(var i=arguments[t],r=0,a=i.length;r<a;r++,s++)o[s]=i[r];return o},__spreadArray:function(e,t,n){if(n||2===arguments.length)for(var o,s=0,i=t.length;s<i;s++)!o&&s in t||(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))},__await:l,__asyncGenerator:function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,s=n.apply(e,t||[]),i=[];return o={},r("next"),r("throw"),r("return"),o[Symbol.asyncIterator]=function(){return this},o;function r(e){s[e]&&(o[e]=function(t){return new Promise((function(n,o){i.push([e,t,n,o])>1||a(e,t)}))})}function a(e,t){try{(n=s[e](t)).value instanceof l?Promise.resolve(n.value.v).then(c,u):p(i[0][2],n)}catch(e){p(i[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function p(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}},__asyncDelegator:function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,s){t[o]=e[o]?function(t){return(n=!n)?{value:l(e[o](t)),done:"return"===o}:s?s(t):t}:s}},__asyncValues:function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=c(e),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,s){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,s,(t=e[n](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 n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&a(t,e,n);return p(t,e),t},__importDefault:function(e){return e&&e.__esModule?e:{default:e}},__classPrivateFieldGet:function(e,t,n,o){if("a"===n&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?o:"a"===n?o.call(e):o?o.value:t.get(e)},__classPrivateFieldSet:function(e,t,n,o,s){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?s.call(e,n):s?s.value=n:t.set(e,n),n},__classPrivateFieldIn:function(e,t){if(null===t||"object"!==s(t)&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}}),f=n(d),h={};!function(e){e.__esModule=!0,e.NetworkStatus=void 0,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.NetworkStatus||(e.NetworkStatus={}))}(h);var m={},y={},g={};!function(e){e.__esModule=!0,e.Permission=void 0,function(e){e.WRITE="WRITE",e.READ="READ",e.NONE="NONE"}(e.Permission||(e.Permission={}))}(g);var v={__esModule:!0,Emitter:void 0},S=h,E=function(){function e(e){this.socket=e}return e.prototype.emit=function(e){this.socket.status!==S.NetworkStatus.CONNECT_FAILED&&this.socket.status!==S.NetworkStatus.DISCONNECTED?(e.start(),this.doEmit(e)):e.fail({resultCode:"409",content:"Please connect first"})},e.prototype.doEmit=function(e){var t=this;if(e.isTimeout())e.fail({resultCode:408,content:"Host unreachable or timeout"});else if(this.socket.status!==S.NetworkStatus.CONNECT_FAILED)if(this.authenticated())if(this.hasPermission(e))if([S.NetworkStatus.CONNECTED,S.NetworkStatus.RECONNECTED,S.NetworkStatus.EXPIRED_RECONNECTED].includes(this.socket.status)){if(!e.complete){var n=setTimeout((function(){t.doEmit(e)}),e.singleTimeout);e.unique&&(e.params.retried=e.retried),this.socket.doEmit(e.name,e.params,(function(t){clearTimeout(n),200===t.resultCode||200==t.code?e.success(t):e.fail(t)})),e.retried++}}else this.socket.connectedPromise.then((function(){t.doEmit(e)}));else e.fail({resultCode:401,content:"No permission"});else this.socket.connectedPromise.then((function(){t.doEmit(e)}));else e.fail({resultCode:408,content:"Failed to connect GoEasy."})},e.prototype.hasPermission=function(e){return!!this.socket.permissions.find((function(t){return t===e.permission}))},e.prototype.authenticated=function(){return[S.NetworkStatus.CONNECTED,S.NetworkStatus.RECONNECTING,S.NetworkStatus.RECONNECTED,S.NetworkStatus.EXPIRED_RECONNECTED].includes(this.socket.status)},e}();v.Emitter=E;var C={exports:{}},_=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,b=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],M=function(e){var t=e,n=e.indexOf("["),o=e.indexOf("]");-1!=n&&-1!=o&&(e=e.substring(0,n)+e.substring(n,o).replace(/:/g,";")+e.substring(o,e.length));for(var s=_.exec(e||""),i={},r=14;r--;)i[b[r]]=s[r]||"";return-1!=n&&-1!=o&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i},w={exports:{}},T={exports:{}},I=1e3,N=6e4,A=60*N,R=24*A,k=365.25*R,P=function(e,t){t=t||{};var n=s(e);if("string"===n&&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 n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*k;case"days":case"day":case"d":return n*R;case"hours":case"hour":case"hrs":case"hr":case"h":return n*A;case"minutes":case"minute":case"mins":case"min":case"m":return n*N;case"seconds":case"second":case"secs":case"sec":case"s":return n*I;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return O(e,R,"day")||O(e,A,"hour")||O(e,N,"minute")||O(e,I,"second")||e+" ms"}(e):function(e){if(e>=R)return Math.round(e/R)+"d";if(e>=A)return Math.round(e/A)+"h";if(e>=N)return Math.round(e/N)+"m";if(e>=I)return Math.round(e/I)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function O(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function s(){if(s.enabled){var e=s,o=+new Date,i=o-(n||o);e.diff=i,e.prev=n,e.curr=o,n=o;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(n,o){if("%%"===n)return n;c++;var s=t.formatters[o];if("function"==typeof s){var i=r[c];n=s.call(e,i),r.splice(c,1),c--}return n})),t.formatArgs.call(e,r);var u=s.log||t.log||console.log.bind(console);u.apply(e,r)}}return s.namespace=e,s.enabled=t.enabled(e),s.useColors=t.useColors(),s.color=function(e){var n,o=0;for(n in e)o=(o<<5)-o+e.charCodeAt(n),o|=0;return t.colors[Math.abs(o)%t.colors.length]}(e),s.destroy=o,"function"==typeof t.init&&t.init(s),t.instances.push(s),s}function o(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var o=("string"==typeof e?e:"").split(/[\s,]+/),s=o.length;for(n=0;n<s;n++)o[n]&&("-"===(e=o[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,o;for(n=0,o=t.skips.length;n<o;n++)if(t.skips[n].test(e))return!1;for(n=0,o=t.names.length;n<o;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=P,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(T,T.exports),function(e,t){function n(){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=T.exports).log=function(){return"object"===("undefined"==typeof console?"undefined":s(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var s=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(s++,"%c"===e&&(i=s))})),e.splice(i,0,o)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,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(n())}(w,w.exports);var D=M,x=w.exports("socket.io-client:url"),F=function(e,t){var n=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)||(x("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),x("parse %s",e),n=D(e));n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443"));n.path=n.path||"/";var o=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+o+":"+n.port,n.href=n.protocol+"://"+o+(t&&t.port===n.port?"":":"+n.port),n};var G={},U={exports:{}};!function(e){function t(e){if(e)return function(e){for(var n in t.prototype)e[n]=t.prototype[n];return e}(e)}e.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 n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),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 n,o=this._callbacks["$"+e];if(!o)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var s=0;s<o.length;s++)if((n=o[s])===t||n.fn===t){o.splice(s,1);break}return this},t.prototype.emit=function(e){this._callbacks=this._callbacks||{};var t=[].slice.call(arguments,1),n=this._callbacks["$"+e];if(n)for(var o=0,s=(n=n.slice(0)).length;o<s;++o)n[o].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}}(U);var L={}.toString,q=Array.isArray||function(e){return"[object Array]"==L.call(e)};!function(e){w.exports("socket.io-parser");var t=U.exports,n=q;function o(){}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=o,e.Decoder=i;var s=e.ERROR+'"encode error"';function i(){this.reconstructor=null}function r(t){return{type:e.ERROR,data:"parser error: "+t}}o.prototype.encode=function(t,n){var o=function(t){var n=""+t.type;e.BINARY_EVENT!==t.type&&e.BINARY_ACK!==t.type||(n+=t.attachments+"-");t.nsp&&"/"!==t.nsp&&(n+=t.nsp+",");null!=t.id&&(n+=t.id);if(null!=t.data){var o=function(e){try{return JSON.stringify(e)}catch(e){return!1}}(t.data);if(!1===o)return s;n+=o}return n}(t);n([o])},t(i.prototype),i.prototype.add=function(t){var o;if("string"!=typeof t)throw new Error("Unknown type: "+t);o=function(t){var o=0,s={type:Number(t.charAt(0))};if(null==e.types[s.type])return r("unknown packet type "+s.type);if(e.BINARY_EVENT===s.type||e.BINARY_ACK===s.type){for(var i="";"-"!==t.charAt(++o)&&(i+=t.charAt(o),o!=t.length););if(i!=Number(i)||"-"!==t.charAt(o))throw new Error("Illegal attachments");s.attachments=Number(i)}if("/"===t.charAt(o+1))for(s.nsp="";++o;){if(","===(c=t.charAt(o)))break;if(s.nsp+=c,o===t.length)break}else s.nsp="/";var a=t.charAt(o+1);if(""!==a&&Number(a)==a){for(s.id="";++o;){var c;if(null==(c=t.charAt(o))||Number(c)!=c){--o;break}if(s.id+=t.charAt(o),o===t.length)break}s.id=Number(s.id)}if(t.charAt(++o)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(t.substr(o));if(!(!1!==u&&(s.type===e.ERROR||n(u))))return r("invalid payload");s.data=u}return s}(t),this.emit("decoded",o)},i.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}(G);var B={exports:{}},j={},V={},H=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var o in e)n.call(e,o)&&t.push(o);return t},W=q,z=Object.prototype.toString,X="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===z.call(Blob),J="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===z.call(File),Y=function e(t){if(!t||"object"!==s(t))return!1;if(W(t)){for(var n=0,o=t.length;n<o;n++)if(e(t[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(t)||"function"==typeof ArrayBuffer&&t instanceof ArrayBuffer||X&&t instanceof Blob||J&&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 Q=function(e,t,n){var o=!1;return n=n||K,s.count=e,0===e?t():s;function s(e,i){if(s.count<=0)throw new Error("after called too many times");--s.count,e?(o=!0,t(e),t=n):0!==s.count||o||t(null,i)}};function K(){}var $,Z,ee,te=String.fromCharCode;function ne(e){for(var t,n,o=[],s=0,i=e.length;s<i;)(t=e.charCodeAt(s++))>=55296&&t<=56319&&s<i?56320==(64512&(n=e.charCodeAt(s++)))?o.push(((1023&t)<<10)+(1023&n)+65536):(o.push(t),s--):o.push(t);return o}function oe(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 se(e,t){return te(e>>t&63|128)}function ie(e,t){if(0==(4294967168&e))return te(e);var n="";return 0==(4294965248&e)?n=te(e>>6&31|192):0==(4294901760&e)?(oe(e,t)||(e=65533),n=te(e>>12&15|224),n+=se(e,6)):0==(4292870144&e)&&(n=te(e>>18&7|240),n+=se(e,12),n+=se(e,6)),n+=te(63&e|128)}function re(){if(ee>=Z)throw Error("Invalid byte index");var e=255&$[ee];if(ee++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function ae(e){var t,n;if(ee>Z)throw Error("Invalid byte index");if(ee==Z)return!1;if(t=255&$[ee],ee++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|re())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|re()<<6|re())>=2048)return oe(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|re()<<12|re()<<6|re())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var ce={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,o=ne(e),s=o.length,i=-1,r="";++i<s;)r+=ie(o[i],n);return r},decode:function(e,t){var n=!1!==(t=t||{}).strict;$=ne(e),Z=$.length,ee=0;for(var o,s=[];!1!==(o=ae(n));)s.push(o);return function(e){for(var t,n=e.length,o=-1,s="";++o<n;)(t=e[o])>65535&&(s+=te((t-=65536)>>>10&1023|55296),t=56320|1023&t),s+=te(t);return s}(s)}},ue=void 0!==ue?ue:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,le=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),pe=le&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),de=ue&&ue.prototype.append&&ue.prototype.getBlob;function fe(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 he(e,t){t=t||{};var n=new ue;return fe(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function me(e,t){return new Blob(fe(e),t||{})}"undefined"!=typeof Blob&&(he.prototype=Blob.prototype,me.prototype=Blob.prototype);var ye=le?pe?Blob:me:de?he:void 0;!function(e){var t=H,n=Y,o=Q,s=ce;"undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),"undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),e.protocol=3;var i=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},r=t(i),a={type:"error",data:"parser error"},c=ye;e.encodePacket=function(e,t,n,o){"function"==typeof t&&(o=t,t=!1),"function"==typeof n&&(o=n,n=null),void 0===e.data||e.data.buffer||e.data;var r=i[e.type];return void 0!==e.data&&(r+=n?s.encode(String(e.data),{strict:!1}):String(e.data)),o(""+r)},e.decodePacket=function(e,t,n){if(void 0===e)return a;if("string"==typeof e){if(n&&!1===(e=function(e){try{e=s.decode(e,{strict:!1})}catch(e){return!1}return e}(e)))return a;var o=e.charAt(0);return Number(o)==o&&r[o]?e.length>1?{type:r[o],data:e.substring(1)}:{type:r[o]}:a}o=new Uint8Array(e)[0];var i=sliceBuffer(e,1);return c&&"blob"===t&&(i=new c([i])),{type:r[o],data:i}},e.encodePayload=function(t,s,i){"function"==typeof s&&(i=s,s=null);var r=n(t);if(!t.length)return i("0:");!function(e,t,n){for(var s=new Array(e.length),i=o(e.length,n),r=function(e,n,o){t(n,(function(t,n){s[e]=n,o(t,s)}))},a=0;a<e.length;a++)r(a,e[a],i)}(t,(function(t,n){e.encodePacket(t,!!r&&s,!0,(function(e){n(null,function(e){return e.length+":"+e}(e))}))}),(function(e,t){return i(t.join(""))}))},e.decodePayload=function(t,n,o){var s;if("function"==typeof n&&(o=n,n=null),""===t)return o(a,0,1);for(var i,r,c="",u=0,l=t.length;u<l;u++){var p=t.charAt(u);if(":"===p){if(""===c||c!=(i=Number(c)))return o(a,0,1);if(c!=(r=t.substr(u+1,i)).length)return o(a,0,1);if(r.length){if(s=e.decodePacket(r,n,!0),a.type===s.type&&a.data===s.data)return o(a,0,1);if(!1===o(s,u+i,l))return}u+=i,c=""}else c+=p}return""!==c?o(a,0,1):void 0}}(V);var ge=V,ve=Se;function Se(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,U.exports)(Se.prototype),Se.prototype.onError=function(e,t){var n=new Error(e);return n.type="TransportError",n.description=t,this.emit("error",n),this},Se.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},Se.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},Se.prototype.send=function(e){if("open"!==this.readyState)throw new Error("Transport not open");this.write(e)},Se.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},Se.prototype.onData=function(e){var t=ge.decodePacket(e,this.socket.binaryType);this.onPacket(t)},Se.prototype.onPacket=function(e){this.emit("packet",e)},Se.prototype.onClose=function(){this.readyState="closed",this.emit("close")};var Ee,Ce={encode:function(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t},decode:function(e){for(var t={},n=e.split("&"),o=0,s=n.length;o<s;o++){var i=n[o].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}},_e=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},be="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),Me={},we=0,Te=0;function Ie(e){var t="";do{t=be[e%64]+t,e=Math.floor(e/64)}while(e>0);return t}function Ne(){var e=Ie(+new Date);return e!==Ee?(we=0,Ee=e):e+"."+Ie(we++)}for(;Te<64;Te++)Me[be[Te]]=Te;Ne.encode=Ie,Ne.decode=function(e){var t=0;for(Te=0;Te<e.length;Te++)t=64*t+Me[e.charAt(Te)];return t};var Ae=Ne,Re={exports:{}},ke={exports:{}},Pe=1e3,Oe=60*Pe,De=60*Oe,xe=24*De,Fe=365.25*xe,Ge=function(e,t){t=t||{};var n=s(e);if("string"===n&&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 n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*Fe;case"days":case"day":case"d":return n*xe;case"hours":case"hour":case"hrs":case"hr":case"h":return n*De;case"minutes":case"minute":case"mins":case"min":case"m":return n*Oe;case"seconds":case"second":case"secs":case"sec":case"s":return n*Pe;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}(e);if("number"===n&&!1===isNaN(e))return t.long?function(e){return Ue(e,xe,"day")||Ue(e,De,"hour")||Ue(e,Oe,"minute")||Ue(e,Pe,"second")||e+" ms"}(e):function(e){if(e>=xe)return Math.round(e/xe)+"d";if(e>=De)return Math.round(e/De)+"h";if(e>=Oe)return Math.round(e/Oe)+"m";if(e>=Pe)return Math.round(e/Pe)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Ue(e,t,n){if(!(e<t))return e<1.5*t?Math.floor(e/t)+" "+n:Math.ceil(e/t)+" "+n+"s"}!function(e,t){function n(e){var n;function s(){if(s.enabled){var e=s,o=+new Date,i=o-(n||o);e.diff=i,e.prev=n,e.curr=o,n=o;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(n,o){if("%%"===n)return n;c++;var s=t.formatters[o];if("function"==typeof s){var i=r[c];n=s.call(e,i),r.splice(c,1),c--}return n})),t.formatArgs.call(e,r);var u=s.log||t.log||console.log.bind(console);u.apply(e,r)}}return s.namespace=e,s.enabled=t.enabled(e),s.useColors=t.useColors(),s.color=function(e){var n,o=0;for(n in e)o=(o<<5)-o+e.charCodeAt(n),o|=0;return t.colors[Math.abs(o)%t.colors.length]}(e),s.destroy=o,"function"==typeof t.init&&t.init(s),t.instances.push(s),s}function o(){var e=t.instances.indexOf(this);return-1!==e&&(t.instances.splice(e,1),!0)}(t=e.exports=n.debug=n.default=n).coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){t.enable("")},t.enable=function(e){var n;t.save(e),t.names=[],t.skips=[];var o=("string"==typeof e?e:"").split(/[\s,]+/),s=o.length;for(n=0;n<s;n++)o[n]&&("-"===(e=o[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")));for(n=0;n<t.instances.length;n++){var i=t.instances[n];i.enabled=t.enabled(i.namespace)}},t.enabled=function(e){if("*"===e[e.length-1])return!0;var n,o;for(n=0,o=t.skips.length;n<o;n++)if(t.skips[n].test(e))return!1;for(n=0,o=t.names.length;n<o;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Ge,t.instances=[],t.names=[],t.skips=[],t.formatters={}}(ke,ke.exports),function(e,t){function n(){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=ke.exports).log=function(){return"object"===("undefined"==typeof console?"undefined":s(console))&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var n=this.useColors;if(e[0]=(n?"%c":"")+this.namespace+(n?" %c":" ")+e[0]+(n?"%c ":" ")+"+"+t.humanize(this.diff),!n)return;var o="color: "+this.color;e.splice(1,0,o,"color: inherit");var s=0,i=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(s++,"%c"===e&&(i=s))})),e.splice(i,0,o)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=n,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(n())}(Re,Re.exports);var Le={exports:{}};try{Le.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){Le.exports=!1}var qe=Le.exports,Be=function(e){var t=e.xdomain,n=e.xscheme,o=e.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!t||qe))return new XMLHttpRequest}catch(e){}try{if("undefined"!=typeof XDomainRequest&&!n&&o)return new XDomainRequest}catch(e){}if(!t)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}},je=ve,Ve=Ce,He=V,We=_e,ze=Ae,Xe=Re.exports("engine.io-client:polling"),Je=Qe,Ye=null!=new Be({xdomain:!1}).responseType;function Qe(e){var t=e&&e.forceBase64;Ye&&!t||(this.supportsBinary=!1),je.call(this,e)}We(Qe,je),Qe.prototype.name="polling",Qe.prototype.doOpen=function(){this.poll()},Qe.prototype.pause=function(e){var t=this;function n(){Xe("paused"),t.readyState="paused",e()}if(this.readyState="pausing",this.polling||!this.writable){var o=0;this.polling&&(Xe("we are currently polling - waiting to pause"),o++,this.once("pollComplete",(function(){Xe("pre-pause polling complete"),--o||n()}))),this.writable||(Xe("we are currently writing - waiting to pause"),o++,this.once("drain",(function(){Xe("pre-pause writing complete"),--o||n()})))}else n()},Qe.prototype.poll=function(){Xe("polling"),this.polling=!0,this.doPoll(),this.emit("poll")},Qe.prototype.onData=function(e){var t=this;Xe("polling got data %s",e);He.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():Xe('ignoring poll - transport state "%s"',this.readyState))},Qe.prototype.doClose=function(){var e=this;function t(){Xe("writing close packet"),e.write([{type:"close"}])}"open"===this.readyState?(Xe("transport open - closing"),t()):(Xe("transport not open - deferring close"),this.once("open",t))},Qe.prototype.write=function(e){var t=this;this.writable=!1;var n=function(){t.writable=!0,t.emit("drain")};He.encodePayload(e,this.supportsBinary,(function(e){t.doWrite(e,n)}))},Qe.prototype.uri=function(){var e=this.query||{},t=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(e[this.timestampParam]=ze()),this.supportsBinary||e.sid||(e.b64=1),e=Ve.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};var Ke,$e=Je,Ze=it,et=/\n/g,nt=/\\n/g;function ot(){}function st(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:{}}function it(e){if($e.call(this,e),this.query=this.query||{},!Ke){var t=st();Ke=t.___eio=t.___eio||[]}this.index=Ke.length;var n=this;Ke.push((function(e){n.onData(e)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=ot)}),!1)}_e(it,$e),it.prototype.supportsBinary=!1,it.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),$e.prototype.doClose.call(this)},it.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 n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(t,n):(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)},it.prototype.doWrite=function(e,t){var n=this;if(!this.form){var o,s=document.createElement("form"),i=document.createElement("textarea"),r=this.iframeId="eio_iframe_"+this.index;s.className="socketio",s.style.position="absolute",s.style.top="-1000px",s.style.left="-1000px",s.target=r,s.method="POST",s.setAttribute("accept-charset","utf-8"),i.name="d",s.appendChild(i),document.body.appendChild(s),this.form=s,this.area=i}function a(){c(),t()}function c(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(e){n.onError("jsonp polling iframe removal error",e)}try{var e='<iframe src="javascript:0" name="'+n.iframeId+'">';o=document.createElement(e)}catch(e){(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(),c(),e=e.replace(nt,"\\\n"),this.area.value=e.replace(et,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var rt,at,ct=ve,ut=V,lt=Ce,pt=_e,dt=Ae,ft=Re.exports("engine.io-client:websocket");if("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)if("undefined"!=typeof WebSocket)rt=WebSocket;else if("undefined"!=typeof self)rt=self.WebSocket||self.MozWebSocket;else try{at=require("ws")}catch(e){}var ht=rt||at;("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&"undefined"==typeof GameGlobal||(ht=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":s(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)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((function(e){t.onclose(e)}));else{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 i=wx.connectSocket({url:e});t.send=function(e){i.send({data:e})},t.close=function(e){i.close({code:1e3})},i.onOpen((function(){t.onopen()})),i.onError((function(e){t.onerror(e)})),i.onMessage((function(e){t.onmessage(e)})),i.onClose((function(e){t.onclose(e)}))}});var mt=yt;function yt(e){e&&e.forceBase64&&(this.supportsBinary=!1),("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&(this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=rt&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(ht=at)),ct.call(this,e)}pt(yt,ct),yt.prototype.name="websocket",yt.prototype.supportsBinary=!1,yt.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 ht(n,e):new ht(n):new ht(n,e,t):this.ws=new ht(n)}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()}},yt.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)}},yt.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,o=0,s=n;o<s;o++)!function(e){ut.encodePacket(e,t.supportsBinary,(function(o){if("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket){if(!t.usingBrowserWebSocket){var s={};if(e.options&&(s.compress=e.options.compress),t.perMessageDeflate)("string"==typeof o?Buffer.byteLength(o):o.length)<t.perMessageDeflate.threshold&&(s.compress=!1)}try{t.usingBrowserWebSocket?t.ws.send(o):t.ws.send(o,s)}catch(e){ft("websocket closed before onclose event")}}else try{t.ws.send(o)}catch(e){ft("websocket closed before onclose event")}--n||i()}))}(e[o]);function i(){t.emit("flush"),setTimeout((function(){t.writable=!0,t.emit("drain")}),0)}},yt.prototype.onClose=function(){ct.prototype.onClose.call(this)},yt.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},yt.prototype.uri=function(){var e=this.query||{},t=this.secure?"wss":"ws",n="";return this.port&&("wss"===t&&443!==Number(this.port)||"ws"===t&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(e[this.timestampParam]=dt()),this.supportsBinary||(e.b64=1),(e=lt.encode(e)).length&&(e="?"+e),t+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+e},yt.prototype.check=function(){return!(!ht||"__initialize"in ht&&this.name===yt.prototype.name)};var gt=Ze,vt=mt;j.polling=function(e){var t=!1,n=!1;if(e.jsonp,"undefined"!=typeof location){var o="https:"===location.protocol,s=location.port;s||(s=o?443:80),t=e.hostname!==location.hostname||s!==e.port,n=e.secure!==o}return e.xdomain=t,e.xscheme=n,new gt(e)},j.websocket=vt;var St=[].indexOf,Et=function(e,t){if(St)return e.indexOf(t);for(var n=0;n<e.length;++n)if(e[n]===t)return n;return-1},Ct=j,_t=U.exports,bt=Re.exports("engine.io-client:socket"),Mt=Et,wt=V,Tt=M,It=Ce,Nt=At;function At(e,t){if(!(this instanceof At))return new At(e,t);t=t||{},e&&"object"===s(e)&&(t=e,e=null),e?(e=Tt(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=Tt(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=It.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()}At.priorWebsocketSuccess=!1,_t(At.prototype),At.protocol=wt.protocol,At.Socket=At,At.Transport=ve,At.transports=j,At.parser=V,At.prototype.createTransport=function(e){bt('creating transport "%s"',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=wt.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new Ct[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})},At.prototype.open=function(){var e;if(this.rememberUpgrade&&At.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)},At.prototype.setTransport=function(e){bt("setting transport %s",e.name);var t=this;this.transport&&(bt("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")}))},At.prototype.probe=function(e){bt('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,o=this;function s(){if(o.onlyBinaryUpgrades){var s=!this.supportsBinary&&o.transport.supportsBinary;n=n||s}n||(bt('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(s){if(!n)if("pong"===s.type&&"probe"===s.data){if(bt('probe transport "%s" pong',e),o.upgrading=!0,o.emit("upgrading",t),!t)return;At.priorWebsocketSuccess="websocket"===t.name,bt('pausing current transport "%s"',o.transport.name),o.transport.pause((function(){n||"closed"!==o.readyState&&(bt("changing transport and sending upgrade packet"),l(),o.setTransport(t),t.send([{type:"upgrade"}]),o.emit("upgrade",t),t=null,o.upgrading=!1,o.flush())}))}else{bt('probe transport "%s" failed',e);var i=new Error("probe error");i.transport=t.name,o.emit("upgradeError",i)}})))}function i(){n||(n=!0,l(),t.close(),t=null)}function r(n){var s=new Error("probe error: "+n);s.transport=t.name,i(),bt('probe transport "%s" failed because of error: %s',e,n),o.emit("upgradeError",s)}function a(){r("transport closed")}function c(){r("socket closed")}function u(e){t&&e.name!==t.name&&(bt('"%s" works - aborting "%s"',e.name,t.name),i())}function l(){t.removeListener("open",s),t.removeListener("error",r),t.removeListener("close",a),o.removeListener("close",c),o.removeListener("upgrading",u)}At.priorWebsocketSuccess=!1,t.once("open",s),t.once("error",r),t.once("close",a),this.once("close",c),this.once("upgrading",u),t.open()},At.prototype.onOpen=function(){if(bt("socket open"),this.readyState="open",At.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){bt("starting upgrade probes");for(var e=0,t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}},At.prototype.onPacket=function(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(bt('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 bt('packet received with socket readyState "%s"',this.readyState)},At.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))},At.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)},At.prototype.setPing=function(){var e=this;clearTimeout(e.pingIntervalTimer),e.pingIntervalTimer=setTimeout((function(){bt("writing ping packet - expecting pong within %sms",e.pingTimeout),e.ping(),e.onHeartbeat(e.pingTimeout)}),e.pingInterval)},At.prototype.ping=function(){var e=this;this.sendPacket("ping",(function(){e.emit("ping")}))},At.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},At.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(bt("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},At.prototype.write=At.prototype.send=function(e,t,n){return this.sendPacket("message",e,t,n),this},At.prototype.sendPacket=function(e,t,n,o){if("function"==typeof t&&(o=t,t=void 0),"function"==typeof n&&(o=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var s={type:e,data:t,options:n};this.emit("packetCreate",s),this.writeBuffer.push(s),o&&this.once("flush",o),this.flush()}},At.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?o():t()})):this.upgrading?o():t()}function t(){e.onClose("forced close"),bt("socket closing - telling transport to close"),e.transport.close()}function n(){e.removeListener("upgrade",n),e.removeListener("upgradeError",n),t()}function o(){e.once("upgrade",n),e.once("upgradeError",n)}return this},At.prototype.onError=function(e){bt("socket error %j",e),At.priorWebsocketSuccess=!1,this.emit("error",e),this.onClose("transport error",e)},At.prototype.onClose=function(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){bt('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}},At.prototype.filterUpgrades=function(e){for(var t=[],n=0,o=e.length;n<o;n++)~Mt(this.transports,e[n])&&t.push(e[n]);return t},B.exports=Nt,B.exports.parser=V;var Rt={exports:{}},kt=function(e,t){for(var n=[],o=(t=t||0)||0;o<e.length;o++)n[o-t]=e[o];return n};var Pt=function(e,t,n){return e.on(t,n),{destroy:function(){e.removeListener(t,n)}}};var Ot=[].slice,Dt=function(e,t){if("string"==typeof t&&(t=e[t]),"function"!=typeof t)throw new Error("bind() requires a function");var n=Ot.call(arguments,2);return function(){return t.apply(e,n.concat(Ot.call(arguments)))}};!function(e,t){var n=G,o=U.exports,i=kt,r=Pt,a=Dt,c=(w.exports("socket.io-client:socket"),Ce),u=Y;e.exports=d;var l={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},p=o.prototype.emit;function d(e,t,n){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={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}o(d.prototype),d.prototype.subEvents=function(){if(!this.subs){var e=this.io;this.subs=[r(e,"open",a(this,"onopen")),r(e,"packet",a(this,"onpacket")),r(e,"close",a(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(l.hasOwnProperty(e))return p.apply(this,arguments),this;var t=i(arguments),o={type:(void 0!==this.flags.binary?this.flags.binary:u(t))?n.BINARY_EVENT:n.EVENT,data:t,options:{}};return o.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof t[t.length-1]&&(this.ids,this.acks[this.ids]=t.pop(),o.id=this.ids++),this.connected?this.packet(o):this.sendBuffer.push(o),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"===s(this.query)?c.encode(this.query):this.query;this.packet({type:n.CONNECT,query:e})}else this.packet({type:n.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,o=e.type===n.ERROR&&"/"===e.nsp;if(t||o)switch(e.type){case n.CONNECT:this.onconnect();break;case n.EVENT:case n.BINARY_EVENT:this.onevent(e);break;case n.ACK:case n.BINARY_ACK:this.onack(e);break;case n.DISCONNECT:this.ondisconnect();break;case n.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?p.apply(this,t):this.receiveBuffer.push(t)},d.prototype.ack=function(e){var t=this,o=!1;return function(){if(!o){o=!0;var s=i(arguments);t.packet({type:u(s)?n.BINARY_ACK:n.ACK,id:e,data:s})}}},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++)p.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:n.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}}(Rt);var xt=Ft;function Ft(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}Ft.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)},Ft.prototype.reset=function(){this.attempts=0},Ft.prototype.setMin=function(e){this.ms=e},Ft.prototype.setMax=function(e){this.max=e},Ft.prototype.setJitter=function(e){this.jitter=e};var Gt={},Ut={},Lt={};!function(e){e.__esModule=!0,e.PlatformDetector=e.Platform=void 0;var t,n=f;!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 o=function(){function e(){var e,o,s;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 i=this.methods,r=Object.keys(i);try{for(var a=n.__values(r),c=a.next();!c.done;c=a.next()){var u=c.value;if((0,i[u])()){this.platform=u;break}}}catch(e){o={error:e}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(o)throw o.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&&"undefined"!=typeof document&&!!document.getElementById&&"undefined"==typeof GameGlobal&&"weapp"!==process.env.TARO_ENV},e.prototype.isAppiOS=function(){return"object"===("undefined"==typeof uni?"undefined":s(uni))&&!!uni.getSystemInfoSync&&"ios"===uni.getSystemInfoSync().platform&&"object"===("undefined"==typeof plus?"undefined":s(plus))},e.prototype.isAppAndroid=function(){return"object"===("undefined"==typeof uni?"undefined":s(uni))&&!!uni.getSystemInfoSync&&"android"===uni.getSystemInfoSync().platform&&"object"===("undefined"==typeof plus?"undefined":s(plus))},e.prototype.isWXApplet=function(){return"object"===("undefined"==typeof wx?"undefined":s(wx))&&!!wx.getSystemInfoSync&&"undefined"==typeof WebSocket&&"undefined"==typeof XMLHttpRequest&&"undefined"==typeof plus},e.prototype.isWXGameApplet=function(){return"object"===("undefined"==typeof GameGlobal?"undefined":s(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=o}(Lt),function(t){t.__esModule=!0,t.FrameworkDetector=t.Framework=void 0;var n,o=f,i=Lt;!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"}(n=t.Framework||(t.Framework={}));var r=function(){function t(){var e,t,s;this.framework=null,this.methods=((e={})[n.UNIAPP]=this.isUniApp,e[n.REACT_NATIVE]=this.isReactNative,e[n.TARO]=this.isTaro,e[n.NATIVE_APPLET_WX]=this.isWXApplet,e);var i=this.methods,r=Object.keys(i);try{for(var a=o.__values(r),c=a.next();!c.done;c=a.next()){var u=c.value;if((0,i[u])()){this.framework=u;break}}}catch(e){t={error:e}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(t)throw t.error}}this.framework=this.framework||n.UNKNOWN,this.framework}return t.currentFramework=function(){return this.instance.framework},t.prototype.isUniApp=function(){return"object"===("undefined"==typeof uni?"undefined":s(uni))&&!!uni.getSystemInfoSync},t.prototype.isReactNative=function(){return void 0!==e&&e.__fbGenNativeModule},t.prototype.isTaro=function(){return"undefined"!=typeof process&&void 0!==process.env.TARO_ENV},t.prototype.isWXApplet=function(){return i.PlatformDetector.currentPlatform()===i.Platform.APPLET_WX&&"undefined"==typeof uni},t.instance=new t,t}();t.FrameworkDetector=r}(Ut),Gt.__esModule=!0,Gt.uniApp=void 0;var qt=Ut,Bt=new(function(){function e(){this.uniAppRunningBackend=!1,this.listenAppRunning()}return e.prototype.listenAppRunning=function(){var e=this;qt.FrameworkDetector.currentFramework()===qt.Framework.UNIAPP&&"object"===("undefined"==typeof plus?"undefined":s(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}());Gt.uniApp=Bt;var jt={},Vt={};!function(e){e.__esModule=!0,e.default={maxNumber:5}}(Vt);var Ht={},Wt={__esModule:!0,Cookie:void 0},zt=f,Xt=function(){function e(){}return e.get=function(e){var t,n,o=encodeURIComponent(e)+"=",s=document.cookie.split("; ");try{for(var i=zt.__values(s),r=i.next();!r.done;r=i.next()){var a=r.value;if(a.startsWith(o))return decodeURIComponent(a.substring(o.length))}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return null},e.set=function(e,t,n,o,s,i){void 0===s&&(s="/"),void 0===i&&(i=!1);var r=encodeURIComponent(e)+"="+encodeURIComponent(t);n instanceof Date&&(r+="; expires="+n.toGMTString()),s&&(r+="; path="+s),o&&(r+="; domain="+o),i&&(r+="; secure"),document.cookie=r},e.remove=function(t,n,o,s){void 0===o&&(o="/"),void 0===s&&(s=!1),e.set(t,"",new Date(0),n,o,s)},e}();Wt.Cookie=Xt,Ht.__esModule=!0,Ht.LocalStorageDispatcher=void 0;var Jt=f,Yt=Wt,Qt=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=Yt.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;Yt.Cookie.set(e,JSON.stringify(t),n,o)},e.prototype.remove=function(e){var t=this.domain;Yt.Cookie.remove(e,t)},e.prototype.support=function(){return"undefined"!=typeof navigator&&!0===navigator.cookieEnabled},e}(),Kt=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}(),$t=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"!==("undefined"==typeof uni?"undefined":s(uni))||!uni.getStorageSync)},e}(),Zt=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"!==("undefined"==typeof wx?"undefined":s(wx))||!wx.getStorageSync)},e}(),en=function(){function e(){this.supportedStorage=null;var t=e.storages;t.push(new $t),t.push(new Kt),t.push(new Zt),t.push(new Qt),this.dispatch(),this.supportedStorage}return e.localStorage=function(){return this.instance.supportedStorage},e.prototype.dispatch=function(){var t,n;try{for(var o=Jt.__values(e.storages),s=o.next();!s.done;s=o.next()){var i=s.value;if(i.support()){this.supportedStorage=i;break}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}},e.storages=new Array,e.instance=new e,e}();Ht.LocalStorageDispatcher=en,jt.__esModule=!0,jt.goEasyDomainNumber=void 0;var tn=Vt,nn=Ht,on=function(){function e(){}return e.prototype.refreshNumber=function(){var t=e.GOEASY_DOMAIN_NUMBER,n=nn.LocalStorageDispatcher.localStorage(),o=Math.floor(Math.random()*(tn.default.maxNumber-1)+1);return null!==n&&(o=parseInt(n.get(t))||o),o>0&&o<tn.default.maxNumber?o+=1:o===tn.default.maxNumber&&(o=1),null!==n&&n.put(t,o),o},e.GOEASY_DOMAIN_NUMBER="GOEASY_DOMAIN_NUMBER",e}(),sn=new on;jt.goEasyDomainNumber=sn;var rn=B.exports,an=Rt.exports,cn=U.exports,un=G,ln=Pt,pn=Dt,dn=(w.exports("socket.io-client:manager"),Et),fn=xt,hn=Gt.uniApp,mn=jt.goEasyDomainNumber,yn=Object.prototype.hasOwnProperty,gn=vn;function vn(e,t){if(!(this instanceof vn))return new vn(e,t);e&&"object"===s(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 fn({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 n=t.parser||un;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}function Sn(){var e=!1;return"object"===("undefined"==typeof uni?"undefined":s(uni))&&uni.getSystemInfo&&(e=!0),e&&hn.runningBackend()}vn.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)yn.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},vn.prototype.updateSocketIds=function(){for(var e in this.nsps)yn.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},vn.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},cn(vn.prototype),vn.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},vn.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},vn.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},vn.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},vn.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},vn.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},vn.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},vn.prototype.open=vn.prototype.connect=function(e,t){if(this.readyState,~this.readyState.indexOf("open"))return this;this.uri,this.engine=rn(this.uri,this.opts);var n=this.engine,o=this;this.readyState="opening",this.skipReconnect=!1;var s=ln(n,"open",(function(){o.onopen(),e&&e()})),i=ln(n,"error",(function(t){if("undefined"!=typeof window){var n=parseInt(o.uri.match(/[1-9][0-9]*/g)[0]),s=mn.refreshNumber();o.uri=o.uri.replace(n,s)}if(o.cleanup(),o.readyState="closed",o.emitAll("connect_error",t),e){var i=new Error("Connection error");i.data=t,e(i)}else o.maybeReconnectOnOpen()}));if(!1!==this._timeout){var r=this._timeout,a=setTimeout((function(){s.destroy(),n.close(),n.emit("error","timeout"),o.emitAll("connect_timeout",r)}),r);this.subs.push({destroy:function(){clearTimeout(a)}})}return this.subs.push(s),this.subs.push(i),this},vn.prototype.onopen=function(){this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(ln(e,"data",pn(this,"ondata"))),this.subs.push(ln(e,"ping",pn(this,"onping"))),this.subs.push(ln(e,"pong",pn(this,"onpong"))),this.subs.push(ln(e,"error",pn(this,"onerror"))),this.subs.push(ln(e,"close",pn(this,"onclose"))),this.subs.push(ln(this.decoder,"decoded",pn(this,"ondecoded")))},vn.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},vn.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},vn.prototype.ondata=function(e){this.decoder.add(e)},vn.prototype.ondecoded=function(e){this.emit("packet",e)},vn.prototype.onerror=function(e){this.emitAll("error",e)},vn.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new an(this,e,t),this.nsps[e]=n;var o=this;n.on("connecting",s),n.on("connect",(function(){n.id=o.generateId(e)})),this.autoConnect&&s()}function s(){~dn(o.connecting,n)||o.connecting.push(n)}return n},vn.prototype.destroy=function(e){var t=dn(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},vn.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(n){for(var o=0;o<n.length;o++)t.engine.write(n[o],e.options);t.encoding=!1,t.processPacketQueue()})))},vn.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},vn.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()},vn.prototype.close=vn.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()},vn.prototype.onclose=function(e){this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",e),this._reconnection&&!this.skipReconnect&&this.reconnect()},vn.prototype.reconnect=function(){if(Sn(),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 n=setTimeout((function(){e.skipReconnect||(e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||(Sn()?(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)}})}},vn.prototype.onreconnect=function(){var e=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",e)},function(e,t){var n=F,o=G,i=gn;w.exports("socket.io-client");e.exports=t=a;var r=t.managers={};function a(e,t){"object"===s(e)&&(t=e,e=void 0),t=t||{};var o,a=n(e),c=a.source,u=a.id,l=a.path,p=r[u]&&l in r[u].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||p?o=i(c,t):(r[u]||(r[u]=i(c,t)),o=r[u]),a.query&&!t.query&&(t.query=a.query),o.socket(a.path,t)}t.protocol=o.protocol,t.connect=a,t.Manager=gn,t.Socket=Rt.exports}(C,C.exports);var En={};!function(e){e.__esModule=!0;var t=new(function(){function e(){}return e.prototype.isDef=function(e){return!this.isUndef(e)},e.prototype.isUndef=function(e){return null==e},e.prototype.isPrimitive=function(e){return"string"==typeof e||"number"==typeof e||"symbol"===s(e)||"boolean"==typeof e},e.prototype.isObject=function(e){return null!==e&&"object"===s(e)},e.prototype.isPlainObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},e.prototype.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},e.prototype.isValidArrayIndex=function(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)},e.prototype.isString=function(e){return"string"==typeof e},e.prototype.isNumber=function(e){return"number"==typeof e},e.prototype.isStringOrNumber=function(e){return this.isString(e)||this.isNumber(e)},e.prototype.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},e.prototype.isEmpty=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))},e.prototype.isNative=function(e){return"function"==typeof e&&/native code/.test(e.toString())},e.prototype.isFunction=function(e){return"function"==typeof e},e.prototype.isBoolean=function(e){return"boolean"==typeof e},e.prototype.isTrue=function(e){return!0===e},e.prototype.isFalse=function(e){return!1===e},e}());e.default=t}(En),function(e){e.__esModule=!0;var t=h,n=g,o=v,s=C.exports,i=En,r=function(){function e(){this.io=s,this.status=t.NetworkStatus.DISCONNECTED,this.permissions=[n.Permission.NONE],this.connectedObservers=[],this.disconnectedObservers=[],this.connectedPromise=null,this.emitter=new o.Emitter(this)}return e.prototype.connect=function(){this.status=t.NetworkStatus.CONNECTING},e.prototype.emit=function(e){this.emitter.emit(e)},e.prototype.doEmit=function(e,t,n){},e.prototype.on=function(e,t){this.io.on(e,t)},e.prototype.disconnect=function(){this.io.disconnect()},e.prototype.getStatus=function(){return this.status},e.prototype.addConnectedObserver=function(e){i.default.isFunction(e)&&this.connectedObservers.push(e)},e.prototype.addDisconnectedObserver=function(e){i.default.isFunction(e)&&this.disconnectedObservers.push(e)},e.prototype.notify=function(e,t){for(var n=0;n<e.length;n++)e[n](t)},e}();e.default=r}(y);var Cn={};!function(e){e.__esModule=!0;var t=f,n=h,o=function(e){function o(t){var n=e.call(this)||this;return n.reconnectingObservers=[],n.addReconnectingObserver(t.onReconnecting),n.addDisconnectedObserver(t.onDisconnected),n}return t.__extends(o,e),o.prototype.connect=function(t){e.prototype.connect.call(this),this.io=this.io.connect(t.uri,t.opts),this.initListener()},o.prototype.doEmit=function(e,t,n){this.io.emit(e,t,n)},o.prototype.initListener=function(){var e=this;this.connectedPromise=new Promise((function(t,o){e.io.on("connect",(function(){e.status=n.NetworkStatus.CONNECTED,e.notify(e.connectedObservers),t()}))})),this.io.on("reconnecting",(function(t){e.status=n.NetworkStatus.CONNECTING,e.notify(e.reconnectingObservers,t)})),this.io.on("disconnect",(function(){e.status=n.NetworkStatus.DISCONNECTED,e.notify(e.disconnectedObservers)})),this.io.on("connect_error",(function(e){}))},o.prototype.addReconnectingObserver=function(e){this.reconnectingObservers.push(e)},o}(y.default);e.default=o}(Cn);var _n={},bn={},Mn={exports:{}},wn="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(wn){var Tn=new Uint8Array(16);Mn.exports=function(){return wn(Tn),Tn}}else{var In=new Array(16);Mn.exports=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),In[t]=e>>>((3&t)<<3)&255;return In}}for(var Nn=[],An=0;An<256;++An)Nn[An]=(An+256).toString(16).substr(1);var Rn,kn,Pn=function(e,t){var n=t||0,o=Nn;return[o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],"-",o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]],o[e[n++]]].join("")},On=Mn.exports,Dn=Pn,xn=0,Fn=0;var Gn=function(e,t,n){var o=t&&n||0,s=t||[],i=(e=e||{}).node||Rn,r=void 0!==e.clockseq?e.clockseq:kn;if(null==i||null==r){var a=On();null==i&&(i=Rn=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==r&&(r=kn=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:Fn+1,l=c-xn+(u-Fn)/1e4;if(l<0&&void 0===e.clockseq&&(r=r+1&16383),(l<0||c>xn)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");xn=c,Fn=u,kn=r;var p=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;s[o++]=p>>>24&255,s[o++]=p>>>16&255,s[o++]=p>>>8&255,s[o++]=255&p;var d=c/4294967296*1e4&268435455;s[o++]=d>>>8&255,s[o++]=255&d,s[o++]=d>>>24&15|16,s[o++]=d>>>16&255,s[o++]=r>>>8|128,s[o++]=255&r;for(var f=0;f<6;++f)s[o+f]=i[f];return t||Dn(s)},Un=Mn.exports,Ln=Pn;var qn=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var s=(e=e||{}).random||(e.rng||Un)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t)for(var i=0;i<16;++i)t[o+i]=s[i];return t||Ln(s)},Bn=Gn,jn=qn,Vn=jn;Vn.v1=Bn,Vn.v4=jn;var Hn=Vn;!function(e){e.__esModule=!0;var t=Hn,n=function(){function e(){}return e.get=function(){return t.v1().replace(/-/g,"")},e}();e.default=n}(bn),function(e){e.__esModule=!0;var t=bn,n=g,o=function(){function e(e){var o=this;this.permission=n.Permission.NONE,this.singleTimeout=0,this.totalTimeout=0,this.startTime=0,this.complete=!1,this.retried=0,this.unique=!1,this.uuid=t.default.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=function(t){o.complete||(o.complete=!0,e.success(t))},this.fail=function(t){o.complete||(o.complete=!0,e.fail(t))}}return e.prototype.start=function(){this.startTime=Date.now()},e.prototype.isTimeout=function(){return this.startTime+this.totalTimeout<Date.now()},e}();e.default=o}(_n);var Wn={},zn={};!function(e){e.__esModule=!0,e.default=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]}}(zn),Wn.__esModule=!0,Wn.MessageObserver=void 0;var Xn=zn,Jn=function(){function e(e){this.callback=Xn.default,this.guidList=[],this.callback=e}return e.prototype.onMessage=function(e,t){if("string"==typeof t&&(t=JSON.parse(t)),t.i){if(this.guidList.findIndex((function(e){return e===t.i}))>-1)return;this.guidList.unshift(t.i),this.guidList.length>300&&this.guidList.pop()}this.callback(t)},e}();Wn.MessageObserver=Jn;var Yn={};!function(e){e.__esModule=!0,e.SocketTimeout=void 0,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"}(e.SocketTimeout||(e.SocketTimeout={}))}(Yn);var Qn={__esModule:!0,AnonymousUserIdRepository:void 0},Kn=En,$n=Ht,Zn=function(){function e(){}return e.get=function(){var t=e.storage;if(null!==t){var n=t.get(e.ANONYMOUS_USER_ID_KEY);if(!Kn.default.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=$n.LocalStorageDispatcher.localStorage(),e.ANONYMOUS_USER_ID_KEY="goeasy-anonymous-user-id",e}();Qn.AnonymousUserIdRepository=Zn;var eo={__esModule:!0,clientInfo:void 0},to=Lt,no=Ut,oo=function(){function e(){this.platform=to.PlatformDetector.currentPlatform(),this.framework=no.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<e.length;n++){var o=e.charCodeAt(n);t+=String.fromCharCode(o+5)}return t},e}(),so=new oo;eo.clientInfo=so;var io={};!function(e){e.__esModule=!0,e.RocketTypes=void 0,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"}(e.RocketTypes||(e.RocketTypes={}))}(io);var ro={__esModule:!0,GNS:void 0},ao=En,co=Ut,uo=Lt,lo=Gt,po=function(){function e(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."))}return e.init=function(t){this.instance=new e(t)},e.prototype.addAssembler=function(e){this.payloadAssemblers.push(e)},e.prototype.assemblePayload=function(e){var t=this.payloadAssemblers.find((function(t){return t.support(e)}));return t?t.assemble(e):e},e.prototype.createLocalNotification=function(e,t,n){lo.uniApp.runningBackend()&&(n.g=1,"undefined"!=typeof plus&&plus.push.createMessage(t,JSON.stringify(n),{title:e}))},e.prototype.askRegId=function(){var e=this,t=null,n=0,o=function o(){return new Promise((function(s,i){e.uniappPlugin.regId((function(e){s(e)}),(function(s){if(!(1e6===s.data.code&&n<=10))return clearTimeout(t),i(s);t=setTimeout((function(){n++,e.regIdPromise=o()}),3500)}))}))}();return o},e.prototype.getRegIdPromise=function(){return this.regIdPromise},e.prototype.supportNotification=function(){var e=uo.PlatformDetector.currentPlatform(),t=co.FrameworkDetector.currentFramework();return this.allowNotification&&t===co.Framework.UNIAPP&&(e===uo.Platform.APP_ANDROID||e===uo.Platform.APP_IOS)},e.prototype.listenPlusClickNotification=function(){var e=this;plus.push.addEventListener("click",(function(t){try{if(t){var n="string"==typeof t.payload?JSON.parse(t.payload):t.payload;if(e.availableIntent(n)){var o=e.assemblePayload(n);plus.push.clear(),e.onClickNotificationCallback(o)}}}catch(e){}}))},e.prototype.availableIntent=function(e){return e&&Object.keys(e).length&&e.g&&1===parseInt(e.g)},e.prototype.getIntentData=function(){var e=this;this.uniappPlugin.getIntentData((function(t){if(e.availableIntent(t)){var n=e.assemblePayload(t),o=uo.PlatformDetector.currentPlatform();plus.push.clear(),o===uo.Platform.APP_ANDROID&&e.uniappPlugin.clearAll(),e.onClickNotificationCallback(n)}}))},e.prototype.listenClick=function(){this.listenPlusClickNotification();var e=uo.PlatformDetector.currentPlatform();this.uniappPlugin&&e===uo.Platform.APP_ANDROID&&this.getIntentData()},e.prototype.onClickNotification=function(e){if(this.supportNotification()){if(!ao.default.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.")},e}();ro.GNS=po;var fo={},ho={__esModule:!0,EmitterEventDriver:void 0},mo=U.exports,yo=function(){function e(){this.emitter=new mo}return e.prototype.on=function(e,t){return this.emitter.on(e,t),this},e.prototype.once=function(e,t){return this.emitter.once(e,t),this},e.prototype.off=function(e,t){return this.emitter.off(e,t),this},e.prototype.fire=function(e,t){return this.emitter.emit(e,t),this},e}();ho.EmitterEventDriver=yo,fo.__esModule=!0,fo.GoEasyEventCenter=void 0;var go=ho,vo=function(){function e(){}return e.initial=function(){this.eventDriver=new go.EmitterEventDriver},e.on=function(e,t){this.eventDriver.on(e,t)},e.off=function(e,t){this.eventDriver.off(e,t)},e.once=function(e,t){this.eventDriver.once(e,t)},e.fire=function(e,t){this.eventDriver.fire(e,t)},e}();fo.GoEasyEventCenter=vo;var So={};!function(e){e.__esModule=!0,e.SOCKET_INTERNAL_EVENTS=void 0,(e.SOCKET_INTERNAL_EVENTS||(e.SOCKET_INTERNAL_EVENTS={})).MANUAL_DISCONNECTED="MANUAL_DISCONNECTED"}(So),function(e){e.__esModule=!0;var t=f,n=Cn,s=_n,i=g,r=h,a=Wn,c=zn,u=En,l=jt,p=Yn,d=o,m=Lt,v=Qn,S=eo,E=io,C=ro,_=fo,b=So,M=function(e){function o(t,o){var s=e.call(this)||this;return s.ioSocket=null,s.sid=null,s.appKey=null,s.anonymous=!1,s.userId=null,s.userData=null,s.otp=null,s.artifactVersion="0.0.0",s.uri=null,s.ioOpts=null,s.allowNotification=!1,s.reconnectingTimes=0,s.messageObservers={},s.connectFailedObservers=[],s.connectingObservers=[],s.expiredReconnectedObservers=[],s.onConnectSuccess=c.default,s.onConnectFailed=c.default,s.onConnectProgress=c.default,s.setUriAndOpts(t),s.extendOptions(o),s.ioSocket=new n.default({onDisconnected:s.onIoDisconnected.bind(s),onReconnecting:s.onIoReconnecting.bind(s)}),s.ioSocket.addConnectedObserver(s.onIoReconnected.bind(s)),s.appKey=t.appkey,s.allowNotification=t.allowNotification,s.modules=t.modules,u.default.isEmpty(o.id)?(s.anonymous=!0,s.userId=v.AnonymousUserIdRepository.get()):s.userId=o.id.toString(),s.artifactVersion=d.default.version,s.addConnectedObserver(s.onConnectSuccess),s.addConnectFailedObserver(s.onConnectFailed),s.addConnectingObserver(s.onConnectProgress),s}return t.__extends(o,e),o.prototype.extendOptions=function(e){if(u.default.isFunction(e.onSuccess)&&(this.onConnectSuccess=e.onSuccess),u.default.isFunction(e.onFailed)&&(this.onConnectFailed=e.onFailed),u.default.isFunction(e.onProgress)&&(this.onConnectProgress=e.onProgress),u.default.isDef(e.data)&&!u.default.isObject(e.data))throw{code:400,content:"TypeError: data requires an object."};if((u.default.isDef(e.data)?String(e.data).length:0)>300){if(u.default.isObject(e)&&u.default.isFunction(e.onFailed))throw{code:400,content:"user.data-length limit 300 byte."}}else this.userData=e.data;if(u.default.isObject(e.wxmpId)){if(u.default.isEmpty(e.wxmpId.appid))throw{code:400,content:"wxmpId.appid is required."};if(u.default.isEmpty(e.wxmpId.openid))throw{code:400,content:"wxmpId.openid is required. requires string."}}else if(u.default.isPrimitive(e.wxmpId))throw{code:400,content:"TypeError: wxmpId requires an object."};u.default.isDef(e.wxmpId)&&(this.wxmpId=e.wxmpId),this.otp=e.otp||null},o.prototype.setUriAndOpts=function(e){var t=!0;if(m.PlatformDetector.currentPlatform()===m.Platform.BROWSER){var n="://"+l.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}},o.prototype.onIoReconnected=function(){this.status===r.NetworkStatus.RECONNECTING&&this.authorize()},o.prototype.emit=function(t){e.prototype.emit.call(this,t)},o.prototype.doEmit=function(e,t,n){t.sid=this.sid,this.ioSocket.doEmit(e,t,n)},o.prototype.sendAck=function(e,t){this.ioSocket.io.emit(e,t)},o.prototype.connect=function(){e.prototype.connect.call(this),this.onConnecting(),this.ioSocket.connect({uri:this.uri,opts:this.ioOpts}),this.authorize()},o.prototype.disconnect=function(){var e=this;return new Promise((function(t,n){var o=function(){e.status=r.NetworkStatus.DISCONNECTED,e.ioSocket.disconnect(),_.GoEasyEventCenter.fire(b.SOCKET_INTERNAL_EVENTS.MANUAL_DISCONNECTED),t()};if(e.allowNotification){var a=new s.default({name:E.RocketTypes.manualDisconnect,params:{},permission:i.Permission.READ,singleTimeout:p.SocketTimeout.commonRequestSingle,totalTimeout:p.SocketTimeout.commonRequestTotal,fail:function(e){n(e)},success:o});e.emit(a)}else o()}))},o.prototype.initRegId=function(){return t.__awaiter(this,void 0,void 0,(function(){var e,n,o;return t.__generator(this,(function(t){switch(t.label){case 0:if(!((e=C.GNS.instance)&&e.supportNotification()&&e.getRegIdPromise()))return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),n=this,[4,e.getRegIdPromise()];case 2:return n.regId=t.sent(),this.regId,[3,4];case 3:return o=t.sent(),console.warn("Failed to register the Manufacturers Push service:"+JSON.stringify(o)),[3,4];case 4:return[2]}}))}))},o.prototype.authorize=function(){var e=this;this.connectedPromise=new Promise((function(t,n){e.initRegId().then((function(){var o={appkey:e.appKey,userId:e.userId,userData:JSON.stringify(e.userData),otp:e.otp,artifactVersion:e.artifactVersion,sid:e.sid,allowNT:e.allowNotification,regId:e.regId,wxmpId:e.wxmpId,modules:e.modules,a:e.anonymous,z:S.clientInfo.z};JSON.stringify(o);var r=new s.default({name:E.RocketTypes.authorize,params:o,permission:i.Permission.NONE,singleTimeout:p.SocketTimeout.commonInfiniteSingle,totalTimeout:p.SocketTimeout.commonInfiniteTotal,success:function(n){e.onAuthorizeSuccess(n),t(n)},fail:function(t){e.onAuthorizeFailed(t),n(t)}});e.ioSocket.emit(r)}))}))},o.prototype.onConnecting=function(){this.notify(this.connectingObservers,this.reconnectingTimes)},o.prototype.onIoReconnecting=function(){this.reconnectingTimes++,this.status==r.NetworkStatus.CONNECTED||this.status==r.NetworkStatus.EXPIRED_RECONNECTED||this.status==r.NetworkStatus.RECONNECTING?this.status=r.NetworkStatus.RECONNECTING:this.status=r.NetworkStatus.CONNECTING,this.onConnecting()},o.prototype.onIoDisconnected=function(){this.status==r.NetworkStatus.DISCONNECTING&&(this.status=r.NetworkStatus.DISCONNECTED,this.notify(this.disconnectedObservers)),this.notify(this.disconnectedObservers)},o.prototype.onAuthorizeSuccess=function(e){(!0===this.anonymous&&e.u&&(v.AnonymousUserIdRepository.put(e.u),this.userId=e.u),this.status===r.NetworkStatus.RECONNECTING)?this.sid!==e.sid?(this.status=r.NetworkStatus.EXPIRED_RECONNECTED,this.notify(this.expiredReconnectedObservers)):this.status=r.NetworkStatus.RECONNECTED:(this.status=r.NetworkStatus.CONNECTED,this.sid=e.sid);e.enablePublish&&(this.permissions.find((function(e){return e==i.Permission.WRITE}))||this.permissions.push(i.Permission.WRITE)),e.enableSubscribe&&(this.permissions.find((function(e){return e==i.Permission.READ}))||this.permissions.push(i.Permission.READ)),this.reconnectingTimes=0,this.notify(this.connectedObservers)},o.prototype.onAuthorizeFailed=function(e){this.ioSocket.disconnect(),this.status=r.NetworkStatus.CONNECT_FAILED;var t={code:e.resultCode||408,content:e.content||"Host unreachable or timeout"};this.notify(this.connectFailedObservers,t)},o.prototype.addConnectingObserver=function(e){u.default.isFunction(e)&&this.connectingObservers.push(e)},o.prototype.addConnectFailedObserver=function(e){u.default.isFunction(e)&&this.connectFailedObservers.push(e)},o.prototype.addExpiredReconnectedObserver=function(e){u.default.isFunction(e)&&this.expiredReconnectedObservers.push(e)},o.prototype.addMessageObserver=function(e,t){var n=this;this.messageObservers[e]||(this.messageObservers[e]=[],this.ioSocket.io.on(e,(function(t){n.notifyMessageObservers(e,t)}))),this.messageObservers[e].push(new a.MessageObserver(t))},o.prototype.notifyMessageObservers=function(e,t){for(var n=this.messageObservers[e],o=0;o<n.length;o++)n[o].onMessage(e,t)},o}(y.default);e.default=M}(m);var Eo={__esModule:!0,ModuleTypes:void 0};Eo.ModuleTypes={IM:"IM",PUBSUB:"PUBSUB"};var Co={},_o={},bo={};!function(e){e.__esModule=!0;var t=En,n=function(){function e(){}return e.prototype.validateId=function(e,n){if(t.default.isEmpty(e))throw{code:400,content:" ".concat(n," is required.")};if(!t.default.isStringOrNumber(e))throw{code:400,content:"TypeError: ".concat(n," require string or number.")}},e.prototype.validateIdArray=function(e,n){if(!Array.isArray(e)||0===e.length)throw{code:400,content:"TypeError: ".concat(n," require array.")};if(e.length>300)throw{code:400,content:"".concat(n," is over max length 500.")};for(var o=0;o<e.length;o++){if(!t.default.isStringOrNumber(e[o]))throw{code:400,content:"TypeError: ".concat(n," item require string or number.")};if(t.default.isNumber(e[o])&&(e[o]=e[o].toString()),0==e[o].length)throw{code:400,content:"".concat(n," has empty item.")}}if(Array.from(new Set(e)).length<e.length)throw{code:400,content:"Duplicate element in ".concat(n)}},e.prototype.validateChannel=function(e,t){this.validateId(e,t)},e.prototype.validateChannelArray=function(e,t){this.validateIdArray(e,t)},e.prototype.validateChannelAndChannels=function(e,n){var o=!t.default.isEmpty(e),s=!t.default.isEmpty(n);if(!o&&!s)throw{code:400,content:"channel is required."};if(o&&s)throw{code:400,content:"subscribe to either channel or channels, not both."};o&&this.validateId(e,"channel"),s&&this.validateIdArray(n,"channels")},e.prototype.validateCallbackOptions=function(e){if(!t.default.isObject(e))throw{code:400,content:"bad parameters"}},e.prototype.validateNotification=function(e){if(t.default.isObject(e)){if(t.default.isEmpty(e.title))throw{code:400,content:"notification.title is required."};if(!t.default.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(t.default.isEmpty(e.body))throw{code:400,content:"notification.body is required."};if(!t.default.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(t.default.isPrimitive(e))throw{code:400,content:"TypeError: notification requires an object."}},e.prototype.validateValIsEmpty=function(e,n){if(t.default.isUndef(e)||t.default.isEmpty(e))throw{code:400,content:"".concat(n," is empty")}},e.prototype.validateWXMPTemplateMsg=function(e){if(t.default.isObject(e)){if(!t.default.isString(e.template_id))throw{code:400,content:"template_id must be string."};if(!t.default.isEmpty(e.url)&&!t.default.isString(e.url))throw{code:400,content:"url must be string"};if(!(t.default.isEmpty(e.miniprogram)||t.default.isString(e.miniprogram.appid)&&t.default.isString(e.miniprogram.pagepath)))throw{code:400,content:"miniprogram.appid and miniprogram.pagepath must be strings."};if(!t.default.isObject(e.data))throw{code:400,content:"data requires an object."}}else if(t.default.isPrimitive(e))throw{code:400,content:"wxmpTemplateMsg must be an object."}},e}(),o=new n;e.default=o}(bo);var Mo={__esModule:!0,G:void 0},wo=function(){function e(){}return e.i=function(e){this.socket=e},e.s=function(){if(this.socket)return this.socket;throw new Error("Please connect first.")},e.u=function(){return this.s().userId},e.ud=function(){return this.s().userData},e}();Mo.G=wo;var To={};!function(e){e.__esModule=!0,e.default=function e(t){if(null===t||"object"!==s(t)||"isActiveClone"in t)return t;var n=t instanceof Array?[]:{};for(var o in t)"object"===s(t[o])?n[o]=e(t[o]):n[o]=t[o];return n}}(To),function(e){e.__esModule=!0;var t=zn,n=En,o=bn,s=_n,i=g,r=Yn,a=io,c=bo,u=Mo,l=To,p=function(){function e(){}return e.prototype.publish=function(e){n.default.isFunction(e.onFailed)||(e.onFailed=t.default),n.default.isFunction(e.onSuccess)||(e.onSuccess=t.default),this.validate(e),e.channel=e.channel.toString();var c={channel:e.channel,content:e.message,nt:e.notification,at:e.accessToken,guid:o.default.get()};e.wxmpTemplateMsg&&(c.wxmpTemplateMsg=(0,l.default)(e.wxmpTemplateMsg),c.wxmpTemplateMsg.data=JSON.stringify(c.wxmpTemplateMsg.data));var p=new s.default({name:a.RocketTypes.publish,params:c,unique:!0,singleTimeout:r.SocketTimeout.commonRequestSingle,totalTimeout:r.SocketTimeout.commonRequestTotal,permission:i.Permission.WRITE,success:function(t){e.onSuccess({code:200,content:"ok"})},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});u.G.s().emit(p)},e.prototype.validate=function(e){if(c.default.validateChannel(e.channel,"channel"),n.default.isEmpty(e.message))throw{code:400,content:"message is required."};if(!n.default.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&&c.default.validateWXMPTemplateMsg(e.wxmpTemplateMsg),e.notification&&c.default.validateNotification(e.notification)},e}();e.default=p}(_o);var Io={},No={__esModule:!0,Subscription:void 0},Ao=function(){function e(e){this.channels=e.channels,this.accessToken=e.accessToken,this.onSuccess=e.onSuccess,this.onFailed=e.onFailed,this.onMessage=e.onMessage}return e.prototype.empty=function(){},e}();No.Subscription=Ao;var Ro={};!function(e){e.__esModule=!0,e.RemoteEvents=void 0,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"}(e.RemoteEvents||(e.RemoteEvents={}))}(Ro),Io.__esModule=!0,Io.Subscriber=void 0;var ko=zn,Po=En,Oo=_n,Do=g,xo=No,Fo=Yn,Go=io,Uo=Ro,Lo=bo,qo=ro,Bo=Mo,jo=function(){function e(){this.subscriptions=[],qo.GNS.instance.addAssembler(new(function(){function e(){}return e.prototype.assemble=function(e){return{channel:e.ch,content:e.ctt}},e.prototype.support=function(e){return!!e.ch},e}()))}return e.prototype.initialGoEasySocket=function(){Bo.G.s().addMessageObserver(Uo.RemoteEvents.message,this.onNewMessage.bind(this)),Bo.G.s().addExpiredReconnectedObserver(this.onExpiredReconnected.bind(this))},e.prototype.resubscribe=function(){var e=this.subscriptions.slice(0);this.subscriptions=[];for(var t=0;t<e.length;t++)0!=e[t].channels.length&&this.subscribe(e[t])},e.prototype.clearSubscriptions=function(){this.subscriptions=[]},e.prototype.onExpiredReconnected=function(){this.resubscribe()},e.prototype.onNewMessage=function(e){if(!(e.n.indexOf("_presence")>-1)){e.a&&Bo.G.s().sendAck("ack",{publishGuid:e.i});var t={time:e.t,channel:e.n,content:e.c};this.createNotification(e),this.findSubscriptionByChannel(t.channel).onMessage(t)}},e.prototype.createNotification=function(e){var t=qo.GNS.instance.supportNotification();if(Po.default.isObject(e.nt)&&t){var n={ch:e.n,ctt:e.c};qo.GNS.instance.createLocalNotification(e.nt.t,e.nt.c,n)}},e.prototype.formatOptions=function(e){this.formatCallback(e),Po.default.isFunction(e.onMessage)||(e.onMessage=ko.default),e.channel&&(e.channel=e.channel.toString(),e.channels=[e.channel]),e.channels&&(e.channels=e.channels.toString().split(","))},e.prototype.formatCallback=function(e){Po.default.isFunction(e.onSuccess)||(e.onSuccess=ko.default),Po.default.isFunction(e.onFailed)||(e.onFailed=ko.default)},e.prototype.subscribe=function(e){var t=this;Lo.default.validateChannelAndChannels(e.channel,e.channels),this.formatOptions(e);var n=new Oo.default({name:Go.RocketTypes.subscribe,permission:Do.Permission.READ,singleTimeout:Fo.SocketTimeout.commonInfiniteSingle,totalTimeout:Fo.SocketTimeout.commonInfiniteTotal,params:{channels:e.channels,accessToken:e.accessToken},success:function(){var n=new xo.Subscription({channels:e.channels,accessToken:e.accessToken,onSuccess:e.onSuccess,onFailed:e.onFailed,onMessage:e.onMessage});t.subscriptions.push(n),e.onSuccess({code:200,content:"ok"})},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});Bo.G.s().emit(n)},e.prototype.unsubscribe=function(e){var t=this;if(Lo.default.validateChannel(e.channel,"channel"),e.channel=e.channel.toString(),this.findSubscriptionByChannel(e.channel)){var n=new Oo.default({name:Go.RocketTypes.unsubscribe,params:{channel:e.channel},permission:Do.Permission.READ,singleTimeout:Fo.SocketTimeout.commonRequestSingle,totalTimeout:Fo.SocketTimeout.commonRequestTotal,success:function(){e.onSuccess({code:200,content:"ok"}),t.removeChannel(e.channel)},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});Bo.G.s().emit(n)}else e.onFailed({code:400,content:"channel["+e.channel+"] is not subscribed"})},e.prototype.removeChannel=function(e){for(var t=0;t<this.subscriptions.length;t++)for(var n=this.subscriptions[t].channels,o=0;o<n.length;o++)if(n[o]==e){this.subscriptions[t].channels.splice(o,1);break}},e.prototype.findSubscriptionByChannel=function(e){for(var t=!1,n=null,o=this.subscriptions.length-1;o>=0;o--){for(var s=this.subscriptions[o].channels,i=0;i<s.length;i++)if(s[i]==e){t=!0,n=this.subscriptions[o];break}if(t)break}return n},e}();Io.Subscriber=jo;var Vo={__esModule:!0,History:void 0},Ho=zn,Wo=En,zo=_n,Xo=g,Jo=Yn,Yo=io,Qo=bo,Ko=Mo,$o=function(){function e(){}return e.prototype.get=function(e){Wo.default.isFunction(e.onSuccess)||(e.onSuccess=Ho.default),Wo.default.isFunction(e.onFailed)||(e.onFailed=Ho.default),Qo.default.validateChannel(e.channel,"channel"),e.channel=e.channel.toString();var t=new zo.default({name:Yo.RocketTypes.historyMessages,permission:Xo.Permission.READ,params:e,singleTimeout:Jo.SocketTimeout.commonQuerySingle,totalTimeout:Jo.SocketTimeout.commonQueryTotal,success:function(t){e.onSuccess({code:t.resultCode||t.code||200,content:t.content})},fail:function(t){e.onFailed({code:t.resultCode||t.code,content:t.content})}});Ko.G.s().emit(t)},e}();Vo.History=$o;var Zo={},es={__esModule:!0,PresenceSubscription:void 0},ts=function(e){this.channels=e.channels,this.onSuccess=e.onSuccess,this.onFailed=e.onFailed,this.onPresence=e.onPresence};es.PresenceSubscription=ts,Zo.__esModule=!0,Zo.PresenceSubscriber=void 0;var ns=zn,os=En,ss=_n,is=g,rs=Yn,as=es,cs=io,us=Ro,ls=bo,ps=Mo,ds=function(){function e(){this.presenters=[]}return e.prototype.initialGoEasySocket=function(){ps.G.s().addMessageObserver(us.RemoteEvents.message,this.onNewMessage.bind(this)),ps.G.s().addExpiredReconnectedObserver(this.onExpiredReconnected.bind(this))},e.prototype.resubscribe=function(){var e=this.presenters.slice(0);this.presenters=[];for(var t=0;t<e.length;t++){for(var n=0;n<e[t].channels.length;n++){var o=e[t].channels[n].split("_presence");e[t].channels[n]=o[0]}0!=e[t].channels.length&&this.subscribePresence(e[t])}},e.prototype.onExpiredReconnected=function(){this.resubscribe()},e.prototype.onNewMessage=function(e){if(-1!=e.n.indexOf("_presence")){var t=this.findPresenceByChannel(e.n);if(t){var n=JSON.parse(e.c);n.events=n.events.map((function(e){var t=e.userData?JSON.parse(e.userData):{};return{time:e.time,action:e.action,id:e.userId,data:t}})),t.onPresence(n)}}},e.prototype.formatOptions=function(e){this.formatCallback(e),os.default.isFunction(e.onPresence)||(e.onPresence=ns.default),e.channel&&(e.channel=e.channel.toString(),e.channels=[e.channel]),e.channels&&(e.channels=e.channels.toString().split(","))},e.prototype.formatCallback=function(e){os.default.isFunction(e.onSuccess)||(e.onSuccess=ns.default),os.default.isFunction(e.onFailed)||(e.onFailed=ns.default)},e.prototype.subscribePresence=function(e){var t=this;ls.default.validateChannelAndChannels(e.channel,e.channels),this.formatOptions(e),Array.isArray(e.channels)&&(e.channels=e.channels.map((function(e){return e+="_presence"})));var n=new ss.default({name:cs.RocketTypes.subscribe,permission:is.Permission.READ,singleTimeout:rs.SocketTimeout.commonInfiniteSingle,totalTimeout:rs.SocketTimeout.commonInfiniteTotal,params:{channels:e.channels},success:function(){var n=new as.PresenceSubscription({channels:e.channels,onSuccess:e.onSuccess,onFailed:e.onFailed,onPresence:e.onPresence});t.presenters.push(n),e.onSuccess({code:200,content:"ok"})},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});ps.G.s().emit(n)},e.prototype.unsubscribePresence=function(e){var t=this;if(this.formatCallback(e),os.default.isDef(e.channel))if(e.channel+="_presence",this.findPresenceByChannel(e.channel)){var n=new ss.default({name:cs.RocketTypes.unsubscribe,params:{channel:e.channel},permission:is.Permission.READ,singleTimeout:rs.SocketTimeout.commonRequestSingle,totalTimeout:rs.SocketTimeout.commonRequestTotal,success:function(){e.onSuccess({code:200,content:"ok"}),t.removeChannel(e.channel)},fail:function(t){e.onFailed({code:t.resultCode,content:t.content})}});ps.G.s().emit(n)}else e.onFailed({code:400,content:"channel["+e.channel+"] is not subscribed"});else e.onFailed({code:400,content:"channel is required"})},e.prototype.removeChannel=function(e){for(var t=0;t<this.presenters.length;t++)for(var n=this.presenters[t].channels,o=0;o<n.length;o++)if(n[o]==e){this.presenters[t].channels.splice(o,1);break}},e.prototype.findPresenceByChannel=function(e){for(var t=!1,n=null,o=this.presenters.length-1;o>=0;o--){for(var s=this.presenters[o].channels,i=0;i<s.length;i++)if(s[i]==e){t=!0,n=this.presenters[o];break}if(t)break}return n},e}();Zo.PresenceSubscriber=ds;var fs={__esModule:!0,HereNow:void 0},hs=zn,ms=En,ys=_n,gs=g,vs=Yn,Ss=io,Es=bo,Cs=Mo,_s=function(){function e(){}return e.prototype.byChannel=function(e){var t={channels:[],includeUsers:!1,distinct:!1};ms.default.isFunction(e.onSuccess)||(e.onSuccess=hs.default),ms.default.isFunction(e.onFailed)||(e.onFailed=hs.default),Es.default.validateChannelArray(e.channels,"channels"),t.channels=e.channels.toString().split(","),t.includeUsers=e.includeUsers||!1,t.distinct=e.distinct||!1;var n=new ys.default({name:Ss.RocketTypes.hereNow,permission:gs.Permission.READ,params:t,singleTimeout:vs.SocketTimeout.commonQuerySingle,totalTimeout:vs.SocketTimeout.commonQueryTotal,success:function(t){var n=t.content,o=n.channels;for(var s in o)if(o.hasOwnProperty(s)){var i=o[s];i.users&&(i.users=i.users.map((function(e){return e.data=e.data?JSON.parse(e.data):{},e})))}e.onSuccess({code:t.resultCode||t.code||200,content:n})},fail:function(t){e.onFailed({code:t.resultCode||t.code||200,content:t.content})}});Cs.G.s().emit(n)},e.prototype.byUserId=function(e){var t={userIds:[],distinct:!0};ms.default.isFunction(e.onSuccess)||(e.onSuccess=hs.default),ms.default.isFunction(e.onFailed)||(e.onFailed=hs.default),Es.default.validateIdArray(e.userIds,"userIds"),t.userIds=e.userIds.toString().split(","),0==e.distinct&&(t.distinct=!1);var n=new ys.default({name:Ss.RocketTypes.hereNowByUserIds,permission:gs.Permission.READ,params:t,singleTimeout:vs.SocketTimeout.commonQuerySingle,totalTimeout:vs.SocketTimeout.commonQueryTotal,success:function(t){var n=t.content;n=n.map((function(e){return{id:e.userId,data:e.userData?JSON.parse(e.userData):{}}})),e.onSuccess({code:t.resultCode||t.code||200,content:n})},fail:function(t){e.onFailed({code:t.resultCode||t.code||200,content:t.content})}});Cs.G.s().emit(n)},e}();fs.HereNow=_s;var bs={__esModule:!0,CallbackUtils:void 0},Ms=En,ws=function(){function e(){}return e.onSuccess=function(e,t){Ms.default.isFunction(e.onSuccess)&&e.onSuccess(t)},e.onFailed=function(e,t){if(!Ms.default.isObject(e)||!Ms.default.isFunction(e.onFailed))throw t;e.onFailed(t)},e}();bs.CallbackUtils=ws,Co.__esModule=!0,Co.PubSub=void 0;var Ts=_o,Is=Io,Ns=Vo,As=Zo,Rs=fs,ks=bs,Ps=h,Os=Eo,Ds=Mo,xs=function(){function e(e){this.subscriber=new Is.Subscriber,this.options=e}return e.init=function(t){e.instance=new e(t)},e.prototype.initialGoEasySocket=function(){this.publisher=new Ts.default,this.histories=new Ns.History,this.presence=new As.PresenceSubscriber,this.hereNows=new Rs.HereNow,this.subscriber.initialGoEasySocket(),this.presence.initialGoEasySocket()},e.prototype.initialBeforeConnect=function(){this.subscriber.clearSubscriptions()},e.prototype.catch=function(e,t){try{this.validateOptions(),e()}catch(e){ks.CallbackUtils.onFailed(t,e)}},e.prototype.validateOptions=function(){if(!Ds.G.s()||Ds.G.s().getStatus()!==Ps.NetworkStatus.CONNECTED)throw Error("Please call connect() first.");if(!this.options.modules||!this.options.modules.includes(Os.ModuleTypes.PUBSUB))throw{code:400,content:"Invalid options: module '".concat(Os.ModuleTypes.PUBSUB,"' is not enabled")}},e.prototype.publish=function(e){var t=this;this.catch((function(){t.publisher.publish(e)}),e)},e.prototype.subscribe=function(e){var t=this;this.catch((function(){t.subscriber.subscribe(e)}),e)},e.prototype.unsubscribe=function(e){var t=this;this.catch((function(){t.subscriber.unsubscribe(e)}),e)},e.prototype.subscribePresence=function(e){var t=this;this.catch((function(){t.presence.subscribePresence(e)}),e)},e.prototype.unsubscribePresence=function(e){var t=this;this.catch((function(){t.presence.unsubscribePresence(e)}),e)},e.prototype.history=function(e){var t=this;this.catch((function(){t.histories.get(e)}),e)},e.prototype.hereNow=function(e){var t=this;this.catch((function(){t.hereNows.byChannel(e)}),e)},e.prototype.hereNowByUserIds=function(e){var t=this;this.catch((function(){t.hereNows.byUserId(e)}),e)},e}();Co.PubSub=xs;var Fs={},Gs={},Us={};!function(e){var t;e.__esModule=!0,e.ImApiEvents=void 0,(t=e.ImApiEvents||(e.ImApiEvents={})).PRIVATE_MESSAGE_RECEIVED="PRIVATE_MESSAGE_RECEIVED",t.GROUP_MESSAGE_RECEIVED="GROUP_MESSAGE_RECEIVED",t.SYSTEM_MESSAGE_RECEIVED="SYSTEM_MESSAGE_RECEIVED",t.CONVERSATIONS_UPDATED="CONVERSATIONS_UPDATED",t.USER_PRESENCE="USER_PRESENCE",t.GROUP_PRESENCE="GROUP_PRESENCE",t.MESSAGE_DELETED="MESSAGE_DELETED",t.MESSAGE_READ="MESSAGE_READ",t.MESSAGE_RECALLED="MESSAGE_RECALLED",t.CS_MESSAGE_RECEIVED="CS_MESSAGE_RECEIVED",t.PENDING_CONVERSATIONS_UPDATED="PENDING_CONVERSATIONS_UPDATED"}(Us);var Ls={};!function(e){var t;e.__esModule=!0,e.RTCApiEvents=void 0,(t=e.RTCApiEvents||(e.RTCApiEvents={})).RING="RING",t.USER_ACCEPTED="USER_ACCEPTED",t.CALL_ENDED="CALL_ENDED",t.USER_QUITED="USER_QUITED"}(Ls),Gs.__esModule=!0,Gs.ApiEventCenter=void 0;var qs=Us,Bs=Ls,js=U.exports,Vs=En,Hs=function(){function e(){this.emitter=new js}return e.prototype.on=function(e,t){if(!Vs.default.isString(e))throw Error("event require a string.");if(!Vs.default.isDef(qs.ImApiEvents[e])&&!Vs.default.isDef(Bs.RTCApiEvents[e]))throw Error("An event that is not defined");if(!Vs.default.isFunction(t))throw Error("callback must be a function");this.emitter.on(e,t)},e.prototype.fire=function(e,t){this.emitter.emit(e,t)},e.prototype.off=function(e,t){this.emitter.off(e,t)},e}();Gs.ApiEventCenter=Hs;var Ws={},zs={},Xs={},Js={};!function(e){e.__esModule=!0;var t=function(){function e(){}return e.prototype.upload=function(e,t){throw Error("Not implementation yet.")},e}();e.default=t}(Js),Xs.__esModule=!0,Xs.uniAppFileUploader=void 0;var Ys=f,Qs=new(function(e){function t(){return e.call(this)||this}return Ys.__extends(t,e),t.prototype.upload=function(e,t){var n=this;try{return delete e.parameters.fileRes,new Promise((function(o,s){uni.uploadFile({url:e.host,filePath:n.getTempFilePath(e),name:"file",formData:e.parameters,success:function(t){if(200===t.statusCode){var n=e.payload;n.message=t.errMsg,o({code:200,content:n})}else s({code:t.statusCode,content:t.errMsg})},fail:function(e){s({code:500,content:e.errMsg})}}).onProgressUpdate((function(e){t&&t(e)}))}))}catch(e){return new Promise((function(t,n){n({code:500,content:e})}))}},t.prototype.getTempFilePath=function(e){var t=e.file;return t.tempFilePath||t.fullPath||t.path},t}(Js.default));Xs.uniAppFileUploader=Qs;var Ks={__esModule:!0,wxFileUploader:void 0},$s=f,Zs=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $s.__extends(t,e),t.prototype.upload=function(e,t){var n=this;try{return new Promise((function(o,s){wx.uploadFile({url:e.host,filePath:n.getTempFilePath(e),name:"file",formData:e.parameters,success:function(t){if(200===t.statusCode){var n=e.payload;n.message=t.errMsg,o({code:200,content:n})}else s({code:t.statusCode,content:t.errMsg})},fail:function(e){s({code:500,content:e.errMsg})}}).onProgressUpdate((function(e){t&&t(e)}))}))}catch(e){return new Promise((function(t,n){n({code:500,content:e})}))}},t.prototype.getTempFilePath=function(e){var t=e.file||e.fileRes;return t.path||t.tempFilePath},t}(Js.default),ei=new Zs;Ks.wxFileUploader=ei;var ti={__esModule:!0,htmlFileUploader:void 0},ni=f,oi=new(function(e){function t(){return e.call(this)||this}return ni.__extends(t,e),t.prototype.upload=function(e,t){try{return new Promise((function(n,o){var s=new XMLHttpRequest;for(var i in s.open("post",e.host,!0),e.headers)s.setRequestHeader(i,e.headers[i]);s.upload.onprogress=function(e){t&&t(e)},s.upload.onloadstart=function(e){t&&t(e)},s.upload.onloadend=function(e){t&&t(e)};var r=new FormData;for(var a in e.parameters)"fileRes"==a?r.append("file",e.parameters[a]):r.append(a,e.parameters[a]);s.send(r),s.onreadystatechange=function(){if(4==s.readyState)if(s.status>=200&&s.status<300||304==s.status){var t=e.payload;t.message=s.responseText,n({code:200,content:t})}else o({code:s.status,content:s.responseText})}}))}catch(e){return new Promise((function(t,n){n({code:500,content:e})}))}},t}(Js.default));ti.htmlFileUploader=oi,zs.__esModule=!0,zs.fileUploader=zs.FileUploader=void 0;var si=Xs,ii=Ks,ri=ti,ai=Ut,ci=Lt,ui=function(){function e(){var e;this.uploader=((e={})[ai.Framework.UNIAPP]=si.uniAppFileUploader,e[ai.Framework.NATIVE_APPLET_WX]=ii.wxFileUploader,e[ai.Framework.TARO]=ci.Platform.APPLET_WX?ii.wxFileUploader:ri.htmlFileUploader,e[ai.Framework.UNKNOWN]=ri.htmlFileUploader,e)}return e.prototype.upload=function(e,t){var n=ai.FrameworkDetector.currentFramework();return this.uploader[n].upload(e,t)},e}();zs.FileUploader=ui;var li=new ui;zs.fileUploader=li;var pi={},di={},fi={};!function(e){e.__esModule=!0,e.OssType=void 0,function(e){e.aliYun="ALI",e.qiNiu="QN",e.tencent="TX"}(e.OssType||(e.OssType={}))}(fi);var hi={},mi={};!function(e){e.__esModule=!0;var t=function(e,t,n,o,s){this.host=e,this.headers=t,this.parameters=n,this.file=o,this.payload=s};e.default=t}(mi);var yi={};!function(e){e.__esModule=!0;var t=function(){function e(){}return e.prototype.build=function(e,t,n){},e.prototype.newFileName=function(e){return e&&e.newFilename||""},e}();e.default=t}(yi);var gi={};!function(e){e.__esModule=!0,e.MessageType=void 0,function(e){e.TEXT="text",e.IMAGE="image",e.FILE="file",e.VIDEO="video",e.AUDIO="audio"}(e.MessageType||(e.MessageType={}))}(gi),hi.__esModule=!0,hi.aliYunOSSRequestBuilder=hi.AliYunOSSRequestBuilder=void 0;var vi=f,Si=mi,Ei=gi,Ci=function(e){function t(){return e.call(this)||this}return vi.__extends(t,e),t.prototype.url=function(e){return e.host+"/"+e.dir+"/"+this.newFileName(e)},t.prototype.build=function(e,t,n){var o;o={key:e.dir+"/"+this.newFileName(e),OSSAccessKeyId:e.accessKeyId,policy:e.policy,signature:e.signature,success_action_status:"200",fileRes:t},Ei.MessageType.FILE===n&&(o={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});var s={newFileName:this.newFileName(e),url:this.url(e)};return new Si.default(e.host,null,o,t,s)},t}(yi.default);hi.AliYunOSSRequestBuilder=Ci;var _i=new Ci;hi.aliYunOSSRequestBuilder=_i;var bi={__esModule:!0,qiNiuYunOSSRequestBuilder:void 0},Mi=f,wi=mi,Ti=new(function(e){function t(){return e.call(this)||this}return Mi.__extends(t,e),t.prototype.url=function(e){return e.downloadUrl},t.prototype.build=function(e,t){var n={key:this.newFileName(e),token:e.token,file:t},o={newFileName:this.newFileName(e),url:this.url(e)};return new wi.default(e.host,null,n,t,o)},t}(yi.default));bi.qiNiuYunOSSRequestBuilder=Ti;var Ii={__esModule:!0};Ii.tencentOSSRequestBuilder=Ii.TencentOSSRequestBuilder=void 0;var Ni=f,Ai=mi,Ri=gi,ki=function(e){function t(){return e.call(this)||this}return Ni.__extends(t,e),t.prototype.url=function(e){return e.host+"/"+e.key},t.prototype.build=function(e,t,n){var o={"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};Ri.MessageType.FILE===n&&(o={"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=".concat(t.name),fileRes:t});var s={newFileName:e.key,url:this.url(e)};return new Ai.default(e.host,null,o,t,s)},t}(yi.default);Ii.TencentOSSRequestBuilder=ki;var Pi=new ki;Ii.tencentOSSRequestBuilder=Pi,di.__esModule=!0,di.OSSRequestFactory=void 0;var Oi=fi,Di=hi,xi=bi,Fi=Ii,Gi=function(){function e(e){return e===Oi.OssType.aliYun?Di.aliYunOSSRequestBuilder:e===Oi.OssType.tencent?Fi.tencentOSSRequestBuilder:xi.qiNiuYunOSSRequestBuilder}return e.prototype.build=function(e,t,n){},e}();di.OSSRequestFactory=Gi;var Ui={};!function(e){e.__esModule=!0;var t=_n,n=g,o=Yn,s=Mo,i=function(){function e(){}return e.prototype.resolve=function(e){return new Promise((function(i,r){var a=new t.default({name:"uploadToken",params:{filename:e},permission:n.Permission.WRITE,singleTimeout:o.SocketTimeout.commonRequestSingle,totalTimeout:o.SocketTimeout.commonRequestTotal,fail:function(e){r(e)},success:function(e){200===e.code?i(e):r(e)}});s.G.s().emit(a)}))},e}();e.default=i}(Ui),function(e){e.__esModule=!0;var t=di,n=Ui,o=function(){function e(){this.uploadTokenResolver=new n.default}return e.prototype.build=function(e,n,o){var s=this;return new Promise((function(i,r){s.uploadTokenResolver.resolve(n).then((function(n){var s=n.content;i(new t.OSSRequestFactory(s.vendor).build(s,e,o))})).catch((function(e){r(e)}))}))},e}();e.default=o}(pi),Ws.__esModule=!0,Ws.GoEasyUploader=void 0;var Li=zs,qi=pi,Bi=function(){function e(){this.requestBuilder=new qi.default,this.fileUploader=Li.fileUploader}return e.prototype.upload=function(e,t,n,o){var s=this;return new Promise((function(i,r){s.requestBuilder.build(e,t,o).then((function(e){i(s.doUpload(e,n))})).catch((function(e){r(e)}))}))},e.prototype.customizeUpload=function(e,t){this.doUpload(e,t)},e.prototype.doUpload=function(e,t){return this.fileUploader.upload(e,t)},e}();Ws.GoEasyUploader=Bi;var ji={},Vi={},Hi={},Wi={__esModule:!0,AbstractPayloadImprover:void 0},zi=function(){};Wi.AbstractPayloadImprover=zi,Hi.__esModule=!0,Hi.FileMessagePayloadImprover=void 0;var Xi=f,Ji=Ws,Yi=gi,Qi=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.goEasyUploader=new Ji.GoEasyUploader,t}return Xi.__extends(t,e),t.prototype.improve=function(e){var t=this,n=e.message;return new Promise((function(e,o){var s,i=n.buildOptions.createOptions;s=n.type===Yi.MessageType.VIDEO?n.payload.video.name:n.payload.name,t.goEasyUploader.upload(i.file,s,i.onProgress,n.type).then((function(o){t.setPayload(o,n),e()})).catch((function(e){o(e)}))}))},t.prototype.setPayload=function(e,t){var n=e.content,o=void 0===n?{}:n;t.payload.url=o.url},t}(Wi.AbstractPayloadImprover);Hi.FileMessagePayloadImprover=Qi;var Ki={__esModule:!0,VideoMessagePayloadImprover:void 0},$i=f,Zi=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $i.__extends(t,e),t.prototype.setPayload=function(e,t){e.content;var n=t.payload,o="?x-oss-process=video/snapshot,t_0000,f_jpg,h_"+n.thumbnail.height+",m_fast,ar_auto";n.video.url=e.content.url,n.thumbnail.url=e.content.url+o,n.video.name=e.content.newFileName},t}(Hi.FileMessagePayloadImprover);Ki.VideoMessagePayloadImprover=Zi,Vi.__esModule=!0,Vi.PayloadImprover=void 0;var er=Hi,tr=Ki,nr=gi,or=function(){function e(){var e;this.improvers=((e={})[nr.MessageType.FILE]=new er.FileMessagePayloadImprover,e[nr.MessageType.AUDIO]=new er.FileMessagePayloadImprover,e[nr.MessageType.IMAGE]=new er.FileMessagePayloadImprover,e[nr.MessageType.VIDEO]=new tr.VideoMessagePayloadImprover,e)}return e.prototype.improve=function(e){var t=this.improvers[e.message.type];return t?t.improve(e):Promise.resolve()},e}();Vi.PayloadImprover=or;var sr={};!function(e){e.__esModule=!0;var t=gi,n=o,s=To,i=function(){function e(e,t,o,i,r){this.validate(e),this.mt=e.type,this.to=t.id.toString(),this.d=JSON.stringify(t.data),this.p=JSON.stringify(e.payload),o&&(this.nt=o),r&&(this.at=r),i&&(this.wxmpTemplateMsg=(0,s.default)(i),this.wxmpTemplateMsg.data=JSON.stringify(this.wxmpTemplateMsg.data));var a=t.type;if(this.t=a,a===n.Scene.CS){var c=e;this.tid=c.teamId}this.guid=e.messageId}return e.prototype.validate=function(e){if(e.type===t.MessageType.TEXT&&JSON.stringify(e.payload).length>3072)throw Error("message-length limit 3kb")},e}();e.default=i}(sr);var ir={};!function(e){var t;e.__esModule=!0,e.IM_INTERNAL_EVENTS=void 0,(t=e.IM_INTERNAL_EVENTS||(e.IM_INTERNAL_EVENTS={})).MESSAGE_SENDING="IM_INTERNAL_MESSAGE_SENDING",t.MESSAGE_SEND_SUCCESS="IM_INTERNAL_MESSAGE_SEND_SUCCESS",t.MESSAGE_SEND_FAILED="IM_INTERNAL_MESSAGE_SEND_FAILED",t.MESSAGE_RECEIVED="IM_INTERNAL_MESSAGE_RECEIVED",t.MAX_MESSAGE_CHANGED="IM_INTERNAL_MAX_MESSAGE_CHANGED",t.MAX_MESSAGE_DELETED="IM_INTERNAL_MAX_MESSAGE_DELETED",t.UNREAD_AMOUNT_CHANGED="IM_INTERNAL_UNREAD_MESSAGE_CHANGED",t.CS_ONLINE_SUCCESS="CS_ONLINE_SUCCESS",t.CS_OFFLINE_SUCCESS="CS_OFFLINE_SUCCESS",t.CS_ACCEPTED="CS_ACCEPTED",t.CS_ENDED="CS_ENDED",t.CS_TRANSFER="CS_TRANSFER",t.CS_AGENT_MESSAGE_RECEIVED="CS_AGENT_MESSAGE_RECEIVED"}(ir);var rr={__esModule:!0,AbstractMessage:void 0},ar=Mo,cr=function(){function e(){}return e.prototype.clearUseLessAttribute=function(){delete this.buildOptions},e.prototype.isOtherSent=function(){return this.senderId!==ar.G.u()},e.prototype.getToData=function(){return this.buildOptions.createOptions.to.data},e}();rr.AbstractMessage=cr,function(e){e.__esModule=!0;var t=_n,n=g,s=Yn,i=Vi,r=sr,a=fo,c=ir,u=o,l=rr,p=io,d=Mo,f=bs,h=function(){function e(){this.payloadImprover=new i.PayloadImprover}return e.prototype.send=function(e){var t=this;this.validate(e);var n=e.message,o=e.accessToken,s=n.buildOptions,i=s.createOptions,r=i.notification,a=i.wxmpTemplateMsg,c=i.to;c.data||(c.data={}),n.status=u.MessageStatus.SENDING;var l=s.complete,p=this.payloadImprover.improve(e);Promise.all([l,p]).then((function(){t.doSend(n,c,r,a,o,e)})).catch((function(t){n.status=u.MessageStatus.FAIL,f.CallbackUtils.onFailed(e,{code:t.code||400,content:t.content||t})}))},e.prototype.doSend=function(e,o,i,l,h,m){var y=new r.default(e,o,i,l,h);a.GoEasyEventCenter.fire(c.IM_INTERNAL_EVENTS.MESSAGE_SENDING,e);var g=new t.default({name:p.RocketTypes.publishIM,params:y,unique:!0,permission:n.Permission.WRITE,singleTimeout:s.SocketTimeout.commonRequestSingle,totalTimeout:s.SocketTimeout.commonRequestTotal,fail:function(t){e.status=u.MessageStatus.FAIL,a.GoEasyEventCenter.fire(c.IM_INTERNAL_EVENTS.MESSAGE_SEND_FAILED,e),f.CallbackUtils.onFailed(m,{code:t.resultCode,content:t.content})},success:function(t){if(e.status=u.MessageStatus.SUCCESS,e.timestamp=t.content.timestamp,e.scene()===u.Scene.CS){var n=e;n.customerId()!==d.G.u()&&(n.sessionId=t.content.sessionId)}e.clearUseLessAttribute(),a.GoEasyEventCenter.fire(c.IM_INTERNAL_EVENTS.MESSAGE_SEND_SUCCESS,e),f.CallbackUtils.onSuccess(m,e)}});d.G.s().emit(g)},e.prototype.validate=function(e){var t=e.message;if(!(t instanceof l.AbstractMessage))throw new Error("it is invalid message");if(t.status!==u.MessageStatus.NEW)throw new Error("Please create a new message, a message can only be sent once")},e}();e.default=h}(ji);var ur={},lr={},pr={},dr={},fr={},hr={},mr={__esModule:!0,SortedInserter:void 0},yr=function(){function e(){}return e.prototype.insert=function(e,t){var n=this.binarySearch(e,t);if(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 s=o+n>>1,i=this.compare(t,e[s]);if(i>0)n=s+1;else{if(!(i<0))return s;o=s-1}}return-n-1},e}();mr.SortedInserter=yr,function(e){e.__esModule=!0;var t=f,n=o,s=En,i=mr,r=function(){function e(e){this.messages=new Array,this.allLoaded=!1,this.target=e}return e.prototype.all=function(){return this.messages},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.getMaxMessage=function(){return this.messages[this.messages.length-1]},e.prototype.loadLocalMessages=function(e,t){var n=[],o=this.messages.length;if(t){if(o>0){var s=this.messages[0].timestamp,i=this.messages[o-1].timestamp;if(t>=s&&t<=i)for(var r=o-1;r>=0;r--){var a=this.messages[r];if(a.timestamp<t){if(!(n.length<e))break;n.unshift(a)}}}}else n=this.messages.slice(-e);return n},e.prototype.cacheServerMessages=function(t,n){var o=this,s=this.messages[0];this.messages.length<e.CACHE_MAX_LENGTH&&(!t.lastTimestamp||this.messages.length>0&&s.timestamp===t.lastTimestamp)&&(n.forEach((function(t){e.sortedInserter.insert(o.messages,t)})),n.length<t.limit&&(this.allLoaded=!0))},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);s.default.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);s.default.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.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===n.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 n(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(n,e),n.prototype.compare=function(e,t){var n=e.timestamp-t.timestamp;return n>0?1:0===n?0:-1},n}(i.SortedInserter)),e}();e.default=r}(hr);var gr={},vr={},Sr={__esModule:!0,Target:void 0},Er=o,Cr=En,_r=Mo,br=function(){function e(e,t,n){this.scene=e,this.id=t,Cr.default.isDef(n)&&(this.teamId=n)}return e.prototype.toString=function(){return Er.Scene.PRIVATE===this.scene||Er.Scene.GROUP===this.scene?this.scene+"#"+this.id:this.scene+"#"+this.id+"#"+this.teamId},e.prototype.customerId=function(){if(Er.Scene.CS===this.scene)return this.id===this.teamId?_r.G.u():this.id},e.byScene=function(t,n,o){return new e(t,n,o)},e.byIMMessage=function(t){var n,o,s=t.scene();if(s===Er.Scene.PRIVATE){var i=t.senderId,r=t.targetId();o=_r.G.u()===i?r:i}else if(s===Er.Scene.GROUP)o=t.targetId();else{if(s!==Er.Scene.CS)throw{code:400,content:"scene ".concat(s," not exists")};o=t.targetId(),n=t.teamId}return new e(s,o,n)},e.byMessageReadRemoteEvent=function(t){var n,o=t.scene,s=t.targetId,i=t.markerId,r=t.teamId;return o===Er.Scene.PRIVATE?n=_r.G.u()===i?s:i:o===Er.Scene.GROUP?n=s:o===Er.Scene.CS&&(n=s===r?i===_r.G.u()?r:i:i===_r.G.u()?s:r),new e(o,n,r)},e.byIMMessageDeletedEvent=function(t){var n=t.scene,o=t.deleterId;return n===Er.Scene.PRIVATE?new e(n,_r.G.u()===o?t.targetId:o):n===Er.Scene.GROUP?new e(n,t.targetId):void 0},e.byConversationDTO=function(e){var t=e.lastMessage;return this.byIMMessage(t)},e.byRemoteRecallEvent=function(t){var n;if(t.scene===Er.Scene.PRIVATE){var o=t.conversationId.split(":",2);n=o[0]===_r.G.u()?o[1]:o[0]}else n=t.conversationId;return new e(t.scene,n)},e}();Sr.Target=br,vr.__esModule=!0,vr.DeleteMessageRequest=void 0;var Mr=o,wr=Sr,Tr=function(e){var t=this;this.times=new Array;var n=e[0],o=wr.Target.byIMMessage(n);this.scene=o.scene,this.targetId=o.id,e.forEach((function(e){e.status===Mr.MessageStatus.SUCCESS&&t.times.push(e.timestamp)})),this.times.sort((function(e,t){return e<t?-1:e==t?0:1}))};vr.DeleteMessageRequest=Tr,function(e){e.__esModule=!0;var t=o,n=vr,s=_n,i=g,r=Yn,a=io,c=Mo,u=function(){function e(){}return e.deleteServerMessages=function(e){var t=new n.DeleteMessageRequest(e);return t.times.length<0?Promise.resolve():new Promise((function(e,n){var o=new s.default({name:a.RocketTypes.IM_DELETE_MESSAGE,params:t,permission:i.Permission.WRITE,singleTimeout:r.SocketTimeout.commonQuerySingle,totalTimeout:r.SocketTimeout.commonQueryTotal,success:function(t){200===t.code?e(t):n(t)},fail:function(e){n(e)}});c.G.s().emit(o)}))},e.validate=function(e){for(var n=e.messages,o=0;o<n.length;o++){var s=n[o];if(s.status===t.MessageStatus.SENDING)throw{code:400,content:"message["+o+"] is '"+s.status+"' and cannot be deleted"}}},e}();e.default=u}(gr);var Ir={},Nr={__esModule:!0,RecallMessageRequest:void 0},Ar=Sr,Rr=function(e){var t=this;this.times=new Array;var n=e[0],o=Ar.Target.byIMMessage(n);this.scene=o.scene,this.targetId=o.id,e.forEach((function(e){t.times.push(e.timestamp)})),this.times.sort((function(e,t){return e<t?-1:e==t?0:1}))};Nr.RecallMessageRequest=Rr,function(e){e.__esModule=!0;var t=o,n=Nr,s=_n,i=g,r=Yn,a=io,c=Mo,u=function(){function e(){}return e.recallServerMessages=function(e){var t=new n.RecallMessageRequest(e);return 0===t.times.length?Promise.resolve():new Promise((function(e,n){var o=new s.default({name:a.RocketTypes.IM_RECALL_MESSAGE,params:t,permission:i.Permission.WRITE,singleTimeout:r.SocketTimeout.commonRequestSingle,totalTimeout:r.SocketTimeout.commonRequestTotal,fail:function(e){n(e)},success:function(t){200===t.code?e(t):n(t)}});c.G.s().emit(o)}))},e.validate=function(e){for(var n=e.messages,o=0;o<n.length;o++){var s=n[o];if(s.status!==t.MessageStatus.SUCCESS)throw{code:400,content:"message["+o+"] is '"+s.status+"' and cannot be recalled"};if(s.recalled)throw{code:400,content:"message["+o+"] has been recalled"};if(s.senderId!==c.G.u())throw{code:400,content:"it is not allowed to recall messages sent by others"}}},e}();e.default=u}(Ir);var kr={},Pr={};!function(e){e.__esModule=!0;var t=function(e,t,n,o,s){this.scene=e,this.id=t,this.after=n,this.min=o,this.teamId=s};e.default=t}(Pr);var Or={__esModule:!0,ReadMessageMarkRequest:void 0},Dr=function(e,t,n,o){this.id=e,this.scene=t,this.lastTimestamp=n,this.teamId=o};Or.ReadMessageMarkRequest=Dr;var xr={},Fr={__esModule:!0,PrivateMessage:void 0},Gr=f,Ur=o,Lr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.read=!1,t}return Gr.__extends(t,e),t.prototype.scene=function(){return Ur.Scene.PRIVATE},t.prototype.targetId=function(){return this.receiverId},t}(rr.AbstractMessage);Fr.PrivateMessage=Lr;var qr={__esModule:!0,GroupMessage:void 0},Br=f,jr=o,Vr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Br.__extends(t,e),t.prototype.scene=function(){return jr.Scene.GROUP},t.prototype.targetId=function(){return this.groupId},t}(rr.AbstractMessage);qr.GroupMessage=Vr;var Hr={__esModule:!0,CSMessage:void 0},Wr=f,zr=o,Xr=Mo,Jr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.accepted=!1,t}return Wr.__extends(t,e),t.prototype.scene=function(){return zr.Scene.CS},t.prototype.targetId=function(){return Xr.G.u()===this.customerId()?this.teamId:this.customerId()},t.prototype.sendByCustomer=function(){return this.to===this.teamId},t.prototype.customerId=function(){return this.sendByCustomer()?this.senderId:this.to},t.prototype.isOtherSent=function(){return Xr.G.u()===this.customerId()?this.senderId!==Xr.G.u():this.senderId===this.customerId()},t}(rr.AbstractMessage);Hr.CSMessage=Jr;var Yr={};!function(e){var t;e.__esModule=!0,e.CSMessageType=void 0,(t=e.CSMessageType||(e.CSMessageType={})).ACCEPT="CS_ACCEPT",t.END="CS_END",t.TRANSFER="CS_TRANSFER"}(Yr),xr.__esModule=!0,xr.RemoteAbbrMessageBuilder=void 0;var Qr=o,Kr=Fr,$r=qr,Zr=Hr,ea=En,ta=Mo,na=Yr,oa=function(){function e(){}return e.prototype.build=function(e){var t,n=e.t;n===Qr.Scene.PRIVATE?((t=new Kr.PrivateMessage).read=!1,t.receiverId=e.r):n===Qr.Scene.GROUP?((t=new $r.GroupMessage).groupId=e.r,t.senderData=e.d?JSON.parse(e.d):{}):n===Qr.Scene.CS&&((t=new Zr.CSMessage).to=e.r,t.teamId=e.tid,t.senderData=e.d?JSON.parse(e.d):{},t.accepted=e.accepted,t.customerId()!==ta.G.u()&&(t.sessionId=e.sessionId)),t.senderId=e.s,t.messageId=e.i,t.timestamp=e.ts,t.type=e.mt;var o=e.p;if(ea.default.isDef(o))if(n===Qr.Scene.CS&&t.type===na.CSMessageType.TRANSFER){var s=JSON.parse(o);s.transferTo.data=JSON.parse(s.transferTo.data),t.payload=s}else t.payload=JSON.parse(o);return t.recalled=e.rc,t.status=Qr.MessageStatus.SUCCESS,t},e}();xr.RemoteAbbrMessageBuilder=oa,kr.__esModule=!0,kr.RemoteHistory=void 0;var sa=f,ia=o,ra=Pr,aa=_n,ca=io,ua=g,la=Yn,pa=Mo,da=Or,fa=xr,ha=function(){function e(){this.builder=new fa.RemoteAbbrMessageBuilder}return e.prototype.sync=function(e,t,n,o,s){var i=new ra.default(e,t,n,o,s);return new Promise((function(e,t){var n=new aa.default({name:ca.RocketTypes.IM_HISTORY_CHANGE,params:i,permission:ua.Permission.READ,singleTimeout:la.SocketTimeout.commonQuerySingle,totalTimeout:la.SocketTimeout.commonQueryTotal,fail:function(e){t(e)},success:function(t){var n=t.content;e(n)}});pa.G.s().emit(n)}))},e.prototype.loadServerMessages=function(e,t){var n=this;return new Promise((function(o,s){var i=new aa.default({name:ca.RocketTypes.IM_HISTORY,params:t,permission:ua.Permission.READ,singleTimeout:la.SocketTimeout.commonQuerySingle,totalTimeout:la.SocketTimeout.commonQueryTotal,fail:function(e){s(e)},success:function(t){var s=t.content;s.messages=n.convertServerMessages(e,s.messages),o(s)}});pa.G.s().emit(i)}))},e.prototype.convertServerMessages=function(e,t){var n=this,o=[],s=e.scene,i=e.id;return t.forEach((function(t){if(t.t=s,ia.Scene.PRIVATE===s)t.r=t.s===pa.G.u()?i:pa.G.u();else if(ia.Scene.GROUP===s)t.r=i;else if(ia.Scene.CS===s){var r=e.customerId(),a=e.teamId;r===pa.G.u()?t.r=a:t.r=r}var c=n.builder.build(t);o.push(c)})),o},e.prototype.updateServerOffsets=function(e,t){return sa.__awaiter(this,void 0,void 0,(function(){var n;return sa.__generator(this,(function(o){return n=new da.ReadMessageMarkRequest(t.id,t.scene,e,t.teamId),[2,new Promise((function(e,t){var o=new aa.default({name:ca.RocketTypes.IM_MARK_AS_READ,params:n,permission:ua.Permission.WRITE,singleTimeout:la.SocketTimeout.commonRequestSingle,totalTimeout:la.SocketTimeout.commonRequestTotal,success:function(t){e(t)},fail:function(e){t(e)}});pa.G.s().emit(o)}))]}))}))},e.instance=new e,e}();kr.RemoteHistory=ha;var ma={__esModule:!0,UserOffsets:void 0},ya=En,ga=Mo,va=function(){function e(){this.offsetMap=new Map,this.markingTime=0,this.userId=ga.G.u()}return e.prototype.updateOffset=function(e,t){var n=this.offsetMap.get(e);return ya.default.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(this.userId,e)},e.prototype.myOffset=function(){return this.getOffset(this.userId)},e.prototype.getOffset=function(e){var t=this.offsetMap.get(e);return t||0},e}();ma.UserOffsets=va;var Sa={};!function(e){e.__esModule=!0;var t=function(e,t,n,o,s){this.id=e,this.scene=t,this.lastTimestamp=n,this.limit=o,this.teamId=s};e.default=t}(Sa);var Ea={__esModule:!0,UnreadAmountMaxMessageChangeDetector:void 0},Ca=fo,_a=ir,ba=function(){function e(e){this.history=e}return e.prototype.pre=function(){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)},e.prototype.post=function(){var e,t,n,o=this.history.unreadAmount(),s=this.history.getMaxMessage();s&&(n=s.status,e=s.read,t=s.recalled);var i=this.history.target;this.oldLastMessage!==s||this.oldLastMessageRead!==e||this.oldLastMessageRecalled!==t||this.oldLastMessageStatus!==n?s?Ca.GoEasyEventCenter.fire(_a.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,s):Ca.GoEasyEventCenter.fire(_a.IM_INTERNAL_EVENTS.MAX_MESSAGE_DELETED,i):this.oldUnreadAmount!==o&&Ca.GoEasyEventCenter.fire(_a.IM_INTERNAL_EVENTS.UNREAD_AMOUNT_CHANGED,i)},e}();Ea.UnreadAmountMaxMessageChangeDetector=ba,function(e){e.__esModule=!0;var t=f,n=o,s=bs,i=Us,r=hr,a=gr,c=Ir,u=Fs,l=Mo,p=kr,d=ma,h=Sa,m=En,y=Ea,g=fo,v=ir,S=function(){function e(e){this.expiredTime=0,this.remoteHistory=p.RemoteHistory.instance,this.target=e,this.userOffsets=new d.UserOffsets,this.messageCache=new r.default(e)}return e.prototype.initMaxMessageAndOffsets=function(e,t){var n=this;this.existsMessage(e)||(this.messageCache.saveMessage(e),t.forEach((function(e){n.markLocalMessagesRead(n.messageCache.all(),e.userId,e.offset,!1)})))},e.prototype.existsMessage=function(e){return this.messageCache.existsMessage(e.messageId)},e.prototype.loadHistory=function(e,n){return t.__awaiter(this,void 0,void 0,(function(){return t.__generator(this,(function(t){switch(t.label){case 0:return this.expiredTime>0&&!this.messageCache.isEmpty()?[4,this.updateByServerChange()]:[3,2];case 1:t.sent(),t.label=2;case 2:return m.default.isUndef(n)?n=10:n>30&&(n=30),[4,this.loadServerMessages(e,n)];case 3:return[2,t.sent()]}}))}))},e.prototype.loadServerMessages=function(e,n){return t.__awaiter(this,void 0,void 0,(function(){var o,s,i,r,a,c,u=this;return t.__generator(this,(function(t){switch(t.label){case 0:return o=this.messageCache.loadLocalMessages(n,e),!1!==this.messageCache.allLoaded||o.length===n?[3,2]:(s=n-o.length,i=o[0]?o[0].timestamp:e,r=new h.default(this.target.id.toString(),this.target.scene,i,s,this.target.teamId),[4,this.remoteHistory.loadServerMessages(this.target,r)]);case 1:a=t.sent(),c=a.messages,o=c.concat(o),this.messageCache.cacheServerMessages(r,c),a.userOffsets.forEach((function(e){u.userOffsets.updateOffset(e.userId,e.offset)})),this.userOffsets.offsetMap.forEach((function(e,t){u.markLocalMessagesRead(c,t,e,!1)})),t.label=2;case 2:return[2,o]}}))}))},e.prototype.deleteMessages=function(e){return t.__awaiter(this,void 0,void 0,(function(){var n=this;return t.__generator(this,(function(o){switch(o.label){case 0:return[4,this.aopUnreadAmountMaxMessage((function(){return t.__awaiter(n,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return n=e.messages,[4,a.default.deleteServerMessages(n)];case 1:return t.sent(),this.messageCache.deleteMessages(n),s.CallbackUtils.onSuccess(e),[2]}}))}))}))];case 1:return o.sent(),[2]}}))}))},e.prototype.syncDeletedMessage=function(e,t){var n=this;this.aopUnreadAmountMaxMessage((function(){n.doSyncDeletedMessage(e,t)}))},e.prototype.doSyncDeletedMessage=function(e,t){if(e===l.G.u()){var n=this.messageCache.findMessagesByTimes(t);this.messageCache.deleteMessages(n),n.length>0&&u.IM.aec.fire(i.ImApiEvents.MESSAGE_DELETED,n)}},e.prototype.recallMessage=function(e){return t.__awaiter(this,void 0,void 0,(function(){var n=this;return t.__generator(this,(function(o){switch(o.label){case 0:return[4,this.aopUnreadAmountMaxMessage((function(){return t.__awaiter(n,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return n=e.messages,[4,c.default.recallServerMessages(n)];case 1:return t.sent(),this.messageCache.recallMessages(n),s.CallbackUtils.onSuccess(e),[2]}}))}))}))];case 1:return o.sent(),[2]}}))}))},e.prototype.syncRecalledMessage=function(e){var n=this;this.aopUnreadAmountMaxMessage((function(){return t.__awaiter(n,void 0,void 0,(function(){return t.__generator(this,(function(t){return this.doSyncRecalledMessage(e),[2]}))}))}))},e.prototype.doSyncRecalledMessage=function(e){var t=this.messageCache.findMessagesByTimes(e);t.length>0&&(this.messageCache.recallMessages(t),u.IM.aec.fire(i.ImApiEvents.MESSAGE_RECALLED,t))},e.prototype.expire=function(){this.messageCache.isEmpty()||(this.expiredTime=this.messageCache.maxSuccessMessageTime())},e.prototype.updateByServerChange=function(){return t.__awaiter(this,void 0,void 0,(function(){var e=this;return t.__generator(this,(function(n){switch(n.label){case 0:return[4,this.aopUnreadAmountMaxMessage((function(){return t.__awaiter(e,void 0,void 0,(function(){var e,n,o,s=this;return t.__generator(this,(function(t){switch(t.label){case 0:return[4,this.remoteHistory.sync(this.target.scene,this.target.id,this.expiredTime,this.messageCache.minTime(),this.target.teamId)];case 1:return(e=t.sent()).userOffsets.forEach((function(e){s.markLocalMessagesRead(s.messageCache.all(),e.userId,e.offset,!0)})),(n=e.deletedMessageTimes).length>0&&this.doSyncDeletedMessage(l.G.u(),n),(o=e.recalled).length>0&&this.doSyncRecalledMessage(o),this.expiredTime=0,[2]}}))}))}))];case 1:return n.sent(),[2]}}))}))},e.prototype.markRead=function(){return t.__awaiter(this,void 0,void 0,(function(){var e=this;return t.__generator(this,(function(n){switch(n.label){case 0:return[4,this.aopUnreadAmountMaxMessage((function(){return t.__awaiter(e,void 0,void 0,(function(){var e,n;return t.__generator(this,(function(t){switch(t.label){case 0:return e=this.messageCache.maxSuccessMessageTime(),n=this.userOffsets.myOffset(),e>n?(this.userOffsets.markingTime=e,[4,this.remoteHistory.updateServerOffsets(e,this.target)]):[3,2];case 1:t.sent(),e===this.userOffsets.markingTime&&this.markLocalMessagesRead(this.messageCache.all(),l.G.u(),e,!0),t.label=2;case 2:return[2]}}))}))}))];case 1:return n.sent(),[2]}}))}))},e.prototype.syncMarkedMessage=function(e){var t=this;this.aopUnreadAmountMaxMessage((function(){t.markLocalMessagesRead(t.messageCache.all(),e.markerId,e.time,!0)}))},e.prototype.onMessageSending=function(e){var t=this;this.aopUnreadAmountMaxMessage((function(){t.messageCache.saveMessage(e)}))},e.prototype.onMessageSendSuccess=function(e){var t=this;this.aopUnreadAmountMaxMessage((function(){t.messageCache.correctPosition(e),t.markLocalMessagesRead(t.messageCache.all(),l.G.u(),e.timestamp,!0)}))},e.prototype.onMessageSendFailed=function(e){this.getMaxMessage()===e&&g.GoEasyEventCenter.fire(v.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,e)},e.prototype.onMessageReceived=function(e){var t=this;this.aopUnreadAmountMaxMessage((function(){t.messageCache.saveMessage(e),t.markLocalMessagesRead(t.messageCache.all(),e.senderId,e.timestamp,!0)}))},e.prototype.aopUnreadAmountMaxMessage=function(e,n){return t.__awaiter(this,void 0,void 0,(function(){var o,i;return t.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),(o=new y.UnreadAmountMaxMessageChangeDetector(this)).pre(),[4,e()];case 1:return t.sent(),o.post(),[3,3];case 2:return i=t.sent(),s.CallbackUtils.onFailed(n,i),[3,3];case 3:return[2]}}))}))},e.prototype.markLocalMessagesRead=function(e,t,n,o){if(this.userOffsets.updateOffset(t,n),this.isOtherUserId(t)){var s=this.markMySentRead(e,n);o&&s.length>0&&u.IM.aec.fire(i.ImApiEvents.MESSAGE_READ,s)}else t===l.G.u()&&this.markOthersSentRead(e,n)},e.prototype.markOthersSentRead=function(e,t){if(this.target.scene===n.Scene.PRIVATE)for(var o=e.length-1;o>=0;o--){var s=e[o];if(s.isOtherSent()&&s.timestamp<=t){if(s.read)break;s.read=!0}}},e.prototype.markMySentRead=function(e,t){var o=new Array;if(this.target.scene===n.Scene.PRIVATE)for(var s=e.length-1;s>=0;s--){var i=e[s];if(!i.isOtherSent()&&i.timestamp<=t&&i.status===n.MessageStatus.SUCCESS){if(i.read)break;i.read=!0,o.push(i)}}return o},e.prototype.isOtherUserId=function(e){if(this.target.scene===n.Scene.CS){var t=this.target.customerId();return l.G.u()===t?e!==l.G.u():e===t}return e!==l.G.u()},e.prototype.unreadAmount=function(e){var n,o,s=0,i=this.userOffsets.myOffset(),r=this.messageCache.all();try{for(var a=t.__values(r),c=a.next();!c.done;c=a.next()){var u=c.value;u.isOtherSent()&&!1===u.recalled&&u.timestamp>i&&(s+=1)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}return s},e.prototype.getMaxMessage=function(e){return this.messageCache.getMaxMessage()},e.prototype.maxTime=function(e){var t=this.getMaxMessage();return m.default.isDef(t)?t.timestamp:0},e}();e.default=S}(fr);var Ma={},wa={},Ta={__esModule:!0,LiveSessionRequest:void 0},Ia=function(e,t){this.teamId=e,this.customerId=t};Ta.LiveSessionRequest=Ia;var Na={__esModule:!0,CustomerStatus:void 0},Aa=function(){};Na.CustomerStatus=Aa;var Ra={},ka={__esModule:!0,CSOnlineRequest:void 0},Pa=function(e,t,n){this.teamId=e,this.teamData=JSON.stringify(t),this.agentData=JSON.stringify(n)};ka.CSOnlineRequest=Pa;var Oa={__esModule:!0,CSOfflineRequest:void 0},Da=function(e){this.teamId=e};Oa.CSOfflineRequest=Da;var xa={__esModule:!0,CsAgentsQueryRequest:void 0},Fa=function(e){this.teamId=e};xa.CsAgentsQueryRequest=Fa,Ra.__esModule=!0,Ra.AgentStatus=void 0;var Ga=f,Ua=_n,La=io,qa=g,Ba=Yn,ja=En,Va=ka,Ha=Oa,Wa=fo,za=ir,Xa=bs,Ja=Mo,Ya=xa,Qa=Ro,Ka=function(){function e(){this.synchronized=!0,Ja.G.s().addDisconnectedObserver(this.onDisconnected.bind(this)),Ja.G.s().addConnectedObserver(this.onConnected.bind(this)),Ja.G.s().addMessageObserver(Qa.RemoteEvents.CS_ONLINE_CHANGED,this.onlineChanged.bind(this))}return e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.queryTeams=function(){var e=this;return this.queryMyTeamPromise||(this.queryMyTeamPromise=new Promise((function(t,n){var o=new Ua.default({name:La.RocketTypes.CS_MY_TEAMS,params:{},permission:qa.Permission.READ,singleTimeout:Ba.SocketTimeout.commonQuerySingle,totalTimeout:Ba.SocketTimeout.commonQueryTotal,fail:function(e){n(e)},success:function(n){e.teamIds=new Set(n.content),e.synchronized=!0,t(e.teamIds)}});Ja.G.s().emit(o)}))),this.queryMyTeamPromise},e.prototype.myTeams=function(){if(this.synchronized&&this.queryMyTeamPromise)return this.teamIds;throw"please query team first."},e.prototype.isOnline=function(e,t){return Ga.__awaiter(this,void 0,void 0,(function(){return Ga.__generator(this,(function(n){switch(n.label){case 0:return[4,this.queryTeams()];case 1:return n.sent(),Xa.CallbackUtils.onSuccess(t,this.teamIds.has(e)),[2]}}))}))},e.prototype.online=function(e,t){var n=this;if(!ja.default.isObject(t.agentData)||!ja.default.isObject(t.teamData))throw{code:400,content:"agentData and teamData require an object"};var o=new Va.CSOnlineRequest(e,t.teamData,t.agentData),s=new Ua.default({name:La.RocketTypes.CS_ONLINE,params:o,permission:qa.Permission.WRITE,singleTimeout:Ba.SocketTimeout.commonRequestSingle,totalTimeout:Ba.SocketTimeout.commonRequestTotal,fail:function(e){Xa.CallbackUtils.onFailed(t,e)},success:function(o){n.teamIds.add(e),Xa.CallbackUtils.onSuccess(t),Wa.GoEasyEventCenter.fire(za.IM_INTERNAL_EVENTS.CS_ONLINE_SUCCESS)}});Ja.G.s().emit(s)},e.prototype.offline=function(e,t){var n=this,o=new Ha.CSOfflineRequest(e),s=new Ua.default({name:La.RocketTypes.CS_OFFLINE,params:o,permission:qa.Permission.WRITE,singleTimeout:Ba.SocketTimeout.commonRequestSingle,totalTimeout:Ba.SocketTimeout.commonRequestTotal,fail:function(e){Xa.CallbackUtils.onFailed(t,e)},success:function(o){n.teamIds.delete(e),Xa.CallbackUtils.onSuccess(t),Wa.GoEasyEventCenter.fire(za.IM_INTERNAL_EVENTS.CS_OFFLINE_SUCCESS)}});Ja.G.s().emit(s)},e.prototype.agents=function(e,t){var n=new Ya.CsAgentsQueryRequest(e),o=new Ua.default({name:La.RocketTypes.CS_AGENTS,params:n,permission:qa.Permission.READ,singleTimeout:Ba.SocketTimeout.commonQuerySingle,totalTimeout:Ba.SocketTimeout.commonQueryTotal,fail:function(e){Xa.CallbackUtils.onFailed(t,e)},success:function(e){e.content.forEach((function(e){e.data=JSON.parse(e.data)})),Xa.CallbackUtils.onSuccess(t,e)}});Ja.G.s().emit(o)},e.prototype.onlineChanged=function(e){e.online?this.teamIds.add(e.teamId):this.teamIds.delete(e.teamId)},e.prototype.onDisconnected=function(){this.queryMyTeamPromise=null,this.teamIds=null},e.prototype.onConnected=function(){this.synchronized&&(this.queryMyTeamPromise=this.queryTeams())},e}();Ra.AgentStatus=Ka,wa.__esModule=!0,wa.LiveSession=void 0;var $a=f,Za=o,ec=Ta,tc=bo,nc=_n,oc=io,sc=g,ic=Yn,rc=bs,ac=Mo,cc=fo,uc=ir,lc=Na,pc=Yr,dc=Ra,fc=Sr,hc=So,mc=function(){function e(t){this.teamId=t,cc.GoEasyEventCenter.on(uc.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,this.onMessageReceived),cc.GoEasyEventCenter.on(uc.IM_INTERNAL_EVENTS.CS_ACCEPTED,this.onMessageReceived),cc.GoEasyEventCenter.on(uc.IM_INTERNAL_EVENTS.CS_ENDED,this.onMessageReceived),cc.GoEasyEventCenter.on(uc.IM_INTERNAL_EVENTS.CS_TRANSFER,this.onMessageReceived),cc.GoEasyEventCenter.on(hc.SOCKET_INTERNAL_EVENTS.MANUAL_DISCONNECTED,e.destroy)}return e.live=function(t,n){return $a.__awaiter(this,void 0,void 0,(function(){var o,s,i,r=this;return $a.__generator(this,(function(a){switch(a.label){case 0:return o=n.customerId,tc.default.validateId(o,"customerId"),s=new ec.LiveSessionRequest(t,o),[4,dc.AgentStatus.getInstance().queryTeams()];case 1:return a.sent(),i=new nc.default({name:oc.RocketTypes.CS_LIVE_SESSION,params:s,permission:sc.Permission.WRITE,singleTimeout:ic.SocketTimeout.commonRequestSingle,totalTimeout:ic.SocketTimeout.commonRequestTotal,fail:function(e){rc.CallbackUtils.onFailed(n,e)},success:function(o){e.destroy(),r.session=new e(t),r.session.liveOptions=n;var s=o.content.customerStatus;"ACCEPTED"===s.status&&(s.agent.data=JSON.parse(s.agent.data)),r.session.status=s,r.session.liveOptions.onStatusUpdated(r.session.status),rc.CallbackUtils.onSuccess(n)}}),ac.G.s().emit(i),[2]}}))}))},e.prototype.customerId=function(){return this.liveOptions.customerId},e.isMyCustomer=function(t){var n=e.session;if(n&&n.teamId===t.teamId&&n.customerId()===t.customerId()){var o=dc.AgentStatus.getInstance().myTeams(),s=n.status.agent;return o.has(t.teamId)&&(!s||s.id===ac.G.u())}return!0},e.isMyMessage=function(e){var t=fc.Target.byIMMessage(e);return e.type===pc.CSMessageType.TRANSFER&&e.payload.transferTo.id===ac.G.u()||this.isMyCustomer(t)},e.quit=function(t){var n=e.session;if(n){var o=n.liveOptions.customerId;tc.default.validateId(o,"customerId");var s=new ec.LiveSessionRequest(n.teamId,o),i=new nc.default({name:oc.RocketTypes.CS_QUIT_LIVE,params:s,permission:sc.Permission.WRITE,singleTimeout:ic.SocketTimeout.commonRequestSingle,totalTimeout:ic.SocketTimeout.commonRequestTotal,fail:function(e){rc.CallbackUtils.onFailed(t,e)},success:function(n){e.destroy(),rc.CallbackUtils.onSuccess(t)}});ac.G.s().emit(i)}},e.destroy=function(){var t=e.session;t&&(cc.GoEasyEventCenter.off(uc.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,t.onMessageReceived),cc.GoEasyEventCenter.off(uc.IM_INTERNAL_EVENTS.CS_ACCEPTED,t.onMessageReceived),cc.GoEasyEventCenter.off(uc.IM_INTERNAL_EVENTS.CS_ENDED,t.onMessageReceived),cc.GoEasyEventCenter.off(uc.IM_INTERNAL_EVENTS.CS_TRANSFER,t.onMessageReceived),cc.GoEasyEventCenter.off(hc.SOCKET_INTERNAL_EVENTS.MANUAL_DISCONNECTED,e.destroy),e.session=null)},e.prototype.onMessageReceived=function(t){var n=e.session;if(t.scene()===Za.Scene.CS&&n.liveOptions){var o=t,s=n.liveOptions.customerId;n.teamId===o.teamId&&o.customerId()===s&&(n.tryUpdateStatus(o),n.liveOptions.onNewMessage(o))}},e.prototype.tryUpdateStatus=function(e){if(!("FREE"!==this.status.status&&this.status.sessionId>e.sessionId)){var t;switch(e.type){case pc.CSMessageType.ACCEPT:(t=new lc.CustomerStatus).status="ACCEPTED",t.start=e.payload.sessionStart,t.sessionId=e.sessionId,t.agent=new Za.User(e.senderId,e.senderData);break;case pc.CSMessageType.END:(t=new lc.CustomerStatus).status="FREE";break;case pc.CSMessageType.TRANSFER:(t=new lc.CustomerStatus).status="ACCEPTED",t.start=e.payload.sessionStart,t.sessionId=e.sessionId,t.agent=e.payload.transferTo;break;default:"FREE"===this.status.status&&((t=new lc.CustomerStatus).status="PENDING",t.start=e.timestamp,t.sessionId=e.sessionId)}t&&(this.status=t,this.liveOptions.onStatusUpdated(t))}},e}();wa.LiveSession=mc,function(e){e.__esModule=!0;var t=f,n=Sa,o=bs,s=En,i=fo,r=ir,a=Mo,c=Yr,u=wa,l=function(e){function l(t){var n=e.call(this,t)||this;return n.unread=0,n.markingAmount=0,n}return t.__extends(l,e),l.prototype.loadHistory=function(e,n){return t.__awaiter(this,void 0,void 0,(function(){return t.__generator(this,(function(t){switch(t.label){case 0:return s.default.isUndef(n)?n=10:n>30&&(n=30),[4,this.loadServerMessages(e,n)];case 1:return[2,t.sent()]}}))}))},l.prototype.loadServerMessages=function(e,o){return t.__awaiter(this,void 0,void 0,(function(){var s,i,r=this;return t.__generator(this,(function(t){switch(t.label){case 0:return s=new n.default(this.target.id.toString(),this.target.scene,e,o,this.target.teamId),[4,this.remoteHistory.loadServerMessages(this.target,s)];case 1:return(i=t.sent()).userOffsets.forEach((function(e){r.userOffsets.updateOffset(e.userId,e.offset)})),[2,i.messages]}}))}))},l.prototype.deleteMessages=function(e){return t.__awaiter(this,void 0,void 0,(function(){return t.__generator(this,(function(t){return o.CallbackUtils.onFailed(e,"Delete CS message is not supported yet"),[2]}))}))},l.prototype.recallMessage=function(e){return t.__awaiter(this,void 0,void 0,(function(){return t.__generator(this,(function(t){return o.CallbackUtils.onFailed(e,"Recall CS message is not supported yet"),[2]}))}))},l.prototype.initMaxMessageAndOffsets=function(e,t){var n=this;t.forEach((function(e){n.userOffsets.updateOffset(e.userId,e.offset)})),(s.default.isUndef(this.acceptedMaxMessage)||this.acceptedMaxMessage.timestamp<e.timestamp)&&this.increaseUnreadAmount(e),this.saveAcceptedMessage(e)},l.prototype.initPendingMaxMessageAndOffsets=function(e,t){var n=this;t.forEach((function(e){n.userOffsets.updateOffset(e.userId,e.offset)})),this.savePendingMessage(e)},l.prototype.savePendingMessage=function(e){this.pendingMaxMessage?this.pendingMaxMessage.timestamp<e.timestamp&&(this.pendingMaxMessage=e):this.pendingMaxMessage=e},l.prototype.saveAcceptedMessage=function(e){this.acceptedMaxMessage?this.acceptedMaxMessage.timestamp<e.timestamp&&(this.acceptedMaxMessage=e):this.acceptedMaxMessage=e},l.prototype.onMessageSending=function(e){this.saveAcceptedMessage(e),i.GoEasyEventCenter.fire(r.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,e)},l.prototype.onMessageSendSuccess=function(e){this.saveAcceptedMessage(e),this.userOffsets.updateOffset(e.senderId,e.timestamp),this.acceptedMaxMessage===e&&i.GoEasyEventCenter.fire(r.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,e)},l.prototype.onMessageSendFailed=function(e){this.acceptedMaxMessage===e&&i.GoEasyEventCenter.fire(r.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,e)},l.prototype.onMessageReceived=function(e){u.LiveSession.isMyMessage(e)&&(!e.accepted||e.senderId!==a.G.u()&&e.type===c.CSMessageType.ACCEPT?this.savePendingMessage(e):this.saveAcceptedMessage(e),this.userOffsets.updateOffset(e.senderId,e.timestamp),this.increaseUnreadAmount(e),i.GoEasyEventCenter.fire(r.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,e))},l.prototype.increaseUnreadAmount=function(e){(e.sendByCustomer()||e.type===c.CSMessageType.TRANSFER&&e.senderId!==a.G.u())&&(this.userOffsets.myOffset()<e.timestamp&&e.accepted&&(this.unread+=1))},l.prototype.markRead=function(){return t.__awaiter(this,void 0,void 0,(function(){var e;return t.__generator(this,(function(t){switch(t.label){case 0:return e=this.maxAcceptedMessageTime(),u.LiveSession.isMyCustomer(this.target)&&this.preMark(e)?[4,this.remoteHistory.updateServerOffsets(e,this.target)]:[3,2];case 1:t.sent(),this.postMark(e),t.label=2;case 2:return[2]}}))}))},l.prototype.preMark=function(e){var t=this.userOffsets.myOffset();return e>this.userOffsets.markingTime&&e>t&&(this.userOffsets.markingTime=e,this.markingAmount=this.unread,!0)},l.prototype.postMark=function(e){e===this.userOffsets.markingTime&&(this.unread-=this.markingAmount,this.markingAmount=0,this.userOffsets.updateOffset(a.G.u(),e),i.GoEasyEventCenter.fire(r.IM_INTERNAL_EVENTS.UNREAD_AMOUNT_CHANGED,this.target))},l.prototype.syncMarkedMessage=function(e){},l.prototype.getMaxMessage=function(e){return e?this.acceptedMaxMessage:this.pendingMaxMessage},l.prototype.unreadAmount=function(e){return e?this.unread:0},l.prototype.existsMessage=function(e){return this.acceptedMaxMessage&&this.acceptedMaxMessage.messageId===e.messageId||this.pendingMaxMessage&&this.pendingMaxMessage.messageId===e.messageId},l.prototype.maxAcceptedMessageTime=function(){return this.acceptedMaxMessage?this.acceptedMaxMessage.timestamp:0},l.prototype.maxTime=function(e){var t=this.getMaxMessage(e);return t?t.timestamp:0},l}(fr.default);e.default=l}(Ma);var yc={};!function(e){e.__esModule=!0;var t=f,n=bs,o=function(e){function o(t){return e.call(this,t)||this}return t.__extends(o,e),o.prototype.deleteMessages=function(e){return t.__awaiter(this,void 0,void 0,(function(){return t.__generator(this,(function(t){return n.CallbackUtils.onFailed(e,"Delete CS message is not supported yet"),[2]}))}))},o.prototype.recallMessage=function(e){return t.__awaiter(this,void 0,void 0,(function(){return t.__generator(this,(function(t){return n.CallbackUtils.onFailed(e,"Recall CS message is not supported yet"),[2]}))}))},o}(fr.default);e.default=o}(yc),function(e){e.__esModule=!0;var t=f,n=o,s=En,i=fr,r=Sr,a=fo,c=ir,u=rr,l=gr,p=Ir,d=Ro,h=Mo,m=bs,y=Ma,g=yc,v=function(){function e(){}return e.init=function(){return e.instance||(e.instance=new e),e.instance.map=new Map,e.instance},e.prototype.initialListeners=function(){var e=this;a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.MESSAGE_SENDING,(function(t){return e.onMessageSending(t)})),a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.MESSAGE_SEND_SUCCESS,(function(t){return e.onMessageSendSuccess(t)})),a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.MESSAGE_SEND_FAILED,(function(t){return e.onMessageSendFailed(t)})),a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.MESSAGE_RECEIVED,(function(t){return e.onMessageReceived(t)})),a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,(function(t){return e.onMessageReceived(t)})),a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.CS_ACCEPTED,(function(t){return e.onMessageReceived(t)})),a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.CS_ENDED,(function(t){return e.onMessageReceived(t)})),a.GoEasyEventCenter.on(c.IM_INTERNAL_EVENTS.CS_TRANSFER,(function(t){return e.onMessageReceived(t)})),h.G.s().addMessageObserver(d.RemoteEvents.IM_MSG_READ,this.onRemoteMarkRead.bind(this)),h.G.s().addMessageObserver(d.RemoteEvents.IM_MSG_DELETED,this.onRemoteMessageDeleted.bind(this)),h.G.s().addMessageObserver(d.RemoteEvents.IM_MSG_RECALLED,this.onRemoteMessageRecalled.bind(this)),h.G.s().addDisconnectedObserver(this.onDisconnected.bind(this))},e.prototype.loadHistory=function(e,n){return t.__awaiter(this,void 0,void 0,(function(){var o,s;return t.__generator(this,(function(t){switch(t.label){case 0:return o=this.queryToTarget(e,n),[4,this.findOrCreateHistory(o).loadHistory(e.lastTimestamp,e.limit)];case 1:return s=t.sent(),m.CallbackUtils.onSuccess(e,{code:200,content:s}),[2]}}))}))},e.prototype.queryToTarget=function(e,t){if(s.default.isDef(e.userId))return new r.Target(n.Scene.PRIVATE,e.userId);if(s.default.isDef(e.groupId))return new r.Target(n.Scene.GROUP,e.groupId);if(s.default.isDef(e.type)){if(!Object.values(n.Scene).includes(e.type))throw new Error("incorrect type, must be: "+Object.values(n.Scene));if(s.default.isUndef(e.id))throw new Error("If type is not empty, id is required.");return n.Scene.CS==e.type&&s.default.isUndef(t)&&(t=e.id),new r.Target(e.type,e.id,t)}throw new Error("incorrect query options.")},e.prototype.onMessageSending=function(e){var t=r.Target.byIMMessage(e);this.findOrCreateHistory(t).onMessageSending(e)},e.prototype.onMessageSendSuccess=function(e){var t=r.Target.byIMMessage(e);this.findHistory(t).onMessageSendSuccess(e)},e.prototype.onMessageSendFailed=function(e){var t=r.Target.byIMMessage(e);this.findHistory(t).onMessageSendFailed(e)},e.prototype.onMessageReceived=function(e){var t=r.Target.byIMMessage(e);this.findOrCreateHistory(t).onMessageReceived(e)},e.prototype.privateMarkAsRead=function(e){return t.__awaiter(this,void 0,void 0,(function(){var o;return t.__generator(this,(function(t){switch(t.label){case 0:if(s.default.isUndef(e.userId))throw new Error("userId could not be empty.");return o=r.Target.byScene(n.Scene.PRIVATE,e.userId),[4,this.markAsRead(o,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.groupMarkAsRead=function(e){return t.__awaiter(this,void 0,void 0,(function(){var o;return t.__generator(this,(function(t){switch(t.label){case 0:if(s.default.isUndef(e.groupId))throw new Error("groupId could not be empty.");return o=r.Target.byScene(n.Scene.GROUP,e.groupId),[4,this.markAsRead(o,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.markMessageAsRead=function(e,o){return t.__awaiter(this,void 0,void 0,(function(){var i;return t.__generator(this,(function(t){switch(t.label){case 0:if(s.default.isUndef(e.id))throw new Error("id could not be empty.");if(!Object.values(n.Scene).includes(e.type))throw new Error("incorrect type, must be: "+Object.values(n.Scene));return n.Scene.CS==e.type&&s.default.isUndef(o)&&(o=e.id),i=r.Target.byScene(e.type,e.id,o),[4,this.markAsRead(i,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.markAsRead=function(e,n){return t.__awaiter(this,void 0,void 0,(function(){var o;return t.__generator(this,(function(t){switch(t.label){case 0:return(o=this.findHistory(e))?[4,o.markRead()]:[3,2];case 1:t.sent(),t.label=2;case 2:return m.CallbackUtils.onSuccess(n),[2]}}))}))},e.prototype.onRemoteMarkRead=function(e){var t=r.Target.byMessageReadRemoteEvent(e),n=this.findHistory(t);n&&n.syncMarkedMessage(e)},e.prototype.deleteMessage=function(e){return t.__awaiter(this,void 0,void 0,(function(){var n,o,s;return t.__generator(this,(function(t){switch(t.label){case 0:return this.validateMessageArray(e.messages),l.default.validate(e),n=e.messages[0],o=r.Target.byIMMessage(n),(s=this.findHistory(o))?[4,s.deleteMessages(e)]:[3,2];case 1:return t.sent(),[3,3];case 2:throw{code:400,content:"No message that could be deleted"};case 3:return[2]}}))}))},e.prototype.onRemoteMessageDeleted=function(e){var t=r.Target.byIMMessageDeletedEvent(e),n=this.findHistory(t);n&&n.syncDeletedMessage(e.deleterId,e.times)},e.prototype.recallMessage=function(e){return t.__awaiter(this,void 0,void 0,(function(){var n,o,s;return t.__generator(this,(function(t){switch(t.label){case 0:return this.validateMessageArray(e.messages),p.default.validate(e),n=e.messages[0],o=r.Target.byIMMessage(n),(s=this.findHistory(o))?[4,s.recallMessage(e)]:[3,2];case 1:return t.sent(),[3,3];case 2:throw{code:400,content:"No message that could be recalled"};case 3:return[2]}}))}))},e.prototype.onRemoteMessageRecalled=function(e){var t=r.Target.byRemoteRecallEvent(e),n=this.findHistory(t);n&&n.syncRecalledMessage(e.times)},e.prototype.onDisconnected=function(){this.map.forEach((function(e,t){e.expire()}))},e.prototype.findOrCreateHistory=function(e){var t=this.findHistory(e);return t||(t=e.scene===n.Scene.CS?h.G.u()===e.customerId()?new g.default(e):new y.default(e):new i.default(e),this.map.set(e.toString(),t),t)},e.get=function(t){return e.instance.findOrCreateHistory(t)},e.prototype.findHistory=function(e){return this.map.get(e.toString())},e.prototype.validateMessageArray=function(e){if(!s.default.isArray(e)||s.default.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"};for(var t=r.Target.byIMMessage(e[0]),n=0;n<e.length;n++){var o=e[n];if(!(o instanceof u.AbstractMessage))throw{code:400,content:"message["+n+"] is not a correct message"};if(n>0){var i=r.Target.byIMMessage(o);if(i.scene!==t.scene||i.id!==t.id)throw{code:400,content:"each message must be from the same friend or group"}}}},e}();e.default=v}(dr),pr.__esModule=!0,pr.Conversation=void 0;var gc=o,vc=dr,Sc=function(){function e(e){this.top=!1,this.data=null,this.dataLoaded=!1,this.target=e}return e.prototype.toDto=function(){var e=this.target.scene,t=this.target.id,n=new gc.ConversationDTO;return e===gc.Scene.PRIVATE?n.userId=t:e===gc.Scene.GROUP?n.groupId=t:e===gc.Scene.CS&&(n.id=this.target.teamId),n.type=e,n.lastMessage=this.getMaxMessage(),n.unread=this.getUnreadAmount(),n.top=this.top,n.data=this.data,n},e.prototype.getMaxMessage=function(){return vc.default.get(this.target).getMaxMessage()},e.prototype.getUnreadAmount=function(){return vc.default.get(this.target).unreadAmount()},e.prototype.maxMessageTime=function(){return vc.default.get(this.target).maxTime()},e}();pr.Conversation=Sc;var Ec={__esModule:!0,CSConversation:void 0},Cc=f,_c=dr,bc=o,Mc=Yr,wc=Mo,Tc=function(e){function t(t){var n=e.call(this,t)||this;return n.accepted=!1,n}return Cc.__extends(t,e),t.prototype.toDto=function(){var e=new bc.ConversationDTO,t=this.target.scene,n=this.target.id,o=this.target.teamId;return e.id=n,e.teamId=o,e.type=t,e.lastMessage=this.getMaxMessage(),e.unread=this.getUnreadAmount(),e.top=this.top,e.data=this.data,e.ended=this.isEnded(),e},t.prototype.isEnded=function(){var e=this.getMaxMessage(),t=e.type,n=e.payload;return t===Mc.CSMessageType.END||t===Mc.CSMessageType.TRANSFER&&n.transferTo.id!==wc.G.u()},t.prototype.getMaxMessage=function(){return _c.default.get(this.target).getMaxMessage(this.accepted)},t.prototype.getUnreadAmount=function(){return _c.default.get(this.target).unreadAmount(this.accepted)},t.prototype.maxMessageTime=function(){return _c.default.get(this.target).maxTime(this.accepted)},t}(pr.Conversation);Ec.CSConversation=Tc;var Ic={},Nc={};!function(e){e.__esModule=!0;var t=function(e,t,n,o){this.type=e,this.top=t,this.targetId=n,this.teamId=o};e.default=t}(Nc);var Ac={};!function(e){e.__esModule=!0;var t=function(e,t,n){this.type=e,this.targetId=t,this.teamId=n};e.default=t}(Ac);var Rc={};!function(e){e.__esModule=!0;var t=function(e,t,n){this.type=e,this.targetId=t,this.teamId=n};e.default=t}(Rc),function(e){e.__esModule=!0;var t=f,n=Nc,o=_n,s=io,i=g,r=Yn,a=Ac,c=Mo,u=Rc,l=function(){function e(){}return e.prototype.top=function(e,t){var a=new n.default(e.scene,t,e.id,e.teamId);return new Promise((function(e,t){var n=new o.default({name:s.RocketTypes.topConversation,params:a,permission:i.Permission.WRITE,singleTimeout:r.SocketTimeout.commonRequestSingle,totalTimeout:r.SocketTimeout.commonRequestTotal,success:function(n){200===n.code?e(n):t(n)},fail:function(e){t(e)}});c.G.s().emit(n)}))},e.prototype.remove=function(e){var t=new a.default(e.scene,e.id,e.teamId);return new Promise((function(e,n){var a=new o.default({name:s.RocketTypes.removeConversation,params:t,permission:i.Permission.WRITE,singleTimeout:r.SocketTimeout.commonRequestSingle,totalTimeout:r.SocketTimeout.commonRequestTotal,success:function(t){200==t.code?e(t):n(t)},fail:function(e){n(e)}});c.G.s().emit(a)}))},e.prototype.query=function(e){var n=this;return new Promise((function(s,a){var u=new o.default({name:e,params:{},permission:i.Permission.READ,singleTimeout:r.SocketTimeout.commonQuerySingle,totalTimeout:r.SocketTimeout.commonQueryTotal,fail:function(e){a(e)},success:function(e){return t.__awaiter(n,void 0,void 0,(function(){return t.__generator(this,(function(t){return s(e),[2]}))}))}});c.G.s().emit(u)}))},e.prototype.loadData=function(e){var t=new u.default(e.scene,e.id,e.teamId);return new Promise((function(e,n){var a=new o.default({name:s.RocketTypes.imData,params:t,permission:i.Permission.READ,singleTimeout:r.SocketTimeout.commonQuerySingle,totalTimeout:r.SocketTimeout.commonQueryTotal,success:function(t){var n=JSON.parse(t.content);e(n)},fail:function(e){n(e)}});c.G.s().emit(a)}))},e.instance=new e,e}();e.default=l}(Ic),lr.__esModule=!0,lr.Conversations=void 0;var kc=f,Pc=pr,Oc=bs,Dc=o,xc=xr,Fc=io,Gc=Us,Uc=mr,Lc=fo,qc=ir,Bc=Sr,jc=Ec,Vc=Fs,Hc=Ic,Wc=dr,zc=Mo,Xc=Yr,Jc=En,Yc=function(){function e(){var e=this;this.list=new Array,this.builder=new xc.RemoteAbbrMessageBuilder,this.remoteConversations=Hc.default.instance,this.synchronized=!1,Lc.GoEasyEventCenter.on(qc.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,(function(t){return e.onMaxMessageChanged(t)})),Lc.GoEasyEventCenter.on(qc.IM_INTERNAL_EVENTS.UNREAD_AMOUNT_CHANGED,(function(t){return e.onUnreadMessageChanged(t)})),Lc.GoEasyEventCenter.on(qc.IM_INTERNAL_EVENTS.MAX_MESSAGE_DELETED,(function(t){return e.onMaxMessageDeleted(t)}))}return e.prototype.onUnreadMessageChanged=function(e){this.findConversation(e)&&this.fireUpdated()},e.prototype.fireUpdated=function(){var e=this.loadLocalConversations(),t=this.getUpdatedEventName();Vc.IM.aec.fire(t,{unreadTotal:e.content.unreadTotal,conversations:e.content.conversations})},e.prototype.getUpdatedEventName=function(){return Gc.ImApiEvents.CONVERSATIONS_UPDATED},e.prototype.latestConversations=function(e){return kc.__awaiter(this,void 0,void 0,(function(){var t;return kc.__generator(this,(function(n){switch(n.label){case 0:return this.synchronized?[3,2]:[4,this.loadServerConversations()];case 1:n.sent(),n.label=2;case 2:return t=this.loadLocalConversations(),Oc.CallbackUtils.onSuccess(e,t),[2]}}))}))},e.prototype.loadServerConversations=function(){return kc.__awaiter(this,void 0,void 0,(function(){var e,t;return kc.__generator(this,(function(n){switch(n.label){case 0:return e=this.rocketName(),[4,this.remoteConversations.query(e)];case 1:return t=n.sent(),this.convertAbbrConversation(t.content),this.synchronized=!0,[2]}}))}))},e.prototype.rocketName=function(){return Fc.RocketTypes.imLastConversations},e.prototype.convertAbbrConversation=function(e){var t,n,o=e;try{for(var s=kc.__values(o),i=s.next();!i.done;i=s.next()){var r=i.value,a=r.t,c=r.top,u=r.d?JSON.parse(r.d):{},l=r.userOffsets;r.lmsg.t=a;var p=r.lmsg,d=this.builder.build(p),f=Bc.Target.byIMMessage(d),h=this.findConversation(f);Jc.default.isUndef(h)?(h=this.buildByAbbr(r,d),this.insertOne(h)):(h.top=c,h.data=u),Wc.default.get(f).initMaxMessageAndOffsets(d,l),this.correctPosition(h)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}},e.prototype.onMaxMessageDeleted=function(e){this.removeConversation(e)},e.prototype.onMaxMessageChanged=function(e){return kc.__awaiter(this,void 0,void 0,(function(){var t;return kc.__generator(this,(function(n){switch(n.label){case 0:return e.scene()===Dc.Scene.CS&&(t=e,zc.G.u()!=t.customerId()&&(!1===t.accepted||t.type===Xc.CSMessageType.ACCEPT&&t.senderId!=zc.G.u()))?[2]:[4,this.saveOrUpdateConversation(e)];case 1:return n.sent(),[2]}}))}))},e.prototype.saveOrUpdateConversation=function(e){return kc.__awaiter(this,void 0,void 0,(function(){var t,n,o,s;return kc.__generator(this,(function(i){switch(i.label){case 0:return t=e.status,n=Bc.Target.byIMMessage(e),o=this.findConversation(n),Jc.default.isUndef(o)&&t!==Dc.MessageStatus.FAIL?(o=this.buildByMessage(e),this.insertOne(o),t!==Dc.MessageStatus.SUCCESS?[3,2]:(s=o,[4,this.remoteConversations.loadData(n)])):[3,2];case 1:s.data=i.sent(),o.dataLoaded=!0,i.label=2;case 2:return t===Dc.MessageStatus.SENDING&&(o.data=e.getToData(),o.dataLoaded=!0),o&&o.dataLoaded&&(this.correctPosition(o),this.fireUpdated()),[2]}}))}))},e.prototype.loadLocalConversations=function(){var e,t,n=0,o=new Array;try{for(var s=kc.__values(this.list),i=s.next();!i.done;i=s.next()){var r=i.value;if(r.dataLoaded&&r.getMaxMessage()){n+=r.getUnreadAmount();var a=r.toDto();o.push(a)}}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=s.return)&&t.call(s)}finally{if(e)throw e.error}}return{code:200,content:{unreadTotal:n,conversations:o}}},e.prototype.findConversationIndex=function(e){return this.list.findIndex((function(t){return e.toString()===t.target.toString()}))},e.prototype.findConversation=function(e){var t=this.findConversationIndex(e);return this.list[t]},e.prototype.removeLocalConversation=function(e){var t=this.findConversationIndex(e.target);this.list.splice(t,1)},e.prototype.insertOne=function(t){e.sortedInserter.insert(this.list,t),this.list.length>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.removeConversation=function(e){var t=this.findConversation(e);t&&(this.removeLocalConversation(t),this.fireUpdated())},e.prototype.top=function(e,t,n){return kc.__awaiter(this,void 0,void 0,(function(){var o;return kc.__generator(this,(function(s){switch(s.label){case 0:if(!Jc.default.isBoolean(t))throw new Error("top must be boolean.");if(!(o=this.findConversation(e)))throw new Error("conversation does not exist.");return o.top==t?[3,2]:[4,this.remoteConversations.top(e,t)];case 1:s.sent(),o.top=t,this.correctPosition(o),s.label=2;case 2:return this.fireUpdated(),Oc.CallbackUtils.onSuccess(n),[2]}}))}))},e.prototype.remove=function(e,t){return kc.__awaiter(this,void 0,void 0,(function(){var n;return kc.__generator(this,(function(o){switch(o.label){case 0:if(!(n=this.findConversation(e)))throw new Error("conversation does not exist.");if(n instanceof jc.CSConversation&&!n.isEnded())throw new Error("CS conversation can only be deleted after it ends");return[4,this.remoteConversations.remove(e)];case 1:return o.sent(),this.removeLocalConversation(n),this.fireUpdated(),Oc.CallbackUtils.onSuccess(t),[2]}}))}))},e.prototype.buildByAbbr=function(e,t){var n,o=Bc.Target.byIMMessage(t);if(e.t===Dc.Scene.CS){var s=t;zc.G.u()===s.customerId()?n=new Pc.Conversation(o):(n=new jc.CSConversation(o)).accepted=s.accepted}else n=new Pc.Conversation(o);return n.dataLoaded=!0,n.top=e.top,n.data=e.d?JSON.parse(e.d):{},n},e.prototype.buildByMessage=function(e){var t,n=Bc.Target.byIMMessage(e);if(e.scene()===Dc.Scene.CS){var o=e;zc.G.u()===o.customerId()?t=new Pc.Conversation(n):(t=new jc.CSConversation(n)).accepted=o.accepted}else t=new Pc.Conversation(n);return t},e.CONVERSATIONS_MAX_LENGTH=200,e.sortedInserter=new(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return kc.__extends(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}(Uc.SortedInserter)),e}();lr.Conversations=Yc;var Qc={__esModule:!0,PendingConversations:void 0},Kc=f,$c=o,Zc=io,eu=Sr,tu=fo,nu=ir,ou=Us,su=Yr,iu=dr,ru=Ec,au=Mo,cu=En,uu=function(e){function t(){var t=e.call(this)||this;return t.expired=!1,tu.GoEasyEventCenter.on(nu.IM_INTERNAL_EVENTS.CS_ONLINE_SUCCESS,(function(){return t.onCSOnlineSuccess()})),tu.GoEasyEventCenter.on(nu.IM_INTERNAL_EVENTS.CS_OFFLINE_SUCCESS,(function(){return t.onCSOfflineSuccess()})),au.G.s().addDisconnectedObserver(t.onDisconnected.bind(t)),au.G.s().addConnectedObserver(t.onConnected.bind(t)),t}return Kc.__extends(t,e),t.prototype.onMaxMessageChanged=function(e){return Kc.__awaiter(this,void 0,void 0,(function(){var t,n;return Kc.__generator(this,(function(o){switch(o.label){case 0:return e.scene()!==$c.Scene.CS||((t=e).customerId()==au.G.u()||!1!==t.accepted&&t.type!==su.CSMessageType.ACCEPT)?[3,3]:su.CSMessageType.ACCEPT!==e.type?[3,1]:(n=eu.Target.byIMMessage(e),this.removeConversation(n),[3,3]);case 1:return[4,this.saveOrUpdateConversation(e)];case 2:o.sent(),o.label=3;case 3:return[2]}}))}))},t.prototype.latestConversations=function(t){return Kc.__awaiter(this,void 0,void 0,(function(){var n;return Kc.__generator(this,(function(o){switch(o.label){case 0:return n=this.synchronized,[4,e.prototype.latestConversations.call(this,t)];case 1:return o.sent(),this.list.length>0&&!n&&this.fireUpdated(),[2]}}))}))},t.prototype.onUnreadMessageChanged=function(e){},t.prototype.onCSOnlineSuccess=function(){return Kc.__awaiter(this,void 0,void 0,(function(){return Kc.__generator(this,(function(e){switch(e.label){case 0:return[4,this.loadServerConversations()];case 1:return e.sent(),this.fireUpdated(),[2]}}))}))},t.prototype.onCSOfflineSuccess=function(){this.list=[],this.fireUpdated()},t.prototype.getUpdatedEventName=function(){return ou.ImApiEvents.PENDING_CONVERSATIONS_UPDATED},t.prototype.rocketName=function(){return Zc.RocketTypes.CS_PENDING_CONVERSATION},t.prototype.convertAbbrConversation=function(e){return Kc.__awaiter(this,void 0,void 0,(function(){var t,n,o,s,i,r,a,c,u,l,p,d,f;return Kc.__generator(this,(function(h){t=e;try{for(n=Kc.__values(t),o=n.next();!o.done;o=n.next())(s=o.value).lastMessage.t=$c.Scene.CS,i=s.customerData,r=s.lastMessage,a=s.userOffsets,c=i?JSON.parse(i):{},u=this.builder.build(r),l=eu.Target.byIMMessage(u),p=this.findConversation(l),cu.default.isUndef(p)&&((p=new ru.CSConversation(l)).accepted=u.accepted,p.dataLoaded=!0,this.insertOne(p)),p.top=!1,p.data=c,iu.default.get(l).initPendingMaxMessageAndOffsets(u,a),this.correctPosition(p)}catch(e){d={error:e}}finally{try{o&&!o.done&&(f=n.return)&&f.call(n)}finally{if(d)throw d.error}}return[2]}))}))},t.prototype.onDisconnected=function(){this.expired=!0},t.prototype.onConnected=function(){return Kc.__awaiter(this,void 0,void 0,(function(){return Kc.__generator(this,(function(e){switch(e.label){case 0:return this.expired?(this.expired=!1,this.list=[],[4,this.loadServerConversations()]):[3,2];case 1:e.sent(),this.fireUpdated(),e.label=2;case 2:return[2]}}))}))},t}(lr.Conversations);Qc.PendingConversations=uu,function(e){e.__esModule=!0;var t=lr,n=Sr,s=o,i=Qc,r=Hr,a=Mo,c=function(){function e(){this.conversations=new t.Conversations,this.pendingConversations=new i.PendingConversations}return e.prototype.latestConversations=function(e){this.conversations.latestConversations(e)},e.prototype.latestPendingConversations=function(e){this.pendingConversations.latestConversations(e)},e.prototype.topPrivateConversation=function(e){var t=n.Target.byScene(s.Scene.PRIVATE,e.userId);this.conversations.top(t,e.top,e)},e.prototype.topGroupConversation=function(e){var t=n.Target.byScene(s.Scene.GROUP,e.groupId);this.conversations.top(t,e.top,e)},e.prototype.topConversation=function(e){var t=e.conversation;this.validateConversationDTO(t);var o=n.Target.byConversationDTO(t);this.conversations.top(o,e.top,e)},e.prototype.removePrivateConversation=function(e){var t=n.Target.byScene(s.Scene.PRIVATE,e.userId);this.conversations.remove(t,e)},e.prototype.removeGroupConversation=function(e){var t=n.Target.byScene(s.Scene.GROUP,e.groupId);this.conversations.remove(t,e)},e.prototype.removeConversation=function(e){var t=e.conversation;this.validateConversationDTO(t);var o=n.Target.byConversationDTO(t);this.conversations.remove(o,e)},e.prototype.validateConversationDTO=function(e){if(!(e instanceof s.ConversationDTO))throw new Error("Incorrect conversation object.");var t=e.lastMessage;if(t instanceof r.CSMessage&&t.customerId()!==a.G.u()&&!1===t.accepted)throw new Error("pending conversation cannot be topped or removed.")},e}();e.default=c}(ur);var lu={};!function(e){e.__esModule=!0;var t=ir,n=fo,s=xr,i=Ro,r=ro,a=En,c=o,u=Mo,l=Us,p=dr,d=Sr,f=Fs,h=function(){function e(){this.builder=new s.RemoteAbbrMessageBuilder,r.GNS.instance.addAssembler(new(function(){function e(){}return e.prototype.assemble=function(e){var t={messageId:e.id,timestamp:e.tm,type:e.t,senderId:e.sid,toType:e.tt};return e.tt===c.Scene.GROUP&&(t.groupId=e.gid),t},e.prototype.support=function(e){return!!e.sid},e}()))}return e.prototype.initialGoEasySocket=function(){u.G.s().addMessageObserver(i.RemoteEvents.imMessage,this.onMessageReceived.bind(this))},e.prototype.onMessageReceived=function(e){if(e.t!==c.Scene.CS){var o=this.builder.build(e);this.sendAck(o);var s=d.Target.byIMMessage(o),i=s.scene;p.default.get(s).existsMessage(o)||(this.createNotification(e),n.GoEasyEventCenter.fire(t.IM_INTERNAL_EVENTS.MESSAGE_RECEIVED,o),i===c.Scene.PRIVATE?f.IM.aec.fire(l.ImApiEvents.PRIVATE_MESSAGE_RECEIVED,o):i===c.Scene.GROUP&&f.IM.aec.fire(l.ImApiEvents.GROUP_MESSAGE_RECEIVED,o))}},e.prototype.sendAck=function(e){u.G.s().sendAck("imAck",{publishGuid:e.messageId})},e.prototype.createNotification=function(e){var t=r.GNS.instance.supportNotification();if(a.default.isObject(e.nt)&&e.s!==u.G.u()&&t){var n={id:e.i,tm:e.ts,t:e.mt,sid:e.s,tt:e.t};n.tt===c.Scene.GROUP&&(n.gid=e.r),r.GNS.instance.createLocalNotification(e.nt.t,e.nt.c,n)}},e}();e.default=h}(lu);var pu={};!function(e){e.__esModule=!0;var t=_n,n=g,o=Yn,s=bo,i=io,r=bs,a=Mo,c=function(){function e(){}return e.prototype.subscribe=function(e){s.default.validateIdArray(e.groupIds,"groupIds"),e.groupIds=e.groupIds.toString().split(",");var c=new t.default({name:i.RocketTypes.subscribeGroups,params:{groupIds:e.groupIds,at:e.accessToken},permission:n.Permission.WRITE,singleTimeout:o.SocketTimeout.commonInfiniteSingle,totalTimeout:o.SocketTimeout.commonInfiniteTotal,success:function(){r.CallbackUtils.onSuccess(e,{code:200,content:"ok"})},fail:function(t){r.CallbackUtils.onFailed(e,{code:t.resultCode||408,content:t.content||"Failed to subscribe group message"})}});a.G.s().emit(c)},e.prototype.unsubscribe=function(e){s.default.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();var c=new t.default({name:i.RocketTypes.unsubscribeGroup,params:{groupId:e.groupId},permission:n.Permission.READ,singleTimeout:o.SocketTimeout.commonRequestSingle,totalTimeout:o.SocketTimeout.commonRequestTotal,success:function(){r.CallbackUtils.onSuccess(e,{code:200,content:"ok"})},fail:function(t){r.CallbackUtils.onFailed(e,{code:t.resultCode||408,content:t.content||"Failed to unsubscribe group message"})}});a.G.s().emit(c)},e}();e.default=c}(pu);var du={};!function(e){e.__esModule=!0;var t=_n,n=g,o=Yn,s=io,i=Ro,r=Us,a=bo,c=bs,u=Mo,l=Fs,p=function(){function e(){u.G.s().addMessageObserver(i.RemoteEvents.groupPresence,this.newMessageReceived.bind(this))}return e.prototype.presence=function(e){a.default.validateIdArray(e.groupIds,"groupIds"),e.groupIds.toString().split(",");var t={groupIds:e.groupIds};this.emitRocket(s.RocketTypes.subscribeGroupPresence,t,(function(){c.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){c.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to subscribe group message"})}),o.SocketTimeout.commonInfiniteSingle,o.SocketTimeout.commonInfiniteTotal)},e.prototype.unPresence=function(e){a.default.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();var t={groupId:e.groupId};this.emitRocket(s.RocketTypes.unsubscribeGroupPresence,t,(function(){c.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){c.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}),o.SocketTimeout.commonRequestSingle,o.SocketTimeout.commonRequestTotal)},e.prototype.emitRocket=function(e,o,s,i,r,a){var c=new t.default({name:e,params:o,singleTimeout:r,totalTimeout:a,permission:n.Permission.WRITE,success:s,fail:i});u.G.s().emit(c)},e.prototype.newMessageReceived=function(e){var t=null;e.c&&(t=JSON.parse(e.c)),t&&t.events&&t.events.map((function(e){var n=e.userData?JSON.parse(e.userData):{},o={time:e.time,action:e.action,groupOnlineCount:t.userAmount,groupId:t.groupId,id:e.userId,data:n};l.IM.aec.fire(r.ImApiEvents.GROUP_PRESENCE,o)}))},e}();e.default=p}(du);var fu={};!function(e){e.__esModule=!0;var t=_n,n=g,o=Yn,s=io,i=bo,r=bs,a=Mo,c=function(){function e(){}return e.prototype.get=function(e){i.default.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();var c=new t.default({name:s.RocketTypes.imGroupOnlineCount,params:{groupId:e.groupId},permission:n.Permission.READ,singleTimeout:o.SocketTimeout.commonQuerySingle,totalTimeout:o.SocketTimeout.commonQueryTotal,fail:function(t){r.CallbackUtils.onFailed(e,t||{code:408,content:"Failed to query online group users"})},success:function(t){200==t.code?r.CallbackUtils.onSuccess(e,t):r.CallbackUtils.onFailed(e,t)}});a.G.s().emit(c)},e}();e.default=c}(fu);var hu={},mu={__esModule:!0,IMHereNow:void 0},yu=_n,gu=g,vu=Yn,Su=bs,Eu=Mo,Cu=function(){function e(){}return e.prototype.doHereNow=function(e,t,n){var o=new yu.default({name:e,params:t,permission:gu.Permission.READ,singleTimeout:vu.SocketTimeout.commonQuerySingle,totalTimeout:vu.SocketTimeout.commonQueryTotal,fail:function(e){Su.CallbackUtils.onFailed(n,e)},success:function(e){var t=e.content;e.content=t.map((function(e){var t=e.userData?JSON.parse(e.userData):{};return{id:e.userId,data:t}})),Su.CallbackUtils.onSuccess(n,e)}});Eu.G.s().emit(o)},e}();mu.IMHereNow=Cu,function(e){e.__esModule=!0;var t=f,n=io,o=bo,s=function(e){function s(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(s,e),s.prototype.hereNow=function(e){o.default.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();var t={groupId:e.groupId};this.doHereNow(n.RocketTypes.imGroupHereNow,t,e)},s}(mu.IMHereNow);e.default=s}(hu);var _u={};!function(e){e.__esModule=!0;var t=_n,n=g,o=Yn,s=bo,i=io,r=Ro,a=Us,c=bs,u=Mo,l=Fs,p=function(){function e(){u.G.s().addMessageObserver(r.RemoteEvents.userPresence,this.newMessageReceived.bind(this))}return e.prototype.presence=function(e){s.default.validateIdArray(e.userIds,"userIds"),e.userIds.toString().split(",");var t={userIds:e.userIds};this.emitRocket(i.RocketTypes.subscribeUserPresence,t,(function(){c.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){c.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to subscribe group message"})}),o.SocketTimeout.commonInfiniteSingle,o.SocketTimeout.commonInfiniteTotal)},e.prototype.unPresence=function(e){s.default.validateId(e.userId,"userId"),e.userId=e.userId.toString();var t={userId:e.userId};this.emitRocket(i.RocketTypes.unsubscribeUserPresence,t,(function(){c.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){c.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}),o.SocketTimeout.commonRequestSingle,o.SocketTimeout.commonRequestTotal)},e.prototype.emitRocket=function(e,o,s,i,r,a){var c=new t.default({name:e,params:o,singleTimeout:r,totalTimeout:a,permission:n.Permission.WRITE,success:s,fail:i});u.G.s().emit(c)},e.prototype.newMessageReceived=function(e){var t=[];e.c&&(t=JSON.parse(e.c).events||[]),t.map((function(e){var t=e.userData?JSON.parse(e.userData):{},n={time:e.time,action:e.action,id:e.userId,data:t};l.IM.aec.fire(a.ImApiEvents.USER_PRESENCE,n)}))},e}();e.default=p}(_u);var bu={};!function(e){e.__esModule=!0;var t=f,n=io,o=bo,s=function(e){function s(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(s,e),s.prototype.hereNow=function(e){var t=e.userIds;o.default.validateIdArray(t,"userIds"),t.toString().split(","),this.doHereNow(n.RocketTypes.imHereNow,e,e)},s}(mu.IMHereNow);e.default=s}(bu);var Mu={},wu={},Tu={__esModule:!0,str:void 0},Iu=En,Nu=function(){function e(){}return e.prototype.fileExtension=function(e,t){if(Iu.default.isString(e))try{var n=e.split(t);return n[n.length-1]}catch(e){throw Error(e)}},e}(),Au=new Nu;Tu.str=Au;var Ru={},ku={},Pu={__esModule:!0,AbstractMessagePayload:void 0},Ou=function(){};Pu.AbstractMessagePayload=Ou,ku.__esModule=!0,ku.FileMessagePayload=void 0;var Du=f,xu=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 Du.__extends(t,e),t}(Pu.AbstractMessagePayload);ku.FileMessagePayload=xu,Ru.__esModule=!0,Ru.ImageMessagePayload=void 0;var Fu=f,Gu=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.width=0,t.height=0,t}return Fu.__extends(t,e),t}(ku.FileMessagePayload);Ru.ImageMessagePayload=Gu;var Uu={},Lu={__esModule:!0,AbstractPayloadBuilder:void 0},qu=function(){function e(){}return e.prototype.build=function(e){this.validate(e.createOptions);var t=this.create();return this.setPayload(e,t),t},e}();Lu.AbstractPayloadBuilder=qu,function(e){e.__esModule=!0;var t=f,n=ku,o=En,s=function(e){function s(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(s,e),s.prototype.create=function(){return new n.FileMessagePayload},s.prototype.setPayload=function(e,t){var n=t,o=e.createOptions.file;n.url=o.path,n.name=o.name,n.size=o.size,n.contentType=o.type,e.complete=Promise.resolve()},s.prototype.validate=function(e){if(!o.default.isObject(e))throw Error("it is an empty message.");if(!o.default.isDef(e.file))throw Error("file is empty.")},s}(Lu.AbstractPayloadBuilder);e.default=s}(Uu),function(e){e.__esModule=!0;var t=f,n=Tu,o=En,s=Ru,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new s.ImageMessagePayload},i.prototype.setPayload=function(t,s){e.prototype.setPayload.call(this,t,s);var i=t.createOptions.file,r=s,a=i.path||i.tempFilePath,c=o.default.isEmpty(i.name)||void 0===i.name?a:i.name;r.name="wx-image."+n.str.fileExtension(c,"."),r.contentType="image/"+n.str.fileExtension(c,"."),r.url=a,r.size=i.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)}})}))},i.prototype.validate=function(t){e.prototype.validate.call(this,t)},i}(Uu.default);e.default=i}(wu);var Bu={},ju={__esModule:!0,AudioMessagePayload:void 0},Vu=f,Hu=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.duration=0,t}return Vu.__extends(t,e),t}(ku.FileMessagePayload);ju.AudioMessagePayload=Hu,function(e){e.__esModule=!0;var t=f,n=ju,o=En,s=Tu,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new n.AudioMessagePayload},i.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var i=t.createOptions.file,r=n,a=i.tempFilePath,c=o.default.isEmpty(i.name)||null==i.name?a:i.name,u=i.duration,l=i.fileSize;r.url=a,r.size=l,r.duration=u/1e3,r.name="wx-audio."+s.str.fileExtension(c,"."),r.contentType="audio/"+s.str.fileExtension(c,"."),t.complete=Promise.resolve()},i.prototype.validate=function(t){e.prototype.validate.call(this,t)},i}(Uu.default);e.default=i}(Bu);var Wu={},zu={__esModule:!0,TextMessagePayload:void 0},Xu=f,Ju=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.text="",t}return Xu.__extends(t,e),t}(Pu.AbstractMessagePayload);zu.TextMessagePayload=Ju,Wu.__esModule=!0,Wu.TextPayloadBuilder=void 0;var Yu=f,Qu=zu,Ku=En,$u=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Yu.__extends(t,e),t.prototype.create=function(){return new Qu.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(Ku.default.isEmpty(e.text))throw{code:400,content:"text is empty"};if(!Ku.default.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}(Lu.AbstractPayloadBuilder);Wu.TextPayloadBuilder=$u;var Zu={},el={__esModule:!0,VideoMessagePayload:void 0},tl=f,nl=Lt,ol=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.video=new il,t.thumbnail=new sl,t}return tl.__extends(t,e),t}(Pu.AbstractMessagePayload);el.VideoMessagePayload=ol;var sl=function(){function e(){this.name="",this.url="",this.width=0,this.height=0,this.contentType=""}return e.prototype.initURL=function(e){var t=nl.PlatformDetector.currentPlatform();[nl.Platform.APP_IOS,nl.Platform.APP_ANDROID].includes(t)?this.appUrl(e):[nl.Platform.APPLET_WX,nl.Platform.APPLET_WX_GAME].includes(t)?this.wxUrl(e):this.htmlUrl(e)},e.prototype.htmlUrl=function(e){var 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")},e.prototype.wxUrl=function(e){},e.prototype.appUrl=function(e){},e}(),il=function(){this.name="",this.url="",this.width=0,this.height=0,this.contentType="",this.size=0,this.duration=0};!function(e){e.__esModule=!0;var t=f,n=el,o=En,s=Tu,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new n.VideoMessagePayload},i.prototype.setPayload=function(e,t){var n=e.createOptions.file,i=t,r=i.video,a=i.thumbnail,c=n.duration,u=n.height,l=n.size,p=n.tempFilePath,d=n.thumbTempFilePath,f=n.width,h=n.name,m=void 0===h?"":h,y=o.default.isEmpty(m)?p:m;r.contentType="video/"+s.str.fileExtension(y,"."),r.name="wx-video."+s.str.fileExtension(y,"."),r.url=p,r.width=a.width=f,r.height=a.height=u,r.size=l,r.duration=c,a.url=d,a.contentType="image/jpg",a.name="wx-thumbnail.jpg",e.complete=Promise.resolve()},i.prototype.validate=function(e){if(!o.default.isObject(e))throw Error("it is an empty message.");if(!o.default.isDef(e.file))throw Error("file is empty.")},i}(Lu.AbstractPayloadBuilder);e.default=i}(Zu);var rl={},al={};!function(e){e.__esModule=!0;var t=f,n=ku,o=En,s=function(e){function s(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(s,e),s.prototype.create=function(){return new n.FileMessagePayload},s.prototype.setPayload=function(e,t){var n=t,o=e.createOptions.file;n.url=o.fullPath,n.name=o.name,n.size=o.size,n.contentType=o.type,o.type,e.complete=Promise.resolve()},s.prototype.validate=function(e){if(!o.default.isObject(e))throw Error("it is an empty message.");if(!o.default.isDef(e.file))throw Error("file is empty.")},s}(Lu.AbstractPayloadBuilder);e.default=s}(al),function(e){e.__esModule=!0;var t=f,n=Tu,o=En,s=Ru,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new s.ImageMessagePayload},i.prototype.setPayload=function(e,t){var s=t,i=e.createOptions.file;s.url=i.path,s.size=i.size;var r=o.default.isEmpty(i.name)||void 0===i.name?i.path:i.name;s.contentType="image/"+n.str.fileExtension(r,"."),s.name="uni-image."+n.str.fileExtension(r,"."),e.complete=new Promise((function(e,t){uni.getImageInfo({src:i.path,success:function(t){s.width=t.width,s.height=t.height,e()},fail:function(e){t(e)}})}))},i.prototype.validate=function(t){e.prototype.validate.call(this,t)},i}(al.default);e.default=i}(rl);var cl={};!function(e){e.__esModule=!0;var t=f,n=En,o=Tu,s=ju,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new s.AudioMessagePayload},i.prototype.setPayload=function(e,t){var s=e.createOptions,i=t,r=s.file,a=r.tempFilePath,c=n.default.isEmpty(r.name)||null==r.name?a:r.name;i.url=a,i.name="uni-audio."+o.str.fileExtension(c,"."),i.contentType="audio/"+o.str.fileExtension(c,"."),e.complete=new Promise((function(e,t){uni.getFileInfo({filePath:a,success:function(o){var r=o.size;if(i.size=r,0===r)e();else if(n.default.isDef(s.file.duration))i.duration=s.file.duration/1e3,e();else{var c=uni.createInnerAudioContext();c.src=a,c.onCanplay((function(n){n.errCode?(c.destroy(),t(n)):(i.duration=c.duration,c.destroy(),e())})),c.onError((function(n){c.destroy(),-99===n.errCode?e():t(n)}))}},fail:function(e){t(e)}})}))},i.prototype.validate=function(t){e.prototype.validate.call(this,t)},i}(al.default);e.default=i}(cl);var ul={};!function(e){e.__esModule=!0;var t=f,n=En,o=Tu,s=el,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new s.VideoMessagePayload},i.prototype.setPayload=function(e,t){var s=e.createOptions.file,i=t,r=i.video,a=i.thumbnail,c=s.duration,u=s.height,l=s.size,p=s.tempFilePath,d=s.width,f=s.name,h=void 0===f?"":f,m=n.default.isEmpty(h)?p:h;r.size=l,r.width=d,r.height=u,r.url=p,r.duration=c,r.contentType="video/"+o.str.fileExtension(m,"."),r.name="uni-video."+o.str.fileExtension(m,"."),a.url=p,a.height=200,a.width=Number((r.width*a.height/r.height).toFixed(0)),a.contentType="image/jpg",a.name="uni-thumbnail.jpg",e.complete=Promise.resolve()},i.prototype.validate=function(e){if(!n.default.isObject(e))throw Error("it is an empty message.");if(!n.default.isDef(e.file))throw Error("file is empty.")},i}(Lu.AbstractPayloadBuilder);e.default=i}(ul);var ll={},pl={};!function(e){e.__esModule=!0;var t=f,n=ku,o=En,s=function(e){function s(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(s,e),s.prototype.create=function(){return new n.FileMessagePayload},s.prototype.setPayload=function(e,t){var n=t,o=e.createOptions.file,s=window.URL||window.webkitURL;n.url=s.createObjectURL(o),n.name=o.name,n.size=o.size,n.contentType=o.type,e.complete=Promise.resolve()},s.prototype.validate=function(e){if(!o.default.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")},s}(Lu.AbstractPayloadBuilder);e.default=s}(pl),function(e){e.__esModule=!0;var t=f,n=Ru,o=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(o,e),o.prototype.create=function(){return new n.ImageMessagePayload},o.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var o=t.createOptions.file,s=n,i=window.URL||window.webkitURL,r=new Image;r.src=i.createObjectURL(o),t.complete=new Promise((function(e,t){r.onload=function(){s.width=r.width,s.height=r.height,i.revokeObjectURL(r.src),e()},r.onerror=function(e){i.revokeObjectURL(r.src),t(e)}}))},o.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.")},o}(pl.default);e.default=o}(ll);var dl={};!function(e){e.__esModule=!0;var t=f,n=ju,o=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(o,e),o.prototype.create=function(){return new n.AudioMessagePayload},o.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var o=t.createOptions.file,s=n,i=window.URL||window.webkitURL,r=document.createElement("audio");r.src=i.createObjectURL(o),t.complete=new Promise((function(e,t){r.onloadedmetadata=function(){s.duration=r.duration,i.revokeObjectURL(r.src),e()},r.onerror=function(e){i.revokeObjectURL(r.src),t(e)}}))},o.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.")},o}(pl.default);e.default=o}(dl);var fl={};!function(e){e.__esModule=!0;var t=f,n=el,o=En,s=function(e){function s(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(s,e),s.prototype.create=function(){return new n.VideoMessagePayload},s.prototype.setPayload=function(e,t){var n=this,o=e.createOptions.file,s=t,i=s.video,r=s.thumbnail,a=window.URL||window.webkitURL,c=document.createElement("video");c.src=a.createObjectURL(o),i.size=o.size,i.name=o.name,i.contentType=o.type,i.url=c.src,r.name=o.name,r.contentType="image/jpg",e.complete=new Promise((function(e,t){c.onloadedmetadata=function(){i.duration=c.duration,i.width=c.videoWidth,i.height=c.videoHeight,r.width=c.videoWidth,r.height=c.videoHeight,r.url=n.getThumbnailUrl(c),a.revokeObjectURL(c.src),e()},c.onerror=function(e){a.revokeObjectURL(c.src),t(e)}}))},s.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")},s.prototype.validate=function(e){if(!o.default.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.")},s}(Lu.AbstractPayloadBuilder);e.default=s}(fl);var hl={},ml={};!function(e){e.__esModule=!0;var t=f,n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(n,e),n}(Pu.AbstractMessagePayload);e.default=n}(ml),hl.__esModule=!0,hl.CustomPayloadBuilder=void 0;var yl=f,gl=ml,vl=En,Sl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return yl.__extends(t,e),t.prototype.create=function(){return new gl.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(vl.default.isEmpty(t))throw Error("type is empty.");if(!vl.default.isString(t))throw Error("type require a string");if(vl.default.isEmpty(n))throw Error("payload is empty.");if(!vl.default.isPlainObject(n)&&!vl.default.isStringOrNumber(n))throw Error("payload require object | string | number.")},t}(Lu.AbstractPayloadBuilder);hl.CustomPayloadBuilder=Sl;var El={__esModule:!0,LocalIMMessageBuildOptions:void 0},Cl=function(e,t){this.type=e,this.createOptions=t};El.LocalIMMessageBuildOptions=Cl,Mu.__esModule=!0,Mu.IMMessageBuilder=void 0;var _l=Ut,bl=wu,Ml=Uu,wl=Bu,Tl=Wu,Il=Zu,Nl=rl,Al=al,Rl=cl,kl=ul,Pl=ll,Ol=pl,Dl=dl,xl=fl,Fl=hl,Gl=El,Ul=bn,Ll=En,ql=o,Bl=qr,jl=Fr,Vl=bo,Hl=Hr,Wl=bs,zl=Mo,Xl=Lt,Jl=function(){function e(){var e;this.framework=_l.FrameworkDetector.currentFramework(),this.payloadBuilders=((e={})[_l.Framework.UNIAPP]={image:new Nl.default,file:new Al.default,audio:new Rl.default,video:new kl.default,text:new Tl.TextPayloadBuilder},e[_l.Framework.NATIVE_APPLET_WX]={image:new bl.default,file:new Ml.default,audio:new wl.default,video:new Il.default,text:new Tl.TextPayloadBuilder},e[_l.Framework.UNKNOWN]={image:new Pl.default,file:new Ol.default,audio:new Dl.default,video:new xl.default,text:new Tl.TextPayloadBuilder},e[_l.Framework.TARO]={image:Xl.Platform.APPLET_WX?new bl.default:new Pl.default,file:Xl.Platform.APPLET_WX?new Ml.default:new Ol.default,audio:Xl.Platform.APPLET_WX?new wl.default:new Dl.default,video:Xl.Platform.APPLET_WX?new Il.default:new xl.default,text:new Tl.TextPayloadBuilder},e)}return e.prototype.buildMessage=function(e,t){var n=this.payloadBuilders[this.framework][e],o=new Gl.LocalIMMessageBuildOptions(e,t);if(n){var s=n.build(o);o.payload=s}else{s=(new Fl.CustomPayloadBuilder).build(o);o.payload=s.payload}var i=this.build(o);return o.complete.then((function(){Wl.CallbackUtils.onSuccess(t,i)})).catch((function(e){Wl.CallbackUtils.onFailed(t,e)})),i},e.prototype.build=function(e){var t,n=e.type,o=e.payload,s=e.createOptions,i=s.to,r=i.type;return this.validate(s),r===ql.Scene.GROUP?((t=new Bl.GroupMessage).groupId=i.id.toString(),t.senderData=zl.G.ud()):r===ql.Scene.PRIVATE?((t=new jl.PrivateMessage).read=!1,t.receiverId=i.id.toString()):r===ql.Scene.CS&&((t=new Hl.CSMessage).to=i.id.toString(),t.teamId=i.id.toString(),t.senderData=zl.G.ud()),t.senderId=zl.G.u(),t.messageId=Ul.default.get(),t.payload=o,t.timestamp=Date.now(),t.type=n,t.recalled=!1,t.status=ql.MessageStatus.NEW,t.buildOptions=e,t},e.prototype.validate=function(e){var t=e.to;if(!t)throw new Error("message require property to.");if(!Ll.default.isObject(t))throw new Error("TypeError: to requires an object.");if(!Ll.default.isObject(t.data))throw new Error("TypeError: to.data requires an object.");if(!t.type||t.type!==ql.Scene.GROUP&&t.type!==ql.Scene.PRIVATE&&t.type!==ql.Scene.CS)throw new Error("message require property to.type");if(Ll.default.isEmpty(t.id))throw new Error("message require property to.id");if(!Ll.default.isStringOrNumber(t.id))throw new Error("to.id should be a string or number.");if(zl.G.u()===t.id)throw new Error("to.id can not be the same as your id.");e.notification&&Vl.default.validateNotification(e.notification),e.wxmpTemplateMsg&&Vl.default.validateWXMPTemplateMsg(e.wxmpTemplateMsg)},e}();Mu.IMMessageBuilder=Jl;var Yl={__esModule:!0,CsMessageReceiver:void 0},Ql=f,Kl=fo,$l=ir,Zl=Ra,ep=Mo,tp=Fs,np=Us,op=Sr,sp=dr,ip=o,rp=wa,ap=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Ql.__extends(t,e),t.prototype.onMessageReceived=function(e){var t=this;if(e.t===ip.Scene.CS){var n=this.builder.build(e);this.sendAck(n);var o=op.Target.byIMMessage(n);if(!sp.default.get(o).existsMessage(n))if(n.customerId()===ep.G.u())this.createNotification(e),Kl.GoEasyEventCenter.fire($l.IM_INTERNAL_EVENTS.MESSAGE_RECEIVED,n),tp.IM.aec.fire(np.ImApiEvents.CS_MESSAGE_RECEIVED,n);else Zl.AgentStatus.getInstance().queryTeams().then((function(){rp.LiveSession.isMyMessage(n)&&t.createNotification(e),Kl.GoEasyEventCenter.fire($l.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,n)}))}},t}(lu.default);Yl.CsMessageReceiver=ap,Fs.__esModule=!0,Fs.IM=void 0;var cp=f,up=Gs,lp=Ws,pp=ji,dp=ur,fp=lu,hp=pu,mp=du,yp=fu,gp=hu,vp=_u,Sp=bu,Ep=En,Cp=Eo,_p=bo,bp=bs,Mp=Mu,wp=gi,Tp=dr,Ip=Mo,Np=Yl,Ap=function(){function e(t){this._iMReceiver=new fp.default,this.csMessageReceiver=new Np.CsMessageReceiver,this.options=t,e.aec=new up.ApiEventCenter,this._userHereNow=new Sp.default,this.goEasyUploader=new lp.GoEasyUploader,this._groupHereNow=new gp.default,this._groupOnlineCount=new yp.default,this.groupMessageSubscriber=new hp.default}return e.init=function(t){e.instance=new e(t)},e.prototype.afterConnect=function(){this._iMReceiver.initialGoEasySocket(),this.csMessageReceiver.initialGoEasySocket(),this.messageBuilder=new Mp.IMMessageBuilder,this.messageSender=new pp.default,this.histories=Tp.default.init(),this.histories.initialListeners(),this.conversations=new dp.default,this._groupPresenceSubscriber=new mp.default,this._userPresenceSubscriber=new vp.default},e.prototype.validateModules=function(){if(Ep.default.isUndef(Ip.G.s()))throw Error("Please call connect() first.");if(!this.options.modules||!this.options.modules.includes(Cp.ModuleTypes.IM))throw Error("Invalid options: module '".concat(Cp.ModuleTypes.IM,"' is not enabled"))},e.prototype.catch=function(e,t){return cp.__awaiter(this,void 0,void 0,(function(){var n;return cp.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this.validateModules(),_p.default.validateCallbackOptions(t),[4,e()];case 1:return o.sent(),[3,3];case 2:return n=o.sent(),bp.CallbackUtils.onFailed(t,n),[3,3];case 3:return[2]}}))}))},e.prototype.on=function(t,n){e.aec.on(t,n)},e.prototype.off=function(t,n){e.aec.off(t,n)},e.prototype.createTextMessage=function(e){return this.validateModules(),this.messageBuilder.buildMessage(wp.MessageType.TEXT,e)},e.prototype.createImageMessage=function(e){return this.validateModules(),this.messageBuilder.buildMessage(wp.MessageType.IMAGE,e)},e.prototype.createFileMessage=function(e){return this.validateModules(),this.messageBuilder.buildMessage(wp.MessageType.FILE,e)},e.prototype.createAudioMessage=function(e){return this.validateModules(),this.messageBuilder.buildMessage(wp.MessageType.AUDIO,e)},e.prototype.createVideoMessage=function(e){return this.validateModules(),this.messageBuilder.buildMessage(wp.MessageType.VIDEO,e)},e.prototype.createCustomMessage=function(e){return this.validateModules(),this.messageBuilder.buildMessage(e.type,e)},e.prototype.sendMessage=function(e){var t=this;this.catch((function(){t.messageSender.send(e)}),e)},e.prototype.recallMessage=function(e){var t=this;this.catch((function(){t.histories.recallMessage(e)}),e)},e.prototype.deleteMessage=function(e){var t=this;this.catch((function(){t.histories.deleteMessage(e)}),e)},e.prototype.markGroupMessageAsRead=function(e){var t=this;this.catch((function(){return cp.__awaiter(t,void 0,void 0,(function(){return cp.__generator(this,(function(t){switch(t.label){case 0:return[4,this.histories.groupMarkAsRead(e)];case 1:return t.sent(),[2]}}))}))}),e)},e.prototype.markPrivateMessageAsRead=function(e){var t=this;this.catch((function(){return cp.__awaiter(t,void 0,void 0,(function(){return cp.__generator(this,(function(t){switch(t.label){case 0:return[4,this.histories.privateMarkAsRead(e)];case 1:return t.sent(),[2]}}))}))}),e)},e.prototype.markMessageAsRead=function(e,t){var n=this;this.catch((function(){return cp.__awaiter(n,void 0,void 0,(function(){return cp.__generator(this,(function(n){switch(n.label){case 0:return[4,this.histories.markMessageAsRead(e,t)];case 1:return n.sent(),[2]}}))}))}),e)},e.prototype.latestConversations=function(e){this.validateModules(),this.conversations.latestConversations(e)},e.prototype.removePrivateConversation=function(e){var t=this;this.catch((function(){return t.conversations.removePrivateConversation(e)}),e)},e.prototype.removeGroupConversation=function(e){var t=this;this.catch((function(){return t.conversations.removeGroupConversation(e)}),e)},e.prototype.topPrivateConversation=function(e){var t=this;this.catch((function(){return t.conversations.topPrivateConversation(e)}),e)},e.prototype.topGroupConversation=function(e){var t=this;this.catch((function(){return t.conversations.topGroupConversation(e)}),e)},e.prototype.history=function(e,t){var n=this;this.catch((function(){n.histories.loadHistory(e,t)}),e)},e.prototype.subscribeUserPresence=function(e){var t=this;this.catch((function(){return t._userPresenceSubscriber.presence(e)}),e)},e.prototype.unsubscribeUserPresence=function(e){var t=this;this.catch((function(){return t._userPresenceSubscriber.unPresence(e)}),e)},e.prototype.hereNow=function(e){var t=this;this.catch((function(){return t._userHereNow.hereNow(e)}),e)},e.prototype.subscribeGroup=function(e){var t=this;this.catch((function(){return t.groupMessageSubscriber.subscribe(e)}),e)},e.prototype.unsubscribeGroup=function(e){var t=this;this.catch((function(){return t.groupMessageSubscriber.unsubscribe(e)}),e)},e.prototype.subscribeGroupPresence=function(e){var t=this;this.catch((function(){return t._groupPresenceSubscriber.presence(e)}),e)},e.prototype.unsubscribeGroupPresence=function(e){var t=this;this.catch((function(){return t._groupPresenceSubscriber.unPresence(e)}),e)},e.prototype.groupHereNow=function(e){var t=this;this.catch((function(){return t._groupHereNow.hereNow(e)}),e)},e.prototype.groupOnlineCount=function(e){var t=this;this.catch((function(){return t._groupOnlineCount.get(e)}),e)},e.prototype.latestPendingConversations=function(e){this.validateModules(),this.conversations.latestPendingConversations(e)},e.prototype.topConversation=function(e){this.validateModules(),this.conversations.topConversation(e)},e.prototype.removeConversation=function(e){this.validateModules(),this.conversations.removeConversation(e)},e}();Fs.IM=Ap;var Rp={};!function(e){var t;e.__esModule=!0,e.MediaType=void 0,(t=e.MediaType||(e.MediaType={})).VIDEO="VIDEO",t.VOICE="VOICE"}(Rp);var kp={},Pp={},Op={},Dp={__esModule:!0,CSStatusQueryRequest:void 0},xp=function(e,t){this.customerId=e,this.teamId=t};Dp.CSStatusQueryRequest=xp;var Fp={__esModule:!0,CSAcceptRequest:void 0},Gp=o,Up=function(e,t){this.teamId=e;var n=new Gp.User(t.id.toString(),JSON.stringify(t.data));this.customer=n};Fp.CSAcceptRequest=Up;var Lp={__esModule:!0,CSTransferRequest:void 0},qp=function(e,t,n){this.customerId=e,this.teamId=t,this.agentId=n};Lp.CSTransferRequest=qp;var Bp={__esModule:!0,CSEndRequest:void 0},jp=function(e,t){this.customerId=e,this.teamId=t};Bp.CSEndRequest=jp,Op.__esModule=!0,Op.ConversationHandler=void 0;var Vp=f,Hp=Dp,Wp=Fp,zp=bo,Xp=_n,Jp=io,Yp=g,Qp=Yn,Kp=bs,$p=Mo,Zp=Lp,ed=fo,td=ir,nd=xr,od=Bp,sd=En,id=function(){function e(e){this.builder=new nd.RemoteAbbrMessageBuilder,this.teamId=e}return e.prototype.accept=function(e,t){var n=this,o=t.customer;if(sd.default.isUndef(o))throw{code:400,content:"customer is required."};zp.default.validateId(o.id,"customer.id");var s=o.data;if(sd.default.isUndef(s)||!sd.default.isObject(s))throw{code:400,content:"customer data must be non-empty object."};var i=new Wp.CSAcceptRequest(e,o),r=new Xp.default({name:Jp.RocketTypes.CS_ACCEPT,params:i,permission:Yp.Permission.WRITE,singleTimeout:Qp.SocketTimeout.commonRequestSingle,totalTimeout:Qp.SocketTimeout.commonRequestTotal,fail:function(e){Kp.CallbackUtils.onFailed(t,e)},success:function(e){var o=n.builder.build(e.content.message);ed.GoEasyEventCenter.fire(td.IM_INTERNAL_EVENTS.CS_ACCEPTED,o),Kp.CallbackUtils.onSuccess(t)}});$p.G.s().emit(r)},e.prototype.end=function(e,t){var n=this;zp.default.validateId(t.id,"id");var o=t.id.toString(),s=new od.CSEndRequest(o,e),i=new Xp.default({name:Jp.RocketTypes.CS_END,params:s,permission:Yp.Permission.WRITE,singleTimeout:Qp.SocketTimeout.commonRequestSingle,totalTimeout:Qp.SocketTimeout.commonRequestTotal,fail:function(e){Kp.CallbackUtils.onFailed(t,e)},success:function(e){var o=n.builder.build(e.content.message);ed.GoEasyEventCenter.fire(td.IM_INTERNAL_EVENTS.CS_ENDED,o),Kp.CallbackUtils.onSuccess(t)}});$p.G.s().emit(i)},e.prototype.queryCustomerStatus=function(e,t){return Vp.__awaiter(this,void 0,void 0,(function(){var n;return Vp.__generator(this,(function(o){switch(o.label){case 0:return zp.default.validateId(t.id,"id"),[4,this.doCustomerStatus(e,t.id)];case 1:return n=o.sent(),this.activeCustomerStatus=n,this.activeCustomerStatusOptions=t,Kp.CallbackUtils.onSuccess(t,n),[2]}}))}))},e.prototype.doCustomerStatus=function(e,t){var n=t.toString(),o=new Hp.CSStatusQueryRequest(n,e);return new Promise((function(e,t){var n=new Xp.default({name:Jp.RocketTypes.CS_CUSTOMER_STATUS,params:o,permission:Yp.Permission.READ,singleTimeout:Qp.SocketTimeout.commonQuerySingle,totalTimeout:Qp.SocketTimeout.commonQueryTotal,fail:function(e){t(e)},success:function(t){var n=t.content;n.agent&&(n.agent.data=JSON.parse(n.agent.data)),e(n)}});$p.G.s().emit(n)}))},e.prototype.transfer=function(e,t){var n=this;zp.default.validateId(t.customerId,"customerId"),zp.default.validateId(t.agentId,"agentId");var o=t.customerId.toString(),s=t.agentId.toString(),i=new Zp.CSTransferRequest(o,e,s),r=new Xp.default({name:Jp.RocketTypes.CS_TRANSFER,params:i,permission:Yp.Permission.WRITE,singleTimeout:Qp.SocketTimeout.commonRequestSingle,totalTimeout:Qp.SocketTimeout.commonRequestTotal,fail:function(e){Kp.CallbackUtils.onFailed(t,e)},success:function(e){var o=n.builder.build(e.content.message);ed.GoEasyEventCenter.fire(td.IM_INTERNAL_EVENTS.CS_TRANSFER,o),Kp.CallbackUtils.onSuccess(t)}});$p.G.s().emit(r)},e}();Op.ConversationHandler=id;var rd={__esModule:!0,MessageCreator:void 0},ad=o,cd=Fs,ud=function(){function e(){}return e.getInstance=function(){return e.instance||(e.instance=new e),e.instance},e.prototype.createTextMessage=function(e,t){var n=cd.IM.instance.createTextMessage(t);this.extendProps(e,n)},e.prototype.createImageMessage=function(e,t){var n=cd.IM.instance.createImageMessage(t);this.extendProps(e,n)},e.prototype.createFileMessage=function(e,t){var n=cd.IM.instance.createFileMessage(t);this.extendProps(e,n)},e.prototype.createAudioMessage=function(e,t){var n=cd.IM.instance.createAudioMessage(t);this.extendProps(e,n)},e.prototype.createVideoMessage=function(e,t){var n=cd.IM.instance.createVideoMessage(t);this.extendProps(e,n)},e.prototype.createCustomMessage=function(e,t){var n=cd.IM.instance.createCustomMessage(t);this.extendProps(e,n)},e.prototype.extendProps=function(e,t){if(t.scene()===ad.Scene.CS){var n=t;n.teamId=e,n.accepted=!0}},e}();rd.MessageCreator=ud,Pp.__esModule=!0,Pp.Team=void 0;var ld=f,pd=bo,dd=bs,fd=Fs,hd=Op,md=Ra,yd=rd,gd=wa,vd=function(){function e(e){this.teamId=e,this.agentStatus=md.AgentStatus.getInstance(),this.conversationHandler=new hd.ConversationHandler(e),this.messageCreator=yd.MessageCreator.getInstance()}return e.prototype.catch=function(e,t){return ld.__awaiter(this,void 0,void 0,(function(){var n;return ld.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),pd.default.validateCallbackOptions(t),[4,e()];case 1:return o.sent(),[3,3];case 2:return n=o.sent(),dd.CallbackUtils.onFailed(t,n),[3,3];case 3:return[2]}}))}))},e.prototype.isOnline=function(e){var t=this;this.catch((function(){t.agentStatus.isOnline(t.teamId,e)}),e)},e.prototype.online=function(e){var t=this;this.catch((function(){t.agentStatus.online(t.teamId,e)}),e)},e.prototype.offline=function(e){var t=this;this.catch((function(){t.agentStatus.offline(t.teamId,e)}),e)},e.prototype.customerStatus=function(e){var t=this;this.catch((function(){t.conversationHandler.queryCustomerStatus(t.teamId,e)}),e)},e.prototype.accept=function(e){var t=this;this.catch((function(){t.conversationHandler.accept(t.teamId,e)}),e)},e.prototype.end=function(e){var t=this;this.catch((function(){t.conversationHandler.end(t.teamId,e)}),e)},e.prototype.history=function(e){fd.IM.instance.history(e,this.teamId)},e.prototype.markMessageAsRead=function(e){fd.IM.instance.markMessageAsRead(e,this.teamId)},e.prototype.createTextMessage=function(e){this.messageCreator.createTextMessage(this.teamId,e)},e.prototype.createImageMessage=function(e){this.messageCreator.createImageMessage(this.teamId,e)},e.prototype.createFileMessage=function(e){this.messageCreator.createFileMessage(this.teamId,e)},e.prototype.createAudioMessage=function(e){this.messageCreator.createAudioMessage(this.teamId,e)},e.prototype.createVideoMessage=function(e){this.messageCreator.createVideoMessage(this.teamId,e)},e.prototype.createCustomMessage=function(e){this.messageCreator.createCustomMessage(this.teamId,e)},e.prototype.transfer=function(e){var t=this;this.catch((function(){t.conversationHandler.transfer(t.teamId,e)}),e)},e.prototype.agents=function(e){var t=this;this.catch((function(){t.agentStatus.agents(t.teamId,e)}),e)},e.prototype.liveSession=function(e){var t=this;this.catch((function(){gd.LiveSession.live(t.teamId,e)}),e)},e.prototype.quitLiveSession=function(e){this.catch((function(){gd.LiveSession.quit(e)}),e)},e.prototype.listenCustomer=function(e){var t=this,n={customerId:e.id,onNewMessage:e.onNewMessage,onStatusUpdated:e.onStatusUpdated,onFailed:e.onFailed,onSuccess:e.onSuccess};this.catch((function(){gd.LiveSession.live(t.teamId,n)}),e)},e.prototype.cancelListenCustomer=function(e){this.catch((function(){gd.LiveSession.quit(e)}),e)},e}();Pp.Team=vd,kp.__esModule=!0,kp.CS=void 0;var Sd=Pp,Ed=bo,Cd=function(){function e(){}return e.team=function(e){Ed.default.validateId(e,"teamId");var t=this.teams.get(e);return t||(t=new Sd.Team(e.toString()),this.teams.set(e.toString(),t)),t},e.teams=new Map,e}();return kp.CS=Cd,function(e){e.__esModule=!0,e.CSTeam=e.GoEasyIM=e.GoEasyPubSub=e.CustomerStatusOptions=e.User=e.AgentOnlineOptions=e.ConversationDTO=e.MessageStatus=e.Scene=e.CallBackOptions=void 0;var t,n,o=f,s=h,i=m,r=En,a=Eo,c=Co,u=Fs,l=ro,p=Us,d=fo,y=Rp,g=kp,v=Mo,S=function(){};e.CallBackOptions=S,function(e){e.PRIVATE="private",e.GROUP="group",e.SYSTEM="system",e.CS="cs"}(t=e.Scene||(e.Scene={})),(n=e.MessageStatus||(e.MessageStatus={})).NEW="new",n.SENDING="sending",n.SUCCESS="success",n.FAIL="fail";var E=function(){};e.ConversationDTO=E;var C=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),t}(S);e.AgentOnlineOptions=C;var _=function(e,t){this.id=e,this.data=t};e.User=_;var b=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o.__extends(t,e),t}(S);e.CustomerStatusOptions=b;var M=function(){function e(e){c.PubSub.init(e)}return e.prototype.initialGoEasySocket=function(){c.PubSub.instance.initialGoEasySocket()},e.prototype.initialBeforeConnect=function(){c.PubSub.instance.initialBeforeConnect()},e.prototype.publish=function(e){c.PubSub.instance.publisher.publish(e)},e.prototype.subscribe=function(e){c.PubSub.instance.subscriber.subscribe(e)},e.prototype.unsubscribe=function(e){c.PubSub.instance.subscriber.unsubscribe(e)},e.prototype.subscribePresence=function(e){c.PubSub.instance.presence.subscribePresence(e)},e.prototype.unsubscribePresence=function(e){c.PubSub.instance.presence.unsubscribePresence(e)},e.prototype.history=function(e){c.PubSub.instance.histories.get(e)},e.prototype.hereNow=function(e){c.PubSub.instance.hereNows.byChannel(e)},e.prototype.hereNowByUserIds=function(e){c.PubSub.instance.hereNows.byUserId(e)},e}();e.GoEasyPubSub=M;var w=function(){function e(e){u.IM.init(e)}return e.prototype.afterConnect=function(){u.IM.instance.afterConnect()},e.prototype.on=function(e,t){u.IM.instance.on(e,t)},e.prototype.off=function(e,t){u.IM.instance.off(e,t)},e.prototype.createTextMessage=function(e){return u.IM.instance.createTextMessage(e)},e.prototype.createImageMessage=function(e){return u.IM.instance.createImageMessage(e)},e.prototype.createFileMessage=function(e){return u.IM.instance.createFileMessage(e)},e.prototype.createAudioMessage=function(e){return u.IM.instance.createAudioMessage(e)},e.prototype.createVideoMessage=function(e){return u.IM.instance.createVideoMessage(e)},e.prototype.createCustomMessage=function(e){return u.IM.instance.createCustomMessage(e)},e.prototype.sendMessage=function(e){u.IM.instance.sendMessage(e)},e.prototype.recallMessage=function(e){u.IM.instance.recallMessage(e)},e.prototype.deleteMessage=function(e){u.IM.instance.deleteMessage(e)},e.prototype.markGroupMessageAsRead=function(e){u.IM.instance.markGroupMessageAsRead(e)},e.prototype.markPrivateMessageAsRead=function(e){u.IM.instance.markPrivateMessageAsRead(e)},e.prototype.latestConversations=function(e){u.IM.instance.latestConversations(e)},e.prototype.removePrivateConversation=function(e){u.IM.instance.removePrivateConversation(e)},e.prototype.removeGroupConversation=function(e){u.IM.instance.removeGroupConversation(e)},e.prototype.topPrivateConversation=function(e){u.IM.instance.topPrivateConversation(e)},e.prototype.topGroupConversation=function(e){u.IM.instance.topGroupConversation(e)},e.prototype.history=function(e){u.IM.instance.history(e)},e.prototype.subscribeUserPresence=function(e){u.IM.instance.subscribeUserPresence(e)},e.prototype.unsubscribeUserPresence=function(e){u.IM.instance.unsubscribeUserPresence(e)},e.prototype.hereNow=function(e){u.IM.instance.hereNow(e)},e.prototype.subscribeGroup=function(e){u.IM.instance.subscribeGroup(e)},e.prototype.unsubscribeGroup=function(e){u.IM.instance.unsubscribeGroup(e)},e.prototype.subscribeGroupPresence=function(e){u.IM.instance.subscribeGroupPresence(e)},e.prototype.unsubscribeGroupPresence=function(e){u.IM.instance.unsubscribeGroupPresence(e)},e.prototype.groupHereNow=function(e){u.IM.instance.groupHereNow(e)},e.prototype.groupOnlineCount=function(e){u.IM.instance.groupOnlineCount(e)},e.prototype.markMessageAsRead=function(e){u.IM.instance.markMessageAsRead(e)},e.prototype.csteam=function(e){return new I(e)},e.prototype.pendingConversations=function(e){u.IM.instance.latestPendingConversations(e)},e.prototype.topConversation=function(e){u.IM.instance.topConversation(e)},e.prototype.removeConversation=function(e){u.IM.instance.removeConversation(e)},e}();e.GoEasyIM=w;var T=function(){function e(t){if(r.default.isDef(e.instance)&&e.instance.getConnectionStatus()!==s.NetworkStatus.DISCONNECTED)return e.instance;this.validateOptions(t),this.options=t,l.GNS.init(t.allowNotification),this.pubsub=new M(this.options),this.im=new w(this.options)}return e.getInstance=function(t){return r.default.isUndef(e.instance)&&(e.instance=new e(t)),e.instance},e.prototype.connect=function(e){this.getConnectionStatus()!==s.NetworkStatus.DISCONNECTED&&r.default.isObject(e)&&r.default.isFunction(e.onFailed)?e.onFailed({code:408,content:"It is already connected, don't try again until disconnect() is called. "}):(this.confirmUserId(e),d.GoEasyEventCenter.initial(),this.pubsub.initialBeforeConnect(),this.goEasySocket=new i.default(this.options,e),this.goEasySocket.connect(),v.G.i(this.goEasySocket),this.im.afterConnect(),this.pubsub.initialGoEasySocket())},e.prototype.disconnect=function(e){this.goEasySocket.disconnect().then((function(){r.default.isObject(e)&&r.default.isFunction(e.onSuccess)&&e.onSuccess()})).catch((function(t){r.default.isObject(e)&&r.default.isFunction(e.onFailed)&&e.onFailed(t)}))},e.prototype.getConnectionStatus=function(){return this.goEasySocket?this.goEasySocket.getStatus():s.NetworkStatus.DISCONNECTED},e.prototype.validateOptions=function(e){var t="";if(!r.default.isObject(e))throw t="options is require an object.",Error(t);if(!r.default.isPrimitive(e.appkey)||0==e.appkey.length)throw t="Invalid options:'appkey' is empty.",Error(t);if(!r.default.isPrimitive(e.host)||0==e.host.length)throw t="Invalid options:'host' is empty.",Error(t);if(!r.default.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 '".concat(e,"' is not support"),Error(t);return o}));e.modules=o},e.prototype.onClickNotification=function(e){l.GNS.instance.onClickNotification(e)},e.prototype.confirmUserId=function(e){if(this.options.modules.includes(a.ModuleTypes.IM)&&(r.default.isEmpty(e.id)||!r.default.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.5.13",e.IM_EVENT=p.ImApiEvents,e.IM_SCENE=t,e.MEDIA_TYPE=y.MediaType,e}();e.default=T;var I=function(){function e(e){this.id=e}return e.prototype.isOnline=function(e){g.CS.team(this.id).isOnline(e)},e.prototype.online=function(e){g.CS.team(this.id).online(e)},e.prototype.offline=function(e){g.CS.team(this.id).offline(e)},e.prototype.customerStatus=function(e){g.CS.team(this.id).customerStatus(e)},e.prototype.accept=function(e){g.CS.team(this.id).accept(e)},e.prototype.end=function(e){g.CS.team(this.id).end(e)},e.prototype.history=function(e){g.CS.team(this.id).history(e)},e.prototype.markMessageAsRead=function(e){g.CS.team(this.id).markMessageAsRead(e)},e.prototype.createTextMessage=function(e){g.CS.team(this.id).createTextMessage(e)},e.prototype.createImageMessage=function(e){g.CS.team(this.id).createImageMessage(e)},e.prototype.createFileMessage=function(e){g.CS.team(this.id).createFileMessage(e)},e.prototype.createAudioMessage=function(e){g.CS.team(this.id).createAudioMessage(e)},e.prototype.createVideoMessage=function(e){g.CS.team(this.id).createVideoMessage(e)},e.prototype.createCustomMessage=function(e){g.CS.team(this.id).createCustomMessage(e)},e.prototype.transfer=function(e){g.CS.team(this.id).transfer(e)},e.prototype.agents=function(e){g.CS.team(this.id).agents(e)},e.prototype.liveSession=function(e){g.CS.team(this.id).liveSession(e)},e.prototype.quitLiveSession=function(e){g.CS.team(this.id).quitLiveSession(e)},e.prototype.listenCustomer=function(e){g.CS.team(this.id).listenCustomer(e)},e.prototype.cancelListenCustomer=function(e){g.CS.team(this.id).cancelListenCustomer(e)},e}();e.CSTeam=I}(o),t(o)}));