!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={},i={};function r(){r=function(){return t};var e,t={},n=Object.prototype,o=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",c=s.asyncIterator||"@@asyncIterator",u=s.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function f(e,t,n,o){var r=t&&t.prototype instanceof v?t:v,s=Object.create(r.prototype),a=new P(o||[]);return i(s,"_invoke",{value:T(e,n,a)}),s}function p(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var d="suspendedStart",h="suspendedYield",m="executing",y="completed",g={};function v(){}function S(){}function E(){}var _={};l(_,a,(function(){return this}));var M=Object.getPrototypeOf,b=M&&M(M(A([])));b&&b!==n&&o.call(b,a)&&(_=b);var C=E.prototype=v.prototype=Object.create(_);function w(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function n(i,r,s,a){var c=p(e[i],e,r);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&o.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,s,a)}),(function(e){n("throw",e,s,a)})):t.resolve(l).then((function(e){u.value=e,s(u)}),(function(e){return n("throw",e,s,a)}))}a(c.arg)}var r;i(this,"_invoke",{value:function(e,o){function i(){return new t((function(t,i){n(e,o,t,i)}))}return r=r?r.then(i,i):i()}})}function T(t,n,o){var i=d;return function(r,s){if(i===m)throw new Error("Generator is already running");if(i===y){if("throw"===r)throw s;return{value:e,done:!0}}for(o.method=r,o.arg=s;;){var a=o.delegate;if(a){var c=k(a,o);if(c){if(c===g)continue;return c}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(i===d)throw i=y,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);i=m;var u=p(t,n,o);if("normal"===u.type){if(i=o.done?y:h,u.arg===g)continue;return{value:u.arg,done:o.done}}"throw"===u.type&&(i=y,o.method="throw",o.arg=u.arg)}}}function k(t,n){var o=n.method,i=t.iterator[o];if(i===e)return n.delegate=null,"throw"===o&&t.iterator.return&&(n.method="return",n.arg=e,k(t,n),"throw"===n.method)||"return"!==o&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+o+"' method")),g;var r=p(i,t.iterator,n.arg);if("throw"===r.type)return n.method="throw",n.arg=r.arg,n.delegate=null,g;var s=r.arg;return s?s.done?(n[t.resultName]=s.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):s:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function N(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function R(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(N,this),this.reset(!0)}function A(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,r=function n(){for(;++i=0;--r){var s=this.tryEntries[r],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var c=o.call(s,"catchLoc"),u=o.call(s,"finallyLoc");if(c&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&o.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),R(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var o=n.completion;if("throw"===o.type){var i=o.arg;R(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,o){return this.delegate={iterator:A(t),resultName:n,nextLoc:o},"next"===this.method&&(this.arg=e),g}},t}function s(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function a(e){return a="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},a(e)}function c(e,t,n,o,i,r,s){try{var a=e[r](s),c=a.value}catch(e){return void n(e)}a.done?t(c):Promise.resolve(c).then(o,i)}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,o=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,s=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return s=e.done,e},e:function(e){a=!0,r=e},f:function(){try{s||null==n.return||n.return()}finally{if(a)throw r}}}}var y={},g=function(e,t){return g=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])},g(e,t)};function v(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}g(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var S=function(){return S=Object.assign||function(e){for(var t,n=1,o=arguments.length;n=0;c--)(i=e[c])&&(s=(r<3?i(s):r>3?i(t,n,s):i(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s}function M(e,t){return function(n,o){t(n,o,e)}}function b(e,t){if("object"===("undefined"==typeof Reflect?"undefined":a(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function C(e,t,n,o){return new(n||(n=Promise))((function(i,r){function s(e){try{c(o.next(e))}catch(e){r(e)}}function a(e){try{c(o.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((o=o.apply(e,t||[])).next())}))}function w(e,t){var n,o,i,r,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;r&&(r=0,a[0]&&(s=0)),s;)try{if(n=1,o&&(i=2&a[0]?o.return:a[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,a[1])).done)return i;switch(o=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function N(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,i,r=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(o=r.next()).done;)s.push(o.value)}catch(e){i={error:e}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s}function R(){for(var e=[],t=0;t1||a(e,t)}))})}function a(e,t){try{!function(e){e.value instanceof O?Promise.resolve(e.value.v).then(c,u):l(r[0][2],e)}(i[e](t))}catch(e){l(r[0][3],e)}}function c(e){a("next",e)}function u(e){a("throw",e)}function l(e,t){e(t),r.shift(),r.length&&a(r[0][0],r[0][1])}}function x(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,i){t[o]=e[o]?function(t){return(n=!n)?{value:O(e[o](t)),done:!1}:i?i(t):t}:i}}function G(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=k(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,i){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,i,(t=e[n](t)).done,t.value)}))}}}function U(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}var L=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t};function F(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)&&I(t,e,n);return L(t,e),t}function B(e){return e&&e.__esModule?e:{default:e}}function q(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)}function j(e,t,n,o,i){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?i.call(e,n):i?i.value=n:t.set(e,n),n}function V(e,t){if(null===t||"object"!==a(t)&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function H(e,t,n){if(null!=t){if("object"!==a(t)&&"function"!=typeof t)throw new TypeError("Object expected.");var o;if(n){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");o=t[Symbol.asyncDispose]}if(void 0===o){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");o=t[Symbol.dispose]}if("function"!=typeof o)throw new TypeError("Object not disposable.");e.stack.push({value:t,dispose:o,async:n})}else n&&e.stack.push({async:!0});return t}var z="function"==typeof SuppressedError?SuppressedError:function(e,t,n){var o=new Error(n);return o.name="SuppressedError",o.error=e,o.suppressed=t,o};function W(e){function t(t){e.error=e.hasError?new z(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}return function n(){for(;e.stack.length;){var o=e.stack.pop();try{var i=o.dispose&&o.dispose.call(o.value);if(o.async)return Promise.resolve(i).then(n,(function(e){return t(e),n()}))}catch(e){t(e)}}if(e.hasError)throw e.error}()}var J={__extends:v,__assign:S,__rest:E,__decorate:_,__param:M,__metadata:b,__awaiter:C,__generator:w,__createBinding:I,__exportStar:T,__values:k,__read:N,__spread:R,__spreadArrays:P,__spreadArray:A,__await:O,__asyncGenerator:D,__asyncDelegator:x,__asyncValues:G,__makeTemplateObject:U,__importStar:F,__importDefault:B,__classPrivateFieldGet:q,__classPrivateFieldSet:j,__classPrivateFieldIn:V,__addDisposableResource:H,__disposeResources:W},X=Object.freeze({__proto__:null,__extends:v,get __assign(){return S},__rest:E,__decorate:_,__param:M,__esDecorate:function(e,t,n,o,i,r){function s(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var c,u=o.kind,l="getter"===u?"get":"setter"===u?"set":"value",f=!t&&e?o.static?e:e.prototype:null,p=t||(f?Object.getOwnPropertyDescriptor(f,o.name):{}),d=!1,h=n.length-1;h>=0;h--){var m={};for(var y in o)m[y]="access"===y?{}:o[y];for(var y in o.access)m.access[y]=o.access[y];m.addInitializer=function(e){if(d)throw new TypeError("Cannot add initializers after decoration has completed");r.push(s(e||null))};var g=(0,n[h])("accessor"===u?{get:p.get,set:p.set}:p[l],m);if("accessor"===u){if(void 0===g)continue;if(null===g||"object"!==a(g))throw new TypeError("Object expected");(c=s(g.get))&&(p.get=c),(c=s(g.set))&&(p.set=c),(c=s(g.init))&&i.unshift(c)}else(c=s(g))&&("field"===u?i.unshift(c):p[l]=c)}f&&Object.defineProperty(f,o.name,p),d=!0},__runInitializers:function(e,t,n){for(var o=arguments.length>2,i=0;i=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.prototype.isNull=function(e){return null===e},e}(),n=new t;e.default=n}(te);var ne={};!function(e){e.__esModule=!0,e.Platform=e.PlatformDetector=e.PlatformType=void 0;var t,n=Q,o=i;!function(e){e.MP_WX="mp-wx",e.MP_WGAME="mp-wgame",e.MP_BYTE="mp-byte",e.MP_BAIDU="mp-baidu",e.MP_ALI="mp-ali",e.BROWSER="browser",e.NODE="node",e.UNI_IOS="uni-ios",e.UNI_ANDROID="uni-android",e.COCOS_IOS="cocos-ios",e.COCOS_ANDROID="cocos-android",e.RN_IOS="rn-ios",e.RN_ANDROID="rn-android",e.UNKNOWN="unknown"}(t=e.PlatformType||(e.PlatformType={}));var r=function(){function e(){var e,o,i;this.platform=null,this.methods=((e={})[t.BROWSER]=this.isBrowser,e[t.MP_WX]=this.isMPWX,e[t.MP_WGAME]=this.isMPWeGame,e[t.MP_BYTE]=this.isMPByte,e[t.MP_BAIDU]=this.isMPBaidu,e[t.MP_ALI]=this.isMPAli,e[t.NODE]=this.isNode,e[t.UNI_IOS]=this.isUniAppIOS,e[t.UNI_ANDROID]=this.isUniAppAndroid,e[t.COCOS_IOS]=this.isCocosIOS,e[t.COCOS_ANDROID]=this.isCocosAndroid,e[t.RN_IOS]=this.isRNiOS,e[t.RN_ANDROID]=this.isRNAndroid,e);var r=this.methods,s=Object.keys(r);try{for(var a=n.__values(s),c=a.next();!c.done;c=a.next()){var u=c.value;if((0,r[u])()){this.platform=u;break}}}catch(e){o={error:e}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}this.platform=this.platform||t.UNKNOWN,this.platform}return e.currentPlatform=function(){return this.instance||(this.instance=new e),e.instance.platform},e.prototype.isBrowser=function(){return"undefined"!=typeof navigator&&"Taro"!==navigator.product&&"ReactNative"!==navigator.product&&"undefined"==typeof GameGlobal&&("undefined"==typeof cc||null!==cc.sys.browserType)&&"undefined"==typeof my&&"undefined"==typeof tt&&"undefined"==typeof swan},e.prototype.isMPWX=function(){return"object"===("undefined"==typeof wx?"undefined":a(wx))&&"function"==typeof wx.getSystemInfoSync&&"undefined"==typeof WebSocket&&"undefined"==typeof XMLHttpRequest&&"undefined"==typeof plus&&"undefined"==typeof tt},e.prototype.isMPWeGame=function(){return"object"===("undefined"==typeof GameGlobal?"undefined":a(GameGlobal))},e.prototype.isMPByte=function(){return"object"===("undefined"==typeof tt?"undefined":a(tt))&&"function"==typeof tt.getSystemInfoSync},e.prototype.isMPBaidu=function(){return"object"===("undefined"==typeof swan?"undefined":a(swan))&&"function"==typeof swan.getSystemInfoSync},e.prototype.isMPAli=function(){return"object"===("undefined"==typeof my?"undefined":a(my))&&"function"==typeof my.getSystemInfoSync},e.prototype.isNode=function(){try{return"node"===process.release.name}catch(e){return!1}},e.prototype.isUniAppIOS=function(){try{return"ios"===uni.getSystemInfoSync().platform&&"app"===uni.getSystemInfoSync().uniPlatform}catch(e){return!1}},e.prototype.isUniAppAndroid=function(){try{return"android"===uni.getSystemInfoSync().platform&&"app"===uni.getSystemInfoSync().uniPlatform}catch(e){return!1}},e.prototype.isCocosIOS=function(){try{return"iOS"===cc.sys.os}catch(e){return!1}},e.prototype.isCocosAndroid=function(){try{return"Android"===cc.sys.os}catch(e){return!1}},e.prototype.isRNiOS=function(){try{return"ios"===o.RNPlugins.platform.OS}catch(e){return!1}},e.prototype.isRNAndroid=function(){try{return"android"===o.RNPlugins.platform.OS}catch(e){return!1}},e}();e.PlatformDetector=r;var s=function(){function e(){}return e.type=t,e.current=r.currentPlatform(),e}();e.Platform=s}(ne);var oe={__esModule:!0,runStatus:void 0},ie=Q,re=ne,se=function(){function e(){var e=this;[new ce,new ue].forEach((function(t){if(t.support())return e.checker=t,void e.checker.startCheck()}))}return e.prototype.isBackend=function(){return this.checker&&this.checker.isBackend()},e.prototype.onFrontend=function(e){this.checker.onFrontend(e)},e}(),ae=function(){function e(){}return e.prototype.onFrontend=function(e){this.onFrontendCallback=e},e}(),ce=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.runningBackend=!1,t}return ie.__extends(t,e),t.prototype.startCheck=function(){var e=this;"object"===("undefined"==typeof plus?"undefined":a(plus))&&(plus.globalEvent.addEventListener("resume",(function(){e.runningBackend=!1,e.runningBackend,e.onFrontendCallback&&e.onFrontendCallback()}),!1),plus.globalEvent.addEventListener("pause",(function(){e.runningBackend=!0,e.runningBackend}),!1))},t.prototype.isBackend=function(){return this.runningBackend},t.prototype.support=function(){var e=re.PlatformDetector.currentPlatform();return[re.PlatformType.UNI_IOS,re.PlatformType.UNI_ANDROID].includes(e)},t}(ae),ue=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.runningBackend=!1,t}return ie.__extends(t,e),t.prototype.startCheck=function(){var e=this;wx.onAppShow((function(){e.runningBackend=!1})),wx.onAppHide((function(){e.runningBackend=!0}))},t.prototype.isBackend=function(){return this.runningBackend},t.prototype.support=function(){return re.PlatformDetector.currentPlatform()===re.PlatformType.MP_WX},t}(ae),le=new se;oe.runStatus=le;var fe={};!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.PUBSUB_PRESENCE_SUBSCRIBE="PUBSUB_PRESENCE_SUBSCRIBE",e.PUBSUB_PRESENCE_UNSUBSCRIBE="PUBSUB_PRESENCE_UNSUBSCRIBE",e.PUBSUB_PRESENCE_HERENOW="PUBSUB_PRESENCE_HERENOW",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.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.SET_IOS_BADGE="SET_IOS_BADGE",e.MD_CMD="MD_CMD"}(e.RocketTypes||(e.RocketTypes={}))}(fe);var pe={};!function(e){e.__esModule=!0,e.SocketTimeout=void 0,function(e){e[e.connect=3e3]="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={}))}(pe);var de={__esModule:!0,CallbackUtils:void 0},he=te,me=function(){function e(){}return e.onSuccess=function(e,t){he.default.isFunction(e.onSuccess)&&e.onSuccess(t)},e.onFailed=function(e,t){if(!he.default.isObject(e)||!he.default.isFunction(e.onFailed))throw t;e.onFailed(t)},e}();de.CallbackUtils=me;var ye={},ge={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 i=0;i>>((3&t)<<3)&255;return Me}}for(var be=[],Ce=0;Ce<256;++Ce)be[Ce]=(Ce+256).toString(16).substr(1);var we,Ie,Te=function(e,t){var n=t||0,o=be;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("")},ke=Se.exports,Ne=Te,Re=0,Pe=0;var Ae=function(e,t,n){var o=t&&n||0,i=t||[],r=(e=e||{}).node||we,s=void 0!==e.clockseq?e.clockseq:Ie;if(null==r||null==s){var a=ke();null==r&&(r=we=[1|a[0],a[1],a[2],a[3],a[4],a[5]]),null==s&&(s=Ie=16383&(a[6]<<8|a[7]))}var c=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:Pe+1,l=c-Re+(u-Pe)/1e4;if(l<0&&void 0===e.clockseq&&(s=s+1&16383),(l<0||c>Re)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Re=c,Pe=u,Ie=s;var f=(1e4*(268435455&(c+=122192928e5))+u)%4294967296;i[o++]=f>>>24&255,i[o++]=f>>>16&255,i[o++]=f>>>8&255,i[o++]=255&f;var p=c/4294967296*1e4&268435455;i[o++]=p>>>8&255,i[o++]=255&p,i[o++]=p>>>24&15|16,i[o++]=p>>>16&255,i[o++]=s>>>8|128,i[o++]=255&s;for(var d=0;d<6;++d)i[o+d]=r[d];return t||Ne(i)},Oe=Se.exports,De=Te;var xe=function(e,t,n){var o=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Oe)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var r=0;r<16;++r)t[o+r]=i[r];return t||De(i)},Ge=Ae,Ue=xe,Le=Ue;Le.v1=Ge,Le.v4=Ue;var Fe=Le,Be=function(){function e(){u(this,e)}return f(e,[{key:"support",value:function(){return!0}},{key:"getParams",value:function(){return this.params}},{key:"setData",value:function(e){this.active=e.a,this.data=e.d}},{key:"preConnect",value:function(e){}},{key:"postConnect",value:function(){}}]),e}(),qe=function(){function e(){u(this,e)}return f(e,null,[{key:"initModule",value:function(e){e.support()&&this.modules.set(e.name,e)}},{key:"getParams",value:function(){return C(this,void 0,void 0,r().mark((function e(){var t,n,o,i,s,a;return r().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t={},n=m(this.modules),e.prev=2,n.s();case 4:if((o=n.n()).done){e.next=14;break}return i=p(o.value,2),s=i[0],a=i[1],e.next=8,a.getParams();case 8:if(e.t0=e.sent,e.t0){e.next=11;break}e.t0=null;case 11:t[s]=e.t0;case 12:e.next=4;break;case 14:e.next=19;break;case 16:e.prev=16,e.t1=e.catch(2),n.e(e.t1);case 19:return e.prev=19,n.f(),e.finish(19);case 22:return e.abrupt("return",t);case 23:case"end":return e.stop()}}),e,this,[[2,16,19,22]])})))}},{key:"setDatas",value:function(e){var t=this;Object.keys(e).forEach((function(n){t.modules.get(n).setData(e[n])}))}},{key:"preConnect",value:function(e){this.modules.forEach((function(t,n){t.preConnect(e)}))}},{key:"postConnect",value:function(){this.modules.forEach((function(e,t){e.postConnect()}))}}]),e}();qe.Module=Be,qe.modules=new Map;var je,Ve,He=ve,ze=function(){function e(){u(this,e),this.emitter=new He}return f(e,[{key:"on",value:function(e,t){return this.emitter.on(e,t),this}},{key:"once",value:function(e,t){return this.emitter.once(e,t),this}},{key:"off",value:function(e,t){return this.emitter.off(e,t),this}},{key:"fire",value:function(e,t){return this.emitter.emit(e,t),this}}]),e}(),We=function(){function e(){u(this,e),this.eventDriver=new ze}return f(e,[{key:"on",value:function(e,t){this.eventDriver.on(e,t)}},{key:"off",value:function(e,t){this.eventDriver.off(e,t)}},{key:"fire",value:function(e,t){this.eventDriver.fire(e,t)}}]),e}(),Je=new(function(){function e(){u(this,e)}return f(e,[{key:"isDef",value:function(e){return!this.isUndef(e)}},{key:"isUndef",value:function(e){return null==e}},{key:"isPrimitive",value:function(e){return"string"==typeof e||"number"==typeof e||"symbol"==a(e)||"boolean"==typeof e}},{key:"isObject",value:function(e){return null!==e&&"object"==a(e)}},{key:"isPlainObject",value:function(e){return"[object Object]"===Object.prototype.toString.call(e)}},{key:"isRegExp",value:function(e){return"[object RegExp]"===Object.prototype.toString.call(e)}},{key:"isValidArrayIndex",value:function(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}},{key:"isString",value:function(e){return"string"==typeof e}},{key:"isNumber",value:function(e){return"number"==typeof e}},{key:"isStringOrNumber",value:function(e){return this.isString(e)||this.isNumber(e)}},{key:"isArray",value:function(e){return"[object Array]"===Object.prototype.toString.call(e)}},{key:"isEmpty",value:function(e){return this.isArray(e)?0===e.length:this.isObject(e)?!this.isDef(e):!this.isNumber(e)&&(this.isString(e)?""===e.trim():!this.isDef(e))}},{key:"isNative",value:function(e){return"function"==typeof e&&/native code/.test(e.toString())}},{key:"isFunction",value:function(e){return"function"==typeof e}},{key:"isBoolean",value:function(e){return"boolean"==typeof e}},{key:"isTrue",value:function(e){return!0===e}},{key:"isFalse",value:function(e){return!1===e}},{key:"isNull",value:function(e){return null===e}}]),e}()),Xe=ve,Qe=function(){function e(){u(this,e),this.emitter=new Xe}return f(e,[{key:"on",value:function(e,t){if(!Je.isString(e))throw Error("event require a string.");if(!Je.isFunction(t))throw Error("callback must be a function");this.emitter.on(e,t)}},{key:"fire",value:function(e,t){this.emitter.emit(e,t)}},{key:"off",value:function(e,t){this.emitter.off(e,t)}}]),e}(),Ye=function(){function e(){u(this,e)}return f(e,null,[{key:"init",value:function(e,t,n,o,i,r){this.Socket=e,this.N=t,this.Member=n,this.v=o,this.Platform=i,this.GModules=r}}]),e}(),Ke=Fe,$e=function(){function e(){u(this,e)}return f(e,null,[{key:"get",value:function(){return Ke.v1().replace(/-/g,"")}}]),e}();(Ve=je||(je={})).WRITE="WRITE",Ve.READ="READ",Ve.NONE="NONE";var Ze=function(){function e(t){var n=this;u(this,e),this.permission=je.NONE,this.singleTimeout=0,this.totalTimeout=0,this.startTime=0,this.complete=!1,this.retried=0,this.unique=!1,this.uuid=$e.get(),this.name=t.name,this.params=t.params,this.permission=t.permission,this.totalTimeout=t.totalTimeout,this.singleTimeout=t.singleTimeout,t.unique&&(this.unique=t.unique),this.success=function(e){n.complete||(n.end(),t.success(e))},this.fail=function(e){n.complete||(n.end(),t.fail(e))}}return f(e,[{key:"start",value:function(){this.startTime=Date.now(),this.initAutoTimeout()}},{key:"end",value:function(){this.complete=!0,clearTimeout(this.timeoutHandler)}},{key:"initAutoTimeout",value:function(){var e=this;this.timeoutHandler=setTimeout((function(){e.complete||e.fail({resultCode:408,content:"Host unreachable or timeout"})}),this.totalTimeout)}}]),e}(),et=n(Object.freeze({__proto__:null,AbstractEventCenter:We,ApiEventCenter:Qe,EmitterEventDriver:ze,G:Ye,GModule:Be,GModules:qe,get Permission(){return je},Rocket:Ze,UUID:$e}));ye.__esModule=!0,ye.GNModule=void 0;var nt=Q,ot=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return nt.__extends(t,e),t.init=function(){return this.module=new t,this.module.name=this.GN_MODULE_NAME,this.module},t.setRegId=function(e,t){if(e){this.module.regIdPromise=e;var n=t;this.module.params={v:{npv:n}}}},t.prototype.preConnect=function(e){this.wxmpId=e.wxmpId},t.prototype.getParams=function(){return nt.__awaiter(this,void 0,void 0,(function(){var e,t;return nt.__generator(this,(function(n){switch(n.label){case 0:if(this.params=this.params||{},!this.regIdPromise)return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),e=this.params,[4,this.regIdPromise];case 2:return e.regId=n.sent(),[3,4];case 3:return t=n.sent(),console.warn("Failed to register the Manufacturers Push service:"+JSON.stringify(t)),[3,4];case 4:return this.params.wxmpId=this.wxmpId,[2,this.params]}}))}))},t.GN_MODULE_NAME="GN",t}(et.GModule);ye.GNModule=ot,ee.__esModule=!0,ee.GN=void 0;var it=te,rt=ne,st=oe,at=fe,ct=pe,ut=de,lt=ye,ft=et,pt=function(){function e(){}return e.init=function(){var e=lt.GNModule.init();ft.GModules.initModule(e),this.supportAppNotification()&&(this.uniappPlugin=uni.requireNativePlugin("GoEasy-Uniapp"),this.uniappPlugin?(this.regIdPromise=this.askRegId(),this.v=this.uniappPlugin.v(),lt.GNModule.setRegId(this.regIdPromise,this.v)):console.warn("No GoEasy-Uniapp Native Plugin."),this.setClientBadge(0))},e.addAssembler=function(e){this.payloadAssemblers.push(e)},e.assemblePayload=function(e){var t=this.payloadAssemblers.find((function(t){return t.support(e)}));return t?t.assemble(e):e},e.createLocalNotification=function(t,n,o,i,r){st.runStatus.isBackend()&&(o.g=1,"undefined"!=typeof plus&&(i?(this.uniappPlugin&&this.uniappPlugin.playSound(i),plus.push.createMessage(n,JSON.stringify(o),{title:t,sound:"none"})):plus.push.createMessage(n,JSON.stringify(o),{title:t}),"+1"===r&&this.setClientBadge(e.badge+1)))},e.setBadge=function(t){var n=this;if(!Number.isInteger(t.badge)||t.badge<0)ut.CallbackUtils.onFailed(t,"badge must be an integer greater than or equal to 0.");else if(e.supportAppNotification())if(this.uniappPlugin&&rt.PlatformDetector.currentPlatform()===rt.PlatformType.UNI_IOS){var o=new ft.Rocket({name:at.RocketTypes.SET_IOS_BADGE,params:{badge:t.badge},unique:!0,singleTimeout:ct.SocketTimeout.commonRequestSingle,totalTimeout:ct.SocketTimeout.commonRequestTotal,permission:ft.Permission.WRITE,success:function(){ut.CallbackUtils.onSuccess(t),n.setClientBadge(t.badge)},fail:function(e){ut.CallbackUtils.onFailed(t,e.content)}});ft.G.Socket.e(o)}else ut.CallbackUtils.onSuccess(t),this.setClientBadge(t.badge)},e.setClientBadge=function(t){"vivo"!==plus.device.vendor&&(e.badge=t,plus.runtime.setBadgeNumber(t))},e.askRegId=function(){var e=this,t=null,n=0,o=function o(){return new Promise((function(i,r){e.uniappPlugin.regId((function(e){i(e)}),(function(i){if(!(1e6===i.data.code&&n<=10))return clearTimeout(t),r(i);t=setTimeout((function(){n++,e.regIdPromise=o()}),3500)}))}))}();return o},e.getRegIdPromise=function(){return this.regIdPromise},e.supportAppNotification=function(){var e=rt.PlatformDetector.currentPlatform();return e===rt.PlatformType.UNI_ANDROID||e===rt.PlatformType.UNI_IOS},e.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.availableIntent=function(e){return e&&Object.keys(e).length&&e.g&&1===parseInt(e.g)},e.getIntentData=function(){var e=this;this.uniappPlugin.getIntentData((function(t){if(e.availableIntent(t)){var n=e.assemblePayload(t),o=rt.PlatformDetector.currentPlatform();plus.push.clear(),o===rt.PlatformType.UNI_ANDROID&&e.uniappPlugin.clearAll(),e.onClickNotificationCallback(n)}}))},e.listenClick=function(){var e=this;this.listenPlusClickNotification();var t=rt.PlatformDetector.currentPlatform();this.uniappPlugin&&t===rt.PlatformType.UNI_ANDROID&&(this.getIntentData(),st.runStatus.onFrontend((function(){e.getIntentData()})))},e.onClickNotification=function(t){if(e.supportAppNotification()){if(!it.default.isFunction(t))throw new Error("The arguments must be a function.");null===this.onClickNotificationCallback?(this.onClickNotificationCallback=t,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.uniappPlugin=null,e.v=null,e.regIdPromise=null,e.onClickNotificationCallback=null,e.payloadAssemblers=new Array,e}();ee.GN=pt;var dt={},ht={},mt={},yt={};!function(e){e.__esModule=!0,e.default=function(){}}(yt);var gt={};!function(e){e.__esModule=!0;var t=te,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.isString(e))throw{code:400,content:"TypeError: ".concat(n," require string.")}},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>100)throw{code:400,content:"".concat(n," is over max length 100.")};for(var o=0;o1e4)throw{code:400,content:"Message over max length 10000."};if(e.qos&&!(e.qos in[0,1]))throw{code:400,content:"Qos must be 0 or 1."};e.wxmpTemplateMsg&&r.default.validateWXMPTemplateMsg(e.wxmpTemplateMsg),n.default.isDef(e.notification)&&r.default.validateNotification(e.notification)},e}();e.default=c}(mt);var St={},Et={__esModule:!0,Subscription:void 0},_t=te,Mt=function(e){if(this.options=e,this.channels=e.channels||[e.channel],!_t.default.isEmpty(e.channel)){var t=e.channel.toString();this.channels=[t]}_t.default.isEmpty(e.channels)||(this.channels=e.channels.toString().split(","))};Et.Subscription=Mt;var bt={};!function(e){e.__esModule=!0,e.RemoteEvents=void 0,function(e){e.message="message",e.imMessage="imMessage",e.userPresence="userPresence",e.groupPresence="groupPresence",e.PS_PRESENCE_EVENT="PS_PRESENCE_EVENT",e.IM_MSG_READ="IM_MSG_READ",e.IM_MSG_DELETED="IM_MSG_DELETED",e.IM_MSG_RECALLED="IM_MSG_RECALLED",e.CS_ONLINE_CHANGED="CS_ONLINE_CHANGED"}(e.RemoteEvents||(e.RemoteEvents={}))}(bt);var Ct={};!function(e){e.__esModule=!0,e.SocketEvent=void 0,function(e){e.CONNECTED="CONNECTED",e.RECONNECTED="RECONNECTED",e.DISCONNECTED="DISCONNECTED",e.LOST="LOST",e.EXPIRED_RECONNECTED="EXPIRED_RECONNECTED",e.NEW_MESSAGE="NEW_MESSAGE",e.CONNECTING="CONNECTING"}(e.SocketEvent||(e.SocketEvent={}))}(Ct),St.__esModule=!0,St.Subscriber=void 0;var wt=te,It=Et,Tt=pe,kt=fe,Nt=bt,Rt=gt,Pt=et,At=de,Ot=Ct,Dt=function(){function e(){this.subscriptions=[],Pt.G.Socket.onMessage(Nt.RemoteEvents.message,this.onNewMessage.bind(this)),Pt.G.Socket.on(Ot.SocketEvent.EXPIRED_RECONNECTED,this.expiredResubscribe.bind(this)),Pt.G.Socket.on(Ot.SocketEvent.CONNECTED,this.resubscribePresenceChannel.bind(this))}return e.prototype.expiredResubscribe=function(){var e=this;this.subscriptions.forEach((function(t){e.doSubscribe(t,!1)}))},e.prototype.resubscribePresenceChannel=function(){var e=this;this.subscriptions.forEach((function(t){var n=t.options;n.presence&&n.presence.enable&&e.doSubscribe(t,!0)}))},e.prototype.onNewMessage=function(e){if(!(e.n.indexOf("_presence")>-1)){e.a&&Pt.G.Socket.sendAck("ack",{i:e.i,c:e.n});var t={time:e.t,channel:e.n,content:e.c};this.createNotification(e),this.findSubscriptionByChannel(t.channel).options.onMessage(t)}},e.prototype.createNotification=function(e){var t=Pt.G.N.supportAppNotification();if(wt.default.isObject(e.nt)&&t){var n={ch:e.n,ctt:e.c};Pt.G.N.createLocalNotification(e.nt.t,e.nt.c,n,e.nt.sound,e.nt.badge)}},e.prototype.subscribe=function(e){var t=this;if(Rt.default.validateChannelAndChannels(e.channel,e.channels),wt.default.isDef(e.presence)){var n=e.presence.enable;if(!wt.default.isBoolean(n))throw{code:400,content:"Subscription failed. presence.enable must be a boolean"};if(n&&!Pt.G.Socket.user().id)throw{code:400,content:"Subscription failed. If presence is enable, the id must be specified when calling the connect method"}}var o=new It.Subscription(e);this.doSubscribe(o,!1).then((function(){t.subscriptions.push(o),At.CallbackUtils.onSuccess(e,{code:200,content:"ok"})})).catch((function(t){At.CallbackUtils.onFailed(e,{code:t.resultCode,content:t.content})}))},e.prototype.doSubscribe=function(e,t){var n=e.options;return new Promise((function(o,i){var r=new Pt.Rocket({name:kt.RocketTypes.subscribe,permission:Pt.Permission.READ,singleTimeout:Tt.SocketTimeout.commonRequestSingle,totalTimeout:Tt.SocketTimeout.commonRequestTotal,params:{channels:e.channels,accessToken:n.accessToken,presence:n.presence,resubscribe:t},success:function(){o()},fail:function(e){i(e)}});Pt.G.Socket.e(r)}))},e.prototype.unsubscribe=function(e){var t=this;Rt.default.validateChannel(e.channel,"channel"),e.channel=e.channel.toString();var n=this.findSubscriptionByChannel(e.channel);if(n){var o=new Pt.Rocket({name:kt.RocketTypes.unsubscribe,params:{channel:e.channel,presence:n.options.presence},permission:Pt.Permission.READ,singleTimeout:Tt.SocketTimeout.commonRequestSingle,totalTimeout:Tt.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})}});Pt.G.Socket.e(o)}else e.onFailed({code:400,content:"channel["+e.channel+"] is not subscribed"})},e.prototype.removeChannel=function(e){for(var t=this.subscriptions.length-1;t>=0;t--){var n=this.subscriptions[t].channels,o=n.indexOf(e);if(o>-1){n.splice(o,1),0===n.length&&this.subscriptions.splice(t,1);break}}},e.prototype.findSubscriptionByChannel=function(e){for(var t=!1,n=null,o=this.subscriptions.length-1;o>=0;o--){for(var i=this.subscriptions[o].channels,r=0;rn.membersLimit&&n.doQuery(e.limit),t=n.queryPromise):t=en(e.channel,e.limit),t.then((function(t){e.onSuccess(t)})).catch((function(t){e.onFailed(t)}))},e.prototype.subscribe=function(e){if(Kt.default.validateChannel(e.channel,"channel"),Qt.default.isUndef(e.onPresence)||!Qt.default.isFunction(e.onPresence))throw{code:400,content:"Subscription Presence failed. onPresence callback function is required"};var t=e.channel.toString(),n=this.channelPresenceMap.get(t);n||(n=new Zt(t),this.channelPresenceMap.set(t,n)),n.subscribe(e)},e.prototype.unsubscribe=function(e){var t=this;Kt.default.validateChannel(e.channel,"channel");var n=e.channel.toString();if(this.channelPresenceMap.get(n)){var o=new zt.Rocket({name:Xt.RocketTypes.PUBSUB_PRESENCE_UNSUBSCRIBE,permission:zt.Permission.READ,singleTimeout:Wt.SocketTimeout.commonRequestSingle,totalTimeout:Wt.SocketTimeout.commonRequestTotal,params:{channel:n},success:function(o){t.channelPresenceMap.delete(n),e.onSuccess()},fail:function(t){e.onFailed(t)}});zt.G.Socket.e(o)}else e.onSuccess()},e}();Vt.PresenceService=$t;var Zt=function(){function e(e){this.membersLimit=10,this.queried=!1,this.channel=e}return e.prototype.onPresence=function(e){return Ht.__awaiter(this,void 0,void 0,(function(){return Ht.__generator(this,(function(t){switch(t.label){case 0:return this.queried?(this.update(e),[3,3]):[3,1];case 1:return[4,this.queryPromise];case 2:t.sent(),t.label=3;case 3:return this.on({channel:this.channel,action:e.action,member:e.member,time:e.time,amount:this.amount,members:this.membersByLimit()}),[2]}}))}))},e.prototype.membersByLimit=function(){return this.members.slice(0,this.membersLimit)},e.prototype.subscribe=function(e){return Ht.__awaiter(this,void 0,void 0,(function(){var t;return Ht.__generator(this,(function(n){switch(n.label){case 0:if(e.membersLimit&&(this.membersLimit=Math.min(e.membersLimit,300)),this.subscribed())return[3,4];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.doSubscribe()];case 2:return n.sent(),[3,4];case 3:return t=n.sent(),e.onFailed(t),[2];case 4:return this.on=e.onPresence,e.onSuccess(),[2]}}))}))},e.prototype.doSubscribe=function(){var e=this;return this.doQuery(this.membersLimit),new Promise((function(t,n){var o=new zt.Rocket({name:Xt.RocketTypes.PUBSUB_PRESENCE_SUBSCRIBE,permission:zt.Permission.READ,params:{channel:e.channel},singleTimeout:Wt.SocketTimeout.commonRequestSingle,totalTimeout:Wt.SocketTimeout.commonRequestTotal,success:function(e){t()},fail:function(e){n(e)}});zt.G.Socket.e(o)}))},e.prototype.doQuery=function(e){var t=this;this.queryPromise=en(this.channel,e),this.queryPromise.then((function(e){t.members=e.content.members,t.amount=e.content.amount,t.queried=!0})).catch((function(e){throw e}))},e.prototype.update=function(e){if(["join","back"].includes(e.action))this.members.unshift(e.member);else if(["leave","timeout"].includes(e.action)){var t=this.members.findIndex((function(t){return t.id===e.member.id}));t>-1&&this.members.splice(t,1)}this.amount=e.amount},e.prototype.expire=function(){this.queried=!1,this.queryPromise=null},e.prototype.subscribed=function(){return void 0!==this.on},e}();function en(e,t){return t||(t=10),new Promise((function(n,o){var i={channel:e,limit:t},r=new zt.Rocket({name:Xt.RocketTypes.PUBSUB_PRESENCE_HERENOW,permission:zt.Permission.READ,params:i,singleTimeout:Wt.SocketTimeout.commonQuerySingle,totalTimeout:Wt.SocketTimeout.commonQueryTotal,success:function(e){n(e)},fail:function(e){o(e)}});zt.G.Socket.e(r)}))}Vt.ChannelPresence=Zt,ht.__esModule=!0,ht.PubSub=void 0;var tn=mt,nn=St,on=xt,rn=Vt,sn=function(){function e(){this.publisher=new tn.default,this.subscriber=new nn.Subscriber,this.presence2=new rn.PresenceService,this.histories=new on.History}return e.init=function(){this.instance=new e},e.prototype.publish=function(e){this.publisher.publish(e)},e.prototype.subscribe=function(e){this.subscriber.subscribe(e)},e.prototype.unsubscribe=function(e){this.subscriber.unsubscribe(e)},e.prototype.subscribePresence=function(e){this.presence2.subscribe(e)},e.prototype.unsubscribePresence=function(e){this.presence2.unsubscribe(e)},e.prototype.history=function(e){this.histories.get(e)},e.prototype.hereNow=function(e){this.presence2.hereNow(e)},e}();ht.PubSub=sn;var an={__esModule:!0,GWSModule:void 0},cn=Q,un=ht,ln=ee,fn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return cn.__extends(t,e),t.init=function(){return this.module=new t,this.module.name=this.GWS_MODULE_NAME,this.initGN(),this.module},t.initGN=function(){ln.GN.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}()))},t.prototype.postConnect=function(){un.PubSub.init()},t.check=function(){if(!this.module)throw{code:400,content:"PubSub not initialized. Please include 'PUBSUB' in the 'modules' during GoEasy initialization."}},t.GWS_MODULE_NAME="GWS",t}(et.GModule);an.GWSModule=fn,dt.__esModule=!0,dt.GWS=void 0;var pn=ht,dn=de,hn=an,mn=$,yn=et,gn=function(){function e(){}return e.publish=function(e){this.catch((function(){pn.PubSub.instance.publish(e)}),e)},e.subscribe=function(e){this.catch((function(){pn.PubSub.instance.subscribe(e)}),e)},e.unsubscribe=function(e){this.catch((function(){pn.PubSub.instance.unsubscribe(e)}),e)},e.subscribePresence=function(e){this.catch((function(){pn.PubSub.instance.subscribePresence(e)}),e)},e.unsubscribePresence=function(e){this.catch((function(){pn.PubSub.instance.unsubscribePresence(e)}),e)},e.history=function(e){this.catch((function(){pn.PubSub.instance.history(e)}),e)},e.hereNow=function(e){this.catch((function(){pn.PubSub.instance.hereNow(e)}),e)},e.catch=function(e,t){try{if(hn.GWSModule.check(),[mn.NetworkStatus.DISCONNECTED,mn.NetworkStatus.DISCONNECTING,mn.NetworkStatus.CONNECT_FAILED].includes(yn.G.Socket.status()))throw new Error("Please call connect() first.");e()}catch(e){dn.CallbackUtils.onFailed(t,e)}},e}();dt.GWS=gn;var vn={},Sn={},En={},_n={},Mn={},bn={};!function(e){e.__esModule=!0;var t=function(){};e.default=t}(bn),Mn.__esModule=!0,Mn.uniAppFileUploader=void 0;var Cn=Q,wn=function(e){function t(){return e.call(this)||this}return Cn.__extends(t,e),t.prototype.upload=function(e,t){var n=this;try{return delete e.parameters.fileRes,new Promise((function(o,i){uni.uploadFile({url:e.host,filePath:n.getTempFilePath(e),name:"file",formData:e.parameters,success:function(e){200===e.statusCode?o():i({code:e.statusCode,content:e.errMsg})},fail:function(e){i({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}(bn.default),In=new wn;Mn.uniAppFileUploader=In;var Tn={__esModule:!0,wxFileUploader:void 0},kn=Q,Nn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return kn.__extends(t,e),t.prototype.upload=function(e,t){var n=this;try{return new Promise((function(o,i){wx.uploadFile({url:e.host,filePath:n.getTempFilePath(e),name:"file",formData:e.parameters,success:function(e){200===e.statusCode?o():i({code:e.statusCode,content:e.errMsg})},fail:function(e){i({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}(bn.default),Rn=new Nn;Tn.wxFileUploader=Rn;var Pn={__esModule:!0,htmlFileUploader:void 0},An=Q,On=function(e){function t(){return e.call(this)||this}return An.__extends(t,e),t.prototype.upload=function(e,t){try{return new Promise((function(n,o){var i=new XMLHttpRequest;for(var r in i.open("post",e.host,!0),e.headers)i.setRequestHeader(r,e.headers[r]);i.upload.onprogress=function(e){t&&t(e)},i.upload.onloadstart=function(e){t&&t(e)},i.upload.onloadend=function(e){t&&t(e)};var s=new FormData;for(var a in e.parameters)"fileRes"==a?s.append("file",e.parameters[a]):s.append(a,e.parameters[a]);i.send(s),i.onreadystatechange=function(){4==i.readyState&&(i.status>=200&&i.status<300||304==i.status?n():o({code:i.status,content:i.responseText}))}}))}catch(e){return new Promise((function(t,n){n({code:500,content:e})}))}},t}(bn.default),Dn=new On;Pn.htmlFileUploader=Dn;var xn={__esModule:!0,aliFileUploader:void 0},Gn=Q,Un=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Gn.__extends(t,e),t.prototype.upload=function(e,t){var n=this;try{return delete e.parameters.fileRes,new Promise((function(o,i){my.uploadFile({url:e.host,filePath:n.getTempFilePath(e),fileType:"image",name:"file",formData:e.parameters,success:function(e){200===e.statusCode?o():i({code:e.statusCode,content:e.errMsg})},fail:function(e){i({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.path||t.tempFilePath},t}(bn.default),Ln=new Un;xn.aliFileUploader=Ln;var Fn={__esModule:!0,baiduFileUploader:void 0},Bn=Q,qn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Bn.__extends(t,e),t.prototype.upload=function(e,t){var n=this;try{return delete e.parameters.fileRes,new Promise((function(o,i){swan.uploadFile({url:e.host,filePath:n.getTempFilePath(e),name:"file",formData:e.parameters,success:function(e){200===e.statusCode?o():i({code:e.statusCode,content:e.errMsg})},fail:function(e){i({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.path||t.tempFilePath},t}(bn.default),jn=new qn;Fn.baiduFileUploader=jn;var Vn={__esModule:!0,FileUploadResponse:void 0},Hn=function(e,t,n){this.storageLocation=e,this.url=t,this.name=n};Vn.FileUploadResponse=Hn,_n.__esModule=!0,_n.fileUploader=_n.FileUploader=void 0;var zn=Q,Wn=Mn,Jn=Tn,Xn=Pn,Qn=xn,Yn=Fn,Kn=y,$n=ne,Zn=Vn,eo=function(){function e(){var e;this.uploader=((e={})[Kn.Framework.UNIAPP]=Wn.uniAppFileUploader,e[$n.PlatformType.MP_WX]=Jn.wxFileUploader,e[$n.PlatformType.BROWSER]=Xn.htmlFileUploader,e[$n.PlatformType.MP_ALI]=Qn.aliFileUploader,e[$n.PlatformType.MP_BAIDU]=Yn.baiduFileUploader,e[Kn.Framework.REACT_NATIVE]=Xn.htmlFileUploader,e[$n.PlatformType.MP_BYTE]=Jn.wxFileUploader,e)}return e.prototype.upload=function(e,t){return zn.__awaiter(this,void 0,void 0,(function(){var n,o,i;return zn.__generator(this,(function(r){switch(r.label){case 0:return n=Kn.FrameworkDetector.currentFramework(),o=$n.PlatformDetector.currentPlatform(),i=n===Kn.Framework.UNKNOWN?o:n,[4,this.uploader[i].upload(e,t)];case 1:return r.sent(),[2,new Zn.FileUploadResponse(e.storageLocation,e.url,e.newFileName)]}}))}))},e}();_n.FileUploader=eo;var to=new eo;_n.fileUploader=to;var no={},oo={};!function(e){e.__esModule=!0;var t=pe,n=et,o=function(){function e(){}return e.prototype.resolve=function(e){return new Promise((function(o,i){var r=new n.Rocket({name:"uploadToken",params:{filename:e},permission:n.Permission.WRITE,singleTimeout:t.SocketTimeout.commonRequestSingle,totalTimeout:t.SocketTimeout.commonRequestTotal,fail:function(e){i(e.content)},success:function(e){200===e.code?o(e.content):i(e.content)}});n.G.Socket.e(r)}))},e}();e.default=o}(oo);var io={};!function(e){e.__esModule=!0,e.FileStorageLocation=void 0,function(e){e.aliYun="ALI",e.qiNiu="QN",e.tencent="TX"}(e.FileStorageLocation||(e.FileStorageLocation={}))}(io);var ro={},so={};!function(e){e.__esModule=!0;var t=function(e,t,n,o,i,r,s){this.storageLocation=e,this.host=t,this.headers=n,this.parameters=o,this.file=i,this.newFileName=r,this.url=s};e.default=t}(so);var ao={};!function(e){e.__esModule=!0;var t=function(){function e(){}return e.prototype.newFileName=function(e){return e&&e.newFilename||""},e}();e.default=t}(ao),ro.__esModule=!0,ro.aliYunOSSRequestBuilder=ro.AliYunOSSRequestBuilder=void 0;var co=Q,uo=so,lo=io,fo=function(e){function t(){return e.call(this)||this}return co.__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,i=this.newFileName(e);return o={key:e.dir+"/"+i,OSSAccessKeyId:e.accessKeyId,policy:e.policy,signature:e.signature,success_action_status:"200",fileRes:t},n&&(o={key:e.dir+"/"+i,OSSAccessKeyId:e.accessKeyId,policy:e.policy,signature:e.signature,success_action_status:"200","Content-Disposition":"attachment;filename="+t.name,fileRes:t}),new uo.default(lo.FileStorageLocation.aliYun,e.host,null,o,t,i,this.url(e))},t}(ao.default);ro.AliYunOSSRequestBuilder=fo;var po=new fo;ro.aliYunOSSRequestBuilder=po;var ho={__esModule:!0};ho.tencentOSSRequestBuilder=ho.TencentOSSRequestBuilder=void 0;var mo=Q,yo=so,go=io,vo=function(e){function t(){return e.call(this)||this}return mo.__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};return 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}),new yo.default(go.FileStorageLocation.tencent,e.host,null,o,t,e.key,this.url(e))},t}(ao.default);ho.TencentOSSRequestBuilder=vo;var So=new vo;ho.tencentOSSRequestBuilder=So,function(e){e.__esModule=!0;var t=Q,n=oo,o=io,i=ro,r=ho,s=function(){function e(){this.uploadTokenResolver=new n.default}return e.prototype.builder=function(e){if(e===o.FileStorageLocation.aliYun)return i.aliYunOSSRequestBuilder;if(e===o.FileStorageLocation.tencent)return r.tencentOSSRequestBuilder;throw new Error("Only Ali OSS and Tencent COS are supported, unknown storage location:"+e)},e.prototype.build=function(e,n,o){return t.__awaiter(this,void 0,void 0,(function(){var i,r,s;return t.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.uploadTokenResolver.resolve(n)];case 1:return i=t.sent(),r=this.builder(i.vendor).build(i,e,o),[2,Promise.resolve(r)];case 2:return s=t.sent(),[2,Promise.reject(s)];case 3:return[2]}}))}))},e}();e.default=s}(no),En.__esModule=!0,En.GoEasyUploader=void 0;var Eo=Q,_o=_n,Mo=no,bo=function(){function e(){this.requestBuilder=new Mo.default,this.fileUploader=_o.fileUploader}return e.prototype.upload=function(e,t,n,o){return Eo.__awaiter(this,void 0,void 0,(function(){var i,r;return Eo.__generator(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.requestBuilder.build(e,t,o)];case 1:return i=s.sent(),[2,this.fileUploader.upload(i,n)];case 2:return r=s.sent(),[2,Promise.reject(r)];case 3:return[2]}}))}))},e}();En.GoEasyUploader=bo;var Co={},wo={};!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.MESSAGE_RECALLED="IM_INTERNAL_MESSAGE_RECALLED",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"}(wo);var Io={__esModule:!0,AbstractMessage:void 0},To=et,ko=function(){function e(){}return e.prototype.clearUseLessAttribute=function(){delete this.buildOptions},e.prototype.isOtherSent=function(){return this.senderId!==To.G.Socket.user().id},e.prototype.getToData=function(){return this.buildOptions.createOptions.to.data},e}();Io.AbstractMessage=ko;var No={},Ro={},Po={__esModule:!0,AbstractPayloadImprover:void 0},Ao=function(){};Po.AbstractPayloadImprover=Ao;var Oo={};!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={}))}(Oo),Ro.__esModule=!0,Ro.FileMessagePayloadImprover=void 0;var Do=Q,xo=En,Go=Oo,Uo=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.goEasyUploader=new xo.GoEasyUploader,t}return Do.__extends(t,e),t.prototype.improve=function(e){var t=this,n=e.message;return new Promise((function(e,o){var i,r=n.buildOptions.createOptions;i=n.type===Go.MessageType.VIDEO?n.payload.video.name:n.payload.name,t.goEasyUploader.upload(r.file,i,r.onProgress,n.type===Go.MessageType.FILE).then((function(o){o.url=encodeURI(o.url),t.setPayload(o,n),e()})).catch((function(e){o(e)}))}))},t.prototype.setPayload=function(e,t){t.payload.url=e.url},t}(Po.AbstractPayloadImprover);Ro.FileMessagePayloadImprover=Uo;var Lo={__esModule:!0,VideoMessagePayloadImprover:void 0},Fo=Q,Bo=io,qo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Fo.__extends(t,e),t.prototype.setPayload=function(e,t){var n,o=t.payload;switch(o.video.url=e.url,o.video.name=e.name,o.thumbnail.height>200&&(o.thumbnail.height=200,o.thumbnail.width=200*o.video.width/o.video.height),e.storageLocation){case Bo.FileStorageLocation.aliYun:n="?x-oss-process=video/snapshot,t_0000,f_jpg,h_"+o.thumbnail.height+",m_fast,ar_auto";break;case Bo.FileStorageLocation.tencent:n="?ci-process=snapshot&time=1&format=jpg&height="+o.thumbnail.height;break;default:throw new Error("Only Ali OSS and Tencent COS are supported, unknown storage location:"+e.storageLocation)}o.thumbnail.url=e.url+n},t}(Ro.FileMessagePayloadImprover);Lo.VideoMessagePayloadImprover=qo;var jo={__esModule:!0,ImageMessagePayloadImprover:void 0},Vo=Q,Ho=io,zo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Vo.__extends(t,e),t.prototype.setPayload=function(e,t){var n,o=t.payload;o.url=e.url;var i=o.height>200?200:o.height;switch(e.storageLocation){case Ho.FileStorageLocation.aliYun:n="?x-oss-process=image/resize,m_lfit,h_"+i;break;case Ho.FileStorageLocation.tencent:n="?imageMogr2/thumbnail/x".concat(i);break;default:throw new Error("Only Ali OSS and Tencent COS are supported, unknown storage location:"+e.storageLocation)}o.thumbnail=e.url+n},t}(Ro.FileMessagePayloadImprover);jo.ImageMessagePayloadImprover=zo,No.__esModule=!0,No.PayloadImprover=void 0;var Wo=Ro,Jo=Lo,Xo=Oo,Qo=jo,Yo=function(){function e(){var e;this.improvers=((e={})[Xo.MessageType.FILE]=new Wo.FileMessagePayloadImprover,e[Xo.MessageType.AUDIO]=new Wo.FileMessagePayloadImprover,e[Xo.MessageType.IMAGE]=new Qo.ImageMessagePayloadImprover,e[Xo.MessageType.VIDEO]=new Jo.VideoMessagePayloadImprover,e)}return e.prototype.improve=function(e){var t=this.improvers[e.message.type];if(t)try{return t.improve(e)}catch(e){return Promise.reject(e)}return Promise.resolve()},e}();No.PayloadImprover=Yo;var Ko={__esModule:!0,IMEC:void 0},$o=Q,Zo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return $o.__extends(t,e),t.init=function(){this.i=new t},t}(et.AbstractEventCenter);Ko.IMEC=Zo;var ei={};!function(e){e.__esModule=!0;var t=Oo,n=Z,o=vt,i=function(){function e(e,t,i,r,s){this.validate(e),this.mt=e.type,this.to=t.id.toString(),this.d=JSON.stringify(t.data),this.p=JSON.stringify(e.payload),i&&(this.nt=i),s&&(this.at=s),r&&(this.wxmpTemplateMsg=(0,o.default)(r),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}(ei),function(e){e.__esModule=!0;var t=Q,n=wo,o=Z,i=Io,r=fe,s=et,a=de,c=No,u=Ko,l=ei,f=pe,p=et,d=function(){function e(){this.payloadImprover=new c.PayloadImprover}return e.prototype.send=function(e){var n=this;this.validate(e);var i=e.message,r=e.accessToken,s=i.buildOptions,c=s.createOptions,u=c.notification,l=c.wxmpTemplateMsg,f=c.to;f.data||(f.data={}),i.status=o.MessageStatus.SENDING;var p=s.complete,d=this.payloadImprover.improve(e);Promise.all([p,d]).then((function(){return t.__awaiter(n,void 0,void 0,(function(){var n;return t.__generator(this,(function(t){switch(t.label){case 0:return c.beforeSend?(n=JSON.parse(JSON.stringify(i)),[4,c.beforeSend(n)]):[3,2];case 1:t.sent(),t.label=2;case 2:return this.doSend(i,f,u,l,r,e),[2]}}))}))})).catch((function(t){i.status=o.MessageStatus.FAIL,a.CallbackUtils.onFailed(e,{code:t&&t.code||400,content:t&&t.content||t})}))},e.prototype.doSend=function(e,t,i,c,d,h){var m=new l.default(e,t,i,c,d);u.IMEC.i.fire(n.IM_INTERNAL_EVENTS.MESSAGE_SENDING,e);var y=new p.Rocket({name:r.RocketTypes.publishIM,params:m,unique:!0,permission:p.Permission.WRITE,singleTimeout:f.SocketTimeout.commonRequestSingle,totalTimeout:f.SocketTimeout.commonRequestTotal,fail:function(t){e.status=o.MessageStatus.FAIL,u.IMEC.i.fire(n.IM_INTERNAL_EVENTS.MESSAGE_SEND_FAILED,e),a.CallbackUtils.onFailed(h,{code:t.resultCode,content:t.content})},success:function(t){if(e.status=o.MessageStatus.SUCCESS,e.timestamp=t.content.timestamp,e.messageId=JSON.stringify(t.content.id),e.scene()===o.Scene.CS){var i=e;i.customerId()!==s.G.Socket.user().id&&(i.sessionId=t.content.sessionId)}e.clearUseLessAttribute(),u.IMEC.i.fire(n.IM_INTERNAL_EVENTS.MESSAGE_SEND_SUCCESS,e),a.CallbackUtils.onSuccess(h,e)}});s.G.Socket.e(y)},e.prototype.validate=function(e){var t=e.message;if(!(t instanceof i.AbstractMessage))throw new Error("it is invalid message");if(t.status!==o.MessageStatus.NEW)throw new Error("Please create a new message, a message can only be sent once")},e}();e.default=d}(Co);var ti={},ni={},oi={},ii={},ri={},si={},ai={__esModule:!0,SortedInserter:void 0},ci=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 i=o+n>>1,r=this.compare(t,e[i]);if(r>0)n=i+1;else{if(!(r<0))return i;o=i-1}}return-n-1},e}();ai.SortedInserter=ci,function(e){e.__esModule=!0;var t=Q,n=Z,o=te,i=ai,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 i=this.messages[0].timestamp,r=this.messages[o-1].timestamp;if(t>=i&&t<=r)for(var s=o-1;s>=0;s--){var a=this.messages[s];if(a.timestamp0&&i.timestamp===t.lastTimestamp)&&(n.forEach((function(t){e.sortedInserter.insert(o.messages,t)})),n.length-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.recallMessage=function(e){var t=this;return e.times.map((function(e){return t.findMessageByTime(e)})).filter((function(e){return o.default.isDef(e)})).map((function(t){return t.recalled=!0,t.recaller=e.recaller,t}))},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}(si);var ui={},li={},fi={__esModule:!0,Target:void 0},pi=Z,di=te,hi=et,mi=function(){function e(e,t,n){this.scene=e,this.id=t,di.default.isDef(n)&&(this.teamId=n)}return e.prototype.toString=function(){return pi.Scene.PRIVATE===this.scene||pi.Scene.GROUP===this.scene?this.scene+"#"+this.id:this.scene+"#"+this.id+"#"+this.teamId},e.prototype.customerId=function(){if(pi.Scene.CS===this.scene)return this.id===this.teamId?hi.G.Socket.user().id:this.id},e.byScene=function(t,n,o){return new e(t,n,o)},e.byIMMessage=function(t){var n,o,i=t.scene();if(i===pi.Scene.PRIVATE){var r=t.senderId,s=t.targetId();o=hi.G.Socket.user().id===r?s:r}else if(i===pi.Scene.GROUP)o=t.targetId();else{if(i!==pi.Scene.CS)throw{code:400,content:"scene ".concat(i," not exists")};o=t.targetId(),n=t.teamId}return new e(i,o,n)},e.byMessageReadRemoteEvent=function(t){var n,o=t.scene,i=t.targetId,r=t.markerId,s=t.teamId;return o===pi.Scene.PRIVATE?n=hi.G.Socket.user().id===r?i:r:o===pi.Scene.GROUP?n=i:o===pi.Scene.CS&&(n=i===s?r===hi.G.Socket.user().id?s:r:r===hi.G.Socket.user().id?i:s),new e(o,n,s)},e.byIMMessageDeletedEvent=function(t){var n=t.scene,o=t.deleterId;return n===pi.Scene.PRIVATE?new e(n,hi.G.Socket.user().id===o?t.targetId:o):n===pi.Scene.GROUP?new e(n,t.targetId):void 0},e.byConversationDTO=function(e){var t=e.lastMessage;return this.byIMMessage(t)},e.byConversationId=function(t,n){var o;if(t===pi.Scene.PRIVATE){var i=n.split(":",2);o=i[0]===hi.G.Socket.user().id?i[1]:i[0]}else o=n;return new e(t,o)},e}();fi.Target=mi,li.__esModule=!0,li.DeleteMessageRequest=void 0;var yi=Z,gi=fi,vi=function(e){var t=this;this.times=new Array;var n=e[0],o=gi.Target.byIMMessage(n);this.scene=o.scene,this.targetId=o.id,e.forEach((function(e){e.status===yi.MessageStatus.SUCCESS&&t.times.push(e.timestamp)})),this.times.sort((function(e,t){return en&&(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}();tr.UserOffsets=ir;var rr={};!function(e){e.__esModule=!0;var t=function(e,t,n,o,i){this.id=e,this.scene=t,this.lastTimestamp=n,this.limit=o,this.teamId=i};e.default=t}(rr);var sr={__esModule:!0,UnreadAmountMaxMessageChangeDetector:void 0},ar=wo,cr=Ko,ur=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(),i=this.history.getMaxMessage();i&&(n=i.status,e=i.read,t=i.recalled);var r=this.history.target;this.oldLastMessage!==i||this.oldLastMessageRead!==e||this.oldLastMessageRecalled!==t||this.oldLastMessageStatus!==n?i?cr.IMEC.i.fire(ar.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,i):cr.IMEC.i.fire(ar.IM_INTERNAL_EVENTS.MAX_MESSAGE_DELETED,r):this.oldUnreadAmount!==o&&cr.IMEC.i.fire(ar.IM_INTERNAL_EVENTS.UNREAD_AMOUNT_CHANGED,r)},e}();sr.UnreadAmountMaxMessageChangeDetector=ur;var lr={__esModule:!0,ServerRecalledEvent:void 0},fr=function(e,t,n,o){this.scene=e,this.conversationId=t,this.recaller=n,this.times=o};lr.ServerRecalledEvent=fr;var pr={__esModule:!0,AEC:void 0},dr=et,hr=function(){function e(){}return e.init=function(){this.eventCenter=new dr.ApiEventCenter},e.on=function(e,t){this.eventCenter.on(e,t)},e.fire=function(e,t){this.eventCenter.fire(e,t)},e.off=function(e,t){this.eventCenter.off(e,t)},e}();pr.AEC=hr;var mr={};!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"}(mr),function(e){e.__esModule=!0;var t=Q,n=Z,o=de,i=si,r=ui,s=et,a=Si,c=tr,u=rr,l=te,f=sr,p=wo,d=lr,h=Ko,m=pr,y=mr,g=function(){function e(e){this.expiredTime=0,this.remoteHistory=a.RemoteHistory.instance,this.target=e,this.userOffsets=new c.UserOffsets,this.messageCache=new i.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 l.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,i,r,s,a,c,l=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]:(i=n-o.length,r=o[0]?o[0].timestamp:e,s=new u.default(this.target.id.toString(),this.target.scene,r,i,this.target.teamId),[4,this.remoteHistory.loadServerMessages(this.target,s)]);case 1:a=t.sent(),c=a.messages,o=c.concat(o),this.messageCache.cacheServerMessages(s,c),a.userOffsets.forEach((function(e){l.userOffsets.updateOffset(e.userId,e.offset)})),this.userOffsets.offsetMap.forEach((function(e,t){l.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(i){switch(i.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,r.default.deleteServerMessages(n)];case 1:return t.sent(),this.messageCache.deleteMessages(n),o.CallbackUtils.onSuccess(e),[2]}}))}))}))];case 1:return i.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===s.G.Socket.user().id){var n=this.messageCache.findMessagesByTimes(t);this.messageCache.deleteMessages(n),n.length>0&&m.AEC.fire(y.ImApiEvents.MESSAGE_DELETED,n)}},e.prototype.recallMessages=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(){return t.__generator(this,(function(t){return this.doRecall(e),[2]}))}))}))];case 1:return o.sent(),[2]}}))}))},e.prototype.doRecall=function(e){var t=this.messageCache.recallMessage(e);t.length>0&&m.AEC.fire(y.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,i=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){i.markLocalMessagesRead(i.messageCache.all(),e.userId,e.offset,!0)})),(n=e.deletedMessageTimes).length>0&&this.doSyncDeletedMessage(s.G.Socket.user().id,n),(o=e.recalledMessages).length>0&&o.forEach((function(e){var t=new d.ServerRecalledEvent(i.target.scene,i.target.id,e.recaller,e.times);i.doRecall(t)})),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(),s.G.Socket.user().id,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(),s.G.Socket.user().id,e.timestamp,!0)}))},e.prototype.onMessageSendFailed=function(e){this.getMaxMessage()===e&&h.IMEC.i.fire(p.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 i,r;return t.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),(i=new f.UnreadAmountMaxMessageChangeDetector(this)).pre(),[4,e()];case 1:return t.sent(),i.post(),[3,3];case 2:return r=t.sent(),o.CallbackUtils.onFailed(n,r),[3,3];case 3:return[2]}}))}))},e.prototype.markLocalMessagesRead=function(e,t,n,o){if(this.userOffsets.updateOffset(t,n),this.isOtherUserId(t)){var i=this.markMySentRead(e,n);o&&i.length>0&&m.AEC.fire(y.ImApiEvents.MESSAGE_READ,i)}else t===s.G.Socket.user().id&&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 i=e[o];if(i.isOtherSent()&&i.timestamp<=t){if(i.read)break;i.read=!0}}},e.prototype.markMySentRead=function(e,t){var o=new Array;if(this.target.scene===n.Scene.PRIVATE)for(var i=e.length-1;i>=0;i--){var r=e[i];if(!r.isOtherSent()&&r.timestamp<=t&&r.status===n.MessageStatus.SUCCESS){if(r.read)break;r.read=!0,o.push(r)}}return o},e.prototype.isOtherUserId=function(e){if(this.target.scene===n.Scene.CS){var t=this.target.customerId();return s.G.Socket.user().id===t?e!==s.G.Socket.user().id:e===t}return e!==s.G.Socket.user().id},e.prototype.unreadAmount=function(e){var n,o,i=0,r=this.userOffsets.myOffset(),s=this.messageCache.all();try{for(var a=t.__values(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.isOtherSent()&&!1===u.recalled&&u.timestamp>r&&(i+=1)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}return i},e.prototype.getMaxMessage=function(e){return this.messageCache.getMaxMessage()},e.prototype.maxTime=function(e){var t=this.getMaxMessage();return l.default.isDef(t)?t.timestamp:0},e}();e.default=g}(ri);var yr={},gr={},vr={__esModule:!0,LiveSessionRequest:void 0},Sr=function(e,t){this.teamId=e,this.customerId=t};vr.LiveSessionRequest=Sr;var Er={__esModule:!0,CustomerStatus:void 0},_r=function(){};Er.CustomerStatus=_r;var Mr={},br={__esModule:!0,CSOnlineRequest:void 0},Cr=function(e,t,n){this.teamId=e,this.teamData=JSON.stringify(t),this.agentData=JSON.stringify(n)};br.CSOnlineRequest=Cr;var wr={__esModule:!0,CSOfflineRequest:void 0},Ir=function(e){this.teamId=e};wr.CSOfflineRequest=Ir;var Tr={__esModule:!0,CsAgentsQueryRequest:void 0},kr=function(e){this.teamId=e};Tr.CsAgentsQueryRequest=kr;var Nr={},Rr={},Pr={},Ar={exports:{}},Or=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Dr=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],xr=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 i=Or.exec(e||""),r={},s=14;s--;)r[Dr[s]]=i[s]||"";return-1!=n&&-1!=o&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r},Gr={exports:{}},Ur={exports:{}},Lr=1e3,Fr=60*Lr,Br=60*Fr,qr=24*Br,jr=365.25*qr,Vr=function(e,t){t=t||{};var n=a(e);if("string"===n&&e.length>0)return function(e){if(e=String(e),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*jr;case"days":case"day":case"d":return n*qr;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Br;case"minutes":case"minute":case"mins":case"min":case"m":return n*Fr;case"seconds":case"second":case"secs":case"sec":case"s":return n*Lr;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 Hr(e,qr,"day")||Hr(e,Br,"hour")||Hr(e,Fr,"minute")||Hr(e,Lr,"second")||e+" ms"}(e):function(e){if(e>=qr)return Math.round(e/qr)+"d";if(e>=Br)return Math.round(e/Br)+"h";if(e>=Fr)return Math.round(e/Fr)+"m";if(e>=Lr)return Math.round(e/Lr)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Hr(e,t,n){if(!(e=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())}(Gr,Gr.exports);var zr=xr,Wr=Gr.exports("socket.io-client:url"),Jr=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)||(Wr("protocol-less url %s",e),e=void 0!==t?t.protocol+"//"+e:"https://"+e),Wr("parse %s",e),n=zr(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 Xr={},Qr={}.toString,Yr=Array.isArray||function(e){return"[object Array]"==Qr.call(e)};!function(e){Gr.exports("socket.io-parser");var t=ge.exports,n=Yr;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=r;var i=e.ERROR+'"encode error"';function r(){this.reconstructor=null}function s(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 i;n+=o}return n}(t);n([o])},t(r.prototype),r.prototype.add=function(t){var o;if("string"!=typeof t)throw new Error("Unknown type: "+t);o=function(t){var o=0,i={type:Number(t.charAt(0))};if(null==e.types[i.type])return s("unknown packet type "+i.type);if(e.BINARY_EVENT===i.type||e.BINARY_ACK===i.type){for(var r="";"-"!==t.charAt(++o)&&(r+=t.charAt(o),o!=t.length););if(r!=Number(r)||"-"!==t.charAt(o))throw new Error("Illegal attachments");i.attachments=Number(r)}if("/"===t.charAt(o+1))for(i.nsp="";++o;){if(","===(c=t.charAt(o)))break;if(i.nsp+=c,o===t.length)break}else i.nsp="/";var a=t.charAt(o+1);if(""!==a&&Number(a)==a){for(i.id="";++o;){var c;if(null==(c=t.charAt(o))||Number(c)!=c){--o;break}if(i.id+=t.charAt(o),o===t.length)break}i.id=Number(i.id)}if(t.charAt(++o)){var u=function(e){try{return JSON.parse(e)}catch(e){return!1}}(t.substr(o));if(!(!1!==u&&(i.type===e.ERROR||n(u))))return s("invalid payload");i.data=u}return i}(t),this.emit("decoded",o)},r.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}(Xr);var Kr={exports:{}},$r={},Zr={},es=Object.keys||function(e){var t=[],n=Object.prototype.hasOwnProperty;for(var o in e)n.call(e,o)&&t.push(o);return t},ts=Yr,ns=Object.prototype.toString,os="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===ns.call(Blob),is="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===ns.call(File),rs=function e(t){if(!t||"object"!==a(t))return!1;if(ts(t)){for(var n=0,o=t.length;n=55296&&t<=56319&&i=55296&&e<=57343){if(t)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function hs(e,t){return fs(e>>t&63|128)}function ms(e,t){if(0==(4294967168&e))return fs(e);var n="";return 0==(4294965248&e)?n=fs(e>>6&31|192):0==(4294901760&e)?(ds(e,t)||(e=65533),n=fs(e>>12&15|224),n+=hs(e,6)):0==(4292870144&e)&&(n=fs(e>>18&7|240),n+=hs(e,12),n+=hs(e,6)),n+=fs(63&e|128)}function ys(){if(ls>=us)throw Error("Invalid byte index");var e=255&cs[ls];if(ls++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function gs(e){var t,n;if(ls>us)throw Error("Invalid byte index");if(ls==us)return!1;if(t=255&cs[ls],ls++,0==(128&t))return t;if(192==(224&t)){if((n=(31&t)<<6|ys())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&t)){if((n=(15&t)<<12|ys()<<6|ys())>=2048)return ds(n,e)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&t)&&(n=(7&t)<<18|ys()<<12|ys()<<6|ys())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}var vs={version:"2.1.2",encode:function(e,t){for(var n=!1!==(t=t||{}).strict,o=ps(e),i=o.length,r=-1,s="";++r65535&&(i+=fs((t-=65536)>>>10&1023|55296),t=56320|1023&t),i+=fs(t);return i}(i)}},Ss=void 0!==Ss?Ss:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,Es=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),_s=Es&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),Ms=Ss&&Ss.prototype.append&&Ss.prototype.getBlob;function bs(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 Cs(e,t){t=t||{};var n=new Ss;return bs(e).forEach((function(e){n.append(e)})),t.type?n.getBlob(t.type):n.getBlob()}function ws(e,t){return new Blob(bs(e),t||{})}"undefined"!=typeof Blob&&(Cs.prototype=Blob.prototype,ws.prototype=Blob.prototype);var Is=Es?_s?Blob:ws:Ms?Cs:void 0;!function(e){var t=es,n=rs,o=ss,i=vs;"undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),"undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent),e.protocol=3;var r=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},s=t(r),a={type:"error",data:"parser error"},c=Is;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 s=r[e.type];return void 0!==e.data&&(s+=n?i.encode(String(e.data),{strict:!1}):String(e.data)),o(""+s)},e.decodePacket=function(e,t,n){if(void 0===e)return a;if("string"==typeof e){if(n&&!1===(e=function(e){try{e=i.decode(e,{strict:!1})}catch(e){return!1}return e}(e)))return a;var o=e.charAt(0);return Number(o)==o&&s[o]?e.length>1?{type:s[o],data:e.substring(1)}:{type:s[o]}:a}o=new Uint8Array(e)[0];var r=sliceBuffer(e,1);return c&&"blob"===t&&(r=new c([r])),{type:s[o],data:r}},e.encodePayload=function(t,i,r){"function"==typeof i&&(r=i,i=null);var s=n(t);if(!t.length)return r("0:");!function(e,t,n){for(var i=new Array(e.length),r=o(e.length,n),s=function(e,n,o){t(n,(function(t,n){i[e]=n,o(t,i)}))},a=0;a0);return t}function Fs(){var e=Ls(+new Date);return e!==Rs?(Gs=0,Rs=e):e+"."+Ls(Gs++)}for(;Us';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(oa,"\\\n"),this.area.value=e.replace(na,"\\n");try{this.form.submit()}catch(e){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&a()}:this.iframe.onload=a};var aa,ca,ua=ks,la=Zr,fa=Ps,pa=As,da=Bs,ha=Gr.exports("engine.io-client:websocket");("undefined"==typeof uni&&"undefined"==typeof wx&&"undefined"==typeof my&&"undefined"==typeof swan||"undefined"!=typeof WebSocket)&&("undefined"!=typeof WebSocket?aa=WebSocket:"undefined"!=typeof self&&(aa=self.WebSocket||self.MozWebSocket));var ma=aa||ca;("undefined"==typeof uni&&"undefined"==typeof wx&&"undefined"==typeof my&&"undefined"==typeof swan||"undefined"!=typeof WebSocket)&&"undefined"==typeof GameGlobal||(ma=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":a(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 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 if("undefined"!=typeof swan)swan.connectSocket({url:e}),t.send=function(e){swan.sendSocketMessage({data:e})},t.close=function(e){swan.closeSocket()},swan.onSocketOpen((function(e){t.onopen()})),swan.onSocketError((function(e){t.onerror(e)})),swan.onSocketMessage((function(e){t.onmessage(e)})),swan.onSocketClose((function(e){t.onclose(e)}));else if("undefined"!=typeof uni){var o=uni.connectSocket({url:e,complete:function(){}});t.send=function(e){o.send({data:e})},t.close=function(){o.close()},o.onOpen((function(e){t.onopen()})),o.onError((function(e){t.onerror(e)})),o.onMessage((function(e){t.onmessage(e)})),o.onClose((function(e){t.onclose()}))}else{var 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 ya=ga;function ga(e){e&&e.forceBase64&&(this.supportsBinary=!1),("undefined"==typeof uni&&"undefined"==typeof wx&&"undefined"==typeof my&&"undefined"==typeof swan||"undefined"!=typeof WebSocket)&&(this.perMessageDeflate=e.perMessageDeflate,this.usingBrowserWebSocket=aa&&!e.forceNode,this.protocols=e.protocols,this.usingBrowserWebSocket||(ma=ca)),ua.call(this,e)}pa(ga,ua),ga.prototype.name="websocket",ga.prototype.supportsBinary=!1,ga.prototype.doOpen=function(){var e=this;if(this.check()){var t,n,o=this.uri();if(("undefined"==typeof uni&&"undefined"==typeof wx&&"undefined"==typeof my&&"undefined"==typeof swan||"undefined"!=typeof WebSocket)&&(t=this.protocols),(n="undefined"==typeof uni&&"undefined"==typeof wx&&"undefined"==typeof my&&"undefined"==typeof swan||"undefined"!=typeof WebSocket?{agent:this.agent,perMessageDeflate:this.perMessageDeflate}:{agent:this.agent}).pfx=this.pfx,n.key=this.key,n.passphrase=this.passphrase,n.cert=this.cert,n.ca=this.ca,n.ciphers=this.ciphers,n.rejectUnauthorized=this.rejectUnauthorized,"object"===("undefined"==typeof navigator?"undefined":a(navigator))&&"ReactNative"===navigator.product&&(n={}),this.extraHeaders&&(n.headers=this.extraHeaders),this.localAddress&&(n.localAddress=this.localAddress),"undefined"!=typeof cc&&"Windows"===cc.sys.os)cc.resources.load("cacert",(function(t,n){var i=n.nativeUrl;e.ws=new ma(o,[],i),e.ws.binaryType="arraybuffer",e.addEventListeners()}));else{try{"undefined"==typeof uni&&"undefined"==typeof wx&&"undefined"==typeof my&&"undefined"==typeof swan||"undefined"!=typeof WebSocket?this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new ma(o,t):new ma(o):new ma(o,t,n):this.ws=new ma(o)}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()}}},ga.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)}},ga.prototype.write=function(e){var t=this;this.writable=!1;for(var n=e.length,o=0,i=n;o0&&(this.extraHeaders=t.extraHeaders),t.localAddress&&(this.localAddress=t.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}Ra.priorWebsocketSuccess=!1,ba(Ra.prototype),Ra.protocol=Ia.protocol,Ra.Socket=Ra,Ra.Transport=ks,Ra.transports=$r,Ra.parser=Zr,Ra.prototype.createTransport=function(e){Ca('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=Ia.protocol,t.transport=e;var n=this.transportOptions[e]||{};return this.id&&(t.sid=this.id),new Ma[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})},Ra.prototype.open=function(){var e;if(this.rememberUpgrade&&Ra.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)},Ra.prototype.setTransport=function(e){Ca("setting transport %s",e.name);var t=this;this.transport&&(Ca("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")}))},Ra.prototype.probe=function(e){Ca('probing transport "%s"',e);var t=this.createTransport(e,{probe:1}),n=!1,o=this;function i(){if(o.onlyBinaryUpgrades){var i=!this.supportsBinary&&o.transport.supportsBinary;n=n||i}n||(Ca('probe transport "%s" opened',e),t.send([{type:"ping",data:"probe"}]),t.once("packet",(function(i){if(!n)if("pong"===i.type&&"probe"===i.data){if(Ca('probe transport "%s" pong',e),o.upgrading=!0,o.emit("upgrading",t),!t)return;Ra.priorWebsocketSuccess="websocket"===t.name,Ca('pausing current transport "%s"',o.transport.name),o.transport.pause((function(){n||"closed"!==o.readyState&&(Ca("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{Ca('probe transport "%s" failed',e);var r=new Error("probe error");r.transport=t.name,o.emit("upgradeError",r)}})))}function r(){n||(n=!0,l(),t.close(),t=null)}function s(n){var i=new Error("probe error: "+n);i.transport=t.name,r(),Ca('probe transport "%s" failed because of error: %s',e,n),o.emit("upgradeError",i)}function a(){s("transport closed")}function c(){s("socket closed")}function u(e){t&&e.name!==t.name&&(Ca('"%s" works - aborting "%s"',e.name,t.name),r())}function l(){t.removeListener("open",i),t.removeListener("error",s),t.removeListener("close",a),o.removeListener("close",c),o.removeListener("upgrading",u)}Ra.priorWebsocketSuccess=!1,t.once("open",i),t.once("error",s),t.once("close",a),this.once("close",c),this.once("upgrading",u),t.open()},Ra.prototype.onOpen=function(){if(Ca("socket open"),this.readyState="open",Ra.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause){Ca("starting upgrade probes");for(var e=0,t=this.upgrades.length;e0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ua.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)},Ua.prototype.reset=function(){this.attempts=0},Ua.prototype.setMin=function(e){this.ms=e},Ua.prototype.setMax=function(e){this.max=e},Ua.prototype.setJitter=function(e){this.jitter=e};var La={__esModule:!0,URIResolver:void 0},Fa=ne,Ba=function(){function e(){}return e.init=function(e,t,n){this.host=e,(void 0!==t&&!1===t||!0===n)&&(this.https=!1)},e.isMP=function(){return[Fa.PlatformType.MP_WX,Fa.PlatformType.MP_ALI,Fa.PlatformType.MP_BYTE,Fa.PlatformType.MP_WGAME,Fa.PlatformType.MP_BAIDU].includes(Fa.PlatformDetector.currentPlatform())},e.uri=function(){var e="http";return this.https&&(e+="s"),e+"://"+this.index()+this.host},e.index=function(){return 0==this.i?this.i=Math.floor(Math.random()*(this.max-1)+1):this.i=this.i%this.max+1,this.i},e.i=0,e.max=5,e.https=!0,e}();La.URIResolver=Ba;var qa=Kr.exports,ja=Pa.exports,Va=ge.exports,Ha=Xr,za=Oa,Wa=xa,Ja=(Gr.exports("socket.io-client:manager"),_a),Xa=Ga,Qa=La.URIResolver,Ya=oe.runStatus,Ka=Object.prototype.hasOwnProperty,$a=Za;function Za(e,t){if(!(this instanceof Za))return new Za(e,t);e&&"object"===a(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 Xa({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||Ha;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==t.autoConnect,this.autoConnect&&this.open()}Za.prototype.emitAll=function(){for(var e in this.emit.apply(this,arguments),this.nsps)Ka.call(this.nsps,e)&&this.nsps[e].emit.apply(this.nsps[e],arguments)},Za.prototype.updateSocketIds=function(){for(var e in this.nsps)Ka.call(this.nsps,e)&&(this.nsps[e].id=this.generateId(e))},Za.prototype.generateId=function(e){return("/"===e?"":e+"#")+this.engine.id},Va(Za.prototype),Za.prototype.reconnection=function(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection},Za.prototype.reconnectionAttempts=function(e){return arguments.length?(this._reconnectionAttempts=e,this):this._reconnectionAttempts},Za.prototype.reconnectionDelay=function(e){return arguments.length?(this._reconnectionDelay=e,this.backoff&&this.backoff.setMin(e),this):this._reconnectionDelay},Za.prototype.randomizationFactor=function(e){return arguments.length?(this._randomizationFactor=e,this.backoff&&this.backoff.setJitter(e),this):this._randomizationFactor},Za.prototype.reconnectionDelayMax=function(e){return arguments.length?(this._reconnectionDelayMax=e,this.backoff&&this.backoff.setMax(e),this):this._reconnectionDelayMax},Za.prototype.timeout=function(e){return arguments.length?(this._timeout=e,this):this._timeout},Za.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},Za.prototype.open=Za.prototype.connect=function(e,t){if(this.readyState,~this.readyState.indexOf("open"))return this;this.uri,this.engine=qa(this.uri,this.opts);var n=this.engine,o=this;this.readyState="opening",this.skipReconnect=!1;var i=za(n,"open",(function(){o.onopen(),e&&e()})),s=za(n,"error",function(){var t=function(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var r=e.apply(t,n);function s(e){c(r,o,i,s,a,"next",e)}function a(e){c(r,o,i,s,a,"throw",e)}s(void 0)}))}}(r().mark((function t(n){var i;return r().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o.uri=Qa.uri(),o.cleanup(),o.readyState="closed",o.emitAll("connect_error",n),e?((i=new Error("Connection error")).data=n,e(i)):o.maybeReconnectOnOpen();case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}());if(!1!==this._timeout){var a=this._timeout,u=setTimeout((function(){i.destroy(),n.close(),n.emit("error","timeout"),o.emitAll("connect_timeout",a)}),a);this.subs.push({destroy:function(){clearTimeout(u)}})}return this.subs.push(i),this.subs.push(s),this},Za.prototype.onopen=function(){this.cleanup(),this.readyState="open",this.emit("open");var e=this.engine;this.subs.push(za(e,"data",Wa(this,"ondata"))),this.subs.push(za(e,"ping",Wa(this,"onping"))),this.subs.push(za(e,"pong",Wa(this,"onpong"))),this.subs.push(za(e,"error",Wa(this,"onerror"))),this.subs.push(za(e,"close",Wa(this,"onclose"))),this.subs.push(za(this.decoder,"decoded",Wa(this,"ondecoded")))},Za.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},Za.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},Za.prototype.ondata=function(e){this.decoder.add(e)},Za.prototype.ondecoded=function(e){this.emit("packet",e)},Za.prototype.onerror=function(e){this.emitAll("error",e)},Za.prototype.socket=function(e,t){var n=this.nsps[e];if(!n){n=new ja(this,e,t),this.nsps[e]=n;var o=this;n.on("connecting",i),n.on("connect",(function(){n.id=o.generateId(e)})),this.autoConnect&&i()}function i(){~Ja(o.connecting,n)||o.connecting.push(n)}return n},Za.prototype.destroy=function(e){var t=Ja(this.connecting,e);~t&&this.connecting.splice(t,1),this.connecting.length||this.close()},Za.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;o0&&!this.encoding){var e=this.packetBuffer.shift();this.packet(e)}},Za.prototype.cleanup=function(){for(var e=this.subs.length,t=0;t=this._reconnectionAttempts)this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var t=this.backoff.duration();this.reconnecting=!0;var n=setTimeout((function(){if(Ya.isBackend())return e.reconnecting=!1,e.reconnect(),void e.emitAll("reconnect_error","Uniapp running backend, skipped reconnect...");e.skipReconnect||(e.emitAll("reconnect_attempt",e.backoff.attempts),e.emitAll("reconnecting",e.backoff.attempts),e.skipReconnect||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)}})}},Za.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=Jr,o=Xr,i=$a;Gr.exports("socket.io-client");e.exports=t=s;var r=t.managers={};function s(e,t){"object"===a(e)&&(t=e,e=void 0),t=t||{};var o,s=n(e),c=s.source,u=s.id,l=s.path,f=r[u]&&l in r[u].nsps;return t.forceNew||t["force new connection"]||!1===t.multiplex||f?o=i(c,t):(r[u]||(r[u]=i(c,t)),o=r[u]),s.query&&!t.query&&(t.query=s.query),o.socket(s.path,t)}t.protocol=o.protocol,t.connect=s,t.Manager=$a,t.Socket=Pa.exports}(Ar,Ar.exports),function(e){e.__esModule=!0;var t=$,n=et,o=Ar.exports,i=te,r=function(){function e(){this.io=o,this.status=t.NetworkStatus.DISCONNECTED,this.permissions=[n.Permission.NONE],this.connectedObservers=[],this.disconnectedObservers=[]}return e.prototype.connect=function(){this.status=t.NetworkStatus.CONNECTING},e.prototype.socketio=function(){return this.io},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=n&&e<=o}(e)?String.fromCharCode(function(e){var i=e+t;return i>o?n+(i-o):i}(e)):String.fromCharCode(e)}for(var r="",s=0;s-1)i=n.VENDOR,o=n.RENDERER;else{var r=n.getExtension("WEBGL_debug_renderer_info");if(!r)return null;i=r.UNMASKED_VENDOR_WEBGL,o=r.UNMASKED_RENDERER_WEBGL}var s={vendor:(n.getParameter(i)||"").toString(),renderer:(n.getParameter(o)||"").toString()};return JSON.stringify(s)}}return null},e.z=function(){return Nc.__awaiter(this,void 0,void 0,(function(){var e;return Nc.__generator(this,(function(t){return e={p:Rc.PlatformDetector.currentPlatform(),f:Pc.FrameworkDetector.currentFramework(),vc:this.getVideoCard(),rfp:this.initRNUniqueId()},[2,Ac.ZE.e(JSON.stringify(e),5)]}))}))},e}();Ic.Z=Dc;var xc={__esModule:!0,Emitter:void 0},Gc=$,Uc=function(){function e(e){this.rocketsBuffer=new Set,this.socket=e,this.socket.addConnectedObserver(this.onSocketConnected.bind(this))}return e.prototype.emit=function(e){this.socket.status!==Gc.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.complete)if(this.socket.status!==Gc.NetworkStatus.CONNECT_FAILED)if(this.isConnected())if(this.hasPermission(e)){var n=setTimeout((function(){t.doEmit(e)}),e.singleTimeout);e.unique&&(e.params.retried=e.retried),this.socket.socketio().emit(e.name,e.params,(function(t){clearTimeout(n),200===t.resultCode||200==t.code?e.success(t):e.fail(t)})),e.retried++}else e.fail({resultCode:401,content:"No permission"});else this.isConnecting()&&this.rocketsBuffer.add(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.isConnected=function(){return[Gc.NetworkStatus.CONNECTED,Gc.NetworkStatus.RECONNECTED,Gc.NetworkStatus.EXPIRED_RECONNECTED,Gc.NetworkStatus.DISCONNECTING].includes(this.socket.status)},e.prototype.isConnecting=function(){return[Gc.NetworkStatus.CONNECTING,Gc.NetworkStatus.RECONNECTING].includes(this.socket.status)},e.prototype.onSocketConnected=function(){this.emitBuffer()},e.prototype.emitBuffer=function(){var e=this;Array.from(this.rocketsBuffer).forEach((function(t){e.rocketsBuffer.delete(t),e.doEmit(t)}))},e}();xc.Emitter=Uc;var Lc={__esModule:!0,SEC:void 0},Fc=Q,Bc=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Fc.__extends(t,e),t.init=function(){t.i=new t},t.fire=function(e,t){this.i.fire(e,t)},t.on=function(e,t){this.i.on(e,t)},t.off=function(e,t){this.i.off(e,t)},t}(et.AbstractEventCenter);Lc.SEC=Bc,function(e){e.__esModule=!0;var t=Q,n=ec,o=$,i=te,r=pe,s=Z,a=fe,c=Ct,u=tc,l=Ic,f=xc,p=La,d=et,h=Lc,m=function(e){function m(t,o){var i=e.call(this)||this;return i.ioSocket=null,i.sid=null,i.anonymous=!1,i.userId=null,i.artifactVersion=s.version,i.vname=null,i.uri=null,i.ioOpts=null,i.reconnectingTimes=0,i.messageObservers=new Map,i.connectFailedObservers=[],i.connectingObservers=[],i.expiredReconnectedObservers=[],i.options=t,i.ioSocket=new n.default({onDisconnected:i.onIoDisconnected.bind(i),onReconnecting:i.onIoReconnecting.bind(i)}),i.ioSocketEmitter=new f.Emitter(i.ioSocket),i.ioSocket.addConnectedObserver(i.onIoReconnected.bind(i)),i.initOptions(o),i.connect(),i}return t.__extends(m,e),m.prototype.initUserId=function(){var e=this.connectOptions.id;i.default.isEmpty(e)?this.anonymous=!0:this.userId=e.toString()},m.prototype.socketio=function(){return this.ioSocket.socketio()},m.prototype.extendOptions=function(){var e=this.connectOptions;if(i.default.isNull(e.data)||i.default.isDef(e.data)&&!i.default.isObject(e.data))throw{code:400,content:"TypeError: data requires an object."};if((i.default.isDef(e.data)?String(e.data).length:0)>300&&i.default.isObject(e)&&i.default.isFunction(e.onFailed))throw{code:400,content:"user.data-length limit 300 byte."};if(i.default.isObject(e.wxmpId)){if(i.default.isEmpty(e.wxmpId.appid))throw{code:400,content:"wxmpId.appid is required."};if(i.default.isEmpty(e.wxmpId.openid))throw{code:400,content:"wxmpId.openid is required. requires string."}}else if(i.default.isPrimitive(e.wxmpId))throw{code:400,content:"TypeError: wxmpId requires an object."}},m.prototype.initUriAndOpts=function(){var e=this.options;p.URIResolver.init(e.host,e.forceTLS,e.supportOldBrowser),this.uri=p.URIResolver.uri();var t=["websocket"];!0===e.supportOldBrowser&&t.push("polling"),this.ioOpts={transports:t,timeout:r.SocketTimeout.connect,reconnectionDelayMax:r.SocketTimeout.reconnectionDelayMax}},m.prototype.onIoReconnected=function(){this.status===o.NetworkStatus.RECONNECTING&&this.authorize()},m.prototype.sendAck=function(e,t){this.ioSocket.io.emit(e,t)},m.prototype.initOptions=function(e){this.connectOptions=e,this.addConnectedObserver(e.onSuccess),this.addConnectFailedObserver(e.onFailed),this.addConnectingObserver(e.onProgress),this.initUserId()},m.prototype.connect=function(){this.initUriAndOpts(),this.extendOptions(),e.prototype.connect.call(this),this.onConnecting(),this.ioSocket.connect({uri:this.uri,opts:this.ioOpts}),this.authorize()},m.prototype.disconnect=function(){var e=this;return new Promise((function(t,n){e.status=o.NetworkStatus.DISCONNECTING;var i=function(){e.ioSocket.disconnect(),e.status=o.NetworkStatus.DISCONNECTED,h.SEC.fire(c.SocketEvent.DISCONNECTED),t()},s=d.GModules.modules.get("GN");if(s&&(s.params.regId||e.connectOptions.wxmpId)){var u=new d.Rocket({name:a.RocketTypes.manualDisconnect,params:{},permission:d.Permission.READ,singleTimeout:r.SocketTimeout.commonRequestSingle,totalTimeout:r.SocketTimeout.commonRequestTotal,fail:function(e){n(e)},success:i});d.G.Socket.e(u)}else i()}))},m.prototype.authorize=function(){return t.__awaiter(this,void 0,void 0,(function(){var e,n,o,i,s=this;return t.__generator(this,(function(t){switch(t.label){case 0:return e=this.connectOptions,i={appkey:this.options.appkey,userId:this.userId,userData:JSON.stringify(e.data),otp:e.otp,artifactVersion:this.artifactVersion,sid:this.sid},[4,d.GModules.getParams()];case 1:return i.mP=t.sent(),i.a=this.anonymous,[4,l.Z.z()];case 2:return i.z=t.sent(),[4,u.ServerMarkRepository.get()];case 3:return i.sm=t.sent(),i.c={n:this.vname,v:this.artifactVersion},n=i,JSON.stringify(n),o=new d.Rocket({name:a.RocketTypes.authorize,params:n,permission:d.Permission.NONE,singleTimeout:r.SocketTimeout.commonInfiniteSingle,totalTimeout:r.SocketTimeout.commonInfiniteTotal,success:function(e){s.onAuthorizeSuccess(e)},fail:function(e){s.onAuthorizeFailed(e)}}),this.ioSocketEmitter.emit(o),[2]}}))}))},m.prototype.onConnecting=function(){h.SEC.fire(c.SocketEvent.CONNECTING,this.reconnectingTimes),this.notify(this.connectingObservers,this.reconnectingTimes)},m.prototype.onIoReconnecting=function(){this.reconnectingTimes++,this.status==o.NetworkStatus.CONNECTED||this.status==o.NetworkStatus.EXPIRED_RECONNECTED||this.status==o.NetworkStatus.RECONNECTING?this.status=o.NetworkStatus.RECONNECTING:this.status=o.NetworkStatus.CONNECTING,this.onConnecting()},m.prototype.onIoDisconnected=function(){this.status!==o.NetworkStatus.DISCONNECTING&&(this.status=o.NetworkStatus.RECONNECTING,h.SEC.fire(c.SocketEvent.LOST),this.notify(this.disconnectedObservers))},m.prototype.onAuthorizeSuccess=function(e){(u.ServerMarkRepository.put(e),d.GModules.setDatas(e.mD),this.status===o.NetworkStatus.RECONNECTING)?this.sid!==e.sid?(this.status=o.NetworkStatus.EXPIRED_RECONNECTED,this.sid=e.sid,h.SEC.fire(c.SocketEvent.EXPIRED_RECONNECTED),this.notify(this.expiredReconnectedObservers)):(this.status=o.NetworkStatus.RECONNECTED,h.SEC.fire(c.SocketEvent.RECONNECTED)):(this.status=o.NetworkStatus.CONNECTED,this.sid=e.sid);e.enablePublish&&(this.permissions.find((function(e){return e==d.Permission.WRITE}))||this.permissions.push(d.Permission.WRITE)),e.enableSubscribe&&(this.permissions.find((function(e){return e==d.Permission.READ}))||this.permissions.push(d.Permission.READ)),this.reconnectingTimes=0,h.SEC.fire(c.SocketEvent.CONNECTED),this.notify(this.connectedObservers)},m.prototype.onAuthorizeFailed=function(e){this.ioSocket.disconnect(),this.status=o.NetworkStatus.CONNECT_FAILED;var t={code:e.resultCode||408,content:e.content||"Host unreachable or timeout"};this.notify(this.connectFailedObservers,t)},m.prototype.addConnectingObserver=function(e){i.default.isFunction(e)&&this.connectingObservers.push(e)},m.prototype.addConnectFailedObserver=function(e){i.default.isFunction(e)&&this.connectFailedObservers.push(e)},m.prototype.addExpiredReconnectedObserver=function(e){i.default.isFunction(e)&&this.expiredReconnectedObservers.push(e)},m.prototype.onMessage=function(e,t){this.ioSocket.io._callbacks.hasOwnProperty("$"+e)||this.ioSocket.io.on(e,t)},m.prototype.user=function(){var e=this.connectOptions;return e?{id:e.id,data:e.data}:null},m}(Pr.default);e.default=m}(Rr);var qc={__esModule:!0,MessageListener:void 0},jc=Lc,Vc=Ct,Hc=function(){function e(e){this.guidList=[],this.socket=e}return e.prototype.offMessage=function(e,t){jc.SEC.off(Vc.SocketEvent.NEW_MESSAGE+"_"+e,t)},e.prototype.onMessage=function(e,t){var n=this;jc.SEC.on(Vc.SocketEvent.NEW_MESSAGE+"_"+e,t),this.socket.onMessage(e,(function(t){n.fire(e,t)}))},e.prototype.fire=function(e,t){var n=this.filter(t);n&&jc.SEC.fire(Vc.SocketEvent.NEW_MESSAGE+"_"+e,n)},e.prototype.filter=function(e){if("string"==typeof e&&(e=JSON.parse(e)),e.i){if(this.guidList.findIndex((function(t){return t===e.i}))>-1)return;this.guidList.unshift(e.i),this.guidList.length>300&&this.guidList.pop()}return e},e}();qc.MessageListener=Hc,Nr.__esModule=!0,Nr.GSocket=void 0;var zc=Rr,Wc=xc,Jc=$,Xc=te,Qc=Lc,Yc=Ct,Kc=qc,$c=et,Zc=de,eu=gt,tu=function(){function e(e){this.goeasyOptions=e}return e.init=function(t){this.i=new e(t)},e.connect=function(e,t){if(this.status()!==Jc.NetworkStatus.DISCONNECTED&&Xc.default.isObject(e)&&Xc.default.isFunction(e.onFailed))e.onFailed({code:408,content:"It is already connected, don't try again until disconnect() is called. "});else{this.confirmUserIdAndData(e),Qc.SEC.init();var n=this.i;$c.GModules.preConnect(e),n.socket=new zc.default(n.goeasyOptions,e),n.socket.vname=t,n.emitter=new Wc.Emitter(n.socket),n.messageListener=new Kc.MessageListener(n.socket),$c.GModules.postConnect()}},e.confirmUserIdAndData=function(e){if($c.GModules.modules.get("GIM"))eu.default.validateId(e.id,"id"),eu.default.validateObject(e.data,"data");else if("string"==typeof e.id&&e.id.length>60)throw{code:400,content:"id over max length 60"}},e.e=function(e){this.i.emitter.emit(e)},e.sendAck=function(e,t){this.i.socket.sendAck(e,t)},e.status=function(){return this.i&&this.i.socket?this.i.socket.getStatus():Jc.NetworkStatus.DISCONNECTED},e.on=function(e,t){Qc.SEC.on(e,t)},e.off=function(e,t){Qc.SEC.off(e,t)},e.offMessage=function(e,t){this.i.messageListener.offMessage(e,t)},e.onMessage=function(e,t){"remoteEvent:".concat(e),this.i.messageListener.onMessage(e,t)},e.disconnect=function(e){this.i.socket.disconnect().then((function(){Zc.CallbackUtils.onSuccess(e)})).catch((function(t){Zc.CallbackUtils.onFailed(e,t)}))},e.user=function(){return this.i.socket.user()},e.EVENT=Yc.SocketEvent,e}();Nr.GSocket=tu,Mr.__esModule=!0,Mr.AgentStatus=void 0;var nu=Q,ou=fe,iu=pe,ru=te,su=br,au=wr,cu=wo,uu=de,lu=et,fu=Tr,pu=bt,du=Ko,hu=Nr,mu=function(){function e(){var e=this;this.synchronized=!0,this.onlineChanged=function(t){t.online?e.teamIds.add(t.teamId):e.teamIds.delete(t.teamId)},this.onDisconnected=function(){e.queryMyTeamPromise=null,e.teamIds=null},this.onConnected=function(){e.synchronized&&(e.queryMyTeamPromise=e.queryTeams())},hu.GSocket.on(hu.GSocket.EVENT.LOST,this.onDisconnected),hu.GSocket.on(hu.GSocket.EVENT.RECONNECTED,this.onConnected),hu.GSocket.onMessage(pu.RemoteEvents.CS_ONLINE_CHANGED,this.onlineChanged)}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 lu.Rocket({name:ou.RocketTypes.CS_MY_TEAMS,params:{},permission:lu.Permission.READ,singleTimeout:iu.SocketTimeout.commonQuerySingle,totalTimeout:iu.SocketTimeout.commonQueryTotal,fail:function(e){n(e)},success:function(n){e.teamIds=new Set(n.content),e.synchronized=!0,t(e.teamIds)}});lu.G.Socket.e(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 nu.__awaiter(this,void 0,void 0,(function(){return nu.__generator(this,(function(n){switch(n.label){case 0:return[4,this.queryTeams()];case 1:return n.sent(),uu.CallbackUtils.onSuccess(t,this.teamIds.has(e)),[2]}}))}))},e.prototype.online=function(e,t){var n=this;if(!ru.default.isObject(t.agentData)||!ru.default.isObject(t.teamData))throw{code:400,content:"agentData and teamData require an object"};var o=new su.CSOnlineRequest(e,t.teamData,t.agentData),i=new lu.Rocket({name:ou.RocketTypes.CS_ONLINE,params:o,permission:lu.Permission.WRITE,singleTimeout:iu.SocketTimeout.commonRequestSingle,totalTimeout:iu.SocketTimeout.commonRequestTotal,fail:function(e){uu.CallbackUtils.onFailed(t,e)},success:function(o){n.teamIds.add(e),uu.CallbackUtils.onSuccess(t),du.IMEC.i.fire(cu.IM_INTERNAL_EVENTS.CS_ONLINE_SUCCESS)}});lu.G.Socket.e(i)},e.prototype.offline=function(e,t){var n=this,o=new au.CSOfflineRequest(e),i=new lu.Rocket({name:ou.RocketTypes.CS_OFFLINE,params:o,permission:lu.Permission.WRITE,singleTimeout:iu.SocketTimeout.commonRequestSingle,totalTimeout:iu.SocketTimeout.commonRequestTotal,fail:function(e){uu.CallbackUtils.onFailed(t,e)},success:function(o){n.teamIds.delete(e),uu.CallbackUtils.onSuccess(t),du.IMEC.i.fire(cu.IM_INTERNAL_EVENTS.CS_OFFLINE_SUCCESS)}});lu.G.Socket.e(i)},e.prototype.agents=function(e,t){var n=new fu.CsAgentsQueryRequest(e),o=new lu.Rocket({name:ou.RocketTypes.CS_AGENTS,params:n,permission:lu.Permission.READ,singleTimeout:iu.SocketTimeout.commonQuerySingle,totalTimeout:iu.SocketTimeout.commonQueryTotal,fail:function(e){uu.CallbackUtils.onFailed(t,e)},success:function(e){e.content.forEach((function(e){e.data=JSON.parse(e.data)})),uu.CallbackUtils.onSuccess(t,e)}});lu.G.Socket.e(o)},e}();Mr.AgentStatus=mu,gr.__esModule=!0,gr.LiveSession=void 0;var yu=Q,gu=Z,vu=vr,Su=gt,Eu=fe,_u=pe,Mu=de,bu=et,Cu=wo,wu=Er,Iu=Ui,Tu=Mr,ku=fi,Nu=Ct,Ru=Ko,Pu=Nr,Au=function(){function e(t){this.onMessageReceived=function(t){var n=e.session;if(t.scene()===gu.Scene.CS&&n.liveOptions){var o=t,i=n.liveOptions.customerId;n.teamId===o.teamId&&o.customerId()===i&&(n.tryUpdateStatus(o),n.liveOptions.onNewMessage(o))}},this.teamId=t,Ru.IMEC.i.on(Cu.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,this.onMessageReceived),Ru.IMEC.i.on(Cu.IM_INTERNAL_EVENTS.CS_ACCEPTED,this.onMessageReceived),Ru.IMEC.i.on(Cu.IM_INTERNAL_EVENTS.CS_ENDED,this.onMessageReceived),Ru.IMEC.i.on(Cu.IM_INTERNAL_EVENTS.CS_TRANSFER,this.onMessageReceived),Pu.GSocket.on(Nu.SocketEvent.DISCONNECTED,e.destroy)}return e.live=function(t,n){return yu.__awaiter(this,void 0,void 0,(function(){var o,i,r,s=this;return yu.__generator(this,(function(a){switch(a.label){case 0:return o=n.customerId,Su.default.validateId(o,"customerId"),i=new vu.LiveSessionRequest(t,o),[4,Tu.AgentStatus.getInstance().queryTeams()];case 1:return a.sent(),r=new bu.Rocket({name:Eu.RocketTypes.CS_LIVE_SESSION,params:i,permission:bu.Permission.WRITE,singleTimeout:_u.SocketTimeout.commonRequestSingle,totalTimeout:_u.SocketTimeout.commonRequestTotal,fail:function(e){Mu.CallbackUtils.onFailed(n,e)},success:function(o){e.destroy(),s.session=new e(t),s.session.liveOptions=n;var i=o.content.customerStatus;"ACCEPTED"===i.status&&(i.agent.data=JSON.parse(i.agent.data)),s.session.status=i,s.session.liveOptions.onStatusUpdated(s.session.status),Mu.CallbackUtils.onSuccess(n)}}),bu.G.Socket.e(r),[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=Tu.AgentStatus.getInstance().myTeams(),i=n.status.agent;return o.has(t.teamId)&&(!i||i.id===bu.G.Socket.user().id)}return!0},e.isMyMessage=function(e){var t=ku.Target.byIMMessage(e);return e.type===Iu.CSMessageType.TRANSFER&&e.payload.transferTo.id===bu.G.Socket.user().id||this.isMyCustomer(t)},e.quit=function(t){var n=e.session;if(n){var o=n.liveOptions.customerId;Su.default.validateId(o,"customerId");var i=new vu.LiveSessionRequest(n.teamId,o),r=new bu.Rocket({name:Eu.RocketTypes.CS_QUIT_LIVE,params:i,permission:bu.Permission.WRITE,singleTimeout:_u.SocketTimeout.commonRequestSingle,totalTimeout:_u.SocketTimeout.commonRequestTotal,fail:function(e){Mu.CallbackUtils.onFailed(t,e)},success:function(n){e.destroy(),Mu.CallbackUtils.onSuccess(t)}});bu.G.Socket.e(r)}},e.prototype.tryUpdateStatus=function(e){if(!("FREE"!==this.status.status&&this.status.sessionId>e.sessionId)){var t;switch(e.type){case Iu.CSMessageType.ACCEPT:(t=new wu.CustomerStatus).status="ACCEPTED",t.start=e.payload.sessionStart,t.sessionId=e.sessionId,t.agent=new gu.User(e.senderId,e.senderData);break;case Iu.CSMessageType.END:(t=new wu.CustomerStatus).status="FREE";break;case Iu.CSMessageType.TRANSFER:(t=new wu.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 wu.CustomerStatus).status="PENDING",t.start=e.timestamp,t.sessionId=e.sessionId)}t&&(this.status=t,this.liveOptions.onStatusUpdated(t))}},e.destroy=function(){var t=e.session;t&&(Ru.IMEC.i.off(Cu.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,t.onMessageReceived),Ru.IMEC.i.off(Cu.IM_INTERNAL_EVENTS.CS_ACCEPTED,t.onMessageReceived),Ru.IMEC.i.off(Cu.IM_INTERNAL_EVENTS.CS_ENDED,t.onMessageReceived),Ru.IMEC.i.off(Cu.IM_INTERNAL_EVENTS.CS_TRANSFER,t.onMessageReceived),Pu.GSocket.off(Nu.SocketEvent.DISCONNECTED,e.destroy),e.session=null)},e}();gr.LiveSession=Au,function(e){e.__esModule=!0;var t=Q,n=rr,o=de,i=te,r=wo,s=et,a=Ui,c=gr,u=Ko,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 i.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 i,r,s=this;return t.__generator(this,(function(t){switch(t.label){case 0:return i=new n.default(this.target.id.toString(),this.target.scene,e,o,this.target.teamId),[4,this.remoteHistory.loadServerMessages(this.target,i)];case 1:return(r=t.sent()).userOffsets.forEach((function(e){s.userOffsets.updateOffset(e.userId,e.offset)})),[2,r.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.initMaxMessageAndOffsets=function(e,t){var n=this;t.forEach((function(e){n.userOffsets.updateOffset(e.userId,e.offset)})),(i.default.isUndef(this.acceptedMaxMessage)||this.acceptedMaxMessage.timestampthis.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(s.G.Socket.user().id,e),u.IMEC.i.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}(ri.default);e.default=l}(yr);var Ou={};!function(e){e.__esModule=!0;var t=Q,n=de,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}(ri.default);e.default=o}(Ou);var Du={__esModule:!0,HistoryValidator:void 0},xu=te,Gu=fi,Uu=Io,Lu=function(){function e(){}return e.validateMessageArray=function(e){if(!xu.default.isArray(e)||xu.default.isEmpty(e))throw{code:400,content:"messages requires non empty array"};if(e.length>20)throw{code:400,content:"The maximum number of messages is 20"};for(var t=Gu.Target.byIMMessage(e[0]),n=0;n0){var i=Gu.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}();Du.HistoryValidator=Lu,function(e){e.__esModule=!0;var t=Q,n=Z,o=te,i=ri,r=fi,s=wo,a=ui,c=bt,u=et,l=de,f=yr,p=Ou,d=Du,h=Ko,m=Nr,y=function(){function e(){var e=this;this.map=new Map,this.onMessageSending=function(t){var n=r.Target.byIMMessage(t);e.findOrCreateHistory(n).onMessageSending(t)},this.onMessageSendSuccess=function(t){var n=r.Target.byIMMessage(t);e.findHistory(n).onMessageSendSuccess(t)},this.onMessageSendFailed=function(t){var n=r.Target.byIMMessage(t);e.findHistory(n).onMessageSendFailed(t)},this.onMessageReceived=function(t){var n=r.Target.byIMMessage(t);e.findOrCreateHistory(n).onMessageReceived(t)},this.onRemoteMarkRead=function(t){var n=r.Target.byMessageReadRemoteEvent(t),o=e.findHistory(n);o&&o.syncMarkedMessage(t)},this.onRemoteMessageDeleted=function(t){var n=r.Target.byIMMessageDeletedEvent(t),o=e.findHistory(n);o&&o.syncDeletedMessage(t.deleterId,t.times)},this.onMessageRecalled=function(t){var n=r.Target.byConversationId(t.scene,t.conversationId),o=e.findHistory(n);o&&o.recallMessages(t)},this.onDisconnected=function(){e.map.forEach((function(e,t){e.expire()}))},this.destroy=function(){},this.initialListeners()}return e.init=function(){return e.instance=new e,e.instance},e.prototype.initialListeners=function(){h.IMEC.i.on(s.IM_INTERNAL_EVENTS.MESSAGE_SENDING,this.onMessageSending),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.MESSAGE_SEND_SUCCESS,this.onMessageSendSuccess),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.MESSAGE_SEND_FAILED,this.onMessageSendFailed),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.MESSAGE_RECEIVED,this.onMessageReceived),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,this.onMessageReceived),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.CS_ACCEPTED,this.onMessageReceived),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.CS_ENDED,this.onMessageReceived),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.CS_TRANSFER,this.onMessageReceived),h.IMEC.i.on(s.IM_INTERNAL_EVENTS.MESSAGE_RECALLED,this.onMessageRecalled),m.GSocket.onMessage(c.RemoteEvents.IM_MSG_READ,this.onRemoteMarkRead),m.GSocket.onMessage(c.RemoteEvents.IM_MSG_DELETED,this.onRemoteMessageDeleted),m.GSocket.on(m.GSocket.EVENT.LOST,this.onDisconnected)},e.prototype.loadHistory=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 o=this.queryToTarget(e,n),[4,this.findOrCreateHistory(o).loadHistory(e.lastTimestamp,e.limit)];case 1:return i=t.sent(),l.CallbackUtils.onSuccess(e,{code:200,content:i}),[2]}}))}))},e.prototype.queryToTarget=function(e,t){if(o.default.isDef(e.userId))return new r.Target(n.Scene.PRIVATE,e.userId);if(o.default.isDef(e.groupId))return new r.Target(n.Scene.GROUP,e.groupId);if(o.default.isDef(e.type)){if(!Object.values(n.Scene).includes(e.type))throw new Error("incorrect type, must be: "+Object.values(n.Scene));if(o.default.isUndef(e.id))throw new Error("If type is not empty, id is required.");return n.Scene.CS==e.type&&o.default.isUndef(t)&&(t=e.id),new r.Target(e.type,e.id,t)}throw new Error("incorrect query options.")},e.prototype.privateMarkAsRead=function(e){return t.__awaiter(this,void 0,void 0,(function(){var i;return t.__generator(this,(function(t){switch(t.label){case 0:if(o.default.isUndef(e.userId))throw new Error("userId could not be empty.");return i=r.Target.byScene(n.Scene.PRIVATE,e.userId),[4,this.markAsRead(i,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.groupMarkAsRead=function(e){return t.__awaiter(this,void 0,void 0,(function(){var i;return t.__generator(this,(function(t){switch(t.label){case 0:if(o.default.isUndef(e.groupId))throw new Error("groupId could not be empty.");return i=r.Target.byScene(n.Scene.GROUP,e.groupId),[4,this.markAsRead(i,e)];case 1:return t.sent(),[2]}}))}))},e.prototype.markMessageAsRead=function(e,i){return t.__awaiter(this,void 0,void 0,(function(){var s;return t.__generator(this,(function(t){switch(t.label){case 0:if(o.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&&o.default.isUndef(i)&&(i=e.id),s=r.Target.byScene(e.type,e.id,i),[4,this.markAsRead(s,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 l.CallbackUtils.onSuccess(n),[2]}}))}))},e.prototype.deleteMessage=function(e){return t.__awaiter(this,void 0,void 0,(function(){var n,o,i;return t.__generator(this,(function(t){switch(t.label){case 0:return this.validateMessageArray(e.messages),a.default.validate(e),n=e.messages[0],o=r.Target.byIMMessage(n),(i=this.findHistory(o))?[4,i.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.findOrCreateHistory=function(e){var t=this.findHistory(e);return t||(t=e.scene===n.Scene.CS?u.G.Socket.user().id===e.customerId()?new p.default(e):new f.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){d.HistoryValidator.validateMessageArray(e)},e}();e.default=y}(ii),oi.__esModule=!0,oi.Conversation=void 0;var Fu=Z,Bu=ii,qu=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 Fu.ConversationDTO;return e===Fu.Scene.PRIVATE?n.userId=t:e===Fu.Scene.GROUP?n.groupId=t:e===Fu.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 Bu.default.get(this.target).getMaxMessage()},e.prototype.getUnreadAmount=function(){return Bu.default.get(this.target).unreadAmount()},e.prototype.maxMessageTime=function(){return Bu.default.get(this.target).maxTime()},e}();oi.Conversation=qu;var ju={__esModule:!0,CSConversation:void 0},Vu=Q,Hu=ii,zu=Z,Wu=Ui,Ju=et,Xu=function(e){function t(t){var n=e.call(this,t)||this;return n.accepted=!1,n}return Vu.__extends(t,e),t.prototype.toDto=function(){var e=new zu.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===Wu.CSMessageType.END||t===Wu.CSMessageType.TRANSFER&&n.transferTo.id!==Ju.G.Socket.user().id},t.prototype.getMaxMessage=function(){return Hu.default.get(this.target).getMaxMessage(this.accepted)},t.prototype.getUnreadAmount=function(){return Hu.default.get(this.target).unreadAmount(this.accepted)},t.prototype.maxMessageTime=function(){return Hu.default.get(this.target).maxTime(this.accepted)},t}(oi.Conversation);ju.CSConversation=Xu;var Qu={},Yu={};!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}(Yu);var Ku={};!function(e){e.__esModule=!0;var t=function(e,t,n){this.type=e,this.targetId=t,this.teamId=n};e.default=t}(Ku);var $u={};!function(e){e.__esModule=!0;var t=function(e,t,n){this.type=e,this.targetId=t,this.teamId=n};e.default=t}($u),function(e){e.__esModule=!0;var t=Q,n=Yu,o=fe,i=pe,r=Ku,s=et,a=$u,c=function(){function e(){}return e.prototype.top=function(e,t){var r=new n.default(e.scene,t,e.id,e.teamId);return new Promise((function(e,t){var n=new s.Rocket({name:o.RocketTypes.topConversation,params:r,permission:s.Permission.WRITE,singleTimeout:i.SocketTimeout.commonRequestSingle,totalTimeout:i.SocketTimeout.commonRequestTotal,success:function(n){200===n.code?e(n):t(n)},fail:function(e){t(e)}});s.G.Socket.e(n)}))},e.prototype.remove=function(e){var t=new r.default(e.scene,e.id,e.teamId);return new Promise((function(e,n){var r=new s.Rocket({name:o.RocketTypes.removeConversation,params:t,permission:s.Permission.WRITE,singleTimeout:i.SocketTimeout.commonRequestSingle,totalTimeout:i.SocketTimeout.commonRequestTotal,success:function(t){200==t.code?e(t):n(t)},fail:function(e){n(e)}});s.G.Socket.e(r)}))},e.prototype.query=function(e){var n=this;return new Promise((function(o,r){var a=new s.Rocket({name:e,params:{},permission:s.Permission.READ,singleTimeout:i.SocketTimeout.commonQuerySingle,totalTimeout:i.SocketTimeout.commonQueryTotal,fail:function(e){r(e)},success:function(e){return t.__awaiter(n,void 0,void 0,(function(){return t.__generator(this,(function(t){return o(e),[2]}))}))}});s.G.Socket.e(a)}))},e.prototype.loadData=function(e){var t=new a.default(e.scene,e.id,e.teamId);return new Promise((function(e,n){var r=new s.Rocket({name:o.RocketTypes.imData,params:t,permission:s.Permission.READ,singleTimeout:i.SocketTimeout.commonQuerySingle,totalTimeout:i.SocketTimeout.commonQueryTotal,success:function(t){var n=JSON.parse(t.content);e(n)},fail:function(e){n(e)}});s.G.Socket.e(r)}))},e.instance=new e,e}();e.default=c}(Qu),ni.__esModule=!0,ni.Conversations=void 0;var Zu=Q,el=oi,tl=de,nl=Z,ol=bi,il=fe,rl=ai,sl=wo,al=fi,cl=ju,ul=Qu,ll=ii,fl=et,pl=Ui,dl=te,hl=Ko,ml=pr,yl=mr,gl=function(){function e(){this.list=new Array,this.builder=new ol.RemoteAbbrMessageBuilder,this.remoteConversations=ul.default.instance,this.synchronized=!1,hl.IMEC.i.on(sl.IM_INTERNAL_EVENTS.MAX_MESSAGE_CHANGED,this.onMaxMessageChanged.bind(this)),hl.IMEC.i.on(sl.IM_INTERNAL_EVENTS.UNREAD_AMOUNT_CHANGED,this.onUnreadMessageChanged.bind(this)),hl.IMEC.i.on(sl.IM_INTERNAL_EVENTS.MAX_MESSAGE_DELETED,this.onMaxMessageDeleted.bind(this))}return e.prototype.onUnreadMessageChanged=function(e){this.findConversation(e)&&this.fireUpdated()},e.prototype.fireUpdated=function(){var e=this.loadLocalConversations(),t=this.getUpdatedEventName();ml.AEC.fire(t,{unreadTotal:e.content.unreadTotal,conversations:e.content.conversations})},e.prototype.getUpdatedEventName=function(){return yl.ImApiEvents.CONVERSATIONS_UPDATED},e.prototype.latestConversations=function(e){return Zu.__awaiter(this,void 0,void 0,(function(){var t;return Zu.__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(),tl.CallbackUtils.onSuccess(e,t),[2]}}))}))},e.prototype.loadServerConversations=function(){return Zu.__awaiter(this,void 0,void 0,(function(){var e,t;return Zu.__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 il.RocketTypes.imLastConversations},e.prototype.convertAbbrConversation=function(e){var t,n,o=e;try{for(var i=Zu.__values(o),r=i.next();!r.done;r=i.next()){var s=r.value,a=s.t,c=s.top,u=s.d?JSON.parse(s.d):{},l=s.userOffsets;s.lmsg.t=a;var f=s.lmsg,p=this.builder.build(f),d=al.Target.byIMMessage(p),h=this.findConversation(d);dl.default.isUndef(h)?(h=this.buildByAbbr(s,p),this.insertOne(h)):(h.top=c,h.data=u),ll.default.get(d).initMaxMessageAndOffsets(p,l),this.correctPosition(h)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},e.prototype.onMaxMessageDeleted=function(e){this.removeConversation(e)},e.prototype.onMaxMessageChanged=function(e){return Zu.__awaiter(this,void 0,void 0,(function(){var t;return Zu.__generator(this,(function(n){switch(n.label){case 0:return e.scene()===nl.Scene.CS&&(t=e,fl.G.Socket.user().id!=t.customerId()&&(!1===t.accepted||t.type===pl.CSMessageType.ACCEPT&&t.senderId!=fl.G.Socket.user().id))?[2]:[4,this.saveOrUpdateConversation(e)];case 1:return n.sent(),[2]}}))}))},e.prototype.saveOrUpdateConversation=function(e){return Zu.__awaiter(this,void 0,void 0,(function(){var t,n,o,i;return Zu.__generator(this,(function(r){switch(r.label){case 0:return t=e.status,n=al.Target.byIMMessage(e),o=this.findConversation(n),dl.default.isUndef(o)&&t!==nl.MessageStatus.FAIL?(o=this.buildByMessage(e),this.insertOne(o),t!==nl.MessageStatus.SUCCESS?[3,2]:(i=o,[4,this.remoteConversations.loadData(n)])):[3,2];case 1:i.data=r.sent(),o.dataLoaded=!0,r.label=2;case 2:return t===nl.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 i=Zu.__values(this.list),r=i.next();!r.done;r=i.next()){var s=r.value;if(s.dataLoaded&&s.getMaxMessage()){n+=s.getUnreadAmount();var a=s.toDto();o.push(a)}}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=i.return)&&t.call(i)}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 Zu.__awaiter(this,void 0,void 0,(function(){var o;return Zu.__generator(this,(function(i){switch(i.label){case 0:if(!dl.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:i.sent(),o.top=t,this.correctPosition(o),i.label=2;case 2:return this.fireUpdated(),tl.CallbackUtils.onSuccess(n),[2]}}))}))},e.prototype.remove=function(e,t){return Zu.__awaiter(this,void 0,void 0,(function(){var n;return Zu.__generator(this,(function(o){switch(o.label){case 0:if(!(n=this.findConversation(e)))throw new Error("conversation does not exist.");if(n instanceof cl.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(),tl.CallbackUtils.onSuccess(t),[2]}}))}))},e.prototype.buildByAbbr=function(e,t){var n,o=al.Target.byIMMessage(t);if(e.t===nl.Scene.CS){var i=t;fl.G.Socket.user().id===i.customerId()?n=new el.Conversation(o):(n=new cl.CSConversation(o)).accepted=i.accepted}else n=new el.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=al.Target.byIMMessage(e);if(e.scene()===nl.Scene.CS){var o=e;fl.G.Socket.user().id===o.customerId()?t=new el.Conversation(n):(t=new cl.CSConversation(n)).accepted=o.accepted}else t=new el.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 Zu.__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}(rl.SortedInserter)),e}();ni.Conversations=gl;var vl={},Sl={__esModule:!0,GIMModule:void 0},El=Q,_l=Sn,Ml=Z,bl=ee,Cl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return El.__extends(t,e),t.init=function(){return this.module=new t,this.module.name=this.GIM_MODULE_NAME,this.initGN(),this.module},t.initGN=function(){bl.GN.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===Ml.Scene.GROUP&&(t.groupId=e.gid),t},e.prototype.support=function(e){return!!e.sid},e}()))},t.prototype.postConnect=function(){_l.IM.init()},t.check=function(){if(!this.module)throw{code:400,content:"IM not initialized. Please include 'IM' in the 'modules' during GoEasy initialization."}},t.GIM_MODULE_NAME="GIM",t}(et.GModule);Sl.GIMModule=Cl,vl.__esModule=!0,vl.PendingConversations=void 0;var wl=Q,Il=Z,Tl=fe,kl=fi,Nl=wo,Rl=Ui,Pl=ii,Al=ju,Ol=et,Dl=te,xl=Sl,Gl=Ko,Ul=Nr,Ll=mr,Fl=function(e){function t(){var t=e.call(this)||this;return t.expired=!1,Gl.IMEC.i.on(Nl.IM_INTERNAL_EVENTS.CS_ONLINE_SUCCESS,t.onCSOnlineSuccess.bind(t)),Gl.IMEC.i.on(Nl.IM_INTERNAL_EVENTS.CS_OFFLINE_SUCCESS,t.onCSOfflineSuccess.bind(t)),Ul.GSocket.on(Ul.GSocket.EVENT.LOST,t.onDisconnected.bind(t)),Ul.GSocket.on(Ul.GSocket.EVENT.RECONNECTED,t.onConnected.bind(t)),t}return wl.__extends(t,e),t.prototype.onMaxMessageChanged=function(e){return wl.__awaiter(this,void 0,void 0,(function(){var t,n;return wl.__generator(this,(function(o){switch(o.label){case 0:return e.scene()!==Il.Scene.CS||((t=e).customerId()==Ol.G.Socket.user().id||!1!==t.accepted&&t.type!==Rl.CSMessageType.ACCEPT)?[3,3]:Rl.CSMessageType.ACCEPT!==e.type?[3,1]:(n=kl.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 wl.__awaiter(this,void 0,void 0,(function(){var n;return wl.__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 wl.__awaiter(this,void 0,void 0,(function(){return wl.__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 Ll.ImApiEvents.PENDING_CONVERSATIONS_UPDATED},t.prototype.rocketName=function(){return Tl.RocketTypes.CS_PENDING_CONVERSATION},t.prototype.convertAbbrConversation=function(e){return wl.__awaiter(this,void 0,void 0,(function(){var t,n,o,i,r,s,a,c,u,l,f,p,d;return wl.__generator(this,(function(h){t=e;try{for(n=wl.__values(t),o=n.next();!o.done;o=n.next())(i=o.value).lastMessage.t=Il.Scene.CS,r=i.customerData,s=i.lastMessage,a=i.userOffsets,c=r?JSON.parse(r):{},u=this.builder.build(s),l=kl.Target.byIMMessage(u),f=this.findConversation(l),Dl.default.isUndef(f)&&((f=new Al.CSConversation(l)).accepted=u.accepted,f.dataLoaded=!0,this.insertOne(f)),f.top=!1,f.data=c,Pl.default.get(l).initPendingMaxMessageAndOffsets(u,a),this.correctPosition(f)}catch(e){p={error:e}}finally{try{o&&!o.done&&(d=n.return)&&d.call(n)}finally{if(p)throw p.error}}return[2]}))}))},t.prototype.onDisconnected=function(){this.expired=!0},t.prototype.onConnected=function(){return wl.__awaiter(this,void 0,void 0,(function(){return wl.__generator(this,(function(e){switch(e.label){case 0:return this.expired&&xl.GIMModule.module&&xl.GIMModule.module.active?(this.expired=!1,this.list=[],[4,this.loadServerConversations()]):[3,2];case 1:e.sent(),this.fireUpdated(),e.label=2;case 2:return[2]}}))}))},t}(ni.Conversations);vl.PendingConversations=Fl,function(e){e.__esModule=!0;var t=ni,n=fi,o=Z,i=vl,r=Ai,s=et,a=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(o.Scene.PRIVATE,e.userId);this.conversations.top(t,e.top,e)},e.prototype.topGroupConversation=function(e){var t=n.Target.byScene(o.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(o.Scene.PRIVATE,e.userId);this.conversations.remove(t,e)},e.prototype.removeGroupConversation=function(e){var t=n.Target.byScene(o.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 o.ConversationDTO))throw new Error("Incorrect conversation object.");var t=e.lastMessage;if(t instanceof r.CSMessage&&t.customerId()!==s.G.Socket.user().id&&!1===t.accepted)throw new Error("pending conversation cannot be topped or removed.")},e}();e.default=a}(ti);var Bl={};!function(e){e.__esModule=!0;var t=wo,n=bi,o=bt,i=te,r=Z,s=et,a=ii,c=fi,u=Ko,l=pr,f=mr,p=function(){function e(){this.builder=new n.RemoteAbbrMessageBuilder,s.G.Socket.onMessage(o.RemoteEvents.imMessage,this.onMessageReceived.bind(this))}return e.prototype.onMessageReceived=function(e){if(e.t!==r.Scene.CS){var n=this.builder.build(e);this.sendAck(n);var o=c.Target.byIMMessage(n),i=o.scene;a.default.get(o).existsMessage(n)||(this.createNotification(e),u.IMEC.i.fire(t.IM_INTERNAL_EVENTS.MESSAGE_RECEIVED,n),i===r.Scene.PRIVATE?l.AEC.fire(f.ImApiEvents.PRIVATE_MESSAGE_RECEIVED,n):i===r.Scene.GROUP&&l.AEC.fire(f.ImApiEvents.GROUP_MESSAGE_RECEIVED,n))}},e.prototype.sendAck=function(e){s.G.Socket.sendAck("imAck",{publishGuid:e.messageId})},e.prototype.createNotification=function(e){var t=s.G.N.supportAppNotification();if(i.default.isObject(e.nt)&&e.s!==s.G.Socket.user().id&&t){var n={id:e.i,tm:e.ts,t:e.mt,sid:e.s,tt:e.t};n.tt===r.Scene.GROUP&&(n.gid=e.r),s.G.N.createLocalNotification(e.nt.t,e.nt.c,n,e.nt.sound,e.nt.badge)}},e}();e.default=p}(Bl);var ql={};!function(e){e.__esModule=!0;var t=pe,n=gt,o=fe,i=de,r=et,s=function(){function e(){}return e.prototype.subscribe=function(e){n.default.validateIdArray(e.groupIds,"groupIds"),e.groupIds=e.groupIds.toString().split(",");var s=new r.Rocket({name:o.RocketTypes.subscribeGroups,params:{groupIds:e.groupIds,at:e.accessToken},permission:r.Permission.WRITE,singleTimeout:t.SocketTimeout.commonRequestSingle,totalTimeout:t.SocketTimeout.commonRequestTotal,success:function(){i.CallbackUtils.onSuccess(e,{code:200,content:"ok"})},fail:function(t){i.CallbackUtils.onFailed(e,{code:t.resultCode||408,content:t.content||"Failed to subscribe group message"})}});r.G.Socket.e(s)},e.prototype.unsubscribe=function(e){n.default.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();var s=new r.Rocket({name:o.RocketTypes.unsubscribeGroup,params:{groupId:e.groupId},permission:r.Permission.READ,singleTimeout:t.SocketTimeout.commonRequestSingle,totalTimeout:t.SocketTimeout.commonRequestTotal,success:function(){i.CallbackUtils.onSuccess(e,{code:200,content:"ok"})},fail:function(t){i.CallbackUtils.onFailed(e,{code:t.resultCode||408,content:t.content||"Failed to unsubscribe group message"})}});r.G.Socket.e(s)},e}();e.default=s}(ql);var jl={};!function(e){e.__esModule=!0;var t=pe,n=fe,o=bt,i=gt,r=de,s=et,a=Nr,c=pr,u=mr,l=function(){function e(){this.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};c.AEC.fire(u.ImApiEvents.GROUP_PRESENCE,o)}))},a.GSocket.onMessage(o.RemoteEvents.groupPresence,this.newMessageReceived)}return e.prototype.presence=function(e){i.default.validateIdArray(e.groupIds,"groupIds"),e.groupIds.toString().split(",");var o={groupIds:e.groupIds};this.emitRocket(n.RocketTypes.subscribeGroupPresence,o,(function(){r.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){r.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to subscribe group message"})}),t.SocketTimeout.commonRequestSingle,t.SocketTimeout.commonRequestTotal)},e.prototype.unPresence=function(e){i.default.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();var o={groupId:e.groupId};this.emitRocket(n.RocketTypes.unsubscribeGroupPresence,o,(function(){r.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){r.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}),t.SocketTimeout.commonRequestSingle,t.SocketTimeout.commonRequestTotal)},e.prototype.emitRocket=function(e,t,n,o,i,r){var a=new s.Rocket({name:e,params:t,singleTimeout:i,totalTimeout:r,permission:s.Permission.WRITE,success:n,fail:o});s.G.Socket.e(a)},e}();e.default=l}(jl);var Vl={};!function(e){e.__esModule=!0;var t=pe,n=fe,o=gt,i=de,r=et,s=function(){function e(){}return e.prototype.get=function(e){o.default.validateId(e.groupId,"groupId"),e.groupId=e.groupId.toString();var s=new r.Rocket({name:n.RocketTypes.imGroupOnlineCount,params:{groupId:e.groupId},permission:r.Permission.READ,singleTimeout:t.SocketTimeout.commonQuerySingle,totalTimeout:t.SocketTimeout.commonQueryTotal,fail:function(t){i.CallbackUtils.onFailed(e,t||{code:408,content:"Failed to query online group users"})},success:function(t){200==t.code?i.CallbackUtils.onSuccess(e,t):i.CallbackUtils.onFailed(e,t)}});r.G.Socket.e(s)},e}();e.default=s}(Vl);var Hl={},zl={__esModule:!0,IMHereNow:void 0},Wl=pe,Jl=de,Xl=et,Ql=function(){function e(){}return e.prototype.doHereNow=function(e,t,n){var o=new Xl.Rocket({name:e,params:t,permission:Xl.Permission.READ,singleTimeout:Wl.SocketTimeout.commonQuerySingle,totalTimeout:Wl.SocketTimeout.commonQueryTotal,fail:function(e){Jl.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}})),Jl.CallbackUtils.onSuccess(n,e)}});Xl.G.Socket.e(o)},e}();zl.IMHereNow=Ql,function(e){e.__esModule=!0;var t=Q,n=fe,o=gt,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.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)},i}(zl.IMHereNow);e.default=i}(Hl);var Yl={};!function(e){e.__esModule=!0;var t=pe,n=gt,o=fe,i=bt,r=de,s=et,a=Nr,c=pr,u=mr,l=function(){function e(){this.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};c.AEC.fire(u.ImApiEvents.USER_PRESENCE,n)}))},a.GSocket.onMessage(i.RemoteEvents.userPresence,this.newMessageReceived)}return e.prototype.presence=function(e){n.default.validateIdArray(e.userIds,"userIds"),e.userIds.toString().split(",");var i={userIds:e.userIds};this.emitRocket(o.RocketTypes.subscribeUserPresence,i,(function(){r.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){r.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to subscribe group message"})}),t.SocketTimeout.commonRequestSingle,t.SocketTimeout.commonRequestTotal)},e.prototype.unPresence=function(e){n.default.validateId(e.userId,"userId"),e.userId=e.userId.toString();var i={userId:e.userId};this.emitRocket(o.RocketTypes.unsubscribeUserPresence,i,(function(){r.CallbackUtils.onSuccess(e,{code:200,content:"ok"})}),(function(t){r.CallbackUtils.onFailed(e,{code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}),t.SocketTimeout.commonRequestSingle,t.SocketTimeout.commonRequestTotal)},e.prototype.emitRocket=function(e,t,n,o,i,r){var a=new s.Rocket({name:e,params:t,singleTimeout:i,totalTimeout:r,permission:s.Permission.WRITE,success:n,fail:o});s.G.Socket.e(a)},e}();e.default=l}(Yl);var Kl={};!function(e){e.__esModule=!0;var t=Q,n=fe,o=gt,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.hereNow=function(e){var t=e.userIds;o.default.validateIdArray(t,"userIds"),t.toString().split(","),this.doHereNow(n.RocketTypes.imHereNow,e,e)},i}(zl.IMHereNow);e.default=i}(Kl);var $l={},Zl={},ef={__esModule:!0,str:void 0},tf=te,nf=function(){function e(){}return e.prototype.fileExtension=function(e,t){if(tf.default.isString(e))try{var n=e.split(t);return n[n.length-1]}catch(e){throw Error(e)}},e}(),of=new nf;ef.str=of;var rf={},sf={},af={__esModule:!0,AbstractMessagePayload:void 0},cf=function(){};af.AbstractMessagePayload=cf,sf.__esModule=!0,sf.FileMessagePayload=void 0;var uf=Q,lf=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 uf.__extends(t,e),t}(af.AbstractMessagePayload);sf.FileMessagePayload=lf,rf.__esModule=!0,rf.ImageMessagePayload=void 0;var ff=Q,pf=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.width=0,t.height=0,t}return ff.__extends(t,e),t}(sf.FileMessagePayload);rf.ImageMessagePayload=pf;var df={},hf={__esModule:!0,AbstractPayloadBuilder:void 0},mf=function(){function e(){}return e.prototype.build=function(e){this.validate(e.createOptions);var t=this.create();return this.setPayload(e,t),t},e}();hf.AbstractPayloadBuilder=mf,function(e){e.__esModule=!0;var t=Q,n=sf,o=te,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.FileMessagePayload},i.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()},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}(hf.AbstractPayloadBuilder);e.default=i}(df),function(e){e.__esModule=!0;var t=Q,n=ef,o=te,i=rf,r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype.create=function(){return new i.ImageMessagePayload},r.prototype.setPayload=function(t,i){e.prototype.setPayload.call(this,t,i);var r=t.createOptions.file,s=i,a=r.path||r.tempFilePath,c=o.default.isEmpty(r.name)||void 0===r.name?a:r.name;s.name="wx-image."+n.str.fileExtension(c,"."),s.contentType="image/"+n.str.fileExtension(c,"."),s.url=a,s.size=r.size,t.complete=new Promise((function(e,t){wx.getImageInfo({src:s.url,success:function(t){s.width=t.width,s.height=t.height,e()},fail:function(e){t(e)}})}))},r.prototype.validate=function(t){e.prototype.validate.call(this,t)},r}(df.default);e.default=r}(Zl);var yf={},gf={__esModule:!0,AudioMessagePayload:void 0},vf=Q,Sf=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.duration=0,t}return vf.__extends(t,e),t}(sf.FileMessagePayload);gf.AudioMessagePayload=Sf,function(e){e.__esModule=!0;var t=Q,n=gf,o=te,i=ef,r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype.create=function(){return new n.AudioMessagePayload},r.prototype.setPayload=function(t,n){e.prototype.setPayload.call(this,t,n);var r=t.createOptions.file,s=n,a=r.tempFilePath,c=o.default.isEmpty(r.name)||null==r.name?a:r.name,u=r.duration,l=r.fileSize;s.url=a,s.size=l,s.duration=u/1e3,s.name="wx-audio."+i.str.fileExtension(c,"."),s.contentType="audio/"+i.str.fileExtension(c,"."),t.complete=Promise.resolve()},r.prototype.validate=function(t){e.prototype.validate.call(this,t)},r}(df.default);e.default=r}(yf);var Ef={},_f={__esModule:!0,TextMessagePayload:void 0},Mf=Q,bf=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.text="",t}return Mf.__extends(t,e),t}(af.AbstractMessagePayload);_f.TextMessagePayload=bf,Ef.__esModule=!0,Ef.TextPayloadBuilder=void 0;var Cf=Q,wf=_f,If=te,Tf=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Cf.__extends(t,e),t.prototype.create=function(){return new wf.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(If.default.isEmpty(e.text))throw{code:400,content:"text is empty"};if(!If.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}(hf.AbstractPayloadBuilder);Ef.TextPayloadBuilder=Tf;var kf={},Nf={__esModule:!0,VideoMessagePayload:void 0},Rf=Q,Pf=ne,Af=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.video=new Df,t.thumbnail=new Of,t}return Rf.__extends(t,e),t}(af.AbstractMessagePayload);Nf.VideoMessagePayload=Af;var Of=function(){function e(){this.name="",this.url="",this.width=0,this.height=0,this.contentType=""}return e.prototype.initURL=function(e){Pf.PlatformDetector.currentPlatform()===Pf.PlatformType.BROWSER&&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}(),Df=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=Q,n=Nf,o=te,i=ef,r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype.create=function(){return new n.VideoMessagePayload},r.prototype.setPayload=function(e,t){var n=e.createOptions.file,r=t,s=r.video,a=r.thumbnail,c=n.duration,u=n.height,l=n.size,f=n.tempFilePath,p=n.thumbTempFilePath,d=n.width,h=n.name,m=void 0===h?"":h,y=o.default.isEmpty(m)?f:m;s.contentType="video/"+i.str.fileExtension(y,"."),s.name="wx-video."+i.str.fileExtension(y,"."),s.url=f,s.width=a.width=d,s.height=a.height=u,s.size=l,s.duration=c,a.url=p,a.contentType="image/jpg",a.name="wx-thumbnail.jpg",e.complete=Promise.resolve()},r.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.")},r}(hf.AbstractPayloadBuilder);e.default=r}(kf);var xf={},Gf={};!function(e){e.__esModule=!0;var t=Q,n=sf,o=te,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.FileMessagePayload},i.prototype.setPayload=function(e,t){var n=t,o=e.createOptions.file;n.url=o.fullPath||o.path,n.name=o.name,n.size=o.size,n.contentType=o.type,o.type,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}(hf.AbstractPayloadBuilder);e.default=i}(Gf),function(e){e.__esModule=!0;var t=Q,n=ef,o=te,i=rf,r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype.create=function(){return new i.ImageMessagePayload},r.prototype.setPayload=function(e,t){var i=t,r=e.createOptions.file;i.url=r.path,i.size=r.size;var s=o.default.isEmpty(r.name)||void 0===r.name?r.path:r.name;i.contentType="image/"+n.str.fileExtension(s,"."),i.name="uni-image."+n.str.fileExtension(s,"."),e.complete=new Promise((function(e,t){uni.getImageInfo({src:r.path,success:function(t){i.width=t.width,i.height=t.height,e()},fail:function(e){t(e)}})}))},r.prototype.validate=function(t){e.prototype.validate.call(this,t)},r}(Gf.default);e.default=r}(xf);var Uf={};!function(e){e.__esModule=!0;var t=Q,n=te,o=ef,i=gf,r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype.create=function(){return new i.AudioMessagePayload},r.prototype.setPayload=function(e,t){var i=e.createOptions,r=t,s=i.file,a=s.tempFilePath,c=n.default.isEmpty(s.name)||null==s.name?a:s.name;r.url=a,r.name="uni-audio."+o.str.fileExtension(c,"."),r.contentType="audio/"+o.str.fileExtension(c,"."),e.complete=new Promise((function(e,t){uni.getFileInfo({filePath:a,success:function(o){var s=o.size;if(r.size=s,0===s)e();else if(n.default.isDef(i.file.duration))r.duration=i.file.duration/1e3,e();else{var c=uni.createInnerAudioContext();c.src=a,c.onCanplay((function(n){n.errCode?(c.destroy(),t(n)):(r.duration=c.duration,c.destroy(),e())})),c.onError((function(n){c.destroy(),-99===n.errCode?e():t(n)}))}},fail:function(e){t(e)}})}))},r.prototype.validate=function(t){e.prototype.validate.call(this,t)},r}(Gf.default);e.default=r}(Uf);var Lf={};!function(e){e.__esModule=!0;var t=Q,n=te,o=ef,i=Nf,r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype.create=function(){return new i.VideoMessagePayload},r.prototype.setPayload=function(e,t){var i=e.createOptions.file,r=t,s=r.video,a=r.thumbnail,c=i.duration,u=i.height,l=i.size,f=i.tempFilePath,p=i.width,d=i.name,h=void 0===d?"":d,m=n.default.isEmpty(h)?f:h;s.size=l,s.width=p,s.height=u,s.url=f,s.duration=c,s.contentType="video/"+o.str.fileExtension(m,"."),s.name="uni-video."+o.str.fileExtension(m,"."),a.url=f,a.height=200,a.width=Number((s.width*a.height/s.height).toFixed(0)),a.contentType="image/jpg",a.name="uni-thumbnail.jpg",e.complete=Promise.resolve()},r.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.")},r}(hf.AbstractPayloadBuilder);e.default=r}(Lf);var Ff={},Bf={};!function(e){e.__esModule=!0;var t=Q,n=sf,o=te,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.FileMessagePayload},i.prototype.setPayload=function(e,t){var n=t,o=e.createOptions.file,i=window.URL||window.webkitURL;n.url=i.createObjectURL(o),n.name=o.name,n.size=o.size,n.contentType=o.type,e.complete=Promise.resolve()},i.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")},i}(hf.AbstractPayloadBuilder);e.default=i}(Bf),function(e){e.__esModule=!0;var t=Q,n=rf,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,i=n,r=window.URL||window.webkitURL,s=new Image;s.src=r.createObjectURL(o),t.complete=new Promise((function(e,t){s.onload=function(){i.width=s.width,i.height=s.height,r.revokeObjectURL(s.src),e()},s.onerror=function(e){r.revokeObjectURL(s.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}(Bf.default);e.default=o}(Ff);var qf={};!function(e){e.__esModule=!0;var t=Q,n=gf,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,i=n,r=window.URL||window.webkitURL,s=document.createElement("audio");s.src=r.createObjectURL(o),t.complete=new Promise((function(e,t){s.onloadedmetadata=function(){i.duration=s.duration,r.revokeObjectURL(s.src),e()},s.onerror=function(e){r.revokeObjectURL(s.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}(Bf.default);e.default=o}(qf);var jf={};!function(e){e.__esModule=!0;var t=Q,n=Nf,o=te,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=this,o=e.createOptions.file,i=t,r=i.video,s=i.thumbnail,a=window.URL||window.webkitURL,c=document.createElement("video");c.src=a.createObjectURL(o),r.size=o.size,r.name=o.name,r.contentType=o.type,r.url=c.src,s.name=o.name,s.contentType="image/jpg",e.complete=new Promise((function(e,t){c.onloadedmetadata=function(){r.duration=c.duration,r.width=c.videoWidth,r.height=c.videoHeight,s.width=c.videoWidth,s.height=c.videoHeight,s.url=n.getThumbnailUrl(c),a.revokeObjectURL(c.src),e()},c.onerror=function(e){a.revokeObjectURL(c.src),t(e)}}))},i.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")},i.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.")},i}(hf.AbstractPayloadBuilder);e.default=i}(jf);var Vf={};!function(e){e.__esModule=!0;var t=Q,n=te,o=Nf,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new o.VideoMessagePayload},i.prototype.setPayload=function(e,t){var n=e.createOptions.file,o=t,i=o.video,r=o.thumbnail,s=n.duration,a=n.height,c=n.size,u=n.tempFilePath,l=n.tempVideoThumbPath,f=n.width;i.size=c,i.width=f,i.height=a,i.url=u,i.duration=s,i.contentType="video/mp4",i.name="ali-video.mp4",r.url=l,r.height=200,r.width=Number((i.width*r.height/i.height).toFixed(0)),r.contentType="image/jpg",r.name="ali-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}(hf.AbstractPayloadBuilder);e.default=i}(Vf);var Hf={},zf={};!function(e){e.__esModule=!0;var t=Q,n=sf,o=te,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.FileMessagePayload},i.prototype.setPayload=function(e,t){e.complete=Promise.reject("Alipay not support file message.")},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}(hf.AbstractPayloadBuilder);e.default=i}(zf),function(e){e.__esModule=!0;var t=Q,n=rf,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(e,t){var n=t,o=e.createOptions.file;n.url=o.path,n.size=o.size,e.complete=new Promise((function(e,t){my.getImageInfo({src:o.path,success:function(t){n.width=t.width,n.height=t.height,n.contentType="image/"+t.type,n.name="ali-image."+t.type,e()},fail:function(e){t(e)}})}))},o.prototype.validate=function(t){e.prototype.validate.call(this,t)},o}(zf.default);e.default=o}(Hf);var Wf={};!function(e){e.__esModule=!0;var t=Q,n=ef,o=gf,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new o.AudioMessagePayload},i.prototype.setPayload=function(e,t){var o=t,i=e.createOptions.file,r=i.tempFilePath;o.url=r,o.name="ali-audio."+n.str.fileExtension(r,"."),o.contentType="audio/"+n.str.fileExtension(r,"."),o.duration=i.duration,o.size=i.fileSize,e.complete=Promise.resolve()},i.prototype.validate=function(t){e.prototype.validate.call(this,t)},i}(zf.default);e.default=i}(Wf);var Jf={};!function(e){e.__esModule=!0;var t=Q,n=te,o=Nf,i=ef,r=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(r,e),r.prototype.create=function(){return new o.VideoMessagePayload},r.prototype.setPayload=function(e,t){var n=e.createOptions.file,o=t,r=o.video,s=o.thumbnail,a=n.duration,c=n.height,u=n.size,l=n.tempFilePath,f=n.thumbTempFilePath,p=n.width;r.size=u,r.width=p,r.height=c,r.url=l,r.duration=a,r.contentType="video/"+i.str.fileExtension(l,"."),r.name="baidu-video."+i.str.fileExtension(l,"."),s.url=f,s.height=200,s.width=Number((r.width*s.height/r.height).toFixed(0)),s.contentType="image/"+i.str.fileExtension(f,"."),s.name="baidu-thumbnail."+i.str.fileExtension(l,"."),e.complete=Promise.resolve()},r.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.")},r}(hf.AbstractPayloadBuilder);e.default=r}(Jf);var Xf={};!function(e){e.__esModule=!0;var t=Q,n=sf,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.FileMessagePayload},o.prototype.setPayload=function(e,t){e.complete=Promise.reject("Baidu app not support file message.")},o.prototype.validate=function(e){},o}(hf.AbstractPayloadBuilder);e.default=o}(Xf);var Qf={};!function(e){e.__esModule=!0;var t=Q,n=ef,o=gf,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new o.AudioMessagePayload},i.prototype.setPayload=function(e,t){var o=t,i=e.createOptions.file,r=i.tempFilePath;o.url=r,o.name="baidu-audio."+n.str.fileExtension(r,"."),o.contentType="audio/"+n.str.fileExtension(r,"."),o.duration=i.duration/1e3,o.size=i.fileSize,e.complete=Promise.resolve()},i.prototype.validate=function(t){e.prototype.validate.call(this,t)},i}(Xf.default);e.default=i}(Qf);var Yf={};!function(e){e.__esModule=!0;var t=Q,n=rf,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(e,t){var n=t,o=e.createOptions.file;n.url=o.path,n.size=o.size,e.complete=new Promise((function(e,t){swan.getImageInfo({src:o.path,success:function(t){n.width=t.width,n.height=t.height,n.contentType="image/"+t.type,n.name="baidu-image."+t.type,e()},fail:function(e){t(e)}})}))},o.prototype.validate=function(t){e.prototype.validate.call(this,t)},o}(Xf.default);e.default=o}(Yf);var Kf={},$f={};!function(e){e.__esModule=!0;var t=Q,n=sf,o=te,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.FileMessagePayload},i.prototype.setPayload=function(e,t){var n=t,o=e.createOptions.file,i=o.uri,r=o.type,s=o.size,a=o.name;n.url=decodeURIComponent(i),n.name=a,n.size=s,n.contentType=r,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}(hf.AbstractPayloadBuilder);e.default=i}($f),function(e){e.__esModule=!0;var t=Q,n=rf,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(e,t){var n=t,o=e.createOptions.file,i=o.uri,r=o.fileSize,s=o.type,a=o.fileName,c=o.width,u=o.height;n.url=i,n.size=r,n.contentType=s,n.name=a,n.width=c,n.height=u,e.complete=Promise.resolve()},o.prototype.validate=function(t){e.prototype.validate.call(this,t)},o}($f.default);e.default=o}(Kf);var Zf={};!function(e){e.__esModule=!0;var t=Q,n=te,o=Nf,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new o.VideoMessagePayload},i.prototype.setPayload=function(e,t){var n=e.createOptions.file,o=t,i=o.video,r=o.thumbnail,s=n.uri,a=n.type,c=n.fileSize,u=n.fileName,l=n.duration,f=n.height,p=n.width;i.size=c,i.width=p,i.height=f,i.url=s,i.duration=l,i.contentType=a,i.name=u,r.url=s,r.name="rn-thumbnail.jpg",r.height=200,r.width=Number((i.width*r.height/i.height).toFixed(0)),r.contentType="image/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}(hf.AbstractPayloadBuilder);e.default=i}(Zf);var ep={};!function(e){e.__esModule=!0;var t=Q,n=ef,o=gf,i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(i,e),i.prototype.create=function(){return new o.AudioMessagePayload},i.prototype.setPayload=function(e,t){var o=e.createOptions,i=t,r=o.file,s=r.uri,a=r.name,c=r.duration,u=r.size;i.url=s,i.duration=Number((c/1e3).toFixed(2)),i.size=u,i.name=a||"rn-audio."+n.str.fileExtension(s,"."),i.contentType="audio/"+n.str.fileExtension(s,"."),o.file={uri:s,type:i.contentType,name:i.name},e.complete=Promise.resolve()},i.prototype.validate=function(t){e.prototype.validate.call(this,t)},i}($f.default);e.default=i}(ep);var tp={},np={};!function(e){e.__esModule=!0;var t=Q,n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return t.__extends(n,e),n}(af.AbstractMessagePayload);e.default=n}(np),tp.__esModule=!0,tp.CustomPayloadBuilder=void 0;var op=Q,ip=np,rp=te,sp=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return op.__extends(t,e),t.prototype.create=function(){return new ip.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(rp.default.isEmpty(t))throw Error("type is empty.");if(!rp.default.isString(t))throw Error("type require a string");if(rp.default.isEmpty(n))throw Error("payload is empty.");if(!rp.default.isPlainObject(n)&&!rp.default.isStringOrNumber(n))throw Error("payload require object | string | number.")},t}(hf.AbstractPayloadBuilder);tp.CustomPayloadBuilder=sp;var ap={__esModule:!0,LocalIMMessageBuildOptions:void 0},cp=function(e,t){this.type=e,this.createOptions=t};ap.LocalIMMessageBuildOptions=cp,$l.__esModule=!0,$l.IMMessageBuilder=void 0;var up=y,lp=Zl,fp=df,pp=yf,dp=Ef,hp=kf,mp=xf,yp=Gf,gp=Uf,vp=Lf,Sp=Ff,Ep=Bf,_p=qf,Mp=jf,bp=Vf,Cp=Hf,wp=Wf,Ip=zf,Tp=Jf,kp=Xf,Np=Qf,Rp=Yf,Pp=Kf,Ap=Zf,Op=ep,Dp=$f,xp=tp,Gp=ap,Up=te,Lp=Z,Fp=ki,Bp=Ci,qp=gt,jp=Ai,Vp=de,Hp=et,zp=ne,Wp=function(){function e(){var e;this.framework=up.FrameworkDetector.currentFramework(),this.platform=zp.PlatformDetector.currentPlatform(),this.payloadBuilders=((e={})[up.Framework.UNIAPP]={image:new mp.default,file:new yp.default,audio:new gp.default,video:new vp.default,text:new dp.TextPayloadBuilder},e[zp.PlatformType.MP_WX]={image:new lp.default,file:new fp.default,audio:new pp.default,video:new hp.default,text:new dp.TextPayloadBuilder},e[zp.PlatformType.BROWSER]={image:new Sp.default,file:new Ep.default,audio:new _p.default,video:new Mp.default,text:new dp.TextPayloadBuilder},e[zp.PlatformType.MP_ALI]={image:new Cp.default,file:new Ip.default,audio:new wp.default,video:new bp.default,text:new dp.TextPayloadBuilder},e[zp.PlatformType.MP_BAIDU]={image:new Rp.default,file:new kp.default,audio:new Np.default,video:new Tp.default,text:new dp.TextPayloadBuilder},e[up.Framework.REACT_NATIVE]={image:new Pp.default,file:new Dp.default,audio:new Op.default,video:new Ap.default,text:new dp.TextPayloadBuilder},e[zp.PlatformType.MP_BYTE]={image:new lp.default,file:new fp.default,audio:new pp.default,video:new hp.default,text:new dp.TextPayloadBuilder},e)}return e.prototype.buildMessage=function(e,t){var n=this.framework===up.Framework.UNKNOWN?this.platform:this.framework,o=this.payloadBuilders[n][e],i=new Gp.LocalIMMessageBuildOptions(e,t);if(o){var r=o.build(i);i.payload=r}else{r=(new xp.CustomPayloadBuilder).build(i);i.payload=r.payload}var s=this.build(i);return i.complete.then((function(){Vp.CallbackUtils.onSuccess(t,s)})).catch((function(e){Vp.CallbackUtils.onFailed(t,e)})),s},e.prototype.build=function(e){var t,n=e.type,o=e.payload,i=e.createOptions,r=i.to,s=r.type;return this.validate(i),s===Lp.Scene.GROUP?((t=new Fp.GroupMessage).groupId=r.id.toString(),t.senderData=Hp.G.Socket.user().data):s===Lp.Scene.PRIVATE?((t=new Bp.PrivateMessage).read=!1,t.receiverId=r.id.toString()):s===Lp.Scene.CS&&((t=new jp.CSMessage).to=r.id.toString(),t.teamId=r.id.toString(),t.senderData=Hp.G.Socket.user().data),t.senderId=Hp.G.Socket.user().id,t.messageId=Hp.UUID.get(),t.payload=o,t.timestamp=Date.now(),t.type=n,t.recalled=!1,t.status=Lp.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(!Up.default.isObject(t))throw new Error("TypeError: to requires an object.");if(!Up.default.isObject(t.data))throw new Error("TypeError: to.data requires an object.");if(!t.type||t.type!==Lp.Scene.GROUP&&t.type!==Lp.Scene.PRIVATE&&t.type!==Lp.Scene.CS)throw new Error("message require property to.type");if(qp.default.validateId(t.id,"to.id"),Hp.G.Socket.user().id===t.id)throw new Error("to.id can not be the same as your id.");Up.default.isDef(e.notification)&&qp.default.validateNotification(e.notification),e.wxmpTemplateMsg&&qp.default.validateWXMPTemplateMsg(e.wxmpTemplateMsg)},e}();$l.IMMessageBuilder=Wp;var Jp={__esModule:!0,CsMessageReceiver:void 0},Xp=Q,Qp=wo,Yp=Mr,Kp=et,$p=fi,Zp=ii,ed=Z,td=gr,nd=Ko,od=pr,id=mr,rd=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Xp.__extends(t,e),t.prototype.onMessageReceived=function(e){var t=this;if(e.t===ed.Scene.CS){var n=this.builder.build(e);this.sendAck(n);var o=$p.Target.byIMMessage(n);if(!Zp.default.get(o).existsMessage(n))if(n.customerId()===Kp.G.Socket.user().id)this.createNotification(e),nd.IMEC.i.fire(Qp.IM_INTERNAL_EVENTS.MESSAGE_RECEIVED,n),od.AEC.fire(id.ImApiEvents.CS_MESSAGE_RECEIVED,n);else Yp.AgentStatus.getInstance().queryTeams().then((function(){td.LiveSession.isMyMessage(n)&&t.createNotification(e),nd.IMEC.i.fire(Qp.IM_INTERNAL_EVENTS.CS_AGENT_MESSAGE_RECEIVED,n)}))}},t}(Bl.default);Jp.CsMessageReceiver=rd;var sd={},ad={__esModule:!0,RecallMessageRequest:void 0},cd=fi,ud=function(e){var t=this;this.times=new Array;var n=e[0],o=cd.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 e0?"".concat(e,":").concat(t):"".concat(t,":").concat(e)}(t,o);if(n.Scene.GROUP===e)return o;throw{code:400,content:"scene: ".concat(e," not support")}},e.prototype.recallServerMessages=function(e){var t=new o.RecallMessageRequest(e);return 0===t.times.length?Promise.resolve():new Promise((function(e,n){var o=new s.Rocket({name:r.RocketTypes.IM_RECALL_MESSAGE,params:t,permission:s.Permission.WRITE,singleTimeout:i.SocketTimeout.commonRequestSingle,totalTimeout:i.SocketTimeout.commonRequestTotal,fail:function(e){n(e)},success:function(t){200===t.code?e(t):n(t)}});s.G.Socket.e(o)}))},e.prototype.validate=function(e){for(var t=e.messages,o=0;o