UNPKG

inertialrush-game-test

Version:

This package enables the integration of the Inertial Rush game into any React application, making it easy to showcase the game.

1,527 lines (1,526 loc) 91.2 kB
/*! * Socket.IO v4.5.0 * (c) 2014-2022 Guillermo Rauch * Released under the MIT License. */ !(function (t, e) { "object" == typeof exports && "undefined" != typeof module ? (module.exports = e()) : "function" == typeof define && define.amd ? define(e) : ((t = "undefined" != typeof globalThis ? globalThis : t || self).io = e()); })(this, function () { "use strict"; function t(t, e) { return ( e.forEach(function (e) { Object.keys(e).forEach(function (n) { if ("default" !== n && !(n in t)) { var r = Object.getOwnPropertyDescriptor(e, n); Object.defineProperty( t, n, r.get ? r : { enumerable: !0, get: function () { return e[n]; }, } ); } }); }), Object.freeze(t) ); } function e(t) { return ( (e = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (t) { return typeof t; } : function (t) { return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t; }), e(t) ); } function n(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); } function r(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; (r.enumerable = r.enumerable || !1), (r.configurable = !0), "value" in r && (r.writable = !0), Object.defineProperty(t, r.key, r); } } function i(t, e, n) { return e && r(t.prototype, e), n && r(t, n), t; } function s() { return ( (s = Object.assign || function (t) { for (var e = 1; e < arguments.length; e++) { var n = arguments[e]; for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]); } return t; }), s.apply(this, arguments) ); } function o(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); (t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 }, })), e && c(t, e); } function a(t) { return ( (a = Object.setPrototypeOf ? Object.getPrototypeOf : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }), a(t) ); } function c(t, e) { return ( (c = Object.setPrototypeOf || function (t, e) { return (t.__proto__ = e), t; }), c(t, e) ); } function u() { if ("undefined" == typeof Reflect || !Reflect.construct) return !1; if (Reflect.construct.sham) return !1; if ("function" == typeof Proxy) return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0; } catch (t) { return !1; } } function h(t, e, n) { return ( (h = u() ? Reflect.construct : function (t, e, n) { var r = [null]; r.push.apply(r, e); var i = new (Function.bind.apply(t, r))(); return n && c(i, n.prototype), i; }), h.apply(null, arguments) ); } function f(t) { var e = "function" == typeof Map ? new Map() : void 0; return ( (f = function (t) { if (null === t || ((n = t), -1 === Function.toString.call(n).indexOf("[native code]"))) return t; var n; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== e) { if (e.has(t)) return e.get(t); e.set(t, r); } function r() { return h(t, arguments, a(this).constructor); } return ( (r.prototype = Object.create(t.prototype, { constructor: { value: r, enumerable: !1, writable: !0, configurable: !0 }, })), c(r, t) ); }), f(t) ); } function l(t) { if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t; } function p(t, e) { if (e && ("object" == typeof e || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return l(t); } function d(t) { var e = u(); return function () { var n, r = a(t); if (e) { var i = a(this).constructor; n = Reflect.construct(r, arguments, i); } else n = r.apply(this, arguments); return p(this, n); }; } function y(t, e, n) { return ( (y = "undefined" != typeof Reflect && Reflect.get ? Reflect.get : function (t, e, n) { var r = (function (t, e) { for (; !Object.prototype.hasOwnProperty.call(t, e) && null !== (t = a(t)); ); return t; })(t, e); if (r) { var i = Object.getOwnPropertyDescriptor(r, e); return i.get ? i.get.call(n) : i.value; } }), y(t, e, n || t) ); } function v(t, e) { (null == e || e > t.length) && (e = t.length); for (var n = 0, r = new Array(e); n < e; n++) r[n] = t[n]; return r; } function g(t, e) { var n = ("undefined" != typeof Symbol && t[Symbol.iterator]) || t["@@iterator"]; if (!n) { if ( Array.isArray(t) || (n = (function (t, e) { if (t) { if ("string" == typeof t) return v(t, e); var n = Object.prototype.toString.call(t).slice(8, -1); return ( "Object" === n && t.constructor && (n = t.constructor.name), "Map" === n || "Set" === n ? Array.from(t) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? v(t, e) : void 0 ); } })(t)) || (e && t && "number" == typeof t.length) ) { n && (t = n); var r = 0, i = function () {}; return { s: i, n: function () { return r >= t.length ? { done: !0 } : { done: !1, value: t[r++] }; }, e: function (t) { throw t; }, f: i, }; } throw new TypeError( "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ); } var s, o = !0, a = !1; return { s: function () { n = n.call(t); }, n: function () { var t = n.next(); return (o = t.done), t; }, e: function (t) { (a = !0), (s = t); }, f: function () { try { o || null == n.return || n.return(); } finally { if (a) throw s; } }, }; } var m = Object.create(null); (m.open = "0"), (m.close = "1"), (m.ping = "2"), (m.pong = "3"), (m.message = "4"), (m.upgrade = "5"), (m.noop = "6"); var _ = Object.create(null); Object.keys(m).forEach(function (t) { _[m[t]] = t; }); for ( var b = { type: "error", data: "parser error" }, k = "function" == typeof Blob || ("undefined" != typeof Blob && "[object BlobConstructor]" === Object.prototype.toString.call(Blob)), w = "function" == typeof ArrayBuffer, O = function (t, e, n) { var r, i = t.type, s = t.data; return k && s instanceof Blob ? e ? n(s) : E(s, n) : w && (s instanceof ArrayBuffer || ((r = s), "function" == typeof ArrayBuffer.isView ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer)) ? e ? n(s) : E(new Blob([s]), n) : n(m[i] + (s || "")); }, E = function (t, e) { var n = new FileReader(); return ( (n.onload = function () { var t = n.result.split(",")[1]; e("b" + t); }), n.readAsDataURL(t) ); }, C = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", R = "undefined" == typeof Uint8Array ? [] : new Uint8Array(256), T = 0; T < C.length; T++ ) R[C.charCodeAt(T)] = T; var S = "function" == typeof ArrayBuffer, A = function (t, e) { if ("string" != typeof t) return { type: "message", data: x(t, e) }; var n = t.charAt(0); return "b" === n ? { type: "message", data: L(t.substring(1), e) } : _[n] ? t.length > 1 ? { type: _[n], data: t.substring(1) } : { type: _[n] } : b; }, L = function (t, e) { if (S) { var n = (function (t) { var e, n, r, i, s, o = 0.75 * t.length, a = t.length, c = 0; "=" === t[t.length - 1] && (o--, "=" === t[t.length - 2] && o--); var u = new ArrayBuffer(o), h = new Uint8Array(u); for (e = 0; e < a; e += 4) (n = R[t.charCodeAt(e)]), (r = R[t.charCodeAt(e + 1)]), (i = R[t.charCodeAt(e + 2)]), (s = R[t.charCodeAt(e + 3)]), (h[c++] = (n << 2) | (r >> 4)), (h[c++] = ((15 & r) << 4) | (i >> 2)), (h[c++] = ((3 & i) << 6) | (63 & s)); return u; })(t); return x(n, e); } return { base64: !0, data: t }; }, x = function (t, e) { return "blob" === e && t instanceof ArrayBuffer ? new Blob([t]) : t; }, B = String.fromCharCode(30); function U(t) { if (t) return (function (t) { for (var e in U.prototype) t[e] = U.prototype[e]; return t; })(t); } (U.prototype.on = U.prototype.addEventListener = function (t, e) { return ( (this._callbacks = this._callbacks || {}), (this._callbacks["$" + t] = this._callbacks["$" + t] || []).push(e), this ); }), (U.prototype.once = function (t, e) { function n() { this.off(t, n), e.apply(this, arguments); } return (n.fn = e), this.on(t, n), this; }), (U.prototype.off = U.prototype.removeListener = U.prototype.removeAllListeners = U.prototype.removeEventListener = function (t, e) { if (((this._callbacks = this._callbacks || {}), 0 == arguments.length)) return (this._callbacks = {}), this; var n, r = this._callbacks["$" + t]; if (!r) return this; if (1 == arguments.length) return delete this._callbacks["$" + t], this; for (var i = 0; i < r.length; i++) if ((n = r[i]) === e || n.fn === e) { r.splice(i, 1); break; } return 0 === r.length && delete this._callbacks["$" + t], this; }), (U.prototype.emit = function (t) { this._callbacks = this._callbacks || {}; for ( var e = new Array(arguments.length - 1), n = this._callbacks["$" + t], r = 1; r < arguments.length; r++ ) e[r - 1] = arguments[r]; if (n) { r = 0; for (var i = (n = n.slice(0)).length; r < i; ++r) n[r].apply(this, e); } return this; }), (U.prototype.emitReserved = U.prototype.emit), (U.prototype.listeners = function (t) { return (this._callbacks = this._callbacks || {}), this._callbacks["$" + t] || []; }), (U.prototype.hasListeners = function (t) { return !!this.listeners(t).length; }); var j = "undefined" != typeof self ? self : "undefined" != typeof window ? window : Function("return this")(); function P(t) { for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++) n[r - 1] = arguments[r]; return n.reduce(function (e, n) { return t.hasOwnProperty(n) && (e[n] = t[n]), e; }, {}); } var N = setTimeout, q = clearTimeout; function M(t, e) { e.useNativeTimers ? ((t.setTimeoutFn = N.bind(j)), (t.clearTimeoutFn = q.bind(j))) : ((t.setTimeoutFn = setTimeout.bind(j)), (t.clearTimeoutFn = clearTimeout.bind(j))); } var D, I = (function (t) { o(r, t); var e = d(r); function r(t, i, s) { var o; return ( n(this, r), ((o = e.call(this, t)).description = i), (o.context = s), (o.type = "TransportError"), o ); } return r; })(f(Error)), F = (function (t) { o(r, t); var e = d(r); function r(t) { var i; return ( n(this, r), ((i = e.call(this)).writable = !1), M(l(i), t), (i.opts = t), (i.query = t.query), (i.readyState = ""), (i.socket = t.socket), i ); } return ( i(r, [ { key: "onError", value: function (t, e, n) { return ( y(a(r.prototype), "emitReserved", this).call(this, "error", new I(t, e, n)), this ); }, }, { key: "open", value: function () { return ( ("closed" !== this.readyState && "" !== this.readyState) || ((this.readyState = "opening"), this.doOpen()), this ); }, }, { key: "close", value: function () { return ( ("opening" !== this.readyState && "open" !== this.readyState) || (this.doClose(), this.onClose()), this ); }, }, { key: "send", value: function (t) { "open" === this.readyState && this.write(t); }, }, { key: "onOpen", value: function () { (this.readyState = "open"), (this.writable = !0), y(a(r.prototype), "emitReserved", this).call(this, "open"); }, }, { key: "onData", value: function (t) { var e = A(t, this.socket.binaryType); this.onPacket(e); }, }, { key: "onPacket", value: function (t) { y(a(r.prototype), "emitReserved", this).call(this, "packet", t); }, }, { key: "onClose", value: function (t) { (this.readyState = "closed"), y(a(r.prototype), "emitReserved", this).call(this, "close", t); }, }, ]), r ); })(U), H = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""), $ = {}, z = 0, V = 0; function W(t) { var e = ""; do { (e = H[t % 64] + e), (t = Math.floor(t / 64)); } while (t > 0); return e; } function X() { var t = W(+new Date()); return t !== D ? ((z = 0), (D = t)) : t + "." + W(z++); } for (; V < 64; V++) $[H[V]] = V; function K(t) { var e = ""; for (var n in t) t.hasOwnProperty(n) && (e.length && (e += "&"), (e += encodeURIComponent(n) + "=" + encodeURIComponent(t[n]))); return e; } function J(t) { for (var e = {}, n = t.split("&"), r = 0, i = n.length; r < i; r++) { var s = n[r].split("="); e[decodeURIComponent(s[0])] = decodeURIComponent(s[1]); } return e; } var Y = !1; try { Y = "undefined" != typeof XMLHttpRequest && "withCredentials" in new XMLHttpRequest(); } catch (t) {} var G = Y; function Q(t) { var e = t.xdomain; try { if ("undefined" != typeof XMLHttpRequest && (!e || G)) return new XMLHttpRequest(); } catch (t) {} if (!e) try { return new j[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); } catch (t) {} } function Z() {} var tt = null != new Q({ xdomain: !1 }).responseType, et = (function (t) { o(r, t); var e = d(r); function r(t) { var i; if ((n(this, r), ((i = e.call(this, t)).polling = !1), "undefined" != typeof location)) { var s = "https:" === location.protocol, o = location.port; o || (o = s ? "443" : "80"), (i.xd = ("undefined" != typeof location && t.hostname !== location.hostname) || o !== t.port), (i.xs = t.secure !== s); } var a = t && t.forceBase64; return (i.supportsBinary = tt && !a), i; } return ( i(r, [ { key: "name", get: function () { return "polling"; }, }, { key: "doOpen", value: function () { this.poll(); }, }, { key: "pause", value: function (t) { var e = this; this.readyState = "pausing"; var n = function () { (e.readyState = "paused"), t(); }; if (this.polling || !this.writable) { var r = 0; this.polling && (r++, this.once("pollComplete", function () { --r || n(); })), this.writable || (r++, this.once("drain", function () { --r || n(); })); } else n(); }, }, { key: "poll", value: function () { (this.polling = !0), this.doPoll(), this.emitReserved("poll"); }, }, { key: "onData", value: function (t) { var e = this; (function (t, e) { for (var n = t.split(B), r = [], i = 0; i < n.length; i++) { var s = A(n[i], e); if ((r.push(s), "error" === s.type)) break; } return r; })(t, this.socket.binaryType).forEach(function (t) { if ( ("opening" === e.readyState && "open" === t.type && e.onOpen(), "close" === t.type) ) return e.onClose({ description: "transport closed by the server" }), !1; e.onPacket(t); }), "closed" !== this.readyState && ((this.polling = !1), this.emitReserved("pollComplete"), "open" === this.readyState && this.poll()); }, }, { key: "doClose", value: function () { var t = this, e = function () { t.write([{ type: "close" }]); }; "open" === this.readyState ? e() : this.once("open", e); }, }, { key: "write", value: function (t) { var e = this; (this.writable = !1), (function (t, e) { var n = t.length, r = new Array(n), i = 0; t.forEach(function (t, s) { O(t, !1, function (t) { (r[s] = t), ++i === n && e(r.join(B)); }); }); })(t, function (t) { e.doWrite(t, function () { (e.writable = !0), e.emitReserved("drain"); }); }); }, }, { key: "uri", value: function () { var t = this.query || {}, e = this.opts.secure ? "https" : "http", n = ""; !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = X()), this.supportsBinary || t.sid || (t.b64 = 1), this.opts.port && (("https" === e && 443 !== Number(this.opts.port)) || ("http" === e && 80 !== Number(this.opts.port))) && (n = ":" + this.opts.port); var r = K(t); return ( e + "://" + (-1 !== this.opts.hostname.indexOf(":") ? "[" + this.opts.hostname + "]" : this.opts.hostname) + n + this.opts.path + (r.length ? "?" + r : "") ); }, }, { key: "request", value: function () { var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}; return s(t, { xd: this.xd, xs: this.xs }, this.opts), new nt(this.uri(), t); }, }, { key: "doWrite", value: function (t, e) { var n = this, r = this.request({ method: "POST", data: t }); r.on("success", e), r.on("error", function (t, e) { n.onError("xhr post error", t, e); }); }, }, { key: "doPoll", value: function () { var t = this, e = this.request(); e.on("data", this.onData.bind(this)), e.on("error", function (e, n) { t.onError("xhr poll error", e, n); }), (this.pollXhr = e); }, }, ]), r ); })(F), nt = (function (t) { o(r, t); var e = d(r); function r(t, i) { var s; return ( n(this, r), M(l((s = e.call(this))), i), (s.opts = i), (s.method = i.method || "GET"), (s.uri = t), (s.async = !1 !== i.async), (s.data = void 0 !== i.data ? i.data : null), s.create(), s ); } return ( i(r, [ { key: "create", value: function () { var t = this, e = P( this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref" ); (e.xdomain = !!this.opts.xd), (e.xscheme = !!this.opts.xs); var n = (this.xhr = new Q(e)); try { n.open(this.method, this.uri, this.async); try { if (this.opts.extraHeaders) for (var i in (n.setDisableHeaderCheck && n.setDisableHeaderCheck(!0), this.opts.extraHeaders)) this.opts.extraHeaders.hasOwnProperty(i) && n.setRequestHeader(i, this.opts.extraHeaders[i]); } catch (t) {} if ("POST" === this.method) try { n.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); } catch (t) {} try { n.setRequestHeader("Accept", "*/*"); } catch (t) {} "withCredentials" in n && (n.withCredentials = this.opts.withCredentials), this.opts.requestTimeout && (n.timeout = this.opts.requestTimeout), (n.onreadystatechange = function () { 4 === n.readyState && (200 === n.status || 1223 === n.status ? t.onLoad() : t.setTimeoutFn(function () { t.onError("number" == typeof n.status ? n.status : 0); }, 0)); }), n.send(this.data); } catch (e) { return void this.setTimeoutFn(function () { t.onError(e); }, 0); } "undefined" != typeof document && ((this.index = r.requestsCount++), (r.requests[this.index] = this)); }, }, { key: "onError", value: function (t) { this.emitReserved("error", t, this.xhr), this.cleanup(!0); }, }, { key: "cleanup", value: function (t) { if (void 0 !== this.xhr && null !== this.xhr) { if (((this.xhr.onreadystatechange = Z), t)) try { this.xhr.abort(); } catch (t) {} "undefined" != typeof document && delete r.requests[this.index], (this.xhr = null); } }, }, { key: "onLoad", value: function () { var t = this.xhr.responseText; null !== t && (this.emitReserved("data", t), this.emitReserved("success"), this.cleanup()); }, }, { key: "abort", value: function () { this.cleanup(); }, }, ]), r ); })(U); if (((nt.requestsCount = 0), (nt.requests = {}), "undefined" != typeof document)) if ("function" == typeof attachEvent) attachEvent("onunload", rt); else if ("function" == typeof addEventListener) { addEventListener("onpagehide" in j ? "pagehide" : "unload", rt, !1); } function rt() { for (var t in nt.requests) nt.requests.hasOwnProperty(t) && nt.requests[t].abort(); } var it = "function" == typeof Promise && "function" == typeof Promise.resolve ? function (t) { return Promise.resolve().then(t); } : function (t, e) { return e(t, 0); }, st = j.WebSocket || j.MozWebSocket, ot = "undefined" != typeof navigator && "string" == typeof navigator.product && "reactnative" === navigator.product.toLowerCase(), at = (function (t) { o(r, t); var e = d(r); function r(t) { var i; return n(this, r), ((i = e.call(this, t)).supportsBinary = !t.forceBase64), i; } return ( i(r, [ { key: "name", get: function () { return "websocket"; }, }, { key: "doOpen", value: function () { if (this.check()) { var t = this.uri(), e = this.opts.protocols, n = ot ? {} : P( 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 = ot ? new st(t, e, n) : e ? new st(t, e) : new st(t); } catch (t) { return this.emitReserved("error", t); } (this.ws.binaryType = this.socket.binaryType || "arraybuffer"), this.addEventListeners(); } }, }, { key: "addEventListeners", value: function () { var t = this; (this.ws.onopen = function () { t.opts.autoUnref && t.ws._socket.unref(), t.onOpen(); }), (this.ws.onclose = function (e) { return t.onClose({ description: "websocket connection closed", context: e }); }), (this.ws.onmessage = function (e) { return t.onData(e.data); }), (this.ws.onerror = function (e) { return t.onError("websocket error", e); }); }, }, { key: "write", value: function (t) { var e = this; this.writable = !1; for ( var n = function (n) { var r = t[n], i = n === t.length - 1; O(r, e.supportsBinary, function (t) { try { e.ws.send(t); } catch (t) {} i && it(function () { (e.writable = !0), e.emitReserved("drain"); }, e.setTimeoutFn); }); }, r = 0; r < t.length; r++ ) n(r); }, }, { key: "doClose", value: function () { void 0 !== this.ws && (this.ws.close(), (this.ws = null)); }, }, { key: "uri", value: function () { var t = this.query || {}, e = this.opts.secure ? "wss" : "ws", n = ""; this.opts.port && (("wss" === e && 443 !== Number(this.opts.port)) || ("ws" === e && 80 !== Number(this.opts.port))) && (n = ":" + this.opts.port), this.opts.timestampRequests && (t[this.opts.timestampParam] = X()), this.supportsBinary || (t.b64 = 1); var r = K(t); return ( e + "://" + (-1 !== this.opts.hostname.indexOf(":") ? "[" + this.opts.hostname + "]" : this.opts.hostname) + n + this.opts.path + (r.length ? "?" + r : "") ); }, }, { key: "check", value: function () { return !(!st || ("__initialize" in st && this.name === r.prototype.name)); }, }, ]), r ); })(F), ct = { websocket: at, polling: et }, ut = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, ht = [ "source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor", ]; function ft(t) { var e = t, n = t.indexOf("["), r = t.indexOf("]"); -1 != n && -1 != r && (t = t.substring(0, n) + t.substring(n, r).replace(/:/g, ";") + t.substring(r, t.length)); for (var i, s, o = ut.exec(t || ""), a = {}, c = 14; c--; ) a[ht[c]] = o[c] || ""; return ( -1 != n && -1 != r && ((a.source = e), (a.host = a.host.substring(1, a.host.length - 1).replace(/;/g, ":")), (a.authority = a.authority.replace("[", "").replace("]", "").replace(/;/g, ":")), (a.ipv6uri = !0)), (a.pathNames = (function (t, e) { var n = /\/{2,9}/g, r = e.replace(n, "/").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, a.path)), (a.queryKey = ((i = a.query), (s = {}), i.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function (t, e, n) { e && (s[e] = n); }), s)), a ); } var lt = (function (t) { o(a, t); var r = d(a); function a(t) { var i, o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; return ( n(this, a), (i = r.call(this)), t && "object" === e(t) && ((o = t), (t = null)), t ? ((t = ft(t)), (o.hostname = t.host), (o.secure = "https" === t.protocol || "wss" === t.protocol), (o.port = t.port), t.query && (o.query = t.query)) : o.host && (o.hostname = ft(o.host).host), M(l(i), o), (i.secure = null != o.secure ? o.secure : "undefined" != typeof location && "https:" === location.protocol), o.hostname && !o.port && (o.port = i.secure ? "443" : "80"), (i.hostname = o.hostname || ("undefined" != typeof location ? location.hostname : "localhost")), (i.port = o.port || ("undefined" != typeof location && location.port ? location.port : i.secure ? "443" : "80")), (i.transports = o.transports || ["polling", "websocket"]), (i.readyState = ""), (i.writeBuffer = []), (i.prevBufferLen = 0), (i.opts = s( { path: "/engine.io", agent: !1, withCredentials: !1, upgrade: !0, timestampParam: "t", rememberUpgrade: !1, rejectUnauthorized: !0, perMessageDeflate: { threshold: 1024 }, transportOptions: {}, closeOnBeforeunload: !0, }, o )), (i.opts.path = i.opts.path.replace(/\/$/, "") + "/"), "string" == typeof i.opts.query && (i.opts.query = J(i.opts.query)), (i.id = null), (i.upgrades = null), (i.pingInterval = null), (i.pingTimeout = null), (i.pingTimeoutTimer = null), "function" == typeof addEventListener && (i.opts.closeOnBeforeunload && addEventListener( "beforeunload", function () { i.transport && (i.transport.removeAllListeners(), i.transport.close()); }, !1 ), "localhost" !== i.hostname && ((i.offlineEventListener = function () { i.onClose("transport close", { description: "network connection lost" }); }), addEventListener("offline", i.offlineEventListener, !1))), i.open(), i ); } return ( i(a, [ { key: "createTransport", value: function (t) { var e = s({}, this.opts.query); (e.EIO = 4), (e.transport = t), this.id && (e.sid = this.id); var n = s({}, this.opts.transportOptions[t], this.opts, { query: e, socket: this, hostname: this.hostname, secure: this.secure, port: this.port, }); return new ct[t](n); }, }, { key: "open", value: function () { var t, e = this; if ( this.opts.rememberUpgrade && a.priorWebsocketSuccess && -1 !== this.transports.indexOf("websocket") ) t = "websocket"; else { if (0 === this.transports.length) return void this.setTimeoutFn(function () { e.emitReserved("error", "No transports available"); }, 0); t = this.transports[0]; } this.readyState = "opening"; try { t = this.createTransport(t); } catch (t) { return this.transports.shift(), void this.open(); } t.open(), this.setTransport(t); }, }, { key: "setTransport", value: function (t) { var e = this; this.transport && 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", function (t) { return e.onClose("transport close", t); }); }, }, { key: "probe", value: function (t) { var e = this, n = this.createTransport(t), r = !1; a.priorWebsocketSuccess = !1; var i = function () { r || (n.send([{ type: "ping", data: "probe" }]), n.once("packet", function (t) { if (!r) if ("pong" === t.type && "probe" === t.data) { if (((e.upgrading = !0), e.emitReserved("upgrading", n), !n)) return; (a.priorWebsocketSuccess = "websocket" === n.name), e.transport.pause(function () { r || ("closed" !== e.readyState && (f(), e.setTransport(n), n.send([{ type: "upgrade" }]), e.emitReserved("upgrade", n), (n = null), (e.upgrading = !1), e.flush())); }); } else { var i = new Error("probe error"); (i.transport = n.name), e.emitReserved("upgradeError", i); } })); }; function s() { r || ((r = !0), f(), n.close(), (n = null)); } var o = function (t) { var r = new Error("probe error: " + t); (r.transport = n.name), s(), e.emitReserved("upgradeError", r); }; function c() { o("transport closed"); } function u() { o("socket closed"); } function h(t) { n && t.name !== n.name && s(); } var f = function () { n.removeListener("open", i), n.removeListener("error", o), n.removeListener("close", c), e.off("close", u), e.off("upgrading", h); }; n.once("open", i), n.once("error", o), n.once("close", c), this.once("close", u), this.once("upgrading", h), n.open(); }, }, { key: "onOpen", value: function () { if ( ((this.readyState = "open"), (a.priorWebsocketSuccess = "websocket" === this.transport.name), this.emitReserved("open"), this.flush(), "open" === this.readyState && this.opts.upgrade && this.transport.pause) ) for (var t = 0, e = this.upgrades.length; t < e; t++) this.probe(this.upgrades[t]); }, }, { key: "onPacket", value: function (t) { if ( "opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState ) switch ((this.emitReserved("packet", t), this.emitReserved("heartbeat"), t.type)) { case "open": this.onHandshake(JSON.parse(t.data)); break; case "ping": this.resetPingTimeout(), this.sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"); break; case "error": var e = new Error("server error"); (e.code = t.data), this.onError(e); break; case "message": this.emitReserved("data", t.data), this.emitReserved("message", t.data); } }, }, { key: "onHandshake", value: function (t) { this.emitReserved("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.maxPayload = t.maxPayload), this.onOpen(), "closed" !== this.readyState && this.resetPingTimeout(); }, }, { key: "resetPingTimeout", value: function () { var t = this; this.clearTimeoutFn(this.pingTimeoutTimer), (this.pingTimeoutTimer = this.setTimeoutFn(function () { t.onClose("ping timeout"); }, this.pingInterval + this.pingTimeout)), this.opts.autoUnref && this.pingTimeoutTimer.unref(); }, }, { key: "onDrain", value: function () { this.writeBuffer.splice(0, this.prevBufferLen), (this.prevBufferLen = 0), 0 === this.writeBuffer.length ? this.emitReserved("drain") : this.flush(); }, }, { key: "flush", value: function () { if ( "closed" !== this.readyState && this.transport.writable && !this.upgrading && this.writeBuffer.length ) { var t = this.getWritablePackets(); this.transport.send(t), (this.prevBufferLen = t.length), this.emitReserved("flush"); } }, }, { key: "getWritablePackets", value: function () { if ( !(this.maxPayload && "polling" === this.transport.name && this.writeBuffer.length > 1) ) return this.writeBuffer; for (var t, e = 1, n = 0; n < this.writeBuffer.length; n++) { var r = this.writeBuffer[n].data; if ( (r && (e += "string" == typeof (t = r) ? (function (t) { for (var e = 0, n = 0, r = 0, i = t.length; r < i; r++) (e = t.charCodeAt(r)) < 128 ? (n += 1) : e < 2048 ? (n += 2) : e < 55296 || e >= 57344 ? (n += 3) : (r++, (n += 4)); return n; })(t) : Math.ceil(1.33 * (t.byteLength || t.size))), n > 0 && e > this.maxPayload) ) return this.writeBuffer.slice(0, n); e += 2; } return this.writeBuffer; }, }, { key: "write", value: function (t, e, n) { return this.sendPacket("message", t, e, n), this; }, }, { key: "send", value: function (t, e, n) { return this.sendPacket("message", t, e, n), this; }, }, { key: "sendPacket", value: function (t, e, n, r) { if ( ("function" == typeof e && ((r = e), (e = void 0)), "function" == typeof n && ((r = n), (n = null)), "closing" !== this.readyState && "closed" !== this.readyState) ) { (n = n || {}).compress = !1 !== n.compress; var i = { type: t, data: e, options: n }; this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush(); } }, }, { key: "close", value: function () { var t = this, e = function () { t.onClose("forced close"), t.transport.close(); }, n = function n() { t.off("upgrade", n), t.off("upgradeError", n), e(); }, r = function () { t.once("upgrade", n), t.once("upgradeError", n); }; return ( ("opening" !== this.readyState && "open" !== this.readyState) || ((this.readyState = "closing"), this.writeBuffer.length ? this.once("drain", function () { t.upgrading ? r() : e(); }) : this.upgrading ? r() : e()), this ); }, }, { key: "onError", value: function (t) { (a.priorWebsocketSuccess = !1), this.emitReserved("error", t), this.onClose("transport error", t); }, }, { key: "onClose", value: function (t, e) { ("opening" !== this.readyState && "open" !== this.readyState && "closing" !== this.readyState) || (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", t, e), (this.writeBuffer = []), (this.prevBufferLen = 0)); }, }, { key: "filterUpgrades", value: function (t) { for (var e = [], n = 0, r = t.length; n < r; n++) ~this.transports.indexOf(t[n]) && e.push(t[n]); return e; }, }, ]), a ); })(U); lt.protocol = 4; var pt = {}, dt = {}; function yt(t, e, n) { for (var r = 0, i = 0, s = n.length; i < s; i++) (r = n.charCodeAt(i)) < 128 ? t.setUint8(e++, r) : r < 2048 ? (t.setUint8(e++, 192 | (r >> 6)), t.setUint8(e++, 128 | (63 & r))) : r < 55296 || r >= 57344 ? (t.setUint8(e++, 224 | (r >> 12)), t.setUint8(e++, 128 | ((r >> 6) & 63)), t.setUint8(e++, 128 | (63 & r))) : (i++, (r = 65536 + (((1023 & r) << 10) | (1023 & n.charCodeAt(i)))), t.setUint8(e++, 240 | (r >> 18)), t.setUint8(e++, 128 | ((r >> 12) & 63)), t.setUint8(e++, 128 | ((r >> 6) & 63)), t.setUint8(e++, 128 | (63 & r))); } function vt(t, n, r) { var i = e(r), s = 0, o = 0, a = 0, c = 0, u = 0,