socket.io.min.js 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038
  1. /*!
  2. * Socket.IO v4.4.1
  3. * (c) 2014-2022 Guillermo Rauch
  4. * Released under the MIT License.
  5. */
  6. !(function (t, e) {
  7. "object" == typeof exports && "undefined" != typeof module
  8. ? (module.exports = e())
  9. : "function" == typeof define && define.amd
  10. ? define(e)
  11. : ((t = "undefined" != typeof globalThis ? globalThis : t || self).io = e());
  12. })(this, function () {
  13. "use strict";
  14. function t(e) {
  15. return (
  16. (t =
  17. "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
  18. ? function (t) {
  19. return typeof t;
  20. }
  21. : function (t) {
  22. return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
  23. }),
  24. t(e)
  25. );
  26. }
  27. function e(t, e) {
  28. if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function");
  29. }
  30. function n(t, e) {
  31. for (var n = 0; n < e.length; n++) {
  32. var r = e[n];
  33. (r.enumerable = r.enumerable || !1), (r.configurable = !0), "value" in r && (r.writable = !0), Object.defineProperty(t, r.key, r);
  34. }
  35. }
  36. function r(t, e, r) {
  37. return e && n(t.prototype, e), r && n(t, r), t;
  38. }
  39. function o() {
  40. return (
  41. (o =
  42. Object.assign ||
  43. function (t) {
  44. for (var e = 1; e < arguments.length; e++) {
  45. var n = arguments[e];
  46. for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
  47. }
  48. return t;
  49. }),
  50. o.apply(this, arguments)
  51. );
  52. }
  53. function i(t, e) {
  54. if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
  55. (t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } })), e && a(t, e);
  56. }
  57. function s(t) {
  58. return (
  59. (s = Object.setPrototypeOf
  60. ? Object.getPrototypeOf
  61. : function (t) {
  62. return t.__proto__ || Object.getPrototypeOf(t);
  63. }),
  64. s(t)
  65. );
  66. }
  67. function a(t, e) {
  68. return (
  69. (a =
  70. Object.setPrototypeOf ||
  71. function (t, e) {
  72. return (t.__proto__ = e), t;
  73. }),
  74. a(t, e)
  75. );
  76. }
  77. function c(t) {
  78. if (void 0 === t) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  79. return t;
  80. }
  81. function u(t, e) {
  82. if (e && ("object" == typeof e || "function" == typeof e)) return e;
  83. if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
  84. return c(t);
  85. }
  86. function h(t) {
  87. var e = (function () {
  88. if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
  89. if (Reflect.construct.sham) return !1;
  90. if ("function" == typeof Proxy) return !0;
  91. try {
  92. return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})), !0;
  93. } catch (t) {
  94. return !1;
  95. }
  96. })();
  97. return function () {
  98. var n,
  99. r = s(t);
  100. if (e) {
  101. var o = s(this).constructor;
  102. n = Reflect.construct(r, arguments, o);
  103. } else n = r.apply(this, arguments);
  104. return u(this, n);
  105. };
  106. }
  107. function f(t, e, n) {
  108. return (
  109. (f =
  110. "undefined" != typeof Reflect && Reflect.get
  111. ? Reflect.get
  112. : function (t, e, n) {
  113. var r = (function (t, e) {
  114. for (; !Object.prototype.hasOwnProperty.call(t, e) && null !== (t = s(t)); );
  115. return t;
  116. })(t, e);
  117. if (r) {
  118. var o = Object.getOwnPropertyDescriptor(r, e);
  119. return o.get ? o.get.call(n) : o.value;
  120. }
  121. }),
  122. f(t, e, n || t)
  123. );
  124. }
  125. function l(t, e) {
  126. (null == e || e > t.length) && (e = t.length);
  127. for (var n = 0, r = new Array(e); n < e; n++) r[n] = t[n];
  128. return r;
  129. }
  130. function p(t, e) {
  131. var n = ("undefined" != typeof Symbol && t[Symbol.iterator]) || t["@@iterator"];
  132. if (!n) {
  133. if (
  134. Array.isArray(t) ||
  135. (n = (function (t, e) {
  136. if (t) {
  137. if ("string" == typeof t) return l(t, e);
  138. var n = Object.prototype.toString.call(t).slice(8, -1);
  139. return (
  140. "Object" === n && t.constructor && (n = t.constructor.name),
  141. "Map" === n || "Set" === n ? Array.from(t) : "Arguments" === n || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n) ? l(t, e) : void 0
  142. );
  143. }
  144. })(t)) ||
  145. (e && t && "number" == typeof t.length)
  146. ) {
  147. n && (t = n);
  148. var r = 0,
  149. o = function () {};
  150. return {
  151. s: o,
  152. n: function () {
  153. return r >= t.length ? { done: !0 } : { done: !1, value: t[r++] };
  154. },
  155. e: function (t) {
  156. throw t;
  157. },
  158. f: o,
  159. };
  160. }
  161. throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  162. }
  163. var i,
  164. s = !0,
  165. a = !1;
  166. return {
  167. s: function () {
  168. n = n.call(t);
  169. },
  170. n: function () {
  171. var t = n.next();
  172. return (s = t.done), t;
  173. },
  174. e: function (t) {
  175. (a = !0), (i = t);
  176. },
  177. f: function () {
  178. try {
  179. s || null == n.return || n.return();
  180. } finally {
  181. if (a) throw i;
  182. }
  183. },
  184. };
  185. }
  186. var d =
  187. /^(?:(?![^:@]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,
  188. y = ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
  189. v = function (t) {
  190. var e = t,
  191. n = t.indexOf("["),
  192. r = t.indexOf("]");
  193. -1 != n && -1 != r && (t = t.substring(0, n) + t.substring(n, r).replace(/:/g, ";") + t.substring(r, t.length));
  194. for (var o, i, s = d.exec(t || ""), a = {}, c = 14; c--; ) a[y[c]] = s[c] || "";
  195. return (
  196. -1 != n &&
  197. -1 != r &&
  198. ((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)),
  199. (a.pathNames = (function (t, e) {
  200. var n = /\/{2,9}/g,
  201. r = e.replace(n, "/").split("/");
  202. ("/" != e.substr(0, 1) && 0 !== e.length) || r.splice(0, 1);
  203. "/" == e.substr(e.length - 1, 1) && r.splice(r.length - 1, 1);
  204. return r;
  205. })(0, a.path)),
  206. (a.queryKey =
  207. ((o = a.query),
  208. (i = {}),
  209. o.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function (t, e, n) {
  210. e && (i[e] = n);
  211. }),
  212. i)),
  213. a
  214. );
  215. };
  216. var m = { exports: {} };
  217. try {
  218. m.exports = "undefined" != typeof XMLHttpRequest && "withCredentials" in new XMLHttpRequest();
  219. } catch (t) {
  220. m.exports = !1;
  221. }
  222. var g = m.exports,
  223. k = "undefined" != typeof self ? self : "undefined" != typeof window ? window : Function("return this")();
  224. function b(t) {
  225. var e = t.xdomain;
  226. try {
  227. if ("undefined" != typeof XMLHttpRequest && (!e || g)) return new XMLHttpRequest();
  228. } catch (t) {}
  229. if (!e)
  230. try {
  231. return new k[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
  232. } catch (t) {}
  233. }
  234. function w(t) {
  235. for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++) n[r - 1] = arguments[r];
  236. return n.reduce(function (e, n) {
  237. return t.hasOwnProperty(n) && (e[n] = t[n]), e;
  238. }, {});
  239. }
  240. var _ = setTimeout,
  241. E = clearTimeout;
  242. function A(t, e) {
  243. e.useNativeTimers ? ((t.setTimeoutFn = _.bind(k)), (t.clearTimeoutFn = E.bind(k))) : ((t.setTimeoutFn = setTimeout.bind(k)), (t.clearTimeoutFn = clearTimeout.bind(k)));
  244. }
  245. var R = T;
  246. function T(t) {
  247. if (t)
  248. return (function (t) {
  249. for (var e in T.prototype) t[e] = T.prototype[e];
  250. return t;
  251. })(t);
  252. }
  253. (T.prototype.on = T.prototype.addEventListener =
  254. function (t, e) {
  255. return (this._callbacks = this._callbacks || {}), (this._callbacks["$" + t] = this._callbacks["$" + t] || []).push(e), this;
  256. }),
  257. (T.prototype.once = function (t, e) {
  258. function n() {
  259. this.off(t, n), e.apply(this, arguments);
  260. }
  261. return (n.fn = e), this.on(t, n), this;
  262. }),
  263. (T.prototype.off =
  264. T.prototype.removeListener =
  265. T.prototype.removeAllListeners =
  266. T.prototype.removeEventListener =
  267. function (t, e) {
  268. if (((this._callbacks = this._callbacks || {}), 0 == arguments.length)) return (this._callbacks = {}), this;
  269. var n,
  270. r = this._callbacks["$" + t];
  271. if (!r) return this;
  272. if (1 == arguments.length) return delete this._callbacks["$" + t], this;
  273. for (var o = 0; o < r.length; o++)
  274. if ((n = r[o]) === e || n.fn === e) {
  275. r.splice(o, 1);
  276. break;
  277. }
  278. return 0 === r.length && delete this._callbacks["$" + t], this;
  279. }),
  280. (T.prototype.emit = function (t) {
  281. this._callbacks = this._callbacks || {};
  282. for (var e = new Array(arguments.length - 1), n = this._callbacks["$" + t], r = 1; r < arguments.length; r++) e[r - 1] = arguments[r];
  283. if (n) {
  284. r = 0;
  285. for (var o = (n = n.slice(0)).length; r < o; ++r) n[r].apply(this, e);
  286. }
  287. return this;
  288. }),
  289. (T.prototype.emitReserved = T.prototype.emit),
  290. (T.prototype.listeners = function (t) {
  291. return (this._callbacks = this._callbacks || {}), this._callbacks["$" + t] || [];
  292. }),
  293. (T.prototype.hasListeners = function (t) {
  294. return !!this.listeners(t).length;
  295. });
  296. var C = Object.create(null);
  297. (C.open = "0"), (C.close = "1"), (C.ping = "2"), (C.pong = "3"), (C.message = "4"), (C.upgrade = "5"), (C.noop = "6");
  298. var O = Object.create(null);
  299. Object.keys(C).forEach(function (t) {
  300. O[C[t]] = t;
  301. });
  302. for (
  303. var S = { type: "error", data: "parser error" },
  304. B = "function" == typeof Blob || ("undefined" != typeof Blob && "[object BlobConstructor]" === Object.prototype.toString.call(Blob)),
  305. N = "function" == typeof ArrayBuffer,
  306. x = function (t, e, n) {
  307. var r,
  308. o = t.type,
  309. i = t.data;
  310. return B && i instanceof Blob
  311. ? e
  312. ? n(i)
  313. : L(i, n)
  314. : N && (i instanceof ArrayBuffer || ((r = i), "function" == typeof ArrayBuffer.isView ? ArrayBuffer.isView(r) : r && r.buffer instanceof ArrayBuffer))
  315. ? e
  316. ? n(i)
  317. : L(new Blob([i]), n)
  318. : n(C[o] + (i || ""));
  319. },
  320. L = function (t, e) {
  321. var n = new FileReader();
  322. return (
  323. (n.onload = function () {
  324. var t = n.result.split(",")[1];
  325. e("b" + t);
  326. }),
  327. n.readAsDataURL(t)
  328. );
  329. },
  330. j = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
  331. P = "undefined" == typeof Uint8Array ? [] : new Uint8Array(256),
  332. q = 0;
  333. q < j.length;
  334. q++
  335. )
  336. P[j.charCodeAt(q)] = q;
  337. var D,
  338. I = "function" == typeof ArrayBuffer,
  339. F = function (t, e) {
  340. if ("string" != typeof t) return { type: "message", data: U(t, e) };
  341. var n = t.charAt(0);
  342. return "b" === n ? { type: "message", data: M(t.substring(1), e) } : O[n] ? (t.length > 1 ? { type: O[n], data: t.substring(1) } : { type: O[n] }) : S;
  343. },
  344. M = function (t, e) {
  345. if (I) {
  346. var n = (function (t) {
  347. var e,
  348. n,
  349. r,
  350. o,
  351. i,
  352. s = 0.75 * t.length,
  353. a = t.length,
  354. c = 0;
  355. "=" === t[t.length - 1] && (s--, "=" === t[t.length - 2] && s--);
  356. var u = new ArrayBuffer(s),
  357. h = new Uint8Array(u);
  358. for (e = 0; e < a; e += 4)
  359. (n = P[t.charCodeAt(e)]),
  360. (r = P[t.charCodeAt(e + 1)]),
  361. (o = P[t.charCodeAt(e + 2)]),
  362. (i = P[t.charCodeAt(e + 3)]),
  363. (h[c++] = (n << 2) | (r >> 4)),
  364. (h[c++] = ((15 & r) << 4) | (o >> 2)),
  365. (h[c++] = ((3 & o) << 6) | (63 & i));
  366. return u;
  367. })(t);
  368. return U(n, e);
  369. }
  370. return { base64: !0, data: t };
  371. },
  372. U = function (t, e) {
  373. return "blob" === e && t instanceof ArrayBuffer ? new Blob([t]) : t;
  374. },
  375. V = String.fromCharCode(30),
  376. H = (function (t) {
  377. i(o, t);
  378. var n = h(o);
  379. function o(t) {
  380. var r;
  381. return e(this, o), ((r = n.call(this)).writable = !1), A(c(r), t), (r.opts = t), (r.query = t.query), (r.readyState = ""), (r.socket = t.socket), r;
  382. }
  383. return (
  384. r(o, [
  385. {
  386. key: "onError",
  387. value: function (t, e) {
  388. var n = new Error(t);
  389. return (n.type = "TransportError"), (n.description = e), f(s(o.prototype), "emit", this).call(this, "error", n), this;
  390. },
  391. },
  392. {
  393. key: "open",
  394. value: function () {
  395. return ("closed" !== this.readyState && "" !== this.readyState) || ((this.readyState = "opening"), this.doOpen()), this;
  396. },
  397. },
  398. {
  399. key: "close",
  400. value: function () {
  401. return ("opening" !== this.readyState && "open" !== this.readyState) || (this.doClose(), this.onClose()), this;
  402. },
  403. },
  404. {
  405. key: "send",
  406. value: function (t) {
  407. "open" === this.readyState && this.write(t);
  408. },
  409. },
  410. {
  411. key: "onOpen",
  412. value: function () {
  413. (this.readyState = "open"), (this.writable = !0), f(s(o.prototype), "emit", this).call(this, "open");
  414. },
  415. },
  416. {
  417. key: "onData",
  418. value: function (t) {
  419. var e = F(t, this.socket.binaryType);
  420. this.onPacket(e);
  421. },
  422. },
  423. {
  424. key: "onPacket",
  425. value: function (t) {
  426. f(s(o.prototype), "emit", this).call(this, "packet", t);
  427. },
  428. },
  429. {
  430. key: "onClose",
  431. value: function () {
  432. (this.readyState = "closed"), f(s(o.prototype), "emit", this).call(this, "close");
  433. },
  434. },
  435. ]),
  436. o
  437. );
  438. })(R),
  439. K = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),
  440. Y = {},
  441. z = 0,
  442. $ = 0;
  443. function W(t) {
  444. var e = "";
  445. do {
  446. (e = K[t % 64] + e), (t = Math.floor(t / 64));
  447. } while (t > 0);
  448. return e;
  449. }
  450. function J() {
  451. var t = W(+new Date());
  452. return t !== D ? ((z = 0), (D = t)) : t + "." + W(z++);
  453. }
  454. for (; $ < 64; $++) Y[K[$]] = $;
  455. (J.encode = W),
  456. (J.decode = function (t) {
  457. var e = 0;
  458. for ($ = 0; $ < t.length; $++) e = 64 * e + Y[t.charAt($)];
  459. return e;
  460. });
  461. var X = J,
  462. G = {
  463. encode: function (t) {
  464. var e = "";
  465. for (var n in t) t.hasOwnProperty(n) && (e.length && (e += "&"), (e += encodeURIComponent(n) + "=" + encodeURIComponent(t[n])));
  466. return e;
  467. },
  468. decode: function (t) {
  469. for (var e = {}, n = t.split("&"), r = 0, o = n.length; r < o; r++) {
  470. var i = n[r].split("=");
  471. e[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
  472. }
  473. return e;
  474. },
  475. },
  476. Q = (function (t) {
  477. i(o, t);
  478. var n = h(o);
  479. function o() {
  480. var t;
  481. return e(this, o), ((t = n.apply(this, arguments)).polling = !1), t;
  482. }
  483. return (
  484. r(o, [
  485. {
  486. key: "name",
  487. get: function () {
  488. return "polling";
  489. },
  490. },
  491. {
  492. key: "doOpen",
  493. value: function () {
  494. this.poll();
  495. },
  496. },
  497. {
  498. key: "pause",
  499. value: function (t) {
  500. var e = this;
  501. this.readyState = "pausing";
  502. var n = function () {
  503. (e.readyState = "paused"), t();
  504. };
  505. if (this.polling || !this.writable) {
  506. var r = 0;
  507. this.polling &&
  508. (r++,
  509. this.once("pollComplete", function () {
  510. --r || n();
  511. })),
  512. this.writable ||
  513. (r++,
  514. this.once("drain", function () {
  515. --r || n();
  516. }));
  517. } else n();
  518. },
  519. },
  520. {
  521. key: "poll",
  522. value: function () {
  523. (this.polling = !0), this.doPoll(), this.emit("poll");
  524. },
  525. },
  526. {
  527. key: "onData",
  528. value: function (t) {
  529. var e = this;
  530. (function (t, e) {
  531. for (var n = t.split(V), r = [], o = 0; o < n.length; o++) {
  532. var i = F(n[o], e);
  533. if ((r.push(i), "error" === i.type)) break;
  534. }
  535. return r;
  536. })(t, this.socket.binaryType).forEach(function (t) {
  537. if (("opening" === e.readyState && "open" === t.type && e.onOpen(), "close" === t.type)) return e.onClose(), !1;
  538. e.onPacket(t);
  539. }),
  540. "closed" !== this.readyState && ((this.polling = !1), this.emit("pollComplete"), "open" === this.readyState && this.poll());
  541. },
  542. },
  543. {
  544. key: "doClose",
  545. value: function () {
  546. var t = this,
  547. e = function () {
  548. t.write([{ type: "close" }]);
  549. };
  550. "open" === this.readyState ? e() : this.once("open", e);
  551. },
  552. },
  553. {
  554. key: "write",
  555. value: function (t) {
  556. var e = this;
  557. (this.writable = !1),
  558. (function (t, e) {
  559. var n = t.length,
  560. r = new Array(n),
  561. o = 0;
  562. t.forEach(function (t, i) {
  563. x(t, !1, function (t) {
  564. (r[i] = t), ++o === n && e(r.join(V));
  565. });
  566. });
  567. })(t, function (t) {
  568. e.doWrite(t, function () {
  569. (e.writable = !0), e.emit("drain");
  570. });
  571. });
  572. },
  573. },
  574. {
  575. key: "uri",
  576. value: function () {
  577. var t = this.query || {},
  578. e = this.opts.secure ? "https" : "http",
  579. n = "";
  580. !1 !== this.opts.timestampRequests && (t[this.opts.timestampParam] = X()),
  581. this.supportsBinary || t.sid || (t.b64 = 1),
  582. this.opts.port && (("https" === e && 443 !== Number(this.opts.port)) || ("http" === e && 80 !== Number(this.opts.port))) && (n = ":" + this.opts.port);
  583. var r = G.encode(t);
  584. return e + "://" + (-1 !== this.opts.hostname.indexOf(":") ? "[" + this.opts.hostname + "]" : this.opts.hostname) + n + this.opts.path + (r.length ? "?" + r : "");
  585. },
  586. },
  587. ]),
  588. o
  589. );
  590. })(H);
  591. function Z() {}
  592. var tt = null != new b({ xdomain: !1 }).responseType,
  593. et = (function (t) {
  594. i(s, t);
  595. var n = h(s);
  596. function s(t) {
  597. var r;
  598. if ((e(this, s), (r = n.call(this, t)), "undefined" != typeof location)) {
  599. var o = "https:" === location.protocol,
  600. i = location.port;
  601. i || (i = o ? "443" : "80"), (r.xd = ("undefined" != typeof location && t.hostname !== location.hostname) || i !== t.port), (r.xs = t.secure !== o);
  602. }
  603. var a = t && t.forceBase64;
  604. return (r.supportsBinary = tt && !a), r;
  605. }
  606. return (
  607. r(s, [
  608. {
  609. key: "request",
  610. value: function () {
  611. var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
  612. return o(t, { xd: this.xd, xs: this.xs }, this.opts), new nt(this.uri(), t);
  613. },
  614. },
  615. {
  616. key: "doWrite",
  617. value: function (t, e) {
  618. var n = this,
  619. r = this.request({ method: "POST", data: t });
  620. r.on("success", e),
  621. r.on("error", function (t) {
  622. n.onError("xhr post error", t);
  623. });
  624. },
  625. },
  626. {
  627. key: "doPoll",
  628. value: function () {
  629. var t = this,
  630. e = this.request();
  631. e.on("data", this.onData.bind(this)),
  632. e.on("error", function (e) {
  633. t.onError("xhr poll error", e);
  634. }),
  635. (this.pollXhr = e);
  636. },
  637. },
  638. ]),
  639. s
  640. );
  641. })(Q),
  642. nt = (function (t) {
  643. i(o, t);
  644. var n = h(o);
  645. function o(t, r) {
  646. var i;
  647. return (
  648. e(this, o), A(c((i = n.call(this))), r), (i.opts = r), (i.method = r.method || "GET"), (i.uri = t), (i.async = !1 !== r.async), (i.data = void 0 !== r.data ? r.data : null), i.create(), i
  649. );
  650. }
  651. return (
  652. r(o, [
  653. {
  654. key: "create",
  655. value: function () {
  656. var t = this,
  657. e = w(this.opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
  658. (e.xdomain = !!this.opts.xd), (e.xscheme = !!this.opts.xs);
  659. var n = (this.xhr = new b(e));
  660. try {
  661. n.open(this.method, this.uri, this.async);
  662. try {
  663. if (this.opts.extraHeaders)
  664. for (var r in (n.setDisableHeaderCheck && n.setDisableHeaderCheck(!0), this.opts.extraHeaders))
  665. this.opts.extraHeaders.hasOwnProperty(r) && n.setRequestHeader(r, this.opts.extraHeaders[r]);
  666. } catch (t) {}
  667. if ("POST" === this.method)
  668. try {
  669. n.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
  670. } catch (t) {}
  671. try {
  672. n.setRequestHeader("Accept", "*/*");
  673. } catch (t) {}
  674. "withCredentials" in n && (n.withCredentials = this.opts.withCredentials),
  675. this.opts.requestTimeout && (n.timeout = this.opts.requestTimeout),
  676. (n.onreadystatechange = function () {
  677. 4 === n.readyState &&
  678. (200 === n.status || 1223 === n.status
  679. ? t.onLoad()
  680. : t.setTimeoutFn(function () {
  681. t.onError("number" == typeof n.status ? n.status : 0);
  682. }, 0));
  683. }),
  684. n.send(this.data);
  685. } catch (e) {
  686. return void this.setTimeoutFn(function () {
  687. t.onError(e);
  688. }, 0);
  689. }
  690. "undefined" != typeof document && ((this.index = o.requestsCount++), (o.requests[this.index] = this));
  691. },
  692. },
  693. {
  694. key: "onSuccess",
  695. value: function () {
  696. this.emit("success"), this.cleanup();
  697. },
  698. },
  699. {
  700. key: "onData",
  701. value: function (t) {
  702. this.emit("data", t), this.onSuccess();
  703. },
  704. },
  705. {
  706. key: "onError",
  707. value: function (t) {
  708. this.emit("error", t), this.cleanup(!0);
  709. },
  710. },
  711. {
  712. key: "cleanup",
  713. value: function (t) {
  714. if (void 0 !== this.xhr && null !== this.xhr) {
  715. if (((this.xhr.onreadystatechange = Z), t))
  716. try {
  717. this.xhr.abort();
  718. } catch (t) {}
  719. "undefined" != typeof document && delete o.requests[this.index], (this.xhr = null);
  720. }
  721. },
  722. },
  723. {
  724. key: "onLoad",
  725. value: function () {
  726. var t = this.xhr.responseText;
  727. null !== t && this.onData(t);
  728. },
  729. },
  730. {
  731. key: "abort",
  732. value: function () {
  733. this.cleanup();
  734. },
  735. },
  736. ]),
  737. o
  738. );
  739. })(R);
  740. if (((nt.requestsCount = 0), (nt.requests = {}), "undefined" != typeof document))
  741. if ("function" == typeof attachEvent) attachEvent("onunload", rt);
  742. else if ("function" == typeof addEventListener) {
  743. addEventListener("onpagehide" in k ? "pagehide" : "unload", rt, !1);
  744. }
  745. function rt() {
  746. for (var t in nt.requests) nt.requests.hasOwnProperty(t) && nt.requests[t].abort();
  747. }
  748. var ot =
  749. "function" == typeof Promise && "function" == typeof Promise.resolve
  750. ? function (t) {
  751. return Promise.resolve().then(t);
  752. }
  753. : function (t, e) {
  754. return e(t, 0);
  755. },
  756. it = k.WebSocket || k.MozWebSocket,
  757. st = "undefined" != typeof navigator && "string" == typeof navigator.product && "reactnative" === navigator.product.toLowerCase(),
  758. at = (function (t) {
  759. i(o, t);
  760. var n = h(o);
  761. function o(t) {
  762. var r;
  763. return e(this, o), ((r = n.call(this, t)).supportsBinary = !t.forceBase64), r;
  764. }
  765. return (
  766. r(o, [
  767. {
  768. key: "name",
  769. get: function () {
  770. return "websocket";
  771. },
  772. },
  773. {
  774. key: "doOpen",
  775. value: function () {
  776. if (this.check()) {
  777. var t = this.uri(),
  778. e = this.opts.protocols,
  779. n = st
  780. ? {}
  781. : w(
  782. this.opts,
  783. "agent",
  784. "perMessageDeflate",
  785. "pfx",
  786. "key",
  787. "passphrase",
  788. "cert",
  789. "ca",
  790. "ciphers",
  791. "rejectUnauthorized",
  792. "localAddress",
  793. "protocolVersion",
  794. "origin",
  795. "maxPayload",
  796. "family",
  797. "checkServerIdentity",
  798. );
  799. this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
  800. try {
  801. this.ws = st ? new it(t, e, n) : e ? new it(t, e) : new it(t);
  802. } catch (t) {
  803. return this.emit("error", t);
  804. }
  805. (this.ws.binaryType = this.socket.binaryType || "arraybuffer"), this.addEventListeners();
  806. }
  807. },
  808. },
  809. {
  810. key: "addEventListeners",
  811. value: function () {
  812. var t = this;
  813. (this.ws.onopen = function () {
  814. t.opts.autoUnref && t.ws._socket.unref(), t.onOpen();
  815. }),
  816. (this.ws.onclose = this.onClose.bind(this)),
  817. (this.ws.onmessage = function (e) {
  818. return t.onData(e.data);
  819. }),
  820. (this.ws.onerror = function (e) {
  821. return t.onError("websocket error", e);
  822. });
  823. },
  824. },
  825. {
  826. key: "write",
  827. value: function (t) {
  828. var e = this;
  829. this.writable = !1;
  830. for (
  831. var n = function (n) {
  832. var r = t[n],
  833. o = n === t.length - 1;
  834. x(r, e.supportsBinary, function (t) {
  835. try {
  836. e.ws.send(t);
  837. } catch (t) {}
  838. o &&
  839. ot(function () {
  840. (e.writable = !0), e.emit("drain");
  841. }, e.setTimeoutFn);
  842. });
  843. },
  844. r = 0;
  845. r < t.length;
  846. r++
  847. )
  848. n(r);
  849. },
  850. },
  851. {
  852. key: "doClose",
  853. value: function () {
  854. void 0 !== this.ws && (this.ws.close(), (this.ws = null));
  855. },
  856. },
  857. {
  858. key: "uri",
  859. value: function () {
  860. var t = this.query || {},
  861. e = this.opts.secure ? "wss" : "ws",
  862. n = "";
  863. this.opts.port && (("wss" === e && 443 !== Number(this.opts.port)) || ("ws" === e && 80 !== Number(this.opts.port))) && (n = ":" + this.opts.port),
  864. this.opts.timestampRequests && (t[this.opts.timestampParam] = X()),
  865. this.supportsBinary || (t.b64 = 1);
  866. var r = G.encode(t);
  867. return e + "://" + (-1 !== this.opts.hostname.indexOf(":") ? "[" + this.opts.hostname + "]" : this.opts.hostname) + n + this.opts.path + (r.length ? "?" + r : "");
  868. },
  869. },
  870. {
  871. key: "check",
  872. value: function () {
  873. return !(!it || ("__initialize" in it && this.name === o.prototype.name));
  874. },
  875. },
  876. ]),
  877. o
  878. );
  879. })(H),
  880. ct = { websocket: at, polling: et },
  881. ut = (function (n) {
  882. i(a, n);
  883. var s = h(a);
  884. function a(n) {
  885. var r,
  886. i = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
  887. return (
  888. e(this, a),
  889. (r = s.call(this)),
  890. n && "object" === t(n) && ((i = n), (n = null)),
  891. n
  892. ? ((n = v(n)), (i.hostname = n.host), (i.secure = "https" === n.protocol || "wss" === n.protocol), (i.port = n.port), n.query && (i.query = n.query))
  893. : i.host && (i.hostname = v(i.host).host),
  894. A(c(r), i),
  895. (r.secure = null != i.secure ? i.secure : "undefined" != typeof location && "https:" === location.protocol),
  896. i.hostname && !i.port && (i.port = r.secure ? "443" : "80"),
  897. (r.hostname = i.hostname || ("undefined" != typeof location ? location.hostname : "localhost")),
  898. (r.port = i.port || ("undefined" != typeof location && location.port ? location.port : r.secure ? "443" : "80")),
  899. (r.transports = i.transports || ["polling", "websocket"]),
  900. (r.readyState = ""),
  901. (r.writeBuffer = []),
  902. (r.prevBufferLen = 0),
  903. (r.opts = o(
  904. {
  905. path: "/engine.io",
  906. agent: !1,
  907. withCredentials: !1,
  908. upgrade: !0,
  909. timestampParam: "t",
  910. rememberUpgrade: !1,
  911. rejectUnauthorized: !0,
  912. perMessageDeflate: { threshold: 1024 },
  913. transportOptions: {},
  914. closeOnBeforeunload: !0,
  915. },
  916. i,
  917. )),
  918. (r.opts.path = r.opts.path.replace(/\/$/, "") + "/"),
  919. "string" == typeof r.opts.query && (r.opts.query = G.decode(r.opts.query)),
  920. (r.id = null),
  921. (r.upgrades = null),
  922. (r.pingInterval = null),
  923. (r.pingTimeout = null),
  924. (r.pingTimeoutTimer = null),
  925. "function" == typeof addEventListener &&
  926. (r.opts.closeOnBeforeunload &&
  927. addEventListener(
  928. "beforeunload",
  929. function () {
  930. r.transport && (r.transport.removeAllListeners(), r.transport.close());
  931. },
  932. !1,
  933. ),
  934. "localhost" !== r.hostname &&
  935. ((r.offlineEventListener = function () {
  936. r.onClose("transport close");
  937. }),
  938. addEventListener("offline", r.offlineEventListener, !1))),
  939. r.open(),
  940. r
  941. );
  942. }
  943. return (
  944. r(a, [
  945. {
  946. key: "createTransport",
  947. value: function (t) {
  948. var e = (function (t) {
  949. var e = {};
  950. for (var n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
  951. return e;
  952. })(this.opts.query);
  953. (e.EIO = 4), (e.transport = t), this.id && (e.sid = this.id);
  954. var n = o({}, this.opts.transportOptions[t], this.opts, { query: e, socket: this, hostname: this.hostname, secure: this.secure, port: this.port });
  955. return new ct[t](n);
  956. },
  957. },
  958. {
  959. key: "open",
  960. value: function () {
  961. var t,
  962. e = this;
  963. if (this.opts.rememberUpgrade && a.priorWebsocketSuccess && -1 !== this.transports.indexOf("websocket")) t = "websocket";
  964. else {
  965. if (0 === this.transports.length)
  966. return void this.setTimeoutFn(function () {
  967. e.emitReserved("error", "No transports available");
  968. }, 0);
  969. t = this.transports[0];
  970. }
  971. this.readyState = "opening";
  972. try {
  973. t = this.createTransport(t);
  974. } catch (t) {
  975. return this.transports.shift(), void this.open();
  976. }
  977. t.open(), this.setTransport(t);
  978. },
  979. },
  980. {
  981. key: "setTransport",
  982. value: function (t) {
  983. var e = this;
  984. this.transport && this.transport.removeAllListeners(),
  985. (this.transport = t),
  986. t
  987. .on("drain", this.onDrain.bind(this))
  988. .on("packet", this.onPacket.bind(this))
  989. .on("error", this.onError.bind(this))
  990. .on("close", function () {
  991. e.onClose("transport close");
  992. });
  993. },
  994. },
  995. {
  996. key: "probe",
  997. value: function (t) {
  998. var e = this,
  999. n = this.createTransport(t),
  1000. r = !1;
  1001. a.priorWebsocketSuccess = !1;
  1002. var o = function () {
  1003. r ||
  1004. (n.send([{ type: "ping", data: "probe" }]),
  1005. n.once("packet", function (t) {
  1006. if (!r)
  1007. if ("pong" === t.type && "probe" === t.data) {
  1008. if (((e.upgrading = !0), e.emitReserved("upgrading", n), !n)) return;
  1009. (a.priorWebsocketSuccess = "websocket" === n.name),
  1010. e.transport.pause(function () {
  1011. r || ("closed" !== e.readyState && (f(), e.setTransport(n), n.send([{ type: "upgrade" }]), e.emitReserved("upgrade", n), (n = null), (e.upgrading = !1), e.flush()));
  1012. });
  1013. } else {
  1014. var o = new Error("probe error");
  1015. (o.transport = n.name), e.emitReserved("upgradeError", o);
  1016. }
  1017. }));
  1018. };
  1019. function i() {
  1020. r || ((r = !0), f(), n.close(), (n = null));
  1021. }
  1022. var s = function (t) {
  1023. var r = new Error("probe error: " + t);
  1024. (r.transport = n.name), i(), e.emitReserved("upgradeError", r);
  1025. };
  1026. function c() {
  1027. s("transport closed");
  1028. }
  1029. function u() {
  1030. s("socket closed");
  1031. }
  1032. function h(t) {
  1033. n && t.name !== n.name && i();
  1034. }
  1035. var f = function () {
  1036. n.removeListener("open", o), n.removeListener("error", s), n.removeListener("close", c), e.off("close", u), e.off("upgrading", h);
  1037. };
  1038. n.once("open", o), n.once("error", s), n.once("close", c), this.once("close", u), this.once("upgrading", h), n.open();
  1039. },
  1040. },
  1041. {
  1042. key: "onOpen",
  1043. value: function () {
  1044. if (
  1045. ((this.readyState = "open"),
  1046. (a.priorWebsocketSuccess = "websocket" === this.transport.name),
  1047. this.emitReserved("open"),
  1048. this.flush(),
  1049. "open" === this.readyState && this.opts.upgrade && this.transport.pause)
  1050. )
  1051. for (var t = 0, e = this.upgrades.length; t < e; t++) this.probe(this.upgrades[t]);
  1052. },
  1053. },
  1054. {
  1055. key: "onPacket",
  1056. value: function (t) {
  1057. if ("opening" === this.readyState || "open" === this.readyState || "closing" === this.readyState)
  1058. switch ((this.emitReserved("packet", t), this.emitReserved("heartbeat"), t.type)) {
  1059. case "open":
  1060. this.onHandshake(JSON.parse(t.data));
  1061. break;
  1062. case "ping":
  1063. this.resetPingTimeout(), this.sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong");
  1064. break;
  1065. case "error":
  1066. var e = new Error("server error");
  1067. (e.code = t.data), this.onError(e);
  1068. break;
  1069. case "message":
  1070. this.emitReserved("data", t.data), this.emitReserved("message", t.data);
  1071. }
  1072. },
  1073. },
  1074. {
  1075. key: "onHandshake",
  1076. value: function (t) {
  1077. this.emitReserved("handshake", t),
  1078. (this.id = t.sid),
  1079. (this.transport.query.sid = t.sid),
  1080. (this.upgrades = this.filterUpgrades(t.upgrades)),
  1081. (this.pingInterval = t.pingInterval),
  1082. (this.pingTimeout = t.pingTimeout),
  1083. this.onOpen(),
  1084. "closed" !== this.readyState && this.resetPingTimeout();
  1085. },
  1086. },
  1087. {
  1088. key: "resetPingTimeout",
  1089. value: function () {
  1090. var t = this;
  1091. this.clearTimeoutFn(this.pingTimeoutTimer),
  1092. (this.pingTimeoutTimer = this.setTimeoutFn(function () {
  1093. t.onClose("ping timeout");
  1094. }, this.pingInterval + this.pingTimeout)),
  1095. this.opts.autoUnref && this.pingTimeoutTimer.unref();
  1096. },
  1097. },
  1098. {
  1099. key: "onDrain",
  1100. value: function () {
  1101. this.writeBuffer.splice(0, this.prevBufferLen), (this.prevBufferLen = 0), 0 === this.writeBuffer.length ? this.emitReserved("drain") : this.flush();
  1102. },
  1103. },
  1104. {
  1105. key: "flush",
  1106. value: function () {
  1107. "closed" !== this.readyState &&
  1108. this.transport.writable &&
  1109. !this.upgrading &&
  1110. this.writeBuffer.length &&
  1111. (this.transport.send(this.writeBuffer), (this.prevBufferLen = this.writeBuffer.length), this.emitReserved("flush"));
  1112. },
  1113. },
  1114. {
  1115. key: "write",
  1116. value: function (t, e, n) {
  1117. return this.sendPacket("message", t, e, n), this;
  1118. },
  1119. },
  1120. {
  1121. key: "send",
  1122. value: function (t, e, n) {
  1123. return this.sendPacket("message", t, e, n), this;
  1124. },
  1125. },
  1126. {
  1127. key: "sendPacket",
  1128. value: function (t, e, n, r) {
  1129. if (("function" == typeof e && ((r = e), (e = void 0)), "function" == typeof n && ((r = n), (n = null)), "closing" !== this.readyState && "closed" !== this.readyState)) {
  1130. (n = n || {}).compress = !1 !== n.compress;
  1131. var o = { type: t, data: e, options: n };
  1132. this.emitReserved("packetCreate", o), this.writeBuffer.push(o), r && this.once("flush", r), this.flush();
  1133. }
  1134. },
  1135. },
  1136. {
  1137. key: "close",
  1138. value: function () {
  1139. var t = this,
  1140. e = function () {
  1141. t.onClose("forced close"), t.transport.close();
  1142. },
  1143. n = function n() {
  1144. t.off("upgrade", n), t.off("upgradeError", n), e();
  1145. },
  1146. r = function () {
  1147. t.once("upgrade", n), t.once("upgradeError", n);
  1148. };
  1149. return (
  1150. ("opening" !== this.readyState && "open" !== this.readyState) ||
  1151. ((this.readyState = "closing"),
  1152. this.writeBuffer.length
  1153. ? this.once("drain", function () {
  1154. t.upgrading ? r() : e();
  1155. })
  1156. : this.upgrading
  1157. ? r()
  1158. : e()),
  1159. this
  1160. );
  1161. },
  1162. },
  1163. {
  1164. key: "onError",
  1165. value: function (t) {
  1166. (a.priorWebsocketSuccess = !1), this.emitReserved("error", t), this.onClose("transport error", t);
  1167. },
  1168. },
  1169. {
  1170. key: "onClose",
  1171. value: function (t, e) {
  1172. ("opening" !== this.readyState && "open" !== this.readyState && "closing" !== this.readyState) ||
  1173. (this.clearTimeoutFn(this.pingTimeoutTimer),
  1174. this.transport.removeAllListeners("close"),
  1175. this.transport.close(),
  1176. this.transport.removeAllListeners(),
  1177. "function" == typeof removeEventListener && removeEventListener("offline", this.offlineEventListener, !1),
  1178. (this.readyState = "closed"),
  1179. (this.id = null),
  1180. this.emitReserved("close", t, e),
  1181. (this.writeBuffer = []),
  1182. (this.prevBufferLen = 0));
  1183. },
  1184. },
  1185. {
  1186. key: "filterUpgrades",
  1187. value: function (t) {
  1188. for (var e = [], n = 0, r = t.length; n < r; n++) ~this.transports.indexOf(t[n]) && e.push(t[n]);
  1189. return e;
  1190. },
  1191. },
  1192. ]),
  1193. a
  1194. );
  1195. })(R);
  1196. ut.protocol = 4;
  1197. var ht = "function" == typeof ArrayBuffer,
  1198. ft = Object.prototype.toString,
  1199. lt = "function" == typeof Blob || ("undefined" != typeof Blob && "[object BlobConstructor]" === ft.call(Blob)),
  1200. pt = "function" == typeof File || ("undefined" != typeof File && "[object FileConstructor]" === ft.call(File));
  1201. function dt(t) {
  1202. return (
  1203. (ht &&
  1204. (t instanceof ArrayBuffer ||
  1205. (function (t) {
  1206. return "function" == typeof ArrayBuffer.isView ? ArrayBuffer.isView(t) : t.buffer instanceof ArrayBuffer;
  1207. })(t))) ||
  1208. (lt && t instanceof Blob) ||
  1209. (pt && t instanceof File)
  1210. );
  1211. }
  1212. function yt(e, n) {
  1213. if (!e || "object" !== t(e)) return !1;
  1214. if (Array.isArray(e)) {
  1215. for (var r = 0, o = e.length; r < o; r++) if (yt(e[r])) return !0;
  1216. return !1;
  1217. }
  1218. if (dt(e)) return !0;
  1219. if (e.toJSON && "function" == typeof e.toJSON && 1 === arguments.length) return yt(e.toJSON(), !0);
  1220. for (var i in e) if (Object.prototype.hasOwnProperty.call(e, i) && yt(e[i])) return !0;
  1221. return !1;
  1222. }
  1223. function vt(t) {
  1224. var e = [],
  1225. n = t.data,
  1226. r = t;
  1227. return (r.data = mt(n, e)), (r.attachments = e.length), { packet: r, buffers: e };
  1228. }
  1229. function mt(e, n) {
  1230. if (!e) return e;
  1231. if (dt(e)) {
  1232. var r = { _placeholder: !0, num: n.length };
  1233. return n.push(e), r;
  1234. }
  1235. if (Array.isArray(e)) {
  1236. for (var o = new Array(e.length), i = 0; i < e.length; i++) o[i] = mt(e[i], n);
  1237. return o;
  1238. }
  1239. if ("object" === t(e) && !(e instanceof Date)) {
  1240. var s = {};
  1241. for (var a in e) e.hasOwnProperty(a) && (s[a] = mt(e[a], n));
  1242. return s;
  1243. }
  1244. return e;
  1245. }
  1246. function gt(t, e) {
  1247. return (t.data = kt(t.data, e)), (t.attachments = void 0), t;
  1248. }
  1249. function kt(e, n) {
  1250. if (!e) return e;
  1251. if (e && e._placeholder) return n[e.num];
  1252. if (Array.isArray(e)) for (var r = 0; r < e.length; r++) e[r] = kt(e[r], n);
  1253. else if ("object" === t(e)) for (var o in e) e.hasOwnProperty(o) && (e[o] = kt(e[o], n));
  1254. return e;
  1255. }
  1256. var bt;
  1257. !(function (t) {
  1258. (t[(t.CONNECT = 0)] = "CONNECT"),
  1259. (t[(t.DISCONNECT = 1)] = "DISCONNECT"),
  1260. (t[(t.EVENT = 2)] = "EVENT"),
  1261. (t[(t.ACK = 3)] = "ACK"),
  1262. (t[(t.CONNECT_ERROR = 4)] = "CONNECT_ERROR"),
  1263. (t[(t.BINARY_EVENT = 5)] = "BINARY_EVENT"),
  1264. (t[(t.BINARY_ACK = 6)] = "BINARY_ACK");
  1265. })(bt || (bt = {}));
  1266. var wt = (function () {
  1267. function t() {
  1268. e(this, t);
  1269. }
  1270. return (
  1271. r(t, [
  1272. {
  1273. key: "encode",
  1274. value: function (t) {
  1275. return (t.type !== bt.EVENT && t.type !== bt.ACK) || !yt(t) ? [this.encodeAsString(t)] : ((t.type = t.type === bt.EVENT ? bt.BINARY_EVENT : bt.BINARY_ACK), this.encodeAsBinary(t));
  1276. },
  1277. },
  1278. {
  1279. key: "encodeAsString",
  1280. value: function (t) {
  1281. var e = "" + t.type;
  1282. return (
  1283. (t.type !== bt.BINARY_EVENT && t.type !== bt.BINARY_ACK) || (e += t.attachments + "-"),
  1284. t.nsp && "/" !== t.nsp && (e += t.nsp + ","),
  1285. null != t.id && (e += t.id),
  1286. null != t.data && (e += JSON.stringify(t.data)),
  1287. e
  1288. );
  1289. },
  1290. },
  1291. {
  1292. key: "encodeAsBinary",
  1293. value: function (t) {
  1294. var e = vt(t),
  1295. n = this.encodeAsString(e.packet),
  1296. r = e.buffers;
  1297. return r.unshift(n), r;
  1298. },
  1299. },
  1300. ]),
  1301. t
  1302. );
  1303. })(),
  1304. _t = (function (n) {
  1305. i(a, n);
  1306. var o = h(a);
  1307. function a() {
  1308. return e(this, a), o.call(this);
  1309. }
  1310. return (
  1311. r(
  1312. a,
  1313. [
  1314. {
  1315. key: "add",
  1316. value: function (t) {
  1317. var e;
  1318. if ("string" == typeof t)
  1319. (e = this.decodeString(t)).type === bt.BINARY_EVENT || e.type === bt.BINARY_ACK
  1320. ? ((this.reconstructor = new Et(e)), 0 === e.attachments && f(s(a.prototype), "emitReserved", this).call(this, "decoded", e))
  1321. : f(s(a.prototype), "emitReserved", this).call(this, "decoded", e);
  1322. else {
  1323. if (!dt(t) && !t.base64) throw new Error("Unknown type: " + t);
  1324. if (!this.reconstructor) throw new Error("got binary data when not reconstructing a packet");
  1325. (e = this.reconstructor.takeBinaryData(t)) && ((this.reconstructor = null), f(s(a.prototype), "emitReserved", this).call(this, "decoded", e));
  1326. }
  1327. },
  1328. },
  1329. {
  1330. key: "decodeString",
  1331. value: function (t) {
  1332. var e = 0,
  1333. n = { type: Number(t.charAt(0)) };
  1334. if (void 0 === bt[n.type]) throw new Error("unknown packet type " + n.type);
  1335. if (n.type === bt.BINARY_EVENT || n.type === bt.BINARY_ACK) {
  1336. for (var r = e + 1; "-" !== t.charAt(++e) && e != t.length; );
  1337. var o = t.substring(r, e);
  1338. if (o != Number(o) || "-" !== t.charAt(e)) throw new Error("Illegal attachments");
  1339. n.attachments = Number(o);
  1340. }
  1341. if ("/" === t.charAt(e + 1)) {
  1342. for (var i = e + 1; ++e; ) {
  1343. if ("," === t.charAt(e)) break;
  1344. if (e === t.length) break;
  1345. }
  1346. n.nsp = t.substring(i, e);
  1347. } else n.nsp = "/";
  1348. var s = t.charAt(e + 1);
  1349. if ("" !== s && Number(s) == s) {
  1350. for (var c = e + 1; ++e; ) {
  1351. var u = t.charAt(e);
  1352. if (null == u || Number(u) != u) {
  1353. --e;
  1354. break;
  1355. }
  1356. if (e === t.length) break;
  1357. }
  1358. n.id = Number(t.substring(c, e + 1));
  1359. }
  1360. if (t.charAt(++e)) {
  1361. var h = (function (t) {
  1362. try {
  1363. return JSON.parse(t);
  1364. } catch (t) {
  1365. return !1;
  1366. }
  1367. })(t.substr(e));
  1368. if (!a.isPayloadValid(n.type, h)) throw new Error("invalid payload");
  1369. n.data = h;
  1370. }
  1371. return n;
  1372. },
  1373. },
  1374. {
  1375. key: "destroy",
  1376. value: function () {
  1377. this.reconstructor && this.reconstructor.finishedReconstruction();
  1378. },
  1379. },
  1380. ],
  1381. [
  1382. {
  1383. key: "isPayloadValid",
  1384. value: function (e, n) {
  1385. switch (e) {
  1386. case bt.CONNECT:
  1387. return "object" === t(n);
  1388. case bt.DISCONNECT:
  1389. return void 0 === n;
  1390. case bt.CONNECT_ERROR:
  1391. return "string" == typeof n || "object" === t(n);
  1392. case bt.EVENT:
  1393. case bt.BINARY_EVENT:
  1394. return Array.isArray(n) && n.length > 0;
  1395. case bt.ACK:
  1396. case bt.BINARY_ACK:
  1397. return Array.isArray(n);
  1398. }
  1399. },
  1400. },
  1401. ],
  1402. ),
  1403. a
  1404. );
  1405. })(R);
  1406. var Et = (function () {
  1407. function t(n) {
  1408. e(this, t), (this.packet = n), (this.buffers = []), (this.reconPack = n);
  1409. }
  1410. return (
  1411. r(t, [
  1412. {
  1413. key: "takeBinaryData",
  1414. value: function (t) {
  1415. if ((this.buffers.push(t), this.buffers.length === this.reconPack.attachments)) {
  1416. var e = gt(this.reconPack, this.buffers);
  1417. return this.finishedReconstruction(), e;
  1418. }
  1419. return null;
  1420. },
  1421. },
  1422. {
  1423. key: "finishedReconstruction",
  1424. value: function () {
  1425. (this.reconPack = null), (this.buffers = []);
  1426. },
  1427. },
  1428. ]),
  1429. t
  1430. );
  1431. })(),
  1432. At = Object.freeze({
  1433. __proto__: null,
  1434. protocol: 5,
  1435. get PacketType() {
  1436. return bt;
  1437. },
  1438. Encoder: wt,
  1439. Decoder: _t,
  1440. });
  1441. function Rt(t, e, n) {
  1442. return (
  1443. t.on(e, n),
  1444. function () {
  1445. t.off(e, n);
  1446. }
  1447. );
  1448. }
  1449. var Tt = Object.freeze({ connect: 1, connect_error: 1, disconnect: 1, disconnecting: 1, newListener: 1, removeListener: 1 }),
  1450. Ct = (function (t) {
  1451. i(o, t);
  1452. var n = h(o);
  1453. function o(t, r, i) {
  1454. var s;
  1455. return (
  1456. e(this, o),
  1457. ((s = n.call(this)).connected = !1),
  1458. (s.disconnected = !0),
  1459. (s.receiveBuffer = []),
  1460. (s.sendBuffer = []),
  1461. (s.ids = 0),
  1462. (s.acks = {}),
  1463. (s.flags = {}),
  1464. (s.io = t),
  1465. (s.nsp = r),
  1466. i && i.auth && (s.auth = i.auth),
  1467. s.io._autoConnect && s.open(),
  1468. s
  1469. );
  1470. }
  1471. return (
  1472. r(o, [
  1473. {
  1474. key: "subEvents",
  1475. value: function () {
  1476. if (!this.subs) {
  1477. var t = this.io;
  1478. this.subs = [Rt(t, "open", this.onopen.bind(this)), Rt(t, "packet", this.onpacket.bind(this)), Rt(t, "error", this.onerror.bind(this)), Rt(t, "close", this.onclose.bind(this))];
  1479. }
  1480. },
  1481. },
  1482. {
  1483. key: "active",
  1484. get: function () {
  1485. return !!this.subs;
  1486. },
  1487. },
  1488. {
  1489. key: "connect",
  1490. value: function () {
  1491. return this.connected || (this.subEvents(), this.io._reconnecting || this.io.open(), "open" === this.io._readyState && this.onopen()), this;
  1492. },
  1493. },
  1494. {
  1495. key: "open",
  1496. value: function () {
  1497. return this.connect();
  1498. },
  1499. },
  1500. {
  1501. key: "send",
  1502. value: function () {
  1503. for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++) e[n] = arguments[n];
  1504. return e.unshift("message"), this.emit.apply(this, e), this;
  1505. },
  1506. },
  1507. {
  1508. key: "emit",
  1509. value: function (t) {
  1510. if (Tt.hasOwnProperty(t)) throw new Error('"' + t + '" is a reserved event name');
  1511. for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), r = 1; r < e; r++) n[r - 1] = arguments[r];
  1512. n.unshift(t);
  1513. var o = { type: bt.EVENT, data: n, options: {} };
  1514. if (((o.options.compress = !1 !== this.flags.compress), "function" == typeof n[n.length - 1])) {
  1515. var i = this.ids++,
  1516. s = n.pop();
  1517. this._registerAckCallback(i, s), (o.id = i);
  1518. }
  1519. var a = this.io.engine && this.io.engine.transport && this.io.engine.transport.writable,
  1520. c = this.flags.volatile && (!a || !this.connected);
  1521. return c || (this.connected ? this.packet(o) : this.sendBuffer.push(o)), (this.flags = {}), this;
  1522. },
  1523. },
  1524. {
  1525. key: "_registerAckCallback",
  1526. value: function (t, e) {
  1527. var n = this,
  1528. r = this.flags.timeout;
  1529. if (void 0 !== r) {
  1530. var o = this.io.setTimeoutFn(function () {
  1531. delete n.acks[t];
  1532. for (var r = 0; r < n.sendBuffer.length; r++) n.sendBuffer[r].id === t && n.sendBuffer.splice(r, 1);
  1533. e.call(n, new Error("operation has timed out"));
  1534. }, r);
  1535. this.acks[t] = function () {
  1536. n.io.clearTimeoutFn(o);
  1537. for (var t = arguments.length, r = new Array(t), i = 0; i < t; i++) r[i] = arguments[i];
  1538. e.apply(n, [null].concat(r));
  1539. };
  1540. } else this.acks[t] = e;
  1541. },
  1542. },
  1543. {
  1544. key: "packet",
  1545. value: function (t) {
  1546. (t.nsp = this.nsp), this.io._packet(t);
  1547. },
  1548. },
  1549. {
  1550. key: "onopen",
  1551. value: function () {
  1552. var t = this;
  1553. "function" == typeof this.auth
  1554. ? this.auth(function (e) {
  1555. t.packet({ type: bt.CONNECT, data: e });
  1556. })
  1557. : this.packet({ type: bt.CONNECT, data: this.auth });
  1558. },
  1559. },
  1560. {
  1561. key: "onerror",
  1562. value: function (t) {
  1563. this.connected || this.emitReserved("connect_error", t);
  1564. },
  1565. },
  1566. {
  1567. key: "onclose",
  1568. value: function (t) {
  1569. (this.connected = !1), (this.disconnected = !0), delete this.id, this.emitReserved("disconnect", t);
  1570. },
  1571. },
  1572. {
  1573. key: "onpacket",
  1574. value: function (t) {
  1575. if (t.nsp === this.nsp)
  1576. switch (t.type) {
  1577. case bt.CONNECT:
  1578. if (t.data && t.data.sid) {
  1579. var e = t.data.sid;
  1580. this.onconnect(e);
  1581. } else
  1582. this.emitReserved(
  1583. "connect_error",
  1584. new Error(
  1585. "It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)",
  1586. ),
  1587. );
  1588. break;
  1589. case bt.EVENT:
  1590. case bt.BINARY_EVENT:
  1591. this.onevent(t);
  1592. break;
  1593. case bt.ACK:
  1594. case bt.BINARY_ACK:
  1595. this.onack(t);
  1596. break;
  1597. case bt.DISCONNECT:
  1598. this.ondisconnect();
  1599. break;
  1600. case bt.CONNECT_ERROR:
  1601. this.destroy();
  1602. var n = new Error(t.data.message);
  1603. (n.data = t.data.data), this.emitReserved("connect_error", n);
  1604. }
  1605. },
  1606. },
  1607. {
  1608. key: "onevent",
  1609. value: function (t) {
  1610. var e = t.data || [];
  1611. null != t.id && e.push(this.ack(t.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e));
  1612. },
  1613. },
  1614. {
  1615. key: "emitEvent",
  1616. value: function (t) {
  1617. if (this._anyListeners && this._anyListeners.length) {
  1618. var e,
  1619. n = p(this._anyListeners.slice());
  1620. try {
  1621. for (n.s(); !(e = n.n()).done; ) {
  1622. e.value.apply(this, t);
  1623. }
  1624. } catch (t) {
  1625. n.e(t);
  1626. } finally {
  1627. n.f();
  1628. }
  1629. }
  1630. f(s(o.prototype), "emit", this).apply(this, t);
  1631. },
  1632. },
  1633. {
  1634. key: "ack",
  1635. value: function (t) {
  1636. var e = this,
  1637. n = !1;
  1638. return function () {
  1639. if (!n) {
  1640. n = !0;
  1641. for (var r = arguments.length, o = new Array(r), i = 0; i < r; i++) o[i] = arguments[i];
  1642. e.packet({ type: bt.ACK, id: t, data: o });
  1643. }
  1644. };
  1645. },
  1646. },
  1647. {
  1648. key: "onack",
  1649. value: function (t) {
  1650. var e = this.acks[t.id];
  1651. "function" == typeof e && (e.apply(this, t.data), delete this.acks[t.id]);
  1652. },
  1653. },
  1654. {
  1655. key: "onconnect",
  1656. value: function (t) {
  1657. (this.id = t), (this.connected = !0), (this.disconnected = !1), this.emitBuffered(), this.emitReserved("connect");
  1658. },
  1659. },
  1660. {
  1661. key: "emitBuffered",
  1662. value: function () {
  1663. var t = this;
  1664. this.receiveBuffer.forEach(function (e) {
  1665. return t.emitEvent(e);
  1666. }),
  1667. (this.receiveBuffer = []),
  1668. this.sendBuffer.forEach(function (e) {
  1669. return t.packet(e);
  1670. }),
  1671. (this.sendBuffer = []);
  1672. },
  1673. },
  1674. {
  1675. key: "ondisconnect",
  1676. value: function () {
  1677. this.destroy(), this.onclose("io server disconnect");
  1678. },
  1679. },
  1680. {
  1681. key: "destroy",
  1682. value: function () {
  1683. this.subs &&
  1684. (this.subs.forEach(function (t) {
  1685. return t();
  1686. }),
  1687. (this.subs = void 0)),
  1688. this.io._destroy(this);
  1689. },
  1690. },
  1691. {
  1692. key: "disconnect",
  1693. value: function () {
  1694. return this.connected && this.packet({ type: bt.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
  1695. },
  1696. },
  1697. {
  1698. key: "close",
  1699. value: function () {
  1700. return this.disconnect();
  1701. },
  1702. },
  1703. {
  1704. key: "compress",
  1705. value: function (t) {
  1706. return (this.flags.compress = t), this;
  1707. },
  1708. },
  1709. {
  1710. key: "volatile",
  1711. get: function () {
  1712. return (this.flags.volatile = !0), this;
  1713. },
  1714. },
  1715. {
  1716. key: "timeout",
  1717. value: function (t) {
  1718. return (this.flags.timeout = t), this;
  1719. },
  1720. },
  1721. {
  1722. key: "onAny",
  1723. value: function (t) {
  1724. return (this._anyListeners = this._anyListeners || []), this._anyListeners.push(t), this;
  1725. },
  1726. },
  1727. {
  1728. key: "prependAny",
  1729. value: function (t) {
  1730. return (this._anyListeners = this._anyListeners || []), this._anyListeners.unshift(t), this;
  1731. },
  1732. },
  1733. {
  1734. key: "offAny",
  1735. value: function (t) {
  1736. if (!this._anyListeners) return this;
  1737. if (t) {
  1738. for (var e = this._anyListeners, n = 0; n < e.length; n++) if (t === e[n]) return e.splice(n, 1), this;
  1739. } else this._anyListeners = [];
  1740. return this;
  1741. },
  1742. },
  1743. {
  1744. key: "listenersAny",
  1745. value: function () {
  1746. return this._anyListeners || [];
  1747. },
  1748. },
  1749. ]),
  1750. o
  1751. );
  1752. })(R),
  1753. Ot = St;
  1754. function St(t) {
  1755. (t = t || {}), (this.ms = t.min || 100), (this.max = t.max || 1e4), (this.factor = t.factor || 2), (this.jitter = t.jitter > 0 && t.jitter <= 1 ? t.jitter : 0), (this.attempts = 0);
  1756. }
  1757. (St.prototype.duration = function () {
  1758. var t = this.ms * Math.pow(this.factor, this.attempts++);
  1759. if (this.jitter) {
  1760. var e = Math.random(),
  1761. n = Math.floor(e * this.jitter * t);
  1762. t = 0 == (1 & Math.floor(10 * e)) ? t - n : t + n;
  1763. }
  1764. return 0 | Math.min(t, this.max);
  1765. }),
  1766. (St.prototype.reset = function () {
  1767. this.attempts = 0;
  1768. }),
  1769. (St.prototype.setMin = function (t) {
  1770. this.ms = t;
  1771. }),
  1772. (St.prototype.setMax = function (t) {
  1773. this.max = t;
  1774. }),
  1775. (St.prototype.setJitter = function (t) {
  1776. this.jitter = t;
  1777. });
  1778. var Bt = (function (n) {
  1779. i(s, n);
  1780. var o = h(s);
  1781. function s(n, r) {
  1782. var i, a;
  1783. e(this, s),
  1784. ((i = o.call(this)).nsps = {}),
  1785. (i.subs = []),
  1786. n && "object" === t(n) && ((r = n), (n = void 0)),
  1787. ((r = r || {}).path = r.path || "/socket.io"),
  1788. (i.opts = r),
  1789. A(c(i), r),
  1790. i.reconnection(!1 !== r.reconnection),
  1791. i.reconnectionAttempts(r.reconnectionAttempts || 1 / 0),
  1792. i.reconnectionDelay(r.reconnectionDelay || 1e3),
  1793. i.reconnectionDelayMax(r.reconnectionDelayMax || 5e3),
  1794. i.randomizationFactor(null !== (a = r.randomizationFactor) && void 0 !== a ? a : 0.5),
  1795. (i.backoff = new Ot({ min: i.reconnectionDelay(), max: i.reconnectionDelayMax(), jitter: i.randomizationFactor() })),
  1796. i.timeout(null == r.timeout ? 2e4 : r.timeout),
  1797. (i._readyState = "closed"),
  1798. (i.uri = n);
  1799. var u = r.parser || At;
  1800. return (i.encoder = new u.Encoder()), (i.decoder = new u.Decoder()), (i._autoConnect = !1 !== r.autoConnect), i._autoConnect && i.open(), i;
  1801. }
  1802. return (
  1803. r(s, [
  1804. {
  1805. key: "reconnection",
  1806. value: function (t) {
  1807. return arguments.length ? ((this._reconnection = !!t), this) : this._reconnection;
  1808. },
  1809. },
  1810. {
  1811. key: "reconnectionAttempts",
  1812. value: function (t) {
  1813. return void 0 === t ? this._reconnectionAttempts : ((this._reconnectionAttempts = t), this);
  1814. },
  1815. },
  1816. {
  1817. key: "reconnectionDelay",
  1818. value: function (t) {
  1819. var e;
  1820. return void 0 === t ? this._reconnectionDelay : ((this._reconnectionDelay = t), null === (e = this.backoff) || void 0 === e || e.setMin(t), this);
  1821. },
  1822. },
  1823. {
  1824. key: "randomizationFactor",
  1825. value: function (t) {
  1826. var e;
  1827. return void 0 === t ? this._randomizationFactor : ((this._randomizationFactor = t), null === (e = this.backoff) || void 0 === e || e.setJitter(t), this);
  1828. },
  1829. },
  1830. {
  1831. key: "reconnectionDelayMax",
  1832. value: function (t) {
  1833. var e;
  1834. return void 0 === t ? this._reconnectionDelayMax : ((this._reconnectionDelayMax = t), null === (e = this.backoff) || void 0 === e || e.setMax(t), this);
  1835. },
  1836. },
  1837. {
  1838. key: "timeout",
  1839. value: function (t) {
  1840. return arguments.length ? ((this._timeout = t), this) : this._timeout;
  1841. },
  1842. },
  1843. {
  1844. key: "maybeReconnectOnOpen",
  1845. value: function () {
  1846. !this._reconnecting && this._reconnection && 0 === this.backoff.attempts && this.reconnect();
  1847. },
  1848. },
  1849. {
  1850. key: "open",
  1851. value: function (t) {
  1852. var e = this;
  1853. if (~this._readyState.indexOf("open")) return this;
  1854. this.engine = new ut(this.uri, this.opts);
  1855. var n = this.engine,
  1856. r = this;
  1857. (this._readyState = "opening"), (this.skipReconnect = !1);
  1858. var o = Rt(n, "open", function () {
  1859. r.onopen(), t && t();
  1860. }),
  1861. i = Rt(n, "error", function (n) {
  1862. r.cleanup(), (r._readyState = "closed"), e.emitReserved("error", n), t ? t(n) : r.maybeReconnectOnOpen();
  1863. });
  1864. if (!1 !== this._timeout) {
  1865. var s = this._timeout;
  1866. 0 === s && o();
  1867. var a = this.setTimeoutFn(function () {
  1868. o(), n.close(), n.emit("error", new Error("timeout"));
  1869. }, s);
  1870. this.opts.autoUnref && a.unref(),
  1871. this.subs.push(function () {
  1872. clearTimeout(a);
  1873. });
  1874. }
  1875. return this.subs.push(o), this.subs.push(i), this;
  1876. },
  1877. },
  1878. {
  1879. key: "connect",
  1880. value: function (t) {
  1881. return this.open(t);
  1882. },
  1883. },
  1884. {
  1885. key: "onopen",
  1886. value: function () {
  1887. this.cleanup(), (this._readyState = "open"), this.emitReserved("open");
  1888. var t = this.engine;
  1889. this.subs.push(
  1890. Rt(t, "ping", this.onping.bind(this)),
  1891. Rt(t, "data", this.ondata.bind(this)),
  1892. Rt(t, "error", this.onerror.bind(this)),
  1893. Rt(t, "close", this.onclose.bind(this)),
  1894. Rt(this.decoder, "decoded", this.ondecoded.bind(this)),
  1895. );
  1896. },
  1897. },
  1898. {
  1899. key: "onping",
  1900. value: function () {
  1901. this.emitReserved("ping");
  1902. },
  1903. },
  1904. {
  1905. key: "ondata",
  1906. value: function (t) {
  1907. this.decoder.add(t);
  1908. },
  1909. },
  1910. {
  1911. key: "ondecoded",
  1912. value: function (t) {
  1913. this.emitReserved("packet", t);
  1914. },
  1915. },
  1916. {
  1917. key: "onerror",
  1918. value: function (t) {
  1919. this.emitReserved("error", t);
  1920. },
  1921. },
  1922. {
  1923. key: "socket",
  1924. value: function (t, e) {
  1925. var n = this.nsps[t];
  1926. return n || ((n = new Ct(this, t, e)), (this.nsps[t] = n)), n;
  1927. },
  1928. },
  1929. {
  1930. key: "_destroy",
  1931. value: function (t) {
  1932. for (var e = 0, n = Object.keys(this.nsps); e < n.length; e++) {
  1933. var r = n[e];
  1934. if (this.nsps[r].active) return;
  1935. }
  1936. this._close();
  1937. },
  1938. },
  1939. {
  1940. key: "_packet",
  1941. value: function (t) {
  1942. for (var e = this.encoder.encode(t), n = 0; n < e.length; n++) this.engine.write(e[n], t.options);
  1943. },
  1944. },
  1945. {
  1946. key: "cleanup",
  1947. value: function () {
  1948. this.subs.forEach(function (t) {
  1949. return t();
  1950. }),
  1951. (this.subs.length = 0),
  1952. this.decoder.destroy();
  1953. },
  1954. },
  1955. {
  1956. key: "_close",
  1957. value: function () {
  1958. (this.skipReconnect = !0), (this._reconnecting = !1), this.onclose("forced close"), this.engine && this.engine.close();
  1959. },
  1960. },
  1961. {
  1962. key: "disconnect",
  1963. value: function () {
  1964. return this._close();
  1965. },
  1966. },
  1967. {
  1968. key: "onclose",
  1969. value: function (t) {
  1970. this.cleanup(), this.backoff.reset(), (this._readyState = "closed"), this.emitReserved("close", t), this._reconnection && !this.skipReconnect && this.reconnect();
  1971. },
  1972. },
  1973. {
  1974. key: "reconnect",
  1975. value: function () {
  1976. var t = this;
  1977. if (this._reconnecting || this.skipReconnect) return this;
  1978. var e = this;
  1979. if (this.backoff.attempts >= this._reconnectionAttempts) this.backoff.reset(), this.emitReserved("reconnect_failed"), (this._reconnecting = !1);
  1980. else {
  1981. var n = this.backoff.duration();
  1982. this._reconnecting = !0;
  1983. var r = this.setTimeoutFn(function () {
  1984. e.skipReconnect ||
  1985. (t.emitReserved("reconnect_attempt", e.backoff.attempts),
  1986. e.skipReconnect ||
  1987. e.open(function (n) {
  1988. n ? ((e._reconnecting = !1), e.reconnect(), t.emitReserved("reconnect_error", n)) : e.onreconnect();
  1989. }));
  1990. }, n);
  1991. this.opts.autoUnref && r.unref(),
  1992. this.subs.push(function () {
  1993. clearTimeout(r);
  1994. });
  1995. }
  1996. },
  1997. },
  1998. {
  1999. key: "onreconnect",
  2000. value: function () {
  2001. var t = this.backoff.attempts;
  2002. (this._reconnecting = !1), this.backoff.reset(), this.emitReserved("reconnect", t);
  2003. },
  2004. },
  2005. ]),
  2006. s
  2007. );
  2008. })(R),
  2009. Nt = {};
  2010. function xt(e, n) {
  2011. "object" === t(e) && ((n = e), (e = void 0));
  2012. var r,
  2013. o = (function (t) {
  2014. var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "",
  2015. n = arguments.length > 2 ? arguments[2] : void 0,
  2016. r = t;
  2017. (n = n || ("undefined" != typeof location && location)),
  2018. null == t && (t = n.protocol + "//" + n.host),
  2019. "string" == typeof t &&
  2020. ("/" === t.charAt(0) && (t = "/" === t.charAt(1) ? n.protocol + t : n.host + t), /^(https?|wss?):\/\//.test(t) || (t = void 0 !== n ? n.protocol + "//" + t : "https://" + t), (r = v(t))),
  2021. r.port || (/^(http|ws)$/.test(r.protocol) ? (r.port = "80") : /^(http|ws)s$/.test(r.protocol) && (r.port = "443")),
  2022. (r.path = r.path || "/");
  2023. var o = -1 !== r.host.indexOf(":") ? "[" + r.host + "]" : r.host;
  2024. return (r.id = r.protocol + "://" + o + ":" + r.port + e), (r.href = r.protocol + "://" + o + (n && n.port === r.port ? "" : ":" + r.port)), r;
  2025. })(e, (n = n || {}).path || "/socket.io"),
  2026. i = o.source,
  2027. s = o.id,
  2028. a = o.path,
  2029. c = Nt[s] && a in Nt[s].nsps;
  2030. return (
  2031. n.forceNew || n["force new connection"] || !1 === n.multiplex || c ? (r = new Bt(i, n)) : (Nt[s] || (Nt[s] = new Bt(i, n)), (r = Nt[s])),
  2032. o.query && !n.query && (n.query = o.queryKey),
  2033. r.socket(o.path, n)
  2034. );
  2035. }
  2036. return o(xt, { Manager: Bt, Socket: Ct, io: xt, connect: xt }), xt;
  2037. });
  2038. //# sourceMappingURL=socket.io.min.js.map