!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(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},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 o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},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=12)}([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){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;n0&&t.currentNumber-1&&(e=!0,this.splice(n,1)),this.unshift(t);this.length>300;)this.pop();return e},v.prototype={debug:!1,socket:null,networkStatus:"initial",authorizeResult:null,subscribeBuffer:[],subscriptions:[],subscriptionChannelUUIDs:[],maxRetries:3,_manualConnect:!1,_manualDisconnectStatus:"initial",authorizeStatus:"initial",receivedGuids:new f,type:null,_copyConfig:function(t){this._appkey=t.appkey,this._otp=t.otp,this._isEmpty(t.userId)?(this._userId="anonymous-"+Math.floor(1e5*Math.random()+1),t.userId=this._userId):this._userId=this._trim(t.userId),this._isEmpty(t.userData)?this._userData="":this._userData=this._trim(t.userData),1==t.debug&&(this.debug=!0),this._isEmpty(t.type)||(this.type=t.type)},validateSubscription:function(t){var e=t.channel,n=t.channels;if(void 0===e&&void 0===n)return t.onFailed({code:400,content:"channel is required"}),!1;if(void 0!==e&&void 0!==n)return t.onFailed({code:400,content:"subscribe to either channel or channels, not both"}),!1;if(void 0!==e){if("number"==typeof e&&(e=e.toString()),this._isEmpty(e)&&void 0!==t.onFailed)return t.onFailed({code:400,content:"channel is required"}),!1}else{if(!this._isArray(n)||0===n.length)return t.onFailed({code:400,content:"channels must be an array"}),!1;if(this._isArray(n)&&n.length>500)return t.onFailed({code:400,content:"channels over max length:500"}),!1;if(this._isArray(n)&&n.length>0)for(var o=0;o500?e({code:400,content:"userIds is over max length 500"}):this.socket.emit("hereNowByUserIds",n,(function(t){e(t)})))},history:function(t,e){return"number"==typeof t.channel&&(t.channel=t.channel.toString()),this._isEmpty(t.channel)?void(void 0!==e&&e({code:400,content:"channel is required"})):void this.socket.emit("historyMessages",t,(function(t){void 0!==e&&e(t)}))},disconnect:function(){var t=this;this._manualDisconnectStatus="disconnecting","connected"===this.networkStatus&&"authorized"===this.authorizeStatus&&200===this.authorizeResult.code?t.tryEmit("manualDisconnect",null,(function(){t.socket.disconnect()}),(function(){t._manualDisconnectStatus="disconnected"})):this.socket.disconnect()},disconnected:function(){return"disconnected"===this.networkStatus},reconnect:function(){this._manualConnect=!0,this.socket.connect()},tryEmit:function(t,e,n,o){function r(){i.socket.emit(t,e,(function(t){s=!0,void 0!==o&&o(t)}))}var i=this,s=!1,c=0;r();var a=setInterval((function(){var t=c===i.maxRetries;s||t?(clearInterval(a),t&&void 0!==n&&n({code:408,content:"Server unreachable or timeout"})):(c++,e&&"undefined"!==e.retried&&(e.retried=c),r())}),1e3)},_callbackEvents:function(t){var e=this;this.socket.on("message",(function(t,n){var o=JSON.parse(t);if(!e.receivedGuids.unshiftGuid(o.i)){o.a&&e.socket.emit("ack",{publishGuid:o.i});var r=e.subscriptionChannelUUIDs[o.n];if(e._endWith(o.n,"presence"))void 0!==e.subscriptions[r].onPresence&&e.subscriptions[r].onPresence(JSON.parse(o.c));else if(void 0!==e.subscriptions[r].onMessage){var i={time:o.t,channel:o.n,content:o.c};o.s&&(i.senderId=o.s),e.subscriptions[r].onMessage(i)}}})),this.socket.on("connect",(function(){function n(){JSON.stringify(r),e._isEmpty(r.artifactVersion)&&e.sendlogs(),e.socket.emit("authorize",r,(function(n){if(JSON.stringify(n),!i)if(i=!0,e.authorizeStatus="authorized",e._manualDisconnectStatus="initial",null==e.authorizeResult&&(e.authorizeResult={}),e.authorizeResult.code=n.resultCode,e.authorizeResult.content=n.content,200==n.resultCode){if(o(),null==e.authorizeResult.sid)e.authorizeResult.sid=n.sid;else if(e.authorizeResult.sid!=n.sid)for(var r in e.authorizeResult.sid=n.sid,e.subscriptions)e.subscriptions.hasOwnProperty(r)&&(JSON.stringify(e.subscriptions[r]),e.doSubscribeAndCheckAck(e.subscriptions[r]));for(var s in e.subscribeBuffer)e.subscribeBuffer.hasOwnProperty(s)&&(JSON.stringify(e.subscribeBuffer[s]),e.doSubscribeAndCheckAck(e.subscribeBuffer[s]));void 0!==t.onConnected&&t.onConnected()}else void 0!==t.onConnectFailed&&t.onConnectFailed({code:n.resultCode,content:n.content})}))}if("disconnecting"!==e._manualDisconnectStatus&&"disconnected"!==e._manualDisconnectStatus||e._manualConnect){e.authorizeStatus="authorizing",e.networkStatus="connected";var r={appkey:e._appkey,userId:e._userId,userData:e._userData,otp:e._otp,artifactVersion:"1.0.17",type:e.type};null!=e.authorizeResult&&(r.sid=e.authorizeResult.sid);var i=!1;n();var s=setInterval((function(){i||"connected"!=e.networkStatus?clearInterval(s):n()}),1300)}})),this.socket.on("connect_error",(function(e){void 0!==t.onConnectFailed&&t.onConnectFailed({code:408,content:e})})),this.socket.on("disconnect",(function(){e.networkStatus="disconnected",e.authorizeStatus="initial",e._manualConnect=!1,null==e.authorizeResult&&(e.authorizeResult={}),e.authorizeResult.code=408,e.authorizeResult.content="Server unreachable or timeout",void 0!==t.onDisconnected&&t.onDisconnected()}))},_isEmpty:function(t){return void 0===t||null==t||0==this._trim(t).length},_trim:function(t){return t.replace(/(^\s*)|(\s*$)/g,"")},_endWith:function(t,e){return new RegExp(e+"$").test(t)},_isArray:function(t){return"[object Array]"==Object.prototype.toString.call(t)},log:function(t){"undefined"!=typeof window&&window.console&&this.debug&&console.log(t)},uuid_goeasy:function(){return s().replace(/-/g,"")},sendlogs:function(){}};var m=function(){var t;return function(e){return t&&!t.disconnected()||(t=new v(e)),t}}();t.exports=m},function(t,e,n){"use strict";function o(t,e){"object"===(void 0===t?"undefined":r(t))&&(e=t,t=void 0),e=e||{};var n,o=i(t),s=o.source,u=o.id,f=o.path,l=a[u]&&f in a[u].nsps;return e.forceNew||e["force new connection"]||!1===e.multiplex||l?n=c(s,e):(a[u]||(a[u]=c(s,e)),n=a[u]),o.query&&!e.query&&(e.query=o.query),n.socket(o.path,e)}var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=n(2),s=n(5),c=n(8);n(4)("socket.io-client"),t.exports=e=o;var a=e.managers={};e.protocol=s.protocol,e.connect=o,e.Manager=n(8),e.Socket=n(30)},function(t,e,n){"use strict";var o=n(3);n(4)("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=o(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 r=-1!==n.host.indexOf(":")?"["+n.host+"]":n.host;return n.id=n.protocol+"://"+r+":"+n.port,n.href=n.protocol+"://"+r+(e&&e.port===n.port?"":":"+n.port),n}},function(t,e){var n=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,o=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,r=t.indexOf("["),i=t.indexOf("]");-1!=r&&-1!=i&&(t=t.substring(0,r)+t.substring(r,i).replace(/:/g,";")+t.substring(i,t.length));for(var s=n.exec(t||""),c={},a=14;a--;)c[o[a]]=s[a]||"";return-1!=r&&-1!=i&&(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){"use strict";t.exports=function(){return function(){}}},function(t,e,n){"use strict";function o(){}function r(t){var n=""+t.type;if(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),null!=t.data){var o=function(t){try{return JSON.stringify(t)}catch(t){return!1}}(t.data);if(!1===o)return l;n+=o}return n}function i(){this.reconstructor=null}function s(t){var n=0,o={type:Number(t.charAt(0))};if(null==e.types[o.type])return a("unknown packet type "+o.type);if(e.BINARY_EVENT===o.type||e.BINARY_ACK===o.type){for(var r="";"-"!==t.charAt(++n)&&(r+=t.charAt(n),n!=t.length););if(r!=Number(r)||"-"!==t.charAt(n))throw new Error("Illegal attachments");o.attachments=Number(r)}if("/"===t.charAt(n+1))for(o.nsp="";++n&&","!==(s=t.charAt(n))&&(o.nsp+=s,n!==t.length););else o.nsp="/";var i=t.charAt(n+1);if(""!==i&&Number(i)==i){for(o.id="";++n;){var s;if(null==(s=t.charAt(n))||Number(s)!=s){--n;break}if(o.id+=t.charAt(n),n===t.length)break}o.id=Number(o.id)}if(t.charAt(++n)){var c=function(t){try{return JSON.parse(t)}catch(t){return!1}}(t.substr(n));if(!1===c||o.type!==e.ERROR&&!f(c))return a("invalid payload");o.data=c}return o}function c(t){this.reconPack=t,this.buffers=[]}function a(t){return{type:e.ERROR,data:"parser error: "+t}}var u=(n(4)("socket.io-parser"),n(6)),f=n(7);e.protocol=4,e.types=["CONNECT","DISCONNECT","EVENT","ACK","ERROR","BINARY_EVENT","BINARY_ACK"],e.CONNECT=0,e.DISCONNECT=1,e.EVENT=2,e.ACK=3,e.ERROR=4,e.BINARY_EVENT=5,e.BINARY_ACK=6,e.Encoder=o,e.Decoder=i;var l=e.ERROR+'"encode error"';o.prototype.encode=function(t,e){e([r(t)])},u(i.prototype),i.prototype.add=function(t){var e;if("string"!=typeof t)throw new Error("Unknown type: "+t);e=s(t),this.emit("decoded",e)},i.prototype.destroy=function(){this.reconstructor&&this.reconstructor.finishedReconstruction()},c.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},c.prototype.finishedReconstruction=function(){this.reconPack=null,this.buffers=[]}},function(t,e,n){function o(t){if(t)return function(t){for(var e in o.prototype)t[e]=o.prototype[e];return t}(t)}t.exports=o,o.prototype.on=o.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},o.prototype.once=function(t,e){function n(){this.off(t,n),e.apply(this,arguments)}return n.fn=e,this.on(t,n),this},o.prototype.off=o.prototype.removeListener=o.prototype.removeAllListeners=o.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var o,r=0;r0&&!this.encoding){var t=this.packetBuffer.shift();this.packet(t)}},o.prototype.cleanup=function(){for(var t=this.subs.length,e=0;e=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(){t.skipReconnect||(t.emitAll("reconnect_attempt",t.backoff.attempts),t.emitAll("reconnecting",t.backoff.attempts),t.skipReconnect||(function(){var t=!1;return"object"===("undefined"==typeof uni?"undefined":r(uni))&&uni.getSystemInfo&&(t=!0),t&&!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)}})}},o.prototype.onreconnect=function(){var t=this.backoff.attempts;this.reconnecting=!1,this.backoff.reset(),this.updateSocketIds(),this.emitAll("reconnect",t)}},function(t,e,n){"use strict";t.exports=n(10),t.exports.parser=n(15)},function(t,e,n){"use strict";function o(t,e){return this instanceof o?(e=e||{},t&&"object"===(void 0===t?"undefined":r(t))&&(e=t,t=null),t?(t=u(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=u(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=f.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,void this.open()):new o(t,e)}var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=n(11),s=n(6),c=(n(4)("engine.io-client:socket"),n(29)),a=n(15),u=n(3),f=n(22);t.exports=o,o.priorWebsocketSuccess=!1,s(o.prototype),o.protocol=a.protocol,o.Socket=o,o.Transport=n(14),o.transports=n(11),o.parser=n(15),o.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=a.protocol,e.transport=t;var n=this.transportOptions[t]||{};return this.id&&(e.sid=this.id),new i[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})},o.prototype.open=function(){var t;if(this.rememberUpgrade&&o.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)},o.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")}))},o.prototype.probe=function(t){function e(){if(l.onlyBinaryUpgrades){var t=!this.supportsBinary&&l.transport.supportsBinary;f=f||t}f||(u.send([{type:"ping",data:"probe"}]),u.once("packet",(function(t){if(!f)if("pong"===t.type&&"probe"===t.data){if(l.upgrading=!0,l.emit("upgrading",u),!u)return;o.priorWebsocketSuccess="websocket"===u.name,l.transport.pause((function(){f||"closed"!==l.readyState&&(a(),l.setTransport(u),u.send([{type:"upgrade"}]),l.emit("upgrade",u),u=null,l.upgrading=!1,l.flush())}))}else{var e=new Error("probe error");e.transport=u.name,l.emit("upgradeError",e)}})))}function n(){f||(f=!0,a(),u.close(),u=null)}function r(t){var e=new Error("probe error: "+t);e.transport=u.name,n(),l.emit("upgradeError",e)}function i(){r("transport closed")}function s(){r("socket closed")}function c(t){u&&t.name!==u.name&&n()}function a(){u.removeListener("open",e),u.removeListener("error",r),u.removeListener("close",i),l.removeListener("close",s),l.removeListener("upgrading",c)}var u=this.createTransport(t,{probe:1}),f=!1,l=this;o.priorWebsocketSuccess=!1,u.once("open",e),u.once("error",r),u.once("close",i),this.once("close",s),this.once("upgrading",c),u.open()},o.prototype.onOpen=function(){if(this.readyState="open",o.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';i=document.createElement(t)}catch(t){(i=document.createElement("iframe")).name=r.iframeId,i.src="javascript:0"}i.id=r.iframeId,r.form.appendChild(i),r.iframe=i}var r=this;if(!this.form){var i,s=document.createElement("form"),c=document.createElement("textarea"),a=this.iframeId="eio_iframe_"+this.index;s.className="socketio",s.style.position="absolute",s.style.top="-1000px",s.style.left="-1000px",s.target=a,s.method="POST",s.setAttribute("accept-charset","utf-8"),c.name="d",s.appendChild(c),document.body.appendChild(s),this.form=s,this.area=c}this.form.action=this.uri(),o(),t=t.replace(f,"\\\n"),this.area.value=t.replace(u,"\\n");try{this.form.submit()}catch(t){}this.iframe.attachEvent?this.iframe.onreadystatechange=function(){"complete"===r.iframe.readyState&&n()}:this.iframe.onload=n}}).call(e,function(){return this}())},function(t,e,n){"use strict";function o(t){var e=t&&t.forceBase64;u&&!e||(this.supportsBinary=!1),r.call(this,t)}var r=n(14),i=n(22),s=n(15),c=n(23),a=n(24);n(4)("engine.io-client:polling"),t.exports=o;var u=null!=new(n(25))({xdomain:!1}).responseType;c(o,r),o.prototype.name="polling",o.prototype.doOpen=function(){this.poll()},o.prototype.pause=function(t){function e(){n.readyState="paused",t()}var n=this;if(this.readyState="pausing",this.polling||!this.writable){var o=0;this.polling&&(o++,this.once("pollComplete",(function(){--o||e()}))),this.writable||(o++,this.once("drain",(function(){--o||e()})))}else e()},o.prototype.poll=function(){this.polling=!0,this.doPoll(),this.emit("poll")},o.prototype.onData=function(t){var e=this;s.decodePayload(t,this.socket.binaryType,(function(t,n,o){return"opening"===e.readyState&&e.onOpen(),"close"===t.type?(e.onClose(),!1):void e.onPacket(t)})),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState&&this.poll())},o.prototype.doClose=function(){function t(){e.write([{type:"close"}])}var e=this;"open"===this.readyState?t():this.once("open",t)},o.prototype.write=function(t){var e=this;this.writable=!1;var n=function(){e.writable=!0,e.emit("drain")};s.encodePayload(t,this.supportsBinary,(function(t){e.doWrite(t,n)}))},o.prototype.uri=function(){var t=this.query||{},e=this.secure?"https":"http",n="";return!1!==this.timestampRequests&&(t[this.timestampParam]=a()),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,n){"use strict";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}var r=n(15),i=n(6);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,n){"use strict";function o(t,e,n){for(var o=new Array(t.length),r=s(t.length,n),i=function(t,n,r){e(n,(function(e,n){o[t]=n,r(e,o)}))},c=0;c1?{type:u[o],data:t.substring(1)}:{type:u[o]}:f}o=new Uint8Array(t)[0];var r=sliceBuffer(t,1);return l&&"blob"===e&&(r=new l([r])),{type:u[o],data:r}},e.encodePayload=function(t,n,r){"function"==typeof n&&(r=n,n=null);var s=i(t);return t.length?void o(t,(function(t,o){e.encodePacket(t,!!s&&n,!0,(function(t){o(null,function(t){return t.length+":"+t}(t))}))}),(function(t,e){return r(e.join(""))})):r("0:")},e.decodePayload=function(t,n,o){var r;if("function"==typeof n&&(o=n,n=null),""===t)return o(f,0,1);for(var i,s,c="",a=0,u=t.length;a=55296&&e<=56319&&r=55296&&t<=57343){if(e)throw Error("Lone surrogate U+"+t.toString(16).toUpperCase()+" is not a scalar value");return!1}return!0}function r(t,e){return l(t>>e&63|128)}function i(t,e){if(0==(4294967168&t))return l(t);var n="";return 0==(4294965248&t)?n=l(t>>6&31|192):0==(4294901760&t)?(o(t,e)||(t=65533),n=l(t>>12&15|224),n+=r(t,6)):0==(4292870144&t)&&(n=l(t>>18&7|240),n+=r(t,12),n+=r(t,6)),n+l(63&t|128)}function s(){if(f>=u)throw Error("Invalid byte index");var t=255&a[f];if(f++,128==(192&t))return 63&t;throw Error("Invalid continuation byte")}function c(t){var e,n;if(f>u)throw Error("Invalid byte index");if(f==u)return!1;if(e=255&a[f],f++,0==(128&e))return e;if(192==(224&e)){if((n=(31&e)<<6|s())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&e)){if((n=(15&e)<<12|s()<<6|s())>=2048)return o(n,t)?n:65533;throw Error("Invalid continuation byte")}if(240==(248&e)&&(n=(7&e)<<18|s()<<12|s()<<6|s())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}/*! https://mths.be/utf8js v2.1.2 by @mathias */ var a,u,f,l=String.fromCharCode;t.exports={version:"2.1.2",encode:function(t,e){for(var o=!1!==(e=e||{}).strict,r=n(t),s=r.length,c=-1,a="";++c65535&&(r+=l((e-=65536)>>>10&1023|55296),e=56320|1023&e),r+=l(e);return r}(i)}}},function(t,e){function n(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 o(t,e){e=e||{};var o=new i;return n(t).forEach((function(t){o.append(t)})),e.type?o.getBlob(e.type):o.getBlob()}function r(t,e){return new Blob(n(t),e||{})}var i=void 0!==i?i:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:"undefined"!=typeof MSBlobBuilder?MSBlobBuilder:"undefined"!=typeof MozBlobBuilder&&MozBlobBuilder,s=function(){try{return 2===new Blob(["hi"]).size}catch(t){return!1}}(),c=s&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(t){return!1}}(),a=i&&i.prototype.append&&i.prototype.getBlob;"undefined"!=typeof Blob&&(o.prototype=Blob.prototype,r.prototype=Blob.prototype),t.exports=s?c?Blob:r:a?o:void 0},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("&"),o=0,r=n.length;o0);return e}function o(){var t=n(+new Date);return t!==r?(a=0,r=t):t+"."+n(a++)}for(var r,i="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),s=64,c={},a=0,u=0;u0&&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){var o,r,i=n(36),s=n(37),c=0,a=0;t.exports=function(t,e,n){var u=e&&n||0,f=e||[],l=(t=t||{}).node||o,p=void 0!==t.clockseq?t.clockseq:r;if(null==l||null==p){var h=i();null==l&&(l=o=[1|h[0],h[1],h[2],h[3],h[4],h[5]]),null==p&&(p=r=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,r=p;var m=(1e4*(268435455&(d+=122192928e5))+y)%4294967296;f[u++]=m>>>24&255,f[u++]=m>>>16&255,f[u++]=m>>>8&255,f[u++]=255&m;var g=d/4294967296*1e4&268435455;f[u++]=g>>>8&255,f[u++]=255&g,f[u++]=g>>>24&15|16,f[u++]=g>>>16&255,f[u++]=p>>>8|128,f[u++]=255&p;for(var b=0;b<6;++b)f[u+b]=l[b];return e||s(f)}},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 o=new Uint8Array(16);t.exports=function(){return n(o),o}}else{var r=new Array(16);t.exports=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),r[e]=t>>>((3&e)<<3)&255;return r}}},function(t,e){for(var n=[],o=0;o<256;++o)n[o]=(o+256).toString(16).substr(1);t.exports=function(t,e){var o=e||0,r=n;return[r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],"-",r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]],r[t[o++]]].join("")}}])},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){function n(e,o){return t.exports=n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},n(e,o)}t.exports=n},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,n){var o=n(0);t.exports=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=o(t)););return t}},function(t,e,n){"use strict";n.r(e);var o=n(6),r=n.n(o);function i(t){return"string"==typeof t||"number"==typeof t||"symbol"===r()(t)||"boolean"==typeof t}function s(t){return null!=t}function c(t){return null!==t&&"object"===r()(t)}function a(t){return"string"==typeof t||"number"==typeof t}function u(t){return"string"==typeof t}function f(t){return"number"==typeof t}function l(t){return Array.isArray(t)?0==t.length:c(t)?!s(t):!f(t)&&(u(t)?""==t.trim():void 0)}var p,h="undefined"!=typeof window&&window.navigator.userAgent.toLowerCase(),d=(h&&/msie|trident/.test(h),h&&h.indexOf("msie 9.0"),h&&h.indexOf("edge/")>0),y=(h&&/chrome\/\d+/.test(h),h&&h.match(/firefox\/(\d+)/),"undefined"!=typeof Promise&&("function"==typeof(p=Promise)&&/native code/.test(p.toString())));function v(t){if(!y)return null;var e,n=new Promise(t);return s(e=n)&&"function"==typeof e.then&&"function"==typeof e.catch?n:void 0}function m(t,e){if(u(t))try{var n=t.split(e);return n[n.length-1]}catch(t){throw Error(t)}}var g=n(1),b=n.n(g),k=n(2),w=n.n(k),S=n(7),E=n.n(S),R={PRIVATE_MESSAGE_RECEIVED:"PRIVATE_MESSAGE_RECEIVED",GROUP_MESSAGE_RECEIVED:"GROUP_MESSAGE_RECEIVED",SYSTEM_MESSAGE_RECEIVED:"SYSTEM_MESSAGE_RECEIVED",CONNECTED:"CONNECTED",DISCONNECTED:"DISCONNECTED",USER_PRESENCE:"USER_PRESENCE",GROUP_PRESENCE:"GROUP_PRESENCE"};function x(t,e){t.socket.on("imMessage",(function(n){var o=null;if("string"==typeof n&&(o=JSON.parse(n)),!t.receivedGuids.unshiftGuid(o.i)){o.a&&t.socket.emit("imAck",{publishGuid:o.i});var r="";r="private"==o.t?R.PRIVATE_MESSAGE_RECEIVED:"group"==o.t?R.GROUP_MESSAGE_RECEIVED:R.SYSTEM_MESSAGE_RECEIVED,e._events[r]&&e._events[r](function(t){if(!s(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,"group"==t.t?e.groupId=t.r:e.receiverId=t.r,e}catch(t){return t}}(o))}}))}var P=function(){function t(){b()(this,t)}return w()(t,null,[{key:"validateGoEasy",value:function(){if(!s(E.a))throw Error("please call connect() first.")}},{key:"connect",value:function(t,e,n){this.validateGoEasy();var o=this;this._goEasy=new E.a({appkey:t.appkey,host:t.host,userId:t.user.id,otp:t.user.otp,type:t.type,userData:JSON.stringify(t.user.data),onConnected:function(){var n,r;x(o._goEasy,t.im),n=t.im,r=R.CONNECTED,n._events[r]&&n._events[r](),o._userId=t.user.id,e()},onDisconnected:function(){var e,o;e=t.im,o=R.DISCONNECTED,e._events[o]&&e._events[o](),n({code:400,content:"GoEasy disconnected."})},onConnectFailed:function(t){n(t||{code:408,content:"Failed to connect GoEasy"})}})}},{key:"disconnect",value:function(t,e){try{this._goEasy.disconnect(),t()}catch(t){e(t||{code:408,content:"disconnect failed"})}}},{key:"sendPrivateMessage",value:function(t){var e=this;return new Promise((function(n,o){e.validateGoEasy(),e._goEasy.tryEmit("publishIM",t,(function(){o({code:408,content:"Failed to send private message."})}),(function(t){200==t.resultCode?n(t):o(t)}))}))}},{key:"hereNow",value:function(t,e,n){this.validateGoEasy(),this._goEasy.tryEmit("imHereNow",t,(function(t){n(t||{code:408,content:"Failed to query online users"})}),(function(t){200==t.code?e(t):n(t)}))}},{key:"subscribePresence",value:function(t,e,n){this.validateGoEasy(),this._goEasy.subscribePresence({channels:t.channels,onPresence:function(e){var n,o;"private"==t.type?(n=t.im,(o=e)&&o.events&&o.events.map((function(t){var e=R.USER_PRESENCE;n._events[e]&&n._events[e](t)}))):function(t,e){e&&e.events&&e.events.map((function(n){var o=R.GROUP_PRESENCE;n.groupOnlineCount=e.userAmount,n.groupId=e.channel,t._events[o]&&t._events[o](n)}))}(t.im,e)},onSuccess:function(){e()},onFailed:function(t){n(t||{code:408,content:"Failed to subscribe user presence"})}})}},{key:"unsubscribePresence",value:function(t,e,n){this.validateGoEasy(),this._goEasy.unsubscribePresence({channel:t,onSuccess:function(){e()},onFailed:function(t){n(t||{code:408,content:"Failed to unsubscribe user presence"})}})}},{key:"subscribeGroup",value:function(t,e,n){this.validateGoEasy(),this._goEasy.subscribe({channels:t.channels,onMessage:function(t){},onSuccess:function(){e()},onFailed:function(t){n(t||{code:408,content:"Failed to subscribe group message"})}})}},{key:"unSubscribeGroup",value:function(t,e,n){this.validateGoEasy(),this._goEasy.unsubscribe({channel:t.channel,onSuccess:function(){e()},onFailed:function(t){n(t||{code:408,content:"Failed to unsubscribe group message"})}})}},{key:"groupHereNow",value:function(t,e,n){this.validateGoEasy(),this._goEasy.tryEmit("imGroupHereNow",{groupId:t},(function(t){n(t||{code:408,content:"Failed to query online group users"})}),(function(t){200==t.code?e(t):n(t)}))}},{key:"groupOnlineCount",value:function(t,e,n){this.validateGoEasy(),this._goEasy.tryEmit("imGroupOnlineCount",{groupId:t},(function(t){n(t||{code:408,content:"Failed to query online group users"})}),(function(t){200==t.code?e(t):n(t)}))}},{key:"historyMessage",value:function(t,e,n){this.validateGoEasy(),this._goEasy.tryEmit("imHistory",t,(function(t){n(t||{code:408,content:"Failed to query message"})}),(function(t){if(200==t.code){var o=[];t&&t.content&&t.content.map((function(t){var e=Object.create(null);e.timestamp=t.ts,e.senderId=t.s,e.type=t.mt,e.payload=JSON.parse(t.p),o.push(e)})),e({code:t.code,content:o})}else n(t)}))}}]),t}();P._goEasy=null,P._userId=null;var I=P,_=n(3),O=n.n(_),N=n(4),C=n.n(N),A=n(0),D=n.n(A),T=n(8),M=n.n(T);function B(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function j(t){for(var e=1;e=200&&e.status<300||304==e.status?t.success({code:e.status,content:e.responseText}):t.error({code:e.status,content:e.responseText}))}}},{key:"buildParameters",value:function(t,e,n){var o=new FormData,r={key:t.dir+"/"+e,OSSAccessKeyId:t.accessKeyId,policy:t.policy,signature:t.signature,success_action_status:"200",file:n};for(var i in r)o.append(i,r[i]);return o}}]),n}(q));function J(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var W=new(function(t){O()(n,t);var e=J(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"doPost",value:function(t){uni.uploadFile({url:t.url,filePath:this.getTempFilePath(t.params.fileRes),name:"file",formData:t.params,success:function(e){console.log(e),200===e.statusCode?t.success&&t.success({code:200,content:e.errMsg}):t.error&&t.error({code:e.statusCode,content:e.errMsg})},fail:function(e){t.error&&t.error({code:500,content:e.errMsg})}}).onProgressUpdate((function(e){t.onprogress&&t.onprogress(e)}))}},{key:"getTempFilePath",value:function(t){return Array.isArray(t.tempFiles)?t.tempFiles[0].path:t.tempFilePath}},{key:"buildParameters",value:function(t,e,n){return{key:t.dir+"/"+e,OSSAccessKeyId:t.accessKeyId,policy:t.policy,signature:t.signature,success_action_status:"200",fileRes:n}}}]),n}(q)),V=function(){function t(){b()(this,t)}return w()(t,null,[{key:"resolve",value:function(){return function(){try{return!!(s(uni)&&c(uni)&&uni.getSystemInfo)}catch(t){return!1}}()?"uniApp":function(){try{return!!(s(wx)&&c(wx)&&wx.getLocation)&&("function"!=typeof WebSocket||"function"!=typeof XMLHttpRequest)}catch(t){return!1}}()?"wx":"html"}}]),t}(),K=new(function(){function t(){b()(this,t),this.uploader={wx:G,uniApp:W,html:H}}return w()(t,[{key:"dispatch",value:function(){var t=V.resolve();return this.uploader[t]}}]),t}()),X=n(5),$=n.n(X),Y=function(){function t(){b()(this,t)}return w()(t,[{key:"send",value:function(t,e){var n=this;return new Promise((function(o,r){try{n.validateTo(t),n.validateMessage(e),n.buildBulletMessage(t,e).then((function(t){o(n.doSend(t))})).catch((function(t){r(t)}))}catch(t){r(t)}}))}},{key:"validateMessage",value:function(t){if(!(t instanceof Z))throw Error("createMessage first.")}},{key:"validateTo",value:function(t){if(l(t))throw Error("userId is empty.");if(!a(t))throw Error("userId should be a string or number.");if(I._userId==t)throw Error("userId can not be the same as your id.")}},{key:"buildBulletMessage",value:function(t,e){return new Promise((function(n,o){try{var r=Object.create(null);r.mt=e.type,r.to=t,r.p=JSON.stringify(e.payload),r.t=e.sendType,r.guid=e.messageId,n(r)}catch(t){o(t)}}))}},{key:"doSend",value:function(t){return new Promise((function(e,n){try{e(I.sendPrivateMessage(t))}catch(t){n(t)}}))}}]),t}(),Q=new Y,Z=function(){function t(e){b()(this,t),this.type="",this.sender=null,this.timestamp=null,this.senderId=null,this.payload=null,this.messageId=null,this.validate(e),this.setType(),this.setPayload(e),this.setSender(),this.setSenderId(),this.setMessageId()}return w()(t,[{key:"validate",value:function(t){if(!c(t))throw Error("it is an empty message.")}},{key:"setType",value:function(){this.type="message"}},{key:"setPayload",value:function(t){this.payload=Object.create(null)}},{key:"setSender",value:function(){this.sender=Q}},{key:"setSenderId",value:function(){if(!I._userId)throw Error("please call connect() first.");this.senderId=I._userId}},{key:"setMessageId",value:function(){if(!I._goEasy)throw Error("please call connect() first.");this.messageId=I._goEasy.uuid_goeasy()}}]),t}();function tt(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var et=function(t){O()(n,t);var e=tt(n);function n(){return b()(this,n),e.call(this)}return w()(n,[{key:"buildBulletMessage",value:function(t,e){var o=this,r=$()(D()(n.prototype),"buildBulletMessage",this).call(this,t,e);return new Promise((function(t,n){o.upload(e).then((function(i){var s=o.buildPayload(e,i);r.then((function(e){e.p=JSON.stringify(s),t(e)})).catch((function(t){n(t)}))})).catch((function(t){n(t)}))}))}},{key:"buildPayload",value:function(t,e){var n=e.content,o=void 0===n?{}:n,r=t.payload,i=void 0===r?{}:r;return i.url=o.url,i.name=e.content.newFileName,i}},{key:"upload",value:function(t){return K.dispatch().upload(t)}}]),n}(Y),nt=new et,ot={default:"default",text:"text",image:"image",video:"video",audio:"audio",emoji:"emoji",file:"file",customized:"customized"};function rt(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var it=function(t){O()(n,t);var e=rt(n);function n(t){var o;return b()(this,n),(o=e.call(this,t)).file=null,o.onProgress=null,o.setFile(t.file),o.setOnProgress(t.onProgress),o}return w()(n,[{key:"validate",value:function(t){$()(D()(n.prototype),"validate",this).call(this,t)}},{key:"setPayload",value:function(t){$()(D()(n.prototype),"setPayload",this).call(this,t),this.payload.size="",this.payload.contentType="",this.payload.name="",this.payload.url=""}},{key:"setType",value:function(){this.type=ot.file}},{key:"setFile",value:function(t){this.file=t}},{key:"setSender",value:function(){this.sender=nt}},{key:"setOnProgress",value:function(t){this.onProgress=t}}]),n}(Z);function st(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var ct=function(t){O()(n,t);var e=st(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){if($()(D()(n.prototype),"validate",this).call(this,t),!s(t.file))throw Error("file is empty.")}},{key:"setPayload",value:function(t){$()(D()(n.prototype),"setPayload",this).call(this,t)}}]),n}(it);function at(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var ut=function(t){O()(n,t);var e=at(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){if($()(D()(n.prototype),"validate",this).call(this,t),!s(t.file.tempFiles)||0==t.file.tempFiles[0].length)throw Error("tempFiles is empty.")}},{key:"setType",value:function(){this.type=ot.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){$()(D()(n.prototype),"setPayload",this).call(this,t);var e=this,o=t.file.tempFiles[0],r="chooseMedia:ok"==t.file.errMsg?o.tempFilePath:o.path;this.payload.url=r,this.payload.size=o.size,this.payload.width="",this.payload.height="",this.payload.contentType="";var i=l(o.name)||null==o.name?r:o.name;this.payload.name="wx-image."+m(i,"."),this.payload.contentType="image/"+m(i,"."),wx.getImageInfo({src:r,success:function(t){e.payload.width=t.width,e.payload.height=t.height}})}}]),n}(ct);function ft(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var lt=function(t){O()(n,t);var e=ft(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){$()(D()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(){this.type=ot.audio}},{key:"setPayload",value:function(t){$()(D()(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 o=l(t.file.name)||null==t.file.name?e:t.file.name;this.payload.contentType="audio/"+m(o,"."),this.payload.name="wx-audio."+m(o,".")}}]),n}(ct);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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var ht=new(function(t){O()(n,t);var e=pt(n);function n(){return b()(this,n),e.call(this)}return w()(n,[{key:"buildPayload",value:function(t,e){var n=t.payload,o=void 0===n?{}:n,r="?x-oss-process=video/snapshot,t_0000,f_jpg,w_"+t.payload.video.width+",m_fast";return o.video.url=e.content.url,o.thumbnail.url=e.content.url+r,o.video.name=e.content.newFileName,o}}]),n}(et));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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var yt=function(t){O()(n,t);var e=dt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){$()(D()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(){this.type=ot.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),o="chooseMedia:ok"==t.file.errMsg?t.file.tempFiles[0]:t.file,r=o.duration,i=o.height,s=o.size,c=o.tempFilePath,a=o.thumbTempFilePath,u=o.width,f=o.name,p=void 0===f?"":f,h=l(p)?c:p;e.contentType="video/"+m(h,"."),e.name="wx-video."+m(h,"."),e.url=c,e.width=n.width=u,e.height=n.height=i,e.size=s,e.duration=r,n.url=a,n.contentType="image/jpg",n.name="wx-thumbnail.jpg",this.payload.video=e,this.payload.thumbnail=n}},{key:"setSender",value:function(){this.sender=ht}}]),n}(ct);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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var mt=function(t){O()(n,t);var e=vt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){if($()(D()(n.prototype),"validate",this).call(this,t),!s(t.file))throw Error("file is empty.")}},{key:"setPayload",value:function(t){$()(D()(n.prototype),"setPayload",this).call(this,t)}}]),n}(it);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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var bt=function(t){O()(n,t);var e=gt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){$()(D()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(){this.type=ot.audio}},{key:"setPayload",value:function(t){var e=this;$()(D()(n.prototype),"setPayload",this).call(this,t);var o=this,r=t.file.tempFilePath;this.payload.url=r;var i=l(t.file.name)||null==t.file.name?r:t.file.name;if(this.payload.contentType="audio/"+m(i,"."),this.payload.name="uni-audio."+m(i,"."),s(t.file.duration))this.payload.duration=t.file.duration/1e3;else{var c=uni.createInnerAudioContext();c.src=r,c.onCanplay((function(t){o.payload.duration=c.duration,c.destroy()}))}uni.getFileInfo({filePath:r,success:function(t){e.payload.size=t.size}})}}]),n}(mt);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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var wt=function(t){O()(n,t);var e=kt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){$()(D()(n.prototype),"validate",this).call(this,t)}},{key:"setType",value:function(){this.type=ot.video}},{key:"setPayload",value:function(t){var e=Object.create(null),n=Object.create(null);this.payload=Object.create(null);var o=t.file,r=o.duration,i=o.height,s=o.size,c=o.tempFilePath,a=o.width,u=o.name,f=void 0===u?"":u,p=l(f)?c:f;e.contentType="video/"+m(p,"."),e.name="uni-video."+m(p,"."),e.size=s,e.duration=r,e.url=n.url=c,e.width=n.width=a,e.height=n.height=i,n.contentType="image/jpg",n.name="wx-thumbnail.jpg",this.payload.video=e,this.payload.thumbnail=n}},{key:"setSender",value:function(){this.sender=ht}}]),n}(mt);function St(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var Et=function(t){O()(n,t);var e=St(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){if($()(D()(n.prototype),"validate",this).call(this,t),!s(t.file.tempFiles)||0==t.file.tempFiles[0].length)throw Error("tempFiles is empty.")}},{key:"setType",value:function(){this.type=ot.image}},{key:"setPayload",value:function(t){$()(D()(n.prototype),"setPayload",this).call(this,t);var e=this,o=t.file.tempFiles[0];this.payload.url=o.path,this.payload.size=o.size,this.payload.width="",this.payload.height="";var r=l(o.name)||null==o.name?o.path:o.name;this.payload.contentType="image/"+m(r,"."),this.payload.name="uni-iamge."+m(r,"."),uni.getImageInfo({src:o.path,success:function(t){e.payload.width=t.width,e.payload.height=t.height}})}}]),n}(mt);function Rt(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var xt=function(t){O()(n,t);var e=Rt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){if($()(D()(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){$()(D()(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}(it);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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var It=function(t){O()(n,t);var e=Pt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){$()(D()(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]})))throw Error("Only "+e.join(",")+" is supported image.")}},{key:"setType",value:function(){this.type=ot.image}},{key:"setPayload",value:function(t){var e=this;$()(D()(n.prototype),"setPayload",this).call(this,t);var o=window.URL||window.webkitURL,r=new Image;r.src=o.createObjectURL(t.file),r.onload=function(){e.payload.width=r.width,e.payload.height=r.height,o.revokeObjectURL(r.src)}}}]),n}(xt);function _t(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var Ot=function(t){O()(n,t);var e=_t(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){$()(D()(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]})))throw Error("Only "+e.join(",")+" is supported audio.")}},{key:"setType",value:function(){this.type=ot.audio}},{key:"setPayload",value:function(t){$()(D()(n.prototype),"setPayload",this).call(this,t);var e=this,o=window.URL||window.webkitURL,r=document.createElement("audio");r.src=o.createObjectURL(t.file),r.onloadedmetadata=function(){e.payload.duration=r.duration,o.revokeObjectURL(r.src)}}}]),n}(xt);function Nt(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var Ct=function(t){O()(n,t);var e=Nt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){$()(D()(n.prototype),"validate",this).call(this,t);var e=["avi","mov","rmvb","rm","flv","mp4","3gp"];if(!e.find((function(e){return t.file.type.split("/")[1]})))throw Error("Only "+e.join(",")+" is supported video.")}},{key:"setType",value:function(){this.type=ot.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 o=this,r=window.URL||window.webkitURL,i=document.createElement("video"),s=r.createObjectURL(t.file);i.src=s,i.onloadedmetadata=function(){o.payload.video.duration=i.duration,o.payload.video.width=o.payload.thumbnail.width=i.videoWidth,o.payload.video.height=o.payload.thumbnail.height=i.videoHeight,o.payload.video.url=s,o.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")}(i),r.revokeObjectURL(i.src)}}},{key:"setSender",value:function(){this.sender=ht}}]),n}(xt);function At(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var Dt=new(function(t){O()(n,t);var e=At(n);function n(){return b()(this,n),e.call(this)}return w()(n,[{key:"validateMessage",value:function(t){if($()(D()(n.prototype),"validateMessage",this).call(this,t),!(t instanceof Bt))throw Error("it is not textMessage");if((c(t.payload)?JSON.stringify(t.payload).length:t.payload.length)>3072)throw Error("message-length limit 3kb")}}]),n}(Y));function Tt(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,o=D()(t);if(e){var r=D()(this).constructor;n=Reflect.construct(o,arguments,r)}else n=o.apply(this,arguments);return C()(this,n)}}var Mt,Bt=function(t){O()(n,t);var e=Tt(n);function n(t){return b()(this,n),e.call(this,t)}return w()(n,[{key:"validate",value:function(t){if(l(t.text)||""==t.text.trim())throw Error("text is empty")}},{key:"setType",value:function(){this.type=ot.text}},{key:"setPayload",value:function(t){$()(D()(n.prototype),"setPayload",this).call(this,t),this.payload.text=t.text}},{key:"setSender",value:function(){this.sender=Dt}}]),n}(Z),jt=new(function(){function t(){b()(this,t),this.messageTypes={wx:{image:ut,file:ct,audio:lt,video:yt,text:Bt},uniApp:{image:Et,file:mt,audio:bt,video:wt,text:Bt},html:{image:It,file:xt,audio:Ot,video:Ct,text:Bt}}}return w()(t,[{key:"create",value:function(t,e){var n=V.resolve();return new this.messageTypes[n][t](e)}}]),t}());function Ft(t,e){this._appKey=t,this._host=e}(Mt=Ft).prototype.connect=function(t){var e=this;return v((function(n,o){if(c(t))if(a(t.id))if(f(t.id)&&(t.id=t.id.toString()),t.data=s(t.data)?t.data:{},(c(t.data)?JSON.stringify(t.data).length:t.data.length)>300)o({code:400,content:"user.data-length limit 300."});else{var r={appkey:e._appKey,host:e._host,type:"im",im:e,user:t};I.connect(r,n,o)}else o({code:400,content:'The argument "user.id" should be a "number" or "string".'});else o({code:400,content:'The argument "user" should be an object.'})}))},Mt.prototype.disconnect=function(){return v((function(t,e){I.disconnect(t,e)}))},Mt.prototype.createTextMessage=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{text:""};return jt.create("text",t)},Mt.prototype.createImageMessage=function(t){return jt.create("image",t)},Mt.prototype.createFileMessage=function(t){return jt.create("file",t)},Mt.prototype.createAudioMessage=function(t){return jt.create("audio",t)},Mt.prototype.createVideoMessage=function(t){return jt.create("video",t)},Mt.prototype.history=function(t){return v((function(e,n){t.groupId||t.friendId?t.groupId&&t.friendId?n({code:400,content:"The argument can have only groupId or friendId"}):(s(t.groupId)&&f(t.groupId)&&(t.groupId=t.groupId.toString()),s(t.friendId)&&f(t.friendId)&&(t.friendId=t.friendId.toString()),s(t.limit)||(t.limit=10),t.limit>30&&(t.limit=30),I.historyMessage(t,e,n)):n({code:400,content:"The argument 'groupId' or 'friendId' required"})}))},Mt.prototype.sendSystemMessage=function(t,e){return v((function(){I.sendPrivateMessage(options)}))},Mt.prototype.upload=function(t,e){return K.dispatch().upload(t,e)},function(t){t.prototype.on=function(t,e){return!!u(t)&&(!!s(R[t])&&(this._events[t]=e,this))}}(Ft),function(t){t.prototype.sendPrivateMessage=function(t,e){return v((function(n,o){if(!(e instanceof Z))throw Error("createMessage first.");e.sendType="private",e.sender.send(t,e).then((function(t){n({code:t.resultCode||t.code,content:t.content})})).catch((function(t){c(t)&&t.code?o({code:t.code,content:t.content||t}):o({code:400,content:t})}))}))},t.prototype.subscribeUserPresence=function(t){var e=this;return v((function(n,o){if(!Array.isArray(t)||0==t.length)return o({code:400,content:"The argument 'userIds' should be an 'Array' [GoEasyIM.subscribeUserPresence]."}),!1;for(var r=0;r50)n({code:400,content:" The argument 'userIds' max size is 50 [GoEasyIM.hereNow]."});else{for(var o=0;o