@wu-xj/uni-socket.io
Version:
适用于uni-app的socket.io封装,可用于uni-app、微信小程序
8 lines • 74.9 kB
JavaScript
var uniSocketIo=function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=19)}([function(t,e){t.exports=function(){return function(){}}},function(t,e){t.exports="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")()},function(t,e,r){const n=r(26),s=r(27),o=String.fromCharCode(30);t.exports={protocol:4,encodePacket:n,encodePayload:(t,e)=>{const r=t.length,s=new Array(r);let i=0;t.forEach((t,a)=>{n(t,!1,t=>{s[a]=t,++i===r&&e(s.join(o))})})},decodePacket:s,decodePayload:(t,e)=>{const r=t.split(o),n=[];for(let t=0;t<r.length;t++){const o=s(r[t],e);if(n.push(o),"error"===o.type)break}return n}}},function(t,e,r){function n(t){if(t)return function(t){for(var e in n.prototype)t[e]=n.prototype[e];return t}(t)}t.exports=n,n.prototype.on=n.prototype.addEventListener=function(t,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+t]=this._callbacks["$"+t]||[]).push(e),this},n.prototype.once=function(t,e){function r(){this.off(t,r),e.apply(this,arguments)}return r.fn=e,this.on(t,r),this},n.prototype.off=n.prototype.removeListener=n.prototype.removeAllListeners=n.prototype.removeEventListener=function(t,e){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var r,n=this._callbacks["$"+t];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+t],this;for(var s=0;s<n.length;s++)if((r=n[s])===e||r.fn===e){n.splice(s,1);break}return 0===n.length&&delete this._callbacks["$"+t],this},n.prototype.emit=function(t){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),r=this._callbacks["$"+t],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(r){n=0;for(var s=(r=r.slice(0)).length;n<s;++n)r[n].apply(this,e)}return this},n.prototype.listeners=function(t){return this._callbacks=this._callbacks||{},this._callbacks["$"+t]||[]},n.prototype.hasListeners=function(t){return!!this.listeners(t).length}},function(t,e,r){const n=r(1);t.exports.pick=(t,...e)=>e.reduce((e,r)=>(t.hasOwnProperty(r)&&(e[r]=t[r]),e),{});const s=setTimeout,o=clearTimeout;t.exports.installTimerFunctions=(t,e)=>{e.useNativeTimers?(t.setTimeoutFn=s.bind(n),t.clearTimeoutFn=o.bind(n)):(t.setTimeoutFn=setTimeout.bind(n),t.clearTimeoutFn=clearTimeout.bind(n))}},function(t,e,r){const n=r(2),s=r(3),{installTimerFunctions:o}=r(4),i=r(0)("engine.io-client:transport");t.exports=class extends s{constructor(t){super(),o(this,t),this.opts=t,this.query=t.query,this.readyState="",this.socket=t.socket}onError(t,e){const r=new Error(t);return r.type="TransportError",r.description=e,this.emit("error",r),this}open(){return"closed"!==this.readyState&&""!==this.readyState||(this.readyState="opening",this.doOpen()),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(t){"open"===this.readyState?this.write(t):i("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,this.emit("open")}onData(t){const e=n.decodePacket(t,this.socket.binaryType);this.onPacket(e)}onPacket(t){this.emit("packet",t)}onClose(){this.readyState="closed",this.emit("close")}}},function(t,e){e.encode=function(t){var e="";for(var r in t)t.hasOwnProperty(r)&&(e.length&&(e+="&"),e+=encodeURIComponent(r)+"="+encodeURIComponent(t[r]));return e},e.decode=function(t){for(var e={},r=t.split("&"),n=0,s=r.length;n<s;n++){var o=r[n].split("=");e[decodeURIComponent(o[0])]=decodeURIComponent(o[1])}return e}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Decoder=e.Encoder=e.PacketType=e.protocol=void 0;const n=r(3),s=r(40),o=r(16),i=r(0)("socket.io-parser");var a;e.protocol=5,function(t){t[t.CONNECT=0]="CONNECT",t[t.DISCONNECT=1]="DISCONNECT",t[t.EVENT=2]="EVENT",t[t.ACK=3]="ACK",t[t.CONNECT_ERROR=4]="CONNECT_ERROR",t[t.BINARY_EVENT=5]="BINARY_EVENT",t[t.BINARY_ACK=6]="BINARY_ACK"}(a=e.PacketType||(e.PacketType={}));e.Encoder=class{encode(t){return i("encoding packet %j",t),t.type!==a.EVENT&&t.type!==a.ACK||!o.hasBinary(t)?[this.encodeAsString(t)]:(t.type=t.type===a.EVENT?a.BINARY_EVENT:a.BINARY_ACK,this.encodeAsBinary(t))}encodeAsString(t){let e=""+t.type;return t.type!==a.BINARY_EVENT&&t.type!==a.BINARY_ACK||(e+=t.attachments+"-"),t.nsp&&"/"!==t.nsp&&(e+=t.nsp+","),null!=t.id&&(e+=t.id),null!=t.data&&(e+=JSON.stringify(t.data)),i("encoded %j as %s",t,e),e}encodeAsBinary(t){const e=s.deconstructPacket(t),r=this.encodeAsString(e.packet),n=e.buffers;return n.unshift(r),n}};class c extends n{constructor(){super()}add(t){let e;if("string"==typeof t)e=this.decodeString(t),e.type===a.BINARY_EVENT||e.type===a.BINARY_ACK?(this.reconstructor=new h(e),0===e.attachments&&super.emit("decoded",e)):super.emit("decoded",e);else{if(!o.isBinary(t)&&!t.base64)throw new Error("Unknown type: "+t);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");e=this.reconstructor.takeBinaryData(t),e&&(this.reconstructor=null,super.emit("decoded",e))}}decodeString(t){let e=0;const r={type:Number(t.charAt(0))};if(void 0===a[r.type])throw new Error("unknown packet type "+r.type);if(r.type===a.BINARY_EVENT||r.type===a.BINARY_ACK){const n=e+1;for(;"-"!==t.charAt(++e)&&e!=t.length;);const s=t.substring(n,e);if(s!=Number(s)||"-"!==t.charAt(e))throw new Error("Illegal attachments");r.attachments=Number(s)}if("/"===t.charAt(e+1)){const n=e+1;for(;++e;){if(","===t.charAt(e))break;if(e===t.length)break}r.nsp=t.substring(n,e)}else r.nsp="/";const n=t.charAt(e+1);if(""!==n&&Number(n)==n){const n=e+1;for(;++e;){const r=t.charAt(e);if(null==r||Number(r)!=r){--e;break}if(e===t.length)break}r.id=Number(t.substring(n,e+1))}if(t.charAt(++e)){const n=function(t){try{return JSON.parse(t)}catch(t){return!1}}(t.substr(e));if(!c.isPayloadValid(r.type,n))throw new Error("invalid payload");r.data=n}return i("decoded %s as %j",t,r),r}static isPayloadValid(t,e){switch(t){case a.CONNECT:return"object"==typeof e;case a.DISCONNECT:return void 0===e;case a.CONNECT_ERROR:return"string"==typeof e||"object"==typeof e;case a.EVENT:case a.BINARY_EVENT:return Array.isArray(e)&&e.length>0;case a.ACK:case a.BINARY_ACK:return Array.isArray(e)}}destroy(){this.reconstructor&&this.reconstructor.finishedReconstruction()}}e.Decoder=c;class h{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const t=s.reconstructPacket(this.reconPack,this.buffers);return this.finishedReconstruction(),t}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}},function(t,e){var r=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,n=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];t.exports=function(t){var e=t,s=t.indexOf("["),o=t.indexOf("]");-1!=s&&-1!=o&&(t=t.substring(0,s)+t.substring(s,o).replace(/:/g,";")+t.substring(o,t.length));for(var i,a,c=r.exec(t||""),h={},u=14;u--;)h[n[u]]=c[u]||"";return-1!=s&&-1!=o&&(h.source=e,h.host=h.host.substring(1,h.host.length-1).replace(/;/g,":"),h.authority=h.authority.replace("[","").replace("]","").replace(/;/g,":"),h.ipv6uri=!0),h.pathNames=function(t,e){var r=e.replace(/\/{2,9}/g,"/").split("/");"/"!=e.substr(0,1)&&0!==e.length||r.splice(0,1);"/"==e.substr(e.length-1,1)&&r.splice(r.length-1,1);return r}(0,h.path),h.queryKey=(i=h.query,a={},i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(t,e,r){e&&(a[e]=r)})),a),h}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Manager=void 0;const n=r(22),s=r(15),o=r(7),i=r(17),a=r(41),c=r(18),h=r(0)("socket.io-client:manager");class u extends c.StrictEventEmitter{constructor(t,e){super(),this.nsps={},this.subs=[],t&&"object"==typeof t&&(e=t,t=void 0),(e=e||{}).path=e.path||"/socket.io",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 a({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==e.timeout?2e4:e.timeout),this._readyState="closed",this.uri=t;const r=e.parser||o;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==e.autoConnect,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,this):this._reconnection}reconnectionAttempts(t){return void 0===t?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var e;return void 0===t?this._reconnectionDelay:(this._reconnectionDelay=t,null===(e=this.backoff)||void 0===e||e.setMin(t),this)}randomizationFactor(t){var e;return void 0===t?this._randomizationFactor:(this._randomizationFactor=t,null===(e=this.backoff)||void 0===e||e.setJitter(t),this)}reconnectionDelayMax(t){var e;return void 0===t?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,null===(e=this.backoff)||void 0===e||e.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(t){if(h("readyState %s",this._readyState),~this._readyState.indexOf("open"))return this;h("opening %s",this.uri),this.engine=n(this.uri,this.opts);const e=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const s=i.on(e,"open",(function(){r.onopen(),t&&t()})),o=i.on(e,"error",e=>{h("error"),r.cleanup(),r._readyState="closed",this.emitReserved("error",e),t?t(e):r.maybeReconnectOnOpen()});if(!1!==this._timeout){const t=this._timeout;h("connect attempt will timeout after %d",t),0===t&&s();const r=setTimeout(()=>{h("connect attempt timed out after %d",t),s(),e.close(),e.emit("error",new Error("timeout"))},t);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}return this.subs.push(s),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){h("open"),this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(i.on(t,"ping",this.onping.bind(this)),i.on(t,"data",this.ondata.bind(this)),i.on(t,"error",this.onerror.bind(this)),i.on(t,"close",this.onclose.bind(this)),i.on(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){this.decoder.add(t)}ondecoded(t){this.emitReserved("packet",t)}onerror(t){h("error",t),this.emitReserved("error",t)}socket(t,e){let r=this.nsps[t];return r||(r=new s.Socket(this,t,e),this.nsps[t]=r),r}_destroy(t){const e=Object.keys(this.nsps);for(const t of e){if(this.nsps[t].active)return void h("socket %s is still active, skipping close",t)}this._close()}_packet(t){h("writing packet %j",t);const e=this.encoder.encode(t);for(let r=0;r<e.length;r++)this.engine.write(e[r],t.options)}cleanup(){h("cleanup"),this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){h("disconnect"),this.skipReconnect=!0,this._reconnecting=!1,"opening"===this._readyState&&this.cleanup(),this.backoff.reset(),this._readyState="closed",this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(t){h("onclose"),this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)h("reconnect failed"),this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const e=this.backoff.duration();h("will wait %dms before reconnect attempt",e),this._reconnecting=!0;const r=setTimeout(()=>{t.skipReconnect||(h("attempting reconnect"),this.emitReserved("reconnect_attempt",t.backoff.attempts),t.skipReconnect||t.open(e=>{e?(h("reconnect attempt error"),t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",e)):(h("reconnect success"),t.onreconnect())}))},e);this.opts.autoUnref&&r.unref(),this.subs.push((function(){clearTimeout(r)}))}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}e.Manager=u},function(t,e,r){const n=r(11),s=r(25),o=r(29),i=r(30);e.polling=function(t){let e,r=!1,i=!1;const a=!1!==t.jsonp;if("undefined"!=typeof location){const e="https:"===location.protocol;let n=location.port;n||(n=e?443:80),r=t.hostname!==location.hostname||n!==t.port,i=t.secure!==e}if(t.xdomain=r,t.xscheme=i,e=new n(t),"open"in e&&!t.forceJSONP)return new s(t);if(!a)throw new Error("JSONP disabled");return new o(t)},e.websocket=i},function(t,e,r){const n=r(24),s=r(1);t.exports=function(t){const e=t.xdomain,r=t.xscheme,o=t.enablesXDR;try{if("undefined"!=typeof XMLHttpRequest&&(!e||n))return new XMLHttpRequest}catch(t){}try{if("undefined"!=typeof XDomainRequest&&!r&&o)return new XDomainRequest}catch(t){}if(!e)try{return new(s[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(t){}}},function(t,e,r){const n=r(5),s=r(6),o=r(2),i=r(14),a=r(0)("engine.io-client:polling");t.exports=class extends n{get name(){return"polling"}doOpen(){this.poll()}pause(t){this.readyState="pausing";const e=()=>{a("paused"),this.readyState="paused",t()};if(this.polling||!this.writable){let t=0;this.polling&&(a("we are currently polling - waiting to pause"),t++,this.once("pollComplete",(function(){a("pre-pause polling complete"),--t||e()}))),this.writable||(a("we are currently writing - waiting to pause"),t++,this.once("drain",(function(){a("pre-pause writing complete"),--t||e()})))}else e()}poll(){a("polling"),this.polling=!0,this.doPoll(),this.emit("poll")}onData(t){a("polling got data %s",t);o.decodePayload(t,this.socket.binaryType).forEach(t=>{if("opening"===this.readyState&&"open"===t.type&&this.onOpen(),"close"===t.type)return this.onClose(),!1;this.onPacket(t)}),"closed"!==this.readyState&&(this.polling=!1,this.emit("pollComplete"),"open"===this.readyState?this.poll():a('ignoring poll - transport state "%s"',this.readyState))}doClose(){const t=()=>{a("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(a("transport open - closing"),t()):(a("transport not open - deferring close"),this.once("open",t))}write(t){this.writable=!1,o.encodePayload(t,t=>{this.doWrite(t,()=>{this.writable=!0,this.emit("drain")})})}uri(){let t=this.query||{};const e=this.opts.secure?"https":"http";let r="";!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||t.sid||(t.b64=1),t=s.encode(t),this.opts.port&&("https"===e&&443!==Number(this.opts.port)||"http"===e&&80!==Number(this.opts.port))&&(r=":"+this.opts.port),t.length&&(t="?"+t);return e+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+t}}},function(t,e){const r=Object.create(null);r.open="0",r.close="1",r.ping="2",r.pong="3",r.message="4",r.upgrade="5",r.noop="6";const n=Object.create(null);Object.keys(r).forEach(t=>{n[r[t]]=t});t.exports={PACKET_TYPES:r,PACKET_TYPES_REVERSE:n,ERROR_PACKET:{type:"error",data:"parser error"}}},function(t,e,r){"use strict";var n,s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),o={},i=0,a=0;function c(t){var e="";do{e=s[t%64]+e,t=Math.floor(t/64)}while(t>0);return e}function h(){var t=c(+new Date);return t!==n?(i=0,n=t):t+"."+c(i++)}for(;a<64;a++)o[s[a]]=a;h.encode=c,h.decode=function(t){var e=0;for(a=0;a<t.length;a++)e=64*e+o[t.charAt(a)];return e},t.exports=h},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Socket=void 0;const n=r(7),s=r(17),o=r(18),i=r(0)("socket.io-client:socket"),a=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class c extends o.StrictEventEmitter{constructor(t,e,r){super(),this.receiveBuffer=[],this.sendBuffer=[],this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=e,this.ids=0,this.acks={},this.receiveBuffer=[],this.sendBuffer=[],this.connected=!1,this.disconnected=!0,this.flags={},r&&r.auth&&(this.auth=r.auth),this.io._autoConnect&&this.open()}subEvents(){if(this.subs)return;const t=this.io;this.subs=[s.on(t,"open",this.onopen.bind(this)),s.on(t,"packet",this.onpacket.bind(this)),s.on(t,"error",this.onerror.bind(this)),s.on(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...e){if(a.hasOwnProperty(t))throw new Error('"'+t+'" is a reserved event name');e.unshift(t);const r={type:n.PacketType.EVENT,data:e,options:{}};r.options.compress=!1!==this.flags.compress,"function"==typeof e[e.length-1]&&(i("emitting packet with ack id %d",this.ids),this.acks[this.ids]=e.pop(),r.id=this.ids++);const s=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!s||!this.connected)?i("discard packet as the transport is not currently writable"):this.connected?this.packet(r):this.sendBuffer.push(r),this.flags={},this}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){i("transport is open - connecting"),"function"==typeof this.auth?this.auth(t=>{this.packet({type:n.PacketType.CONNECT,data:t})}):this.packet({type:n.PacketType.CONNECT,data:this.auth})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t){i("close (%s)",t),this.connected=!1,this.disconnected=!0,delete this.id,this.emitReserved("disconnect",t)}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case n.PacketType.CONNECT:if(t.data&&t.data.sid){const e=t.data.sid;this.onconnect(e)}else this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case n.PacketType.EVENT:case n.PacketType.BINARY_EVENT:this.onevent(t);break;case n.PacketType.ACK:case n.PacketType.BINARY_ACK:this.onack(t);break;case n.PacketType.DISCONNECT:this.ondisconnect();break;case n.PacketType.CONNECT_ERROR:const e=new Error(t.data.message);e.data=t.data.data,this.emitReserved("connect_error",e)}}onevent(t){const e=t.data||[];i("emitting event %j",e),null!=t.id&&(i("attaching ack callback to event"),e.push(this.ack(t.id))),this.connected?this.emitEvent(e):this.receiveBuffer.push(Object.freeze(e))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const e=this._anyListeners.slice();for(const r of e)r.apply(this,t)}super.emit.apply(this,t)}ack(t){const e=this;let r=!1;return function(...s){r||(r=!0,i("sending ack %j",s),e.packet({type:n.PacketType.ACK,id:t,data:s}))}}onack(t){const e=this.acks[t.id];"function"==typeof e?(i("calling ack %s with %j",t.id,t.data),e.apply(this,t.data),delete this.acks[t.id]):i("bad ack %s",t.id)}onconnect(t){i("socket connected with id %s",t),this.id=t,this.connected=!0,this.disconnected=!1,this.emitReserved("connect"),this.emitBuffered()}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>this.packet(t)),this.sendBuffer=[]}ondisconnect(){i("server disconnect (%s)",this.nsp),this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&(i("performing disconnect (%s)",this.nsp),this.packet({type:n.PacketType.DISCONNECT})),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const e=this._anyListeners;for(let r=0;r<e.length;r++)if(t===e[r])return e.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}}e.Socket=c},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.hasBinary=e.isBinary=void 0;const n="function"==typeof ArrayBuffer,s=Object.prototype.toString,o="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===s.call(Blob),i="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===s.call(File);function a(t){return n&&(t instanceof ArrayBuffer||(t=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(t):t.buffer instanceof ArrayBuffer)(t))||o&&t instanceof Blob||i&&t instanceof File}e.isBinary=a,e.hasBinary=function t(e,r){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let r=0,n=e.length;r<n;r++)if(t(e[r]))return!0;return!1}if(a(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return t(e.toJSON(),!0);for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&t(e[r]))return!0;return!1}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.on=void 0,e.on=function(t,e,r){return t.on(e,r),function(){t.off(e,r)}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.StrictEventEmitter=void 0;const n=r(3);e.StrictEventEmitter=class extends n{on(t,e){return super.on(t,e),this}once(t,e){return super.once(t,e),this}emit(t,...e){return super.emit(t,...e),this}emitReserved(t,...e){return super.emit(t,...e),this}listeners(t){return super.listeners(t)}}},function(t,e,r){t.exports=r(20)},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Socket=e.io=e.Manager=e.protocol=void 0;const n=r(21),s=r(9),o=r(15);Object.defineProperty(e,"Socket",{enumerable:!0,get:function(){return o.Socket}});const i=r(0)("socket.io-client");t.exports=e=c;const a=e.managers={};function c(t,e){"object"==typeof t&&(e=t,t=void 0),e=e||{};const r=n.url(t,e.path),o=r.source,c=r.id,h=r.path,u=a[c]&&h in a[c].nsps;let p;return e.forceNew||e["force new connection"]||!1===e.multiplex||u?(i("ignoring socket cache for %s",o),p=new s.Manager(o,e)):(a[c]||(i("new io instance for %s",o),a[c]=new s.Manager(o,e)),p=a[c]),r.query&&!e.query&&(e.query=r.queryKey),p.socket(r.path,e)}e.io=c;var h=r(7);Object.defineProperty(e,"protocol",{enumerable:!0,get:function(){return h.protocol}}),e.connect=c;var u=r(9);Object.defineProperty(e,"Manager",{enumerable:!0,get:function(){return u.Manager}})},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.url=void 0;const n=r(8),s=r(0)("socket.io-client:url");e.url=function(t,e="",r){let o=t;r=r||"undefined"!=typeof location&&location,null==t&&(t=r.protocol+"//"+r.host),"string"==typeof t&&("/"===t.charAt(0)&&(t="/"===t.charAt(1)?r.protocol+t:r.host+t),/^(https?|wss?):\/\//.test(t)||(s("protocol-less url %s",t),t=void 0!==r?r.protocol+"//"+t:"https://"+t),s("parse %s",t),o=n(t)),o.port||(/^(http|ws)$/.test(o.protocol)?o.port="80":/^(http|ws)s$/.test(o.protocol)&&(o.port="443")),o.path=o.path||"/";const i=-1!==o.host.indexOf(":")?"["+o.host+"]":o.host;return o.id=o.protocol+"://"+i+":"+o.port+e,o.href=o.protocol+"://"+i+(r&&r.port===o.port?"":":"+o.port),o}},function(t,e,r){const n=r(23);t.exports=(t,e)=>new n(t,e),t.exports.Socket=n,t.exports.protocol=n.protocol,t.exports.Transport=r(5),t.exports.transports=r(10),t.exports.parser=r(2)},function(t,e,r){const n=r(10),s=r(3),o=r(0)("engine.io-client:socket"),i=r(2),a=r(8),c=r(6),{installTimerFunctions:h}=r(4);class u extends s{constructor(t,e={}){super(),t&&"object"==typeof t&&(e=t,t=null),t?(t=a(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=a(e.host).host),h(this,e),this.secure=null!=e.secure?e.secure:"undefined"!=typeof location&&"https:"===location.protocol,e.hostname&&!e.port&&(e.port=this.secure?"443":"80"),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.transports=e.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,jsonp:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},e),this.opts.path=this.opts.path.replace(/\/$/,"")+"/","string"==typeof this.opts.query&&(this.opts.query=c.decode(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&addEventListener("beforeunload",()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},!1),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close")},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(t){o('creating transport "%s"',t);const e=function(t){const e={};for(let r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e}(this.opts.query);e.EIO=i.protocol,e.transport=t,this.id&&(e.sid=this.id);const r=Object.assign({},this.opts.transportOptions[t],this.opts,{query:e,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return o("options: %j",r),new n[t](r)}open(){let t;if(this.opts.rememberUpgrade&&u.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))t="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emit("error","No transports available")},0);t=this.transports[0]}this.readyState="opening";try{t=this.createTransport(t)}catch(t){return o("error while creating transport: %s",t),this.transports.shift(),void this.open()}t.open(),this.setTransport(t)}setTransport(t){o("setting transport %s",t.name),this.transport&&(o("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=t,t.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",()=>{this.onClose("transport close")})}probe(t){o('probing transport "%s"',t);let e=this.createTransport(t,{probe:1}),r=!1;u.priorWebsocketSuccess=!1;const n=()=>{r||(o('probe transport "%s" opened',t),e.send([{type:"ping",data:"probe"}]),e.once("packet",n=>{if(!r)if("pong"===n.type&&"probe"===n.data){if(o('probe transport "%s" pong',t),this.upgrading=!0,this.emit("upgrading",e),!e)return;u.priorWebsocketSuccess="websocket"===e.name,o('pausing current transport "%s"',this.transport.name),this.transport.pause(()=>{r||"closed"!==this.readyState&&(o("changing transport and sending upgrade packet"),p(),this.setTransport(e),e.send([{type:"upgrade"}]),this.emit("upgrade",e),e=null,this.upgrading=!1,this.flush())})}else{o('probe transport "%s" failed',t);const r=new Error("probe error");r.transport=e.name,this.emit("upgradeError",r)}}))};function s(){r||(r=!0,p(),e.close(),e=null)}const i=r=>{const n=new Error("probe error: "+r);n.transport=e.name,s(),o('probe transport "%s" failed because of error: %s',t,r),this.emit("upgradeError",n)};function a(){i("transport closed")}function c(){i("socket closed")}function h(t){e&&t.name!==e.name&&(o('"%s" works - aborting "%s"',t.name,e.name),s())}const p=()=>{e.removeListener("open",n),e.removeListener("error",i),e.removeListener("close",a),this.removeListener("close",c),this.removeListener("upgrading",h)};e.once("open",n),e.once("error",i),e.once("close",a),this.once("close",c),this.once("upgrading",h),e.open()}onOpen(){if(o("socket open"),this.readyState="open",u.priorWebsocketSuccess="websocket"===this.transport.name,this.emit("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause){o("starting upgrade probes");let t=0;const e=this.upgrades.length;for(;t<e;t++)this.probe(this.upgrades[t])}}onPacket(t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(o('socket receive: type "%s", data "%s"',t.type,t.data),this.emit("packet",t),this.emit("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emit("ping"),this.emit("pong");break;case"error":const 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)}else o('packet received with socket readyState "%s"',this.readyState)}onHandshake(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.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn(()=>{this.onClose("ping timeout")},this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emit("drain"):this.flush()}flush(){"closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length&&(o("flushing %d packets in socket",this.writeBuffer.length),this.transport.send(this.writeBuffer),this.prevBufferLen=this.writeBuffer.length,this.emit("flush"))}write(t,e,r){return this.sendPacket("message",t,e,r),this}send(t,e,r){return this.sendPacket("message",t,e,r),this}sendPacket(t,e,r,n){if("function"==typeof e&&(n=e,e=void 0),"function"==typeof r&&(n=r,r=null),"closing"===this.readyState||"closed"===this.readyState)return;(r=r||{}).compress=!1!==r.compress;const s={type:t,data:e,options:r};this.emit("packetCreate",s),this.writeBuffer.push(s),n&&this.once("flush",n),this.flush()}close(){const t=()=>{this.onClose("forced close"),o("socket closing - telling transport to close"),this.transport.close()},e=()=>{this.removeListener("upgrade",e),this.removeListener("upgradeError",e),t()},r=()=>{this.once("upgrade",e),this.once("upgradeError",e)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}onError(t){o("socket error %j",t),u.priorWebsocketSuccess=!1,this.emit("error",t),this.onClose("transport error",t)}onClose(t,e){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(o('socket close with reason: "%s"',t),this.clearTimeoutFn(this.pingIntervalTimer),this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&removeEventListener("offline",this.offlineEventListener,!1),this.readyState="closed",this.id=null,this.emit("close",t,e),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(t){const e=[];let r=0;const n=t.length;for(;r<n;r++)~this.transports.indexOf(t[r])&&e.push(t[r]);return e}}u.priorWebsocketSuccess=!1,u.protocol=i.protocol,t.exports=u},function(t,e){try{t.exports="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){t.exports=!1}},function(t,e,r){const n=r(11),s=r(12),o=r(3),{pick:i,installTimerFunctions:a}=r(4),c=r(1),h=r(0)("engine.io-client:polling-xhr");function u(){}const p=null!=new n({xdomain:!1}).responseType;class f extends o{constructor(t,e){super(),a(this,e),this.opts=e,this.method=e.method||"GET",this.uri=t,this.async=!1!==e.async,this.data=void 0!==e.data?e.data:null,this.create()}create(){const t=i(this.opts,"agent","enablesXDR","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd,t.xscheme=!!this.opts.xs;const e=this.xhr=new n(t);try{h("xhr open %s: %s",this.method,this.uri),e.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders){e.setDisableHeaderCheck&&e.setDisableHeaderCheck(!0);for(let t in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(t)&&e.setRequestHeader(t,this.opts.extraHeaders[t])}}catch(t){}if("POST"===this.method)try{e.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{e.setRequestHeader("Accept","*/*")}catch(t){}"withCredentials"in e&&(e.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(e.timeout=this.opts.requestTimeout),this.hasXDR()?(e.onload=()=>{this.onLoad()},e.onerror=()=>{this.onError(e.responseText)}):e.onreadystatechange=()=>{4===e.readyState&&(200===e.status||1223===e.status?this.onLoad():this.setTimeoutFn(()=>{this.onError("number"==typeof e.status?e.status:0)},0))},h("xhr data %s",this.data),e.send(this.data)}catch(t){return void this.setTimeoutFn(()=>{this.onError(t)},0)}"undefined"!=typeof document&&(this.index=f.requestsCount++,f.requests[this.index]=this)}onSuccess(){this.emit("success"),this.cleanup()}onData(t){this.emit("data",t),this.onSuccess()}onError(t){this.emit("error",t),this.cleanup(!0)}cleanup(t){if(void 0!==this.xhr&&null!==this.xhr){if(this.hasXDR()?this.xhr.onload=this.xhr.onerror=u:this.xhr.onreadystatechange=u,t)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete f.requests[this.index],this.xhr=null}}onLoad(){const t=this.xhr.responseText;null!==t&&this.onData(t)}hasXDR(){return"undefined"!=typeof XDomainRequest&&!this.xs&&this.enablesXDR}abort(){this.cleanup()}}if(f.requestsCount=0,f.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",l);else if("function"==typeof addEventListener){addEventListener("onpagehide"in c?"pagehide":"unload",l,!1)}function l(){for(let t in f.requests)f.requests.hasOwnProperty(t)&&f.requests[t].abort()}t.exports=class extends s{constructor(t){if(super(t),"undefined"!=typeof location){const e="https:"===location.protocol;let r=location.port;r||(r=e?443:80),this.xd="undefined"!=typeof location&&t.hostname!==location.hostname||r!==t.port,this.xs=t.secure!==e}const e=t&&t.forceBase64;this.supportsBinary=p&&!e}request(t={}){return Object.assign(t,{xd:this.xd,xs:this.xs},this.opts),new f(this.uri(),t)}doWrite(t,e){const r=this.request({method:"POST",data:t});r.on("success",e),r.on("error",t=>{this.onError("xhr post error",t)})}doPoll(){h("xhr poll");const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",t=>{this.onError("xhr poll error",t)}),this.pollXhr=t}},t.exports.Request=f},function(t,e,r){const{PACKET_TYPES:n}=r(13),s="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),o="function"==typeof ArrayBuffer,i=(t,e)=>{const r=new FileReader;return r.onload=function(){const t=r.result.split(",")[1];e("b"+t)},r.readAsDataURL(t)};t.exports=({type:t,data:e},r,a)=>{return s&&e instanceof Blob?r?a(e):i(e,a):o&&(e instanceof ArrayBuffer||(c=e,"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(c):c&&c.buffer instanceof ArrayBuffer))?r?a(e):i(new Blob([e]),a):a(n[t]+(e||""));var c}},function(t,e,r){const{PACKET_TYPES_REVERSE:n,ERROR_PACKET:s}=r(13);let o;"function"==typeof ArrayBuffer&&(o=r(28));const i=(t,e)=>{if(o){const r=o.decode(t);return a(r,e)}return{base64:!0,data:t}},a=(t,e)=>{switch(e){case"blob":return t instanceof ArrayBuffer?new Blob([t]):t;case"arraybuffer":default:return t}};t.exports=(t,e)=>{if("string"!=typeof t)return{type:"message",data:a(t,e)};const r=t.charAt(0);if("b"===r)return{type:"message",data:i(t.substring(1),e)};return n[r]?t.length>1?{type:n[r],data:t.substring(1)}:{type:n[r]}:s}},function(t,e){!function(t){"use strict";e.encode=function(e){var r,n=new Uint8Array(e),s=n.length,o="";for(r=0;r<s;r+=3)o+=t[n[r]>>2],o+=t[(3&n[r])<<4|n[r+1]>>4],o+=t[(15&n[r+1])<<2|n[r+2]>>6],o+=t[63&n[r+2]];return s%3==2?o=o.substring(0,o.length-1)+"=":s%3==1&&(o=o.substring(0,o.length-2)+"=="),o},e.decode=function(e){var r,n,s,o,i,a=.75*e.length,c=e.length,h=0;"="===e[e.length-1]&&(a--,"="===e[e.length-2]&&a--);var u=new ArrayBuffer(a),p=new Uint8Array(u);for(r=0;r<c;r+=4)n=t.indexOf(e[r]),s=t.indexOf(e[r+1]),o=t.indexOf(e[r+2]),i=t.indexOf(e[r+3]),p[h++]=n<<2|s>>4,p[h++]=(15&s)<<4|o>>2,p[h++]=(3&o)<<6|63&i;return u}}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")},function(t,e,r){const n=r(12),s=r(1),o=/\n/g,i=/\\n/g;let a;t.exports=class extends n{constructor(t){super(t),this.query=this.query||{},a||(a=s.___eio=s.___eio||[]),this.index=a.length,a.push(this.onData.bind(this)),this.query.j=this.index}get supportsBinary(){return!1}doClose(){this.script&&(this.script.onerror=()=>{},this.script.parentNode.removeChild(this.script),this.script=null),this.form&&(this.form.parentNode.removeChild(this.form),this.form=null,this.iframe=null),super.doClose()}doPoll(){const t=document.createElement("script");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),t.async=!0,t.src=this.uri(),t.onerror=t=>{this.onError("jsonp poll error",t)};const e=document.getElementsByTagName("script")[0];e?e.parentNode.insertBefore(t,e):(document.head||document.body).appendChild(t),this.script=t;"undefined"!=typeof navigator&&/gecko/i.test(navigator.userAgent)&&this.setTimeoutFn((function(){const t=document.createElement("iframe");document.body.appendChild(t),document.body.removeChild(t)}),100)}doWrite(t,e){let r;if(!this.form){const t=document.createElement("form"),e=document.createElement("textarea"),r=this.iframeId="eio_iframe_"+this.index;t.className="socketio",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.target=r,t.method="POST",t.setAttribute("accept-charset","utf-8"),e.name="d",t.appendChild(e),document.body.appendChild(t),this.form=t,this.area=e}function n(){s(),e()}this.form.action=this.uri();const s=()=>{if(this.iframe)try{this.form.removeChild(this.iframe)}catch(t){this.onError("jsonp polling iframe removal error",t)}try{const t='<iframe src="javascript:0" name="'+this.iframeId+'">';r=document.createElement(t)}catch(t){r=document.createElement("iframe"),r.name=this.iframeId,r.src="javascript:0"}r.id=this.iframeId,this.form.appendChild(r),this.iframe=r};s(),t=t.replace(i,"\\\n"),this.area.value=t.replace(o,"\\n");try{this.form.submit()}catch(t){}this.iframe.attachEvent?this.iframe.onreadystatechange=()=>{"complete"===this.iframe.readyState&&n()}:this.iframe.onload=n}}},function(t,e,r){(function(e){const n=r(5),s=r(2),o=r(6),i=r(14),{pick:a}=r(4);let{WebSocket:c,usingBrowserWebSocket:h,defaultBinaryType:u,nextTick:p}=r(36);const f=r(0)("engine.io-client:websocket");"undefined"==typeof window&&(c=r(37),h=!1,u="nodebuffer");const l="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class d extends n{constructor(t){super(t),this.supportsBinary=!t.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const t=this.uri(),e=this.opts.protocols,r=l?{}:a(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=h&&!l?e?new c(t,e):new c(t):new c(t,e,r)}catch(t){return this.emit("error",t)}this.ws.binaryType=this.socket.binaryType||u,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=this.onClose.bind(this),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let r=0;r<t.length;r++){const n=t[r],o=r===t.length-1;s.encodePacket(n,this.supportsBinary,t=>{const r={};if(!h&&(n.options&&(r.compress=n.options.compress),this.opts.perMessageDeflate)){("string"==typeof t?e.byteLength(t):t.length)<this.opts.perMessageDeflate.threshold&&(r.compress=!1)}try{h?this.ws.send(t):this.ws.send(t,r)}catch(t){f("websocket closed before onclose event")}o&&p(()=>{this.writable=!0,this.emit("drain")},this.setTimeoutFn)})}}onClose(){n.prototype.onClose.call(this)}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){let t=this.query||{};const e=this.opts.secure?"wss":"ws";let r="";this.opts.port&&("wss"===e&&443!==Number(this.opts.port)||"ws"===e&&80!==Number(this.opts.port))&&(r=":"+this.opts.port),this.opts.timestampRequests&&(t[this.opts.timestampParam]=i()),this.supportsBinary||(t.b64=1),t=o.encode(t),t.length&&(t="?"+t);return e+"://"+(-1!==this.opts.hostname.indexOf(":")?"["+this.opts.hostname+"]":this.opts.hostname)+r+this.opts.path+t}check(){return!(!c||"__initialize"in c&&this.name===d.prototype.name)}}t.exports=d}).call(this,r(31).Buffer)},function(t,e,r){"use strict";(function(t){
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/
var n=r(33),s=r(34),o=r(35);function i(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(t,e){if(i()<e)throw new RangeError("Invalid typed array length");return c.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=c.prototype:(null===t&&(t=new c(e)),t.length=e),t}function c(t,e,r){if(!(c.TYPED_ARRAY_SUPPORT||this instanceof c))return new c(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return p(this,t)}return h(this,t,e,r)}function h(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n);c.TYPED_ARRAY_SUPPORT?(t=e).__proto__=c.prototype:t=f(t,e);return t}(t,e,r,n):"string"==typeof e?function(t,e,r){"string"==typeof r&&""!==r||(r="utf8");if(!c.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|d(e,r),s=(t=a(t,n)).write(e,r);s!==n&&(t=t.slice(0,s));return t}(t,e,r):function(t,e){if(c.isBuffer(e)){var r=0|l(e.length);return 0===(t=a(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?a(t,0):f(t,e);if("Buffer"===e.type&&o(e.data))return f(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function p(t,e){if(u(e),t=a(t,e<0?0:0|l(e)),!c.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function f(t,e){var r=e.length<0?0:0|l(e.length);t=a(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function l(t){if(t>=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|t}function d(t,e){if(c.isBuffer(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Y(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(n)return Y(t).length;e=(""+e).toLowerCase(),n=!0}}function y(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return P(this,e,r);case"utf8":case"utf-8":return S(this,e,r);case"ascii":return R(this,e,r);case"latin1":case"binary":return x(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function m(t,e,r,n,s){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=s?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(s)return-1;r=t.length-1}else if(r<0){if(!s)return-1;r=0}if("string"==typeof e&&(e=c.from(e,n)),c.isBuffer(e))return 0===e.length?-1:v(t,e,r,n,s);if("number"==typeof e)return e&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?s?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):v(t,[e],r,n,s);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,s){var o,i=1,a=t.length,c=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;i=2,a/=2,c/=2,r/=2}function h(t,e){return 1===i?t[e]:t.readUInt16BE(e*i)}if(s){var u=-1;for(o=r;o<a;o++)if(h(t,o)===h(e,-1===u?0:o-u)){if(-1===u&&(u=o),o-u+1===c)return u*i}else-1!==u&&(o-=o-u),u=-1}else for(r+c>a&&(r=a-c),o=r;o>=0;o--){for(var p=!0,f=0;f<c;f++)if(h(t,o+f)!==h(e,f)){p=!1;break}if(p)return o}return-1}function b(t,e,r,n){r=Number(r)||0;var s=t.length-r;n?(n=Number(n))>s&&(n=s):n=s;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var i=0;i<n;++i){var a=parseInt(e.substr(2*i,2),16);if(isNaN(a))return i;t[r+i]=a}return i}function w(t,e,r,n){return F(Y(e,t.length-r),t,r,n)}function E(t,e,r,n){return F(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function _(t,e,r,n){return E(t,e,r,n)}function k(t,e,r,n){return F(q(e),t,r,n)}function A(t,e,r,n){return F(function(t,e){for(var r,n,s,o=[],i=0;i<t.length&&!((e-=2)<0);++i)r=t.charCodeAt(i),n=r>>8,s=r%256,o.push(s),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function S(t,e,r){r=Math.min(t.length,r);for(var n=[],s=e;s<r;){var o,i,a,c,h=t[s],u=null,p=h>239?4:h>223?3:h>191?2:1;if(s+p<=r)switch(p){case 1:h<128&&(u=h);break;case 2:128==(192&(o=t[s+1]))&&(c=(31&h)<<6|63&o)>127&&(u=c);break;case 3:o=t[s+1],i=t[s+2],128==(192&o)&&128==(192&i)&&(c=(15&h)<<12|(63&o)<<6|63&i)>2047&&(c<55296||c>57343)&&(u=c);break;case 4:o=t[s+1],i=t[s+2],a=t[s+3],128==(192&o)&&128==(192&i)&&128==(192&a)&&(c=(15&h)<<18|(63&o)<<12|(63&i)<<6|63&a)>65535&&c<1114112&&(u=c)}null===u?(u=65533,p=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),s+=p}return function(t){var e=t.length;if(e<=4096)return String.fromCharCode.apply(String,t);var r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=4096));return r}(n)}e.Buffer=c,e.SlowBuffer=function(t){+t!=t&&(t=0);return c.alloc(+t)},e.INSPECT_MAX_BYTES=50,c.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:function(){try{var t=new Uint8Array(1);return t.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===t.foo()&&"function"==typeof t.subarray&&0===t.subarray(1,1).byteLength}catch(t){return!1}}(),e.kMaxLength=i(),c.poolSize=8192,c._augment=function(t){return t.__proto__=c.prototype,t},c.from=function(t,e,r){return h(null,t,e,r)},c.TYPED_ARRAY_SUPPORT&&(c.prototype.__proto__=Uint8Array.prototype,c.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&c[Symbol.species]===c&&Object.defineProperty(c,Symbol.species,{value:null,configurable:!0})),c.alloc=function(t,e,r){return function(t,e,r,n){return u(e),e<=0?a(t,e):void 0!==r?"string"==typeof n?a(t,e).fill(r,n):a(t,e).fill(r):a(t,e)}(null,t,e,r)},c.allocUnsafe=function(t){return p(null,t)},c.allocUnsafeSlow=function(t){return p(null,t)},c.isBuffer=function(t){return!(null==t||!t._isBuffer)},c.compare=function(t,e){if(!c.isBuffer(t)||!c.isBuffer(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,s=0,o=Math.min(r,n);s<o;++s)if(t[s]!==e[s]){r=t[s],n=e[s];break}return r<n?-1:n<r?1:0},c.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},c.concat=function(t,e){if(!o(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return c.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=c.allocUnsafe(e),s=0;for(r=0;r<t.length;++r){var i=t[r];if(!c.isBuffer(i))throw new TypeError('"list" argument must be an Array o