goeasy-im-1.3.1.js 119 KB

123
  1. !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.GoEasyIM=e():t.GoEasyIM=e()}(window,(function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=57)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t}},function(t,e){function n(e){return t.exports=n=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},n(e)}t.exports=n},function(t,e,n){var r=n(13);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}},function(t,e,n){var r=n(7),i=n(11);t.exports=function(t,e){return!e||"object"!==r(e)&&"function"!=typeof e?i(t):e}},function(t,e,n){var r=n(37);function i(e,n,o){return"undefined"!=typeof Reflect&&Reflect.get?t.exports=i=Reflect.get:t.exports=i=function(t,e,n){var i=r(t,e);if(i){var o=Object.getOwnPropertyDescriptor(i,e);return o.get?o.get.call(n):o.value}},i(e,n,o||e)}t.exports=i},function(t,e){t.exports=function(){return function(){}}},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=n=function(t){return typeof t}:t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(e)}t.exports=n},function(t,e,n){var r=n(46),i=n(21),o=n(48),s=n(49);"undefined"!=typeof navigator&&/Android/i.test(navigator.userAgent),"undefined"!=typeof navigator&&/PhantomJS/i.test(navigator.userAgent);e.protocol=3;var c=e.packets={open:0,close:1,ping:2,pong:3,message:4,upgrade:5,noop:6},a=r(c),u={type:"error",data:"parser error"},l=n(50);e.encodePacket=function(t,e,n,r){"function"==typeof e&&(r=e,e=!1),"function"==typeof n&&(r=n,n=null);void 0===t.data||t.data.buffer||t.data;var i=c[t.type];return void 0!==t.data&&(i+=n?s.encode(String(t.data),{strict:!1}):String(t.data)),r(""+i)},e.decodePacket=function(t,e,n){if(void 0===t)return u;if("string"==typeof t){if(n&&!1===(t=function(t){try{t=s.decode(t,{strict:!1})}catch(t){return!1}return t}(t)))return u;var r=t.charAt(0);return Number(r)==r&&a[r]?t.length>1?{type:a[r],data:t.substring(1)}:{type:a[r]}:u}r=new Uint8Array(t)[0];var i=sliceBuffer(t,1);return l&&"blob"===e&&(i=new l([i])),{type:a[r],data:i}},e.encodePayload=function(t,n,r){"function"==typeof n&&(r=n,n=null);var s=i(t);if(!t.length)return r("0:");!function(t,e,n){for(var r=new Array(t.length),i=o(t.length,n),s=function(t,n,i){e(n,(function(e,n){r[t]=n,i(e,r)}))},c=0;c<t.length;c++)s(c,t[c],i)}(t,(function(t,r){e.encodePacket(t,!!s&&n,!0,(function(t){r(null,function(t){return t.length+":"+t}(t))}))}),(function(t,e){return r(e.join(""))}))},e.decodePayload=function(t,n,r){var i;if("function"==typeof n&&(r=n,n=null),""===t)return r(u,0,1);for(var o,s,c="",a=0,l=t.length;a<l;a++){var f=t.charAt(a);if(":"===f){if(""===c||c!=(o=Number(c)))return r(u,0,1);if(c!=(s=t.substr(a+1,o)).length)return r(u,0,1);if(s.length){if(i=e.decodePacket(s,n,!0),u.type===i.type&&u.data===i.data)return r(u,0,1);if(!1===r(i,a+o,l))return}a+=o,c=""}else c+=f}return""!==c?r(u,0,1):void 0}},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}},function(t,e,n){"use strict";n.d(e,"a",(function(){return u}));var r=n(7),i=n.n(r),o=n(0),s=n.n(o),c=n(1),a=n.n(c),u=new(function(){function t(){s()(this,t)}return a()(t,[{key:"isWx",value:function(){return!("undefined"==typeof wx||!wx.getLocation)&&("undefined"!=typeof GameGlobal||("function"!=typeof WebSocket||"function"!=typeof XMLHttpRequest))}},{key:"isUni",value:function(){return!("object"!==("undefined"==typeof uni?"undefined":i()(uni))||!uni.getSystemInfo)}},{key:"isTT",value:function(){return!("object"!==("undefined"==typeof tt?"undefined":i()(tt))||!tt.getSystemInfo)}},{key:"isBrowserClient",value:function(){return this.isUni()?"function"==typeof WebSocket&&"function"==typeof XMLHttpRequest&&"object"==("undefined"==typeof localStorage?"undefined":i()(localStorage)):!(this.isReactNative()||this.isWx()||this.isTT())}},{key:"isReactNative",value:function(){return"undefined"!=typeof navigator&&"ReactNative"==navigator.product}}]),t}())},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e){e.encode=function(t){var e="";for(var n in t)t.hasOwnProperty(n)&&(e.length&&(e+="&"),e+=encodeURIComponent(n)+"="+encodeURIComponent(t[n]));return e},e.decode=function(t){for(var e={},n=t.split("&"),r=0,i=n.length;r<i;r++){var o=n[r].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}},function(t,e){function n(e,r){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,r)}t.exports=n},function(t,e,n){n(6)("socket.io-parser");var r=n(39),i=n(40);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=c;var s=e.ERROR+'"encode error"';function c(){this.reconstructor=null}function a(t){this.reconPack=t,this.buffers=[]}function u(t){return{type:e.ERROR,data:"parser error: "+t}}o.prototype.encode=function(t,n){n([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 r=function(t){try{return JSON.stringify(t)}catch(t){return!1}}(t.data);if(!1===r)return s;n+=r}return n}(t)])},r(c.prototype),c.prototype.add=function(t){var n;if("string"!=typeof t)throw new Error("Unknown type: "+t);n=function(t){var n=0,r={type:Number(t.charAt(0))};if(null==e.types[r.type])return u("unknown packet type "+r.type);if(e.BINARY_EVENT===r.type||e.BINARY_ACK===r.type){for(var o="";"-"!==t.charAt(++n)&&(o+=t.charAt(n),n!=t.length););if(o!=Number(o)||"-"!==t.charAt(n))throw new Error("Illegal attachments");r.attachments=Number(o)}if("/"===t.charAt(n+1))for(r.nsp="";++n;){if(","===(c=t.charAt(n)))break;if(r.nsp+=c,n===t.length)break}else r.nsp="/";var s=t.charAt(n+1);if(""!==s&&Number(s)==s){for(r.id="";++n;){var c;if(null==(c=t.charAt(n))||Number(c)!=c){--n;break}if(r.id+=t.charAt(n),n===t.length)break}r.id=Number(r.id)}if(t.charAt(++n)){var a=function(t){try{return JSON.parse(t)}catch(t){return!1}}(t.substr(n));if(!(!1!==a&&(r.type===e.ERROR||i(a))))return u("invalid payload");r.data=a}return r}(t),this.emit("decoded",n)},c.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},a.prototype.takeBinaryData=function(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){var e=binary.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null},a.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,n){var r=n(8),i=n(22);function o(t){this.path=t.path,this.hostname=t.hostname,this.port=t.port,this.secure=t.secure,this.query=t.query,this.timestampParam=t.timestampParam,this.timestampRequests=t.timestampRequests,this.readyState="",this.agent=t.agent||!1,this.socket=t.socket,this.enablesXDR=t.enablesXDR,this.pfx=t.pfx,this.key=t.key,this.passphrase=t.passphrase,this.cert=t.cert,this.ca=t.ca,this.ciphers=t.ciphers,this.rejectUnauthorized=t.rejectUnauthorized,this.forceNode=t.forceNode,this.isReactNative=t.isReactNative,this.extraHeaders=t.extraHeaders,this.localAddress=t.localAddress}t.exports=o,i(o.prototype),o.prototype.onError=function(t,e){var n=new Error(t);return n.type="TransportError",n.description=e,this.emit("error",n),this},o.prototype.open=function(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this},o.prototype.close=function(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this},o.prototype.send=function(t){if("open"!==this.readyState)throw new Error("Transport not open");this.write(t)},o.prototype.onOpen=function(){this.readyState="open",this.writable=!0,this.emit("open")},o.prototype.onData=function(t){var e=r.decodePacket(t,this.socket.binaryType);this.onPacket(e)},o.prototype.onPacket=function(t){this.emit("packet",t)},o.prototype.onClose=function(){this.readyState="closed",this.emit("close")}},function(t,e){t.exports=function(t,e){var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}},function(t,e,n){"use strict";n.r(e),n.d(e,"GoEasyDomainNumber",(function(){return l}));var r=n(0),i=n.n(r),o=n(1),s=n.n(o),c=n(10),a=new(function(){function t(){i()(this,t)}return s()(t,[{key:"getCookie",value:function(){var t,e=new RegExp("(^| )"+name+"=([^;]*)(;|$)");return(t=document.cookie.match(e))?unescape(t[2]):null}},{key:"getData",value:function(t){return window.localStorage?window.localStorage.getItem(t):this.getCookie(t)}},{key:"setCookie",value:function(t,e){var n=new Date;n.setTime(n.getTime()+2592e6),document.cookie=t+"="+escape(e)+";expires="+n.toGMTString()}},{key:"setData",value:function(t,e){window.localStorage?window.localStorage.setItem(t,e):this.setCookie(t,e)}}]),t}()),u=10,l=function(){function t(){i()(this,t)}return s()(t,null,[{key:"refreshNumber",value:function(){var t=Math.floor(Math.random()*(u-1)+1);return c.a.isBrowserClient()&&(t=parseInt(a.getData("goEasyNode"))||t),t>0&&t<u?t+=1:t==u&&(t=1),c.a.isBrowserClient()&&a.setData("goEasyNode",t),t}}]),t}()},function(t,e){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,r=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,i=t.indexOf("["),o=t.indexOf("]");-1!=i&&-1!=o&&(t=t.substring(0,i)+t.substring(i,o).replace(/:/g,";")+t.substring(o,t.length));for(var s=n.exec(t||""),c={},a=14;a--;)c[r[a]]=s[a]||"";return-1!=i&&-1!=o&&(c.source=e,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c}},function(t,e,n){var r=n(41),i=n(25),o=n(26),s=n(14),c=n(27),a=n(28),u=(n(6)("socket.io-client:manager"),n(24)),l=n(56);const f=n(17).GoEasyDomainNumber;var p=Object.prototype.hasOwnProperty;function h(t,e){if(!(this instanceof h))return new h(t,e);t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",this.nsps={},this.subs=[],this.opts=e,this.reconnection(!1!==e.reconnection),this.reconnectionAttempts(e.reconnectionAttempts||1/0),this.reconnectionDelay(e.reconnectionDelay||1e3),this.reconnectionDelayMax(e.reconnectionDelayMax||5e3),this.randomizationFactor(e.randomizationFactor||.5),this.backoff=new l({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this.readyState="closed",this.uri=t,this.connecting=[],this.lastPing=null,this.encoding=!1,this.packetBuffer=[];var n=e.parser||s;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this.autoConnect=!1!==e.autoConnect,this.autoConnect&&this.open()}t.exports=h,h.prototype.emitAll=function(){for(var t in this.emit.apply(this,arguments),this.nsps)p.call(this.nsps,t)&&this.nsps[t].emit.apply(this.nsps[t],arguments)},h.prototype.updateSocketIds=function(){for(var t in this.nsps)p.call(this.nsps,t)&&(this.nsps[t].id=this.generateId(t))},h.prototype.generateId=function(t){return("/"===t?"":t+"#")+this.engine.id},o(h.prototype),h.prototype.reconnection=function(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection},h.prototype.reconnectionAttempts=function(t){return arguments.length?(this._reconnectionAttempts=t,this):this._reconnectionAttempts},h.prototype.reconnectionDelay=function(t){return arguments.length?(this._reconnectionDelay=t,this.backoff&&this.backoff.setMin(t),this):this._reconnectionDelay},h.prototype.randomizationFactor=function(t){return arguments.length?(this._randomizationFactor=t,this.backoff&&this.backoff.setJitter(t),this):this._randomizationFactor},h.prototype.reconnectionDelayMax=function(t){return arguments.length?(this._reconnectionDelayMax=t,this.backoff&&this.backoff.setMax(t),this):this._reconnectionDelayMax},h.prototype.timeout=function(t){return arguments.length?(this._timeout=t,this):this._timeout},h.prototype.maybeReconnectOnOpen=function(){!this.reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()},h.prototype.open=h.prototype.connect=function(t,e){if(~this.readyState.indexOf("open"))return this;this.engine=r(this.uri,this.opts);var n=this.engine,i=this;this.readyState="opening",this.skipReconnect=!1;var o=c(n,"open",(function(){i.onopen(),t&&t()})),s=c(n,"error",(function(e){if("undefined"!=typeof window){var n=parseInt(i.uri.match(/[1-9][0-9]*/g)[0]),r=f.refreshNumber();i.uri=i.uri.replace(n,r)}if(i.cleanup(),i.readyState="closed",i.emitAll("connect_error",e),t){var o=new Error("Connection error");o.data=e,t(o)}else i.maybeReconnectOnOpen()}));if(!1!==this._timeout){var a=this._timeout,u=setTimeout((function(){o.destroy(),n.close(),n.emit("error","timeout"),i.emitAll("connect_timeout",a)}),a);this.subs.push({destroy:function(){clearTimeout(u)}})}return this.subs.push(o),this.subs.push(s),this},h.prototype.onopen=function(){this.cleanup(),this.readyState="open",this.emit("open");var t=this.engine;this.subs.push(c(t,"data",a(this,"ondata"))),this.subs.push(c(t,"ping",a(this,"onping"))),this.subs.push(c(t,"pong",a(this,"onpong"))),this.subs.push(c(t,"error",a(this,"onerror"))),this.subs.push(c(t,"close",a(this,"onclose"))),this.subs.push(c(this.decoder,"decoded",a(this,"ondecoded")))},h.prototype.onping=function(){this.lastPing=new Date,this.emitAll("ping")},h.prototype.onpong=function(){this.emitAll("pong",new Date-this.lastPing)},h.prototype.ondata=function(t){this.decoder.add(t)},h.prototype.ondecoded=function(t){this.emit("packet",t)},h.prototype.onerror=function(t){this.emitAll("error",t)},h.prototype.socket=function(t,e){var n=this.nsps[t];if(!n){n=new i(this,t,e),this.nsps[t]=n;var r=this;n.on("connecting",o),n.on("connect",(function(){n.id=r.generateId(t)})),this.autoConnect&&o()}function o(){~u(r.connecting,n)||r.connecting.push(n)}return n},h.prototype.destroy=function(t){var e=u(this.connecting,t);~e&&this.connecting.splice(e,1),this.connecting.length||this.close()},h.prototype.packet=function(t){var e=this;t.query&&0===t.type&&(t.nsp+="?"+t.query),e.encoding?e.packetBuffer.push(t):(e.encoding=!0,this.encoder.encode(t,(function(n){for(var r=0;r<n.length;r++)e.engine.write(n[r],t.options);e.encoding=!1,e.processPacketQueue()})))},h.prototype.processPacketQueue=function(){if(this.packetBuffer.length>0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},h.prototype.cleanup=function(){for(var t=this.subs.length,e=0;e<t;e++){this.subs.shift().destroy()}this.packetBuffer=[],this.encoding=!1,this.lastPing=null,this.decoder.destroy()},h.prototype.close=h.prototype.disconnect=function(){this.skipReconnect=!0,this.reconnecting=!1,"opening"===this.readyState&&this.cleanup(),this.backoff.reset(),this.readyState="closed",this.engine&&this.engine.close()},h.prototype.onclose=function(t){this.cleanup(),this.backoff.reset(),this.readyState="closed",this.emit("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()},h.prototype.reconnect=function(){if(this.reconnecting||this.skipReconnect)return this;var t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitAll("reconnect_failed"),this.reconnecting=!1;else{var e=this.backoff.duration();this.reconnecting=!0;var n=setTimeout((function(){var e;t.skipReconnect||(t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||(e=!1,"object"==typeof uni&&uni.getSystemInfo&&(e=!0),e&&!0===getApp().uniAppRunningBackend?(t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error","Uniapp running backend, skipped reconnect...")):t.open((function(e){e?(t.reconnecting=!1,t.reconnect(),t.emitAll("reconnect_error",e.data)):t.onreconnect()}))))}),e);this.subs.push({destroy:function(){clearTimeout(n)}})}},h.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,n){var r=n(43),i=n(53);e.polling=function(t){var e=!1,n=!1;t.jsonp;if("undefined"!=typeof location){var i="https:"===location.protocol,o=location.port;o||(o=i?443:80),e=t.hostname!==location.hostname||o!==t.port,n=t.secure!==i}return t.xdomain=e,t.xscheme=n,new r(t)},e.websocket=i},function(t,e,n){var r=n(47),i=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===i.call(Blob),s="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===i.call(File);t.exports=function t(e){if(!e||"object"!=typeof e)return!1;if(r(e)){for(var n=0,i=e.length;n<i;n++)if(t(e[n]))return!0;return!1}if("function"==typeof Buffer&&Buffer.isBuffer&&Buffer.isBuffer(e)||"function"==typeof ArrayBuffer&&e instanceof ArrayBuffer||o&&e instanceof Blob||s&&e instanceof File)return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return t(e.toJSON(),!0);for(var c in e)if(Object.prototype.hasOwnProperty.call(e,c)&&t(e[c]))return!0;return!1}},function(t,e,n){function r(t){if(t)return function(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}(t)}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i<r.length;i++)if((n=r[i])===e||n.fn===e){r.splice(i,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n)for(var r=0,i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,e);return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,n){"use strict";var r,i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),o={},s=0,c=0;function a(t){var e="";do{e=i[t%64]+e,t=Math.floor(t/64)}while(t>0);return e}function u(){var t=a(+new Date);return t!==r?(s=0,r=t):t+"."+a(s++)}for(;c<64;c++)o[i[c]]=c;u.encode=a,u.decode=function(t){var e=0;for(c=0;c<t.length;c++)e=64*e+o[t.charAt(c)];return e},t.exports=u},function(t,e){var n=[].indexOf;t.exports=function(t,e){if(n)return t.indexOf(e);for(var r=0;r<t.length;++r)if(t[r]===e)return r;return-1}},function(t,e,n){var r=n(14),i=n(26),o=n(55),s=n(27),c=n(28),a=(n(6)("socket.io-client:socket"),n(12)),u=n(21);t.exports=p;var l={connect:1,connect_error:1,connect_timeout:1,connecting:1,disconnect:1,error:1,reconnect:1,reconnect_attempt:1,reconnect_failed:1,reconnect_error:1,reconnecting:1,ping:1,pong:1},f=i.prototype.emit;function p(t,e,n){this.io=t,this.nsp=e,this.json=this,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},n&&n.query&&(this.query=n.query),this.io.autoConnect&&this.open()}i(p.prototype),p.prototype.subEvents=function(){if(!this.subs){var t=this.io;this.subs=[s(t,"open",c(this,"onopen")),s(t,"packet",c(this,"onpacket")),s(t,"close",c(this,"onclose"))]}},p.prototype.open=p.prototype.connect=function(){return this.connected||(this.subEvents(),this.io.open(),"open"===this.io.readyState&&this.onopen(),this.emit("connecting")),this},p.prototype.send=function(){var t=o(arguments);return t.unshift("message"),this.emit.apply(this,t),this},p.prototype.emit=function(t){if(l.hasOwnProperty(t))return f.apply(this,arguments),this;var e=o(arguments),n={type:(void 0!==this.flags.binary?this.flags.binary:u(e))?r.BINARY_EVENT:r.EVENT,data:e,options:{}};return n.options.compress=!this.flags||!1!==this.flags.compress,"function"==typeof e[e.length-1]&&(this.acks[this.ids]=e.pop(),n.id=this.ids++),this.connected?this.packet(n):this.sendBuffer.push(n),this.flags={},this},p.prototype.packet=function(t){t.nsp=this.nsp,this.io.packet(t)},p.prototype.onopen=function(){if("/"!==this.nsp)if(this.query){var t="object"==typeof this.query?a.encode(this.query):this.query;this.packet({type:r.CONNECT,query:t})}else this.packet({type:r.CONNECT})},p.prototype.onclose=function(t){this.connected=!1,this.disconnected=!0,delete this.id,this.emit("disconnect",t)},p.prototype.onpacket=function(t){var e=t.nsp===this.nsp,n=t.type===r.ERROR&&"/"===t.nsp;if(e||n)switch(t.type){case r.CONNECT:this.onconnect();break;case r.EVENT:case r.BINARY_EVENT:this.onevent(t);break;case r.ACK:case r.BINARY_ACK:this.onack(t);break;case r.DISCONNECT:this.ondisconnect();break;case r.ERROR:this.emit("error",t.data)}},p.prototype.onevent=function(t){var e=t.data||[];null!=t.id&&e.push(this.ack(t.id)),this.connected?f.apply(this,e):this.receiveBuffer.push(e)},p.prototype.ack=function(t){var e=this,n=!1;return function(){if(!n){n=!0;var i=o(arguments);e.packet({type:u(i)?r.BINARY_ACK:r.ACK,id:t,data:i})}}},p.prototype.onack=function(t){var e=this.acks[t.id];"function"==typeof e&&(e.apply(this,t.data),delete this.acks[t.id])},p.prototype.onconnect=function(){this.connected=!0,this.disconnected=!1,this.emit("connect"),this.emitBuffered()},p.prototype.emitBuffered=function(){var t;for(t=0;t<this.receiveBuffer.length;t++)f.apply(this,this.receiveBuffer[t]);for(this.receiveBuffer=[],t=0;t<this.sendBuffer.length;t++)this.packet(this.sendBuffer[t]);this.sendBuffer=[]},p.prototype.ondisconnect=function(){this.destroy(),this.onclose("io server disconnect")},p.prototype.destroy=function(){if(this.subs){for(var t=0;t<this.subs.length;t++)this.subs[t].destroy();this.subs=null}this.io.destroy(this)},p.prototype.close=p.prototype.disconnect=function(){return this.connected&&this.packet({type:r.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this},p.prototype.compress=function(t){return this.flags.compress=t,this},p.prototype.binary=function(t){return this.flags.binary=t,this}},function(t,e,n){function r(t){if(t)return function(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}(t)}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i<r.length;i++)if((n=r[i])===e||n.fn===e){r.splice(i,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n)for(var r=0,i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,e);return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){t.exports=function(t,e,n){return t.on(e,n),{destroy:function(){t.removeListener(e,n)}}}},function(t,e){var n=[].slice;t.exports=function(t,e){if("string"==typeof e&&(e=t[e]),"function"!=typeof e)throw new Error("bind() requires a function");var r=n.call(arguments,2);return function(){return e.apply(t,r.concat(n.call(arguments)))}}},function(t,e,n){var r,i,o=n(32),s=n(33),c=0,a=0;t.exports=function(t,e,n){var u=e&&n||0,l=e||[],f=(t=t||{}).node||r,p=void 0!==t.clockseq?t.clockseq:i;if(null==f||null==p){var h=o();null==f&&(f=r=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==p&&(p=i=16383&(h[6]<<8|h[7]))}var d=void 0!==t.msecs?t.msecs:(new Date).getTime(),y=void 0!==t.nsecs?t.nsecs:a+1,v=d-c+(y-a)/1e4;if(v<0&&void 0===t.clockseq&&(p=p+1&16383),(v<0||d>c)&&void 0===t.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");c=d,a=y,i=p;var m=(1e4*(268435455&(d+=122192928e5))+y)%4294967296;l[u++]=m>>>24&255,l[u++]=m>>>16&255,l[u++]=m>>>8&255,l[u++]=255&m;var g=d/4294967296*1e4&268435455;l[u++]=g>>>8&255,l[u++]=255&g,l[u++]=g>>>24&15|16,l[u++]=g>>>16&255,l[u++]=p>>>8|128,l[u++]=255&p;for(var b=0;b<6;++b)l[u+b]=f[b];return e||s(l)}},function(t,e,n){var r=n(2),i=n(13),o=n(34),s=n(35);function c(e){var n="function"==typeof Map?new Map:void 0;return t.exports=c=function(t){if(null===t||!o(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,e)}function e(){return s(t,arguments,r(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),i(e,t)},c(e)}t.exports=c},function(t,e,n){var r=n(38),i=n(14),o=n(19);n(6)("socket.io-client");t.exports=e=c;var s=e.managers={};function c(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};var n,i=r(t),c=i.source,a=i.id,u=i.path,l=s[a]&&u in s[a].nsps;return e.forceNew||e["force new connection"]||!1===e.multiplex||l?n=o(c,e):(s[a]||(s[a]=o(c,e)),n=s[a]),i.query&&!e.query&&(e.query=i.query),n.socket(i.path,e)}e.protocol=i.protocol,e.connect=c,e.Manager=n(19),e.Socket=n(25)},function(t,e){var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(n){var r=new Uint8Array(16);t.exports=function(){return n(r),r}}else{var i=new Array(16);t.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),i[e]=t>>>((3&e)<<3)&255;return i}}},function(t,e){for(var n=[],r=0;r<256;++r)n[r]=(r+256).toString(16).substr(1);t.exports=function(t,e){var r=e||0,i=n;return[i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],"-",i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]],i[t[r++]]].join("")}},function(t,e){t.exports=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}},function(t,e,n){var r=n(13),i=n(36);function o(e,n,s){return i()?t.exports=o=Reflect.construct:t.exports=o=function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&r(o,n.prototype),o},o.apply(null,arguments)}t.exports=o},function(t,e){t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}},function(t,e,n){var r=n(2);t.exports=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}},function(t,e,n){var r=n(18);n(6)("socket.io-client:url");t.exports=function(t,e){var n=t;e=e||"undefined"!=typeof location&&location,null==t&&(t=e.protocol+"//"+e.host);"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?e.protocol+t:e.host+t),/^(https?|wss?):\/\//.test(t)||(t=void 0!==e?e.protocol+"//"+t:"https://"+t),n=r(t));n.port||(/^(http|ws)$/.test(n.protocol)?n.port="80":/^(http|ws)s$/.test(n.protocol)&&(n.port="443"));n.path=n.path||"/";var i=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+i+":"+n.port,n.href=n.protocol+"://"+i+(e&&e.port===n.port?"":":"+n.port),n}},function(t,e,n){function r(t){if(t)return function(t){for(var e in r.prototype)t[e]=r.prototype[e];return t}(t)}t.exports=r,r.prototype.on=r.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},r.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+t];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var i=0;i<r.length;i++)if((n=r[i])===e||n.fn===e){r.splice(i,1);break}return this},r.prototype.emit=function(t){this._callbacks=this._callbacks||{};var e=[].slice.call(arguments,1),n=this._callbacks["$"+t];if(n)for(var r=0,i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,e);return this},r.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},r.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e,n){t.exports=n(42),t.exports.parser=n(8)},function(t,e,n){var r=n(20),i=n(22),o=(n(6)("engine.io-client:socket"),n(24)),s=n(8),c=n(18),a=n(12);function u(t,e){if(!(this instanceof u))return new u(t,e);e=e||{},t&&"object"==typeof t&&(e=t,t=null),t?(t=c(t),e.hostname=t.host,e.secure="https"===t.protocol||"wss"===t.protocol,e.port=t.port,t.query&&(e.query=t.query)):e.host&&(e.hostname=c(e.host).host),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),this.agent=e.agent||!1,this.hostname=e.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=e.port||("undefined"!=typeof location&&location.port?location.port:this.secure?443:80),this.query=e.query||{},"string"==typeof this.query&&(this.query=a.decode(this.query)),this.upgrade=!1!==e.upgrade,this.path=(e.path||"/engine.io").replace(/\/$/,"")+"/",this.forceJSONP=!!e.forceJSONP,this.jsonp=!1!==e.jsonp,this.forceBase64=!!e.forceBase64,this.enablesXDR=!!e.enablesXDR,this.timestampParam=e.timestampParam||"t",this.timestampRequests=e.timestampRequests,this.transports=e.transports||["polling","websocket"],this.transportOptions=e.transportOptions||{},this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.policyPort=e.policyPort||843,this.rememberUpgrade=e.rememberUpgrade||!1,this.binaryType=null,this.onlyBinaryUpgrades=e.onlyBinaryUpgrades,this.perMessageDeflate=!1!==e.perMessageDeflate&&(e.perMessageDeflate||{}),!0===this.perMessageDeflate&&(this.perMessageDeflate={}),this.perMessageDeflate&&null==this.perMessageDeflate.threshold&&(this.perMessageDeflate.threshold=1024),this.pfx=e.pfx||null,this.key=e.key||null,this.passphrase=e.passphrase||null,this.cert=e.cert||null,this.ca=e.ca||null,this.ciphers=e.ciphers||null,this.rejectUnauthorized=void 0===e.rejectUnauthorized||e.rejectUnauthorized,this.forceNode=!!e.forceNode,this.isReactNative="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase(),("undefined"==typeof self||this.isReactNative)&&(e.extraHeaders&&Object.keys(e.extraHeaders).length>0&&(this.extraHeaders=e.extraHeaders),e.localAddress&&(this.localAddress=e.localAddress)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingIntervalTimer=null,this.pingTimeoutTimer=null,this.open()}t.exports=u,u.priorWebsocketSuccess=!1,i(u.prototype),u.protocol=s.protocol,u.Socket=u,u.Transport=n(15),u.transports=n(20),u.parser=n(8),u.prototype.createTransport=function(t){var e=function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}(this.query);e.EIO=s.protocol,e.transport=t;var n=this.transportOptions[t]||{};return this.id&&(e.sid=this.id),new r[t]({query:e,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})},u.prototype.open=function(){var t;if(this.rememberUpgrade&&u.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length){var e=this;return void setTimeout((function(){e.emit("error","No transports available")}),0)}t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return this.transports.shift(),void this.open()}t.open(),this.setTransport(t)},u.prototype.setTransport=function(t){var e=this;this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",(function(){e.onDrain()})).on("packet",(function(t){e.onPacket(t)})).on("error",(function(t){e.onError(t)})).on("close",(function(){e.onClose("transport close")}))},u.prototype.probe=function(t){var e=this.createTransport(t,{probe:1}),n=!1,r=this;function i(){if(r.onlyBinaryUpgrades){var t=!this.supportsBinary&&r.transport.supportsBinary;n=n||t}n||(e.send([{type:"ping",data:"probe"}]),e.once("packet",(function(t){if(!n)if("pong"===t.type&&"probe"===t.data){if(r.upgrading=!0,r.emit("upgrading",e),!e)return;u.priorWebsocketSuccess="websocket"===e.name,r.transport.pause((function(){n||"closed"!==r.readyState&&(f(),r.setTransport(e),e.send([{type:"upgrade"}]),r.emit("upgrade",e),e=null,r.upgrading=!1,r.flush())}))}else{var i=new Error("probe error");i.transport=e.name,r.emit("upgradeError",i)}})))}function o(){n||(n=!0,f(),e.close(),e=null)}function s(t){var n=new Error("probe error: "+t);n.transport=e.name,o(),r.emit("upgradeError",n)}function c(){s("transport closed")}function a(){s("socket closed")}function l(t){e&&t.name!==e.name&&o()}function f(){e.removeListener("open",i),e.removeListener("error",s),e.removeListener("close",c),r.removeListener("close",a),r.removeListener("upgrading",l)}u.priorWebsocketSuccess=!1,e.once("open",i),e.once("error",s),e.once("close",c),this.once("close",a),this.once("upgrading",l),e.open()},u.prototype.onOpen=function(){if(this.readyState="open",u.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.upgrade&&this.transport.pause)for(var t=0,e=this.upgrades.length;t<e;t++)this.probe(this.upgrades[t])},u.prototype.onPacket=function(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"pong":this.setPing(),this.emit("pong");break;case"error":var e=new Error("server error");e.code=t.data,this.onError(e);break;case"message":this.emit("data",t.data),this.emit("message",t.data)}},u.prototype.onHandshake=function(t){this.emit("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this.upgrades=this.filterUpgrades(t.upgrades),this.pingInterval=t.pingInterval,this.pingTimeout=t.pingTimeout,this.onOpen(),"closed"!==this.readyState&&(this.setPing(),this.removeListener("heartbeat",this.onHeartbeat),this.on("heartbeat",this.onHeartbeat))},u.prototype.onHeartbeat=function(t){clearTimeout(this.pingTimeoutTimer);var e=this;e.pingTimeoutTimer=setTimeout((function(){"closed"!==e.readyState&&e.onClose("ping timeout")}),t||e.pingInterval+e.pingTimeout)},u.prototype.setPing=function(){var t=this;clearTimeout(t.pingIntervalTimer),t.pingIntervalTimer=setTimeout((function(){t.ping(),t.onHeartbeat(t.pingTimeout)}),t.pingInterval)},u.prototype.ping=function(){var t=this;this.sendPacket("ping",(function(){t.emit("ping")}))},u.prototype.onDrain=function(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()},u.prototype.flush=function(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))},u.prototype.write=u.prototype.send=function(t,e,n){return this.sendPacket("message",t,e,n),this},u.prototype.sendPacket=function(t,e,n,r){if("function"==typeof e&&(r=e,e=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){(n=n||{}).compress=!1!==n.compress;var i={type:t,data:e,options:n};this.emit("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}},u.prototype.close=function(){if("opening"===this.readyState||"open"===this.readyState){this.readyState="closing";var t=this;this.writeBuffer.length?this.once("drain",(function(){this.upgrading?r():e()})):this.upgrading?r():e()}function e(){t.onClose("forced close"),t.transport.close()}function n(){t.removeListener("upgrade",n),t.removeListener("upgradeError",n),e()}function r(){t.once("upgrade",n),t.once("upgradeError",n)}return this},u.prototype.onError=function(t){u.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)},u.prototype.onClose=function(t,e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){clearTimeout(this.pingIntervalTimer),clearTimeout(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),this.readyState="closed",this.id=null,this.emit("close",t,e),this.writeBuffer=[],this.prevBufferLen=0}},u.prototype.filterUpgrades=function(t){for(var e=[],n=0,r=t.length;n<r;n++)~o(this.transports,t[n])&&e.push(t[n]);return e}},function(t,e,n){(function(e){var r=n(45),i=n(16);t.exports=l;var o,s=/\n/g,c=/\\n/g;function a(){}function u(){return"undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==e?e:{}}function l(t){if(r.call(this,t),this.query=this.query||{},!o){var e=u();o=e.___eio=e.___eio||[]}this.index=o.length;var n=this;o.push((function(t){n.onData(t)})),this.query.j=this.index,"function"==typeof addEventListener&&addEventListener("beforeunload",(function(){n.script&&(n.script.onerror=a)}),!1)}i(l,r),l.prototype.supportsBinary=!1,l.prototype.doClose=function(){this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),r.prototype.doClose.call(this)},l.prototype.doPoll=function(){var t=this,e=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),e.async=!0,e.src=this.uri(),e.onerror=function(e){t.onError("jsonp poll error",e)};var n=document.getElementsByTagName("script")[0];n?n.parentNode.insertBefore(e,n):(document.head||document.body).appendChild(e),this.script=e,"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&setTimeout((function(){var t=document.createElement("iframe");document.body.appendChild(t),document.body.removeChild(t)}),100)},l.prototype.doWrite=function(t,e){var n=this;if(!this.form){var r,i=document.createElement("form"),o=document.createElement("textarea"),a=this.iframeId="eio_iframe_"+this.index;i.className="socketio",i.style.position="absolute",i.style.top="-1000px",i.style.left="-1000px",i.target=a,i.method="POST",i.setAttribute("accept-charset","utf-8"),o.name="d",i.appendChild(o),document.body.appendChild(i),this.form=i,this.area=o}function u(){l(),e()}function l(){if(n.iframe)try{n.form.removeChild(n.iframe)}catch(t){n.onError("jsonp polling iframe removal error",t)}try{var t='<iframe src="javascript:0" name="'+n.iframeId+'">';r=document.createElement(t)}catch(t){(r=document.createElement("iframe")).name=n.iframeId,r.src="javascript:0"}r.id=n.iframeId,n.form.appendChild(r),n.iframe=r}this.form.action=this.uri(),l(),t=t.replace(c,"\\\n"),this.area.value=t.replace(s,"\\n");try{this.form.submit()}catch(t){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===n.iframe.readyState&&u()}:this.iframe.onload=u}}).call(this,n(44))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){var r=n(15),i=n(12),o=n(8),s=n(16),c=n(23);n(6)("engine.io-client:polling");t.exports=u;var a=null!=new(n(51))({xdomain:!1}).responseType;function u(t){var e=t&&t.forceBase64;a&&!e||(this.supportsBinary=!1),r.call(this,t)}s(u,r),u.prototype.name="polling",u.prototype.doOpen=function(){this.poll()},u.prototype.pause=function(t){var e=this;function n(){e.readyState="paused",t()}if(this.readyState="pausing",this.polling||!this.writable){var r=0;this.polling&&(r++,this.once("pollComplete",(function(){--r||n()}))),this.writable||(r++,this.once("drain",(function(){--r||n()})))}else n()},u.prototype.poll=function(){this.polling=!0,this.doPoll(),this.emit("poll")},u.prototype.onData=function(t){var e=this;o.decodePayload(t,this.socket.binaryType,(function(t,n,r){if("opening"===e.readyState&&e.onOpen(),"close"===t.type)return e.onClose(),!1;e.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState&&this.poll())},u.prototype.doClose=function(){var t=this;function e(){t.write([{type:"close"}])}"open"===this.readyState?e():this.once("open",e)},u.prototype.write=function(t){var e=this;this.writable=!1;var n=function(){e.writable=!0,e.emit("drain")};o.encodePayload(t,this.supportsBinary,(function(t){e.doWrite(t,n)}))},u.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(t[this.timestampParam]=c()),this.supportsBinary||t.sid||(t.b64=1),t=i.encode(t),this.port&&("https"===e&&443!==Number(this.port)||"http"===e&&80!==Number(this.port))&&(n=":"+this.port),t.length&&(t="?"+t),e+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+t}},function(t,e){t.exports=Object.keys||function(t){var e=[],n=Object.prototype.hasOwnProperty;for(var r in t)n.call(t,r)&&e.push(r);return e}},function(t,e){var n={}.toString;t.exports=Array.isArray||function(t){return"[object Array]"==n.call(t)}},function(t,e){function n(){}t.exports=function(t,e,r){var i=!1;return r=r||n,o.count=t,0===t?e():o;function o(t,n){if(o.count<=0)throw new Error("after called too many times");--o.count,t?(i=!0,e(t),e=r):0!==o.count||i||e(null,n)}}},function(t,e){
  2. /*! https://mths.be/utf8js v2.1.2 by @mathias */
  3. var n,r,i,o=String.fromCharCode;function s(t){for(var e,n,r=[],i=0,o=t.length;i<o;)(e=t.charCodeAt(i++))>=55296&&e<=56319&&i<o?56320==(64512&(n=t.charCodeAt(i++)))?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),i--):r.push(e);return r}function c(t,e){if(t>=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function a(t,e){return o(t>>e&63|128)}function u(t,e){if(0==(4294967168&t))return o(t);var n="";return 0==(4294965248&t)?n=o(t>>6&31|192):0==(4294901760&t)?(c(t,e)||(t=65533),n=o(t>>12&15|224),n+=a(t,6)):0==(4292870144&t)&&(n=o(t>>18&7|240),n+=a(t,12),n+=a(t,6)),n+=o(63&t|128)}function l(){if(i>=r)throw Error("Invalid byte index");var t=255&n[i];if(i++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function f(t){var e,o;if(i>r)throw Error("Invalid byte index");if(i==r)return!1;if(e=255&n[i],i++,0==(128&e))return e;if(192==(224&e)){if((o=(31&e)<<6|l())>=128)return o;throw Error("Invalid continuation byte")}if(224==(240&e)){if((o=(15&e)<<12|l()<<6|l())>=2048)return c(o,t)?o:65533;throw Error("Invalid continuation byte")}if(240==(248&e)&&(o=(7&e)<<18|l()<<12|l()<<6|l())>=65536&&o<=1114111)return o;throw Error("Invalid UTF-8 detected")}t.exports={version:"2.1.2",encode:function(t,e){for(var n=!1!==(e=e||{}).strict,r=s(t),i=r.length,o=-1,c="";++o<i;)c+=u(r[o],n);return c},decode:function(t,e){var c=!1!==(e=e||{}).strict;n=s(t),r=n.length,i=0;for(var a,u=[];!1!==(a=f(c));)u.push(a);return function(t){for(var e,n=t.length,r=-1,i="";++r<n;)(e=t[r])>65535&&(i+=o((e-=65536)>>>10&1023|55296),e=56320|1023&e),i+=o(e);return i}(u)}}},function(t,e){var n=void 0!==n?n:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,r=function(){try{return 2===new Blob(["hi"]).size}catch(t){return!1}}(),i=r&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(t){return!1}}(),o=n&&n.prototype.append&&n.prototype.getBlob;function s(t){return t.map((function(t){if(t.buffer instanceof ArrayBuffer){var e=t.buffer;if(t.byteLength!==e.byteLength){var n=new Uint8Array(t.byteLength);n.set(new Uint8Array(e,t.byteOffset,t.byteLength)),e=n.buffer}return e}return t}))}function c(t,e){e=e||{};var r=new n;return s(t).forEach((function(t){r.append(t)})),e.type?r.getBlob(e.type):r.getBlob()}function a(t,e){return new Blob(s(t),e||{})}"undefined"!=typeof Blob&&(c.prototype=Blob.prototype,a.prototype=Blob.prototype),t.exports=r?i?Blob:a:o?c:void 0},function(t,e,n){var r=n(52);t.exports=function(t){var e=t.xdomain,n=t.xscheme,i=t.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!e||r))return new XMLHttpRequest}catch(t){}try{if("undefined"!=typeof XDomainRequest&&!n&&i)return new XDomainRequest}catch(t){}if(!e)try{return new(self[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}},function(t,e){try{t.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){t.exports=!1}},function(t,e,n){var r,i,o=n(15),s=n(8),c=n(12),a=n(16),u=n(23);n(6)("engine.io-client:websocket");if("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)if("undefined"!=typeof WebSocket)r=WebSocket;else if("undefined"!=typeof self)r=self.WebSocket||self.MozWebSocket;else try{i=n(54)}catch(t){}var l=r||i;function f(t){t&&t.forceBase64&&(this.supportsBinary=!1),("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&(this.perMessageDeflate=t.perMessageDeflate,this.usingBrowserWebSocket=r&&!t.forceNode,this.protocols=t.protocols,this.usingBrowserWebSocket||(l=i)),o.call(this,t)}"undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket||(l=function(t){var e=this;if(e.onopen=function(){},e.onclose=function(){},e.onmessage=function(t){},e.onerror=function(t){},"object"==typeof tt&&tt.getSystemInfo){let n=tt.connectSocket({url:t});e.send=function(t){n.send({data:t})},e.close=function(){n.close()},n.onOpen((function(){e.onopen()})),n.onError((function(t){e.onerror(t)})),n.onMessage((function(t){e.onmessage(t)})),n.onClose((function(){e.onclose()}))}else"undefined"!=typeof uni?(e.send=function(t){uni.sendSocketMessage({data:t})},e.close=function(){uni.closeSocket()},uni.onSocketOpen((function(t){e.onopen()})),uni.onSocketError((function(t){e.onerror(t)})),uni.onSocketMessage((function(t){e.onmessage(t)})),uni.onSocketClose((function(t){e.onclose()})),uni.connectSocket({url:t})):(e.send=function(t){wx.sendSocketMessage({data:t})},e.close=function(){wx.closeSocket()},wx.onSocketOpen((function(t){e.onopen()})),wx.onSocketError((function(t){e.onerror(t)})),wx.onSocketMessage((function(t){e.onmessage(t)})),wx.onSocketClose((function(t){e.onclose()})),wx.connectSocket({url:t}))}),t.exports=f,a(f,o),f.prototype.name="websocket",f.prototype.supportsBinary=!1,f.prototype.doOpen=function(){if(this.check()){var t,e,n=this.uri();("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket)&&(t=this.protocols),(e="undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket?{agent:this.agent,perMessageDeflate:this.perMessageDeflate}:{agent:this.agent}).pfx=this.pfx,e.key=this.key,e.passphrase=this.passphrase,e.cert=this.cert,e.ca=this.ca,e.ciphers=this.ciphers,e.rejectUnauthorized=this.rejectUnauthorized,this.extraHeaders&&(e.headers=this.extraHeaders),this.localAddress&&(e.localAddress=this.localAddress);try{"undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket?this.ws=this.usingBrowserWebSocket&&!this.isReactNative?t?new l(n,t):new l(n):new l(n,t,e):this.ws=new l(n)}catch(t){return this.emit("error",t)}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()}},f.prototype.addEventListeners=function(){var t=this;this.ws.onopen=function(){t.onOpen()},this.ws.onclose=function(){t.onClose()},this.ws.onmessage=function(e){t.onData(e.data)},this.ws.onerror=function(e){t.onError("websocket error",e)}},f.prototype.write=function(t){var e=this;this.writable=!1;for(var n=t.length,r=0,i=n;r<i;r++)!function(t){s.encodePacket(t,e.supportsBinary,(function(r){if("undefined"==typeof uni&&"undefined"==typeof wx||"undefined"!=typeof WebSocket){if(!e.usingBrowserWebSocket){var i={};if(t.options&&(i.compress=t.options.compress),e.perMessageDeflate)("string"==typeof r?Buffer.byteLength(r):r.length)<e.perMessageDeflate.threshold&&(i.compress=!1)}try{e.usingBrowserWebSocket?e.ws.send(r):e.ws.send(r,i)}catch(t){}}else try{e.ws.send(r)}catch(t){}--n||o()}))}(t[r]);function o(){e.emit("flush"),setTimeout((function(){e.writable=!0,e.emit("drain")}),0)}},f.prototype.onClose=function(){o.prototype.onClose.call(this)},f.prototype.doClose=function(){void 0!==this.ws&&this.ws.close()},f.prototype.uri=function(){var t=this.query||{},e=this.secure?"wss":"ws",n="";return this.port&&("wss"===e&&443!==Number(this.port)||"ws"===e&&80!==Number(this.port))&&(n=":"+this.port),this.timestampRequests&&(t[this.timestampParam]=u()),this.supportsBinary||(t.b64=1),(t=c.encode(t)).length&&(t="?"+t),e+"://"+(-1!==this.hostname.indexOf(":")?"["+this.hostname+"]":this.hostname)+n+this.path+t},f.prototype.check=function(){return!(!l||"__initialize"in l&&this.name===f.prototype.name)}},function(t,e){},function(t,e){t.exports=function(t,e){for(var n=[],r=(e=e||0)||0;r<t.length;r++)n[r-e]=t[r];return n}},function(t,e){function n(t){t=t||{},this.ms=t.min||100,this.max=t.max||1e4,this.factor=t.factor||2,this.jitter=t.jitter>0&&t.jitter<=1?t.jitter:0,this.attempts=0}t.exports=n,n.prototype.duration=function(){var t=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var e=Math.random(),n=Math.floor(e*this.jitter*t);t=0==(1&Math.floor(10*e))?t-n:t+n}return 0|Math.min(t,this.max)},n.prototype.reset=function(){this.attempts=0},n.prototype.setMin=function(t){this.ms=t},n.prototype.setMax=function(t){this.max=t},n.prototype.setJitter=function(t){this.jitter=t}},function(t,e,n){"use strict";n.r(e);var r=n(0),i=n.n(r),o=n(1),s=n.n(o),c=Object.create(null);c.PRIVATE_MESSAGE_RECEIVED="PRIVATE_MESSAGE_RECEIVED",c.GROUP_MESSAGE_RECEIVED="GROUP_MESSAGE_RECEIVED",c.SYSTEM_MESSAGE_RECEIVED="SYSTEM_MESSAGE_RECEIVED",c.CONVERSATIONS_UPDATED="CONVERSATIONS_UPDATED",c.CONNECTED="CONNECTED",c.CONNECTING="CONNECTING",c.DISCONNECTED="DISCONNECTED",c.USER_PRESENCE="USER_PRESENCE",c.GROUP_PRESENCE="GROUP_PRESENCE";var a=n(7),u=n.n(a),l=new(function(){function t(){i()(this,t)}return s()(t,[{key:"isUndef",value:function(t){return null==t}},{key:"isTrue",value:function(t){return!0===t}},{key:"isFalse",value:function(t){return!1===t}},{key:"isPrimitive",value:function(t){return"string"==typeof t||"number"==typeof t||"symbol"===u()(t)||"boolean"==typeof t}},{key:"isDef",value:function(t){return null!=t}},{key:"isObject",value:function(t){return null!==t&&"object"===u()(t)}},{key:"isPlainObject",value:function(t){return"[object Object]"===Object.prototype.toString.call(t)}},{key:"isRegExp",value:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)}},{key:"isValidArrayIndex",value:function(t){var e=parseFloat(String(t));return e>=0&&Math.floor(e)===e&&isFinite(t)}},{key:"isStringOrNumber",value:function(t){return"string"==typeof t||"number"==typeof t}},{key:"isString",value:function(t){return"string"==typeof t}},{key:"isNumber",value:function(t){return"number"==typeof t}},{key:"isEmpty",value:function(t){return Array.isArray(t)?0==t.length:this.isObject(t)?!this.isDef(t):!this.isNumber(t)&&(this.isString(t)?""==t.trim():!this.isDef(t))}},{key:"isNative",value:function(t){return"function"==typeof t&&/native code/.test(t.toString())}},{key:"isFunction",value:function(t){return"function"==typeof t}}]),t}()),f=n(29),p=n.n(f),h=function(){function t(){i()(this,t)}return s()(t,null,[{key:"get",value:function(){return p()().replace(/-/g,"")}}]),t}(),d=n(3),y=n.n(d),v=n(4),m=n.n(v),g=n(2),b=n.n(g),k=n(30);function w(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}new(function(t){y()(n,t);var e=w(n);function n(){return i()(this,n),e.apply(this,arguments)}return s()(n,[{key:"deleteByKey",value:function(t,e,n){var r=t.findIndex((function(t){return t[e]==n}));r>-1&&t.splice(r,1)}},{key:"unshiftGuid",value:function(t){var e=!1,n=this.findIndex((function(e){return e==t}));for(n>-1&&(e=!0,this.splice(n,1)),this.unshift(t);this.length>300;)this.pop();return e}}]),n}(n.n(k)()(Array)));var E=n(10),R=n(17);function O(){}var S=new(function(){function t(){i()(this,t),this.subs=null,this.subs=Object.create(null)}return s()(t,[{key:"on",value:function(t,e){if(!l.isString(t))throw Error("eventType require a string.");if(!l.isDef(c[t]))throw Error("event not found.");if(!l.isFunction(e))throw Error("event require a callback.");this.subs[t]=e}},{key:"notify",value:function(t,e){var n=this.subs[t];n&&n(e)}}]),t}()),C="group",N="private",P="system",T={new:"new",sending:"sending",success:"success",fail:"fail"},I=function(){function t(){i()(this,t)}return s()(t,null,[{key:"assemble",value:function(t){if(!l.isDef(t))return null;try{var e=Object.create(null);return e.type=t.mt,e.timestamp=t.ts,e.senderId=t.s,e.payload=JSON.parse(t.p),e.messageId=t.i,e.status=T.success,t.t==C?e.groupId=t.r:e.receiverId=t.r,e}catch(t){return t}}}]),t}(),_=function(){function t(){i()(this,t),this.type="",this.lastMessage=null,this.unread=0,this.lastConsumedTimestamp=0,this.top=!1}return s()(t,null,[{key:"buildByNewMessage",value:function(e){var n=new t;return n.type=e.t,n.lastMessage=I.assemble(e),n.lastConsumedTimestamp=n.lastMessage.timestamp-1,n.unread=1,e.t==C?n.groupId=e.r:Ye.userId==e.r?n.userId=e.s:n.userId=e.r,n}},{key:"buildByConversations",value:function(e){var n=new t;return n.type=e.t,e.lmsg.t=e.t,n.lastMessage=I.assemble(e.lmsg),n.unread=0,n.lastConsumedTimestamp=e.lcts,n.top=e.top||!1,e.t==C?n.groupId=e.g:n.userId=e.uid,n}}]),t}(),x={WRITE:"WRITE",READ:"READ",NONE:"NONE"},D=function(){function t(e){var n=this;i()(this,t),this.uuid=null,this.name="",this.params=null,this.success=null,this.fail=null,this.permission=x.NONE,this.singleTimeout=0,this.totalTimeout=0,this.startTime=0,this.complete=!1,this.retried=0,this.uuid=h.get(),this.name=e.name,this.params=e.params,this.permission=e.permission,this.totalTimeout=e.totalTimeout,this.singleTimeout=e.singleTimeout,this.success=function(t){n.complete||(n.complete=!0,e.success(t))},this.fail=function(t){n.complete||(n.complete=!0,e.fail(t))}}return s()(t,[{key:"start",value:function(){this.startTime=Date.now()}},{key:"isTimeout",value:function(){return this.startTime+this.totalTimeout<Date.now()}}]),t}(),M=1500,A=3e3,j=1500,B=1e4,F=2500,U=12e3,q=1700,L=12e3,G="authorize",z="subscribe",H="unsubscribe",V="imLastConversations",W="markPrivateMessageAsRead",J="markGroupMessageAsRead",X="imGroupOnlineCount",$="imHereNow",K="imGroupHereNow",Y="publishIM",Q="imHistory",Z="subscribeUserPresence",tt="unsubscribeUserPresence",et="subscribeGroupPresence",nt="unsubscribeGroupPresence",rt="removeConversation",it="topConversation",ot={message:"message",imMessage:"imMessage",userPresence:"userPresence",groupPresence:"groupPresence"},st=function(){function t(e){i()(this,t),this.im=null,this.list=[],this.synchronized=!1,this.im=e,this.im._goEasySocket.addMessageObserver(ot.imMessage,this.updateByNewMessage.bind(this))}return s()(t,[{key:"onUpdated",value:function(){var t=this;this.latestConversations().then((function(){t.im._event.notify(c.CONVERSATIONS_UPDATED,{unreadTotal:t.getUnreadTotal(t.list),conversations:t.list})}))}},{key:"latestConversations",value:function(){return this.synchronized?this.loadLocalConversations():this.loadServerConversations()}},{key:"updateByNewMessage",value:function(t){var e,n=this,r=this.list.findIndex((function(e){return t.t==C&&t.r==e.groupId||t.t==N&&n.getFriendId(t)==e.userId}));r>-1?((e=this.list[r]).unread+=1,this.list.splice(r,1),this.applyLastMessage(e,t)):e=_.buildByNewMessage(t),this.insertOne(e),this.onUpdated()}},{key:"imLastConversations",value:function(t,e){var n=new D({name:V,params:{},permission:x.READ,singleTimeout:F,totalTimeout:U,fail:e,success:t});this.im._goEasySocket.emit(n)}},{key:"loadServerConversations",value:function(){var t=this;return new Promise((function(e,n){t.imLastConversations((function(r){200==r.code?function(){for(var n=r.content,i=function(e,r){var i=t.list.find((function(t){return n[e].t==C&&n[e].g==t.groupId||n[e].t==N&&n[e].uid==t.userId}));l.isDef(i)?i.top=n[e].top:(i=_.buildByConversations(n[e]),t.insertOne(i))},o=0,s=n.length;o<s;o++)i(o);t.synchronized=!0,e({code:200,content:{unreadTotal:t.getUnreadTotal(t.list),conversations:t.list}})}():n(r)}),(function(t){n({code:t.resultCode,content:t.content})}))}))}},{key:"loadLocalConversations",value:function(){return Promise.resolve({code:200,content:{unreadTotal:this.getUnreadTotal(this.list),conversations:this.list}})}},{key:"privateMarkAsRead",value:function(t,e){var n=this,r=this.list.find((function(e){return e.userId==t}));if(!r)return Promise.reject({code:400,content:"not found this message."});e||(e=r.lastMessage.timestamp);var i={friendId:t,lastTimestamp:e,lastConsumedTimestamp:r.lastConsumedTimestamp};return new Promise((function(t,o){n.requestEmit(W,i,(function(i){200==i.code?(n.resetConversation(r,e,i.content.amount),t({code:200,content:"ok"})):o(i)}),(function(t){o({code:t.code||"408",content:t.content||"markAsRead failed"})}))}))}},{key:"groupMarkAsRead",value:function(t,e){var n=this,r=this.list.find((function(e){return e.groupId==t}));if(!r)return Promise.reject({code:400,content:"not found this message."});if(e||(e=r.lastMessage.timestamp),e<r.lastConsumedTimestamp)return Promise.reject({code:400,content:"Can not set a read timestamp"});if(e>r.lastMessage.timestamp)return Promise.reject({code:400,content:"Can not set a nonexistent timestamp"});var i={groupId:t,lastTimestamp:e,lastConsumedTimestamp:r.lastConsumedTimestamp};return new Promise((function(t,o){n.requestEmit(J,i,(function(i){200==i.code?(n.resetConversation(r,e,i.content.amount),t({code:200,content:"ok"})):o(i)}),(function(t){o(t||{code:t.code||408,content:t.content||"Failed to query message"})}))}))}},{key:"resetConversation",value:function(t,e,n){e<=t.lastConsumedTimestamp||(t.unread-=n,t.lastConsumedTimestamp=e,this.onUpdated())}},{key:"getUnreadTotal",value:function(t){for(var e=0,n=0,r=t.length;n<r;n++)e+=t[n].unread;return e}},{key:"getFriendId",value:function(t){return t.r==Ye.userId?t.s:t.r}},{key:"insertOne",value:function(t){var e=this.getPosIndex(t);this.list.splice(e+1,0,t)}},{key:"getPosIndex",value:function(t){if(0==this.list.length)return-1;for(var e,n,r=0,i=this.list.length;i-r>1;){e=Math.floor((r+i)/2),n=this.list[e];var o=this.compares(t,n);if(0==o)return e;o>0?r=e:i=e}return 0==r&&this.compares(this.list[0],t)>0?-1:r}},{key:"compares",value:function(t,e){var n;return(n=t.top==e.top?e.lastMessage.timestamp-t.lastMessage.timestamp:t.top?-1:1)>0?1:0===n?0:-1}},{key:"applyLastMessage",value:function(t,e){t.lastMessage.timestamp<e.ts&&(t.lastMessage=I.assemble(e))}},{key:"removeConversation",value:function(t,e){var n=this,r=e==N?"userId":"groupId";return l.isStringOrNumber(t)?(l.isNumber(t)&&(t=t.toString()),-1==this.findConversationIndex(e,t)?Promise.reject({code:400,content:"Failed to remove conversation, "+r+" does not exists."}):new Promise((function(r,i){var o={targetId:t,type:e};n.requestEmit(rt,o,(function(o){var s=n.findConversationIndex(e,t);s>-1&&n.list.splice(s,1),n.onUpdated(),200==o.code?r({}):i({code:o.code||408,content:o.content||"Failed to remove conversation"})}),(function(t){i({code:t.code||408,content:t.content||"Failed to remove conversation"})}))}))):Promise.reject({code:400,content:"Failed to remove conversation, "+r+" must be a string or integer."})}},{key:"topConversation",value:function(t,e,n){var r=this,i=n==N?"userId":"groupId";if(!l.isStringOrNumber(t))return Promise.reject({code:400,content:"Failed to top conversation, "+i+" must be a string or integer."});l.isNumber(t)&&(t=t.toString());var o=this.findConversationIndex(n,t);return-1==o||this.list[o].top==e?Promise.reject({code:400,content:"Failed to top conversation, "+i+" does not exists."}):new Promise((function(i,o){var s={targetId:t,top:e,type:n};r.requestEmit(it,s,(function(){var o=r.findConversationIndex(n,t),s=r.list[o];s.top=e,r.list.splice(o,1),r.insertOne(s),r.onUpdated(),i({})}),(function(t){o({code:t.code||408,content:t.content||"Failed to top Conversation"})}))}))}},{key:"requestEmit",value:function(t,e,n,r){var i=new D({name:t,params:e,permission:x.WRITE,singleTimeout:q,totalTimeout:L,success:n,fail:r});this.im._goEasySocket.emit(i)}},{key:"findConversationIndex",value:function(t,e){return this.list.findIndex((function(n){return t==N?n.type==t&&n.userId==e:n.type==t&&n.groupId==e}))}}]),t}(),ct=new(function(){function t(){i()(this,t)}return s()(t,[{key:"fileExtension",value:function(t,e){if(l.isString(t))try{var n=t.split(e);return n[n.length-1]}catch(t){throw Error(t)}}}]),t}()),at=n(5),ut=n.n(at),lt={default:"default",text:"text",image:"image",video:"video",audio:"audio",emoji:"emoji",file:"file"},ft=function(){function t(e){i()(this,t),this.type="",this.timestamp=null,this.senderId=null,this.payload=null,this.messageId=h.get(),this.status=T.new,this.validate(e),this.setSenderId(),this.setType(e),this.setPayload(e)}return s()(t,[{key:"validate",value:function(t){if(!l.isObject(t))throw Error("it is an empty message.")}},{key:"setType",value:function(t){throw Error("Abstract method")}},{key:"setPayload",value:function(t){this.payload=Object.create(null)}},{key:"setSenderId",value:function(){if(!Ye.userId)throw Error("please call connect() first.");this.senderId=Ye.userId}}]),t}();function pt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var ht=function(t){y()(n,t);var e=pt(n);function n(t){var r;return i()(this,n),(r=e.call(this,t)).file=null,r.onProgress=null,r.setFile(t.file),r.setOnProgress(t.onProgress),r}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t)}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t),this.payload.size="",this.payload.contentType="",this.payload.name="",this.payload.url=""}},{key:"setType",value:function(t){this.type=lt.file}},{key:"setFile",value:function(t){this.file=t}},{key:"setOnProgress",value:function(t){this.onProgress=t}}]),n}(ft);function dt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var yt=function(t){y()(n,t);var e=dt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){if(ut()(b()(n.prototype),"validate",this).call(this,t),!l.isDef(t.file))throw Error("file is empty.")}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t)}}]),n}(ht);function vt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var mt=function(t){y()(n,t);var e=vt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){if(ut()(b()(n.prototype),"validate",this).call(this,t),!l.isDef(t.file.tempFiles)||0==t.file.tempFiles[0].length)throw Error("tempFiles is empty.")}},{key:"setType",value:function(t){this.type=lt.image}},{key:"setFile",value:function(t){var e="chooseMedia:ok"==t.errMsg?t.tempFiles[0].tempFilePath:t.tempFiles[0].path;t.tempFiles[0].path=e,this.file=t}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t);var e=this,r=t.file.tempFiles[0],i="chooseMedia:ok"==t.file.errMsg?r.tempFilePath:r.path;this.payload.url=i,this.payload.size=r.size,this.payload.width="",this.payload.height="",this.payload.contentType="";var o=l.isEmpty(r.name)||null==r.name?i:r.name;this.payload.name="wx-image."+ct.fileExtension(o,"."),this.payload.contentType="image/"+ct.fileExtension(o,"."),wx.getImageInfo({src:i,success:function(t){e.payload.width=t.width,e.payload.height=t.height}})}}]),n}(yt);function gt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var bt=function(t){y()(n,t);var e=gt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(t){this.type=lt.audio}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t);var e=t.file.tempFilePath;this.payload.url=e,this.payload.duration=t.file.duration/1e3,this.payload.size=t.file.fileSize;var r=l.isEmpty(t.file.name)||null==t.file.name?e:t.file.name;this.payload.contentType="audio/"+ct.fileExtension(r,"."),this.payload.name="wx-audio."+ct.fileExtension(r,".")}}]),n}(yt);function kt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var wt=function(t){y()(n,t);var e=kt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(t){this.type=lt.video}},{key:"setFile",value:function(t){this.file="chooseMedia:ok"==t.errMsg?t.tempFiles[0]:t}},{key:"setPayload",value:function(t){this.payload=Object.create(null);var e=Object.create(null),n=Object.create(null),r="chooseMedia:ok"==t.file.errMsg?t.file.tempFiles[0]:t.file,i=r.duration,o=r.height,s=r.size,c=r.tempFilePath,a=r.thumbTempFilePath,u=r.width,f=r.name,p=void 0===f?"":f,h=l.isEmpty(p)?c:p;e.contentType="video/"+ct.fileExtension(h,"."),e.name="wx-video."+ct.fileExtension(h,"."),e.url=c,e.width=n.width=u,e.height=n.height=o,e.size=s,e.duration=i,n.url=a,n.contentType="image/jpg",n.name="wx-thumbnail.jpg",this.payload.video=e,this.payload.thumbnail=n}}]),n}(yt);function Et(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Rt=function(t){y()(n,t);var e=Et(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){if(ut()(b()(n.prototype),"validate",this).call(this,t),!l.isDef(t.file))throw Error("file is empty.")}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t)}}]),n}(ht);function Ot(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var St=function(t){y()(n,t);var e=Ot(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(t){this.type=lt.audio}},{key:"setPayload",value:function(t){var e=this;ut()(b()(n.prototype),"setPayload",this).call(this,t);var r=this,i=t.file.tempFilePath;this.payload.url=i;var o=l.isEmpty(t.file.name)||null==t.file.name?i:t.file.name;if(this.payload.contentType="audio/"+ct.fileExtension(o,"."),this.payload.name="uni-audio."+ct.fileExtension(o,"."),l.isDef(t.file.duration))this.payload.duration=t.file.duration/1e3;else{var s=uni.createInnerAudioContext();s.src=i,s.onCanplay((function(t){r.payload.duration=s.duration,s.destroy()}))}uni.getFileInfo({filePath:i,success:function(t){e.payload.size=t.size}})}}]),n}(Rt);function Ct(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Nt=function(t){y()(n,t);var e=Ct(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(t){this.type=lt.video}},{key:"setPayload",value:function(t){var e=Object.create(null),n=Object.create(null);this.payload=Object.create(null);var r=t.file,i=r.duration,o=r.height,s=r.size,c=r.tempFilePath,a=r.width,u=r.name,f=void 0===u?"":u,p=l.isEmpty(f)?c:f;e.contentType="video/"+ct.fileExtension(p,"."),e.name="uni-video."+ct.fileExtension(p,"."),e.size=s,e.duration=i,e.url=n.url=c,e.width=n.width=a,e.height=n.height=o,n.contentType="image/jpg",n.name="wx-thumbnail.jpg",this.payload.video=e,this.payload.thumbnail=n}}]),n}(Rt);function Pt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Tt=function(t){y()(n,t);var e=Pt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){if(ut()(b()(n.prototype),"validate",this).call(this,t),!l.isDef(t.file.tempFiles)||0==t.file.tempFiles[0].length)throw Error("tempFiles is empty.")}},{key:"setType",value:function(t){this.type=lt.image}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t);var e=this,r=t.file.tempFiles[0];this.payload.url=r.path,this.payload.size=r.size,this.payload.width="",this.payload.height="";var i=l.isEmpty(r.name)||null==r.name?r.path:r.name;this.payload.contentType="image/"+ct.fileExtension(i,"."),this.payload.name="uni-image."+ct.fileExtension(i,"."),uni.getImageInfo({src:r.path,success:function(t){e.payload.width=t.width,e.payload.height=t.height}})}}]),n}(Rt);function It(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var _t=function(t){y()(n,t);var e=It(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){if(ut()(b()(n.prototype),"validate",this).call(this,t),!(t.file instanceof File))throw Error("wrong file type.");if(0==t.file.size)throw Error("File size is 0.");if(t.file.size>31457280)throw Error("message-length limit 30mib")}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t),this.payload.contentType=t.file.type,this.payload.name=t.file.name,this.payload.size=t.file.size;var e=(window.URL||window.webkitURL).createObjectURL(t.file);this.payload.url=e}}]),n}(ht);function xt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Dt=function(t){y()(n,t);var e=xt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t);var e=["gif","jpg","png","jpeg"];if(!e.find((function(e){return e==t.file.type.split("/")[1].toLowerCase()})))throw Error("Only "+e.join(",")+" is supported image.")}},{key:"setType",value:function(t){this.type=lt.image}},{key:"setPayload",value:function(t){var e=this;ut()(b()(n.prototype),"setPayload",this).call(this,t);var r=window.URL||window.webkitURL,i=new Image;i.src=r.createObjectURL(t.file),i.onload=function(){e.payload.width=i.width,e.payload.height=i.height,r.revokeObjectURL(i.src)}}}]),n}(_t);function Mt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var At=function(t){y()(n,t);var e=Mt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t);var e=["mp3","ogg","wav","wma","ape","acc","mpeg"];if(!e.find((function(e){return e==t.file.type.split("/")[1].toLowerCase()})))throw Error("Only "+e.join(",")+" is supported audio.")}},{key:"setType",value:function(t){this.type=lt.audio}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t);var e=this,r=window.URL||window.webkitURL,i=document.createElement("audio");i.src=r.createObjectURL(t.file),i.onloadedmetadata=function(){e.payload.duration=i.duration,r.revokeObjectURL(i.src)}}}]),n}(_t);function jt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Bt=function(t){y()(n,t);var e=jt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){ut()(b()(n.prototype),"validate",this).call(this,t);var e=["avi","mov","rmvb","rm","flv","mp4","3gp","quicktime"];if(!e.find((function(e){return e==t.file.type.split("/")[1].toLowerCase()})))throw Error("Only "+e.join(",")+" is supported video.")}},{key:"setType",value:function(t){this.type=lt.video}},{key:"setPayload",value:function(t){this.payload=Object.create(null);var e=Object.create(null),n=Object.create(null);e.contentType=t.file.type,e.size=t.file.size,e.duration=0,e.url=n.url="",e.name=t.file.name,e.width=n.width=0,e.height=n.height=0,n.contentType="image/jpg",this.payload.video=e,this.payload.thumbnail=n;var r=this,i=window.URL||window.webkitURL,o=document.createElement("video"),s=i.createObjectURL(t.file);o.src=s,o.onloadedmetadata=function(){r.payload.video.duration=o.duration,r.payload.video.width=r.payload.thumbnail.width=o.videoWidth,r.payload.video.height=r.payload.thumbnail.height=o.videoHeight,r.payload.video.url=s,r.payload.thumbnail.url=function(t){var e=document.createElement("canvas");return e.width=t.videoWidth,e.height=t.videoHeight,e.getContext("2d").drawImage(t,0,0,e.width,e.height),e.toDataURL("image/png")}(o),i.revokeObjectURL(o.src)}}}]),n}(_t);var Ft=function(){function t(){i()(this,t)}return s()(t,null,[{key:"resolve",value:function(){return E.a.isUni()?"uniApp":E.a.isWx()?"wx":"html"}}]),t}();function Ut(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var qt=function(t){y()(n,t);var e=Ut(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"validate",value:function(t){if(l.isEmpty(t.text)||""==t.text.trim())throw Error("text is empty")}},{key:"setType",value:function(t){this.type=lt.text}},{key:"setPayload",value:function(t){ut()(b()(n.prototype),"setPayload",this).call(this,t),this.payload.text=t.text}}]),n}(ft);function Lt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Gt=function(t){y()(n,t);var e=Lt(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"setType",value:function(t){if(!l.isStringOrNumber(t.type))throw Error("type require a string or number.");if(l.isEmpty(t.type))throw Error("type is empty.");this.type=t.type}},{key:"setPayload",value:function(t){if(l.isEmpty(t.payload))throw Error("payload is empty.");if(!l.isPlainObject(t.payload)&&!l.isStringOrNumber(t.payload))throw Error("payload require object | string | number.");this.payload=t.payload}}]),n}(ft),zt=new(function(){function t(){i()(this,t),this.messageTypes={wx:{image:mt,file:yt,audio:bt,video:wt,text:qt},uniApp:{image:Tt,file:Rt,audio:St,video:Nt,text:qt},html:{image:Dt,file:_t,audio:At,video:Bt,text:qt}}}return s()(t,[{key:"create",value:function(t,e){var n=Ft.resolve(),r=this.messageTypes[n][t];return r?new r(e):new Gt(e)}}]),t}()),Ht=n(11),Vt=n.n(Ht),Wt={DISCONNECTED:"disconnected",DISCONNECTING:"disconnecting",CONNECTING:"connecting",CONNECTED:"connected",RECONNECTING:"reconnecting",RECONNECTED:"reconnected",EXPIRED_RECONNECTED:"reconnected",CONNECT_FAILED:"connect_failed"},Jt=function(){function t(e){i()(this,t),this.socket=null,this.socket=e}return s()(t,[{key:"emit",value:function(t){this.socket.status!==Wt.CONNECT_FAILED&&this.socket.status!==Wt.DISCONNECTED?(t.start(),this.doEmit(t)):t.fail({resultCode:"409",content:"Please connect first"})}},{key:"doEmit",value:function(t){var e=this;if(t.isTimeout())t.fail({resultCode:408,content:"Host unreachable or timeout"});else if(this.socket.status!==Wt.CONNECT_FAILED)if(this.authenticated())if(this.hasPermission(t))if(this.socket.status===Wt.CONNECTED||this.socket.status===Wt.RECONNECTED||this.socket.status===Wt.EXPIRED_RECONNECTED){if(!t.complete){var n=setTimeout((function(){e.doEmit(t)}),t.singleTimeout);this.socket.doEmit(t.name,t.params,(function(e){clearTimeout(n),200===e.resultCode||200==e.code?t.success(e):t.fail(e)})),t.retried++}}else setTimeout((function(){e.doEmit(t)}),500);else t.fail({resultCode:401,content:"No permission"});else setTimeout((function(){e.doEmit(t)}),500);else t.fail({resultCode:408,content:"Failed to connect GoEasy."})}},{key:"hasPermission",value:function(t){return!!this.socket.permissions.find((function(e){return e===t.permission}))}},{key:"authenticated",value:function(){return this.socket.status===Wt.CONNECTED||this.socket.status===Wt.RECONNECTING||this.socket.status===Wt.RECONNECTED||this.socket.status===Wt.EXPIRED_RECONNECTED}}]),t}(),Xt=n(31),$t=n.n(Xt),Kt=function(){function t(){i()(this,t),this.io=$t.a,this.status=Wt.DISCONNECTED,this.permissions=[x.NONE],this.emitter=null,this.connectedObservers=[],this.disconnectedObservers=[],this.emitter=new Jt(this)}return s()(t,[{key:"connect",value:function(){this.status=Wt.CONNECTING}},{key:"emit",value:function(t){this.emitter.emit(t)}},{key:"doEmit",value:function(t,e,n){}},{key:"on",value:function(t,e){this.io.on(t,e)}},{key:"disconnect",value:function(){this.io.disconnect()}},{key:"getStatus",value:function(){return this.status}},{key:"addConnectedObserver",value:function(t){l.isFunction(t)&&this.connectedObservers.push(t)}},{key:"addDisconnectedObserver",value:function(t){l.isFunction(t)&&this.disconnectedObservers.push(t)}},{key:"notify",value:function(t,e){for(var n=0;n<t.length;n++)t[n](e)}}]),t}();function Yt(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Qt=function(t){y()(n,t);var e=Yt(n);function n(t){var r;return i()(this,n),(r=e.call(this)).reconnectingObservers=[],r.addReconnectingObserver(t.onReconnecting),r.addDisconnectedObserver(t.onDisconnected),r}return s()(n,[{key:"connect",value:function(t){ut()(b()(n.prototype),"connect",this).call(this),this.io=this.io.connect(t.uri,t.opts),this.initListener()}},{key:"doEmit",value:function(t,e,n){this.io.emit(t,e,n)}},{key:"initListener",value:function(){var t=this;this.io.on("reconnecting",(function(e){t.status=Wt.CONNECTING,t.notify(t.reconnectingObservers,e)})),this.io.on("connect",(function(){t.status=Wt.CONNECTED,t.notify(t.connectedObservers)})),this.io.on("disconnect",(function(){t.status=Wt.DISCONNECTED,t.notify(t.disconnectedObservers)})),this.io.on("connect_error",(function(t){}))}},{key:"addReconnectingObserver",value:function(t){this.reconnectingObservers.push(t)}}]),n}(Kt),Zt=function(){function t(e){i()(this,t),this.callback=O,this.guidList=[],this.callback=e}return s()(t,[{key:"onMessage",value:function(t,e){"string"==typeof e&&(e=JSON.parse(e));var n=this.guidList.findIndex((function(t){return t==e.i}));this.guidList.unshift(e.i),n>-1?this.guidList.splice(n,1):(this.guidList.length>300&&this.guidList.pop(),this.callback(e))}}]),t}(),te=new(function(){function t(){i()(this,t),this.overrided=!1}return s()(t,[{key:"overrideUniShowHideMethods",value:function(){if(E.a.isUni()&&!this.overrided&&getApp()&&void 0!==getApp().$options){this.overrided=!0;var t=getApp().$options;if(void 0!==t.onShow){var e=t.onShow[0];t.onShow[0]=function(){getApp().uniAppRunningBackend=!1,e&&e.call(t)}}if(void 0!==t.onHide){var n=t.onHide[0];t.onHide[0]=function(){getApp().uniAppRunningBackend=!0,n&&n.call(t)}}}}}]),t}());function ee(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var ne=function(t){y()(n,t);var e=ee(n);function n(t){var r;return i()(this,n),(r=e.call(this)).ioSocket=null,r.sid=null,r.appKey=null,r.userId=null,r.userData=null,r.otp=null,r.artifactVersion="0.0.0",r.imVersion="0.0.0",r.uri=null,r.ioOpts=null,r.type="",r.reconnectingTimes=0,r.messageObservers={},r.connectFailedObservers=[],r.connectingObservers=[],r.expiredReconnectedObservers=[],r.ioSocket=new Qt({onDisconnected:r.onIoDisconnected.bind(Vt()(r)),onReconnecting:r.onIoReconnecting.bind(Vt()(r))}),r.ioSocket.addConnectedObserver(r.onIoReconnected.bind(Vt()(r))),r.appKey=t.appkey,r.userId=t.userId,r.userData=t.userData||"",r.otp=t.otp||null,r.ioOpts=t.opts,r.uri=t.uri,r.imVersion=t.imVersion,r.artifactVersion=t.artifactVersion,r.type=t.type||"",r.addConnectedObserver(t.onConnected),r.addConnectingObserver(t.onConnecting),r.addConnectFailedObserver(t.onConnectFailed),r.addDisconnectedObserver(t.onDisconnected),r}return s()(n,[{key:"onIoReconnected",value:function(){this.status===Wt.RECONNECTING&&this.authorize()}},{key:"emit",value:function(t){ut()(b()(n.prototype),"emit",this).call(this,t)}},{key:"doEmit",value:function(t,e,n){e.sid=this.sid,this.ioSocket.doEmit(t,e,n)}},{key:"sendAck",value:function(t,e){this.ioSocket.io.emit(t,e)}},{key:"connect",value:function(t){ut()(b()(n.prototype),"connect",this).call(this),this.onConnecting(this.reconnectingTimes),this.ioSocket.connect({uri:this.uri,opts:this.ioOpts}),this.authorize()}},{key:"disconnect",value:function(){this.status=Wt.DISCONNECTING,this.ioSocket.disconnect()}},{key:"authorize",value:function(){var t={appkey:this.appKey,userId:this.userId,userData:this.userData,otp:this.otp,artifactVersion:this.artifactVersion,type:this.type,sid:this.sid,imVersion:this.imVersion},e=new D({name:G,params:t,permission:x.NONE,singleTimeout:j,totalTimeout:B,success:this.onAuthorizeSuccess.bind(this),fail:this.onAuthorizeFailed.bind(this)});this.ioSocket.emit(e)}},{key:"onConnecting",value:function(){this.notify(this.connectingObservers,this.reconnectingTimes)}},{key:"onIoReconnecting",value:function(){te.overrideUniShowHideMethods(),this.reconnectingTimes++,this.status==Wt.CONNECTED||this.status==Wt.EXPIRED_RECONNECTED||this.status==Wt.RECONNECTING?this.status=Wt.RECONNECTING:this.status=Wt.CONNECTING,this.onConnecting()}},{key:"onIoDisconnected",value:function(){this.status==Wt.DISCONNECTING&&(this.status=Wt.DISCONNECTED,this.notify(this.disconnectedObservers))}},{key:"onAuthorizeSuccess",value:function(t){this.status===Wt.RECONNECTING?this.sid!==t.sid?(this.status=Wt.EXPIRED_RECONNECTED,this.notify(this.expiredReconnectedObservers)):this.status=Wt.RECONNECTED:(this.status=Wt.CONNECTED,this.sid=t.sid);t.enablePublish&&(this.permissions.find((function(t){return t==x.WRITE}))||this.permissions.push(x.WRITE)),t.enableSubscribe&&(this.permissions.find((function(t){return t==x.READ}))||this.permissions.push(x.READ)),this.reconnectingTimes=0,this.notify(this.connectedObservers)}},{key:"onAuthorizeFailed",value:function(t){this.ioSocket.disconnect(),this.status=Wt.CONNECT_FAILED;var e={code:t.resultCode||408,content:t.content||"Host unreachable or timeout"};this.notify(this.connectFailedObservers,e)}},{key:"addConnectingObserver",value:function(t){l.isFunction(t)&&this.connectingObservers.push(t)}},{key:"addConnectFailedObserver",value:function(t){l.isFunction(t)&&this.connectFailedObservers.push(t)}},{key:"addExpiredReconnectedObserver",value:function(t){l.isFunction(t)&&this.expiredReconnectedObservers.push(t)}},{key:"addMessageObserver",value:function(t,e){var n=this;this.ioSocket.io.on(t,(function(e){n.notifyMessageObservers(t,e)})),this.messageObservers[t]||(this.messageObservers[t]=[]),this.messageObservers[t].push(new Zt(e))}},{key:"notifyMessageObservers",value:function(t,e){for(var n=this.messageObservers[t],r=0;r<n.length;r++)n[r].onMessage(t,e)}}]),n}(Kt),re=function(){function t(e){i()(this,t),this.im=null,this.im=e}return s()(t,[{key:"connect",value:function(){var t=this;return new Promise((function(e,n){t.im._goEasySocket.addConnectedObserver((function(){t.im._event.notify(c.CONNECTED),e()})),t.im._goEasySocket.addConnectFailedObserver((function(t){n({code:t.resultCode||408,content:t.content||"Failed to connect GoEasy"})})),t.im._goEasySocket.addConnectingObserver((function(e){t.im._event.notify(c.CONNECTING,e)})),t.im._goEasySocket.addDisconnectedObserver((function(){t.im._event.notify(c.DISCONNECT),n({code:400,content:"GoEasy disconnected."})})),t.im._goEasySocket.connect()}))}},{key:"disconnect",value:function(){var t=this;return new Promise((function(e,n){try{t.im._goEasySocket.disconnect(),e()}catch(t){n({code:t.resultCode||408,content:t.content||"disconnect failed"})}}))}}]),t}(),ie=(new re,function(){function t(e){i()(this,t),this.mt=null,this.to=null,this.p=null,this.t=null,this.guid=null,this.validate(e.to,e.message),this.mt=e.message.type,this.to=e.to,this.t=e.conversationType,this.guid=e.message.messageId,this.p=e.message.payload}return s()(t,[{key:"validate",value:function(t,e){if(!(e instanceof ft))throw Error("createMessage first.");if(l.isEmpty(t))throw Error("userId is empty.");if(!l.isStringOrNumber(t))throw Error("userId should be a string or number.");if(Ye.userId==t)throw Error("userId can not be the same as your id.");if(e.type==lt.text){if(!(e instanceof qt))throw Error("it is not textMessage");if((l.isObject(e.payload)?JSON.stringify(e.payload).length:e.payload.length)>3072)throw Error("message-length limit 3kb")}}}]),t}()),oe=function(){function t(){i()(this,t)}return s()(t,[{key:"build",value:function(){throw Error("Not implementation yet.")}}]),t}();function se(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var ce=new(function(t){y()(n,t);var e=se(n);function n(){return i()(this,n),e.call(this)}return s()(n,[{key:"build",value:function(t){return new Promise((function(e,n){try{e(t.payload)}catch(t){n(t)}}))}}]),n}(oe)),ae=function t(e){i()(this,t)},ue=n(9),le=n.n(ue),fe=function(){function t(){i()(this,t)}return s()(t,[{key:"upload",value:function(t){throw Error("Not implementation yet.")}}]),t}();function pe(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function he(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?pe(Object(n),!0).forEach((function(e){le()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):pe(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function de(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var ye=new(function(t){y()(n,t);var e=de(n);function n(){return i()(this,n),e.call(this)}return s()(n,[{key:"upload",value:function(t,e){var n=this;try{return new Promise((function(r,i){uni.uploadFile({url:t.host,filePath:n.getTempFilePath(t),name:"file",formData:t.parameters,success:function(e){200===e.statusCode?r({code:200,content:he(he({},t.payload),{},{message:e.errMsg})}):i({code:e.statusCode,content:e.errMsg})},fail:function(t){i({code:500,content:t.errMsg})}}).onProgressUpdate((function(t){e&&e(t)}))}))}catch(t){return new Promise((function(e,n){n({code:500,content:t})}))}}},{key:"getTempFilePath",value:function(t){var e=t.file||t.fileRes;return Array.isArray(e.tempFiles)?e.tempFiles[0].path:e.tempFilePath}}]),n}(fe));function ve(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function me(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ve(Object(n),!0).forEach((function(e){le()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ve(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function ge(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var be=new(function(t){y()(n,t);var e=ge(n);function n(){return i()(this,n),e.apply(this,arguments)}return s()(n,[{key:"upload",value:function(t,e){var n=this;try{return new Promise((function(r,i){wx.uploadFile({url:t.host,filePath:n.getTempFilePath(t),name:"file",formData:t.parameters,success:function(e){200===e.statusCode?r({code:200,content:me(me({},t.payload),{},{message:e.errMsg})}):i({code:e.statusCode,content:e.errMsg})},fail:function(t){i({code:500,content:t.errMsg})}}).onProgressUpdate((function(t){e&&e(t)}))}))}catch(t){return new Promise((function(e,n){n({code:500,content:t})}))}}},{key:"getTempFilePath",value:function(t){var e=t.file||t.fileRes;return Array.isArray(e.tempFiles)?e.tempFiles[0].path:e.tempFilePath}}]),n}(fe));function ke(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function we(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ke(Object(n),!0).forEach((function(e){le()(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ke(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function Ee(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Re=new(function(t){y()(n,t);var e=Ee(n);function n(){return i()(this,n),e.call(this)}return s()(n,[{key:"upload",value:function(t,e){try{return new Promise((function(n,r){var i=new XMLHttpRequest;for(var o in i.open("post",t.host,!0),t.headers)i.setRequestHeader(o,t.headers[o]);i.upload.onprogress=function(t){e&&e(t)},i.upload.onloadstart=function(t){e&&e(t)},i.upload.onloadend=function(t){e&&e(t)};var s=new FormData;for(var c in t.parameters)"fileRes"==c?s.append("file",t.parameters[c]):s.append(c,t.parameters[c]);i.send(s),i.onreadystatechange=function(){4==i.readyState&&(i.status>=200&&i.status<300||304==i.status?n({code:i.status,content:we(we({},t.payload),{},{message:i.responseText})}):r({code:i.status,content:i.responseText}))}}))}catch(t){return new Promise((function(e,n){n({code:500,content:t})}))}}}]),n}(fe)),Oe=new(function(){function t(){i()(this,t),this.uploader={uniApp:ye,wx:be,html:Re}}return s()(t,[{key:"upload",value:function(t,e){var n=Ft.resolve();return this.uploader[n].upload(t,e)}}]),t}()),Se="ALI",Ce=function t(e,n,r,o,s){i()(this,t),this.host="",this.headers={},this.parameters={},this.file={},this.payload={},this.host=e,this.headers=n,this.parameters=r,this.file=o,this.payload=s},Ne=function(){function t(){i()(this,t)}return s()(t,[{key:"build",value:function(t,e){}},{key:"newFileName",value:function(t){return t&&t.newFilename||""}}]),t}();function Pe(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Te=new(function(t){y()(n,t);var e=Pe(n);function n(){return i()(this,n),e.call(this)}return s()(n,[{key:"url",value:function(t){return t.host+"/"+t.dir+"/"+this.newFileName(t)}},{key:"build",value:function(t,e){var n={key:t.dir+"/"+this.newFileName(t),OSSAccessKeyId:t.accessKeyId,policy:t.policy,signature:t.signature,success_action_status:"200",fileRes:e},r={newFileName:this.newFileName(t),url:this.url(t)};return new Ce(t.host,null,n,e,r)}}]),n}(Ne));function Ie(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var _e=new(function(t){y()(n,t);var e=Ie(n);function n(){return i()(this,n),e.call(this)}return s()(n,[{key:"url",value:function(t){return t.downloadUrl}},{key:"build",value:function(t,e){var n={key:this.newFileName(t),token:t.token,file:e},r={newFileName:this.newFileName(t),url:this.url(t)};return new Ce(t.host,null,n,e,r)}}]),n}(Ne)),xe=function t(e){return i()(this,t),e==Se?Te:_e},De=function(){function t(e){i()(this,t),this.im=null,this.im=e}return s()(t,[{key:"resolve",value:function(t){var e=this;return new Promise((function(n,r){var i=new D({name:"uploadToken",params:{filename:t},permission:x.WRITE,singleTimeout:q,totalTimeout:L,fail:function(t){r(t)},success:function(t){200==t.code?n(t):r(t)}});e.im._goEasySocket.emit(i)}))}}]),t}(),Me=function(){function t(e){i()(this,t),this.uploadTokenResolver=null,this.uploadTokenResolver=new De(e)}return s()(t,[{key:"build",value:function(t,e){var n=this;return new Promise((function(r,i){n.uploadTokenResolver.resolve(e).then((function(e){var n=e.content;r(new xe(n.vendor).build(n,t))})).catch((function(t){i(t)}))}))}}]),t}(),Ae=function(){function t(e){i()(this,t),this.requestBuilder=null,this.fileUploader=Oe,this.requestBuilder=new Me(e)}return s()(t,[{key:"upload",value:function(t,e,n){var r=this;return new Promise((function(i,o){r.requestBuilder.build(t,e).then((function(t){i(r.doUpload(t,n))})).catch((function(t){o(t)}))}))}},{key:"customizeUpload",value:function(t,e){this.doUpload(t,e)}},{key:"doUpload",value:function(t,e){return this.fileUploader.upload(t,e)}}]),t}();function je(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Be=function(t){y()(n,t);var e=je(n);function n(t){var r;return i()(this,n),(r=e.call(this)).im=null,r.goEasyUploader=new Ae(t),r}return s()(n,[{key:"build",value:function(t){var e=this;return new Promise((function(n,r){var i=new ae;e.upload(t).then((function(e){var r=e.content,o=void 0===r?{}:r;(i=t.payload).url=o.url,i.name=o.newFileName,n(i)})).catch((function(t){r(t)}))}))}},{key:"upload",value:function(t){var e=t.type==lt.video?t.payload.video.name:t.payload.name;return this.goEasyUploader.upload(t.file,e,t.onProgress)}}]),n}(oe);function Fe(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}();return function(){var n,r=b()(t);if(e){var i=b()(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return m()(this,n)}}var Ue=function(t){y()(n,t);var e=Fe(n);function n(t){return i()(this,n),e.call(this,t)}return s()(n,[{key:"build",value:function(t){var e=this;return new Promise((function(n,r){var i=new ae;e.upload(t).then((function(e){e.content;i=t.payload;var r="?x-oss-process=video/snapshot,t_0000,f_jpg,w_"+t.payload.video.width+",m_fast,ar_auto";i.video.url=e.content.url,i.thumbnail.url=e.content.url+r,i.video.name=e.content.newFileName,n(i)})).catch((function(t){r(t)}))}))}}]),n}(Be),qe=function t(e,n){return i()(this,t),e==lt.video?new Ue(n):e==lt.audio||e==lt.image||e==lt.file?new Be(n):ce},Le=function(){function t(e){i()(this,t),this.im=null,this.im=e}return s()(t,[{key:"build",value:function(t,e,n){var r=this;return new Promise((function(i,o){var s=new ie({to:t,message:e,conversationType:n}),c=e.type;new qe(c,r.im).build(e).then((function(t){s.p=JSON.stringify(t),i(s)})).catch((function(t){o(t)}))}))}}]),t}(),Ge=function(){function t(e){i()(this,t),this.im=null,this.bulletMessageBuilder=null,this.im=e,this.bulletMessageBuilder=new Le(e)}return s()(t,[{key:"send",value:function(t,e,n){var r=this;return new Promise((function(i,o){e.status===T.new?(e.status=T.sending,r.bulletMessageBuilder.build(t,e,n).then((function(t){var n=new D({name:Y,params:t,permission:x.WRITE,singleTimeout:q,totalTimeout:L,fail:function(t){e.status=T.fail,o({code:t.resultCode||408,content:t.content||"Failed to send private message."})},success:function(t){e.status=T.success,200==t.resultCode?i({code:200,content:t.content}):o(t)}});r.im._goEasySocket.emit(n)})).catch((function(t){o({code:t.code||400,content:t.content||t})}))):o({code:400,content:"Please create a new message, a message can only be sent once"})}))}}]),t}(),ze=function(){function t(e){i()(this,t),this.im=null,this.im=e}return s()(t,[{key:"history",value:function(t){var e=this;return new Promise((function(n,r){e.transformOptions(t);var i=new D({name:Q,params:t,permission:x.READ,singleTimeout:F,totalTimeout:U,fail:function(t){r({code:t.code||408,content:t.content||"Failed to query message"})},success:function(t){if(200==t.code){var i=e.transformHistories(t);n({code:200,content:i})}else r(t)}});e.im._goEasySocket.emit(i)}))}},{key:"transformOptions",value:function(t){if(!l.isObject(t)||!l.isDef(t.friendId)&&!l.isDef(t.groupId))throw Error("friendId or groupId is not define.");if(l.isDef(t.friendId)&&l.isDef(t.groupId))throw Error("only contain friendId or groupId.");if(l.isDef(t.limit)||(t.limit=10),t.limit>30&&(t.limit=30),l.isDef(t.friendId)){if(!l.isStringOrNumber(t.friendId))throw Error("TypeError: friendId require string or number.");l.isNumber(t.friendId)&&(t.friendId=t.friendId.toString())}else{if(!l.isStringOrNumber(t.groupId))throw Error("TypeError: groupId require string or number.");l.isNumber(t.groupId)&&(t.groupId=t.groupId.toString())}return t}},{key:"transformHistories",value:function(t){var e=[];return t&&t.content&&t.content.map((function(t){var n=Object.create(null);n.timestamp=t.ts,n.senderId=t.s,n.type=t.mt,n.payload="string"==typeof t.p?JSON.parse(t.p):t.p,e.push(n)})),e}}]),t}(),He=function(){function t(e){i()(this,t),this.im=null,this.im=e,this.im._goEasySocket.addMessageObserver(ot.imMessage,this.newNewMessageReceived.bind(this))}return s()(t,[{key:"newNewMessageReceived",value:function(t){if(t.t===C&&t.a){this.im._goEasySocket.sendAck("imAck",{publishGuid:t.i});var e=I.assemble(t);this.im._event.notify(c.GROUP_MESSAGE_RECEIVED,e)}}},{key:"subscribe",value:function(t){var e=this;return new Promise((function(n,r){if(Array.isArray(t)&&0!=t.length){for(var i=0;i<t.length;i++){if(!l.isStringOrNumber(t[i]))return void r({code:400,content:"TypeError: groups item require string or number."});l.isNumber(t[i])&&(t[i]=t[i].toString())}var o=new D({name:z,params:{channels:t},permission:x.WRITE,singleTimeout:q,totalTimeout:L,success:function(){n({code:200,content:"ok"})},fail:function(t){r({code:t.resultCode||408,content:t.content||"Failed to subscribe group message"})}});e.im._goEasySocket.emit(o)}else r({code:400,content:"TypeError: groups require array."})}))}},{key:"unsubscribe",value:function(t){var e=this;return new Promise((function(n,r){if(l.isStringOrNumber(t)){t=t.toString();var i=new D({name:H,params:{channel:t},permission:x.READ,singleTimeout:q,totalTimeout:L,success:function(){n({code:200,content:"ok"})},fail:function(t){r({code:t.resultCode||408,content:t.content||"Failed to unsubscribe group message"})}});e.im._goEasySocket.emit(i)}else r({code:400,content:"TypeError: channel require string or number."})}))}}]),t}(),Ve=function(){function t(e){i()(this,t),this.im=null,this.im=e,this.im._goEasySocket.addMessageObserver(ot.imMessage,this.onNewMessageReceived.bind(this))}return s()(t,[{key:"onNewMessageReceived",value:function(t){if(t.t==N){t.a&&this.im._goEasySocket.sendAck("imAck",{publishGuid:t.i});var e=I.assemble(t);this.im._event.notify(c.PRIVATE_MESSAGE_RECEIVED,e)}}}]),t}(),We=function(){function t(e){i()(this,t),this.im=null,this.im=e}return s()(t,[{key:"get",value:function(t){var e=this;return new Promise((function(n,r){if(l.isStringOrNumber(t)){l.isNumber(t)&&(t=t.toString());var i=new D({name:X,params:{groupId:t},permission:x.READ,singleTimeout:F,totalTimeout:U,fail:function(t){r(t||{code:408,content:"Failed to query online group users"})},success:function(t){200==t.code?n(t):r(t)}});e.im._goEasySocket.emit(i)}else r({code:400,content:"TypeError: groupId require string or number."})}))}}]),t}(),Je=function(){function t(e){i()(this,t),this.im=null,this.im=e,this.im._goEasySocket.addMessageObserver(ot.groupPresence,this.newMessageReceived.bind(this))}return s()(t,[{key:"presence",value:function(t){var e=this;return new Promise((function(n,r){if(Array.isArray(t)&&0!=t.length){for(var i=0;i<t.length;i++){if(!l.isStringOrNumber(t[i]))return void r({code:400,content:"TypeError: groupIds item require string or number."});if(l.isNumber(t[i])&&(t[i]=t[i].toString()),0==t[i].length)return void r({code:400,content:"TypeError: groupIds has empty item."})}var o={groupIds:t};e.emitRocket(et,o,(function(){n({code:200,content:"ok"})}),(function(t){r({code:t.code||408,content:t.content||"Failed to subscribe group message"})}))}else r({code:400,content:"TypeError: groupIds require array."})}))}},{key:"unPresence",value:function(t){var e=this;return new Promise((function(n,r){if(l.isStringOrNumber(t)){l.isNumber(t)&&(t=t.toString());var i={groupId:t};e.emitRocket(nt,i,(function(){n({code:200,content:"ok"})}),(function(t){r({code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}))}else r({code:400,content:"TypeError: groupId require string or number."})}))}},{key:"emitRocket",value:function(t,e,n,r){var i=new D({name:t,params:e,singleTimeout:q,totalTimeout:L,permission:x.WRITE,success:n,fail:r});this.im._goEasySocket.emit(i)}},{key:"newMessageReceived",value:function(t){var e=this,n=null;t.c&&(n=JSON.parse(t.c)),n&&n.events&&n.events.map((function(t){t.groupOnlineCount=n.userAmount,t.groupId=n.channel,"string"==typeof t.userData&&(t.userData=JSON.parse(t.userData)),e.im._event.notify(c.GROUP_PRESENCE,t)}))}}]),t}(),Xe=function(){function t(e){i()(this,t),this.im=null,this.im=e,this.im._goEasySocket.addMessageObserver(ot.userPresence,this.newMessageReceived.bind(this))}return s()(t,[{key:"presence",value:function(t){var e=this;return new Promise((function(n,r){if(Array.isArray(t)&&0!=t.length){for(var i=0;i<t.length;i++){if(!l.isStringOrNumber(t[i]))return void r({code:400,content:"TypeError: userIds item require string or number."});if(l.isNumber(t[i])&&(t[i]=t[i].toString()),0==t[i].length)return void r({code:400,content:"TypeError: userIds has empty item."})}var o={userIds:t};e.emitRocket(Z,o,(function(){n({code:200,content:"ok"})}),(function(t){r({code:t.code||408,content:t.content||"Failed to subscribe group message"})}))}else r({code:400,content:"TypeError: userIds require array."})}))}},{key:"unPresence",value:function(t){var e=this;return new Promise((function(n,r){if(l.isStringOrNumber(t)){l.isNumber(t)&&(t=t.toString());var i={userId:t};e.emitRocket(tt,i,(function(){n({code:200,content:"ok"})}),(function(t){r({code:t.code||408,content:t.content||"Failed to unsubscribe presence"})}))}else r({code:400,content:"TypeError: id require string or number."})}))}},{key:"emitRocket",value:function(t,e,n,r){var i=new D({name:t,params:e,singleTimeout:q,totalTimeout:L,permission:x.WRITE,success:n,fail:r});this.im._goEasySocket.emit(i)}},{key:"newMessageReceived",value:function(t){var e=this,n=[];t.c&&(n=JSON.parse(t.c).events||[]),n.map((function(t){"string"==typeof t.userData&&(t.userData=JSON.parse(t.userData)),e.im._event.notify(c.USER_PRESENCE,t)}))}}]),t}(),$e=function(){function t(e){i()(this,t),this.im=null,this.im=e}return s()(t,[{key:"hereNow",value:function(t){var e=this;return new Promise((function(n,r){if(t.userIds&&Array.isArray(t.userIds)&&0!=t.userIds.length){for(var i=0;i<t.userIds.length;i++){if(!l.isStringOrNumber(t.userIds[i]))return void r({code:400,content:"TypeError: userIds item require string or number."});if(l.isNumber(t.userIds[i])&&(t.userIds[i]=t.userIds[i].toString()),0==t.userIds[i].length)return void r({code:400,content:"TypeError: userIds has empty item."})}var o=new D({name:$,params:t,permission:x.READ,singleTimeout:F,totalTimeout:U,fail:function(t){r({code:t.resultCode||408,content:t.content||"Failed to query online users"})},success:function(t){200==t.code?n(t):r(t)}});e.im._goEasySocket.emit(o)}else r({code:400,content:"TypeError: userIds require array."})}))}}]),t}(),Ke=function(){function t(e){i()(this,t),this.im=null,this.im=e}return s()(t,[{key:"hereNow",value:function(t){var e=this;return new Promise((function(n,r){if(l.isStringOrNumber(t)){l.isNumber(t)&&(t=t.toString());var i=new D({name:K,params:{groupId:t},permission:x.READ,singleTimeout:F,totalTimeout:U,fail:function(t){r({code:t.resultCode||408,content:t.content||"Failed to query online group users"})},success:function(t){200==t.code?n(t):r(t)}});e.im._goEasySocket.emit(i)}else r({code:400,content:"TypeError: groupId require string or number."})}))}}]),t}(),Ye=function(){function t(e){i()(this,t),this._appKey=void 0,this._host=void 0,this._supportOldBrowser=!1,this._event=S,this._goEasyUploader=null,this._connection=null,this._goEasySocket=null,this._messageSender=null,this._history=null,this._conversations=null,this._groupMessageReceive=null,this._groupPresenceSubscriber=null,this._groupOnlineCount=null,this._groupHereNow=null,this._privateMessageReceive=null,this._userPresenceSubscriber=null,this._userHereNow=null,this._appKey=e.appkey,this._host=e.host,this._supportOldBrowser=e.supportOldBrowser}return s()(t,[{key:"on",value:function(t,e){this._event.on(t,e)}},{key:"initialBeforeConnect",value:function(e){var n=this.setUriAndOpts(e.forceTLS);t.userId=e.id,this._goEasySocket=new ne({appkey:this._appKey,host:this._host,userId:e.id,userData:JSON.stringify(e.data),otp:e.otp,artifactVersion:"1.2.2",imVersion:t.version,type:"im",opts:n.opts,uri:n.uri}),this._connection=new re(this),this._messageSender=new Ge(this),this._history=new ze(this),this._goEasyUploader=new Ae(this),this._userHereNow=new $e(this),this._groupHereNow=new Ke(this),this._groupOnlineCount=new We(this)}},{key:"initialAfterConnect",value:function(){this._conversations=new st(this),this._groupPresenceSubscriber=new Je(this),this._groupMessageReceive=new He(this),this._userPresenceSubscriber=new Xe(this),this._privateMessageReceive=new Ve(this)}},{key:"connect",value:function(t){if(!l.isObject(t))return Promise.reject({code:400,content:"TypeError: user require an object."});if(l.isEmpty(t.id)||!l.isStringOrNumber(t.id))return Promise.reject({code:400,content:"TypeError: id require number or string."});if(l.isNumber(t.id)&&(t.id=t.id.toString()),t.data=l.isDef(t.data)?t.data:{},(l.isObject(t.data)?JSON.stringify(t.data).length:t.data.length)>300)return Promise.reject({code:400,content:"user.data-length limit 300 byte."});this.initialBeforeConnect(t);var e=this._connection.connect(t);return this.initialAfterConnect(),e}},{key:"disconnect",value:function(){return this._connection.disconnect()}},{key:"getStatus",value:function(){return this._goEasySocket.getStatus()}},{key:"createTextMessage",value:function(t){return zt.create(lt.text,t)}},{key:"createImageMessage",value:function(t){return zt.create(lt.image,t)}},{key:"createFileMessage",value:function(t){return zt.create(lt.file,t)}},{key:"createAudioMessage",value:function(t){return zt.create(lt.audio,t)}},{key:"createVideoMessage",value:function(t){return zt.create(lt.video,t)}},{key:"createCustomMessage",value:function(t){return zt.create(t.type,t)}},{key:"latestConversations",value:function(){return this._conversations?this._conversations.latestConversations():Promise.reject({code:500,content:"Please connect GoEasyIM first."})}},{key:"groupMarkAsRead",value:function(t,e){return this._conversations.groupMarkAsRead(t,e)}},{key:"privateMarkAsRead",value:function(t,e){return this._conversations.privateMarkAsRead(t,e)}},{key:"removePrivateConversation",value:function(t){return this._conversations.removeConversation(t,N)}},{key:"removeGroupConversation",value:function(t){return this._conversations.removeConversation(t,C)}},{key:"topPrivateConversation",value:function(t,e){return this._conversations.topConversation(t,e,N)}},{key:"topGroupConversation",value:function(t,e){return this._conversations.topConversation(t,e,C)}},{key:"history",value:function(t){return this._history.history(t)}},{key:"upload",value:function(t,e,n){return this._goEasyUploader.upload(t,e,n)}},{key:"sendSystemMessage",value:function(t,e){return this._messageSender.send(t,e,P)}},{key:"sendPrivateMessage",value:function(t,e){return this._messageSender.send(t,e,N)}},{key:"subscribeUserPresence",value:function(t){return this._userPresenceSubscriber.presence(t)}},{key:"unsubscribeUserPresence",value:function(t){return this._userPresenceSubscriber.unPresence(t)}},{key:"hereNow",value:function(t){return this._userHereNow.hereNow(t,N)}},{key:"sendGroupMessage",value:function(t,e){return this._messageSender.send(t,e,C)}},{key:"subscribeGroup",value:function(t){return this._groupMessageReceive.subscribe(t)}},{key:"unsubscribeGroup",value:function(t){return this._groupMessageReceive.unsubscribe(t)}},{key:"subscribeGroupPresence",value:function(t){return this._groupPresenceSubscriber.presence(t)}},{key:"unsubscribeGroupPresence",value:function(t){return this._groupPresenceSubscriber.unPresence(t)}},{key:"groupHereNow",value:function(t){return this._groupHereNow.hereNow(t)}},{key:"groupOnlineCount",value:function(t){return this._groupOnlineCount.get(t)}},{key:"setUriAndOpts",value:function(t){var e,n,r="://"+R.GoEasyDomainNumber.refreshNumber()+this._host;E.a.isBrowserClient()?(e=!1===t?"http"+r+":80":"https"+r+":443",n={transports:!0===this._supportOldBrowser?["polling","websocket"]:["websocket"],timeout:M}):(e="https://wx-"+this._host+":443",n={transports:["websocket"],reconnectionDelayMax:A});return{uri:e,opts:n}}}]),t}();Ye.version=null,Ye.userId=void 0;var Qe=null,Ze=function(){function t(){if(i()(this,t),!(this instanceof t&&Qe&&Qe._appKey&&Qe._host))throw Error("please call getInstance to structure instance.")}return s()(t,[{key:"on",value:function(t,e){Qe.on(t,e)}},{key:"connect",value:function(t){return Qe.connect(t)}},{key:"disconnect",value:function(){return Qe.disconnect()}},{key:"getStatus",value:function(){return Qe.getStatus()}},{key:"createTextMessage",value:function(t){return Qe.createTextMessage(t)}},{key:"createImageMessage",value:function(t){return Qe.createImageMessage(t)}},{key:"createFileMessage",value:function(t){return Qe.createFileMessage(t)}},{key:"createAudioMessage",value:function(t){return Qe.createAudioMessage(t)}},{key:"createVideoMessage",value:function(t){return Qe.createVideoMessage(t)}},{key:"createCustomMessage",value:function(t){return Qe.createCustomMessage(t)}},{key:"latestConversations",value:function(){return Qe.latestConversations()}},{key:"removePrivateConversation",value:function(t){return Qe.removePrivateConversation(t)}},{key:"removeGroupConversation",value:function(t){return Qe.removeGroupConversation(t)}},{key:"history",value:function(t){return Qe.history(t)}},{key:"upload",value:function(t,e,n){return Qe.upload(t,e,n)}},{key:"sendSystemMessage",value:function(t,e){return Qe.sendSystemMessage(t,e)}},{key:"sendPrivateMessage",value:function(t,e){return Qe.sendPrivateMessage(t,e)}},{key:"markGroupMessageAsRead",value:function(t,e){return Qe.groupMarkAsRead(t,e)}},{key:"markPrivateMessageAsRead",value:function(t,e){return Qe.privateMarkAsRead(t,e)}},{key:"topPrivateConversation",value:function(t,e){return Qe.topPrivateConversation(t,e)}},{key:"topGroupConversation",value:function(t,e){return Qe.topGroupConversation(t,e)}},{key:"subscribeUserPresence",value:function(t){return Qe.subscribeUserPresence(t)}},{key:"unsubscribeUserPresence",value:function(t){return Qe.unsubscribeUserPresence(t)}},{key:"hereNow",value:function(t){return Qe.hereNow(t)}},{key:"sendGroupMessage",value:function(t,e){return Qe.sendGroupMessage(t,e)}},{key:"subscribeGroup",value:function(t){return Qe.subscribeGroup(t)}},{key:"unsubscribeGroup",value:function(t){return Qe.unsubscribeGroup(t)}},{key:"subscribeGroupPresence",value:function(t){return Qe.subscribeGroupPresence(t)}},{key:"unsubscribeGroupPresence",value:function(t){return Qe.unsubscribeGroupPresence(t)}},{key:"groupHereNow",value:function(t){return Qe.groupHereNow(t)}},{key:"groupOnlineCount",value:function(t){return Qe.groupOnlineCount(t)}}],[{key:"getInstance",value:function(e){var n="";if(!l.isObject(e))throw n="options is require an object.",Error(n);if(!l.isPrimitive(e.appkey)||0==e.appkey.length)throw n="Invalid options: 'appkey' is empty.",Error(n);if(!l.isPrimitive(e.appkey)||0==e.appkey.length)throw n="Invalid options:'host' is empty.",Error(n);return null==t.goEasyIM&&(Ye.version=t.version,Qe=new Ye(e),this.goEasyIM=new t),this.goEasyIM}}]),t}();Ze.goEasyIM=null,Ze.EVENT=Object.create(c),Ze.version="1.3.1";e.default=Ze}]).default}));