UNPKG

simple-peer-wrapper

Version:

A wrapper for simple-peer that includes a socket.io signaling server client. To be used in the browser with simple-peer-server.

6 lines 156 kB
(function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,t.SimplePeerWrapper=e()}})(function(){var t=Math.floor,n=Math.abs,r=Math.pow,o=String.fromCharCode,s=Math.min;return function(){function s(d,e,n){function t(o,i){if(!e[o]){if(!d[o]){var l="function"==typeof require&&require;if(!i&&l)return l(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var a=e[o]={exports:{}};d[o][0].call(a.exports,function(e){var r=d[o][1][e];return t(r||e)},a,a.exports,s,d,e,n)}return e[o].exports}for(var r="function"==typeof require&&require,o=0;o<n.length;o++)t(n[o]);return t}return s}()({1:[function(e,t,n){function r(e){if(e)return o(e)}function o(e){for(var t in r.prototype)e[t]=r.prototype[t];return e}n.Emitter=r,r.prototype.on=r.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},r.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},r.prototype.off=r.prototype.removeListener=r.prototype.removeAllListeners=r.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var r=0,o;r<n.length;r++)if(o=n[r],o===t||o.fn===t){n.splice(r,1);break}return 0===n.length&&delete this._callbacks["$"+e],this},r.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,o=n.length;r<o;++r)n[r].apply(this,t)}return this},r.prototype.emitReserved=r.prototype.emit,r.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},r.prototype.hasListeners=function(e){return!!this.listeners(e).length}},{}],2:[function(e,t,n){"use strict";function r(e){var t=e.length;if(0<t%4)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");-1===n&&(n=t);var r=n===t?0:4-n%4;return[n,r]}function o(e,t,n){return 3*(t+n)/4-n}function a(e){var t=r(e),n=t[0],a=t[1],s=new p(o(e,n,a)),d=0,l=0<a?n-4:n,u,f;for(f=0;f<l;f+=4)u=c[e.charCodeAt(f)]<<18|c[e.charCodeAt(f+1)]<<12|c[e.charCodeAt(f+2)]<<6|c[e.charCodeAt(f+3)],s[d++]=255&u>>16,s[d++]=255&u>>8,s[d++]=255&u;return 2===a&&(u=c[e.charCodeAt(f)]<<2|c[e.charCodeAt(f+1)]>>4,s[d++]=255&u),1===a&&(u=c[e.charCodeAt(f)]<<10|c[e.charCodeAt(f+1)]<<4|c[e.charCodeAt(f+2)]>>2,s[d++]=255&u>>8,s[d++]=255&u),s}function s(e){return l[63&e>>18]+l[63&e>>12]+l[63&e>>6]+l[63&e]}function d(e,t,n){for(var r=[],o=t,a;o<n;o+=3)a=(16711680&e[o]<<16)+(65280&e[o+1]<<8)+(255&e[o+2]),r.push(s(a));return r.join("")}n.byteLength=function t(e){var n=r(e),o=n[0],a=n[1];return 3*(o+a)/4-a},n.toByteArray=a,n.fromByteArray=function t(e){for(var n=e.length,r=n%3,o=[],a=16383,s=0,c=n-r,p;s<c;s+=a)o.push(d(e,s,s+a>c?c:s+a));return 1===r?(p=e[n-1],o.push(l[p>>2]+l[63&p<<4]+"==")):2===r&&(p=(e[n-2]<<8)+e[n-1],o.push(l[p>>10]+l[63&p>>4]+l[63&p<<2]+"=")),o.join("")};for(var l=[],c=[],p="undefined"==typeof Uint8Array?Array:Uint8Array,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,g=u.length;f<g;++f)l[f]=u[f],c[u.charCodeAt(f)]=f;c[45]=62,c[95]=63},{}],3:[function(e,t,n){},{}],4:[function(e,t,n){(function(t){(function(){/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */"use strict";function t(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()}catch(t){return!1}}function a(e){if(2147483647<e)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"");var t=new Uint8Array(e);return t.__proto__=d.prototype,t}function d(e,t,n){if("number"==typeof e){if("string"==typeof t)throw new TypeError("The \"string\" argument must be of type string. Received type number");return u(e)}return l(e,t,n)}function l(e,t,n){if("string"==typeof e)return f(e,t);if(ArrayBuffer.isView(e))return g(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(X(e,ArrayBuffer)||e&&X(e.buffer,ArrayBuffer))return m(e,t,n);if("number"==typeof e)throw new TypeError("The \"value\" argument must not be of type number. Received type number");var r=e.valueOf&&e.valueOf();if(null!=r&&r!==e)return d.from(r,t,n);var o=h(e);if(o)return o;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return d.from(e[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw new TypeError("\"size\" argument must be of type number");else if(0>e)throw new RangeError("The value \""+e+"\" is invalid for option \"size\"")}function p(e,t,n){return c(e),0>=e?a(e):void 0===t?a(e):"string"==typeof n?a(e).fill(t,n):a(e).fill(t)}function u(e){return c(e),a(0>e?0:0|_(e))}function f(e,t){if(("string"!=typeof t||""===t)&&(t="utf8"),!d.isEncoding(t))throw new TypeError("Unknown encoding: "+t);var n=0|b(e,t),r=a(n),o=r.write(e,t);return o!==n&&(r=r.slice(0,o)),r}function g(e){for(var t=0>e.length?0:0|_(e.length),n=a(t),r=0;r<t;r+=1)n[r]=255&e[r];return n}function m(e,t,n){if(0>t||e.byteLength<t)throw new RangeError("\"offset\" is outside of buffer bounds");if(e.byteLength<t+(n||0))throw new RangeError("\"length\" is outside of buffer bounds");var r;return r=void 0===t&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,t):new Uint8Array(e,t,n),r.__proto__=d.prototype,r}function h(e){if(d.isBuffer(e)){var t=0|_(e.length),n=a(t);return 0===n.length?n:(e.copy(n,0,0,t),n)}return void 0===e.length?"Buffer"===e.type&&Array.isArray(e.data)?g(e.data):void 0:"number"!=typeof e.length||J(e.length)?a(0):g(e)}function _(e){if(e>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+2147483647 .toString(16)+" bytes");return 0|e}function y(e){return+e!=e&&(e=0),d.alloc(+e)}function b(e,t){if(d.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||X(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw new TypeError("The \"string\" argument must be one of type string, Buffer, or ArrayBuffer. Received type "+typeof e);var n=e.length,r=2<arguments.length&&!0===arguments[2];if(!r&&0===n)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return Y(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return z(e).length;default:if(o)return r?-1:Y(e).length;t=(""+t).toLowerCase(),o=!0;}}function k(e,t,n){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");!0;)switch(e){case"hex":return M(this,t,n);case"utf8":case"utf-8":return x(this,t,n);case"ascii":return O(this,t,n);case"latin1":case"binary":return j(this,t,n);case"base64":return L(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0;}}function C(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function R(e,t,n,r,o){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):2147483647<n?n=2147483647:-2147483648>n&&(n=-2147483648),n=+n,J(n)&&(n=o?0:e.length-1),0>n&&(n=e.length+n),n>=e.length){if(o)return-1;n=e.length-1}else if(0>n)if(o)n=0;else return-1;if("string"==typeof t&&(t=d.from(t,r)),d.isBuffer(t))return 0===t.length?-1:E(e,t,n,r,o);if("number"==typeof t)return t&=255,"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):E(e,[t],n,r,o);throw new TypeError("val must be string, number or Buffer")}function E(e,t,n,r,o){function a(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}var s=1,d=e.length,l=t.length;if(void 0!==r&&(r=(r+"").toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(2>e.length||2>t.length)return-1;s=2,d/=2,l/=2,n/=2}var c;if(o){var p=-1;for(c=n;c<d;c++)if(a(e,c)!==a(t,-1===p?0:c-p))-1!==p&&(c-=c-p),p=-1;else if(-1===p&&(p=c),c-p+1===l)return p*s}else for(n+l>d&&(n=d-l),c=n;0<=c;c--){for(var u=!0,f=0;f<l;f++)if(a(e,c+f)!==a(t,f)){u=!1;break}if(u)return c}return-1}function S(e,t,n,r){n=+n||0;var o=e.length-n;r?(r=+r,r>o&&(r=o)):r=o;var a=t.length;r>a/2&&(r=a/2);for(var s=0,d;s<r;++s){if(d=parseInt(t.substr(2*s,2),16),J(d))return s;e[n+s]=d}return s}function w(e,t,n,r){return G(Y(t,e.length-n),e,n,r)}function T(e,t,n,r){return G(V(t),e,n,r)}function v(e,t,n,r){return T(e,t,n,r)}function P(e,t,n,r){return G(z(t),e,n,r)}function A(e,t,n,r){return G(K(t,e.length-n),e,n,r)}function L(e,t,n){return 0===t&&n===e.length?$.fromByteArray(e):$.fromByteArray(e.slice(t,n))}function x(e,t,n){n=s(e.length,n);for(var r=[],o=t;o<n;){var a=e[o],d=null,l=239<a?4:223<a?3:191<a?2:1;if(o+l<=n){var c,p,u,f;1===l?128>a&&(d=a):2===l?(c=e[o+1],128==(192&c)&&(f=(31&a)<<6|63&c,127<f&&(d=f))):3===l?(c=e[o+1],p=e[o+2],128==(192&c)&&128==(192&p)&&(f=(15&a)<<12|(63&c)<<6|63&p,2047<f&&(55296>f||57343<f)&&(d=f))):4===l?(c=e[o+1],p=e[o+2],u=e[o+3],128==(192&c)&&128==(192&p)&&128==(192&u)&&(f=(15&a)<<18|(63&c)<<12|(63&p)<<6|63&u,65535<f&&1114112>f&&(d=f))):void 0}null===d?(d=65533,l=1):65535<d&&(d-=65536,r.push(55296|1023&d>>>10),d=56320|1023&d),r.push(d),o+=l}return N(r)}function N(e){var t=e.length;if(t<=4096)return o.apply(String,e);for(var n="",r=0;r<t;)n+=o.apply(String,e.slice(r,r+=4096));return n}function O(e,t,n){var r="";n=s(e.length,n);for(var a=t;a<n;++a)r+=o(127&e[a]);return r}function j(e,t,n){var r="";n=s(e.length,n);for(var a=t;a<n;++a)r+=o(e[a]);return r}function M(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var o="",a=t;a<n;++a)o+=H(e[a]);return o}function B(e,t,n){for(var r=e.slice(t,n),a="",s=0;s<r.length;s+=2)a+=o(r[s]+256*r[s+1]);return a}function D(e,t,n){if(0!=e%1||0>e)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function I(e,t,n,r,o,a){if(!d.isBuffer(e))throw new TypeError("\"buffer\" argument must be a Buffer instance");if(t>o||t<a)throw new RangeError("\"value\" argument is out of bounds");if(n+r>e.length)throw new RangeError("Index out of range")}function F(e,t,n,r,o,a){if(n+r>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function q(e,t,n,r,o){return t=+t,n>>>=0,o||F(e,t,n,4,34028234663852886e22,-34028234663852886e22),Q.write(e,t,n,r,23,4),n+4}function U(e,t,n,r,o){return t=+t,n>>>=0,o||F(e,t,n,8,17976931348623157e292,-17976931348623157e292),Q.write(e,t,n,r,52,8),n+8}function W(e){if(e=e.split("=")[0],e=e.trim().replace(te,""),2>e.length)return"";for(;0!=e.length%4;)e+="=";return e}function H(e){return 16>e?"0"+e.toString(16):e.toString(16)}function Y(e,t){t=t||1/0;for(var n=e.length,r=null,o=[],a=0,s;a<n;++a){if(s=e.charCodeAt(a),55295<s&&57344>s){if(!r){if(56319<s){-1<(t-=3)&&o.push(239,191,189);continue}else if(a+1===n){-1<(t-=3)&&o.push(239,191,189);continue}r=s;continue}if(56320>s){-1<(t-=3)&&o.push(239,191,189),r=s;continue}s=(r-55296<<10|s-56320)+65536}else r&&-1<(t-=3)&&o.push(239,191,189);if(r=null,128>s){if(0>(t-=1))break;o.push(s)}else if(2048>s){if(0>(t-=2))break;o.push(192|s>>6,128|63&s)}else if(65536>s){if(0>(t-=3))break;o.push(224|s>>12,128|63&s>>6,128|63&s)}else if(1114112>s){if(0>(t-=4))break;o.push(240|s>>18,128|63&s>>12,128|63&s>>6,128|63&s)}else throw new Error("Invalid code point")}return o}function V(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}function K(e,t){for(var n=[],r=0,o,a,s;r<e.length&&!(0>(t-=2));++r)o=e.charCodeAt(r),a=o>>8,s=o%256,n.push(s),n.push(a);return n}function z(e){return $.toByteArray(W(e))}function G(e,t,n,r){for(var o=0;o<r&&!(o+n>=t.length||o>=e.length);++o)t[o+n]=e[o];return o}function X(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}function J(e){return e!==e}var $=e("base64-js"),Q=e("ieee754");n.Buffer=d,n.SlowBuffer=y,n.INSPECT_MAX_BYTES=50;var Z=2147483647;n.kMaxLength=2147483647,d.TYPED_ARRAY_SUPPORT=t(),d.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){return d.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){return d.isBuffer(this)?this.byteOffset:void 0}}),"undefined"!=typeof Symbol&&null!=Symbol.species&&d[Symbol.species]===d&&Object.defineProperty(d,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),d.poolSize=8192,d.from=function(e,t,n){return l(e,t,n)},d.prototype.__proto__=Uint8Array.prototype,d.__proto__=Uint8Array,d.alloc=function(e,t,n){return p(e,t,n)},d.allocUnsafe=function(e){return u(e)},d.allocUnsafeSlow=function(e){return u(e)},d.isBuffer=function t(e){return null!=e&&!0===e._isBuffer&&e!==d.prototype},d.compare=function n(e,t){if(X(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),X(t,Uint8Array)&&(t=d.from(t,t.offset,t.byteLength)),!d.isBuffer(e)||!d.isBuffer(t))throw new TypeError("The \"buf1\", \"buf2\" arguments must be one of type Buffer or Uint8Array");if(e===t)return 0;for(var r=e.length,o=t.length,l=0,c=s(r,o);l<c;++l)if(e[l]!==t[l]){r=e[l],o=t[l];break}return r<o?-1:o<r?1:0},d.isEncoding=function t(e){switch((e+"").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;}},d.concat=function n(e,t){if(!Array.isArray(e))throw new TypeError("\"list\" argument must be an Array of Buffers");if(0===e.length)return d.alloc(0);var r;if(t===void 0)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var o=d.allocUnsafe(t),a=0;for(r=0;r<e.length;++r){var s=e[r];if(X(s,Uint8Array)&&(s=d.from(s)),!d.isBuffer(s))throw new TypeError("\"list\" argument must be an Array of Buffers");s.copy(o,a),a+=s.length}return o},d.byteLength=b,d.prototype._isBuffer=!0,d.prototype.swap16=function e(){var t=this.length;if(0!=t%2)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var n=0;n<t;n+=2)C(this,n,n+1);return this},d.prototype.swap32=function e(){var t=this.length;if(0!=t%4)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var n=0;n<t;n+=4)C(this,n,n+3),C(this,n+1,n+2);return this},d.prototype.swap64=function e(){var t=this.length;if(0!=t%8)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var n=0;n<t;n+=8)C(this,n,n+7),C(this,n+1,n+6),C(this,n+2,n+5),C(this,n+3,n+4);return this},d.prototype.toString=function e(){var t=this.length;return 0===t?"":0===arguments.length?x(this,0,t):k.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function t(e){if(!d.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===d.compare(this,e)},d.prototype.inspect=function e(){var t="",r=n.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},d.prototype.compare=function a(e,t,n,r,o){if(X(e,Uint8Array)&&(e=d.from(e,e.offset,e.byteLength)),!d.isBuffer(e))throw new TypeError("The \"target\" argument must be one of type Buffer or Uint8Array. Received type "+typeof e);if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===o&&(o=this.length),0>t||n>e.length||0>r||o>this.length)throw new RangeError("out of range index");if(r>=o&&t>=n)return 0;if(r>=o)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,o>>>=0,this===e)return 0;for(var l=o-r,c=n-t,p=s(l,c),u=this.slice(r,o),f=e.slice(t,n),g=0;g<p;++g)if(u[g]!==f[g]){l=u[g],c=f[g];break}return l<c?-1:c<l?1:0},d.prototype.includes=function r(e,t,n){return-1!==this.indexOf(e,t,n)},d.prototype.indexOf=function r(e,t,n){return R(this,e,t,n,!0)},d.prototype.lastIndexOf=function r(e,t,n){return R(this,e,t,n,!1)},d.prototype.write=function o(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(n)?(n>>>=0,void 0===r&&(r="utf8")):(r=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var a=this.length-t;if((void 0===n||n>a)&&(n=a),0<e.length&&(0>n||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return S(this,e,t,n);case"utf8":case"utf-8":return w(this,e,t,n);case"ascii":return T(this,e,t,n);case"latin1":case"binary":return v(this,e,t,n);case"base64":return P(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),s=!0;}},d.prototype.toJSON=function e(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;d.prototype.slice=function n(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,0>e?(e+=r,0>e&&(e=0)):e>r&&(e=r),0>t?(t+=r,0>t&&(t=0)):t>r&&(t=r),t<e&&(t=e);var o=this.subarray(e,t);return o.__proto__=d.prototype,o},d.prototype.readUIntLE=function r(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var o=this[e],a=1,s=0;++s<t&&(a*=256);)o+=this[e+s]*a;return o},d.prototype.readUIntBE=function r(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var o=this[e+--t],a=1;0<t&&(a*=256);)o+=this[e+--t]*a;return o},d.prototype.readUInt8=function n(e,t){return e>>>=0,t||D(e,1,this.length),this[e]},d.prototype.readUInt16LE=function n(e,t){return e>>>=0,t||D(e,2,this.length),this[e]|this[e+1]<<8},d.prototype.readUInt16BE=function n(e,t){return e>>>=0,t||D(e,2,this.length),this[e]<<8|this[e+1]},d.prototype.readUInt32LE=function n(e,t){return e>>>=0,t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},d.prototype.readUInt32BE=function n(e,t){return e>>>=0,t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},d.prototype.readIntLE=function o(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var a=this[e],s=1,d=0;++d<t&&(s*=256);)a+=this[e+d]*s;return s*=128,a>=s&&(a-=r(2,8*t)),a},d.prototype.readIntBE=function o(e,t,n){e>>>=0,t>>>=0,n||D(e,t,this.length);for(var a=t,s=1,d=this[e+--a];0<a&&(s*=256);)d+=this[e+--a]*s;return s*=128,d>=s&&(d-=r(2,8*t)),d},d.prototype.readInt8=function n(e,t){return e>>>=0,t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},d.prototype.readInt16LE=function n(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},d.prototype.readInt16BE=function n(e,t){e>>>=0,t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},d.prototype.readInt32LE=function n(e,t){return e>>>=0,t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},d.prototype.readInt32BE=function n(e,t){return e>>>=0,t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},d.prototype.readFloatLE=function n(e,t){return e>>>=0,t||D(e,4,this.length),Q.read(this,e,!0,23,4)},d.prototype.readFloatBE=function n(e,t){return e>>>=0,t||D(e,4,this.length),Q.read(this,e,!1,23,4)},d.prototype.readDoubleLE=function n(e,t){return e>>>=0,t||D(e,8,this.length),Q.read(this,e,!0,52,8)},d.prototype.readDoubleBE=function n(e,t){return e>>>=0,t||D(e,8,this.length),Q.read(this,e,!1,52,8)},d.prototype.writeUIntLE=function a(e,t,n,o){if(e=+e,t>>>=0,n>>>=0,!o){var s=r(2,8*n)-1;I(this,e,t,n,s,0)}var d=1,l=0;for(this[t]=255&e;++l<n&&(d*=256);)this[t+l]=255&e/d;return t+n},d.prototype.writeUIntBE=function a(e,t,n,o){if(e=+e,t>>>=0,n>>>=0,!o){var s=r(2,8*n)-1;I(this,e,t,n,s,0)}var d=n-1,l=1;for(this[t+d]=255&e;0<=--d&&(l*=256);)this[t+d]=255&e/l;return t+n},d.prototype.writeUInt8=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,1,255,0),this[t]=255&e,t+1},d.prototype.writeUInt16LE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},d.prototype.writeUInt16BE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},d.prototype.writeUInt32LE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,4,4294967295,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},d.prototype.writeUInt32BE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,4,4294967295,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},d.prototype.writeIntLE=function a(e,t,n,o){if(e=+e,t>>>=0,!o){var s=r(2,8*n-1);I(this,e,t,n,s-1,-s)}var d=0,l=1,c=0;for(this[t]=255&e;++d<n&&(l*=256);)0>e&&0===c&&0!==this[t+d-1]&&(c=1),this[t+d]=255&(e/l>>0)-c;return t+n},d.prototype.writeIntBE=function a(e,t,n,o){if(e=+e,t>>>=0,!o){var s=r(2,8*n-1);I(this,e,t,n,s-1,-s)}var d=n-1,l=1,c=0;for(this[t+d]=255&e;0<=--d&&(l*=256);)0>e&&0===c&&0!==this[t+d+1]&&(c=1),this[t+d]=255&(e/l>>0)-c;return t+n},d.prototype.writeInt8=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,1,127,-128),0>e&&(e=255+e+1),this[t]=255&e,t+1},d.prototype.writeInt16LE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},d.prototype.writeInt16BE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},d.prototype.writeInt32LE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,4,2147483647,-2147483648),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},d.prototype.writeInt32BE=function r(e,t,n){return e=+e,t>>>=0,n||I(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},d.prototype.writeFloatLE=function r(e,t,n){return q(this,e,t,!0,n)},d.prototype.writeFloatBE=function r(e,t,n){return q(this,e,t,!1,n)},d.prototype.writeDoubleLE=function r(e,t,n){return U(this,e,t,!0,n)},d.prototype.writeDoubleBE=function r(e,t,n){return U(this,e,t,!1,n)},d.prototype.copy=function o(e,t,n,r){if(!d.isBuffer(e))throw new TypeError("argument should be a Buffer");if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),0<r&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("Index out of range");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a=r-n;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,n,r);else if(this===e&&n<t&&t<r)for(var s=a-1;0<=s;--s)e[s+t]=this[s+n];else Uint8Array.prototype.set.call(e,this.subarray(n,r),t);return a},d.prototype.fill=function o(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!d.isEncoding(r))throw new TypeError("Unknown encoding: "+r);if(1===e.length){var a=e.charCodeAt(0);("utf8"===r&&128>a||"latin1"===r)&&(e=a)}}else"number"==typeof e&&(e&=255);if(0>t||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;t>>>=0,n=n===void 0?this.length:n>>>0,e||(e=0);var s;if("number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var l=d.isBuffer(e)?e:d.from(e,r),c=l.length;if(0===c)throw new TypeError("The value \""+e+"\" is invalid for argument \"value\"");for(s=0;s<n-t;++s)this[s+t]=l[s%c]}return this};var te=/[^+/0-9A-Za-z-_]/g}).call(this)}).call(this,e("buffer").Buffer)},{"base64-js":2,buffer:4,ieee754:29}],5:[function(e,t,n){(function(o){(function(){function r(){return!!("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))||!("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function a(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;e.splice(1,0,n,"color: inherit");let r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,e=>{"%%"===e||(r++,"%c"===e&&(o=r))}),e.splice(o,0,n)}function s(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}}function i(){let e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&"undefined"!=typeof o&&"env"in o&&(e=o.env.DEBUG),e}function d(){try{return localStorage}catch(e){}}n.formatArgs=a,n.save=s,n.load=i,n.useColors=r,n.storage=d(),n.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],n.log=console.debug||console.log||(()=>{}),t.exports=e("./common")(n);const{formatters:l}=t.exports;l.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this)}).call(this,e("_process"))},{"./common":6,_process:32}],6:[function(e,t,r){function o(t){function r(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return o.colors[n(t)%o.colors.length]}function o(e){function t(...e){if(!t.enabled)return;const n=t,a=+new Date,s=a-(r||a);n.diff=s,n.prev=r,n.curr=a,r=a,e[0]=o.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let i=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,r)=>{if("%%"===t)return"%";i++;const a=o.formatters[r];if("function"==typeof a){const r=e[i];t=a.call(n,r),e.splice(i,1),i--}return t}),o.formatArgs.call(n,e);const d=n.log||o.log;d.apply(n,e)}let n=null,r,s,i;return t.namespace=e,t.useColors=o.useColors(),t.color=o.selectColor(e),t.extend=a,t.destroy=o.destroy,Object.defineProperty(t,"enabled",{enumerable:!0,configurable:!1,get:()=>null===n?(s!==o.namespaces&&(s=o.namespaces,i=o.enabled(e)),i):n,set:e=>{n=e}}),"function"==typeof o.init&&o.init(t),t}function a(e,t){const n=o(this.namespace+("undefined"==typeof t?":":t)+e);return n.log=this.log,n}function s(e){o.save(e),o.namespaces=e,o.names=[],o.skips=[];let t;const n=("string"==typeof e?e:"").split(/[\s,]+/),r=n.length;for(t=0;t<r;t++)n[t]&&(e=n[t].replace(/\*/g,".*?"),"-"===e[0]?o.skips.push(new RegExp("^"+e.slice(1)+"$")):o.names.push(new RegExp("^"+e+"$")))}function i(){const e=[...o.names.map(l),...o.skips.map(l).map(e=>"-"+e)].join(",");return o.enable(""),e}function d(e){if("*"===e[e.length-1])return!0;let t,n;for(t=0,n=o.skips.length;t<n;t++)if(o.skips[t].test(e))return!1;for(t=0,n=o.names.length;t<n;t++)if(o.names[t].test(e))return!0;return!1}function l(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}function c(e){return e instanceof Error?e.stack||e.message:e}function p(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return o.debug=o,o.default=o,o.coerce=c,o.disable=i,o.enable=s,o.enabled=d,o.humanize=e("ms"),o.destroy=p,Object.keys(t).forEach(e=>{o[e]=t[e]}),o.names=[],o.skips=[],o.formatters={},o.selectColor=r,o.enable(o.load()),o}t.exports=o},{ms:31}],7:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.hasCORS=void 0;let r=!1;try{r="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}n.hasCORS=r},{}],8:[function(e,t,n){"use strict";function r(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function o(e){let t={},n=e.split("&");for(let r=0,o=n.length,a;r<o;r++)a=n[r].split("="),t[decodeURIComponent(a[0])]=decodeURIComponent(a[1]);return t}Object.defineProperty(n,"__esModule",{value:!0}),n.decode=n.encode=void 0,n.encode=r,n.decode=o},{}],9:[function(e,t,n){"use strict";function r(t){const n=t,r=t.indexOf("["),l=t.indexOf("]");-1!=r&&-1!=l&&(t=t.substring(0,r)+t.substring(r,l).replace(/:/g,";")+t.substring(l,t.length));let e=s.exec(t||""),c={},p=14;for(;p--;)c[d[p]]=e[p]||"";return-1!=r&&-1!=l&&(c.source=n,c.host=c.host.substring(1,c.host.length-1).replace(/;/g,":"),c.authority=c.authority.replace("[","").replace("]","").replace(/;/g,":"),c.ipv6uri=!0),c.pathNames=o(c,c.path),c.queryKey=a(c,c.query),c}function o(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return("/"==t.substr(0,1)||0===t.length)&&r.splice(0,1),"/"==t.substr(t.length-1,1)&&r.splice(r.length-1,1),r}function a(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}Object.defineProperty(n,"__esModule",{value:!0}),n.parse=void 0;const s=/^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];n.parse=r},{}],10:[function(e,n,r){"use strict";function o(e){let n="";do n=d[e%l]+n,e=t(e/l);while(0<e);return n}function a(e){let t=0;for(u=0;u<e.length;u++)t=t*l+c[e.charAt(u)];return t}function s(){const e=o(+new Date);return e===f?e+"."+o(p++):(p=0,f=e)}Object.defineProperty(r,"__esModule",{value:!0}),r.yeast=r.decode=r.encode=void 0;const d=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","-","_"],l=64,c={};let p=0,u=0,f;for(r.encode=o,r.decode=a,r.yeast=s;u<l;u++)c[d[u]]=u},{}],11:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.globalThisShim=void 0,n.globalThisShim=(()=>"undefined"==typeof self?"undefined"==typeof window?Function("return this")():window:self)()},{}],12:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.parse=n.installTimerFunctions=n.transports=n.Transport=n.protocol=n.Socket=void 0;const r=e("./socket.js");Object.defineProperty(n,"Socket",{enumerable:!0,get:function(){return r.Socket}}),n.protocol=r.Socket.protocol;var o=e("./transport.js");Object.defineProperty(n,"Transport",{enumerable:!0,get:function(){return o.Transport}});var a=e("./transports/index.js");Object.defineProperty(n,"transports",{enumerable:!0,get:function(){return a.transports}});var s=e("./util.js");Object.defineProperty(n,"installTimerFunctions",{enumerable:!0,get:function(){return s.installTimerFunctions}});var i=e("./contrib/parseuri.js");Object.defineProperty(n,"parse",{enumerable:!0,get:function(){return i.parse}})},{"./contrib/parseuri.js":9,"./socket.js":13,"./transport.js":14,"./transports/index.js":15,"./util.js":20}],13:[function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.Socket=void 0;const o=e("./transports/index.js"),a=e("./util.js"),s=e("./contrib/parseqs.js"),i=e("./contrib/parseuri.js"),d=r(e("debug")),l=e("@socket.io/component-emitter"),c=e("engine.io-parser"),p=(0,d.default)("engine.io-client:socket");class u extends l.Emitter{constructor(e,t={}){super(),e&&"object"==typeof e&&(t=e,e=null),e?(e=(0,i.parse)(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=(0,i.parse)(t.host).host),(0,a.installTimerFunctions)(this,t),this.secure=null==t.secure?"undefined"!=typeof location&&"https:"===location.protocol:t.secure,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"==typeof location?"localhost":location.hostname),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket"],this.readyState="",this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!0},t),this.opts.path=this.opts.path.replace(/\/$/,"")+"/","string"==typeof this.opts.query&&(this.opts.query=(0,s.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",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){p("creating transport \"%s\"",e);const t=Object.assign({},this.opts.query);t.EIO=c.protocol,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts.transportOptions[e],this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port});return p("options: %j",n),new o.transports[e](n)}open(){let e;if(this.opts.rememberUpgrade&&u.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(t){return p("error while creating transport: %s",t),this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){p("setting transport %s",e.name),this.transport&&(p("clearing existing transport %s",this.transport.name),this.transport.removeAllListeners()),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",e=>this.onClose("transport close",e))}probe(e){function t(){s||(s=!0,l(),a.close(),a=null)}function n(){d("transport closed")}function r(){d("socket closed")}function o(e){a&&e.name!==a.name&&(p("\"%s\" works - aborting \"%s\"",e.name,a.name),t())}p("probing transport \"%s\"",e);let a=this.createTransport(e),s=!1;u.priorWebsocketSuccess=!1;const i=()=>{s||(p("probe transport \"%s\" opened",e),a.send([{type:"ping",data:"probe"}]),a.once("packet",t=>{if(!s)if("pong"===t.type&&"probe"===t.data){if(p("probe transport \"%s\" pong",e),this.upgrading=!0,this.emitReserved("upgrading",a),!a)return;u.priorWebsocketSuccess="websocket"===a.name,p("pausing current transport \"%s\"",this.transport.name),this.transport.pause(()=>{s||"closed"===this.readyState||(p("changing transport and sending upgrade packet"),l(),this.setTransport(a),a.send([{type:"upgrade"}]),this.emitReserved("upgrade",a),a=null,this.upgrading=!1,this.flush())})}else{p("probe transport \"%s\" failed",e);const t=new Error("probe error");t.transport=a.name,this.emitReserved("upgradeError",t)}}))},d=n=>{const r=new Error("probe error: "+n);r.transport=a.name,t(),p("probe transport \"%s\" failed because of error: %s",e,n),this.emitReserved("upgradeError",r)},l=()=>{a.removeListener("open",i),a.removeListener("error",d),a.removeListener("close",n),this.off("close",r),this.off("upgrading",o)};a.once("open",i),a.once("error",d),a.once("close",n),this.once("close",r),this.once("upgrading",o),a.open()}onOpen(){if(p("socket open"),this.readyState="open",u.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade&&this.transport.pause){p("starting upgrade probes");let e=0;for(const t=this.upgrades.length;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(p("socket receive: type \"%s\", data \"%s\"",e.type,e.data),this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.resetPingTimeout(),this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data);}else p("packet received with socket readyState \"%s\"",this.readyState)}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,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.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();p("flushing %d packets in socket",e.length),this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){const e=this.maxPayload&&"polling"===this.transport.name&&1<this.writeBuffer.length;if(!e)return this.writeBuffer;let t=1;for(let e=0;e<this.writeBuffer.length;e++){const n=this.writeBuffer[e].data;if(n&&(t+=(0,a.byteLength)(n)),0<e&&t>this.maxPayload)return p("only send %d out of %d packets",e,this.writeBuffer.length),this.writeBuffer.slice(0,e);t+=2}return p("payload size is %d (max: %d)",t,this.maxPayload),this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"!==this.readyState&&"closed"!==this.readyState){n=n||{},n.compress=!1!==n.compress;const o={type:e,data:t,options:n};this.emitReserved("packetCreate",o),this.writeBuffer.push(o),r&&this.once("flush",r),this.flush()}}close(){const e=()=>{this.onClose("forced close"),p("socket closing - telling transport to close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return("opening"===this.readyState||"open"===this.readyState)&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}onError(e){p("socket error %j",e),u.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)&&(p("socket close with reason: \"%s\"",e),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.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;for(const r=e.length;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}n.Socket=u,u.protocol=c.protocol},{"./contrib/parseqs.js":8,"./contrib/parseuri.js":9,"./transports/index.js":15,"./util.js":20,"@socket.io/component-emitter":1,debug:5,"engine.io-parser":25}],14:[function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.Transport=void 0;const o=e("engine.io-parser"),a=e("@socket.io/component-emitter"),s=e("./util.js"),i=r(e("debug")),d=(0,i.default)("engine.io-client:transport");class l extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class c extends a.Emitter{constructor(e){super(),this.writable=!1,(0,s.installTimerFunctions)(this,e),this.opts=e,this.query=e.query,this.readyState="",this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new l(e,t,n)),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(e){"open"===this.readyState?this.write(e):d("transport is not open, discarding packets")}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=(0,o.decodePacket)(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}}n.Transport=c},{"./util.js":20,"@socket.io/component-emitter":1,debug:5,"engine.io-parser":25}],15:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.transports=void 0;const r=e("./polling.js"),o=e("./websocket.js");n.transports={websocket:o.WS,polling:r.Polling}},{"./polling.js":16,"./websocket.js":18}],16:[function(e,t,n){"use strict";function r(){}function o(){for(let e in y.requests)y.requests.hasOwnProperty(e)&&y.requests[e].abort()}var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.Request=n.Polling=void 0;const s=e("../transport.js"),i=a(e("debug")),d=e("../contrib/yeast.js"),l=e("../contrib/parseqs.js"),c=e("engine.io-parser"),p=e("./xmlhttprequest.js"),u=e("@socket.io/component-emitter"),f=e("../util.js"),g=e("../globalThis.js"),m=(0,i.default)("engine.io-client:polling"),h=function(){const e=new p.XHR({xdomain:!1});return null!=e.responseType}();class _ extends s.Transport{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port,this.xs=e.secure!==t}const t=e&&e.forceBase64;this.supportsBinary=h&&!t}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{m("paused"),this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(m("we are currently polling - waiting to pause"),e++,this.once("pollComplete",function(){m("pre-pause polling complete"),--e||t()})),this.writable||(m("we are currently writing - waiting to pause"),e++,this.once("drain",function(){m("pre-pause writing complete"),--e||t()}))}else t()}poll(){m("polling"),this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){m("polling got data %s",e);const t=e=>("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type?(this.onClose({description:"transport closed by the server"}),!1):void this.onPacket(e));(0,c.decodePayload)(e,this.socket.binaryType).forEach(t),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState?this.poll():m("ignoring poll - transport state \"%s\"",this.readyState))}doClose(){const e=()=>{m("writing close packet"),this.write([{type:"close"}])};"open"===this.readyState?(m("transport open - closing"),e()):(m("transport not open - deferring close"),this.once("open",e))}write(e){this.writable=!1,(0,c.encodePayload)(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){let e=this.query||{};const t=this.opts.secure?"https":"http";let n="";!1!==this.opts.timestampRequests&&(e[this.opts.timestampParam]=(0,d.yeast)()),this.supportsBinary||e.sid||(e.b64=1),this.opts.port&&("https"===t&&443!==+this.opts.port||"http"===t&&80!==+this.opts.port)&&(n=":"+this.opts.port);const r=(0,l.encode)(e),o=-1!==this.opts.hostname.indexOf(":");return t+"://"+(o?"["+this.opts.hostname+"]":this.opts.hostname)+n+this.opts.path+(r.length?"?"+r:"")}request(e={}){return Object.assign(e,{xd:this.xd,xs:this.xs},this.opts),new y(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){m("xhr poll");const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}n.Polling=_;class y extends u.Emitter{constructor(e,t){super(),(0,f.installTimerFunctions)(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.async=!1!==t.async,this.data=void 0===t.data?null:t.data,this.create()}create(){const e=(0,f.pick)(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");e.xdomain=!!this.opts.xd,e.xscheme=!!this.opts.xs;const t=this.xhr=new p.XHR(e);try{m("xhr open %s: %s",this.method,this.uri),t.open(this.method,this.uri,this.async);try{if(this.opts.extraHeaders)for(let e in t.setDisableHeaderCheck&&t.setDisableHeaderCheck(!0),this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&t.setRequestHeader(e,this.opts.extraHeaders[e])}catch(t){}if("POST"===this.method)try{t.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(t){}try{t.setRequestHeader("Accept","*/*")}catch(t){}"withCredentials"in t&&(t.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(t.timeout=this.opts.requestTimeout),t.onreadystatechange=()=>{4!==t.readyState||(200===t.status||1223===t.status?this.onLoad():this.setTimeoutFn(()=>{this.onError("number"==typeof t.status?t.status:0)},0))},m("xhr data %s",this.data),t.send(this.data)}catch(t){return void this.setTimeoutFn(()=>{this.onError(t)},0)}"undefined"!=typeof document&&(this.index=y.requestsCount++,y.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if("undefined"!=typeof this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=r,e)try{this.xhr.abort()}catch(t){}"undefined"!=typeof document&&delete y.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(n.Request=y,y.requestsCount=0,y.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",o);else if("function"==typeof addEventListener){const e="onpagehide"in g.globalThisShim?"pagehide":"unload";addEventListener(e,o,!1)}},{"../contrib/parseqs.js":8,"../contrib/yeast.js":10,"../globalThis.js":11,"../transport.js":14,"../util.js":20,"./xmlhttprequest.js":19,"@socket.io/component-emitter":1,debug:5,"engine.io-parser":25}],17:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.defaultBinaryType=n.usingBrowserWebSocket=n.WebSocket=n.nextTick=void 0;const r=e("../globalThis.js");n.nextTick=(()=>{const e="function"==typeof Promise&&"function"==typeof Promise.resolve;return e?e=>Promise.resolve().then(e):(e,t)=>t(e,0)})(),n.WebSocket=r.globalThisShim.WebSocket||r.globalThisShim.MozWebSocket,n.usingBrowserWebSocket=!0,n.defaultBinaryType="arraybuffer"},{"../globalThis.js":11}],18:[function(e,t,n){(function(t){(function(){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.WS=void 0;const o=e("../transport.js"),a=e("../contrib/parseqs.js"),s=e("../contrib/yeast.js"),i=e("../util.js"),d=e("./websocket-constructor.js"),l=r(e("debug")),c=e("engine.io-parser"),p=(0,l.default)("engine.io-client:websocket"),u="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class f extends o.Transport{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=u?{}:(0,i.pick)(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=d.usingBrowserWebSocket&&!u?t?new d.WebSocket(e,t):ne