@danidoble/webserial 4.4.0-beta.1 → 4.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/boardroid.cjs +1 -1
  2. package/dist/boardroid.js +106 -101
  3. package/dist/hopper.cjs +2 -2
  4. package/dist/hopper.js +66 -51
  5. package/dist/jofemar.cjs +1 -1
  6. package/dist/jofemar.js +62 -144
  7. package/dist/kernel-C1HLYiV1.cjs +1 -0
  8. package/dist/kernel-C8ISUhzV.cjs +1 -0
  9. package/dist/kernel-CQcZ_OiG.js +831 -0
  10. package/dist/{kernel-505KqpPU.js → kernel-DkC7Kj3m.js} +151 -125
  11. package/dist/kernel-DtXV8d8B.js +831 -0
  12. package/dist/kernel-DyNuXvtW.cjs +1 -0
  13. package/dist/kernel-aqBCxtkj.js +831 -0
  14. package/dist/kernel-pO_elWba.cjs +1 -0
  15. package/dist/kernel.cjs +2 -2
  16. package/dist/kernel.d.ts +14 -0
  17. package/dist/kernel.d.ts.map +1 -0
  18. package/dist/kernel.js +3 -4
  19. package/dist/locker.cjs +1 -1
  20. package/dist/locker.js +33 -26
  21. package/dist/main.d.ts +28 -0
  22. package/dist/main.d.ts.map +1 -0
  23. package/dist/pinpad.cjs +15 -20
  24. package/dist/pinpad.js +1405 -1259
  25. package/dist/pinpax.cjs +4 -4
  26. package/dist/pinpax.js +68 -68
  27. package/dist/{relay-CsdB0FSa.js → relay-DP8PLsDP.js} +2 -2
  28. package/dist/{relay-DGFymXOw.cjs → relay-E3NCcSjS.cjs} +1 -1
  29. package/dist/relay.cjs +1 -1
  30. package/dist/relay.js +11 -29
  31. package/dist/serial/boardroid.d.ts +206 -0
  32. package/dist/serial/boardroid.d.ts.map +1 -0
  33. package/dist/serial/hopper.d.ts +85 -0
  34. package/dist/serial/hopper.d.ts.map +1 -0
  35. package/dist/serial/jofemar.d.ts +218 -0
  36. package/dist/serial/jofemar.d.ts.map +1 -0
  37. package/dist/serial/kernel.d.ts +137 -0
  38. package/dist/serial/kernel.d.ts.map +1 -0
  39. package/dist/serial/locker.d.ts +33 -0
  40. package/dist/serial/locker.d.ts.map +1 -0
  41. package/dist/serial/pinpad.d.ts +263 -0
  42. package/dist/serial/pinpad.d.ts.map +1 -0
  43. package/dist/serial/pinpax.d.ts +60 -0
  44. package/dist/serial/pinpax.d.ts.map +1 -0
  45. package/dist/serial/relay.d.ts +13 -0
  46. package/dist/serial/relay.d.ts.map +1 -0
  47. package/dist/utils/devices.d.ts +26 -0
  48. package/dist/utils/devices.d.ts.map +1 -0
  49. package/dist/utils/dispatcher.d.ts +17 -0
  50. package/dist/utils/dispatcher.d.ts.map +1 -0
  51. package/dist/utils/emulator.d.ts +80 -0
  52. package/dist/utils/emulator.d.ts.map +1 -0
  53. package/dist/utils/utils.d.ts +7 -0
  54. package/dist/utils/utils.d.ts.map +1 -0
  55. package/dist/{webserial-core-C0ZbaNYy.js → webserial-core-CH2Xov2y.js} +943 -933
  56. package/dist/webserial-core-Cj_EZjAU.cjs +4 -0
  57. package/dist/webserial-core-D3luFguv.js +3325 -0
  58. package/dist/webserial-core-YjdXyVOx.cjs +4 -0
  59. package/dist/webserial.cjs +2 -2
  60. package/dist/webserial.js +19 -19
  61. package/package.json +17 -14
  62. package/dist/kernel-Dq3Fv1y8.cjs +0 -1
  63. package/dist/webserial-core-B7vfLzGH.cjs +0 -4
@@ -1,124 +1,124 @@
1
1
  class Y extends CustomEvent {
2
- constructor(t, e) {
3
- super(t, e);
2
+ constructor(e, t) {
3
+ super(e, t);
4
4
  }
5
5
  }
6
- class et extends EventTarget {
6
+ class te extends EventTarget {
7
7
  __listeners__ = {
8
8
  debug: !1
9
9
  };
10
10
  __debug__ = !1;
11
11
  __listenersCallbacks__ = [];
12
- dispatch(t, e = null) {
13
- const n = new Y(t, { detail: e });
14
- this.dispatchEvent(n), this.__debug__ && this.dispatchEvent(new Y("debug", { detail: { type: t, data: e } }));
12
+ dispatch(e, t = null) {
13
+ const n = new Y(e, { detail: t });
14
+ this.dispatchEvent(n), this.__debug__ && this.dispatchEvent(new Y("debug", { detail: { type: e, data: t } }));
15
15
  }
16
- dispatchAsync(t, e = null, n = 100) {
16
+ dispatchAsync(e, t = null, n = 100) {
17
17
  const r = this;
18
18
  setTimeout(() => {
19
- r.dispatch(t, e);
19
+ r.dispatch(e, t);
20
20
  }, n);
21
21
  }
22
- on(t, e) {
23
- typeof this.__listeners__[t] < "u" && !this.__listeners__[t] && (this.__listeners__[t] = !0), this.__listenersCallbacks__.push({ key: t, callback: e }), this.addEventListener(t, e);
22
+ on(e, t) {
23
+ typeof this.__listeners__[e] < "u" && !this.__listeners__[e] && (this.__listeners__[e] = !0), this.__listenersCallbacks__.push({ key: e, callback: t }), this.addEventListener(e, t);
24
24
  }
25
- off(t, e) {
26
- this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((n) => !(n.key === t && n.callback === e)), this.removeEventListener(t, e);
25
+ off(e, t) {
26
+ this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((n) => !(n.key === e && n.callback === t)), this.removeEventListener(e, t);
27
27
  }
28
- serialRegisterAvailableListener(t) {
29
- this.__listeners__[t] || (this.__listeners__[t] = !1);
28
+ serialRegisterAvailableListener(e) {
29
+ this.__listeners__[e] || (this.__listeners__[e] = !1);
30
30
  }
31
31
  get availableListeners() {
32
- return Object.keys(this.__listeners__).sort().map((t) => ({
33
- type: t,
34
- listening: this.__listeners__[t]
32
+ return Object.keys(this.__listeners__).sort().map((e) => ({
33
+ type: e,
34
+ listening: this.__listeners__[e]
35
35
  }));
36
36
  }
37
37
  removeAllListeners() {
38
- for (const t of this.__listenersCallbacks__)
39
- ["internal:queue"].includes(t.key) || (this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((e) => !(e.key === t.key && e.callback === t.callback)), this.removeEventListener(t.key, t.callback));
40
- for (const t of Object.keys(this.__listeners__))
41
- this.__listeners__[t] = !1;
38
+ for (const e of this.__listenersCallbacks__)
39
+ ["internal:queue"].includes(e.key) || (this.__listenersCallbacks__ = this.__listenersCallbacks__.filter((t) => !(t.key === e.key && t.callback === e.callback)), this.removeEventListener(e.key, e.callback));
40
+ for (const e of Object.keys(this.__listeners__))
41
+ this.__listeners__[e] = !1;
42
42
  }
43
43
  }
44
- class a extends et {
44
+ class a extends te {
45
45
  static instance;
46
46
  static devices = {};
47
47
  constructor() {
48
- super(), ["change"].forEach((t) => {
49
- this.serialRegisterAvailableListener(t);
48
+ super(), ["change"].forEach((e) => {
49
+ this.serialRegisterAvailableListener(e);
50
50
  });
51
51
  }
52
- static $dispatchChange(t = null) {
53
- t && t.$checkAndDispatchConnection(), a.instance.dispatch("change", { devices: a.devices, dispatcher: t });
52
+ static $dispatchChange(e = null) {
53
+ e && e.$checkAndDispatchConnection(), a.instance.dispatch("change", { devices: a.devices, dispatcher: e });
54
54
  }
55
- static typeError(t) {
56
- const e = new Error();
57
- throw e.message = `Type ${t} is not supported`, e.name = "DeviceTypeError", e;
55
+ static typeError(e) {
56
+ const t = new Error();
57
+ throw t.message = `Type ${e} is not supported`, t.name = "DeviceTypeError", t;
58
58
  }
59
- static registerType(t) {
60
- typeof a.devices[t] > "u" && (a.devices = { ...a.devices, [t]: {} });
59
+ static registerType(e) {
60
+ typeof a.devices[e] > "u" && (a.devices = { ...a.devices, [e]: {} });
61
61
  }
62
- static add(t) {
63
- const e = t.typeDevice;
64
- typeof a.devices[e] > "u" && a.registerType(e);
65
- const n = t.uuid;
66
- if (typeof a.devices[e] > "u" && a.typeError(e), a.devices[e][n])
62
+ static add(e) {
63
+ const t = e.typeDevice;
64
+ typeof a.devices[t] > "u" && a.registerType(t);
65
+ const n = e.uuid;
66
+ if (typeof a.devices[t] > "u" && a.typeError(t), a.devices[t][n])
67
67
  throw new Error(`Device with id ${n} already exists`);
68
- return a.devices[e][n] = t, a.$dispatchChange(t), Object.keys(a.devices[e]).indexOf(n);
68
+ return a.devices[t][n] = e, a.$dispatchChange(e), Object.keys(a.devices[t]).indexOf(n);
69
69
  }
70
- static get(t, e) {
71
- return typeof a.devices[t] > "u" && a.registerType(t), typeof a.devices[t] > "u" && a.typeError(t), a.devices[t][e];
70
+ static get(e, t) {
71
+ return typeof a.devices[e] > "u" && a.registerType(e), typeof a.devices[e] > "u" && a.typeError(e), a.devices[e][t];
72
72
  }
73
- static getAll(t = null) {
74
- return t === null ? a.devices : (typeof a.devices[t] > "u" && a.typeError(t), a.devices[t]);
73
+ static getAll(e = null) {
74
+ return e === null ? a.devices : (typeof a.devices[e] > "u" && a.typeError(e), a.devices[e]);
75
75
  }
76
76
  static getList() {
77
- return Object.values(a.devices).map((t) => Object.values(t)).flat();
77
+ return Object.values(a.devices).map((e) => Object.values(e)).flat();
78
78
  }
79
- static getByNumber(t, e) {
80
- return typeof a.devices[t] > "u" && a.typeError(t), Object.values(a.devices[t]).find((n) => n.deviceNumber === e) ?? null;
79
+ static getByNumber(e, t) {
80
+ return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((n) => n.deviceNumber === t) ?? null;
81
81
  }
82
- static getCustom(t, e = 1) {
83
- return typeof a.devices[t] > "u" && a.typeError(t), Object.values(a.devices[t]).find((n) => n.deviceNumber === e) ?? null;
82
+ static getCustom(e, t = 1) {
83
+ return typeof a.devices[e] > "u" && a.typeError(e), Object.values(a.devices[e]).find((n) => n.deviceNumber === t) ?? null;
84
84
  }
85
85
  static async connectToAll() {
86
- const t = a.getList();
87
- for (const e of t)
88
- e.isConnected || await e.connect().catch(console.warn);
86
+ const e = a.getList();
87
+ for (const t of e)
88
+ t.isConnected || await t.connect().catch(console.warn);
89
89
  return Promise.resolve(a.areAllConnected());
90
90
  }
91
91
  static async disconnectAll() {
92
- const t = a.getList();
93
- for (const e of t)
94
- e.isDisconnected || await e.disconnect().catch(console.warn);
92
+ const e = a.getList();
93
+ for (const t of e)
94
+ t.isDisconnected || await t.disconnect().catch(console.warn);
95
95
  return Promise.resolve(a.areAllDisconnected());
96
96
  }
97
97
  static async areAllConnected() {
98
- const t = a.getList();
99
- for (const e of t)
100
- if (!e.isConnected) return Promise.resolve(!1);
98
+ const e = a.getList();
99
+ for (const t of e)
100
+ if (!t.isConnected) return Promise.resolve(!1);
101
101
  return Promise.resolve(!0);
102
102
  }
103
103
  static async areAllDisconnected() {
104
- const t = a.getList();
105
- for (const e of t)
106
- if (!e.isDisconnected) return Promise.resolve(!1);
104
+ const e = a.getList();
105
+ for (const t of e)
106
+ if (!t.isDisconnected) return Promise.resolve(!1);
107
107
  return Promise.resolve(!0);
108
108
  }
109
109
  static async getAllConnected() {
110
- const t = a.getList();
111
- return Promise.resolve(t.filter((e) => e.isConnected));
110
+ const e = a.getList();
111
+ return Promise.resolve(e.filter((t) => t.isConnected));
112
112
  }
113
113
  static async getAllDisconnected() {
114
- const t = a.getList();
115
- return Promise.resolve(t.filter((e) => e.isDisconnected));
114
+ const e = a.getList();
115
+ return Promise.resolve(e.filter((t) => t.isDisconnected));
116
116
  }
117
117
  }
118
118
  a.instance || (a.instance = new a());
119
119
  function J(s = 100) {
120
120
  return new Promise(
121
- (t) => setTimeout(() => t(), s)
121
+ (e) => setTimeout(() => e(), s)
122
122
  );
123
123
  }
124
124
  const m = /* @__PURE__ */ Object.create(null);
@@ -133,88 +133,88 @@ const x = /* @__PURE__ */ Object.create(null);
133
133
  Object.keys(m).forEach((s) => {
134
134
  x[m[s]] = s;
135
135
  });
136
- const q = { type: "error", data: "parser error" }, st = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", nt = typeof ArrayBuffer == "function", rt = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s && s.buffer instanceof ArrayBuffer, V = ({ type: s, data: t }, e, n) => st && t instanceof Blob ? e ? n(t) : Q(t, n) : nt && (t instanceof ArrayBuffer || rt(t)) ? e ? n(t) : Q(new Blob([t]), n) : n(m[s] + (t || "")), Q = (s, t) => {
137
- const e = new FileReader();
138
- return e.onload = function() {
139
- const n = e.result.split(",")[1];
140
- t("b" + (n || ""));
141
- }, e.readAsDataURL(s);
136
+ const D = { type: "error", data: "parser error" }, se = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", ne = typeof ArrayBuffer == "function", re = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s && s.buffer instanceof ArrayBuffer, V = ({ type: s, data: e }, t, n) => se && e instanceof Blob ? t ? n(e) : Q(e, n) : ne && (e instanceof ArrayBuffer || re(e)) ? t ? n(e) : Q(new Blob([e]), n) : n(m[s] + (e || "")), Q = (s, e) => {
137
+ const t = new FileReader();
138
+ return t.onload = function() {
139
+ const n = t.result.split(",")[1];
140
+ e("b" + (n || ""));
141
+ }, t.readAsDataURL(s);
142
142
  };
143
143
  function X(s) {
144
144
  return s instanceof Uint8Array ? s : s instanceof ArrayBuffer ? new Uint8Array(s) : new Uint8Array(s.buffer, s.byteOffset, s.byteLength);
145
145
  }
146
146
  let P;
147
- function ft(s, t) {
148
- if (st && s.data instanceof Blob)
149
- return s.data.arrayBuffer().then(X).then(t);
150
- if (nt && (s.data instanceof ArrayBuffer || rt(s.data)))
151
- return t(X(s.data));
152
- V(s, !1, (e) => {
153
- P || (P = new TextEncoder()), t(P.encode(e));
147
+ function fe(s, e) {
148
+ if (se && s.data instanceof Blob)
149
+ return s.data.arrayBuffer().then(X).then(e);
150
+ if (ne && (s.data instanceof ArrayBuffer || re(s.data)))
151
+ return e(X(s.data));
152
+ V(s, !1, (t) => {
153
+ P || (P = new TextEncoder()), e(P.encode(t));
154
154
  });
155
155
  }
156
156
  const G = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", E = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
157
157
  for (let s = 0; s < G.length; s++)
158
158
  E[G.charCodeAt(s)] = s;
159
- const yt = (s) => {
160
- let t = s.length * 0.75, e = s.length, n, r = 0, i, o, h, c;
161
- s[s.length - 1] === "=" && (t--, s[s.length - 2] === "=" && t--);
162
- const p = new ArrayBuffer(t), u = new Uint8Array(p);
163
- for (n = 0; n < e; n += 4)
159
+ const ye = (s) => {
160
+ let e = s.length * 0.75, t = s.length, n, r = 0, i, o, h, c;
161
+ s[s.length - 1] === "=" && (e--, s[s.length - 2] === "=" && e--);
162
+ const p = new ArrayBuffer(e), u = new Uint8Array(p);
163
+ for (n = 0; n < t; n += 4)
164
164
  i = E[s.charCodeAt(n)], o = E[s.charCodeAt(n + 1)], h = E[s.charCodeAt(n + 2)], c = E[s.charCodeAt(n + 3)], u[r++] = i << 2 | o >> 4, u[r++] = (o & 15) << 4 | h >> 2, u[r++] = (h & 3) << 6 | c & 63;
165
165
  return p;
166
- }, gt = typeof ArrayBuffer == "function", H = (s, t) => {
166
+ }, ge = typeof ArrayBuffer == "function", H = (s, e) => {
167
167
  if (typeof s != "string")
168
168
  return {
169
169
  type: "message",
170
- data: it(s, t)
170
+ data: ie(s, e)
171
171
  };
172
- const e = s.charAt(0);
173
- return e === "b" ? {
172
+ const t = s.charAt(0);
173
+ return t === "b" ? {
174
174
  type: "message",
175
- data: mt(s.substring(1), t)
176
- } : x[e] ? s.length > 1 ? {
177
- type: x[e],
175
+ data: me(s.substring(1), e)
176
+ } : x[t] ? s.length > 1 ? {
177
+ type: x[t],
178
178
  data: s.substring(1)
179
179
  } : {
180
- type: x[e]
181
- } : q;
182
- }, mt = (s, t) => {
183
- if (gt) {
184
- const e = yt(s);
185
- return it(e, t);
180
+ type: x[t]
181
+ } : D;
182
+ }, me = (s, e) => {
183
+ if (ge) {
184
+ const t = ye(s);
185
+ return ie(t, e);
186
186
  } else
187
187
  return { base64: !0, data: s };
188
- }, it = (s, t) => {
189
- switch (t) {
188
+ }, ie = (s, e) => {
189
+ switch (e) {
190
190
  case "blob":
191
191
  return s instanceof Blob ? s : new Blob([s]);
192
192
  case "arraybuffer":
193
193
  default:
194
194
  return s instanceof ArrayBuffer ? s : s.buffer;
195
195
  }
196
- }, ot = "", bt = (s, t) => {
197
- const e = s.length, n = new Array(e);
196
+ }, oe = "", be = (s, e) => {
197
+ const t = s.length, n = new Array(t);
198
198
  let r = 0;
199
199
  s.forEach((i, o) => {
200
200
  V(i, !1, (h) => {
201
- n[o] = h, ++r === e && t(n.join(ot));
201
+ n[o] = h, ++r === t && e(n.join(oe));
202
202
  });
203
203
  });
204
- }, wt = (s, t) => {
205
- const e = s.split(ot), n = [];
206
- for (let r = 0; r < e.length; r++) {
207
- const i = H(e[r], t);
204
+ }, we = (s, e) => {
205
+ const t = s.split(oe), n = [];
206
+ for (let r = 0; r < t.length; r++) {
207
+ const i = H(t[r], e);
208
208
  if (n.push(i), i.type === "error")
209
209
  break;
210
210
  }
211
211
  return n;
212
212
  };
213
- function vt() {
213
+ function ve() {
214
214
  return new TransformStream({
215
- transform(s, t) {
216
- ft(s, (e) => {
217
- const n = e.length;
215
+ transform(s, e) {
216
+ fe(s, (t) => {
217
+ const n = t.length;
218
218
  let r;
219
219
  if (n < 126)
220
220
  r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, n);
@@ -227,104 +227,104 @@ function vt() {
227
227
  const i = new DataView(r.buffer);
228
228
  i.setUint8(0, 127), i.setBigUint64(1, BigInt(n));
229
229
  }
230
- s.data && typeof s.data != "string" && (r[0] |= 128), t.enqueue(r), t.enqueue(e);
230
+ s.data && typeof s.data != "string" && (r[0] |= 128), e.enqueue(r), e.enqueue(t);
231
231
  });
232
232
  }
233
233
  });
234
234
  }
235
235
  let N;
236
236
  function C(s) {
237
- return s.reduce((t, e) => t + e.length, 0);
237
+ return s.reduce((e, t) => e + t.length, 0);
238
238
  }
239
- function T(s, t) {
240
- if (s[0].length === t)
239
+ function T(s, e) {
240
+ if (s[0].length === e)
241
241
  return s.shift();
242
- const e = new Uint8Array(t);
242
+ const t = new Uint8Array(e);
243
243
  let n = 0;
244
- for (let r = 0; r < t; r++)
245
- e[r] = s[0][n++], n === s[0].length && (s.shift(), n = 0);
246
- return s.length && n < s[0].length && (s[0] = s[0].slice(n)), e;
244
+ for (let r = 0; r < e; r++)
245
+ t[r] = s[0][n++], n === s[0].length && (s.shift(), n = 0);
246
+ return s.length && n < s[0].length && (s[0] = s[0].slice(n)), t;
247
247
  }
248
- function kt(s, t) {
248
+ function ke(s, e) {
249
249
  N || (N = new TextDecoder());
250
- const e = [];
250
+ const t = [];
251
251
  let n = 0, r = -1, i = !1;
252
252
  return new TransformStream({
253
253
  transform(o, h) {
254
- for (e.push(o); ; ) {
254
+ for (t.push(o); ; ) {
255
255
  if (n === 0) {
256
- if (C(e) < 1)
256
+ if (C(t) < 1)
257
257
  break;
258
- const c = T(e, 1);
258
+ const c = T(t, 1);
259
259
  i = (c[0] & 128) === 128, r = c[0] & 127, r < 126 ? n = 3 : r === 126 ? n = 1 : n = 2;
260
260
  } else if (n === 1) {
261
- if (C(e) < 2)
261
+ if (C(t) < 2)
262
262
  break;
263
- const c = T(e, 2);
263
+ const c = T(t, 2);
264
264
  r = new DataView(c.buffer, c.byteOffset, c.length).getUint16(0), n = 3;
265
265
  } else if (n === 2) {
266
- if (C(e) < 8)
266
+ if (C(t) < 8)
267
267
  break;
268
- const c = T(e, 8), p = new DataView(c.buffer, c.byteOffset, c.length), u = p.getUint32(0);
268
+ const c = T(t, 8), p = new DataView(c.buffer, c.byteOffset, c.length), u = p.getUint32(0);
269
269
  if (u > Math.pow(2, 21) - 1) {
270
- h.enqueue(q);
270
+ h.enqueue(D);
271
271
  break;
272
272
  }
273
273
  r = u * Math.pow(2, 32) + p.getUint32(4), n = 3;
274
274
  } else {
275
- if (C(e) < r)
275
+ if (C(t) < r)
276
276
  break;
277
- const c = T(e, r);
278
- h.enqueue(H(i ? c : N.decode(c), t)), n = 0;
277
+ const c = T(t, r);
278
+ h.enqueue(H(i ? c : N.decode(c), e)), n = 0;
279
279
  }
280
280
  if (r === 0 || r > s) {
281
- h.enqueue(q);
281
+ h.enqueue(D);
282
282
  break;
283
283
  }
284
284
  }
285
285
  }
286
286
  });
287
287
  }
288
- const at = 4;
288
+ const ae = 4;
289
289
  function _(s) {
290
- if (s) return Et(s);
290
+ if (s) return Ee(s);
291
291
  }
292
- function Et(s) {
293
- for (var t in _.prototype)
294
- s[t] = _.prototype[t];
292
+ function Ee(s) {
293
+ for (var e in _.prototype)
294
+ s[e] = _.prototype[e];
295
295
  return s;
296
296
  }
297
- _.prototype.on = _.prototype.addEventListener = function(s, t) {
298
- return this._callbacks = this._callbacks || {}, (this._callbacks["$" + s] = this._callbacks["$" + s] || []).push(t), this;
297
+ _.prototype.on = _.prototype.addEventListener = function(s, e) {
298
+ return this._callbacks = this._callbacks || {}, (this._callbacks["$" + s] = this._callbacks["$" + s] || []).push(e), this;
299
299
  };
300
- _.prototype.once = function(s, t) {
301
- function e() {
302
- this.off(s, e), t.apply(this, arguments);
300
+ _.prototype.once = function(s, e) {
301
+ function t() {
302
+ this.off(s, t), e.apply(this, arguments);
303
303
  }
304
- return e.fn = t, this.on(s, e), this;
304
+ return t.fn = e, this.on(s, t), this;
305
305
  };
306
- _.prototype.off = _.prototype.removeListener = _.prototype.removeAllListeners = _.prototype.removeEventListener = function(s, t) {
306
+ _.prototype.off = _.prototype.removeListener = _.prototype.removeAllListeners = _.prototype.removeEventListener = function(s, e) {
307
307
  if (this._callbacks = this._callbacks || {}, arguments.length == 0)
308
308
  return this._callbacks = {}, this;
309
- var e = this._callbacks["$" + s];
310
- if (!e) return this;
309
+ var t = this._callbacks["$" + s];
310
+ if (!t) return this;
311
311
  if (arguments.length == 1)
312
312
  return delete this._callbacks["$" + s], this;
313
- for (var n, r = 0; r < e.length; r++)
314
- if (n = e[r], n === t || n.fn === t) {
315
- e.splice(r, 1);
313
+ for (var n, r = 0; r < t.length; r++)
314
+ if (n = t[r], n === e || n.fn === e) {
315
+ t.splice(r, 1);
316
316
  break;
317
317
  }
318
- return e.length === 0 && delete this._callbacks["$" + s], this;
318
+ return t.length === 0 && delete this._callbacks["$" + s], this;
319
319
  };
320
320
  _.prototype.emit = function(s) {
321
321
  this._callbacks = this._callbacks || {};
322
- for (var t = new Array(arguments.length - 1), e = this._callbacks["$" + s], n = 1; n < arguments.length; n++)
323
- t[n - 1] = arguments[n];
324
- if (e) {
325
- e = e.slice(0);
326
- for (var n = 0, r = e.length; n < r; ++n)
327
- e[n].apply(this, t);
322
+ for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + s], n = 1; n < arguments.length; n++)
323
+ e[n - 1] = arguments[n];
324
+ if (t) {
325
+ t = t.slice(0);
326
+ for (var n = 0, r = t.length; n < r; ++n)
327
+ t[n].apply(this, e);
328
328
  }
329
329
  return this;
330
330
  };
@@ -335,44 +335,44 @@ _.prototype.listeners = function(s) {
335
335
  _.prototype.hasListeners = function(s) {
336
336
  return !!this.listeners(s).length;
337
337
  };
338
- const O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (s) => Promise.resolve().then(s) : (s, t) => t(s, 0), d = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ct = "arraybuffer";
339
- function ct(s, ...t) {
340
- return t.reduce((e, n) => (s.hasOwnProperty(n) && (e[n] = s[n]), e), {});
338
+ const O = typeof Promise == "function" && typeof Promise.resolve == "function" ? (s) => Promise.resolve().then(s) : (s, e) => e(s, 0), d = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Ce = "arraybuffer";
339
+ function ce(s, ...e) {
340
+ return e.reduce((t, n) => (s.hasOwnProperty(n) && (t[n] = s[n]), t), {});
341
341
  }
342
- const Tt = d.setTimeout, At = d.clearTimeout;
343
- function L(s, t) {
344
- t.useNativeTimers ? (s.setTimeoutFn = Tt.bind(d), s.clearTimeoutFn = At.bind(d)) : (s.setTimeoutFn = d.setTimeout.bind(d), s.clearTimeoutFn = d.clearTimeout.bind(d));
342
+ const Te = d.setTimeout, Ae = d.clearTimeout;
343
+ function L(s, e) {
344
+ e.useNativeTimers ? (s.setTimeoutFn = Te.bind(d), s.clearTimeoutFn = Ae.bind(d)) : (s.setTimeoutFn = d.setTimeout.bind(d), s.clearTimeoutFn = d.clearTimeout.bind(d));
345
345
  }
346
- const xt = 1.33;
347
- function St(s) {
348
- return typeof s == "string" ? Rt(s) : Math.ceil((s.byteLength || s.size) * xt);
346
+ const xe = 1.33;
347
+ function Se(s) {
348
+ return typeof s == "string" ? Re(s) : Math.ceil((s.byteLength || s.size) * xe);
349
349
  }
350
- function Rt(s) {
351
- let t = 0, e = 0;
350
+ function Re(s) {
351
+ let e = 0, t = 0;
352
352
  for (let n = 0, r = s.length; n < r; n++)
353
- t = s.charCodeAt(n), t < 128 ? e += 1 : t < 2048 ? e += 2 : t < 55296 || t >= 57344 ? e += 3 : (n++, e += 4);
354
- return e;
353
+ e = s.charCodeAt(n), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (n++, t += 4);
354
+ return t;
355
355
  }
356
- function lt() {
356
+ function le() {
357
357
  return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
358
358
  }
359
- function Bt(s) {
360
- let t = "";
361
- for (let e in s)
362
- s.hasOwnProperty(e) && (t.length && (t += "&"), t += encodeURIComponent(e) + "=" + encodeURIComponent(s[e]));
363
- return t;
359
+ function Be(s) {
360
+ let e = "";
361
+ for (let t in s)
362
+ s.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(s[t]));
363
+ return e;
364
364
  }
365
- function Ot(s) {
366
- let t = {}, e = s.split("&");
367
- for (let n = 0, r = e.length; n < r; n++) {
368
- let i = e[n].split("=");
369
- t[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
365
+ function Oe(s) {
366
+ let e = {}, t = s.split("&");
367
+ for (let n = 0, r = t.length; n < r; n++) {
368
+ let i = t[n].split("=");
369
+ e[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
370
370
  }
371
- return t;
371
+ return e;
372
372
  }
373
- class Lt extends Error {
374
- constructor(t, e, n) {
375
- super(t), this.description = e, this.context = n, this.type = "TransportError";
373
+ class Le extends Error {
374
+ constructor(e, t, n) {
375
+ super(e), this.description = t, this.context = n, this.type = "TransportError";
376
376
  }
377
377
  }
378
378
  class W extends _ {
@@ -382,8 +382,8 @@ class W extends _ {
382
382
  * @param {Object} opts - options
383
383
  * @protected
384
384
  */
385
- constructor(t) {
386
- super(), this.writable = !1, L(this, t), this.opts = t, this.query = t.query, this.socket = t.socket, this.supportsBinary = !t.forceBase64;
385
+ constructor(e) {
386
+ super(), this.writable = !1, L(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
387
387
  }
388
388
  /**
389
389
  * Emits an error.
@@ -394,8 +394,8 @@ class W extends _ {
394
394
  * @return {Transport} for chaining
395
395
  * @protected
396
396
  */
397
- onError(t, e, n) {
398
- return super.emitReserved("error", new Lt(t, e, n)), this;
397
+ onError(e, t, n) {
398
+ return super.emitReserved("error", new Le(e, t, n)), this;
399
399
  }
400
400
  /**
401
401
  * Opens the transport.
@@ -414,8 +414,8 @@ class W extends _ {
414
414
  *
415
415
  * @param {Array} packets
416
416
  */
417
- send(t) {
418
- this.readyState === "open" && this.write(t);
417
+ send(e) {
418
+ this.readyState === "open" && this.write(e);
419
419
  }
420
420
  /**
421
421
  * Called upon open
@@ -431,49 +431,49 @@ class W extends _ {
431
431
  * @param {String} data
432
432
  * @protected
433
433
  */
434
- onData(t) {
435
- const e = H(t, this.socket.binaryType);
436
- this.onPacket(e);
434
+ onData(e) {
435
+ const t = H(e, this.socket.binaryType);
436
+ this.onPacket(t);
437
437
  }
438
438
  /**
439
439
  * Called with a decoded packet.
440
440
  *
441
441
  * @protected
442
442
  */
443
- onPacket(t) {
444
- super.emitReserved("packet", t);
443
+ onPacket(e) {
444
+ super.emitReserved("packet", e);
445
445
  }
446
446
  /**
447
447
  * Called upon close.
448
448
  *
449
449
  * @protected
450
450
  */
451
- onClose(t) {
452
- this.readyState = "closed", super.emitReserved("close", t);
451
+ onClose(e) {
452
+ this.readyState = "closed", super.emitReserved("close", e);
453
453
  }
454
454
  /**
455
455
  * Pauses the transport, in order not to lose packets during an upgrade.
456
456
  *
457
457
  * @param onPause
458
458
  */
459
- pause(t) {
459
+ pause(e) {
460
460
  }
461
- createUri(t, e = {}) {
462
- return t + "://" + this._hostname() + this._port() + this.opts.path + this._query(e);
461
+ createUri(e, t = {}) {
462
+ return e + "://" + this._hostname() + this._port() + this.opts.path + this._query(t);
463
463
  }
464
464
  _hostname() {
465
- const t = this.opts.hostname;
466
- return t.indexOf(":") === -1 ? t : "[" + t + "]";
465
+ const e = this.opts.hostname;
466
+ return e.indexOf(":") === -1 ? e : "[" + e + "]";
467
467
  }
468
468
  _port() {
469
469
  return this.opts.port && (this.opts.secure && +(this.opts.port !== 443) || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
470
470
  }
471
- _query(t) {
472
- const e = Bt(t);
473
- return e.length ? "?" + e : "";
471
+ _query(e) {
472
+ const t = Be(e);
473
+ return t.length ? "?" + t : "";
474
474
  }
475
475
  }
476
- class Pt extends W {
476
+ class Pe extends W {
477
477
  constructor() {
478
478
  super(...arguments), this._polling = !1;
479
479
  }
@@ -495,20 +495,20 @@ class Pt extends W {
495
495
  * @param {Function} onPause - callback upon buffers are flushed and transport is paused
496
496
  * @package
497
497
  */
498
- pause(t) {
498
+ pause(e) {
499
499
  this.readyState = "pausing";
500
- const e = () => {
501
- this.readyState = "paused", t();
500
+ const t = () => {
501
+ this.readyState = "paused", e();
502
502
  };
503
503
  if (this._polling || !this.writable) {
504
504
  let n = 0;
505
505
  this._polling && (n++, this.once("pollComplete", function() {
506
- --n || e();
506
+ --n || t();
507
507
  })), this.writable || (n++, this.once("drain", function() {
508
- --n || e();
508
+ --n || t();
509
509
  }));
510
510
  } else
511
- e();
511
+ t();
512
512
  }
513
513
  /**
514
514
  * Starts polling cycle.
@@ -523,13 +523,13 @@ class Pt extends W {
523
523
  *
524
524
  * @protected
525
525
  */
526
- onData(t) {
527
- const e = (n) => {
526
+ onData(e) {
527
+ const t = (n) => {
528
528
  if (this.readyState === "opening" && n.type === "open" && this.onOpen(), n.type === "close")
529
529
  return this.onClose({ description: "transport closed by the server" }), !1;
530
530
  this.onPacket(n);
531
531
  };
532
- wt(t, this.socket.binaryType).forEach(e), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
532
+ we(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
533
533
  }
534
534
  /**
535
535
  * For polling, send a close packet.
@@ -537,10 +537,10 @@ class Pt extends W {
537
537
  * @protected
538
538
  */
539
539
  doClose() {
540
- const t = () => {
540
+ const e = () => {
541
541
  this.write([{ type: "close" }]);
542
542
  };
543
- this.readyState === "open" ? t() : this.once("open", t);
543
+ this.readyState === "open" ? e() : this.once("open", e);
544
544
  }
545
545
  /**
546
546
  * Writes a packets payload.
@@ -548,9 +548,9 @@ class Pt extends W {
548
548
  * @param {Array} packets - data packets
549
549
  * @protected
550
550
  */
551
- write(t) {
552
- this.writable = !1, bt(t, (e) => {
553
- this.doWrite(e, () => {
551
+ write(e) {
552
+ this.writable = !1, be(e, (t) => {
553
+ this.doWrite(t, () => {
554
554
  this.writable = !0, this.emitReserved("drain");
555
555
  });
556
556
  });
@@ -561,30 +561,30 @@ class Pt extends W {
561
561
  * @private
562
562
  */
563
563
  uri() {
564
- const t = this.opts.secure ? "https" : "http", e = this.query || {};
565
- return this.opts.timestampRequests !== !1 && (e[this.opts.timestampParam] = lt()), !this.supportsBinary && !e.sid && (e.b64 = 1), this.createUri(t, e);
564
+ const e = this.opts.secure ? "https" : "http", t = this.query || {};
565
+ return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = le()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
566
566
  }
567
567
  }
568
- let ht = !1;
568
+ let he = !1;
569
569
  try {
570
- ht = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
570
+ he = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
571
571
  } catch {
572
572
  }
573
- const Nt = ht;
574
- function It() {
573
+ const Ne = he;
574
+ function Ie() {
575
575
  }
576
- class Dt extends Pt {
576
+ class qe extends Pe {
577
577
  /**
578
578
  * XHR Polling constructor.
579
579
  *
580
580
  * @param {Object} opts
581
581
  * @package
582
582
  */
583
- constructor(t) {
584
- if (super(t), typeof location < "u") {
585
- const e = location.protocol === "https:";
583
+ constructor(e) {
584
+ if (super(e), typeof location < "u") {
585
+ const t = location.protocol === "https:";
586
586
  let n = location.port;
587
- n || (n = e ? "443" : "80"), this.xd = typeof location < "u" && t.hostname !== location.hostname || n !== t.port;
587
+ n || (n = t ? "443" : "80"), this.xd = typeof location < "u" && e.hostname !== location.hostname || n !== e.port;
588
588
  }
589
589
  }
590
590
  /**
@@ -594,12 +594,12 @@ class Dt extends Pt {
594
594
  * @param {Function} called upon flush.
595
595
  * @private
596
596
  */
597
- doWrite(t, e) {
597
+ doWrite(e, t) {
598
598
  const n = this.request({
599
599
  method: "POST",
600
- data: t
600
+ data: e
601
601
  });
602
- n.on("success", e), n.on("error", (r, i) => {
602
+ n.on("success", t), n.on("error", (r, i) => {
603
603
  this.onError("xhr post error", r, i);
604
604
  });
605
605
  }
@@ -609,10 +609,10 @@ class Dt extends Pt {
609
609
  * @private
610
610
  */
611
611
  doPoll() {
612
- const t = this.request();
613
- t.on("data", this.onData.bind(this)), t.on("error", (e, n) => {
614
- this.onError("xhr poll error", e, n);
615
- }), this.pollXhr = t;
612
+ const e = this.request();
613
+ e.on("data", this.onData.bind(this)), e.on("error", (t, n) => {
614
+ this.onError("xhr poll error", t, n);
615
+ }), this.pollXhr = e;
616
616
  }
617
617
  }
618
618
  class g extends _ {
@@ -622,8 +622,8 @@ class g extends _ {
622
622
  * @param {Object} options
623
623
  * @package
624
624
  */
625
- constructor(t, e, n) {
626
- super(), this.createRequest = t, L(this, n), this._opts = n, this._method = n.method || "GET", this._uri = e, this._data = n.data !== void 0 ? n.data : null, this._create();
625
+ constructor(e, t, n) {
626
+ super(), this.createRequest = e, L(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data !== void 0 ? n.data : null, this._create();
627
627
  }
628
628
  /**
629
629
  * Creates the XHR object and sends the request.
@@ -631,10 +631,10 @@ class g extends _ {
631
631
  * @private
632
632
  */
633
633
  _create() {
634
- var t;
635
- const e = ct(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
636
- e.xdomain = !!this._opts.xd;
637
- const n = this._xhr = this.createRequest(e);
634
+ var e;
635
+ const t = ce(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
636
+ t.xdomain = !!this._opts.xd;
637
+ const n = this._xhr = this.createRequest(t);
638
638
  try {
639
639
  n.open(this._method, this._uri, !0);
640
640
  try {
@@ -654,7 +654,7 @@ class g extends _ {
654
654
  n.setRequestHeader("Accept", "*/*");
655
655
  } catch {
656
656
  }
657
- (t = this._opts.cookieJar) === null || t === void 0 || t.addCookies(n), "withCredentials" in n && (n.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (n.timeout = this._opts.requestTimeout), n.onreadystatechange = () => {
657
+ (e = this._opts.cookieJar) === null || e === void 0 || e.addCookies(n), "withCredentials" in n && (n.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (n.timeout = this._opts.requestTimeout), n.onreadystatechange = () => {
658
658
  var r;
659
659
  n.readyState === 3 && ((r = this._opts.cookieJar) === null || r === void 0 || r.parseCookies(
660
660
  // @ts-ignore
@@ -676,17 +676,17 @@ class g extends _ {
676
676
  *
677
677
  * @private
678
678
  */
679
- _onError(t) {
680
- this.emitReserved("error", t, this._xhr), this._cleanup(!0);
679
+ _onError(e) {
680
+ this.emitReserved("error", e, this._xhr), this._cleanup(!0);
681
681
  }
682
682
  /**
683
683
  * Cleans up house.
684
684
  *
685
685
  * @private
686
686
  */
687
- _cleanup(t) {
687
+ _cleanup(e) {
688
688
  if (!(typeof this._xhr > "u" || this._xhr === null)) {
689
- if (this._xhr.onreadystatechange = It, t)
689
+ if (this._xhr.onreadystatechange = Ie, e)
690
690
  try {
691
691
  this._xhr.abort();
692
692
  } catch {
@@ -700,8 +700,8 @@ class g extends _ {
700
700
  * @private
701
701
  */
702
702
  _onLoad() {
703
- const t = this._xhr.responseText;
704
- t !== null && (this.emitReserved("data", t), this.emitReserved("success"), this._cleanup());
703
+ const e = this._xhr.responseText;
704
+ e !== null && (this.emitReserved("data", e), this.emitReserved("success"), this._cleanup());
705
705
  }
706
706
  /**
707
707
  * Aborts the request.
@@ -726,45 +726,45 @@ function Z() {
726
726
  for (let s in g.requests)
727
727
  g.requests.hasOwnProperty(s) && g.requests[s].abort();
728
728
  }
729
- const qt = function() {
730
- const s = ut({
729
+ const De = function() {
730
+ const s = ue({
731
731
  xdomain: !1
732
732
  });
733
733
  return s && s.responseType !== null;
734
734
  }();
735
- class Ut extends Dt {
736
- constructor(t) {
737
- super(t);
738
- const e = t && t.forceBase64;
739
- this.supportsBinary = qt && !e;
735
+ class Ue extends qe {
736
+ constructor(e) {
737
+ super(e);
738
+ const t = e && e.forceBase64;
739
+ this.supportsBinary = De && !t;
740
740
  }
741
- request(t = {}) {
742
- return Object.assign(t, { xd: this.xd }, this.opts), new g(ut, this.uri(), t);
741
+ request(e = {}) {
742
+ return Object.assign(e, { xd: this.xd }, this.opts), new g(ue, this.uri(), e);
743
743
  }
744
744
  }
745
- function ut(s) {
746
- const t = s.xdomain;
745
+ function ue(s) {
746
+ const e = s.xdomain;
747
747
  try {
748
- if (typeof XMLHttpRequest < "u" && (!t || Nt))
748
+ if (typeof XMLHttpRequest < "u" && (!e || Ne))
749
749
  return new XMLHttpRequest();
750
750
  } catch {
751
751
  }
752
- if (!t)
752
+ if (!e)
753
753
  try {
754
754
  return new d[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
755
755
  } catch {
756
756
  }
757
757
  }
758
- const _t = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
759
- class jt extends W {
758
+ const _e = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
759
+ class je extends W {
760
760
  get name() {
761
761
  return "websocket";
762
762
  }
763
763
  doOpen() {
764
- const t = this.uri(), e = this.opts.protocols, n = _t ? {} : ct(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
764
+ const e = this.uri(), t = this.opts.protocols, n = _e ? {} : ce(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
765
765
  this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
766
766
  try {
767
- this.ws = this.createSocket(t, e, n);
767
+ this.ws = this.createSocket(e, t, n);
768
768
  } catch (r) {
769
769
  return this.emitReserved("error", r);
770
770
  }
@@ -778,15 +778,15 @@ class jt extends W {
778
778
  addEventListeners() {
779
779
  this.ws.onopen = () => {
780
780
  this.opts.autoUnref && this.ws._socket.unref(), this.onOpen();
781
- }, this.ws.onclose = (t) => this.onClose({
781
+ }, this.ws.onclose = (e) => this.onClose({
782
782
  description: "websocket connection closed",
783
- context: t
784
- }), this.ws.onmessage = (t) => this.onData(t.data), this.ws.onerror = (t) => this.onError("websocket error", t);
783
+ context: e
784
+ }), this.ws.onmessage = (e) => this.onData(e.data), this.ws.onerror = (e) => this.onError("websocket error", e);
785
785
  }
786
- write(t) {
786
+ write(e) {
787
787
  this.writable = !1;
788
- for (let e = 0; e < t.length; e++) {
789
- const n = t[e], r = e === t.length - 1;
788
+ for (let t = 0; t < e.length; t++) {
789
+ const n = e[t], r = t === e.length - 1;
790
790
  V(n, this.supportsBinary, (i) => {
791
791
  try {
792
792
  this.doWrite(n, i);
@@ -808,37 +808,37 @@ class jt extends W {
808
808
  * @private
809
809
  */
810
810
  uri() {
811
- const t = this.opts.secure ? "wss" : "ws", e = this.query || {};
812
- return this.opts.timestampRequests && (e[this.opts.timestampParam] = lt()), this.supportsBinary || (e.b64 = 1), this.createUri(t, e);
811
+ const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
812
+ return this.opts.timestampRequests && (t[this.opts.timestampParam] = le()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
813
813
  }
814
814
  }
815
815
  const I = d.WebSocket || d.MozWebSocket;
816
- class Mt extends jt {
817
- createSocket(t, e, n) {
818
- return _t ? new I(t, e, n) : e ? new I(t, e) : new I(t);
816
+ class Me extends je {
817
+ createSocket(e, t, n) {
818
+ return _e ? new I(e, t, n) : t ? new I(e, t) : new I(e);
819
819
  }
820
- doWrite(t, e) {
821
- this.ws.send(e);
820
+ doWrite(e, t) {
821
+ this.ws.send(t);
822
822
  }
823
823
  }
824
- class Ft extends W {
824
+ class Fe extends W {
825
825
  get name() {
826
826
  return "webtransport";
827
827
  }
828
828
  doOpen() {
829
829
  try {
830
830
  this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
831
- } catch (t) {
832
- return this.emitReserved("error", t);
831
+ } catch (e) {
832
+ return this.emitReserved("error", e);
833
833
  }
834
834
  this._transport.closed.then(() => {
835
835
  this.onClose();
836
- }).catch((t) => {
837
- this.onError("webtransport error", t);
836
+ }).catch((e) => {
837
+ this.onError("webtransport error", e);
838
838
  }), this._transport.ready.then(() => {
839
- this._transport.createBidirectionalStream().then((t) => {
840
- const e = kt(Number.MAX_SAFE_INTEGER, this.socket.binaryType), n = t.readable.pipeThrough(e).getReader(), r = vt();
841
- r.readable.pipeTo(t.writable), this._writer = r.writable.getWriter();
839
+ this._transport.createBidirectionalStream().then((e) => {
840
+ const t = ke(Number.MAX_SAFE_INTEGER, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = ve();
841
+ r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
842
842
  const i = () => {
843
843
  n.read().then(({ done: h, value: c }) => {
844
844
  h || (this.onPacket(c), i());
@@ -851,10 +851,10 @@ class Ft extends W {
851
851
  });
852
852
  });
853
853
  }
854
- write(t) {
854
+ write(e) {
855
855
  this.writable = !1;
856
- for (let e = 0; e < t.length; e++) {
857
- const n = t[e], r = e === t.length - 1;
856
+ for (let t = 0; t < e.length; t++) {
857
+ const n = e[t], r = t === e.length - 1;
858
858
  this._writer.write(n).then(() => {
859
859
  r && O(() => {
860
860
  this.writable = !0, this.emitReserved("drain");
@@ -863,15 +863,15 @@ class Ft extends W {
863
863
  }
864
864
  }
865
865
  doClose() {
866
- var t;
867
- (t = this._transport) === null || t === void 0 || t.close();
866
+ var e;
867
+ (e = this._transport) === null || e === void 0 || e.close();
868
868
  }
869
869
  }
870
- const $t = {
871
- websocket: Mt,
872
- webtransport: Ft,
873
- polling: Ut
874
- }, Vt = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, Ht = [
870
+ const $e = {
871
+ websocket: Me,
872
+ webtransport: Fe,
873
+ polling: Ue
874
+ }, Ve = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, He = [
875
875
  "source",
876
876
  "protocol",
877
877
  "authority",
@@ -890,22 +890,22 @@ const $t = {
890
890
  function U(s) {
891
891
  if (s.length > 8e3)
892
892
  throw "URI too long";
893
- const t = s, e = s.indexOf("["), n = s.indexOf("]");
894
- e != -1 && n != -1 && (s = s.substring(0, e) + s.substring(e, n).replace(/:/g, ";") + s.substring(n, s.length));
895
- let r = Vt.exec(s || ""), i = {}, o = 14;
893
+ const e = s, t = s.indexOf("["), n = s.indexOf("]");
894
+ t != -1 && n != -1 && (s = s.substring(0, t) + s.substring(t, n).replace(/:/g, ";") + s.substring(n, s.length));
895
+ let r = Ve.exec(s || ""), i = {}, o = 14;
896
896
  for (; o--; )
897
- i[Ht[o]] = r[o] || "";
898
- return e != -1 && n != -1 && (i.source = t, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = Wt(i, i.path), i.queryKey = zt(i, i.query), i;
897
+ i[He[o]] = r[o] || "";
898
+ return t != -1 && n != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = We(i, i.path), i.queryKey = ze(i, i.query), i;
899
899
  }
900
- function Wt(s, t) {
901
- const e = /\/{2,9}/g, n = t.replace(e, "/").split("/");
902
- return (t.slice(0, 1) == "/" || t.length === 0) && n.splice(0, 1), t.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
900
+ function We(s, e) {
901
+ const t = /\/{2,9}/g, n = e.replace(t, "/").split("/");
902
+ return (e.slice(0, 1) == "/" || e.length === 0) && n.splice(0, 1), e.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
903
903
  }
904
- function zt(s, t) {
905
- const e = {};
906
- return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(n, r, i) {
907
- r && (e[r] = i);
908
- }), e;
904
+ function ze(s, e) {
905
+ const t = {};
906
+ return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(n, r, i) {
907
+ r && (t[r] = i);
908
+ }), t;
909
909
  }
910
910
  const j = typeof addEventListener == "function" && typeof removeEventListener == "function", S = [];
911
911
  j && addEventListener("offline", () => {
@@ -918,12 +918,12 @@ class b extends _ {
918
918
  * @param {String|Object} uri - uri or options
919
919
  * @param {Object} opts - options
920
920
  */
921
- constructor(t, e) {
922
- if (super(), this.binaryType = Ct, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, t && typeof t == "object" && (e = t, t = null), t) {
923
- const n = U(t);
924
- e.hostname = n.host, e.secure = n.protocol === "https" || n.protocol === "wss", e.port = n.port, n.query && (e.query = n.query);
925
- } else e.host && (e.hostname = U(e.host).host);
926
- L(this, e), this.secure = e.secure != null ? e.secure : typeof location < "u" && location.protocol === "https:", e.hostname && !e.port && (e.port = this.secure ? "443" : "80"), this.hostname = e.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = e.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, e.transports.forEach((n) => {
921
+ constructor(e, t) {
922
+ if (super(), this.binaryType = Ce, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
923
+ const n = U(e);
924
+ t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
925
+ } else t.host && (t.hostname = U(t.host).host);
926
+ L(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((n) => {
927
927
  const r = n.prototype.name;
928
928
  this.transports.push(r), this._transportsByName[r] = n;
929
929
  }), this.opts = Object.assign({
@@ -940,7 +940,7 @@ class b extends _ {
940
940
  },
941
941
  transportOptions: {},
942
942
  closeOnBeforeunload: !1
943
- }, e), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Ot(this.opts.query)), j && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
943
+ }, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Oe(this.opts.query)), j && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
944
944
  this.transport && (this.transport.removeAllListeners(), this.transport.close());
945
945
  }, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
946
946
  this._onClose("transport close", {
@@ -955,17 +955,17 @@ class b extends _ {
955
955
  * @return {Transport}
956
956
  * @private
957
957
  */
958
- createTransport(t) {
959
- const e = Object.assign({}, this.opts.query);
960
- e.EIO = at, e.transport = t, this.id && (e.sid = this.id);
958
+ createTransport(e) {
959
+ const t = Object.assign({}, this.opts.query);
960
+ t.EIO = ae, t.transport = e, this.id && (t.sid = this.id);
961
961
  const n = Object.assign({}, this.opts, {
962
- query: e,
962
+ query: t,
963
963
  socket: this,
964
964
  hostname: this.hostname,
965
965
  secure: this.secure,
966
966
  port: this.port
967
- }, this.opts.transportOptions[t]);
968
- return new this._transportsByName[t](n);
967
+ }, this.opts.transportOptions[e]);
968
+ return new this._transportsByName[e](n);
969
969
  }
970
970
  /**
971
971
  * Initializes transport to use and starts probe.
@@ -979,18 +979,18 @@ class b extends _ {
979
979
  }, 0);
980
980
  return;
981
981
  }
982
- const t = this.opts.rememberUpgrade && b.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
982
+ const e = this.opts.rememberUpgrade && b.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
983
983
  this.readyState = "opening";
984
- const e = this.createTransport(t);
985
- e.open(), this.setTransport(e);
984
+ const t = this.createTransport(e);
985
+ t.open(), this.setTransport(t);
986
986
  }
987
987
  /**
988
988
  * Sets the current transport. Disables the existing one (if any).
989
989
  *
990
990
  * @private
991
991
  */
992
- setTransport(t) {
993
- this.transport && this.transport.removeAllListeners(), this.transport = t, t.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (e) => this._onClose("transport close", e));
992
+ setTransport(e) {
993
+ this.transport && this.transport.removeAllListeners(), this.transport = e, e.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (t) => this._onClose("transport close", t));
994
994
  }
995
995
  /**
996
996
  * Called when connection is deemed open.
@@ -1005,21 +1005,21 @@ class b extends _ {
1005
1005
  *
1006
1006
  * @private
1007
1007
  */
1008
- _onPacket(t) {
1008
+ _onPacket(e) {
1009
1009
  if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing")
1010
- switch (this.emitReserved("packet", t), this.emitReserved("heartbeat"), t.type) {
1010
+ switch (this.emitReserved("packet", e), this.emitReserved("heartbeat"), e.type) {
1011
1011
  case "open":
1012
- this.onHandshake(JSON.parse(t.data));
1012
+ this.onHandshake(JSON.parse(e.data));
1013
1013
  break;
1014
1014
  case "ping":
1015
1015
  this._sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"), this._resetPingTimeout();
1016
1016
  break;
1017
1017
  case "error":
1018
- const e = new Error("server error");
1019
- e.code = t.data, this._onError(e);
1018
+ const t = new Error("server error");
1019
+ t.code = e.data, this._onError(t);
1020
1020
  break;
1021
1021
  case "message":
1022
- this.emitReserved("data", t.data), this.emitReserved("message", t.data);
1022
+ this.emitReserved("data", e.data), this.emitReserved("message", e.data);
1023
1023
  break;
1024
1024
  }
1025
1025
  }
@@ -1029,8 +1029,8 @@ class b extends _ {
1029
1029
  * @param {Object} data - handshake obj
1030
1030
  * @private
1031
1031
  */
1032
- onHandshake(t) {
1033
- this.emitReserved("handshake", t), this.id = t.sid, this.transport.query.sid = t.sid, this._pingInterval = t.pingInterval, this._pingTimeout = t.pingTimeout, this._maxPayload = t.maxPayload, this.onOpen(), this.readyState !== "closed" && this._resetPingTimeout();
1032
+ onHandshake(e) {
1033
+ this.emitReserved("handshake", e), this.id = e.sid, this.transport.query.sid = e.sid, this._pingInterval = e.pingInterval, this._pingTimeout = e.pingTimeout, this._maxPayload = e.maxPayload, this.onOpen(), this.readyState !== "closed" && this._resetPingTimeout();
1034
1034
  }
1035
1035
  /**
1036
1036
  * Sets and resets ping timeout timer based on server pings.
@@ -1039,10 +1039,10 @@ class b extends _ {
1039
1039
  */
1040
1040
  _resetPingTimeout() {
1041
1041
  this.clearTimeoutFn(this._pingTimeoutTimer);
1042
- const t = this._pingInterval + this._pingTimeout;
1043
- this._pingTimeoutTime = Date.now() + t, this._pingTimeoutTimer = this.setTimeoutFn(() => {
1042
+ const e = this._pingInterval + this._pingTimeout;
1043
+ this._pingTimeoutTime = Date.now() + e, this._pingTimeoutTimer = this.setTimeoutFn(() => {
1044
1044
  this._onClose("ping timeout");
1045
- }, t), this.opts.autoUnref && this._pingTimeoutTimer.unref();
1045
+ }, e), this.opts.autoUnref && this._pingTimeoutTimer.unref();
1046
1046
  }
1047
1047
  /**
1048
1048
  * Called on `drain` event
@@ -1059,8 +1059,8 @@ class b extends _ {
1059
1059
  */
1060
1060
  flush() {
1061
1061
  if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
1062
- const t = this._getWritablePackets();
1063
- this.transport.send(t), this._prevBufferLen = t.length, this.emitReserved("flush");
1062
+ const e = this._getWritablePackets();
1063
+ this.transport.send(e), this._prevBufferLen = e.length, this.emitReserved("flush");
1064
1064
  }
1065
1065
  }
1066
1066
  /**
@@ -1072,12 +1072,12 @@ class b extends _ {
1072
1072
  _getWritablePackets() {
1073
1073
  if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1))
1074
1074
  return this.writeBuffer;
1075
- let t = 1;
1076
- for (let e = 0; e < this.writeBuffer.length; e++) {
1077
- const n = this.writeBuffer[e].data;
1078
- if (n && (t += St(n)), e > 0 && t > this._maxPayload)
1079
- return this.writeBuffer.slice(0, e);
1080
- t += 2;
1075
+ let e = 1;
1076
+ for (let t = 0; t < this.writeBuffer.length; t++) {
1077
+ const n = this.writeBuffer[t].data;
1078
+ if (n && (e += Se(n)), t > 0 && e > this._maxPayload)
1079
+ return this.writeBuffer.slice(0, t);
1080
+ e += 2;
1081
1081
  }
1082
1082
  return this.writeBuffer;
1083
1083
  }
@@ -1094,10 +1094,10 @@ class b extends _ {
1094
1094
  _hasPingExpired() {
1095
1095
  if (!this._pingTimeoutTime)
1096
1096
  return !0;
1097
- const t = Date.now() > this._pingTimeoutTime;
1098
- return t && (this._pingTimeoutTime = 0, O(() => {
1097
+ const e = Date.now() > this._pingTimeoutTime;
1098
+ return e && (this._pingTimeoutTime = 0, O(() => {
1099
1099
  this._onClose("ping timeout");
1100
- }, this.setTimeoutFn)), t;
1100
+ }, this.setTimeoutFn)), e;
1101
1101
  }
1102
1102
  /**
1103
1103
  * Sends a message.
@@ -1107,8 +1107,8 @@ class b extends _ {
1107
1107
  * @param {Function} fn - callback function.
1108
1108
  * @return {Socket} for chaining.
1109
1109
  */
1110
- write(t, e, n) {
1111
- return this._sendPacket("message", t, e, n), this;
1110
+ write(e, t, n) {
1111
+ return this._sendPacket("message", e, t, n), this;
1112
1112
  }
1113
1113
  /**
1114
1114
  * Sends a message. Alias of {@link Socket#write}.
@@ -1118,8 +1118,8 @@ class b extends _ {
1118
1118
  * @param {Function} fn - callback function.
1119
1119
  * @return {Socket} for chaining.
1120
1120
  */
1121
- send(t, e, n) {
1122
- return this._sendPacket("message", t, e, n), this;
1121
+ send(e, t, n) {
1122
+ return this._sendPacket("message", e, t, n), this;
1123
1123
  }
1124
1124
  /**
1125
1125
  * Sends a packet.
@@ -1130,13 +1130,13 @@ class b extends _ {
1130
1130
  * @param {Function} fn - callback function.
1131
1131
  * @private
1132
1132
  */
1133
- _sendPacket(t, e, n, r) {
1134
- if (typeof e == "function" && (r = e, e = void 0), typeof n == "function" && (r = n, n = null), this.readyState === "closing" || this.readyState === "closed")
1133
+ _sendPacket(e, t, n, r) {
1134
+ if (typeof t == "function" && (r = t, t = void 0), typeof n == "function" && (r = n, n = null), this.readyState === "closing" || this.readyState === "closed")
1135
1135
  return;
1136
1136
  n = n || {}, n.compress = n.compress !== !1;
1137
1137
  const i = {
1138
- type: t,
1139
- data: e,
1138
+ type: e,
1139
+ data: t,
1140
1140
  options: n
1141
1141
  };
1142
1142
  this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
@@ -1145,51 +1145,51 @@ class b extends _ {
1145
1145
  * Closes the connection.
1146
1146
  */
1147
1147
  close() {
1148
- const t = () => {
1148
+ const e = () => {
1149
1149
  this._onClose("forced close"), this.transport.close();
1150
- }, e = () => {
1151
- this.off("upgrade", e), this.off("upgradeError", e), t();
1150
+ }, t = () => {
1151
+ this.off("upgrade", t), this.off("upgradeError", t), e();
1152
1152
  }, n = () => {
1153
- this.once("upgrade", e), this.once("upgradeError", e);
1153
+ this.once("upgrade", t), this.once("upgradeError", t);
1154
1154
  };
1155
1155
  return (this.readyState === "opening" || this.readyState === "open") && (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", () => {
1156
- this.upgrading ? n() : t();
1157
- }) : this.upgrading ? n() : t()), this;
1156
+ this.upgrading ? n() : e();
1157
+ }) : this.upgrading ? n() : e()), this;
1158
1158
  }
1159
1159
  /**
1160
1160
  * Called upon transport error
1161
1161
  *
1162
1162
  * @private
1163
1163
  */
1164
- _onError(t) {
1164
+ _onError(e) {
1165
1165
  if (b.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
1166
1166
  return this.transports.shift(), this._open();
1167
- this.emitReserved("error", t), this._onClose("transport error", t);
1167
+ this.emitReserved("error", e), this._onClose("transport error", e);
1168
1168
  }
1169
1169
  /**
1170
1170
  * Called upon transport close.
1171
1171
  *
1172
1172
  * @private
1173
1173
  */
1174
- _onClose(t, e) {
1174
+ _onClose(e, t) {
1175
1175
  if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
1176
1176
  if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), j && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
1177
1177
  const n = S.indexOf(this._offlineEventListener);
1178
1178
  n !== -1 && S.splice(n, 1);
1179
1179
  }
1180
- this.readyState = "closed", this.id = null, this.emitReserved("close", t, e), this.writeBuffer = [], this._prevBufferLen = 0;
1180
+ this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
1181
1181
  }
1182
1182
  }
1183
1183
  }
1184
- b.protocol = at;
1185
- class Kt extends b {
1184
+ b.protocol = ae;
1185
+ class Ke extends b {
1186
1186
  constructor() {
1187
1187
  super(...arguments), this._upgrades = [];
1188
1188
  }
1189
1189
  onOpen() {
1190
1190
  if (super.onOpen(), this.readyState === "open" && this.opts.upgrade)
1191
- for (let t = 0; t < this._upgrades.length; t++)
1192
- this._probe(this._upgrades[t]);
1191
+ for (let e = 0; e < this._upgrades.length; e++)
1192
+ this._probe(this._upgrades[e]);
1193
1193
  }
1194
1194
  /**
1195
1195
  * Probes a transport.
@@ -1197,30 +1197,30 @@ class Kt extends b {
1197
1197
  * @param {String} name - transport name
1198
1198
  * @private
1199
1199
  */
1200
- _probe(t) {
1201
- let e = this.createTransport(t), n = !1;
1200
+ _probe(e) {
1201
+ let t = this.createTransport(e), n = !1;
1202
1202
  b.priorWebsocketSuccess = !1;
1203
1203
  const r = () => {
1204
- n || (e.send([{ type: "ping", data: "probe" }]), e.once("packet", (y) => {
1204
+ n || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (y) => {
1205
1205
  if (!n)
1206
1206
  if (y.type === "pong" && y.data === "probe") {
1207
- if (this.upgrading = !0, this.emitReserved("upgrading", e), !e)
1207
+ if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
1208
1208
  return;
1209
- b.priorWebsocketSuccess = e.name === "websocket", this.transport.pause(() => {
1210
- n || this.readyState !== "closed" && (u(), this.setTransport(e), e.send([{ type: "upgrade" }]), this.emitReserved("upgrade", e), e = null, this.upgrading = !1, this.flush());
1209
+ b.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
1210
+ n || this.readyState !== "closed" && (u(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
1211
1211
  });
1212
1212
  } else {
1213
1213
  const v = new Error("probe error");
1214
- v.transport = e.name, this.emitReserved("upgradeError", v);
1214
+ v.transport = t.name, this.emitReserved("upgradeError", v);
1215
1215
  }
1216
1216
  }));
1217
1217
  };
1218
1218
  function i() {
1219
- n || (n = !0, u(), e.close(), e = null);
1219
+ n || (n = !0, u(), t.close(), t = null);
1220
1220
  }
1221
1221
  const o = (y) => {
1222
1222
  const v = new Error("probe error: " + y);
1223
- v.transport = e.name, i(), this.emitReserved("upgradeError", v);
1223
+ v.transport = t.name, i(), this.emitReserved("upgradeError", v);
1224
1224
  };
1225
1225
  function h() {
1226
1226
  o("transport closed");
@@ -1229,17 +1229,17 @@ class Kt extends b {
1229
1229
  o("socket closed");
1230
1230
  }
1231
1231
  function p(y) {
1232
- e && y.name !== e.name && i();
1232
+ t && y.name !== t.name && i();
1233
1233
  }
1234
1234
  const u = () => {
1235
- e.removeListener("open", r), e.removeListener("error", o), e.removeListener("close", h), this.off("close", c), this.off("upgrading", p);
1235
+ t.removeListener("open", r), t.removeListener("error", o), t.removeListener("close", h), this.off("close", c), this.off("upgrading", p);
1236
1236
  };
1237
- e.once("open", r), e.once("error", o), e.once("close", h), this.once("close", c), this.once("upgrading", p), this._upgrades.indexOf("webtransport") !== -1 && t !== "webtransport" ? this.setTimeoutFn(() => {
1238
- n || e.open();
1239
- }, 200) : e.open();
1237
+ t.once("open", r), t.once("error", o), t.once("close", h), this.once("close", c), this.once("upgrading", p), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
1238
+ n || t.open();
1239
+ }, 200) : t.open();
1240
1240
  }
1241
- onHandshake(t) {
1242
- this._upgrades = this._filterUpgrades(t.upgrades), super.onHandshake(t);
1241
+ onHandshake(e) {
1242
+ this._upgrades = this._filterUpgrades(e.upgrades), super.onHandshake(e);
1243
1243
  }
1244
1244
  /**
1245
1245
  * Filters upgrades, returning only those matching client transports.
@@ -1247,35 +1247,35 @@ class Kt extends b {
1247
1247
  * @param {Array} upgrades - server upgrades
1248
1248
  * @private
1249
1249
  */
1250
- _filterUpgrades(t) {
1251
- const e = [];
1252
- for (let n = 0; n < t.length; n++)
1253
- ~this.transports.indexOf(t[n]) && e.push(t[n]);
1254
- return e;
1250
+ _filterUpgrades(e) {
1251
+ const t = [];
1252
+ for (let n = 0; n < e.length; n++)
1253
+ ~this.transports.indexOf(e[n]) && t.push(e[n]);
1254
+ return t;
1255
1255
  }
1256
1256
  }
1257
- let Yt = class extends Kt {
1258
- constructor(s, t = {}) {
1259
- const e = typeof s == "object" ? s : t;
1260
- (!e.transports || e.transports && typeof e.transports[0] == "string") && (e.transports = (e.transports || ["polling", "websocket", "webtransport"]).map((n) => $t[n]).filter((n) => !!n)), super(s, e);
1257
+ let Ye = class extends Ke {
1258
+ constructor(s, e = {}) {
1259
+ const t = typeof s == "object" ? s : e;
1260
+ (!t.transports || t.transports && typeof t.transports[0] == "string") && (t.transports = (t.transports || ["polling", "websocket", "webtransport"]).map((n) => $e[n]).filter((n) => !!n)), super(s, t);
1261
1261
  }
1262
1262
  };
1263
- function Jt(s, t = "", e) {
1263
+ function Je(s, e = "", t) {
1264
1264
  let n = s;
1265
- e = e || typeof location < "u" && location, s == null && (s = e.protocol + "//" + e.host), typeof s == "string" && (s.charAt(0) === "/" && (s.charAt(1) === "/" ? s = e.protocol + s : s = e.host + s), /^(https?|wss?):\/\//.test(s) || (typeof e < "u" ? s = e.protocol + "//" + s : s = "https://" + s), n = U(s)), n.port || (/^(http|ws)$/.test(n.protocol) ? n.port = "80" : /^(http|ws)s$/.test(n.protocol) && (n.port = "443")), n.path = n.path || "/";
1265
+ t = t || typeof location < "u" && location, s == null && (s = t.protocol + "//" + t.host), typeof s == "string" && (s.charAt(0) === "/" && (s.charAt(1) === "/" ? s = t.protocol + s : s = t.host + s), /^(https?|wss?):\/\//.test(s) || (typeof t < "u" ? s = t.protocol + "//" + s : s = "https://" + s), n = U(s)), n.port || (/^(http|ws)$/.test(n.protocol) ? n.port = "80" : /^(http|ws)s$/.test(n.protocol) && (n.port = "443")), n.path = n.path || "/";
1266
1266
  const r = n.host.indexOf(":") !== -1 ? "[" + n.host + "]" : n.host;
1267
- return n.id = n.protocol + "://" + r + ":" + n.port + t, n.href = n.protocol + "://" + r + (e && e.port === n.port ? "" : ":" + n.port), n;
1267
+ return n.id = n.protocol + "://" + r + ":" + n.port + e, n.href = n.protocol + "://" + r + (t && t.port === n.port ? "" : ":" + n.port), n;
1268
1268
  }
1269
- const Qt = typeof ArrayBuffer == "function", Xt = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s.buffer instanceof ArrayBuffer, pt = Object.prototype.toString, Gt = typeof Blob == "function" || typeof Blob < "u" && pt.call(Blob) === "[object BlobConstructor]", Zt = typeof File == "function" || typeof File < "u" && pt.call(File) === "[object FileConstructor]";
1269
+ const Qe = typeof ArrayBuffer == "function", Xe = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s.buffer instanceof ArrayBuffer, pe = Object.prototype.toString, Ge = typeof Blob == "function" || typeof Blob < "u" && pe.call(Blob) === "[object BlobConstructor]", Ze = typeof File == "function" || typeof File < "u" && pe.call(File) === "[object FileConstructor]";
1270
1270
  function z(s) {
1271
- return Qt && (s instanceof ArrayBuffer || Xt(s)) || Gt && s instanceof Blob || Zt && s instanceof File;
1271
+ return Qe && (s instanceof ArrayBuffer || Xe(s)) || Ge && s instanceof Blob || Ze && s instanceof File;
1272
1272
  }
1273
- function R(s, t) {
1273
+ function R(s, e) {
1274
1274
  if (!s || typeof s != "object")
1275
1275
  return !1;
1276
1276
  if (Array.isArray(s)) {
1277
- for (let e = 0, n = s.length; e < n; e++)
1278
- if (R(s[e]))
1277
+ for (let t = 0, n = s.length; t < n; t++)
1278
+ if (R(s[t]))
1279
1279
  return !0;
1280
1280
  return !1;
1281
1281
  }
@@ -1283,53 +1283,53 @@ function R(s, t) {
1283
1283
  return !0;
1284
1284
  if (s.toJSON && typeof s.toJSON == "function" && arguments.length === 1)
1285
1285
  return R(s.toJSON(), !0);
1286
- for (const e in s)
1287
- if (Object.prototype.hasOwnProperty.call(s, e) && R(s[e]))
1286
+ for (const t in s)
1287
+ if (Object.prototype.hasOwnProperty.call(s, t) && R(s[t]))
1288
1288
  return !0;
1289
1289
  return !1;
1290
1290
  }
1291
- function te(s) {
1292
- const t = [], e = s.data, n = s;
1293
- return n.data = M(e, t), n.attachments = t.length, { packet: n, buffers: t };
1291
+ function et(s) {
1292
+ const e = [], t = s.data, n = s;
1293
+ return n.data = M(t, e), n.attachments = e.length, { packet: n, buffers: e };
1294
1294
  }
1295
- function M(s, t) {
1295
+ function M(s, e) {
1296
1296
  if (!s)
1297
1297
  return s;
1298
1298
  if (z(s)) {
1299
- const e = { _placeholder: !0, num: t.length };
1300
- return t.push(s), e;
1299
+ const t = { _placeholder: !0, num: e.length };
1300
+ return e.push(s), t;
1301
1301
  } else if (Array.isArray(s)) {
1302
- const e = new Array(s.length);
1302
+ const t = new Array(s.length);
1303
1303
  for (let n = 0; n < s.length; n++)
1304
- e[n] = M(s[n], t);
1305
- return e;
1304
+ t[n] = M(s[n], e);
1305
+ return t;
1306
1306
  } else if (typeof s == "object" && !(s instanceof Date)) {
1307
- const e = {};
1307
+ const t = {};
1308
1308
  for (const n in s)
1309
- Object.prototype.hasOwnProperty.call(s, n) && (e[n] = M(s[n], t));
1310
- return e;
1309
+ Object.prototype.hasOwnProperty.call(s, n) && (t[n] = M(s[n], e));
1310
+ return t;
1311
1311
  }
1312
1312
  return s;
1313
1313
  }
1314
- function ee(s, t) {
1315
- return s.data = F(s.data, t), delete s.attachments, s;
1314
+ function tt(s, e) {
1315
+ return s.data = F(s.data, e), delete s.attachments, s;
1316
1316
  }
1317
- function F(s, t) {
1317
+ function F(s, e) {
1318
1318
  if (!s)
1319
1319
  return s;
1320
1320
  if (s && s._placeholder === !0) {
1321
- if (typeof s.num == "number" && s.num >= 0 && s.num < t.length)
1322
- return t[s.num];
1321
+ if (typeof s.num == "number" && s.num >= 0 && s.num < e.length)
1322
+ return e[s.num];
1323
1323
  throw new Error("illegal attachments");
1324
1324
  } else if (Array.isArray(s))
1325
- for (let e = 0; e < s.length; e++)
1326
- s[e] = F(s[e], t);
1325
+ for (let t = 0; t < s.length; t++)
1326
+ s[t] = F(s[t], e);
1327
1327
  else if (typeof s == "object")
1328
- for (const e in s)
1329
- Object.prototype.hasOwnProperty.call(s, e) && (s[e] = F(s[e], t));
1328
+ for (const t in s)
1329
+ Object.prototype.hasOwnProperty.call(s, t) && (s[t] = F(s[t], e));
1330
1330
  return s;
1331
1331
  }
1332
- const se = [
1332
+ const st = [
1333
1333
  "connect",
1334
1334
  "connect_error",
1335
1335
  "disconnect",
@@ -1337,19 +1337,19 @@ const se = [
1337
1337
  "newListener",
1338
1338
  "removeListener"
1339
1339
  // used by the Node.js EventEmitter
1340
- ], ne = 5;
1340
+ ], nt = 5;
1341
1341
  var l;
1342
1342
  (function(s) {
1343
1343
  s[s.CONNECT = 0] = "CONNECT", s[s.DISCONNECT = 1] = "DISCONNECT", s[s.EVENT = 2] = "EVENT", s[s.ACK = 3] = "ACK", s[s.CONNECT_ERROR = 4] = "CONNECT_ERROR", s[s.BINARY_EVENT = 5] = "BINARY_EVENT", s[s.BINARY_ACK = 6] = "BINARY_ACK";
1344
1344
  })(l || (l = {}));
1345
- class re {
1345
+ class rt {
1346
1346
  /**
1347
1347
  * Encoder constructor
1348
1348
  *
1349
1349
  * @param {function} replacer - custom replacer to pass down to JSON.parse
1350
1350
  */
1351
- constructor(t) {
1352
- this.replacer = t;
1351
+ constructor(e) {
1352
+ this.replacer = e;
1353
1353
  }
1354
1354
  /**
1355
1355
  * Encode a packet as a single string if non-binary, or as a
@@ -1357,32 +1357,32 @@ class re {
1357
1357
  *
1358
1358
  * @param {Object} obj - packet object
1359
1359
  */
1360
- encode(t) {
1361
- return (t.type === l.EVENT || t.type === l.ACK) && R(t) ? this.encodeAsBinary({
1362
- type: t.type === l.EVENT ? l.BINARY_EVENT : l.BINARY_ACK,
1363
- nsp: t.nsp,
1364
- data: t.data,
1365
- id: t.id
1366
- }) : [this.encodeAsString(t)];
1360
+ encode(e) {
1361
+ return (e.type === l.EVENT || e.type === l.ACK) && R(e) ? this.encodeAsBinary({
1362
+ type: e.type === l.EVENT ? l.BINARY_EVENT : l.BINARY_ACK,
1363
+ nsp: e.nsp,
1364
+ data: e.data,
1365
+ id: e.id
1366
+ }) : [this.encodeAsString(e)];
1367
1367
  }
1368
1368
  /**
1369
1369
  * Encode packet as string.
1370
1370
  */
1371
- encodeAsString(t) {
1372
- let e = "" + t.type;
1373
- return (t.type === l.BINARY_EVENT || t.type === l.BINARY_ACK) && (e += t.attachments + "-"), t.nsp && t.nsp !== "/" && (e += t.nsp + ","), t.id != null && (e += t.id), t.data != null && (e += JSON.stringify(t.data, this.replacer)), e;
1371
+ encodeAsString(e) {
1372
+ let t = "" + e.type;
1373
+ return (e.type === l.BINARY_EVENT || e.type === l.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
1374
1374
  }
1375
1375
  /**
1376
1376
  * Encode packet as 'buffer sequence' by removing blobs, and
1377
1377
  * deconstructing packet into object with placeholders and
1378
1378
  * a list of buffers.
1379
1379
  */
1380
- encodeAsBinary(t) {
1381
- const e = te(t), n = this.encodeAsString(e.packet), r = e.buffers;
1380
+ encodeAsBinary(e) {
1381
+ const t = et(e), n = this.encodeAsString(t.packet), r = t.buffers;
1382
1382
  return r.unshift(n), r;
1383
1383
  }
1384
1384
  }
1385
- function tt(s) {
1385
+ function ee(s) {
1386
1386
  return Object.prototype.toString.call(s) === "[object Object]";
1387
1387
  }
1388
1388
  class K extends _ {
@@ -1391,29 +1391,29 @@ class K extends _ {
1391
1391
  *
1392
1392
  * @param {function} reviver - custom reviver to pass down to JSON.stringify
1393
1393
  */
1394
- constructor(t) {
1395
- super(), this.reviver = t;
1394
+ constructor(e) {
1395
+ super(), this.reviver = e;
1396
1396
  }
1397
1397
  /**
1398
1398
  * Decodes an encoded packet string into packet JSON.
1399
1399
  *
1400
1400
  * @param {String} obj - encoded packet
1401
1401
  */
1402
- add(t) {
1403
- let e;
1404
- if (typeof t == "string") {
1402
+ add(e) {
1403
+ let t;
1404
+ if (typeof e == "string") {
1405
1405
  if (this.reconstructor)
1406
1406
  throw new Error("got plaintext data when reconstructing a packet");
1407
- e = this.decodeString(t);
1408
- const n = e.type === l.BINARY_EVENT;
1409
- n || e.type === l.BINARY_ACK ? (e.type = n ? l.EVENT : l.ACK, this.reconstructor = new ie(e), e.attachments === 0 && super.emitReserved("decoded", e)) : super.emitReserved("decoded", e);
1410
- } else if (z(t) || t.base64)
1407
+ t = this.decodeString(e);
1408
+ const n = t.type === l.BINARY_EVENT;
1409
+ n || t.type === l.BINARY_ACK ? (t.type = n ? l.EVENT : l.ACK, this.reconstructor = new it(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
1410
+ } else if (z(e) || e.base64)
1411
1411
  if (this.reconstructor)
1412
- e = this.reconstructor.takeBinaryData(t), e && (this.reconstructor = null, super.emitReserved("decoded", e));
1412
+ t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
1413
1413
  else
1414
1414
  throw new Error("got binary data when not reconstructing a packet");
1415
1415
  else
1416
- throw new Error("Unknown type: " + t);
1416
+ throw new Error("Unknown type: " + e);
1417
1417
  }
1418
1418
  /**
1419
1419
  * Decode a packet String (JSON data)
@@ -1421,45 +1421,45 @@ class K extends _ {
1421
1421
  * @param {String} str
1422
1422
  * @return {Object} packet
1423
1423
  */
1424
- decodeString(t) {
1425
- let e = 0;
1424
+ decodeString(e) {
1425
+ let t = 0;
1426
1426
  const n = {
1427
- type: Number(t.charAt(0))
1427
+ type: Number(e.charAt(0))
1428
1428
  };
1429
1429
  if (l[n.type] === void 0)
1430
1430
  throw new Error("unknown packet type " + n.type);
1431
1431
  if (n.type === l.BINARY_EVENT || n.type === l.BINARY_ACK) {
1432
- const i = e + 1;
1433
- for (; t.charAt(++e) !== "-" && e != t.length; )
1432
+ const i = t + 1;
1433
+ for (; e.charAt(++t) !== "-" && t != e.length; )
1434
1434
  ;
1435
- const o = t.substring(i, e);
1436
- if (o != Number(o) || t.charAt(e) !== "-")
1435
+ const o = e.substring(i, t);
1436
+ if (o != Number(o) || e.charAt(t) !== "-")
1437
1437
  throw new Error("Illegal attachments");
1438
1438
  n.attachments = Number(o);
1439
1439
  }
1440
- if (t.charAt(e + 1) === "/") {
1441
- const i = e + 1;
1442
- for (; ++e && !(t.charAt(e) === "," || e === t.length); )
1440
+ if (e.charAt(t + 1) === "/") {
1441
+ const i = t + 1;
1442
+ for (; ++t && !(e.charAt(t) === "," || t === e.length); )
1443
1443
  ;
1444
- n.nsp = t.substring(i, e);
1444
+ n.nsp = e.substring(i, t);
1445
1445
  } else
1446
1446
  n.nsp = "/";
1447
- const r = t.charAt(e + 1);
1447
+ const r = e.charAt(t + 1);
1448
1448
  if (r !== "" && Number(r) == r) {
1449
- const i = e + 1;
1450
- for (; ++e; ) {
1451
- const o = t.charAt(e);
1449
+ const i = t + 1;
1450
+ for (; ++t; ) {
1451
+ const o = e.charAt(t);
1452
1452
  if (o == null || Number(o) != o) {
1453
- --e;
1453
+ --t;
1454
1454
  break;
1455
1455
  }
1456
- if (e === t.length)
1456
+ if (t === e.length)
1457
1457
  break;
1458
1458
  }
1459
- n.id = Number(t.substring(i, e + 1));
1459
+ n.id = Number(e.substring(i, t + 1));
1460
1460
  }
1461
- if (t.charAt(++e)) {
1462
- const i = this.tryParse(t.substr(e));
1461
+ if (e.charAt(++t)) {
1462
+ const i = this.tryParse(e.substr(t));
1463
1463
  if (K.isPayloadValid(n.type, i))
1464
1464
  n.data = i;
1465
1465
  else
@@ -1467,27 +1467,27 @@ class K extends _ {
1467
1467
  }
1468
1468
  return n;
1469
1469
  }
1470
- tryParse(t) {
1470
+ tryParse(e) {
1471
1471
  try {
1472
- return JSON.parse(t, this.reviver);
1472
+ return JSON.parse(e, this.reviver);
1473
1473
  } catch {
1474
1474
  return !1;
1475
1475
  }
1476
1476
  }
1477
- static isPayloadValid(t, e) {
1478
- switch (t) {
1477
+ static isPayloadValid(e, t) {
1478
+ switch (e) {
1479
1479
  case l.CONNECT:
1480
- return tt(e);
1480
+ return ee(t);
1481
1481
  case l.DISCONNECT:
1482
- return e === void 0;
1482
+ return t === void 0;
1483
1483
  case l.CONNECT_ERROR:
1484
- return typeof e == "string" || tt(e);
1484
+ return typeof t == "string" || ee(t);
1485
1485
  case l.EVENT:
1486
1486
  case l.BINARY_EVENT:
1487
- return Array.isArray(e) && (typeof e[0] == "number" || typeof e[0] == "string" && se.indexOf(e[0]) === -1);
1487
+ return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && st.indexOf(t[0]) === -1);
1488
1488
  case l.ACK:
1489
1489
  case l.BINARY_ACK:
1490
- return Array.isArray(e);
1490
+ return Array.isArray(t);
1491
1491
  }
1492
1492
  }
1493
1493
  /**
@@ -1497,9 +1497,9 @@ class K extends _ {
1497
1497
  this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
1498
1498
  }
1499
1499
  }
1500
- class ie {
1501
- constructor(t) {
1502
- this.packet = t, this.buffers = [], this.reconPack = t;
1500
+ class it {
1501
+ constructor(e) {
1502
+ this.packet = e, this.buffers = [], this.reconPack = e;
1503
1503
  }
1504
1504
  /**
1505
1505
  * Method to be called when binary data received from connection
@@ -1509,10 +1509,10 @@ class ie {
1509
1509
  * @return {null | Object} returns null if more binary data is expected or
1510
1510
  * a reconstructed packet object if all buffers have been received.
1511
1511
  */
1512
- takeBinaryData(t) {
1513
- if (this.buffers.push(t), this.buffers.length === this.reconPack.attachments) {
1514
- const e = ee(this.reconPack, this.buffers);
1515
- return this.finishedReconstruction(), e;
1512
+ takeBinaryData(e) {
1513
+ if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
1514
+ const t = tt(this.reconPack, this.buffers);
1515
+ return this.finishedReconstruction(), t;
1516
1516
  }
1517
1517
  return null;
1518
1518
  }
@@ -1523,21 +1523,21 @@ class ie {
1523
1523
  this.reconPack = null, this.buffers = [];
1524
1524
  }
1525
1525
  }
1526
- const oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1526
+ const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1527
1527
  __proto__: null,
1528
1528
  Decoder: K,
1529
- Encoder: re,
1529
+ Encoder: rt,
1530
1530
  get PacketType() {
1531
1531
  return l;
1532
1532
  },
1533
- protocol: ne
1533
+ protocol: nt
1534
1534
  }, Symbol.toStringTag, { value: "Module" }));
1535
- function f(s, t, e) {
1536
- return s.on(t, e), function() {
1537
- s.off(t, e);
1535
+ function f(s, e, t) {
1536
+ return s.on(e, t), function() {
1537
+ s.off(e, t);
1538
1538
  };
1539
1539
  }
1540
- const ae = Object.freeze({
1540
+ const at = Object.freeze({
1541
1541
  connect: 1,
1542
1542
  connect_error: 1,
1543
1543
  disconnect: 1,
@@ -1546,12 +1546,12 @@ const ae = Object.freeze({
1546
1546
  newListener: 1,
1547
1547
  removeListener: 1
1548
1548
  });
1549
- let dt = class extends _ {
1549
+ let de = class extends _ {
1550
1550
  /**
1551
1551
  * `Socket` constructor.
1552
1552
  */
1553
- constructor(s, t, e) {
1554
- super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = s, this.nsp = t, e && e.auth && (this.auth = e.auth), this._opts = Object.assign({}, e), this.io._autoConnect && this.open();
1553
+ constructor(s, e, t) {
1554
+ super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = s, this.nsp = e, t && t.auth && (this.auth = t.auth), this._opts = Object.assign({}, t), this.io._autoConnect && this.open();
1555
1555
  }
1556
1556
  /**
1557
1557
  * Whether the socket is currently disconnected
@@ -1660,40 +1660,40 @@ let dt = class extends _ {
1660
1660
  *
1661
1661
  * @return self
1662
1662
  */
1663
- emit(s, ...t) {
1664
- var e, n, r;
1665
- if (ae.hasOwnProperty(s))
1663
+ emit(s, ...e) {
1664
+ var t, n, r;
1665
+ if (at.hasOwnProperty(s))
1666
1666
  throw new Error('"' + s.toString() + '" is a reserved event name');
1667
- if (t.unshift(s), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1668
- return this._addToQueue(t), this;
1667
+ if (e.unshift(s), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
1668
+ return this._addToQueue(e), this;
1669
1669
  const i = {
1670
1670
  type: l.EVENT,
1671
- data: t
1671
+ data: e
1672
1672
  };
1673
- if (i.options = {}, i.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
1674
- const c = this.ids++, p = t.pop();
1673
+ if (i.options = {}, i.options.compress = this.flags.compress !== !1, typeof e[e.length - 1] == "function") {
1674
+ const c = this.ids++, p = e.pop();
1675
1675
  this._registerAckCallback(c, p), i.id = c;
1676
1676
  }
1677
- const o = (n = (e = this.io.engine) === null || e === void 0 ? void 0 : e.transport) === null || n === void 0 ? void 0 : n.writable, h = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
1677
+ const o = (n = (t = this.io.engine) === null || t === void 0 ? void 0 : t.transport) === null || n === void 0 ? void 0 : n.writable, h = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
1678
1678
  return this.flags.volatile && !o || (h ? (this.notifyOutgoingListeners(i), this.packet(i)) : this.sendBuffer.push(i)), this.flags = {}, this;
1679
1679
  }
1680
1680
  /**
1681
1681
  * @private
1682
1682
  */
1683
- _registerAckCallback(s, t) {
1684
- var e;
1685
- const n = (e = this.flags.timeout) !== null && e !== void 0 ? e : this._opts.ackTimeout;
1683
+ _registerAckCallback(s, e) {
1684
+ var t;
1685
+ const n = (t = this.flags.timeout) !== null && t !== void 0 ? t : this._opts.ackTimeout;
1686
1686
  if (n === void 0) {
1687
- this.acks[s] = t;
1687
+ this.acks[s] = e;
1688
1688
  return;
1689
1689
  }
1690
1690
  const r = this.io.setTimeoutFn(() => {
1691
1691
  delete this.acks[s];
1692
1692
  for (let o = 0; o < this.sendBuffer.length; o++)
1693
1693
  this.sendBuffer[o].id === s && this.sendBuffer.splice(o, 1);
1694
- t.call(this, new Error("operation has timed out"));
1694
+ e.call(this, new Error("operation has timed out"));
1695
1695
  }, n), i = (...o) => {
1696
- this.io.clearTimeoutFn(r), t.apply(this, o);
1696
+ this.io.clearTimeoutFn(r), e.apply(this, o);
1697
1697
  };
1698
1698
  i.withError = !0, this.acks[s] = i;
1699
1699
  }
@@ -1713,10 +1713,10 @@ let dt = class extends _ {
1713
1713
  *
1714
1714
  * @return a Promise that will be fulfilled when the server acknowledges the event
1715
1715
  */
1716
- emitWithAck(s, ...t) {
1717
- return new Promise((e, n) => {
1718
- const r = (i, o) => i ? n(i) : e(o);
1719
- r.withError = !0, t.push(r), this.emit(s, ...t);
1716
+ emitWithAck(s, ...e) {
1717
+ return new Promise((t, n) => {
1718
+ const r = (i, o) => i ? n(i) : t(o);
1719
+ r.withError = !0, e.push(r), this.emit(s, ...e);
1720
1720
  });
1721
1721
  }
1722
1722
  /**
@@ -1725,16 +1725,16 @@ let dt = class extends _ {
1725
1725
  * @private
1726
1726
  */
1727
1727
  _addToQueue(s) {
1728
- let t;
1729
- typeof s[s.length - 1] == "function" && (t = s.pop());
1730
- const e = {
1728
+ let e;
1729
+ typeof s[s.length - 1] == "function" && (e = s.pop());
1730
+ const t = {
1731
1731
  id: this._queueSeq++,
1732
1732
  tryCount: 0,
1733
1733
  pending: !1,
1734
1734
  args: s,
1735
1735
  flags: Object.assign({ fromQueue: !0 }, this.flags)
1736
1736
  };
1737
- s.push((n, ...r) => e !== this._queue[0] ? void 0 : (n !== null ? e.tryCount > this._opts.retries && (this._queue.shift(), t && t(n)) : (this._queue.shift(), t && t(null, ...r)), e.pending = !1, this._drainQueue())), this._queue.push(e), this._drainQueue();
1737
+ s.push((n, ...r) => t !== this._queue[0] ? void 0 : (n !== null ? t.tryCount > this._opts.retries && (this._queue.shift(), e && e(n)) : (this._queue.shift(), e && e(null, ...r)), t.pending = !1, this._drainQueue())), this._queue.push(t), this._drainQueue();
1738
1738
  }
1739
1739
  /**
1740
1740
  * Send the first packet of the queue, and wait for an acknowledgement from the server.
@@ -1745,8 +1745,8 @@ let dt = class extends _ {
1745
1745
  _drainQueue(s = !1) {
1746
1746
  if (!this.connected || this._queue.length === 0)
1747
1747
  return;
1748
- const t = this._queue[0];
1749
- t.pending && !s || (t.pending = !0, t.tryCount++, this.flags = t.flags, this.emit.apply(this, t.args));
1748
+ const e = this._queue[0];
1749
+ e.pending && !s || (e.pending = !0, e.tryCount++, this.flags = e.flags, this.emit.apply(this, e.args));
1750
1750
  }
1751
1751
  /**
1752
1752
  * Sends a packet.
@@ -1795,8 +1795,8 @@ let dt = class extends _ {
1795
1795
  * @param description
1796
1796
  * @private
1797
1797
  */
1798
- onclose(s, t) {
1799
- this.connected = !1, delete this.id, this.emitReserved("disconnect", s, t), this._clearAcks();
1798
+ onclose(s, e) {
1799
+ this.connected = !1, delete this.id, this.emitReserved("disconnect", s, e), this._clearAcks();
1800
1800
  }
1801
1801
  /**
1802
1802
  * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
@@ -1806,9 +1806,9 @@ let dt = class extends _ {
1806
1806
  */
1807
1807
  _clearAcks() {
1808
1808
  Object.keys(this.acks).forEach((s) => {
1809
- if (!this.sendBuffer.some((t) => String(t.id) === s)) {
1810
- const t = this.acks[s];
1811
- delete this.acks[s], t.withError && t.call(this, new Error("socket has been disconnected"));
1809
+ if (!this.sendBuffer.some((e) => String(e.id) === s)) {
1810
+ const e = this.acks[s];
1811
+ delete this.acks[s], e.withError && e.call(this, new Error("socket has been disconnected"));
1812
1812
  }
1813
1813
  });
1814
1814
  }
@@ -1837,8 +1837,8 @@ let dt = class extends _ {
1837
1837
  break;
1838
1838
  case l.CONNECT_ERROR:
1839
1839
  this.destroy();
1840
- const t = new Error(s.data.message);
1841
- t.data = s.data.data, this.emitReserved("connect_error", t);
1840
+ const e = new Error(s.data.message);
1841
+ e.data = s.data.data, this.emitReserved("connect_error", e);
1842
1842
  break;
1843
1843
  }
1844
1844
  }
@@ -1849,14 +1849,14 @@ let dt = class extends _ {
1849
1849
  * @private
1850
1850
  */
1851
1851
  onevent(s) {
1852
- const t = s.data || [];
1853
- s.id != null && t.push(this.ack(s.id)), this.connected ? this.emitEvent(t) : this.receiveBuffer.push(Object.freeze(t));
1852
+ const e = s.data || [];
1853
+ s.id != null && e.push(this.ack(s.id)), this.connected ? this.emitEvent(e) : this.receiveBuffer.push(Object.freeze(e));
1854
1854
  }
1855
1855
  emitEvent(s) {
1856
1856
  if (this._anyListeners && this._anyListeners.length) {
1857
- const t = this._anyListeners.slice();
1858
- for (const e of t)
1859
- e.apply(this, s);
1857
+ const e = this._anyListeners.slice();
1858
+ for (const t of e)
1859
+ t.apply(this, s);
1860
1860
  }
1861
1861
  super.emit.apply(this, s), this._pid && s.length && typeof s[s.length - 1] == "string" && (this._lastOffset = s[s.length - 1]);
1862
1862
  }
@@ -1866,10 +1866,10 @@ let dt = class extends _ {
1866
1866
  * @private
1867
1867
  */
1868
1868
  ack(s) {
1869
- const t = this;
1870
- let e = !1;
1869
+ const e = this;
1870
+ let t = !1;
1871
1871
  return function(...n) {
1872
- e || (e = !0, t.packet({
1872
+ t || (t = !0, e.packet({
1873
1873
  type: l.ACK,
1874
1874
  id: s,
1875
1875
  data: n
@@ -1883,16 +1883,16 @@ let dt = class extends _ {
1883
1883
  * @private
1884
1884
  */
1885
1885
  onack(s) {
1886
- const t = this.acks[s.id];
1887
- typeof t == "function" && (delete this.acks[s.id], t.withError && s.data.unshift(null), t.apply(this, s.data));
1886
+ const e = this.acks[s.id];
1887
+ typeof e == "function" && (delete this.acks[s.id], e.withError && s.data.unshift(null), e.apply(this, s.data));
1888
1888
  }
1889
1889
  /**
1890
1890
  * Called upon server connect.
1891
1891
  *
1892
1892
  * @private
1893
1893
  */
1894
- onconnect(s, t) {
1895
- this.id = s, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this.emitReserved("connect"), this._drainQueue(!0);
1894
+ onconnect(s, e) {
1895
+ this.id = s, this.recovered = e && this._pid === e, this._pid = e, this.connected = !0, this.emitBuffered(), this.emitReserved("connect"), this._drainQueue(!0);
1896
1896
  }
1897
1897
  /**
1898
1898
  * Emit buffered events (received and emitted).
@@ -2039,10 +2039,10 @@ let dt = class extends _ {
2039
2039
  if (!this._anyListeners)
2040
2040
  return this;
2041
2041
  if (s) {
2042
- const t = this._anyListeners;
2043
- for (let e = 0; e < t.length; e++)
2044
- if (s === t[e])
2045
- return t.splice(e, 1), this;
2042
+ const e = this._anyListeners;
2043
+ for (let t = 0; t < e.length; t++)
2044
+ if (s === e[t])
2045
+ return e.splice(t, 1), this;
2046
2046
  } else
2047
2047
  this._anyListeners = [];
2048
2048
  return this;
@@ -2108,10 +2108,10 @@ let dt = class extends _ {
2108
2108
  if (!this._anyOutgoingListeners)
2109
2109
  return this;
2110
2110
  if (s) {
2111
- const t = this._anyOutgoingListeners;
2112
- for (let e = 0; e < t.length; e++)
2113
- if (s === t[e])
2114
- return t.splice(e, 1), this;
2111
+ const e = this._anyOutgoingListeners;
2112
+ for (let t = 0; t < e.length; t++)
2113
+ if (s === e[t])
2114
+ return e.splice(t, 1), this;
2115
2115
  } else
2116
2116
  this._anyOutgoingListeners = [];
2117
2117
  return this;
@@ -2132,9 +2132,9 @@ let dt = class extends _ {
2132
2132
  */
2133
2133
  notifyOutgoingListeners(s) {
2134
2134
  if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
2135
- const t = this._anyOutgoingListeners.slice();
2136
- for (const e of t)
2137
- e.apply(this, s.data);
2135
+ const e = this._anyOutgoingListeners.slice();
2136
+ for (const t of e)
2137
+ t.apply(this, s.data);
2138
2138
  }
2139
2139
  }
2140
2140
  };
@@ -2144,8 +2144,8 @@ function w(s) {
2144
2144
  w.prototype.duration = function() {
2145
2145
  var s = this.ms * Math.pow(this.factor, this.attempts++);
2146
2146
  if (this.jitter) {
2147
- var t = Math.random(), e = Math.floor(t * this.jitter * s);
2148
- s = (Math.floor(t * 10) & 1) == 0 ? s - e : s + e;
2147
+ var e = Math.random(), t = Math.floor(e * this.jitter * s);
2148
+ s = (Math.floor(e * 10) & 1) == 0 ? s - t : s + t;
2149
2149
  }
2150
2150
  return Math.min(s, this.max) | 0;
2151
2151
  };
@@ -2162,36 +2162,36 @@ w.prototype.setJitter = function(s) {
2162
2162
  this.jitter = s;
2163
2163
  };
2164
2164
  class $ extends _ {
2165
- constructor(t, e) {
2165
+ constructor(e, t) {
2166
2166
  var n;
2167
- super(), this.nsps = {}, this.subs = [], t && typeof t == "object" && (e = t, t = void 0), e = e || {}, e.path = e.path || "/socket.io", this.opts = e, L(this, e), this.reconnection(e.reconnection !== !1), this.reconnectionAttempts(e.reconnectionAttempts || 1 / 0), this.reconnectionDelay(e.reconnectionDelay || 1e3), this.reconnectionDelayMax(e.reconnectionDelayMax || 5e3), this.randomizationFactor((n = e.randomizationFactor) !== null && n !== void 0 ? n : 0.5), this.backoff = new w({
2167
+ super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, L(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((n = t.randomizationFactor) !== null && n !== void 0 ? n : 0.5), this.backoff = new w({
2168
2168
  min: this.reconnectionDelay(),
2169
2169
  max: this.reconnectionDelayMax(),
2170
2170
  jitter: this.randomizationFactor()
2171
- }), this.timeout(e.timeout == null ? 2e4 : e.timeout), this._readyState = "closed", this.uri = t;
2172
- const r = e.parser || oe;
2173
- this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = e.autoConnect !== !1, this._autoConnect && this.open();
2171
+ }), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
2172
+ const r = t.parser || ot;
2173
+ this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
2174
2174
  }
2175
- reconnection(t) {
2176
- return arguments.length ? (this._reconnection = !!t, t || (this.skipReconnect = !0), this) : this._reconnection;
2175
+ reconnection(e) {
2176
+ return arguments.length ? (this._reconnection = !!e, e || (this.skipReconnect = !0), this) : this._reconnection;
2177
2177
  }
2178
- reconnectionAttempts(t) {
2179
- return t === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = t, this);
2178
+ reconnectionAttempts(e) {
2179
+ return e === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = e, this);
2180
2180
  }
2181
- reconnectionDelay(t) {
2182
- var e;
2183
- return t === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = t, (e = this.backoff) === null || e === void 0 || e.setMin(t), this);
2181
+ reconnectionDelay(e) {
2182
+ var t;
2183
+ return e === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = e, (t = this.backoff) === null || t === void 0 || t.setMin(e), this);
2184
2184
  }
2185
- randomizationFactor(t) {
2186
- var e;
2187
- return t === void 0 ? this._randomizationFactor : (this._randomizationFactor = t, (e = this.backoff) === null || e === void 0 || e.setJitter(t), this);
2185
+ randomizationFactor(e) {
2186
+ var t;
2187
+ return e === void 0 ? this._randomizationFactor : (this._randomizationFactor = e, (t = this.backoff) === null || t === void 0 || t.setJitter(e), this);
2188
2188
  }
2189
- reconnectionDelayMax(t) {
2190
- var e;
2191
- return t === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = t, (e = this.backoff) === null || e === void 0 || e.setMax(t), this);
2189
+ reconnectionDelayMax(e) {
2190
+ var t;
2191
+ return e === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = e, (t = this.backoff) === null || t === void 0 || t.setMax(e), this);
2192
2192
  }
2193
- timeout(t) {
2194
- return arguments.length ? (this._timeout = t, this) : this._timeout;
2193
+ timeout(e) {
2194
+ return arguments.length ? (this._timeout = e, this) : this._timeout;
2195
2195
  }
2196
2196
  /**
2197
2197
  * Starts trying to reconnect if reconnection is enabled and we have not
@@ -2209,20 +2209,20 @@ class $ extends _ {
2209
2209
  * @return self
2210
2210
  * @public
2211
2211
  */
2212
- open(t) {
2212
+ open(e) {
2213
2213
  if (~this._readyState.indexOf("open"))
2214
2214
  return this;
2215
- this.engine = new Yt(this.uri, this.opts);
2216
- const e = this.engine, n = this;
2215
+ this.engine = new Ye(this.uri, this.opts);
2216
+ const t = this.engine, n = this;
2217
2217
  this._readyState = "opening", this.skipReconnect = !1;
2218
- const r = f(e, "open", function() {
2219
- n.onopen(), t && t();
2218
+ const r = f(t, "open", function() {
2219
+ n.onopen(), e && e();
2220
2220
  }), i = (h) => {
2221
- this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), t ? t(h) : this.maybeReconnectOnOpen();
2222
- }, o = f(e, "error", i);
2221
+ this.cleanup(), this._readyState = "closed", this.emitReserved("error", h), e ? e(h) : this.maybeReconnectOnOpen();
2222
+ }, o = f(t, "error", i);
2223
2223
  if (this._timeout !== !1) {
2224
2224
  const h = this._timeout, c = this.setTimeoutFn(() => {
2225
- r(), i(new Error("timeout")), e.close();
2225
+ r(), i(new Error("timeout")), t.close();
2226
2226
  }, h);
2227
2227
  this.opts.autoUnref && c.unref(), this.subs.push(() => {
2228
2228
  this.clearTimeoutFn(c);
@@ -2236,8 +2236,8 @@ class $ extends _ {
2236
2236
  * @return self
2237
2237
  * @public
2238
2238
  */
2239
- connect(t) {
2240
- return this.open(t);
2239
+ connect(e) {
2240
+ return this.open(e);
2241
2241
  }
2242
2242
  /**
2243
2243
  * Called upon transport open.
@@ -2246,12 +2246,12 @@ class $ extends _ {
2246
2246
  */
2247
2247
  onopen() {
2248
2248
  this.cleanup(), this._readyState = "open", this.emitReserved("open");
2249
- const t = this.engine;
2249
+ const e = this.engine;
2250
2250
  this.subs.push(
2251
- f(t, "ping", this.onping.bind(this)),
2252
- f(t, "data", this.ondata.bind(this)),
2253
- f(t, "error", this.onerror.bind(this)),
2254
- f(t, "close", this.onclose.bind(this)),
2251
+ f(e, "ping", this.onping.bind(this)),
2252
+ f(e, "data", this.ondata.bind(this)),
2253
+ f(e, "error", this.onerror.bind(this)),
2254
+ f(e, "close", this.onclose.bind(this)),
2255
2255
  // @ts-ignore
2256
2256
  f(this.decoder, "decoded", this.ondecoded.bind(this))
2257
2257
  );
@@ -2269,11 +2269,11 @@ class $ extends _ {
2269
2269
  *
2270
2270
  * @private
2271
2271
  */
2272
- ondata(t) {
2272
+ ondata(e) {
2273
2273
  try {
2274
- this.decoder.add(t);
2275
- } catch (e) {
2276
- this.onclose("parse error", e);
2274
+ this.decoder.add(e);
2275
+ } catch (t) {
2276
+ this.onclose("parse error", t);
2277
2277
  }
2278
2278
  }
2279
2279
  /**
@@ -2281,9 +2281,9 @@ class $ extends _ {
2281
2281
  *
2282
2282
  * @private
2283
2283
  */
2284
- ondecoded(t) {
2284
+ ondecoded(e) {
2285
2285
  O(() => {
2286
- this.emitReserved("packet", t);
2286
+ this.emitReserved("packet", e);
2287
2287
  }, this.setTimeoutFn);
2288
2288
  }
2289
2289
  /**
@@ -2291,8 +2291,8 @@ class $ extends _ {
2291
2291
  *
2292
2292
  * @private
2293
2293
  */
2294
- onerror(t) {
2295
- this.emitReserved("error", t);
2294
+ onerror(e) {
2295
+ this.emitReserved("error", e);
2296
2296
  }
2297
2297
  /**
2298
2298
  * Creates a new socket for the given `nsp`.
@@ -2300,9 +2300,9 @@ class $ extends _ {
2300
2300
  * @return {Socket}
2301
2301
  * @public
2302
2302
  */
2303
- socket(t, e) {
2304
- let n = this.nsps[t];
2305
- return n ? this._autoConnect && !n.active && n.connect() : (n = new dt(this, t, e), this.nsps[t] = n), n;
2303
+ socket(e, t) {
2304
+ let n = this.nsps[e];
2305
+ return n ? this._autoConnect && !n.active && n.connect() : (n = new de(this, e, t), this.nsps[e] = n), n;
2306
2306
  }
2307
2307
  /**
2308
2308
  * Called upon a socket close.
@@ -2310,9 +2310,9 @@ class $ extends _ {
2310
2310
  * @param socket
2311
2311
  * @private
2312
2312
  */
2313
- _destroy(t) {
2314
- const e = Object.keys(this.nsps);
2315
- for (const n of e)
2313
+ _destroy(e) {
2314
+ const t = Object.keys(this.nsps);
2315
+ for (const n of t)
2316
2316
  if (this.nsps[n].active)
2317
2317
  return;
2318
2318
  this._close();
@@ -2323,10 +2323,10 @@ class $ extends _ {
2323
2323
  * @param packet
2324
2324
  * @private
2325
2325
  */
2326
- _packet(t) {
2327
- const e = this.encoder.encode(t);
2328
- for (let n = 0; n < e.length; n++)
2329
- this.engine.write(e[n], t.options);
2326
+ _packet(e) {
2327
+ const t = this.encoder.encode(e);
2328
+ for (let n = 0; n < t.length; n++)
2329
+ this.engine.write(t[n], e.options);
2330
2330
  }
2331
2331
  /**
2332
2332
  * Clean up transport subscriptions and packet buffer.
@@ -2334,7 +2334,7 @@ class $ extends _ {
2334
2334
  * @private
2335
2335
  */
2336
2336
  cleanup() {
2337
- this.subs.forEach((t) => t()), this.subs.length = 0, this.decoder.destroy();
2337
+ this.subs.forEach((e) => e()), this.subs.length = 0, this.decoder.destroy();
2338
2338
  }
2339
2339
  /**
2340
2340
  * Close the current socket.
@@ -2361,9 +2361,9 @@ class $ extends _ {
2361
2361
  *
2362
2362
  * @private
2363
2363
  */
2364
- onclose(t, e) {
2364
+ onclose(e, t) {
2365
2365
  var n;
2366
- this.cleanup(), (n = this.engine) === null || n === void 0 || n.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", t, e), this._reconnection && !this.skipReconnect && this.reconnect();
2366
+ this.cleanup(), (n = this.engine) === null || n === void 0 || n.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", e, t), this._reconnection && !this.skipReconnect && this.reconnect();
2367
2367
  }
2368
2368
  /**
2369
2369
  * Attempt a reconnection.
@@ -2373,17 +2373,17 @@ class $ extends _ {
2373
2373
  reconnect() {
2374
2374
  if (this._reconnecting || this.skipReconnect)
2375
2375
  return this;
2376
- const t = this;
2376
+ const e = this;
2377
2377
  if (this.backoff.attempts >= this._reconnectionAttempts)
2378
2378
  this.backoff.reset(), this.emitReserved("reconnect_failed"), this._reconnecting = !1;
2379
2379
  else {
2380
- const e = this.backoff.duration();
2380
+ const t = this.backoff.duration();
2381
2381
  this._reconnecting = !0;
2382
2382
  const n = this.setTimeoutFn(() => {
2383
- t.skipReconnect || (this.emitReserved("reconnect_attempt", t.backoff.attempts), !t.skipReconnect && t.open((r) => {
2384
- r ? (t._reconnecting = !1, t.reconnect(), this.emitReserved("reconnect_error", r)) : t.onreconnect();
2383
+ e.skipReconnect || (this.emitReserved("reconnect_attempt", e.backoff.attempts), !e.skipReconnect && e.open((r) => {
2384
+ r ? (e._reconnecting = !1, e.reconnect(), this.emitReserved("reconnect_error", r)) : e.onreconnect();
2385
2385
  }));
2386
- }, e);
2386
+ }, t);
2387
2387
  this.opts.autoUnref && n.unref(), this.subs.push(() => {
2388
2388
  this.clearTimeoutFn(n);
2389
2389
  });
@@ -2395,44 +2395,44 @@ class $ extends _ {
2395
2395
  * @private
2396
2396
  */
2397
2397
  onreconnect() {
2398
- const t = this.backoff.attempts;
2399
- this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", t);
2398
+ const e = this.backoff.attempts;
2399
+ this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
2400
2400
  }
2401
2401
  }
2402
2402
  const k = {};
2403
- function B(s, t) {
2404
- typeof s == "object" && (t = s, s = void 0), t = t || {};
2405
- const e = Jt(s, t.path || "/socket.io"), n = e.source, r = e.id, i = e.path, o = k[r] && i in k[r].nsps, h = t.forceNew || t["force new connection"] || t.multiplex === !1 || o;
2403
+ function B(s, e) {
2404
+ typeof s == "object" && (e = s, s = void 0), e = e || {};
2405
+ const t = Je(s, e.path || "/socket.io"), n = t.source, r = t.id, i = t.path, o = k[r] && i in k[r].nsps, h = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
2406
2406
  let c;
2407
- return h ? c = new $(n, t) : (k[r] || (k[r] = new $(n, t)), c = k[r]), e.query && !t.query && (t.query = e.queryKey), c.socket(e.path, t);
2407
+ return h ? c = new $(n, e) : (k[r] || (k[r] = new $(n, e)), c = k[r]), t.query && !e.query && (e.query = t.queryKey), c.socket(t.path, e);
2408
2408
  }
2409
2409
  Object.assign(B, {
2410
2410
  Manager: $,
2411
- Socket: dt,
2411
+ Socket: de,
2412
2412
  io: B,
2413
2413
  connect: B
2414
2414
  });
2415
- class ce {
2416
- #e = "http://localhost:3000";
2415
+ class ct {
2416
+ #t = "http://localhost:3000";
2417
2417
  #s = {
2418
2418
  transports: ["websocket"]
2419
2419
  };
2420
- #t;
2420
+ #e;
2421
2421
  #i = !1;
2422
2422
  #o = {};
2423
- set uri(t) {
2424
- const e = new URL(t);
2425
- if (!["http:", "https:", "ws:", "wss:"].includes(e.protocol))
2423
+ set uri(e) {
2424
+ const t = new URL(e);
2425
+ if (!["http:", "https:", "ws:", "wss:"].includes(t.protocol))
2426
2426
  throw new Error("URI must start with http://, https://, ws://, or wss://");
2427
- this.#e = t;
2427
+ this.#t = e;
2428
2428
  }
2429
2429
  get uri() {
2430
- return this.#e;
2430
+ return this.#t;
2431
2431
  }
2432
- set options(t) {
2433
- if (typeof t != "object")
2432
+ set options(e) {
2433
+ if (typeof e != "object")
2434
2434
  throw new Error("Options must be an object");
2435
- this.#s = t;
2435
+ this.#s = e;
2436
2436
  }
2437
2437
  get options() {
2438
2438
  return this.#s;
@@ -2441,29 +2441,29 @@ class ce {
2441
2441
  this.#o.onResponse = this.onResponse.bind(this);
2442
2442
  }
2443
2443
  disconnect() {
2444
- this.#t && (this.#t.off("response", this.#o.onResponse), this.#t.disconnect(), this.#t = null), this.#i = !1;
2444
+ this.#e && (this.#e.off("response", this.#o.onResponse), this.#e.disconnect(), this.#e = null), this.#i = !1;
2445
2445
  }
2446
2446
  prepare() {
2447
- this.#i || (this.#t = B(this.#e, this.#s), this.#i = !0, this.#t.on("response", this.#o.onResponse));
2447
+ this.#i || (this.#e = B(this.#t, this.#s), this.#i = !0, this.#e.on("response", this.#o.onResponse));
2448
2448
  }
2449
- connectDevice(t) {
2450
- this.#t.emit("connectDevice", { config: t });
2449
+ connectDevice(e) {
2450
+ this.#e.emit("connectDevice", { config: e });
2451
2451
  }
2452
- disconnectDevice(t) {
2453
- this.#t.emit("disconnectDevice", { config: t });
2452
+ disconnectDevice(e) {
2453
+ this.#e.emit("disconnectDevice", { config: e });
2454
2454
  }
2455
2455
  disconnectAllDevices() {
2456
- this.#t.emit("disconnectAll");
2456
+ this.#e.emit("disconnectAll");
2457
2457
  }
2458
- write(t) {
2459
- this.#t.emit("cmd", t);
2458
+ write(e) {
2459
+ this.#e.emit("cmd", e);
2460
2460
  }
2461
- onResponse(t) {
2462
- let e = a.get(t.name, t.uuid);
2463
- e || (e = a.getByNumber(t.name, t.deviceNumber)), e && e.socketResponse(t);
2461
+ onResponse(e) {
2462
+ let t = a.get(e.name, e.uuid);
2463
+ t || (t = a.getByNumber(e.name, e.deviceNumber)), t && t.socketResponse(e);
2464
2464
  }
2465
2465
  }
2466
- const A = new ce(), D = {
2466
+ const A = new ct(), q = {
2467
2467
  baudRate: 9600,
2468
2468
  dataBits: 8,
2469
2469
  stopBits: 1,
@@ -2471,7 +2471,7 @@ const A = new ce(), D = {
2471
2471
  bufferSize: 32768,
2472
2472
  flowControl: "none"
2473
2473
  };
2474
- class le extends et {
2474
+ class lt extends te {
2475
2475
  __internal__ = {
2476
2476
  bypassSerialBytesConnection: !1,
2477
2477
  auto_response: !1,
@@ -2519,8 +2519,9 @@ class le extends et {
2519
2519
  delay_first_connection: 200,
2520
2520
  bytes_connection: null,
2521
2521
  filters: [],
2522
- config_port: D,
2522
+ config_port: q,
2523
2523
  queue: [],
2524
+ running_queue: !1,
2524
2525
  auto_response: null,
2525
2526
  free_timeout_ms: 50,
2526
2527
  // In previous versions 400 was used
@@ -2544,17 +2545,17 @@ class le extends et {
2544
2545
  reconnection: 0
2545
2546
  }
2546
2547
  };
2547
- #e = null;
2548
+ #t = null;
2548
2549
  constructor({
2549
- filters: t = null,
2550
- config_port: e = D,
2550
+ filters: e = null,
2551
+ config_port: t = q,
2551
2552
  no_device: n = 1,
2552
2553
  device_listen_on_channel: r = 1,
2553
2554
  bypassSerialBytesConnection: i = !1,
2554
2555
  socket: o = !1
2555
2556
  } = {
2556
2557
  filters: null,
2557
- config_port: D,
2558
+ config_port: q,
2558
2559
  no_device: 1,
2559
2560
  device_listen_on_channel: 1,
2560
2561
  bypassSerialBytesConnection: !1,
@@ -2562,12 +2563,12 @@ class le extends et {
2562
2563
  }) {
2563
2564
  if (super(), !("serial" in navigator))
2564
2565
  throw new Error("Web Serial not supported");
2565
- t && (this.serialFilters = t), e && (this.serialConfigPort = e), i && (this.__internal__.bypassSerialBytesConnection = i), n && this.#w(n), r && ["number", "string"].includes(typeof r) && (this.listenOnChannel = r), this.__internal__.serial.socket = o, this.#y(), this.#g();
2566
+ e && (this.serialFilters = e), t && (this.serialConfigPort = t), i && (this.__internal__.bypassSerialBytesConnection = i), n && this.#w(n), r && ["number", "string"].includes(typeof r) && (this.listenOnChannel = r), this.__internal__.serial.socket = o, this.#y(), this.#g();
2566
2567
  }
2567
- set listenOnChannel(t) {
2568
- if (typeof t == "string" && (t = parseInt(t)), isNaN(t) || t < 1 || t > 255)
2568
+ set listenOnChannel(e) {
2569
+ if (typeof e == "string" && (e = parseInt(e)), isNaN(e) || e < 1 || e > 255)
2569
2570
  throw new Error("Invalid port number");
2570
- this.__internal__.device.listen_on_port = t, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(t));
2571
+ this.__internal__.device.listen_on_port = e, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e));
2571
2572
  }
2572
2573
  get lastAction() {
2573
2574
  return this.__internal__.serial.last_action;
@@ -2575,16 +2576,16 @@ class le extends et {
2575
2576
  get listenOnChannel() {
2576
2577
  return this.__internal__.device.listen_on_port ?? 1;
2577
2578
  }
2578
- set serialFilters(t) {
2579
+ set serialFilters(e) {
2579
2580
  if (this.isConnected) throw new Error("Cannot change serial filters while connected");
2580
- this.__internal__.serial.filters = t;
2581
+ this.__internal__.serial.filters = e;
2581
2582
  }
2582
2583
  get serialFilters() {
2583
2584
  return this.__internal__.serial.filters;
2584
2585
  }
2585
- set serialConfigPort(t) {
2586
+ set serialConfigPort(e) {
2586
2587
  if (this.isConnected) throw new Error("Cannot change serial filters while connected");
2587
- this.__internal__.serial.config_port = t;
2588
+ this.__internal__.serial.config_port = e;
2588
2589
  }
2589
2590
  get serialConfigPort() {
2590
2591
  return this.__internal__.serial.config_port;
@@ -2592,19 +2593,19 @@ class le extends et {
2592
2593
  get useRTSCTS() {
2593
2594
  return this.__internal__.serial.useRTSCTS;
2594
2595
  }
2595
- set useRTSCTS(t) {
2596
- this.__internal__.serial.useRTSCTS = t;
2596
+ set useRTSCTS(e) {
2597
+ this.__internal__.serial.useRTSCTS = e;
2597
2598
  }
2598
2599
  get isConnected() {
2599
- const t = this.__internal__.serial.connected, e = this.#s(this.__internal__.serial.port);
2600
- return t && !e && this.#t({ error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = e, this.__internal__.serial.connected;
2600
+ const e = this.__internal__.serial.connected, t = this.#s(this.__internal__.serial.port);
2601
+ return e && !t && this.#e({ error: "Port is closed, not readable or writable." }), this.__internal__.serial.connected = t, this.__internal__.serial.connected;
2601
2602
  }
2602
2603
  get isConnecting() {
2603
2604
  return this.__internal__.serial.connecting;
2604
2605
  }
2605
2606
  get isDisconnected() {
2606
- const t = this.__internal__.serial.connected, e = this.#s(this.__internal__.serial.port);
2607
- return !t && e && (this.dispatch("serial:connected"), this.#r(!1), a.$dispatchChange(this)), this.__internal__.serial.connected = e, !this.__internal__.serial.connected;
2607
+ const e = this.__internal__.serial.connected, t = this.#s(this.__internal__.serial.port);
2608
+ return !e && t && (this.dispatch("serial:connected"), this.#r(!1), a.$dispatchChange(this)), this.__internal__.serial.connected = t, !this.__internal__.serial.connected;
2608
2609
  }
2609
2610
  get deviceNumber() {
2610
2611
  return this.__internal__.device_number;
@@ -2621,113 +2622,113 @@ class le extends et {
2621
2622
  get responseDelimited() {
2622
2623
  return this.__internal__.serial.response.delimited;
2623
2624
  }
2624
- set responseDelimited(t) {
2625
- if (typeof t != "boolean")
2625
+ set responseDelimited(e) {
2626
+ if (typeof e != "boolean")
2626
2627
  throw new Error("responseDelimited must be a boolean");
2627
- this.__internal__.serial.response.delimited = t;
2628
+ this.__internal__.serial.response.delimited = e;
2628
2629
  }
2629
2630
  get responsePrefixLimited() {
2630
2631
  return this.__internal__.serial.response.prefixLimiter;
2631
2632
  }
2632
- set responsePrefixLimited(t) {
2633
- if (typeof t != "boolean")
2633
+ set responsePrefixLimited(e) {
2634
+ if (typeof e != "boolean")
2634
2635
  throw new Error("responsePrefixLimited must be a boolean");
2635
- this.__internal__.serial.response.prefixLimiter = t;
2636
+ this.__internal__.serial.response.prefixLimiter = e;
2636
2637
  }
2637
2638
  get responseSufixLimited() {
2638
2639
  return this.__internal__.serial.response.sufixLimiter;
2639
2640
  }
2640
- set responseSufixLimited(t) {
2641
- if (typeof t != "boolean")
2641
+ set responseSufixLimited(e) {
2642
+ if (typeof e != "boolean")
2642
2643
  throw new Error("responseSufixLimited must be a boolean");
2643
- this.__internal__.serial.response.sufixLimiter = t;
2644
+ this.__internal__.serial.response.sufixLimiter = e;
2644
2645
  }
2645
2646
  get responseLimiter() {
2646
2647
  return this.__internal__.serial.response.limiter;
2647
2648
  }
2648
- set responseLimiter(t) {
2649
- if (typeof t != "string" && !(t instanceof RegExp))
2649
+ set responseLimiter(e) {
2650
+ if (typeof e != "string" && !(e instanceof RegExp))
2650
2651
  throw new Error("responseLimiter must be a string or a RegExp");
2651
- this.__internal__.serial.response.limiter = t;
2652
+ this.__internal__.serial.response.limiter = e;
2652
2653
  }
2653
2654
  get fixedBytesMessage() {
2654
2655
  return this.__internal__.serial.response.length;
2655
2656
  }
2656
- set fixedBytesMessage(t) {
2657
- if (t !== null && (typeof t != "number" || t < 1))
2657
+ set fixedBytesMessage(e) {
2658
+ if (e !== null && (typeof e != "number" || e < 1))
2658
2659
  throw new Error("Invalid length for fixed bytes message");
2659
- this.__internal__.serial.response.length = t;
2660
+ this.__internal__.serial.response.length = e;
2660
2661
  }
2661
2662
  get timeoutBeforeResponseBytes() {
2662
2663
  return this.__internal__.serial.free_timeout_ms || 50;
2663
2664
  }
2664
- set timeoutBeforeResponseBytes(t) {
2665
- if (t !== void 0 && (typeof t != "number" || t < 1))
2665
+ set timeoutBeforeResponseBytes(e) {
2666
+ if (e !== void 0 && (typeof e != "number" || e < 1))
2666
2667
  throw new Error("Invalid timeout for response bytes");
2667
- this.__internal__.serial.free_timeout_ms = t ?? 50;
2668
+ this.__internal__.serial.free_timeout_ms = e ?? 50;
2668
2669
  }
2669
2670
  get bypassSerialBytesConnection() {
2670
2671
  return this.__internal__.bypassSerialBytesConnection;
2671
2672
  }
2672
- set bypassSerialBytesConnection(t) {
2673
- if (typeof t != "boolean")
2673
+ set bypassSerialBytesConnection(e) {
2674
+ if (typeof e != "boolean")
2674
2675
  throw new Error("bypassSerialBytesConnection must be a boolean");
2675
- this.__internal__.bypassSerialBytesConnection = t;
2676
+ this.__internal__.bypassSerialBytesConnection = e;
2676
2677
  }
2677
2678
  get useSocket() {
2678
2679
  return this.__internal__.serial.socket;
2679
2680
  }
2680
2681
  get connectionBytes() {
2681
- const t = this.__internal__.serial.bytes_connection;
2682
- return t instanceof Uint8Array ? t : typeof t == "string" ? this.stringArrayToUint8Array(this.parseStringToBytes(t, "")) : Array.isArray(t) && typeof t[0] == "string" ? this.stringArrayToUint8Array(t) : Array.isArray(t) && typeof t[0] == "number" ? new Uint8Array(t) : new Uint8Array([]);
2682
+ const e = this.__internal__.serial.bytes_connection;
2683
+ return e instanceof Uint8Array ? e : typeof e == "string" ? this.stringArrayToUint8Array(this.parseStringToBytes(e, "")) : Array.isArray(e) && typeof e[0] == "string" ? this.stringArrayToUint8Array(e) : Array.isArray(e) && typeof e[0] == "number" ? new Uint8Array(e) : new Uint8Array([]);
2683
2684
  }
2684
- set portPath(t) {
2685
+ set portPath(e) {
2685
2686
  if (this.isConnected) throw new Error("Cannot change port path while connected");
2686
- if (typeof t != "string" && t !== null)
2687
+ if (typeof e != "string" && e !== null)
2687
2688
  throw new TypeError("vendorId must be string or null");
2688
- this.__internal__.serial.portInfo.path = t;
2689
+ this.__internal__.serial.portInfo.path = e;
2689
2690
  }
2690
2691
  get portPath() {
2691
2692
  return this.__internal__.serial.portInfo.path;
2692
2693
  }
2693
- set portVendorId(t) {
2694
+ set portVendorId(e) {
2694
2695
  if (this.isConnected) throw new Error("Cannot change port vendorId while connected");
2695
- if (typeof t == "number" && typeof t != "string" && t !== null)
2696
+ if (typeof e == "number" && typeof e != "string" && e !== null)
2696
2697
  throw new TypeError("vendorId must be a number, string or null");
2697
- this.__internal__.serial.portInfo.vendorId = t;
2698
+ this.__internal__.serial.portInfo.vendorId = e;
2698
2699
  }
2699
2700
  get portVendorId() {
2700
2701
  return this.__internal__.serial.portInfo.vendorId;
2701
2702
  }
2702
- set portProductId(t) {
2703
+ set portProductId(e) {
2703
2704
  if (this.isConnected) throw new Error("Cannot change port productId while connected");
2704
- if (typeof t == "number" && typeof t != "string" && t !== null)
2705
+ if (typeof e == "number" && typeof e != "string" && e !== null)
2705
2706
  throw new TypeError("productId must be a number, string or null");
2706
- this.__internal__.serial.portInfo.productId = t;
2707
+ this.__internal__.serial.portInfo.productId = e;
2707
2708
  }
2708
2709
  get portProductId() {
2709
2710
  return this.__internal__.serial.portInfo.productId;
2710
2711
  }
2711
- set socketPortParser(t) {
2712
- if (["byte-length", "inter-byte-timeout"].includes(t))
2712
+ set socketPortParser(e) {
2713
+ if (["byte-length", "inter-byte-timeout"].includes(e))
2713
2714
  throw new TypeError("socketPortParser must be a string, either 'byte-length' or 'inter-byte-timeout'");
2714
- this.__internal__.serial.portInfo.parser.name = t;
2715
+ this.__internal__.serial.portInfo.parser.name = e;
2715
2716
  }
2716
2717
  get socketPortParser() {
2717
2718
  return this.__internal__.serial.portInfo.parser.name;
2718
2719
  }
2719
- set socketPortParserInterval(t) {
2720
- if (typeof t != "number" || t < 1)
2720
+ set socketPortParserInterval(e) {
2721
+ if (typeof e != "number" || e < 1)
2721
2722
  throw new TypeError("Interval must be a positive number");
2722
- this.__internal__.serial.portInfo.parser.interval = t;
2723
+ this.__internal__.serial.portInfo.parser.interval = e;
2723
2724
  }
2724
2725
  get socketPortParserInterval() {
2725
2726
  return this.__internal__.serial.portInfo.parser.interval || 50;
2726
2727
  }
2727
- set socketPortParserLength(t) {
2728
- if (typeof t != "number" || t < 1)
2728
+ set socketPortParserLength(e) {
2729
+ if (typeof e != "number" || e < 1)
2729
2730
  throw new TypeError("Length must be a positive number or null");
2730
- this.__internal__.serial.portInfo.parser.length = t;
2731
+ this.__internal__.serial.portInfo.parser.length = e;
2731
2732
  }
2732
2733
  get socketPortParserLength() {
2733
2734
  return this.__internal__.serial.portInfo.parser.length || 14;
@@ -2777,40 +2778,40 @@ class le extends et {
2777
2778
  }
2778
2779
  };
2779
2780
  }
2780
- #s(t) {
2781
- return this.useSocket ? this.__internal__.serial.connected : !!(t && t.readable && t.writable);
2781
+ #s(e) {
2782
+ return this.useSocket ? this.__internal__.serial.connected : !!(e && e.readable && e.writable);
2782
2783
  }
2783
- async timeout(t, e) {
2784
- this.__internal__.last_error.message = "Operation response timed out.", this.__internal__.last_error.action = e, this.__internal__.last_error.code = t, this.__internal__.timeout.until_response && (clearTimeout(this.__internal__.timeout.until_response), this.__internal__.timeout.until_response = 0), e === "connect" ? (this.__internal__.serial.connected = !1, this.dispatch("serial:reconnect", {}), a.$dispatchChange(this)) : e === "connection:start" && (await this.serialDisconnect(), this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector += 1, a.$dispatchChange(this), await this.serialConnect()), this.dispatch("serial:timeout", {
2784
+ async timeout(e, t) {
2785
+ this.__internal__.last_error.message = "Operation response timed out.", this.__internal__.last_error.action = t, this.__internal__.last_error.code = e, this.__internal__.timeout.until_response && (clearTimeout(this.__internal__.timeout.until_response), this.__internal__.timeout.until_response = 0), t === "connect" ? (this.__internal__.serial.connected = !1, this.dispatch("serial:reconnect", {}), a.$dispatchChange(this)) : t === "connection:start" && (await this.serialDisconnect(), this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector += 1, a.$dispatchChange(this), await this.serialConnect()), this.__internal__.serial.queue.length > 0 && this.dispatch("internal:queue", {}), this.dispatch("serial:timeout", {
2785
2786
  ...this.__internal__.last_error,
2786
- bytes: t,
2787
- action: e
2787
+ bytes: e,
2788
+ action: t
2788
2789
  });
2789
2790
  }
2790
- async disconnect(t = null) {
2791
- await this.serialDisconnect(), this.#t(t);
2791
+ async disconnect(e = null) {
2792
+ await this.serialDisconnect(), this.#e(e);
2792
2793
  }
2793
- #t(t = null) {
2794
- this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected", t), a.$dispatchChange(this);
2794
+ #e(e = null) {
2795
+ this.__internal__.serial.connected = !1, this.__internal__.aux_port_connector = 0, this.dispatch("serial:disconnected", e), a.$dispatchChange(this);
2795
2796
  }
2796
- #i(t) {
2797
- this.__internal__.serial.aux_connecting = t.detail.active ? "connecting" : "finished";
2797
+ #i(e) {
2798
+ this.__internal__.serial.aux_connecting = e.detail.active ? "connecting" : "finished";
2798
2799
  }
2799
- socketResponse(t) {
2800
- const e = this.__internal__.serial.connected;
2801
- if (t.type === "disconnect" || t.type === "error" && t.data === "DISCONNECTED" ? this.__internal__.serial.connected = !1 : t.type === "success" && (this.__internal__.serial.connected = !0), a.$dispatchChange(this), !e && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#r(!1)), t.type === "success")
2802
- this.#n(new Uint8Array(t.data));
2803
- else if (t.type === "error") {
2800
+ socketResponse(e) {
2801
+ const t = this.__internal__.serial.connected;
2802
+ if (e.type === "disconnect" || e.type === "error" && e.data === "DISCONNECTED" ? this.__internal__.serial.connected = !1 : e.type === "success" && (this.__internal__.serial.connected = !0), a.$dispatchChange(this), !t && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#r(!1)), e.type === "success")
2803
+ this.#n(new Uint8Array(e.data));
2804
+ else if (e.type === "error") {
2804
2805
  const n = new Error("The port is closed or is not readable/writable");
2805
2806
  this.serialErrors(n);
2806
- } else t.type === "timeout" && this.timeout(t.data.bytes ?? [], this.lastAction || "unknown");
2807
+ } else e.type === "timeout" && this.timeout(e.data.bytes ?? [], this.lastAction || "unknown");
2807
2808
  this.__internal__.serial.last_action = null;
2808
2809
  }
2809
2810
  async connect() {
2810
- return this.isConnected ? !0 : (this.__internal__.serial.aux_connecting = "idle", new Promise((t, e) => {
2811
- this.#e || (this.#e = this.#i.bind(this)), this.on("internal:connecting", this.#e);
2811
+ return this.isConnected ? !0 : (this.__internal__.serial.aux_connecting = "idle", new Promise((e, t) => {
2812
+ this.#t || (this.#t = this.#i.bind(this)), this.on("internal:connecting", this.#t);
2812
2813
  const n = setInterval(() => {
2813
- this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(n), this.__internal__.serial.aux_connecting = "idle", this.#e !== null && this.off("internal:connecting", this.#e), this.isConnected ? t(!0) : e(`${this.typeDevice} device ${this.deviceNumber} not connected`)) : this.__internal__.serial.aux_connecting === "connecting" && (this.__internal__.serial.aux_connecting = "idle", this.dispatch("internal:connecting", { active: !0 }), this.dispatch("serial:connecting", { active: !0 }));
2814
+ this.__internal__.serial.aux_connecting === "finished" ? (clearInterval(n), this.__internal__.serial.aux_connecting = "idle", this.#t !== null && this.off("internal:connecting", this.#t), this.isConnected ? e(!0) : t(`${this.typeDevice} device ${this.deviceNumber} not connected`)) : this.__internal__.serial.aux_connecting === "connecting" && (this.__internal__.serial.aux_connecting = "idle", this.dispatch("internal:connecting", { active: !0 }), this.dispatch("serial:connecting", { active: !0 }));
2814
2815
  }, 100);
2815
2816
  this.serialConnect();
2816
2817
  }));
@@ -2820,65 +2821,69 @@ class le extends et {
2820
2821
  if (this.useSocket)
2821
2822
  A.disconnectDevice(this.configDeviceSocket);
2822
2823
  else {
2823
- const t = this.__internal__.serial.reader, e = this.__internal__.serial.output_stream;
2824
- t && (await t.cancel().catch((n) => this.serialErrors(n)), await this.__internal__.serial.input_done), e && (await e.getWriter().close(), await this.__internal__.serial.output_done), this.__internal__.serial.connected && this.__internal__.serial && this.__internal__.serial.port && await this.__internal__.serial.port.close();
2824
+ const e = this.__internal__.serial.reader, t = this.__internal__.serial.output_stream;
2825
+ e && (await e.cancel().catch((n) => this.serialErrors(n)), await this.__internal__.serial.input_done), t && (await t.getWriter().close(), await this.__internal__.serial.output_done), this.__internal__.serial.connected && this.__internal__.serial && this.__internal__.serial.port && await this.__internal__.serial.port.close();
2825
2826
  }
2826
- } catch (t) {
2827
- this.serialErrors(t);
2827
+ } catch (e) {
2828
+ this.serialErrors(e);
2828
2829
  } finally {
2829
2830
  this.__internal__.serial.reader = null, this.__internal__.serial.input_done = null, this.__internal__.serial.output_stream = null, this.__internal__.serial.output_done = null, this.__internal__.serial.connected = !1, this.__internal__.serial.port = null, a.$dispatchChange(this);
2830
2831
  }
2831
2832
  }
2832
- async #o(t) {
2833
+ async #o(e) {
2833
2834
  if (this.isDisconnected)
2834
- throw this.#t({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
2835
- const e = this.validateBytes(t);
2836
- A.write({ config: this.configDeviceSocket, bytes: Array.from(e) });
2835
+ throw this.#e({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
2836
+ const t = this.validateBytes(e);
2837
+ A.write({ config: this.configDeviceSocket, bytes: Array.from(t) });
2837
2838
  }
2838
- async #a(t) {
2839
+ async #a(e) {
2839
2840
  if (this.useSocket) {
2840
- await this.#o(t);
2841
+ await this.#o(e);
2841
2842
  return;
2842
2843
  }
2843
- const e = this.__internal__.serial.port;
2844
- if (!e || e && (!e.readable || !e.writable))
2845
- throw this.#t({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
2846
- const n = this.validateBytes(t);
2847
- if (this.useRTSCTS && await this.#c(e, 5e3), e.writable === null) return;
2848
- const r = e.writable.getWriter();
2844
+ const t = this.__internal__.serial.port;
2845
+ if (!t || t && (!t.readable || !t.writable))
2846
+ throw this.#e({ error: "Port is closed, not readable or writable." }), new Error("The port is closed or is not readable/writable");
2847
+ const n = this.validateBytes(e);
2848
+ if (this.useRTSCTS && await this.#c(t, 5e3), t.writable === null) return;
2849
+ const r = t.writable.getWriter();
2849
2850
  await r.write(n), r.releaseLock();
2850
2851
  }
2851
- async #c(t, e = 5e3) {
2852
+ async #c(e, t = 5e3) {
2852
2853
  const n = Date.now();
2853
2854
  for (; ; ) {
2854
- if (Date.now() - n > e)
2855
+ if (Date.now() - n > t)
2855
2856
  throw new Error("Timeout waiting for clearToSend signal");
2856
- const { clearToSend: r } = await t.getSignals();
2857
+ const { clearToSend: r } = await e.getSignals();
2857
2858
  if (r) return;
2858
2859
  await J(100);
2859
2860
  }
2860
2861
  }
2861
- #n(t = new Uint8Array([]), e = !1) {
2862
- if (t && t.length > 0) {
2862
+ #n(e = new Uint8Array([]), t = !1) {
2863
+ if (e && e.length > 0) {
2863
2864
  const n = this.__internal__.serial.connected;
2864
2865
  if (this.__internal__.serial.connected = this.#s(this.__internal__.serial.port), a.$dispatchChange(this), !n && this.__internal__.serial.connected && (this.dispatch("serial:connected"), this.#r(!1)), this.__internal__.interval.reconnection && (clearInterval(this.__internal__.interval.reconnection), this.__internal__.interval.reconnection = 0), this.__internal__.timeout.until_response && (clearTimeout(this.__internal__.timeout.until_response), this.__internal__.timeout.until_response = 0), this.__internal__.serial.response.as === "hex")
2865
- e ? this.serialCorruptMessage(this.parseUint8ToHex(t)) : this.serialMessage(this.parseUint8ToHex(t));
2866
+ t ? this.serialCorruptMessage(this.parseUint8ToHex(e)) : this.serialMessage(this.parseUint8ToHex(e));
2866
2867
  else if (this.__internal__.serial.response.as === "uint8")
2867
- e ? this.serialCorruptMessage(t) : this.serialMessage(t);
2868
+ t ? this.serialCorruptMessage(e) : this.serialMessage(e);
2868
2869
  else if (this.__internal__.serial.response.as === "string") {
2869
- const r = this.parseUint8ArrayToString(t);
2870
+ const r = this.parseUint8ArrayToString(e);
2870
2871
  if (this.__internal__.serial.response.limiter !== null) {
2871
2872
  const i = r.split(this.__internal__.serial.response.limiter);
2872
2873
  for (const o in i)
2873
- i[o] && (e ? this.serialCorruptMessage(i[o]) : this.serialMessage(i[o]));
2874
+ i[o] && (t ? this.serialCorruptMessage(i[o]) : this.serialMessage(i[o]));
2874
2875
  } else
2875
- e ? this.serialCorruptMessage(r) : this.serialMessage(r);
2876
+ t ? this.serialCorruptMessage(r) : this.serialMessage(r);
2876
2877
  } else {
2877
- const r = this.stringToArrayBuffer(this.parseUint8ArrayToString(t));
2878
- e ? this.serialCorruptMessage(r) : this.serialMessage(r);
2878
+ const r = this.stringToArrayBuffer(this.parseUint8ArrayToString(e));
2879
+ t ? this.serialCorruptMessage(r) : this.serialMessage(r);
2879
2880
  }
2880
2881
  }
2881
- this.__internal__.serial.queue.length !== 0 && this.dispatch("internal:queue", {});
2882
+ if (this.__internal__.serial.queue.length === 0) {
2883
+ this.__internal__.serial.running_queue = !1;
2884
+ return;
2885
+ }
2886
+ this.dispatch("internal:queue", {});
2882
2887
  }
2883
2888
  getResponseAsArrayBuffer() {
2884
2889
  this.__internal__.serial.response.as = "arraybuffer";
@@ -2893,75 +2898,75 @@ class le extends et {
2893
2898
  this.__internal__.serial.response.as = "string";
2894
2899
  }
2895
2900
  async #l() {
2896
- const t = this.serialFilters, e = await navigator.serial.getPorts({ filters: t });
2897
- return t.length === 0 ? e : e.filter((n) => {
2901
+ const e = this.serialFilters, t = await navigator.serial.getPorts({ filters: e });
2902
+ return e.length === 0 ? t : t.filter((n) => {
2898
2903
  const r = n.getInfo();
2899
- return t.some((i) => r.usbProductId === i.usbProductId && r.usbVendorId === i.usbVendorId);
2904
+ return e.some((i) => r.usbProductId === i.usbProductId && r.usbVendorId === i.usbVendorId);
2900
2905
  }).filter((n) => !this.#s(n));
2901
2906
  }
2902
- async serialPortsSaved(t) {
2903
- const e = this.serialFilters;
2904
- if (this.__internal__.aux_port_connector < t.length) {
2907
+ async serialPortsSaved(e) {
2908
+ const t = this.serialFilters;
2909
+ if (this.__internal__.aux_port_connector < e.length) {
2905
2910
  const n = this.__internal__.aux_port_connector;
2906
- this.__internal__.serial.port = t[n];
2911
+ this.__internal__.serial.port = e[n];
2907
2912
  } else
2908
2913
  this.__internal__.aux_port_connector = 0, this.__internal__.serial.port = await navigator.serial.requestPort({
2909
- filters: e
2914
+ filters: t
2910
2915
  });
2911
2916
  if (!this.__internal__.serial.port)
2912
2917
  throw new Error("Select another port please");
2913
2918
  }
2914
- serialErrors(t) {
2915
- const e = t.toString().toLowerCase();
2919
+ serialErrors(e) {
2920
+ const t = e.toString().toLowerCase();
2916
2921
  switch (!0) {
2917
- case e.includes("must be handling a user gesture to show a permission request"):
2918
- case e.includes("the port is closed."):
2919
- case e.includes("the port is closed or is not writable"):
2920
- case e.includes("the port is closed or is not readable"):
2921
- case e.includes("the port is closed or is not readable/writable"):
2922
- case e.includes("select another port please"):
2923
- case e.includes("no port selected by the user"):
2924
- case e.includes(
2922
+ case t.includes("must be handling a user gesture to show a permission request"):
2923
+ case t.includes("the port is closed."):
2924
+ case t.includes("the port is closed or is not writable"):
2925
+ case t.includes("the port is closed or is not readable"):
2926
+ case t.includes("the port is closed or is not readable/writable"):
2927
+ case t.includes("select another port please"):
2928
+ case t.includes("no port selected by the user"):
2929
+ case t.includes(
2925
2930
  "this readable stream reader has been released and cannot be used to cancel its previous owner stream"
2926
2931
  ):
2927
2932
  this.dispatch("serial:need-permission", {}), a.$dispatchChange(this);
2928
2933
  break;
2929
- case e.includes("the port is already open."):
2930
- case e.includes("failed to open serial port"):
2934
+ case t.includes("the port is already open."):
2935
+ case t.includes("failed to open serial port"):
2931
2936
  this.serialDisconnect().then(async () => {
2932
2937
  this.__internal__.aux_port_connector += 1, await this.serialConnect();
2933
2938
  });
2934
2939
  break;
2935
- case e.includes("cannot read properties of undefined (reading 'writable')"):
2936
- case e.includes("cannot read properties of null (reading 'writable')"):
2937
- case e.includes("cannot read property 'writable' of null"):
2938
- case e.includes("cannot read property 'writable' of undefined"):
2940
+ case t.includes("cannot read properties of undefined (reading 'writable')"):
2941
+ case t.includes("cannot read properties of null (reading 'writable')"):
2942
+ case t.includes("cannot read property 'writable' of null"):
2943
+ case t.includes("cannot read property 'writable' of undefined"):
2939
2944
  this.serialDisconnect().then(async () => {
2940
2945
  await this.serialConnect();
2941
2946
  });
2942
2947
  break;
2943
- case e.includes("'close' on 'serialport': a call to close() is already in progress."):
2948
+ case t.includes("'close' on 'serialport': a call to close() is already in progress."):
2944
2949
  break;
2945
- case e.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):
2950
+ case t.includes("failed to execute 'open' on 'serialport': a call to open() is already in progress."):
2946
2951
  break;
2947
- case e.includes("the port is already closed."):
2952
+ case t.includes("the port is already closed."):
2948
2953
  break;
2949
- case e.includes("the device has been lost"):
2954
+ case t.includes("the device has been lost"):
2950
2955
  this.dispatch("serial:lost", {}), a.$dispatchChange(this);
2951
2956
  break;
2952
- case e.includes("navigator.serial is undefined"):
2957
+ case t.includes("navigator.serial is undefined"):
2953
2958
  this.dispatch("serial:unsupported", {});
2954
2959
  break;
2955
2960
  default:
2956
- console.error(t);
2961
+ console.error(e);
2957
2962
  break;
2958
2963
  }
2959
- this.dispatch("serial:error", t);
2964
+ this.dispatch("serial:error", e);
2960
2965
  }
2961
- #h(t) {
2962
- if (t) {
2963
- const e = this.__internal__.serial.response.buffer, n = new Uint8Array(e.length + t.byteLength);
2964
- n.set(e, 0), n.set(new Uint8Array(t), e.length), this.__internal__.serial.response.buffer = n;
2966
+ #h(e) {
2967
+ if (e) {
2968
+ const t = this.__internal__.serial.response.buffer, n = new Uint8Array(t.length + e.byteLength);
2969
+ n.set(t, 0), n.set(new Uint8Array(e), t.length), this.__internal__.serial.response.buffer = n;
2965
2970
  }
2966
2971
  }
2967
2972
  async #u() {
@@ -2970,58 +2975,58 @@ class le extends et {
2970
2975
  }, this.__internal__.serial.free_timeout_ms || 50);
2971
2976
  }
2972
2977
  async #_() {
2973
- const t = this.__internal__.serial.response.length;
2974
- let e = this.__internal__.serial.response.buffer;
2975
- if (this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0), !(t === null || !e || e.length === 0)) {
2976
- for (; e.length >= t; ) {
2977
- const n = e.slice(0, t);
2978
- this.#n(n), e = e.slice(t);
2978
+ const e = this.__internal__.serial.response.length;
2979
+ let t = this.__internal__.serial.response.buffer;
2980
+ if (this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0), !(e === null || !t || t.length === 0)) {
2981
+ for (; t.length >= e; ) {
2982
+ const n = t.slice(0, e);
2983
+ this.#n(n), t = t.slice(e);
2979
2984
  }
2980
- this.__internal__.serial.response.buffer = e, e.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
2985
+ this.__internal__.serial.response.buffer = t, t.length > 0 && (this.__internal__.serial.time_until_send_bytes = setTimeout(() => {
2981
2986
  this.#n(this.__internal__.serial.response.buffer, !0);
2982
2987
  }, this.__internal__.serial.free_timeout_ms || 50));
2983
2988
  }
2984
2989
  }
2985
2990
  async #p() {
2986
2991
  const {
2987
- limiter: t,
2988
- prefixLimiter: e = !1,
2992
+ limiter: e,
2993
+ prefixLimiter: t = !1,
2989
2994
  sufixLimiter: n = !0
2990
2995
  } = this.__internal__.serial.response;
2991
- if (!t)
2996
+ if (!e)
2992
2997
  throw new Error("No limiter defined for delimited serial response");
2993
2998
  const r = this.__internal__.serial.response.buffer;
2994
- if (!t || !r || r.length === 0) return;
2999
+ if (!e || !r || r.length === 0) return;
2995
3000
  this.__internal__.serial.time_until_send_bytes && (clearTimeout(this.__internal__.serial.time_until_send_bytes), this.__internal__.serial.time_until_send_bytes = 0);
2996
3001
  let i = new TextDecoder().decode(r);
2997
3002
  const o = [];
2998
- if (typeof t == "string") {
3003
+ if (typeof e == "string") {
2999
3004
  let c;
3000
- if (e && n)
3001
- c = new RegExp(`${t}([^${t}]+)${t}`, "g");
3002
- else if (e)
3003
- c = new RegExp(`${t}([^${t}]*)`, "g");
3005
+ if (t && n)
3006
+ c = new RegExp(`${e}([^${e}]+)${e}`, "g");
3007
+ else if (t)
3008
+ c = new RegExp(`${e}([^${e}]*)`, "g");
3004
3009
  else if (n)
3005
- c = new RegExp(`([^${t}]+)${t}`, "g");
3010
+ c = new RegExp(`([^${e}]+)${e}`, "g");
3006
3011
  else
3007
3012
  return;
3008
3013
  let p, u = 0;
3009
3014
  for (; (p = c.exec(i)) !== null; )
3010
3015
  o.push(new TextEncoder().encode(p[1])), u = c.lastIndex;
3011
3016
  i = i.slice(u);
3012
- } else if (t instanceof RegExp) {
3017
+ } else if (e instanceof RegExp) {
3013
3018
  let c, p = 0;
3014
- if (e && n) {
3015
- const u = new RegExp(`${t.source}(.*?)${t.source}`, "g");
3019
+ if (t && n) {
3020
+ const u = new RegExp(`${e.source}(.*?)${e.source}`, "g");
3016
3021
  for (; (c = u.exec(i)) !== null; )
3017
3022
  o.push(new TextEncoder().encode(c[1])), p = u.lastIndex;
3018
3023
  } else if (n)
3019
- for (; (c = t.exec(i)) !== null; ) {
3024
+ for (; (c = e.exec(i)) !== null; ) {
3020
3025
  const u = c.index, y = i.slice(p, u);
3021
- o.push(new TextEncoder().encode(y)), p = t.lastIndex;
3026
+ o.push(new TextEncoder().encode(y)), p = e.lastIndex;
3022
3027
  }
3023
- else if (e) {
3024
- const u = i.split(t);
3028
+ else if (t) {
3029
+ const u = i.split(e);
3025
3030
  u.shift();
3026
3031
  for (const y of u)
3027
3032
  o.push(new TextEncoder().encode(y));
@@ -3037,24 +3042,24 @@ class le extends et {
3037
3042
  }, this.__internal__.serial.free_timeout_ms ?? 50));
3038
3043
  }
3039
3044
  async #d() {
3040
- const t = this.__internal__.serial.port;
3041
- if (!t || !t.readable) throw new Error("Port is not readable");
3042
- const e = t.readable.getReader();
3043
- this.__internal__.serial.reader = e;
3045
+ const e = this.__internal__.serial.port;
3046
+ if (!e || !e.readable) throw new Error("Port is not readable");
3047
+ const t = e.readable.getReader();
3048
+ this.__internal__.serial.reader = t;
3044
3049
  try {
3045
3050
  for (; this.__internal__.serial.keep_reading; ) {
3046
- const { value: n, done: r } = await e.read();
3051
+ const { value: n, done: r } = await t.read();
3047
3052
  if (r) break;
3048
3053
  this.#h(n), this.__internal__.serial.response.delimited ? await this.#p() : this.__internal__.serial.response.length === null ? await this.#u() : await this.#_();
3049
3054
  }
3050
3055
  } catch (n) {
3051
3056
  this.serialErrors(n);
3052
3057
  } finally {
3053
- e.releaseLock(), this.__internal__.serial.keep_reading = !0, this.__internal__.serial.port && await this.__internal__.serial.port.close();
3058
+ t.releaseLock(), this.__internal__.serial.keep_reading = !0, this.__internal__.serial.port && await this.__internal__.serial.port.close();
3054
3059
  }
3055
3060
  }
3056
- #r(t) {
3057
- t !== this.__internal__.serial.connecting && (this.__internal__.serial.connecting = t, this.dispatch("serial:connecting", { active: t }), this.dispatch("internal:connecting", { active: t }));
3061
+ #r(e) {
3062
+ e !== this.__internal__.serial.connecting && (this.__internal__.serial.connecting = e, this.dispatch("serial:connecting", { active: e }), this.dispatch("internal:connecting", { active: e }));
3058
3063
  }
3059
3064
  async serialConnect() {
3060
3065
  try {
@@ -3066,23 +3071,23 @@ class le extends et {
3066
3071
  bytes: this.__internal__.serial.bytes_connection
3067
3072
  });
3068
3073
  else {
3069
- const t = await this.#l();
3070
- if (t.length > 0)
3071
- await this.serialPortsSaved(t);
3074
+ const e = await this.#l();
3075
+ if (e.length > 0)
3076
+ await this.serialPortsSaved(e);
3072
3077
  else {
3073
3078
  const r = this.serialFilters;
3074
3079
  this.__internal__.serial.port = await navigator.serial.requestPort({
3075
3080
  filters: r
3076
3081
  });
3077
3082
  }
3078
- const e = this.__internal__.serial.port;
3079
- if (!e)
3083
+ const t = this.__internal__.serial.port;
3084
+ if (!t)
3080
3085
  throw new Error("No port selected by the user");
3081
- await e.open(this.serialConfigPort);
3086
+ await t.open(this.serialConfigPort);
3082
3087
  const n = this;
3083
- e.onconnect = (r) => {
3084
- n.dispatch("serial:connected", r), n.#r(!1), a.$dispatchChange(this), n.__internal__.serial.queue.length > 0 && n.dispatch("internal:queue", {});
3085
- }, e.ondisconnect = async () => {
3088
+ t.onconnect = (r) => {
3089
+ n.dispatch("serial:connected", r), n.#r(!1), a.$dispatchChange(this), n.__internal__.serial.queue.length > 0 ? n.dispatch("internal:queue", {}) : n.__internal__.serial.running_queue = !1;
3090
+ }, t.ondisconnect = async () => {
3086
3091
  await n.disconnect();
3087
3092
  }, await J(this.__internal__.serial.delay_first_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
3088
3093
  await n.timeout(n.__internal__.serial.bytes_connection ?? [], "connection:start");
@@ -3091,8 +3096,8 @@ class le extends et {
3091
3096
  bytes: this.__internal__.serial.bytes_connection
3092
3097
  }), this.__internal__.auto_response && this.#n(this.__internal__.serial.auto_response), await this.#d();
3093
3098
  }
3094
- } catch (t) {
3095
- this.#r(!1), this.serialErrors(t);
3099
+ } catch (e) {
3100
+ this.#r(!1), this.serialErrors(e);
3096
3101
  }
3097
3102
  }
3098
3103
  async #f() {
@@ -3101,23 +3106,23 @@ class le extends et {
3101
3106
  async serialForget() {
3102
3107
  return await this.#f();
3103
3108
  }
3104
- decToHex(t) {
3105
- return typeof t == "string" && (t = parseInt(t, 10)), t.toString(16);
3109
+ decToHex(e) {
3110
+ return typeof e == "string" && (e = parseInt(e, 10)), e.toString(16);
3106
3111
  }
3107
- hexToDec(t) {
3108
- return parseInt(t, 16);
3112
+ hexToDec(e) {
3113
+ return parseInt(e, 16);
3109
3114
  }
3110
- hexMaker(t = "00", e = 2) {
3111
- return t.toString().padStart(e, "0").toLowerCase();
3115
+ hexMaker(e = "00", t = 2) {
3116
+ return e.toString().padStart(t, "0").toLowerCase();
3112
3117
  }
3113
- add0x(t) {
3114
- const e = [];
3115
- return t.forEach((n, r) => {
3116
- e[r] = "0x" + n;
3117
- }), e;
3118
+ add0x(e) {
3119
+ const t = [];
3120
+ return e.forEach((n, r) => {
3121
+ t[r] = "0x" + n;
3122
+ }), t;
3118
3123
  }
3119
- bytesToHex(t) {
3120
- return this.add0x(Array.from(t, (e) => this.hexMaker(e)));
3124
+ bytesToHex(e) {
3125
+ return this.add0x(Array.from(e, (t) => this.hexMaker(t)));
3121
3126
  }
3122
3127
  #y() {
3123
3128
  [
@@ -3136,36 +3141,41 @@ class le extends et {
3136
3141
  "serial:unsupported",
3137
3142
  "serial:error",
3138
3143
  "debug"
3139
- ].forEach((t) => {
3140
- this.serialRegisterAvailableListener(t);
3144
+ ].forEach((e) => {
3145
+ this.serialRegisterAvailableListener(e);
3141
3146
  });
3142
3147
  }
3143
3148
  #g() {
3144
- const t = this;
3149
+ const e = this;
3145
3150
  this.on("internal:queue", async () => {
3146
- await t.#b();
3151
+ await e.#b();
3147
3152
  }), this.#m();
3148
3153
  }
3149
3154
  #m() {
3150
- const t = this;
3155
+ const e = this;
3151
3156
  navigator.serial.addEventListener("connect", async () => {
3152
- t.isDisconnected && await t.serialConnect().catch(() => {
3157
+ e.isDisconnected && await e.serialConnect().catch(() => {
3153
3158
  });
3154
3159
  });
3155
3160
  }
3156
3161
  async #b() {
3157
3162
  if (!this.#s(this.__internal__.serial.port)) {
3158
- this.#t({ error: "Port is closed, not readable or writable." }), await this.serialConnect();
3163
+ this.#e({ error: "Port is closed, not readable or writable." }), await this.serialConnect();
3164
+ return;
3165
+ }
3166
+ if (this.__internal__.timeout.until_response) return;
3167
+ if (this.__internal__.serial.queue.length === 0) {
3168
+ this.__internal__.serial.running_queue = !1;
3159
3169
  return;
3160
3170
  }
3161
- if (this.__internal__.timeout.until_response || this.__internal__.serial.queue.length === 0) return;
3162
- const t = this.__internal__.serial.queue[0];
3163
- let e = this.__internal__.time.response_general;
3164
- if (t.action === "connect" && (e = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
3165
- await this.timeout(t.bytes, t.action);
3166
- }, e), this.__internal__.serial.last_action = t.action ?? "unknown", await this.#a(t.bytes), this.dispatch("serial:sent", {
3167
- action: t.action,
3168
- bytes: t.bytes
3171
+ this.__internal__.serial.running_queue = !0;
3172
+ const e = this.__internal__.serial.queue[0];
3173
+ let t = this.__internal__.time.response_general;
3174
+ if (e.action === "connect" && (t = this.__internal__.time.response_connection), this.__internal__.timeout.until_response = setTimeout(async () => {
3175
+ await this.timeout(e.bytes, e.action);
3176
+ }, t), this.__internal__.serial.last_action = e.action ?? "unknown", await this.#a(e.bytes), this.dispatch("serial:sent", {
3177
+ action: e.action,
3178
+ bytes: e.bytes
3169
3179
  }), this.__internal__.auto_response) {
3170
3180
  let r = new Uint8Array(0);
3171
3181
  try {
@@ -3176,43 +3186,43 @@ class le extends et {
3176
3186
  this.#n(r);
3177
3187
  }
3178
3188
  const n = [...this.__internal__.serial.queue];
3179
- this.__internal__.serial.queue = n.splice(1);
3180
- }
3181
- validateBytes(t) {
3182
- let e = new Uint8Array(0);
3183
- if (t instanceof Uint8Array)
3184
- e = t;
3185
- else if (typeof t == "string")
3186
- e = this.parseStringToTextEncoder(t);
3187
- else if (Array.isArray(t) && typeof t[0] == "string")
3188
- e = this.stringArrayToUint8Array(t);
3189
- else if (Array.isArray(t) && typeof t[0] == "number")
3190
- e = new Uint8Array(t);
3189
+ this.__internal__.serial.queue = n.splice(1), this.__internal__.serial.queue.length > 0 && (this.__internal__.serial.running_queue = !0);
3190
+ }
3191
+ validateBytes(e) {
3192
+ let t = new Uint8Array(0);
3193
+ if (e instanceof Uint8Array)
3194
+ t = e;
3195
+ else if (typeof e == "string")
3196
+ t = this.parseStringToTextEncoder(e);
3197
+ else if (Array.isArray(e) && typeof e[0] == "string")
3198
+ t = this.stringArrayToUint8Array(e);
3199
+ else if (Array.isArray(e) && typeof e[0] == "number")
3200
+ t = new Uint8Array(e);
3191
3201
  else
3192
3202
  throw new Error("Invalid data type");
3193
- return e;
3203
+ return t;
3194
3204
  }
3195
- async appendToQueue(t, e) {
3196
- const n = this.validateBytes(t);
3197
- if (["connect", "connection:start"].includes(e)) {
3205
+ async appendToQueue(e, t) {
3206
+ const n = this.validateBytes(e);
3207
+ if (["connect", "connection:start"].includes(t)) {
3198
3208
  if (this.__internal__.serial.connected) return;
3199
3209
  await this.serialConnect();
3200
3210
  return;
3201
3211
  }
3202
- this.__internal__.serial.queue.push({ bytes: n, action: e }), this.dispatch("internal:queue", {});
3212
+ this.__internal__.serial.queue.push({ bytes: n, action: t }), this.dispatch("internal:queue", {});
3203
3213
  }
3204
- #w(t = 1) {
3205
- this.__internal__.device_number = t, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(t));
3214
+ #w(e = 1) {
3215
+ this.__internal__.device_number = e, !this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e));
3206
3216
  }
3207
- serialSetConnectionConstant(t = 1) {
3217
+ serialSetConnectionConstant(e = 1) {
3208
3218
  if (this.__internal__.bypassSerialBytesConnection) return this.__internal__.serial.bytes_connection;
3209
- throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${t}`);
3219
+ throw new Error(`Method not implemented 'serialSetConnectionConstant' to listen on channel ${e}`);
3210
3220
  }
3211
- serialMessage(t) {
3212
- throw console.log(t), this.dispatch("serial:message", { code: t }), new Error("Method not implemented 'serialMessage'");
3221
+ serialMessage(e) {
3222
+ throw console.log(e), this.dispatch("serial:message", { code: e }), new Error("Method not implemented 'serialMessage'");
3213
3223
  }
3214
- serialCorruptMessage(t) {
3215
- throw console.log(t), this.dispatch("serial:corrupt-message", { code: t }), new Error("Method not implemented 'serialCorruptMessage'");
3224
+ serialCorruptMessage(e) {
3225
+ throw console.log(e), this.dispatch("serial:corrupt-message", { code: e }), new Error("Method not implemented 'serialCorruptMessage'");
3216
3226
  }
3217
3227
  #v() {
3218
3228
  this.__internal__.last_error = {
@@ -3225,11 +3235,11 @@ class le extends et {
3225
3235
  clearSerialQueue() {
3226
3236
  this.__internal__.serial.queue = [];
3227
3237
  }
3228
- sumHex(t) {
3229
- let e = 0;
3230
- return t.forEach((n) => {
3231
- e += parseInt(n, 16);
3232
- }), e.toString(16);
3238
+ sumHex(e) {
3239
+ let t = 0;
3240
+ return e.forEach((n) => {
3241
+ t += parseInt(n, 16);
3242
+ }), t.toString(16);
3233
3243
  }
3234
3244
  toString() {
3235
3245
  return JSON.stringify({
@@ -3248,61 +3258,61 @@ class le extends et {
3248
3258
  throw new Error("No connection bytes defined");
3249
3259
  await this.appendToQueue(this.__internal__.serial.bytes_connection, "connect");
3250
3260
  }
3251
- async sendCustomCode({ code: t = [] } = { code: [] }) {
3252
- if (!t)
3261
+ async sendCustomCode({ code: e = [] } = { code: [] }) {
3262
+ if (!e)
3253
3263
  throw new Error("No data to send");
3254
- this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.validateBytes(t)), await this.appendToQueue(t, "custom");
3264
+ this.__internal__.bypassSerialBytesConnection && (this.__internal__.serial.bytes_connection = this.validateBytes(e)), await this.appendToQueue(e, "custom");
3255
3265
  }
3256
- stringToArrayHex(t) {
3257
- return Array.from(t).map((e) => e.charCodeAt(0).toString(16));
3266
+ stringToArrayHex(e) {
3267
+ return Array.from(e).map((t) => t.charCodeAt(0).toString(16));
3258
3268
  }
3259
- stringToArrayBuffer(t, e = `
3269
+ stringToArrayBuffer(e, t = `
3260
3270
  `) {
3261
- return this.parseStringToTextEncoder(t, e).buffer;
3271
+ return this.parseStringToTextEncoder(e, t).buffer;
3262
3272
  }
3263
- parseStringToTextEncoder(t = "", e = `
3273
+ parseStringToTextEncoder(e = "", t = `
3264
3274
  `) {
3265
3275
  const n = new TextEncoder();
3266
- return t += e, n.encode(t);
3276
+ return e += t, n.encode(e);
3267
3277
  }
3268
- parseStringToBytes(t = "", e = `
3278
+ parseStringToBytes(e = "", t = `
3269
3279
  `) {
3270
- const n = this.parseStringToTextEncoder(t, e);
3280
+ const n = this.parseStringToTextEncoder(e, t);
3271
3281
  return Array.from(n).map((r) => r.toString(16));
3272
3282
  }
3273
- parseUint8ToHex(t) {
3274
- return Array.from(t).map((e) => e.toString(16).padStart(2, "0").toLowerCase());
3283
+ parseUint8ToHex(e) {
3284
+ return Array.from(e).map((t) => t.toString(16).padStart(2, "0").toLowerCase());
3275
3285
  }
3276
- parseHexToUint8(t) {
3277
- return new Uint8Array(t.map((e) => parseInt(e, 16)));
3286
+ parseHexToUint8(e) {
3287
+ return new Uint8Array(e.map((t) => parseInt(t, 16)));
3278
3288
  }
3279
- stringArrayToUint8Array(t) {
3280
- const e = [];
3281
- return typeof t == "string" ? this.parseStringToTextEncoder(t).buffer : (t.forEach((n) => {
3289
+ stringArrayToUint8Array(e) {
3290
+ const t = [];
3291
+ return typeof e == "string" ? this.parseStringToTextEncoder(e).buffer : (e.forEach((n) => {
3282
3292
  const r = n.replace("0x", "");
3283
- e.push(parseInt(r, 16));
3284
- }), new Uint8Array(e));
3293
+ t.push(parseInt(r, 16));
3294
+ }), new Uint8Array(t));
3285
3295
  }
3286
- parseUint8ArrayToString(t) {
3287
- let e = new Uint8Array(0);
3288
- t instanceof Uint8Array ? e = t : e = this.stringArrayToUint8Array(t), t = this.parseUint8ToHex(e);
3289
- const n = t.map((r) => parseInt(r, 16));
3296
+ parseUint8ArrayToString(e) {
3297
+ let t = new Uint8Array(0);
3298
+ e instanceof Uint8Array ? t = e : t = this.stringArrayToUint8Array(e), e = this.parseUint8ToHex(t);
3299
+ const n = e.map((r) => parseInt(r, 16));
3290
3300
  return this.__internal__.serial.response.replacer ? String.fromCharCode(...n).replace(this.__internal__.serial.response.replacer, "") : String.fromCharCode(...n);
3291
3301
  }
3292
- hexToAscii(t) {
3293
- const e = t.toString();
3302
+ hexToAscii(e) {
3303
+ const t = e.toString();
3294
3304
  let n = "";
3295
- for (let r = 0; r < e.length; r += 2)
3296
- n += String.fromCharCode(parseInt(e.substring(r, 2), 16));
3305
+ for (let r = 0; r < t.length; r += 2)
3306
+ n += String.fromCharCode(parseInt(t.substring(r, 2), 16));
3297
3307
  return n;
3298
3308
  }
3299
- asciiToHex(t) {
3300
- const e = [];
3301
- for (let n = 0, r = t.length; n < r; n++) {
3302
- const i = Number(t.charCodeAt(n)).toString(16);
3303
- e.push(i);
3309
+ asciiToHex(e) {
3310
+ const t = [];
3311
+ for (let n = 0, r = e.length; n < r; n++) {
3312
+ const i = Number(e.charCodeAt(n)).toString(16);
3313
+ t.push(i);
3304
3314
  }
3305
- return e.join("");
3315
+ return t.join("");
3306
3316
  }
3307
3317
  $checkAndDispatchConnection() {
3308
3318
  return this.isConnected;
@@ -3311,5 +3321,5 @@ class le extends et {
3311
3321
  export {
3312
3322
  A,
3313
3323
  a,
3314
- le as u
3324
+ lt as u
3315
3325
  };