UNPKG

coc-webview

Version:

Vscode webview ported to coc.nvim

974 lines (973 loc) 69 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __reExport = (target, module2, copyDefault, desc) => { if (module2 && typeof module2 === "object" || typeof module2 === "function") { for (let key of __getOwnPropNames(module2)) if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable }); } return target; }; var __toESM = (module2, isNodeMode) => { return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2); }; // node_modules/socket.io-client/dist/socket.io.min.js var require_socket_io_min = __commonJS({ "node_modules/socket.io-client/dist/socket.io.min.js"(exports, module2) { !function(t, e) { typeof exports == "object" && typeof module2 != "undefined" ? module2.exports = e() : typeof define == "function" && define.amd ? define(e) : (t = typeof globalThis != "undefined" ? globalThis : t || self).io = e(); }(exports, function() { "use strict"; function t(e2) { return t = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t2) { return typeof t2; } : function(t2) { return t2 && typeof Symbol == "function" && t2.constructor === Symbol && t2 !== Symbol.prototype ? "symbol" : typeof t2; }, t(e2); } function e(t2, e2) { if (!(t2 instanceof e2)) throw new TypeError("Cannot call a class as a function"); } function n(t2, e2) { for (var n2 = 0; n2 < e2.length; n2++) { var r2 = e2[n2]; r2.enumerable = r2.enumerable || false, r2.configurable = true, "value" in r2 && (r2.writable = true), Object.defineProperty(t2, r2.key, r2); } } function r(t2, e2, r2) { return e2 && n(t2.prototype, e2), r2 && n(t2, r2), t2; } function o() { return o = Object.assign || function(t2) { for (var e2 = 1; e2 < arguments.length; e2++) { var n2 = arguments[e2]; for (var r2 in n2) Object.prototype.hasOwnProperty.call(n2, r2) && (t2[r2] = n2[r2]); } return t2; }, o.apply(this, arguments); } function i(t2, e2) { if (typeof e2 != "function" && e2 !== null) throw new TypeError("Super expression must either be null or a function"); t2.prototype = Object.create(e2 && e2.prototype, { constructor: { value: t2, writable: true, configurable: true } }), e2 && a(t2, e2); } function s(t2) { return s = Object.setPrototypeOf ? Object.getPrototypeOf : function(t3) { return t3.__proto__ || Object.getPrototypeOf(t3); }, s(t2); } function a(t2, e2) { return a = Object.setPrototypeOf || function(t3, e3) { return t3.__proto__ = e3, t3; }, a(t2, e2); } function c(t2) { if (t2 === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t2; } function u(t2, e2) { if (e2 && (typeof e2 == "object" || typeof e2 == "function")) return e2; if (e2 !== void 0) throw new TypeError("Derived constructors may only return object or undefined"); return c(t2); } function h(t2) { var e2 = function() { if (typeof Reflect == "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy == "function") return true; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { })), true; } catch (t3) { return false; } }(); return function() { var n2, r2 = s(t2); if (e2) { var o2 = s(this).constructor; n2 = Reflect.construct(r2, arguments, o2); } else n2 = r2.apply(this, arguments); return u(this, n2); }; } function f(t2, e2, n2) { return f = typeof Reflect != "undefined" && Reflect.get ? Reflect.get : function(t3, e3, n3) { var r2 = function(t4, e4) { for (; !Object.prototype.hasOwnProperty.call(t4, e4) && (t4 = s(t4)) !== null; ) ; return t4; }(t3, e3); if (r2) { var o2 = Object.getOwnPropertyDescriptor(r2, e3); return o2.get ? o2.get.call(n3) : o2.value; } }, f(t2, e2, n2 || t2); } function l(t2, e2) { (e2 == null || e2 > t2.length) && (e2 = t2.length); for (var n2 = 0, r2 = new Array(e2); n2 < e2; n2++) r2[n2] = t2[n2]; return r2; } function p(t2, e2) { var n2 = typeof Symbol != "undefined" && t2[Symbol.iterator] || t2["@@iterator"]; if (!n2) { if (Array.isArray(t2) || (n2 = function(t3, e3) { if (t3) { if (typeof t3 == "string") return l(t3, e3); var n3 = Object.prototype.toString.call(t3).slice(8, -1); return n3 === "Object" && t3.constructor && (n3 = t3.constructor.name), n3 === "Map" || n3 === "Set" ? Array.from(t3) : n3 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n3) ? l(t3, e3) : void 0; } }(t2)) || e2 && t2 && typeof t2.length == "number") { n2 && (t2 = n2); var r2 = 0, o2 = function() { }; return { s: o2, n: function() { return r2 >= t2.length ? { done: true } : { done: false, value: t2[r2++] }; }, e: function(t3) { throw t3; }, f: o2 }; } 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 i2, s2 = true, a2 = false; return { s: function() { n2 = n2.call(t2); }, n: function() { var t3 = n2.next(); return s2 = t3.done, t3; }, e: function(t3) { a2 = true, i2 = t3; }, f: function() { try { s2 || n2.return == null || n2.return(); } finally { if (a2) throw i2; } } }; } var d = /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, y = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"], v = function(t2) { var e2 = t2, n2 = t2.indexOf("["), r2 = t2.indexOf("]"); n2 != -1 && r2 != -1 && (t2 = t2.substring(0, n2) + t2.substring(n2, r2).replace(/:/g, ";") + t2.substring(r2, t2.length)); for (var o2, i2, s2 = d.exec(t2 || ""), a2 = {}, c2 = 14; c2--; ) a2[y[c2]] = s2[c2] || ""; return n2 != -1 && r2 != -1 && (a2.source = e2, a2.host = a2.host.substring(1, a2.host.length - 1).replace(/;/g, ":"), a2.authority = a2.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), a2.ipv6uri = true), a2.pathNames = function(t3, e3) { var n3 = /\/{2,9}/g, r3 = e3.replace(n3, "/").split("/"); e3.substr(0, 1) != "/" && e3.length !== 0 || r3.splice(0, 1); e3.substr(e3.length - 1, 1) == "/" && r3.splice(r3.length - 1, 1); return r3; }(0, a2.path), a2.queryKey = (o2 = a2.query, i2 = {}, o2.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(t3, e3, n3) { e3 && (i2[e3] = n3); }), i2), a2; }; var m = { exports: {} }; try { m.exports = typeof XMLHttpRequest != "undefined" && "withCredentials" in new XMLHttpRequest(); } catch (t2) { m.exports = false; } var g = m.exports, k = typeof self != "undefined" ? self : typeof window != "undefined" ? window : Function("return this")(); function b(t2) { var e2 = t2.xdomain; try { if (typeof XMLHttpRequest != "undefined" && (!e2 || g)) return new XMLHttpRequest(); } catch (t3) { } if (!e2) try { return new k[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP"); } catch (t3) { } } function w(t2) { for (var e2 = arguments.length, n2 = new Array(e2 > 1 ? e2 - 1 : 0), r2 = 1; r2 < e2; r2++) n2[r2 - 1] = arguments[r2]; return n2.reduce(function(e3, n3) { return t2.hasOwnProperty(n3) && (e3[n3] = t2[n3]), e3; }, {}); } var _ = setTimeout, E = clearTimeout; function A(t2, e2) { e2.useNativeTimers ? (t2.setTimeoutFn = _.bind(k), t2.clearTimeoutFn = E.bind(k)) : (t2.setTimeoutFn = setTimeout.bind(k), t2.clearTimeoutFn = clearTimeout.bind(k)); } var R = T; function T(t2) { if (t2) return function(t3) { for (var e2 in T.prototype) t3[e2] = T.prototype[e2]; return t3; }(t2); } T.prototype.on = T.prototype.addEventListener = function(t2, e2) { return this._callbacks = this._callbacks || {}, (this._callbacks["$" + t2] = this._callbacks["$" + t2] || []).push(e2), this; }, T.prototype.once = function(t2, e2) { function n2() { this.off(t2, n2), e2.apply(this, arguments); } return n2.fn = e2, this.on(t2, n2), this; }, T.prototype.off = T.prototype.removeListener = T.prototype.removeAllListeners = T.prototype.removeEventListener = function(t2, e2) { if (this._callbacks = this._callbacks || {}, arguments.length == 0) return this._callbacks = {}, this; var n2, r2 = this._callbacks["$" + t2]; if (!r2) return this; if (arguments.length == 1) return delete this._callbacks["$" + t2], this; for (var o2 = 0; o2 < r2.length; o2++) if ((n2 = r2[o2]) === e2 || n2.fn === e2) { r2.splice(o2, 1); break; } return r2.length === 0 && delete this._callbacks["$" + t2], this; }, T.prototype.emit = function(t2) { this._callbacks = this._callbacks || {}; for (var e2 = new Array(arguments.length - 1), n2 = this._callbacks["$" + t2], r2 = 1; r2 < arguments.length; r2++) e2[r2 - 1] = arguments[r2]; if (n2) { r2 = 0; for (var o2 = (n2 = n2.slice(0)).length; r2 < o2; ++r2) n2[r2].apply(this, e2); } return this; }, T.prototype.emitReserved = T.prototype.emit, T.prototype.listeners = function(t2) { return this._callbacks = this._callbacks || {}, this._callbacks["$" + t2] || []; }, T.prototype.hasListeners = function(t2) { return !!this.listeners(t2).length; }; var C = /* @__PURE__ */ Object.create(null); C.open = "0", C.close = "1", C.ping = "2", C.pong = "3", C.message = "4", C.upgrade = "5", C.noop = "6"; var O = /* @__PURE__ */ Object.create(null); Object.keys(C).forEach(function(t2) { O[C[t2]] = t2; }); for (var S = { type: "error", data: "parser error" }, B = typeof Blob == "function" || typeof Blob != "undefined" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", N = typeof ArrayBuffer == "function", x = function(t2, e2, n2) { var r2, o2 = t2.type, i2 = t2.data; return B && i2 instanceof Blob ? e2 ? n2(i2) : L(i2, n2) : N && (i2 instanceof ArrayBuffer || (r2 = i2, typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(r2) : r2 && r2.buffer instanceof ArrayBuffer)) ? e2 ? n2(i2) : L(new Blob([i2]), n2) : n2(C[o2] + (i2 || "")); }, L = function(t2, e2) { var n2 = new FileReader(); return n2.onload = function() { var t3 = n2.result.split(",")[1]; e2("b" + t3); }, n2.readAsDataURL(t2); }, j = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", P = typeof Uint8Array == "undefined" ? [] : new Uint8Array(256), q = 0; q < j.length; q++) P[j.charCodeAt(q)] = q; var D, I = typeof ArrayBuffer == "function", F = function(t2, e2) { if (typeof t2 != "string") return { type: "message", data: U(t2, e2) }; var n2 = t2.charAt(0); return n2 === "b" ? { type: "message", data: M(t2.substring(1), e2) } : O[n2] ? t2.length > 1 ? { type: O[n2], data: t2.substring(1) } : { type: O[n2] } : S; }, M = function(t2, e2) { if (I) { var n2 = function(t3) { var e3, n3, r2, o2, i2, s2 = 0.75 * t3.length, a2 = t3.length, c2 = 0; t3[t3.length - 1] === "=" && (s2--, t3[t3.length - 2] === "=" && s2--); var u2 = new ArrayBuffer(s2), h2 = new Uint8Array(u2); for (e3 = 0; e3 < a2; e3 += 4) n3 = P[t3.charCodeAt(e3)], r2 = P[t3.charCodeAt(e3 + 1)], o2 = P[t3.charCodeAt(e3 + 2)], i2 = P[t3.charCodeAt(e3 + 3)], h2[c2++] = n3 << 2 | r2 >> 4, h2[c2++] = (15 & r2) << 4 | o2 >> 2, h2[c2++] = (3 & o2) << 6 | 63 & i2; return u2; }(t2); return U(n2, e2); } return { base64: true, data: t2 }; }, U = function(t2, e2) { return e2 === "blob" && t2 instanceof ArrayBuffer ? new Blob([t2]) : t2; }, V = String.fromCharCode(30), H = function(t2) { i(o2, t2); var n2 = h(o2); function o2(t3) { var r2; return e(this, o2), (r2 = n2.call(this)).writable = false, A(c(r2), t3), r2.opts = t3, r2.query = t3.query, r2.readyState = "", r2.socket = t3.socket, r2; } return r(o2, [{ key: "onError", value: function(t3, e2) { var n3 = new Error(t3); return n3.type = "TransportError", n3.description = e2, f(s(o2.prototype), "emit", this).call(this, "error", n3), this; } }, { key: "open", value: function() { return this.readyState !== "closed" && this.readyState !== "" || (this.readyState = "opening", this.doOpen()), this; } }, { key: "close", value: function() { return this.readyState !== "opening" && this.readyState !== "open" || (this.doClose(), this.onClose()), this; } }, { key: "send", value: function(t3) { this.readyState === "open" && this.write(t3); } }, { key: "onOpen", value: function() { this.readyState = "open", this.writable = true, f(s(o2.prototype), "emit", this).call(this, "open"); } }, { key: "onData", value: function(t3) { var e2 = F(t3, this.socket.binaryType); this.onPacket(e2); } }, { key: "onPacket", value: function(t3) { f(s(o2.prototype), "emit", this).call(this, "packet", t3); } }, { key: "onClose", value: function() { this.readyState = "closed", f(s(o2.prototype), "emit", this).call(this, "close"); } }]), o2; }(R), K = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""), Y = {}, z = 0, $ = 0; function W(t2) { var e2 = ""; do { e2 = K[t2 % 64] + e2, t2 = Math.floor(t2 / 64); } while (t2 > 0); return e2; } function J() { var t2 = W(+new Date()); return t2 !== D ? (z = 0, D = t2) : t2 + "." + W(z++); } for (; $ < 64; $++) Y[K[$]] = $; J.encode = W, J.decode = function(t2) { var e2 = 0; for ($ = 0; $ < t2.length; $++) e2 = 64 * e2 + Y[t2.charAt($)]; return e2; }; var X = J, G = { encode: function(t2) { var e2 = ""; for (var n2 in t2) t2.hasOwnProperty(n2) && (e2.length && (e2 += "&"), e2 += encodeURIComponent(n2) + "=" + encodeURIComponent(t2[n2])); return e2; }, decode: function(t2) { for (var e2 = {}, n2 = t2.split("&"), r2 = 0, o2 = n2.length; r2 < o2; r2++) { var i2 = n2[r2].split("="); e2[decodeURIComponent(i2[0])] = decodeURIComponent(i2[1]); } return e2; } }, Q = function(t2) { i(o2, t2); var n2 = h(o2); function o2() { var t3; return e(this, o2), (t3 = n2.apply(this, arguments)).polling = false, t3; } return r(o2, [{ key: "name", get: function() { return "polling"; } }, { key: "doOpen", value: function() { this.poll(); } }, { key: "pause", value: function(t3) { var e2 = this; this.readyState = "pausing"; var n3 = function() { e2.readyState = "paused", t3(); }; if (this.polling || !this.writable) { var r2 = 0; this.polling && (r2++, this.once("pollComplete", function() { --r2 || n3(); })), this.writable || (r2++, this.once("drain", function() { --r2 || n3(); })); } else n3(); } }, { key: "poll", value: function() { this.polling = true, this.doPoll(), this.emit("poll"); } }, { key: "onData", value: function(t3) { var e2 = this; (function(t4, e3) { for (var n3 = t4.split(V), r2 = [], o3 = 0; o3 < n3.length; o3++) { var i2 = F(n3[o3], e3); if (r2.push(i2), i2.type === "error") break; } return r2; })(t3, this.socket.binaryType).forEach(function(t4) { if (e2.readyState === "opening" && t4.type === "open" && e2.onOpen(), t4.type === "close") return e2.onClose(), false; e2.onPacket(t4); }), this.readyState !== "closed" && (this.polling = false, this.emit("pollComplete"), this.readyState === "open" && this.poll()); } }, { key: "doClose", value: function() { var t3 = this, e2 = function() { t3.write([{ type: "close" }]); }; this.readyState === "open" ? e2() : this.once("open", e2); } }, { key: "write", value: function(t3) { var e2 = this; this.writable = false, function(t4, e3) { var n3 = t4.length, r2 = new Array(n3), o3 = 0; t4.forEach(function(t5, i2) { x(t5, false, function(t6) { r2[i2] = t6, ++o3 === n3 && e3(r2.join(V)); }); }); }(t3, function(t4) { e2.doWrite(t4, function() { e2.writable = true, e2.emit("drain"); }); }); } }, { key: "uri", value: function() { var t3 = this.query || {}, e2 = this.opts.secure ? "https" : "http", n3 = ""; this.opts.timestampRequests !== false && (t3[this.opts.timestampParam] = X()), this.supportsBinary || t3.sid || (t3.b64 = 1), this.opts.port && (e2 === "https" && Number(this.opts.port) !== 443 || e2 === "http" && Number(this.opts.port) !== 80) && (n3 = ":" + this.opts.port); var r2 = G.encode(t3); return e2 + "://" + (this.opts.hostname.indexOf(":") !== -1 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + n3 + this.opts.path + (r2.length ? "?" + r2 : ""); } }]), o2; }(H); function Z() { } var tt = new b({ xdomain: false }).responseType != null, et = function(t2) { i(s2, t2); var n2 = h(s2); function s2(t3) { var r2; if (e(this, s2), r2 = n2.call(this, t3), typeof location != "undefined") { var o2 = location.protocol === "https:", i2 = location.port; i2 || (i2 = o2 ? "443" : "80"), r2.xd = typeof location != "undefined" && t3.hostname !== location.hostname || i2 !== t3.port, r2.xs = t3.secure !== o2; } var a2 = t3 && t3.forceBase64; return r2.supportsBinary = tt && !a2, r2; } return r(s2, [{ key: "request", value: function() { var t3 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; return o(t3, { xd: this.xd, xs: this.xs }, this.opts), new nt(this.uri(), t3); } }, { key: "doWrite", value: function(t3, e2) { var n3 = this, r2 = this.request({ method: "POST", data: t3 }); r2.on("success", e2), r2.on("error", function(t4) { n3.onError("xhr post error", t4); }); } }, { key: "doPoll", value: function() { var t3 = this, e2 = this.request(); e2.on("data", this.onData.bind(this)), e2.on("error", function(e3) { t3.onError("xhr poll error", e3); }), this.pollXhr = e2; } }]), s2; }(Q), nt = function(t2) { i(o2, t2); var n2 = h(o2); function o2(t3, r2) { var i2; return e(this, o2), A(c(i2 = n2.call(this)), r2), i2.opts = r2, i2.method = r2.method || "GET", i2.uri = t3, i2.async = r2.async !== false, i2.data = r2.data !== void 0 ? r2.data : null, i2.create(), i2; } return r(o2, [{ key: "create", value: function() { var t3 = this, e2 = w(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref"); e2.xdomain = !!this.opts.xd, e2.xscheme = !!this.opts.xs; var n3 = this.xhr = new b(e2); try { n3.open(this.method, this.uri, this.async); try { if (this.opts.extraHeaders) for (var r2 in n3.setDisableHeaderCheck && n3.setDisableHeaderCheck(true), this.opts.extraHeaders) this.opts.extraHeaders.hasOwnProperty(r2) && n3.setRequestHeader(r2, this.opts.extraHeaders[r2]); } catch (t4) { } if (this.method === "POST") try { n3.setRequestHeader("Content-type", "text/plain;charset=UTF-8"); } catch (t4) { } try { n3.setRequestHeader("Accept", "*/*"); } catch (t4) { } "withCredentials" in n3 && (n3.withCredentials = this.opts.withCredentials), this.opts.requestTimeout && (n3.timeout = this.opts.requestTimeout), n3.onreadystatechange = function() { n3.readyState === 4 && (n3.status === 200 || n3.status === 1223 ? t3.onLoad() : t3.setTimeoutFn(function() { t3.onError(typeof n3.status == "number" ? n3.status : 0); }, 0)); }, n3.send(this.data); } catch (e3) { return void this.setTimeoutFn(function() { t3.onError(e3); }, 0); } typeof document != "undefined" && (this.index = o2.requestsCount++, o2.requests[this.index] = this); } }, { key: "onSuccess", value: function() { this.emit("success"), this.cleanup(); } }, { key: "onData", value: function(t3) { this.emit("data", t3), this.onSuccess(); } }, { key: "onError", value: function(t3) { this.emit("error", t3), this.cleanup(true); } }, { key: "cleanup", value: function(t3) { if (this.xhr !== void 0 && this.xhr !== null) { if (this.xhr.onreadystatechange = Z, t3) try { this.xhr.abort(); } catch (t4) { } typeof document != "undefined" && delete o2.requests[this.index], this.xhr = null; } } }, { key: "onLoad", value: function() { var t3 = this.xhr.responseText; t3 !== null && this.onData(t3); } }, { key: "abort", value: function() { this.cleanup(); } }]), o2; }(R); if (nt.requestsCount = 0, nt.requests = {}, typeof document != "undefined") { if (typeof attachEvent == "function") attachEvent("onunload", rt); else if (typeof addEventListener == "function") { addEventListener("onpagehide" in k ? "pagehide" : "unload", rt, false); } } function rt() { for (var t2 in nt.requests) nt.requests.hasOwnProperty(t2) && nt.requests[t2].abort(); } var ot = typeof Promise == "function" && typeof Promise.resolve == "function" ? function(t2) { return Promise.resolve().then(t2); } : function(t2, e2) { return e2(t2, 0); }, it = k.WebSocket || k.MozWebSocket, st = typeof navigator != "undefined" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative", at = function(t2) { i(o2, t2); var n2 = h(o2); function o2(t3) { var r2; return e(this, o2), (r2 = n2.call(this, t3)).supportsBinary = !t3.forceBase64, r2; } return r(o2, [{ key: "name", get: function() { return "websocket"; } }, { key: "doOpen", value: function() { if (this.check()) { var t3 = this.uri(), e2 = this.opts.protocols, n3 = st ? {} : w(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity"); this.opts.extraHeaders && (n3.headers = this.opts.extraHeaders); try { this.ws = st ? new it(t3, e2, n3) : e2 ? new it(t3, e2) : new it(t3); } catch (t4) { return this.emit("error", t4); } this.ws.binaryType = this.socket.binaryType || "arraybuffer", this.addEventListeners(); } } }, { key: "addEventListeners", value: function() { var t3 = this; this.ws.onopen = function() { t3.opts.autoUnref && t3.ws._socket.unref(), t3.onOpen(); }, this.ws.onclose = this.onClose.bind(this), this.ws.onmessage = function(e2) { return t3.onData(e2.data); }, this.ws.onerror = function(e2) { return t3.onError("websocket error", e2); }; } }, { key: "write", value: function(t3) { var e2 = this; this.writable = false; for (var n3 = function(n4) { var r3 = t3[n4], o3 = n4 === t3.length - 1; x(r3, e2.supportsBinary, function(t4) { try { e2.ws.send(t4); } catch (t5) { } o3 && ot(function() { e2.writable = true, e2.emit("drain"); }, e2.setTimeoutFn); }); }, r2 = 0; r2 < t3.length; r2++) n3(r2); } }, { key: "doClose", value: function() { this.ws !== void 0 && (this.ws.close(), this.ws = null); } }, { key: "uri", value: function() { var t3 = this.query || {}, e2 = this.opts.secure ? "wss" : "ws", n3 = ""; this.opts.port && (e2 === "wss" && Number(this.opts.port) !== 443 || e2 === "ws" && Number(this.opts.port) !== 80) && (n3 = ":" + this.opts.port), this.opts.timestampRequests && (t3[this.opts.timestampParam] = X()), this.supportsBinary || (t3.b64 = 1); var r2 = G.encode(t3); return e2 + "://" + (this.opts.hostname.indexOf(":") !== -1 ? "[" + this.opts.hostname + "]" : this.opts.hostname) + n3 + this.opts.path + (r2.length ? "?" + r2 : ""); } }, { key: "check", value: function() { return !(!it || "__initialize" in it && this.name === o2.prototype.name); } }]), o2; }(H), ct = { websocket: at, polling: et }, ut = function(n2) { i(a2, n2); var s2 = h(a2); function a2(n3) { var r2, i2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; return e(this, a2), r2 = s2.call(this), n3 && t(n3) === "object" && (i2 = n3, n3 = null), n3 ? (n3 = v(n3), i2.hostname = n3.host, i2.secure = n3.protocol === "https" || n3.protocol === "wss", i2.port = n3.port, n3.query && (i2.query = n3.query)) : i2.host && (i2.hostname = v(i2.host).host), A(c(r2), i2), r2.secure = i2.secure != null ? i2.secure : typeof location != "undefined" && location.protocol === "https:", i2.hostname && !i2.port && (i2.port = r2.secure ? "443" : "80"), r2.hostname = i2.hostname || (typeof location != "undefined" ? location.hostname : "localhost"), r2.port = i2.port || (typeof location != "undefined" && location.port ? location.port : r2.secure ? "443" : "80"), r2.transports = i2.transports || ["polling", "websocket"], r2.readyState = "", r2.writeBuffer = [], r2.prevBufferLen = 0, r2.opts = o({ path: "/engine.io", agent: false, withCredentials: false, upgrade: true, timestampParam: "t", rememberUpgrade: false, rejectUnauthorized: true, perMessageDeflate: { threshold: 1024 }, transportOptions: {}, closeOnBeforeunload: true }, i2), r2.opts.path = r2.opts.path.replace(/\/$/, "") + "/", typeof r2.opts.query == "string" && (r2.opts.query = G.decode(r2.opts.query)), r2.id = null, r2.upgrades = null, r2.pingInterval = null, r2.pingTimeout = null, r2.pingTimeoutTimer = null, typeof addEventListener == "function" && (r2.opts.closeOnBeforeunload && addEventListener("beforeunload", function() { r2.transport && (r2.transport.removeAllListeners(), r2.transport.close()); }, false), r2.hostname !== "localhost" && (r2.offlineEventListener = function() { r2.onClose("transport close"); }, addEventListener("offline", r2.offlineEventListener, false))), r2.open(), r2; } return r(a2, [{ key: "createTransport", value: function(t2) { var e2 = function(t3) { var e3 = {}; for (var n4 in t3) t3.hasOwnProperty(n4) && (e3[n4] = t3[n4]); return e3; }(this.opts.query); e2.EIO = 4, e2.transport = t2, this.id && (e2.sid = this.id); var n3 = o({}, this.opts.transportOptions[t2], this.opts, { query: e2, socket: this, hostname: this.hostname, secure: this.secure, port: this.port }); return new ct[t2](n3); } }, { key: "open", value: function() { var t2, e2 = this; if (this.opts.rememberUpgrade && a2.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1) t2 = "websocket"; else { if (this.transports.length === 0) return void this.setTimeoutFn(function() { e2.emitReserved("error", "No transports available"); }, 0); t2 = this.transports[0]; } this.readyState = "opening"; try { t2 = this.createTransport(t2); } catch (t3) { return this.transports.shift(), void this.open(); } t2.open(), this.setTransport(t2); } }, { key: "setTransport", value: function(t2) { var e2 = this; this.transport && this.transport.removeAllListeners(), this.transport = t2, t2.on("drain", this.onDrain.bind(this)).on("packet", this.onPacket.bind(this)).on("error", this.onError.bind(this)).on("close", function() { e2.onClose("transport close"); }); } }, { key: "probe", value: function(t2) { var e2 = this, n3 = this.createTransport(t2), r2 = false; a2.priorWebsocketSuccess = false; var o2 = function() { r2 || (n3.send([{ type: "ping", data: "probe" }]), n3.once("packet", function(t3) { if (!r2) if (t3.type === "pong" && t3.data === "probe") { if (e2.upgrading = true, e2.emitReserved("upgrading", n3), !n3) return; a2.priorWebsocketSuccess = n3.name === "websocket", e2.transport.pause(function() { r2 || e2.readyState !== "closed" && (f2(), e2.setTransport(n3), n3.send([{ type: "upgrade" }]), e2.emitReserved("upgrade", n3), n3 = null, e2.upgrading = false, e2.flush()); }); } else { var o3 = new Error("probe error"); o3.transport = n3.name, e2.emitReserved("upgradeError", o3); } })); }; function i2() { r2 || (r2 = true, f2(), n3.close(), n3 = null); } var s3 = function(t3) { var r3 = new Error("probe error: " + t3); r3.transport = n3.name, i2(), e2.emitReserved("upgradeError", r3); }; function c2() { s3("transport closed"); } function u2() { s3("socket closed"); } function h2(t3) { n3 && t3.name !== n3.name && i2(); } var f2 = function() { n3.removeListener("open", o2), n3.removeListener("error", s3), n3.removeListener("close", c2), e2.off("close", u2), e2.off("upgrading", h2); }; n3.once("open", o2), n3.once("error", s3), n3.once("close", c2), this.once("close", u2), this.once("upgrading", h2), n3.open(); } }, { key: "onOpen", value: function() { if (this.readyState = "open", a2.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush(), this.readyState === "open" && this.opts.upgrade && this.transport.pause) for (var t2 = 0, e2 = this.upgrades.length; t2 < e2; t2++) this.probe(this.upgrades[t2]); } }, { key: "onPacket", value: function(t2) { if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") switch (this.emitReserved("packet", t2), this.emitReserved("heartbeat"), t2.type) { case "open": this.onHandshake(JSON.parse(t2.data)); break; case "ping": this.resetPingTimeout(), this.sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"); break; case "error": var e2 = new Error("server error"); e2.code = t2.data, this.onError(e2); break; case "message": this.emitReserved("data", t2.data), this.emitReserved("message", t2.data); } } }, { key: "onHandshake", value: function(t2) { this.emitReserved("handshake", t2), this.id = t2.sid, this.transport.query.sid = t2.sid, this.upgrades = this.filterUpgrades(t2.upgrades), this.pingInterval = t2.pingInterval, this.pingTimeout = t2.pingTimeout, this.onOpen(), this.readyState !== "closed" && this.resetPingTimeout(); } }, { key: "resetPingTimeout", value: function() { var t2 = this; this.clearTimeoutFn(this.pingTimeoutTimer), this.pingTimeoutTimer = this.setTimeoutFn(function() { t2.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, this.writeBuffer.length === 0 ? this.emitReserved("drain") : this.flush(); } }, { key: "flush", value: function() { this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length && (this.transport.send(this.writeBuffer), this.prevBufferLen = this.writeBuffer.length, this.emitReserved("flush")); } }, { key: "write", value: function(t2, e2, n3) { return this.sendPacket("message", t2, e2, n3), this; } }, { key: "send", value: function(t2, e2, n3) { return this.sendPacket("message", t2, e2, n3), this; } }, { key: "sendPacket", value: function(t2, e2, n3, r2) { if (typeof e2 == "function" && (r2 = e2, e2 = void 0), typeof n3 == "function" && (r2 = n3, n3 = null), this.readyState !== "closing" && this.readyState !== "closed") { (n3 = n3 || {}).compress = n3.compress !== false; var o2 = { type: t2, data: e2, options: n3 }; this.emitReserved("packetCreate", o2), this.writeBuffer.push(o2), r2 && this.once("flush", r2), this.flush(); } } }, { key: "close", value: function() { var t2 = this, e2 = function() { t2.onClose("forced close"), t2.transport.close(); }, n3 = function n4() { t2.off("upgrade", n4), t2.off("upgradeError", n4), e2(); }, r2 = function() { t2.once("upgrade", n3), t2.once("upgradeError", n3); }; return this.readyState !== "opening" && this.readyState !== "open" || (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", function() { t2.upgrading ? r2() : e2(); }) : this.upgrading ? r2() : e2()), this; } }, { key: "onError", value: function(t2) { a2.priorWebsocketSuccess = false, this.emitReserved("error", t2), this.onClose("transport error", t2); } }, { key: "onClose", value: function(t2, e2) { this.readyState !== "opening" && this.readyState !== "open" && this.readyState !== "closing" || (this.clearTimeoutFn(this.pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), typeof removeEventListener == "function" && removeEventListener("offline", this.offlineEventListener, false), this.readyState = "closed", this.id = null, this.emitReserved("close", t2, e2), this.writeBuffer = [], this.prevBufferLen = 0); } }, { key: "filterUpgrades", value: function(t2) { for (var e2 = [], n3 = 0, r2 = t2.length; n3 < r2; n3++) ~this.transports.indexOf(t2[n3]) && e2.push(t2[n3]); return e2; } }]), a2; }(R); ut.protocol = 4; var ht = typeof ArrayBuffer == "function", ft = Object.prototype.toString, lt = typeof Blob == "function" || typeof Blob != "undefined" && ft.call(Blob) === "[object BlobConstructor]", pt = typeof File == "function" || typeof File != "undefined" && ft.call(File) === "[object FileConstructor]"; function dt(t2) { return ht && (t2 instanceof ArrayBuffer || function(t3) { return typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(t3) : t3.buffer instanceof ArrayBuffer; }(t2)) || lt && t2 instanceof Blob || pt && t2 instanceof File; } function yt(e2, n2) { if (!e2 || t(e2) !== "object") return false; if (Array.isArray(e2)) { for (var r2 = 0, o2 = e2.length; r2 < o2; r2++) if (yt(e2[r2])) return true; return false; } if (dt(e2)) return true; if (e2.toJSON && typeof e2.toJSON == "function" && arguments.length === 1) return yt(e2.toJSON(), true); for (var i2 in e2) if (Object.prototype.hasOwnProperty.call(e2, i2) && yt(e2[i2])) return true; return false; } function vt(t2) { var e2 = [], n2 = t2.data, r2 = t2; return r2.data = mt(n2, e2), r2.attachments = e2.length, { packet: r2, buffers: e2 }; } function mt(e2, n2) { if (!e2) return e2; if (dt(e2)) { var r2 = { _placeholder: true, num: n2.length }; return n2.push(e2), r2; } if (Array.isArray(e2)) { for (var o2 = new Array(e2.length), i2 = 0; i2 < e2.length; i2++) o2[i2] = mt(e2[i2], n2); return o2; } if (t(e2) === "object" && !(e2 instanceof Date)) { var s2 = {}; for (var a2 in e2) e2.hasOwnProperty(a2) && (s2[a2] = mt(e2[a2], n2)); return s2; } return e2; } function gt(t2, e2) { return t2.data = kt(t2.data, e2), t2.attachments = void 0, t2; } function kt(e2, n2) { if (!e2) return e2; if (e2 && e2._placeholder) return n2[e2.num]; if (Array.isArray(e2)) for (var r2 = 0; r2 < e2.length; r2++) e2[r2] = kt(e2[r2], n2); else if (t(e2) === "object") for (var o2 in e2) e2.hasOwnProperty(o2) && (e2[o2] = kt(e2[o2], n2)); return e2; } var bt; !function(t2) { t2[t2.CONNECT = 0] = "CONNECT", t2[t2.DISCONNECT = 1] = "DISCONNECT", t2[t2.EVENT = 2] = "EVENT", t2[t2.ACK = 3] = "ACK", t2[t2.CONNECT_ERROR = 4] = "CONNECT_ERROR", t2[t2.BINARY_EVENT = 5] = "BINARY_EVENT", t2[t2.BINARY_ACK = 6] = "BINARY_ACK"; }(bt || (bt = {})); var wt = function() { function t2() { e(this, t2); } return r(t2, [{ key: "encode", value: function(t3) { return t3.type !== bt.EVENT && t3.type !== bt.ACK || !yt(t3) ? [this.encodeAsString(t3)] : (t3.type = t3.type === bt.EVENT ? bt.BINARY_EVENT : bt.BINARY_ACK, this.encodeAsBinary(t3)); } }, { key: "encodeAsString", value: function(t3) { var e2 = "" + t3.type; return t3.type !== bt.BINARY_EVENT && t3.type !== bt.BINARY_ACK || (e2 += t3.attachments + "-"), t3.nsp && t3.nsp !== "/" && (e2 += t3.nsp + ","), t3.id != null && (e2 += t3.id), t3.data != null && (e2 += JSON.stringify(t3.data)), e2; } }, { key: "encodeAsBinary", value: function(t3) { var e2 = vt(t3), n2 = this.encodeAsString(e2.packet), r2 = e2.buffers; return r2.unshift(n2), r2; } }]), t2; }(), _t = function(n2) { i(a2, n2); var o2 = h(a2); function a2() { return e(this, a2), o2.call(this); } return r(a2, [{ key: "add", value: function(t2) { var e2; if (typeof t2 == "string") (e2 = this.decodeString(t2)).type === bt.BINARY_EVENT || e2.type === bt.BINARY_ACK ? (this.reconstructor = new Et(e2), e2.attachments === 0 && f(s(a2.prototype), "emitReserved", this).call(this, "decoded", e2)) : f(s(a2.prototype), "emitReserved", this).call(this, "decoded", e2); else { if (!dt(t2) && !t2.base64) throw new Error("Unknown type: " + t2); if (!this.reconstructor) throw new Error("got binary data when not reconstructing a packet"); (e2 = this.reconstructor.takeBinaryData(t2)) && (this.reconstructor = null, f(s(a2.prototype), "emitReserved", this).call(this, "decoded", e2)); } } }, { key: "decodeString", value: function(t2) { var e2 = 0, n3 = { type: Number(t2.charAt(0)) }; if (bt[n3.type] === void 0) throw new Error("unknown packet type " + n3.type); if (n3.type === bt.BINARY_EVENT || n3.type === bt.BINARY_ACK) { for (var r2 = e2 + 1; t2.charAt(++e2) !== "-" && e2 != t2.length; ) ; var o3 = t2.substring(r2, e2); if (o3 != Number(o3) || t2.charAt(e2) !== "-") throw new Error("Illegal attachments"); n3.attachments = Number(o3); } if (t2.charAt(e2 + 1) === "/") { for (var i2 = e2 + 1; ++e2; ) { if (t2.charAt(e2) === ",") break; if (e2 === t2.length) break; } n3.nsp = t2.substring(i2, e2); } else n3.nsp = "/"; var s2 = t2.charAt(e2 + 1); if (s2 !== "" && Number(s2) == s2) { for (var c2 = e2 + 1; ++e2; ) { var u2 = t2.charAt(e2); if (u2 == null || Number(u2) != u2) { --e2; break; } if (e2 === t2.length) break; } n3.id = Number(t2.substring(c2, e2 + 1)); } if (t2.charAt(++e2)) { var h2 = function(t3) { try { return JSON.parse(t3); } catch (t4) { return false; } }(t2.substr(e2)); if (!a2.isPayloadValid(n3.type, h2)) throw new Error("invalid payload"); n3.data = h2; } return n3; } }, { key: "destroy", value: function() { this.reconstructor && this.reconstructor.finishedReconstruction(); } }], [{ key: "isPayloadValid", value: function(e2, n3) { switch (e2) { case bt.CONNECT: return t(n3) === "object"; case bt.DISCONNECT: return n3 === void 0; case bt.CONNECT_ERROR: return typeof n3 == "string" || t(n3) === "object"; case bt.EVENT: case bt.BINARY_EVENT: return Array.isArray(n3) && n3.length > 0; case bt.ACK: case bt.BINARY_ACK: return Array.isArray(n3); } } }]), a2; }(R); var Et = function() { function t2(n2) { e(this, t2), this.packet = n2, this.buffers = [], this.reconPack = n2; } return r(t2, [{ key: "takeBinaryData", value: function(t3) { if (this.buffers.push(t3), this.buffers.length === this.reconPack.attachments) { var e2 = gt(this.reconPack, this.buffers); return this.finishedReconstruction(), e2; } return null; } }, { key: "finishedReconstruction", value: function() { this.reconPack = null, this.buffers = []; } }]), t2; }(), At = Object.freeze({ __proto__: null, protocol: 5, get PacketType() { return bt; }, Encoder: wt, Decoder: _t }); function Rt(t2, e2, n2) { return t2.on(e2, n2), function() { t2.off(e2, n2); }; } var Tt = Object.freeze({ connect: 1, connect_error: 1, disconnect: 1, disconnecting: 1, newListener: 1, removeListener: 1 }), Ct = function(t2) { i(o2, t2); var n2 = h(o2); function o2(t3, r2, i2) { var s2; return e(this, o2), (s2 = n2.call(this)).connected = false, s2.disconnected = true, s2.receiveBuffer = [], s2.sendBuffer = [], s2.ids = 0, s2.acks = {}, s2.flags = {}, s2.io = t3, s2.nsp = r2, i2 && i2.auth && (s2.auth = i2.auth), s2.io._autoConnect && s2.open(), s2; } return r(o2, [{ key: "subEvents", value: function() { if (!this.subs) { var t3 = this.io; this.subs = [Rt(t3, "open", this.onopen.bind(this)), Rt(t3, "packet", this.onpacket.bind(this)), Rt(t3, "error", this.onerror.bind(this)), Rt(t3, "close", this.onclose.bind(this))]; } } }, { key: "active", get: function() { return !!this.subs; } }, { key: "connect", value: function() { return this.connected || (this.subEvents(), this.io._reconnecting || this.io.open(), this.io._readyState === "open" && this.onopen()), this; } }, { key: "open", value: function() { return this.connect(); } }, { key: "send", value: function() { for (var t3 = arguments.length, e2 = new Array(t3), n3 = 0; n3 < t3; n3++) e2[n3] = arguments[n3]; return e2.unshift("message"), this.emit.apply(this, e2), this; } }, { key: "emit", value: function(t3) { if (Tt.hasOwnProperty(t3)) throw new Error('"' + t3 + '" is a reserved event name'); for (var e2 = arguments.length, n3 = new Array(e2 > 1 ? e2 - 1 : 0), r2 = 1; r2 < e2; r2++) n3[r2 - 1] = arguments[r2]; n3.unshift(t3); var o3 = { type: bt.EVENT, data: n3, options: {} }; if (o3.options.compress = this.flags.compress !== false, typeof n3[n3.length - 1] == "function") { var i2 = this.ids++, s2 = n3.pop(); this._registerAckCallback(i2, s2), o3.id = i2; } var a2 = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable, c2 = this.flags.volatile && (!a2 || !this.connected); return c2 || (this.connected ? this.packet(o3) : this.sendBuffer.push(o3)), this.flags = {}, this; } }, { key: "_registerAckCallback", value: function(t3, e2) { var n3 = this, r2 = this.flags.timeout; if (r2 !== void 0) { var o3 = this.io.setTimeoutFn(function() { delete n3.acks[t3]; for (var r3 = 0; r3 < n3.sendBuffer.length; r3++) n3.sendBuffer[r3].id === t3 && n3.sendBuffer.splice(r3, 1); e2.call(n3, new Error("operation has timed out")); }, r2); this.acks[t3] = function() { n3.io.clearTimeoutFn(o3); for (var t4 = arguments.length, r3 = new Array(t4), i2 = 0; i2 < t4; i2++) r3[i2] = arguments[i2]; e2.apply(n3, [null].concat(r3)); }; } else this.acks[t3] = e2; } }, { key: "packet", value: function(t3) { t3.nsp = this.nsp, this.io._packet(t3); } }, { key: "onopen", value: function() { var t3 = this; typeof this.auth == "function" ? this.auth(function(e2) { t3.packet({ type: bt.CONNECT, data: e2 }); }) : this.packet({ type: bt.CONNECT, data: this.auth }); } }, { key: "onerror", value: function(t3) { this.connected || this.emitReserved("connect_error", t3); } }, { key: "onclose", value: function(t3) { this.conn