@aixa-transformation/pptx-viewer 2.0.2

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 (59) hide show
  1. package/CHANGELOG.md +369 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +18 -0
  4. package/README.md +249 -0
  5. package/dist/GLTFLoader-CV33YWNT.js +2613 -0
  6. package/dist/GLTFLoader-FQJ2I67K.mjs +2611 -0
  7. package/dist/Model3DScene-5ODZLKJM.mjs +49 -0
  8. package/dist/Model3DScene-VLHFNN5B.js +51 -0
  9. package/dist/OrbitControls-HI6CI76Z.mjs +3 -0
  10. package/dist/OrbitControls-XGY7XEC6.js +12 -0
  11. package/dist/SmartArt3DScene-3FL5JELA.mjs +333 -0
  12. package/dist/SmartArt3DScene-7IZ3IJYV.js +335 -0
  13. package/dist/SurfaceChart3DScene-C6GQQQB7.mjs +77 -0
  14. package/dist/SurfaceChart3DScene-KHMGQAGP.js +79 -0
  15. package/dist/chunk-2TOLRBFU.js +27629 -0
  16. package/dist/chunk-2X72MOPZ.mjs +2796 -0
  17. package/dist/chunk-6DZX6EAA.mjs +33 -0
  18. package/dist/chunk-AD2CLKY6.js +92338 -0
  19. package/dist/chunk-CUUYYYC5.js +2800 -0
  20. package/dist/chunk-DAKELFNP.js +915 -0
  21. package/dist/chunk-F2HFXS2Z.mjs +19063 -0
  22. package/dist/chunk-F3LO2NKI.mjs +913 -0
  23. package/dist/chunk-HNI6JYAI.js +34591 -0
  24. package/dist/chunk-IKBO6CZC.js +2 -0
  25. package/dist/chunk-KVM4DBEU.mjs +91768 -0
  26. package/dist/chunk-MOEXMRVK.js +19220 -0
  27. package/dist/chunk-QGM4M3NI.js +37 -0
  28. package/dist/chunk-SQY54X47.js +43506 -0
  29. package/dist/chunk-T5U6P2JH.mjs +1 -0
  30. package/dist/chunk-TB5ZWNMX.mjs +34577 -0
  31. package/dist/chunk-W5V6CEFL.mjs +43064 -0
  32. package/dist/chunk-XAVVR6OX.mjs +27204 -0
  33. package/dist/chunk-Y6FQDUJU.js +1160 -0
  34. package/dist/chunk-YI3G35EC.mjs +1076 -0
  35. package/dist/dist-LQJHTLHL.mjs +2 -0
  36. package/dist/dist-NVA3FEUV.js +2275 -0
  37. package/dist/i18n.d.ts +2 -0
  38. package/dist/i18n.js +19 -0
  39. package/dist/i18n.mjs +2 -0
  40. package/dist/index.d.ts +44 -0
  41. package/dist/index.js +135 -0
  42. package/dist/index.mjs +6 -0
  43. package/dist/internals.d.ts +1 -0
  44. package/dist/internals.js +311 -0
  45. package/dist/internals.mjs +6 -0
  46. package/dist/pptx-viewer.css +2 -0
  47. package/dist/presentation.d.ts +1 -0
  48. package/dist/presentation.js +11 -0
  49. package/dist/presentation.mjs +2 -0
  50. package/dist/three.module-HOXVV2KF.mjs +2 -0
  51. package/dist/three.module-QSJWIYNI.js +1771 -0
  52. package/dist/viewer/index.d.ts +1 -0
  53. package/dist/viewer/index.js +76 -0
  54. package/dist/viewer/index.mjs +7 -0
  55. package/dist/y-webrtc-DFUKFWCA.mjs +4279 -0
  56. package/dist/y-webrtc-RRACJ6WX.js +4284 -0
  57. package/dist/y-websocket-T5R5YGVE.mjs +378 -0
  58. package/dist/y-websocket-WMSHYIGX.js +384 -0
  59. package/package.json +141 -0
@@ -0,0 +1,4279 @@
1
+ import { getUnixTime, create2, floor, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER, unexpectedCase, some, isArray, every, every2, create3, fromCharCode, hasProperty, getVariable, nop, equalityDeep, EqualityTraitSymbol, methodUnimplemented, equals, isObject, production, repeat, createEncoder, writeVarUint, writeSyncStep1, writeVarUint8Array, encodeAwarenessUpdate, toUint8Array, writeUpdate, removeAwarenessStates, subscribe, writeSyncStep2, writeUint8, writeVarString, unsubscribe, toBase64, fromBase64, ObservableV2, Awareness, setIfUndefined, createDecoder, readVarString, readVarUint8Array, readVarUint, readUint8, applyAwarenessUpdate, readSyncMessage, messageYjsSyncStep2, publish, writeAny, Observable, readAny, encodeUtf8, supportsColor, create, min, log10, map, messageYjsSyncStep1 } from './chunk-YI3G35EC.mjs';
2
+ import { __commonJS, __toESM, __require } from './chunk-6DZX6EAA.mjs';
3
+ import 'yjs';
4
+
5
+ // ../../node_modules/simple-peer/simplepeer.min.js
6
+ var require_simplepeer_min = __commonJS({
7
+ "../../node_modules/simple-peer/simplepeer.min.js"(exports, module) {
8
+ (function(e) {
9
+ if ("object" == typeof exports && "undefined" != typeof module) module.exports = e();
10
+ else if ("function" == typeof define && define.amd) define([], e);
11
+ else {
12
+ var t;
13
+ t = "undefined" == typeof window ? "undefined" == typeof global ? "undefined" == typeof self ? this : self : global : window, t.SimplePeer = e();
14
+ }
15
+ })(function() {
16
+ var t = Math.floor, n = Math.abs, r = Math.pow;
17
+ return (/* @__PURE__ */ (function() {
18
+ function d(s, e, n2) {
19
+ function t2(o, i) {
20
+ if (!e[o]) {
21
+ if (!s[o]) {
22
+ var l = "function" == typeof __require && __require;
23
+ if (!i && l) return l(o, true);
24
+ if (r2) return r2(o, true);
25
+ var c = new Error("Cannot find module '" + o + "'");
26
+ throw c.code = "MODULE_NOT_FOUND", c;
27
+ }
28
+ var a2 = e[o] = { exports: {} };
29
+ s[o][0].call(a2.exports, function(e2) {
30
+ var r3 = s[o][1][e2];
31
+ return t2(r3 || e2);
32
+ }, a2, a2.exports, d, s, e, n2);
33
+ }
34
+ return e[o].exports;
35
+ }
36
+ for (var r2 = "function" == typeof __require && __require, a = 0; a < n2.length; a++) t2(n2[a]);
37
+ return t2;
38
+ }
39
+ return d;
40
+ })())({ 1: [function(e, t2, n2) {
41
+ function r2(e2) {
42
+ var t3 = e2.length;
43
+ if (0 < t3 % 4) throw new Error("Invalid string. Length must be a multiple of 4");
44
+ var n3 = e2.indexOf("=");
45
+ -1 === n3 && (n3 = t3);
46
+ var r3 = n3 === t3 ? 0 : 4 - n3 % 4;
47
+ return [n3, r3];
48
+ }
49
+ function a(e2, t3, n3) {
50
+ return 3 * (t3 + n3) / 4 - n3;
51
+ }
52
+ function o(e2) {
53
+ var t3, n3, o2 = r2(e2), d2 = o2[0], s2 = o2[1], l2 = new p(a(e2, d2, s2)), c2 = 0, f2 = 0 < s2 ? d2 - 4 : d2;
54
+ for (n3 = 0; n3 < f2; n3 += 4) t3 = u[e2.charCodeAt(n3)] << 18 | u[e2.charCodeAt(n3 + 1)] << 12 | u[e2.charCodeAt(n3 + 2)] << 6 | u[e2.charCodeAt(n3 + 3)], l2[c2++] = 255 & t3 >> 16, l2[c2++] = 255 & t3 >> 8, l2[c2++] = 255 & t3;
55
+ return 2 === s2 && (t3 = u[e2.charCodeAt(n3)] << 2 | u[e2.charCodeAt(n3 + 1)] >> 4, l2[c2++] = 255 & t3), 1 === s2 && (t3 = u[e2.charCodeAt(n3)] << 10 | u[e2.charCodeAt(n3 + 1)] << 4 | u[e2.charCodeAt(n3 + 2)] >> 2, l2[c2++] = 255 & t3 >> 8, l2[c2++] = 255 & t3), l2;
56
+ }
57
+ function d(e2) {
58
+ return c[63 & e2 >> 18] + c[63 & e2 >> 12] + c[63 & e2 >> 6] + c[63 & e2];
59
+ }
60
+ function s(e2, t3, n3) {
61
+ for (var r3, a2 = [], o2 = t3; o2 < n3; o2 += 3) r3 = (16711680 & e2[o2] << 16) + (65280 & e2[o2 + 1] << 8) + (255 & e2[o2 + 2]), a2.push(d(r3));
62
+ return a2.join("");
63
+ }
64
+ function l(e2) {
65
+ for (var t3, n3 = e2.length, r3 = n3 % 3, a2 = [], o2 = 16383, d2 = 0, l2 = n3 - r3; d2 < l2; d2 += o2) a2.push(s(e2, d2, d2 + o2 > l2 ? l2 : d2 + o2));
66
+ return 1 === r3 ? (t3 = e2[n3 - 1], a2.push(c[t3 >> 2] + c[63 & t3 << 4] + "==")) : 2 === r3 && (t3 = (e2[n3 - 2] << 8) + e2[n3 - 1], a2.push(c[t3 >> 10] + c[63 & t3 >> 4] + c[63 & t3 << 2] + "=")), a2.join("");
67
+ }
68
+ n2.byteLength = function(e2) {
69
+ var t3 = r2(e2), n3 = t3[0], a2 = t3[1];
70
+ return 3 * (n3 + a2) / 4 - a2;
71
+ }, n2.toByteArray = o, n2.fromByteArray = l;
72
+ for (var c = [], u = [], p = "undefined" == typeof Uint8Array ? Array : Uint8Array, f = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", g = 0, _ = f.length; g < _; ++g) c[g] = f[g], u[f.charCodeAt(g)] = g;
73
+ u[45] = 62, u[95] = 63;
74
+ }, {}], 2: [function() {
75
+ }, {}], 3: [function(e, t2, n2) {
76
+ (function() {
77
+ (function() {
78
+ var t3 = String.fromCharCode, o = Math.min;
79
+ function d(e2) {
80
+ if (2147483647 < e2) throw new RangeError('The value "' + e2 + '" is invalid for option "size"');
81
+ var t4 = new Uint8Array(e2);
82
+ return t4.__proto__ = s.prototype, t4;
83
+ }
84
+ function s(e2, t4, n3) {
85
+ if ("number" == typeof e2) {
86
+ if ("string" == typeof t4) throw new TypeError('The "string" argument must be of type string. Received type number');
87
+ return p(e2);
88
+ }
89
+ return l(e2, t4, n3);
90
+ }
91
+ function l(e2, t4, n3) {
92
+ if ("string" == typeof e2) return f(e2, t4);
93
+ if (ArrayBuffer.isView(e2)) return g(e2);
94
+ if (null == e2) throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e2);
95
+ if (K(e2, ArrayBuffer) || e2 && K(e2.buffer, ArrayBuffer)) return _(e2, t4, n3);
96
+ if ("number" == typeof e2) throw new TypeError('The "value" argument must not be of type number. Received type number');
97
+ var r2 = e2.valueOf && e2.valueOf();
98
+ if (null != r2 && r2 !== e2) return s.from(r2, t4, n3);
99
+ var a = h(e2);
100
+ if (a) return a;
101
+ if ("undefined" != typeof Symbol && null != Symbol.toPrimitive && "function" == typeof e2[Symbol.toPrimitive]) return s.from(e2[Symbol.toPrimitive]("string"), t4, n3);
102
+ throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof e2);
103
+ }
104
+ function c(e2) {
105
+ if ("number" != typeof e2) throw new TypeError('"size" argument must be of type number');
106
+ else if (0 > e2) throw new RangeError('The value "' + e2 + '" is invalid for option "size"');
107
+ }
108
+ function u(e2, t4, n3) {
109
+ return c(e2), 0 >= e2 ? d(e2) : void 0 === t4 ? d(e2) : "string" == typeof n3 ? d(e2).fill(t4, n3) : d(e2).fill(t4);
110
+ }
111
+ function p(e2) {
112
+ return c(e2), d(0 > e2 ? 0 : 0 | m(e2));
113
+ }
114
+ function f(e2, t4) {
115
+ if (("string" != typeof t4 || "" === t4) && (t4 = "utf8"), !s.isEncoding(t4)) throw new TypeError("Unknown encoding: " + t4);
116
+ var n3 = 0 | b(e2, t4), r2 = d(n3), a = r2.write(e2, t4);
117
+ return a !== n3 && (r2 = r2.slice(0, a)), r2;
118
+ }
119
+ function g(e2) {
120
+ for (var t4 = 0 > e2.length ? 0 : 0 | m(e2.length), n3 = d(t4), r2 = 0; r2 < t4; r2 += 1) n3[r2] = 255 & e2[r2];
121
+ return n3;
122
+ }
123
+ function _(e2, t4, n3) {
124
+ if (0 > t4 || e2.byteLength < t4) throw new RangeError('"offset" is outside of buffer bounds');
125
+ if (e2.byteLength < t4 + (n3 || 0)) throw new RangeError('"length" is outside of buffer bounds');
126
+ var r2;
127
+ return r2 = void 0 === t4 && void 0 === n3 ? new Uint8Array(e2) : void 0 === n3 ? new Uint8Array(e2, t4) : new Uint8Array(e2, t4, n3), r2.__proto__ = s.prototype, r2;
128
+ }
129
+ function h(e2) {
130
+ if (s.isBuffer(e2)) {
131
+ var t4 = 0 | m(e2.length), n3 = d(t4);
132
+ return 0 === n3.length ? n3 : (e2.copy(n3, 0, 0, t4), n3);
133
+ }
134
+ return void 0 === e2.length ? "Buffer" === e2.type && Array.isArray(e2.data) ? g(e2.data) : void 0 : "number" != typeof e2.length || X(e2.length) ? d(0) : g(e2);
135
+ }
136
+ function m(e2) {
137
+ if (e2 >= 2147483647) throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + 2147483647 .toString(16) + " bytes");
138
+ return 0 | e2;
139
+ }
140
+ function b(e2, t4) {
141
+ if (s.isBuffer(e2)) return e2.length;
142
+ if (ArrayBuffer.isView(e2) || K(e2, ArrayBuffer)) return e2.byteLength;
143
+ if ("string" != typeof e2) throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof e2);
144
+ var n3 = e2.length, r2 = 2 < arguments.length && true === arguments[2];
145
+ if (!r2 && 0 === n3) return 0;
146
+ for (var a = false; ; ) switch (t4) {
147
+ case "ascii":
148
+ case "latin1":
149
+ case "binary":
150
+ return n3;
151
+ case "utf8":
152
+ case "utf-8":
153
+ return H(e2).length;
154
+ case "ucs2":
155
+ case "ucs-2":
156
+ case "utf16le":
157
+ case "utf-16le":
158
+ return 2 * n3;
159
+ case "hex":
160
+ return n3 >>> 1;
161
+ case "base64":
162
+ return z(e2).length;
163
+ default:
164
+ if (a) return r2 ? -1 : H(e2).length;
165
+ t4 = ("" + t4).toLowerCase(), a = true;
166
+ }
167
+ }
168
+ function y(e2, t4, n3) {
169
+ var r2 = false;
170
+ if ((void 0 === t4 || 0 > t4) && (t4 = 0), t4 > this.length) return "";
171
+ if ((void 0 === n3 || n3 > this.length) && (n3 = this.length), 0 >= n3) return "";
172
+ if (n3 >>>= 0, t4 >>>= 0, n3 <= t4) return "";
173
+ for (e2 || (e2 = "utf8"); ; ) switch (e2) {
174
+ case "hex":
175
+ return P(this, t4, n3);
176
+ case "utf8":
177
+ case "utf-8":
178
+ return x(this, t4, n3);
179
+ case "ascii":
180
+ return D(this, t4, n3);
181
+ case "latin1":
182
+ case "binary":
183
+ return I(this, t4, n3);
184
+ case "base64":
185
+ return A(this, t4, n3);
186
+ case "ucs2":
187
+ case "ucs-2":
188
+ case "utf16le":
189
+ case "utf-16le":
190
+ return M(this, t4, n3);
191
+ default:
192
+ if (r2) throw new TypeError("Unknown encoding: " + e2);
193
+ e2 = (e2 + "").toLowerCase(), r2 = true;
194
+ }
195
+ }
196
+ function C(e2, t4, n3) {
197
+ var r2 = e2[t4];
198
+ e2[t4] = e2[n3], e2[n3] = r2;
199
+ }
200
+ function R(e2, t4, n3, r2, a) {
201
+ if (0 === e2.length) return -1;
202
+ if ("string" == typeof n3 ? (r2 = n3, n3 = 0) : 2147483647 < n3 ? n3 = 2147483647 : -2147483648 > n3 && (n3 = -2147483648), n3 = +n3, X(n3) && (n3 = a ? 0 : e2.length - 1), 0 > n3 && (n3 = e2.length + n3), n3 >= e2.length) {
203
+ if (a) return -1;
204
+ n3 = e2.length - 1;
205
+ } else if (0 > n3) if (a) n3 = 0;
206
+ else return -1;
207
+ if ("string" == typeof t4 && (t4 = s.from(t4, r2)), s.isBuffer(t4)) return 0 === t4.length ? -1 : E(e2, t4, n3, r2, a);
208
+ if ("number" == typeof t4) return t4 &= 255, "function" == typeof Uint8Array.prototype.indexOf ? a ? Uint8Array.prototype.indexOf.call(e2, t4, n3) : Uint8Array.prototype.lastIndexOf.call(e2, t4, n3) : E(e2, [t4], n3, r2, a);
209
+ throw new TypeError("val must be string, number or Buffer");
210
+ }
211
+ function E(e2, t4, n3, r2, a) {
212
+ function o2(e3, t5) {
213
+ return 1 === d2 ? e3[t5] : e3.readUInt16BE(t5 * d2);
214
+ }
215
+ var d2 = 1, s2 = e2.length, l2 = t4.length;
216
+ if (void 0 !== r2 && (r2 = (r2 + "").toLowerCase(), "ucs2" === r2 || "ucs-2" === r2 || "utf16le" === r2 || "utf-16le" === r2)) {
217
+ if (2 > e2.length || 2 > t4.length) return -1;
218
+ d2 = 2, s2 /= 2, l2 /= 2, n3 /= 2;
219
+ }
220
+ var c2;
221
+ if (a) {
222
+ var u2 = -1;
223
+ for (c2 = n3; c2 < s2; c2++) if (o2(e2, c2) !== o2(t4, -1 === u2 ? 0 : c2 - u2)) -1 !== u2 && (c2 -= c2 - u2), u2 = -1;
224
+ else if (-1 === u2 && (u2 = c2), c2 - u2 + 1 === l2) return u2 * d2;
225
+ } else for (n3 + l2 > s2 && (n3 = s2 - l2), c2 = n3; 0 <= c2; c2--) {
226
+ for (var p2 = true, f2 = 0; f2 < l2; f2++) if (o2(e2, c2 + f2) !== o2(t4, f2)) {
227
+ p2 = false;
228
+ break;
229
+ }
230
+ if (p2) return c2;
231
+ }
232
+ return -1;
233
+ }
234
+ function w(e2, t4, n3, r2) {
235
+ n3 = +n3 || 0;
236
+ var a = e2.length - n3;
237
+ r2 ? (r2 = +r2, r2 > a && (r2 = a)) : r2 = a;
238
+ var o2 = t4.length;
239
+ r2 > o2 / 2 && (r2 = o2 / 2);
240
+ for (var d2, s2 = 0; s2 < r2; ++s2) {
241
+ if (d2 = parseInt(t4.substr(2 * s2, 2), 16), X(d2)) return s2;
242
+ e2[n3 + s2] = d2;
243
+ }
244
+ return s2;
245
+ }
246
+ function S(e2, t4, n3, r2) {
247
+ return G(H(t4, e2.length - n3), e2, n3, r2);
248
+ }
249
+ function T(e2, t4, n3, r2) {
250
+ return G(Y2(t4), e2, n3, r2);
251
+ }
252
+ function v(e2, t4, n3, r2) {
253
+ return T(e2, t4, n3, r2);
254
+ }
255
+ function k(e2, t4, n3, r2) {
256
+ return G(z(t4), e2, n3, r2);
257
+ }
258
+ function L(e2, t4, n3, r2) {
259
+ return G(V(t4, e2.length - n3), e2, n3, r2);
260
+ }
261
+ function A(e2, t4, n3) {
262
+ return 0 === t4 && n3 === e2.length ? $2.fromByteArray(e2) : $2.fromByteArray(e2.slice(t4, n3));
263
+ }
264
+ function x(e2, t4, n3) {
265
+ n3 = o(e2.length, n3);
266
+ for (var r2 = [], a = t4; a < n3; ) {
267
+ var d2 = e2[a], s2 = null, l2 = 239 < d2 ? 4 : 223 < d2 ? 3 : 191 < d2 ? 2 : 1;
268
+ if (a + l2 <= n3) {
269
+ var c2, u2, p2, f2;
270
+ 1 === l2 ? 128 > d2 && (s2 = d2) : 2 === l2 ? (c2 = e2[a + 1], 128 == (192 & c2) && (f2 = (31 & d2) << 6 | 63 & c2, 127 < f2 && (s2 = f2))) : 3 === l2 ? (c2 = e2[a + 1], u2 = e2[a + 2], 128 == (192 & c2) && 128 == (192 & u2) && (f2 = (15 & d2) << 12 | (63 & c2) << 6 | 63 & u2, 2047 < f2 && (55296 > f2 || 57343 < f2) && (s2 = f2))) : 4 === l2 ? (c2 = e2[a + 1], u2 = e2[a + 2], p2 = e2[a + 3], 128 == (192 & c2) && 128 == (192 & u2) && 128 == (192 & p2) && (f2 = (15 & d2) << 18 | (63 & c2) << 12 | (63 & u2) << 6 | 63 & p2, 65535 < f2 && 1114112 > f2 && (s2 = f2))) : void 0;
271
+ }
272
+ null === s2 ? (s2 = 65533, l2 = 1) : 65535 < s2 && (s2 -= 65536, r2.push(55296 | 1023 & s2 >>> 10), s2 = 56320 | 1023 & s2), r2.push(s2), a += l2;
273
+ }
274
+ return N(r2);
275
+ }
276
+ function N(e2) {
277
+ var n3 = e2.length;
278
+ if (n3 <= 4096) return t3.apply(String, e2);
279
+ for (var r2 = "", a = 0; a < n3; ) r2 += t3.apply(String, e2.slice(a, a += 4096));
280
+ return r2;
281
+ }
282
+ function D(e2, n3, r2) {
283
+ var a = "";
284
+ r2 = o(e2.length, r2);
285
+ for (var d2 = n3; d2 < r2; ++d2) a += t3(127 & e2[d2]);
286
+ return a;
287
+ }
288
+ function I(e2, n3, r2) {
289
+ var a = "";
290
+ r2 = o(e2.length, r2);
291
+ for (var d2 = n3; d2 < r2; ++d2) a += t3(e2[d2]);
292
+ return a;
293
+ }
294
+ function P(e2, t4, n3) {
295
+ var r2 = e2.length;
296
+ (!t4 || 0 > t4) && (t4 = 0), (!n3 || 0 > n3 || n3 > r2) && (n3 = r2);
297
+ for (var a = "", o2 = t4; o2 < n3; ++o2) a += W(e2[o2]);
298
+ return a;
299
+ }
300
+ function M(e2, n3, r2) {
301
+ for (var a = e2.slice(n3, r2), o2 = "", d2 = 0; d2 < a.length; d2 += 2) o2 += t3(a[d2] + 256 * a[d2 + 1]);
302
+ return o2;
303
+ }
304
+ function O(e2, t4, n3) {
305
+ if (0 != e2 % 1 || 0 > e2) throw new RangeError("offset is not uint");
306
+ if (e2 + t4 > n3) throw new RangeError("Trying to access beyond buffer length");
307
+ }
308
+ function F(e2, t4, n3, r2, a, o2) {
309
+ if (!s.isBuffer(e2)) throw new TypeError('"buffer" argument must be a Buffer instance');
310
+ if (t4 > a || t4 < o2) throw new RangeError('"value" argument is out of bounds');
311
+ if (n3 + r2 > e2.length) throw new RangeError("Index out of range");
312
+ }
313
+ function B(e2, t4, n3, r2) {
314
+ if (n3 + r2 > e2.length) throw new RangeError("Index out of range");
315
+ if (0 > n3) throw new RangeError("Index out of range");
316
+ }
317
+ function U(e2, t4, n3, r2, a) {
318
+ return t4 = +t4, n3 >>>= 0, a || B(e2, t4, n3, 4), J.write(e2, t4, n3, r2, 23, 4), n3 + 4;
319
+ }
320
+ function j(e2, t4, n3, r2, a) {
321
+ return t4 = +t4, n3 >>>= 0, a || B(e2, t4, n3, 8), J.write(e2, t4, n3, r2, 52, 8), n3 + 8;
322
+ }
323
+ function q(e2) {
324
+ if (e2 = e2.split("=")[0], e2 = e2.trim().replace(Q, ""), 2 > e2.length) return "";
325
+ for (; 0 != e2.length % 4; ) e2 += "=";
326
+ return e2;
327
+ }
328
+ function W(e2) {
329
+ return 16 > e2 ? "0" + e2.toString(16) : e2.toString(16);
330
+ }
331
+ function H(e2, t4) {
332
+ t4 = t4 || 1 / 0;
333
+ for (var n3, r2 = e2.length, a = null, o2 = [], d2 = 0; d2 < r2; ++d2) {
334
+ if (n3 = e2.charCodeAt(d2), 55295 < n3 && 57344 > n3) {
335
+ if (!a) {
336
+ if (56319 < n3) {
337
+ -1 < (t4 -= 3) && o2.push(239, 191, 189);
338
+ continue;
339
+ } else if (d2 + 1 === r2) {
340
+ -1 < (t4 -= 3) && o2.push(239, 191, 189);
341
+ continue;
342
+ }
343
+ a = n3;
344
+ continue;
345
+ }
346
+ if (56320 > n3) {
347
+ -1 < (t4 -= 3) && o2.push(239, 191, 189), a = n3;
348
+ continue;
349
+ }
350
+ n3 = (a - 55296 << 10 | n3 - 56320) + 65536;
351
+ } else a && -1 < (t4 -= 3) && o2.push(239, 191, 189);
352
+ if (a = null, 128 > n3) {
353
+ if (0 > (t4 -= 1)) break;
354
+ o2.push(n3);
355
+ } else if (2048 > n3) {
356
+ if (0 > (t4 -= 2)) break;
357
+ o2.push(192 | n3 >> 6, 128 | 63 & n3);
358
+ } else if (65536 > n3) {
359
+ if (0 > (t4 -= 3)) break;
360
+ o2.push(224 | n3 >> 12, 128 | 63 & n3 >> 6, 128 | 63 & n3);
361
+ } else if (1114112 > n3) {
362
+ if (0 > (t4 -= 4)) break;
363
+ o2.push(240 | n3 >> 18, 128 | 63 & n3 >> 12, 128 | 63 & n3 >> 6, 128 | 63 & n3);
364
+ } else throw new Error("Invalid code point");
365
+ }
366
+ return o2;
367
+ }
368
+ function Y2(e2) {
369
+ for (var t4 = [], n3 = 0; n3 < e2.length; ++n3) t4.push(255 & e2.charCodeAt(n3));
370
+ return t4;
371
+ }
372
+ function V(e2, t4) {
373
+ for (var n3, r2, a, o2 = [], d2 = 0; d2 < e2.length && !(0 > (t4 -= 2)); ++d2) n3 = e2.charCodeAt(d2), r2 = n3 >> 8, a = n3 % 256, o2.push(a), o2.push(r2);
374
+ return o2;
375
+ }
376
+ function z(e2) {
377
+ return $2.toByteArray(q(e2));
378
+ }
379
+ function G(e2, t4, n3, r2) {
380
+ for (var a = 0; a < r2 && !(a + n3 >= t4.length || a >= e2.length); ++a) t4[a + n3] = e2[a];
381
+ return a;
382
+ }
383
+ function K(e2, t4) {
384
+ return e2 instanceof t4 || null != e2 && null != e2.constructor && null != e2.constructor.name && e2.constructor.name === t4.name;
385
+ }
386
+ function X(e2) {
387
+ return e2 !== e2;
388
+ }
389
+ var $2 = e("base64-js"), J = e("ieee754");
390
+ n2.Buffer = s, n2.SlowBuffer = function(e2) {
391
+ return +e2 != e2 && (e2 = 0), s.alloc(+e2);
392
+ }, n2.INSPECT_MAX_BYTES = 50;
393
+ n2.kMaxLength = 2147483647, s.TYPED_ARRAY_SUPPORT = (function() {
394
+ try {
395
+ var e2 = new Uint8Array(1);
396
+ return e2.__proto__ = { __proto__: Uint8Array.prototype, foo: function() {
397
+ return 42;
398
+ } }, 42 === e2.foo();
399
+ } catch (t4) {
400
+ return false;
401
+ }
402
+ })(), s.TYPED_ARRAY_SUPPORT || "undefined" == typeof console || "function" != typeof console.error || console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."), Object.defineProperty(s.prototype, "parent", { enumerable: true, get: function() {
403
+ return s.isBuffer(this) ? this.buffer : void 0;
404
+ } }), Object.defineProperty(s.prototype, "offset", { enumerable: true, get: function() {
405
+ return s.isBuffer(this) ? this.byteOffset : void 0;
406
+ } }), "undefined" != typeof Symbol && null != Symbol.species && s[Symbol.species] === s && Object.defineProperty(s, Symbol.species, { value: null, configurable: true, enumerable: false, writable: false }), s.poolSize = 8192, s.from = function(e2, t4, n3) {
407
+ return l(e2, t4, n3);
408
+ }, s.prototype.__proto__ = Uint8Array.prototype, s.__proto__ = Uint8Array, s.alloc = function(e2, t4, n3) {
409
+ return u(e2, t4, n3);
410
+ }, s.allocUnsafe = function(e2) {
411
+ return p(e2);
412
+ }, s.allocUnsafeSlow = function(e2) {
413
+ return p(e2);
414
+ }, s.isBuffer = function(e2) {
415
+ return null != e2 && true === e2._isBuffer && e2 !== s.prototype;
416
+ }, s.compare = function(e2, t4) {
417
+ if (K(e2, Uint8Array) && (e2 = s.from(e2, e2.offset, e2.byteLength)), K(t4, Uint8Array) && (t4 = s.from(t4, t4.offset, t4.byteLength)), !s.isBuffer(e2) || !s.isBuffer(t4)) throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');
418
+ if (e2 === t4) return 0;
419
+ for (var n3 = e2.length, r2 = t4.length, d2 = 0, l2 = o(n3, r2); d2 < l2; ++d2) if (e2[d2] !== t4[d2]) {
420
+ n3 = e2[d2], r2 = t4[d2];
421
+ break;
422
+ }
423
+ return n3 < r2 ? -1 : r2 < n3 ? 1 : 0;
424
+ }, s.isEncoding = function(e2) {
425
+ switch ((e2 + "").toLowerCase()) {
426
+ case "hex":
427
+ case "utf8":
428
+ case "utf-8":
429
+ case "ascii":
430
+ case "latin1":
431
+ case "binary":
432
+ case "base64":
433
+ case "ucs2":
434
+ case "ucs-2":
435
+ case "utf16le":
436
+ case "utf-16le":
437
+ return true;
438
+ default:
439
+ return false;
440
+ }
441
+ }, s.concat = function(e2, t4) {
442
+ if (!Array.isArray(e2)) throw new TypeError('"list" argument must be an Array of Buffers');
443
+ if (0 === e2.length) return s.alloc(0);
444
+ var n3;
445
+ if (t4 === void 0) for (t4 = 0, n3 = 0; n3 < e2.length; ++n3) t4 += e2[n3].length;
446
+ var r2 = s.allocUnsafe(t4), a = 0;
447
+ for (n3 = 0; n3 < e2.length; ++n3) {
448
+ var o2 = e2[n3];
449
+ if (K(o2, Uint8Array) && (o2 = s.from(o2)), !s.isBuffer(o2)) throw new TypeError('"list" argument must be an Array of Buffers');
450
+ o2.copy(r2, a), a += o2.length;
451
+ }
452
+ return r2;
453
+ }, s.byteLength = b, s.prototype._isBuffer = true, s.prototype.swap16 = function() {
454
+ var e2 = this.length;
455
+ if (0 != e2 % 2) throw new RangeError("Buffer size must be a multiple of 16-bits");
456
+ for (var t4 = 0; t4 < e2; t4 += 2) C(this, t4, t4 + 1);
457
+ return this;
458
+ }, s.prototype.swap32 = function() {
459
+ var e2 = this.length;
460
+ if (0 != e2 % 4) throw new RangeError("Buffer size must be a multiple of 32-bits");
461
+ for (var t4 = 0; t4 < e2; t4 += 4) C(this, t4, t4 + 3), C(this, t4 + 1, t4 + 2);
462
+ return this;
463
+ }, s.prototype.swap64 = function() {
464
+ var e2 = this.length;
465
+ if (0 != e2 % 8) throw new RangeError("Buffer size must be a multiple of 64-bits");
466
+ for (var t4 = 0; t4 < e2; t4 += 8) C(this, t4, t4 + 7), C(this, t4 + 1, t4 + 6), C(this, t4 + 2, t4 + 5), C(this, t4 + 3, t4 + 4);
467
+ return this;
468
+ }, s.prototype.toString = function() {
469
+ var e2 = this.length;
470
+ return 0 === e2 ? "" : 0 === arguments.length ? x(this, 0, e2) : y.apply(this, arguments);
471
+ }, s.prototype.toLocaleString = s.prototype.toString, s.prototype.equals = function(e2) {
472
+ if (!s.isBuffer(e2)) throw new TypeError("Argument must be a Buffer");
473
+ return this === e2 || 0 === s.compare(this, e2);
474
+ }, s.prototype.inspect = function() {
475
+ var e2 = "", t4 = n2.INSPECT_MAX_BYTES;
476
+ return e2 = this.toString("hex", 0, t4).replace(/(.{2})/g, "$1 ").trim(), this.length > t4 && (e2 += " ... "), "<Buffer " + e2 + ">";
477
+ }, s.prototype.compare = function(e2, t4, n3, r2, a) {
478
+ if (K(e2, Uint8Array) && (e2 = s.from(e2, e2.offset, e2.byteLength)), !s.isBuffer(e2)) throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof e2);
479
+ if (void 0 === t4 && (t4 = 0), void 0 === n3 && (n3 = e2 ? e2.length : 0), void 0 === r2 && (r2 = 0), void 0 === a && (a = this.length), 0 > t4 || n3 > e2.length || 0 > r2 || a > this.length) throw new RangeError("out of range index");
480
+ if (r2 >= a && t4 >= n3) return 0;
481
+ if (r2 >= a) return -1;
482
+ if (t4 >= n3) return 1;
483
+ if (t4 >>>= 0, n3 >>>= 0, r2 >>>= 0, a >>>= 0, this === e2) return 0;
484
+ for (var d2 = a - r2, l2 = n3 - t4, c2 = o(d2, l2), u2 = this.slice(r2, a), p2 = e2.slice(t4, n3), f2 = 0; f2 < c2; ++f2) if (u2[f2] !== p2[f2]) {
485
+ d2 = u2[f2], l2 = p2[f2];
486
+ break;
487
+ }
488
+ return d2 < l2 ? -1 : l2 < d2 ? 1 : 0;
489
+ }, s.prototype.includes = function(e2, t4, n3) {
490
+ return -1 !== this.indexOf(e2, t4, n3);
491
+ }, s.prototype.indexOf = function(e2, t4, n3) {
492
+ return R(this, e2, t4, n3, true);
493
+ }, s.prototype.lastIndexOf = function(e2, t4, n3) {
494
+ return R(this, e2, t4, n3, false);
495
+ }, s.prototype.write = function(e2, t4, n3, r2) {
496
+ if (void 0 === t4) r2 = "utf8", n3 = this.length, t4 = 0;
497
+ else if (void 0 === n3 && "string" == typeof t4) r2 = t4, n3 = this.length, t4 = 0;
498
+ else if (isFinite(t4)) t4 >>>= 0, isFinite(n3) ? (n3 >>>= 0, void 0 === r2 && (r2 = "utf8")) : (r2 = n3, n3 = void 0);
499
+ else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
500
+ var a = this.length - t4;
501
+ if ((void 0 === n3 || n3 > a) && (n3 = a), 0 < e2.length && (0 > n3 || 0 > t4) || t4 > this.length) throw new RangeError("Attempt to write outside buffer bounds");
502
+ r2 || (r2 = "utf8");
503
+ for (var o2 = false; ; ) switch (r2) {
504
+ case "hex":
505
+ return w(this, e2, t4, n3);
506
+ case "utf8":
507
+ case "utf-8":
508
+ return S(this, e2, t4, n3);
509
+ case "ascii":
510
+ return T(this, e2, t4, n3);
511
+ case "latin1":
512
+ case "binary":
513
+ return v(this, e2, t4, n3);
514
+ case "base64":
515
+ return k(this, e2, t4, n3);
516
+ case "ucs2":
517
+ case "ucs-2":
518
+ case "utf16le":
519
+ case "utf-16le":
520
+ return L(this, e2, t4, n3);
521
+ default:
522
+ if (o2) throw new TypeError("Unknown encoding: " + r2);
523
+ r2 = ("" + r2).toLowerCase(), o2 = true;
524
+ }
525
+ }, s.prototype.toJSON = function() {
526
+ return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) };
527
+ };
528
+ s.prototype.slice = function(e2, t4) {
529
+ var n3 = this.length;
530
+ e2 = ~~e2, t4 = t4 === void 0 ? n3 : ~~t4, 0 > e2 ? (e2 += n3, 0 > e2 && (e2 = 0)) : e2 > n3 && (e2 = n3), 0 > t4 ? (t4 += n3, 0 > t4 && (t4 = 0)) : t4 > n3 && (t4 = n3), t4 < e2 && (t4 = e2);
531
+ var r2 = this.subarray(e2, t4);
532
+ return r2.__proto__ = s.prototype, r2;
533
+ }, s.prototype.readUIntLE = function(e2, t4, n3) {
534
+ e2 >>>= 0, t4 >>>= 0, n3 || O(e2, t4, this.length);
535
+ for (var r2 = this[e2], a = 1, o2 = 0; ++o2 < t4 && (a *= 256); ) r2 += this[e2 + o2] * a;
536
+ return r2;
537
+ }, s.prototype.readUIntBE = function(e2, t4, n3) {
538
+ e2 >>>= 0, t4 >>>= 0, n3 || O(e2, t4, this.length);
539
+ for (var r2 = this[e2 + --t4], a = 1; 0 < t4 && (a *= 256); ) r2 += this[e2 + --t4] * a;
540
+ return r2;
541
+ }, s.prototype.readUInt8 = function(e2, t4) {
542
+ return e2 >>>= 0, t4 || O(e2, 1, this.length), this[e2];
543
+ }, s.prototype.readUInt16LE = function(e2, t4) {
544
+ return e2 >>>= 0, t4 || O(e2, 2, this.length), this[e2] | this[e2 + 1] << 8;
545
+ }, s.prototype.readUInt16BE = function(e2, t4) {
546
+ return e2 >>>= 0, t4 || O(e2, 2, this.length), this[e2] << 8 | this[e2 + 1];
547
+ }, s.prototype.readUInt32LE = function(e2, t4) {
548
+ return e2 >>>= 0, t4 || O(e2, 4, this.length), (this[e2] | this[e2 + 1] << 8 | this[e2 + 2] << 16) + 16777216 * this[e2 + 3];
549
+ }, s.prototype.readUInt32BE = function(e2, t4) {
550
+ return e2 >>>= 0, t4 || O(e2, 4, this.length), 16777216 * this[e2] + (this[e2 + 1] << 16 | this[e2 + 2] << 8 | this[e2 + 3]);
551
+ }, s.prototype.readIntLE = function(e2, t4, n3) {
552
+ e2 >>>= 0, t4 >>>= 0, n3 || O(e2, t4, this.length);
553
+ for (var a = this[e2], o2 = 1, d2 = 0; ++d2 < t4 && (o2 *= 256); ) a += this[e2 + d2] * o2;
554
+ return o2 *= 128, a >= o2 && (a -= r(2, 8 * t4)), a;
555
+ }, s.prototype.readIntBE = function(e2, t4, n3) {
556
+ e2 >>>= 0, t4 >>>= 0, n3 || O(e2, t4, this.length);
557
+ for (var a = t4, o2 = 1, d2 = this[e2 + --a]; 0 < a && (o2 *= 256); ) d2 += this[e2 + --a] * o2;
558
+ return o2 *= 128, d2 >= o2 && (d2 -= r(2, 8 * t4)), d2;
559
+ }, s.prototype.readInt8 = function(e2, t4) {
560
+ return e2 >>>= 0, t4 || O(e2, 1, this.length), 128 & this[e2] ? -1 * (255 - this[e2] + 1) : this[e2];
561
+ }, s.prototype.readInt16LE = function(e2, t4) {
562
+ e2 >>>= 0, t4 || O(e2, 2, this.length);
563
+ var n3 = this[e2] | this[e2 + 1] << 8;
564
+ return 32768 & n3 ? 4294901760 | n3 : n3;
565
+ }, s.prototype.readInt16BE = function(e2, t4) {
566
+ e2 >>>= 0, t4 || O(e2, 2, this.length);
567
+ var n3 = this[e2 + 1] | this[e2] << 8;
568
+ return 32768 & n3 ? 4294901760 | n3 : n3;
569
+ }, s.prototype.readInt32LE = function(e2, t4) {
570
+ return e2 >>>= 0, t4 || O(e2, 4, this.length), this[e2] | this[e2 + 1] << 8 | this[e2 + 2] << 16 | this[e2 + 3] << 24;
571
+ }, s.prototype.readInt32BE = function(e2, t4) {
572
+ return e2 >>>= 0, t4 || O(e2, 4, this.length), this[e2] << 24 | this[e2 + 1] << 16 | this[e2 + 2] << 8 | this[e2 + 3];
573
+ }, s.prototype.readFloatLE = function(e2, t4) {
574
+ return e2 >>>= 0, t4 || O(e2, 4, this.length), J.read(this, e2, true, 23, 4);
575
+ }, s.prototype.readFloatBE = function(e2, t4) {
576
+ return e2 >>>= 0, t4 || O(e2, 4, this.length), J.read(this, e2, false, 23, 4);
577
+ }, s.prototype.readDoubleLE = function(e2, t4) {
578
+ return e2 >>>= 0, t4 || O(e2, 8, this.length), J.read(this, e2, true, 52, 8);
579
+ }, s.prototype.readDoubleBE = function(e2, t4) {
580
+ return e2 >>>= 0, t4 || O(e2, 8, this.length), J.read(this, e2, false, 52, 8);
581
+ }, s.prototype.writeUIntLE = function(e2, t4, n3, a) {
582
+ if (e2 = +e2, t4 >>>= 0, n3 >>>= 0, !a) {
583
+ var o2 = r(2, 8 * n3) - 1;
584
+ F(this, e2, t4, n3, o2, 0);
585
+ }
586
+ var d2 = 1, s2 = 0;
587
+ for (this[t4] = 255 & e2; ++s2 < n3 && (d2 *= 256); ) this[t4 + s2] = 255 & e2 / d2;
588
+ return t4 + n3;
589
+ }, s.prototype.writeUIntBE = function(e2, t4, n3, a) {
590
+ if (e2 = +e2, t4 >>>= 0, n3 >>>= 0, !a) {
591
+ var o2 = r(2, 8 * n3) - 1;
592
+ F(this, e2, t4, n3, o2, 0);
593
+ }
594
+ var d2 = n3 - 1, s2 = 1;
595
+ for (this[t4 + d2] = 255 & e2; 0 <= --d2 && (s2 *= 256); ) this[t4 + d2] = 255 & e2 / s2;
596
+ return t4 + n3;
597
+ }, s.prototype.writeUInt8 = function(e2, t4, n3) {
598
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 1, 255, 0), this[t4] = 255 & e2, t4 + 1;
599
+ }, s.prototype.writeUInt16LE = function(e2, t4, n3) {
600
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 2, 65535, 0), this[t4] = 255 & e2, this[t4 + 1] = e2 >>> 8, t4 + 2;
601
+ }, s.prototype.writeUInt16BE = function(e2, t4, n3) {
602
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 2, 65535, 0), this[t4] = e2 >>> 8, this[t4 + 1] = 255 & e2, t4 + 2;
603
+ }, s.prototype.writeUInt32LE = function(e2, t4, n3) {
604
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 4, 4294967295, 0), this[t4 + 3] = e2 >>> 24, this[t4 + 2] = e2 >>> 16, this[t4 + 1] = e2 >>> 8, this[t4] = 255 & e2, t4 + 4;
605
+ }, s.prototype.writeUInt32BE = function(e2, t4, n3) {
606
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 4, 4294967295, 0), this[t4] = e2 >>> 24, this[t4 + 1] = e2 >>> 16, this[t4 + 2] = e2 >>> 8, this[t4 + 3] = 255 & e2, t4 + 4;
607
+ }, s.prototype.writeIntLE = function(e2, t4, n3, a) {
608
+ if (e2 = +e2, t4 >>>= 0, !a) {
609
+ var o2 = r(2, 8 * n3 - 1);
610
+ F(this, e2, t4, n3, o2 - 1, -o2);
611
+ }
612
+ var d2 = 0, s2 = 1, l2 = 0;
613
+ for (this[t4] = 255 & e2; ++d2 < n3 && (s2 *= 256); ) 0 > e2 && 0 === l2 && 0 !== this[t4 + d2 - 1] && (l2 = 1), this[t4 + d2] = 255 & (e2 / s2 >> 0) - l2;
614
+ return t4 + n3;
615
+ }, s.prototype.writeIntBE = function(e2, t4, n3, a) {
616
+ if (e2 = +e2, t4 >>>= 0, !a) {
617
+ var o2 = r(2, 8 * n3 - 1);
618
+ F(this, e2, t4, n3, o2 - 1, -o2);
619
+ }
620
+ var d2 = n3 - 1, s2 = 1, l2 = 0;
621
+ for (this[t4 + d2] = 255 & e2; 0 <= --d2 && (s2 *= 256); ) 0 > e2 && 0 === l2 && 0 !== this[t4 + d2 + 1] && (l2 = 1), this[t4 + d2] = 255 & (e2 / s2 >> 0) - l2;
622
+ return t4 + n3;
623
+ }, s.prototype.writeInt8 = function(e2, t4, n3) {
624
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 1, 127, -128), 0 > e2 && (e2 = 255 + e2 + 1), this[t4] = 255 & e2, t4 + 1;
625
+ }, s.prototype.writeInt16LE = function(e2, t4, n3) {
626
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 2, 32767, -32768), this[t4] = 255 & e2, this[t4 + 1] = e2 >>> 8, t4 + 2;
627
+ }, s.prototype.writeInt16BE = function(e2, t4, n3) {
628
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 2, 32767, -32768), this[t4] = e2 >>> 8, this[t4 + 1] = 255 & e2, t4 + 2;
629
+ }, s.prototype.writeInt32LE = function(e2, t4, n3) {
630
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 4, 2147483647, -2147483648), this[t4] = 255 & e2, this[t4 + 1] = e2 >>> 8, this[t4 + 2] = e2 >>> 16, this[t4 + 3] = e2 >>> 24, t4 + 4;
631
+ }, s.prototype.writeInt32BE = function(e2, t4, n3) {
632
+ return e2 = +e2, t4 >>>= 0, n3 || F(this, e2, t4, 4, 2147483647, -2147483648), 0 > e2 && (e2 = 4294967295 + e2 + 1), this[t4] = e2 >>> 24, this[t4 + 1] = e2 >>> 16, this[t4 + 2] = e2 >>> 8, this[t4 + 3] = 255 & e2, t4 + 4;
633
+ }, s.prototype.writeFloatLE = function(e2, t4, n3) {
634
+ return U(this, e2, t4, true, n3);
635
+ }, s.prototype.writeFloatBE = function(e2, t4, n3) {
636
+ return U(this, e2, t4, false, n3);
637
+ }, s.prototype.writeDoubleLE = function(e2, t4, n3) {
638
+ return j(this, e2, t4, true, n3);
639
+ }, s.prototype.writeDoubleBE = function(e2, t4, n3) {
640
+ return j(this, e2, t4, false, n3);
641
+ }, s.prototype.copy = function(e2, t4, n3, r2) {
642
+ if (!s.isBuffer(e2)) throw new TypeError("argument should be a Buffer");
643
+ if (n3 || (n3 = 0), r2 || 0 === r2 || (r2 = this.length), t4 >= e2.length && (t4 = e2.length), t4 || (t4 = 0), 0 < r2 && r2 < n3 && (r2 = n3), r2 === n3) return 0;
644
+ if (0 === e2.length || 0 === this.length) return 0;
645
+ if (0 > t4) throw new RangeError("targetStart out of bounds");
646
+ if (0 > n3 || n3 >= this.length) throw new RangeError("Index out of range");
647
+ if (0 > r2) throw new RangeError("sourceEnd out of bounds");
648
+ r2 > this.length && (r2 = this.length), e2.length - t4 < r2 - n3 && (r2 = e2.length - t4 + n3);
649
+ var a = r2 - n3;
650
+ if (this === e2 && "function" == typeof Uint8Array.prototype.copyWithin) this.copyWithin(t4, n3, r2);
651
+ else if (this === e2 && n3 < t4 && t4 < r2) for (var o2 = a - 1; 0 <= o2; --o2) e2[o2 + t4] = this[o2 + n3];
652
+ else Uint8Array.prototype.set.call(e2, this.subarray(n3, r2), t4);
653
+ return a;
654
+ }, s.prototype.fill = function(e2, t4, n3, r2) {
655
+ if ("string" == typeof e2) {
656
+ if ("string" == typeof t4 ? (r2 = t4, t4 = 0, n3 = this.length) : "string" == typeof n3 && (r2 = n3, n3 = this.length), void 0 !== r2 && "string" != typeof r2) throw new TypeError("encoding must be a string");
657
+ if ("string" == typeof r2 && !s.isEncoding(r2)) throw new TypeError("Unknown encoding: " + r2);
658
+ if (1 === e2.length) {
659
+ var a = e2.charCodeAt(0);
660
+ ("utf8" === r2 && 128 > a || "latin1" === r2) && (e2 = a);
661
+ }
662
+ } else "number" == typeof e2 && (e2 &= 255);
663
+ if (0 > t4 || this.length < t4 || this.length < n3) throw new RangeError("Out of range index");
664
+ if (n3 <= t4) return this;
665
+ t4 >>>= 0, n3 = n3 === void 0 ? this.length : n3 >>> 0, e2 || (e2 = 0);
666
+ var o2;
667
+ if ("number" == typeof e2) for (o2 = t4; o2 < n3; ++o2) this[o2] = e2;
668
+ else {
669
+ var d2 = s.isBuffer(e2) ? e2 : s.from(e2, r2), l2 = d2.length;
670
+ if (0 === l2) throw new TypeError('The value "' + e2 + '" is invalid for argument "value"');
671
+ for (o2 = 0; o2 < n3 - t4; ++o2) this[o2 + t4] = d2[o2 % l2];
672
+ }
673
+ return this;
674
+ };
675
+ var Q = /[^+/0-9A-Za-z-_]/g;
676
+ }).call(this);
677
+ }).call(this, e("buffer").Buffer);
678
+ }, { "base64-js": 1, buffer: 3, ieee754: 9 }], 4: [function(e, t2, n2) {
679
+ (function(a) {
680
+ (function() {
681
+ function r2() {
682
+ let e2;
683
+ try {
684
+ e2 = n2.storage.getItem("debug");
685
+ } catch (e3) {
686
+ }
687
+ return !e2 && "undefined" != typeof a && "env" in a && (e2 = a.env.DEBUG), e2;
688
+ }
689
+ n2.formatArgs = function(e2) {
690
+ if (e2[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + e2[0] + (this.useColors ? "%c " : " ") + "+" + t2.exports.humanize(this.diff), !this.useColors) return;
691
+ const n3 = "color: " + this.color;
692
+ e2.splice(1, 0, n3, "color: inherit");
693
+ let r3 = 0, a2 = 0;
694
+ e2[0].replace(/%[a-zA-Z%]/g, (e3) => {
695
+ "%%" === e3 || (r3++, "%c" === e3 && (a2 = r3));
696
+ }), e2.splice(a2, 0, n3);
697
+ }, n2.save = function(e2) {
698
+ try {
699
+ e2 ? n2.storage.setItem("debug", e2) : n2.storage.removeItem("debug");
700
+ } catch (e3) {
701
+ }
702
+ }, n2.load = r2, n2.useColors = function() {
703
+ return !!("undefined" != typeof window && window.process && ("renderer" === window.process.type || window.process.__nwjs)) || !("undefined" != typeof navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) && ("undefined" != typeof document && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || "undefined" != typeof window && window.console && (window.console.firebug || window.console.exception && window.console.table) || "undefined" != typeof navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && 31 <= parseInt(RegExp.$1, 10) || "undefined" != typeof navigator && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
704
+ }, n2.storage = (function() {
705
+ try {
706
+ return localStorage;
707
+ } catch (e2) {
708
+ }
709
+ })(), n2.destroy = /* @__PURE__ */ (() => {
710
+ let e2 = false;
711
+ return () => {
712
+ e2 || (e2 = true, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."));
713
+ };
714
+ })(), n2.colors = ["#0000CC", "#0000FF", "#0033CC", "#0033FF", "#0066CC", "#0066FF", "#0099CC", "#0099FF", "#00CC00", "#00CC33", "#00CC66", "#00CC99", "#00CCCC", "#00CCFF", "#3300CC", "#3300FF", "#3333CC", "#3333FF", "#3366CC", "#3366FF", "#3399CC", "#3399FF", "#33CC00", "#33CC33", "#33CC66", "#33CC99", "#33CCCC", "#33CCFF", "#6600CC", "#6600FF", "#6633CC", "#6633FF", "#66CC00", "#66CC33", "#9900CC", "#9900FF", "#9933CC", "#9933FF", "#99CC00", "#99CC33", "#CC0000", "#CC0033", "#CC0066", "#CC0099", "#CC00CC", "#CC00FF", "#CC3300", "#CC3333", "#CC3366", "#CC3399", "#CC33CC", "#CC33FF", "#CC6600", "#CC6633", "#CC9900", "#CC9933", "#CCCC00", "#CCCC33", "#FF0000", "#FF0033", "#FF0066", "#FF0099", "#FF00CC", "#FF00FF", "#FF3300", "#FF3333", "#FF3366", "#FF3399", "#FF33CC", "#FF33FF", "#FF6600", "#FF6633", "#FF9900", "#FF9933", "#FFCC00", "#FFCC33"], n2.log = console.debug || console.log || (() => {
715
+ }), t2.exports = e("./common")(n2);
716
+ const { formatters: o } = t2.exports;
717
+ o.j = function(e2) {
718
+ try {
719
+ return JSON.stringify(e2);
720
+ } catch (e3) {
721
+ return "[UnexpectedJSONParseError]: " + e3.message;
722
+ }
723
+ };
724
+ }).call(this);
725
+ }).call(this, e("_process"));
726
+ }, { "./common": 5, _process: 12 }], 5: [function(e, t2) {
727
+ t2.exports = function(t3) {
728
+ function r2(e2) {
729
+ function t4(...e3) {
730
+ if (!t4.enabled) return;
731
+ const a2 = t4, o3 = +/* @__PURE__ */ new Date(), i = o3 - (n2 || o3);
732
+ a2.diff = i, a2.prev = n2, a2.curr = o3, n2 = o3, e3[0] = r2.coerce(e3[0]), "string" != typeof e3[0] && e3.unshift("%O");
733
+ let d = 0;
734
+ e3[0] = e3[0].replace(/%([a-zA-Z%])/g, (t5, n3) => {
735
+ if ("%%" === t5) return "%";
736
+ d++;
737
+ const o4 = r2.formatters[n3];
738
+ if ("function" == typeof o4) {
739
+ const n4 = e3[d];
740
+ t5 = o4.call(a2, n4), e3.splice(d, 1), d--;
741
+ }
742
+ return t5;
743
+ }), r2.formatArgs.call(a2, e3);
744
+ const s = a2.log || r2.log;
745
+ s.apply(a2, e3);
746
+ }
747
+ let n2, o2 = null;
748
+ return t4.namespace = e2, t4.useColors = r2.useColors(), t4.color = r2.selectColor(e2), t4.extend = a, t4.destroy = r2.destroy, Object.defineProperty(t4, "enabled", { enumerable: true, configurable: false, get: () => null === o2 ? r2.enabled(e2) : o2, set: (e3) => {
749
+ o2 = e3;
750
+ } }), "function" == typeof r2.init && r2.init(t4), t4;
751
+ }
752
+ function a(e2, t4) {
753
+ const n2 = r2(this.namespace + ("undefined" == typeof t4 ? ":" : t4) + e2);
754
+ return n2.log = this.log, n2;
755
+ }
756
+ function o(e2) {
757
+ return e2.toString().substring(2, e2.toString().length - 2).replace(/\.\*\?$/, "*");
758
+ }
759
+ return r2.debug = r2, r2.default = r2, r2.coerce = function(e2) {
760
+ return e2 instanceof Error ? e2.stack || e2.message : e2;
761
+ }, r2.disable = function() {
762
+ const e2 = [...r2.names.map(o), ...r2.skips.map(o).map((e3) => "-" + e3)].join(",");
763
+ return r2.enable(""), e2;
764
+ }, r2.enable = function(e2) {
765
+ r2.save(e2), r2.names = [], r2.skips = [];
766
+ let t4;
767
+ const n2 = ("string" == typeof e2 ? e2 : "").split(/[\s,]+/), a2 = n2.length;
768
+ for (t4 = 0; t4 < a2; t4++) n2[t4] && (e2 = n2[t4].replace(/\*/g, ".*?"), "-" === e2[0] ? r2.skips.push(new RegExp("^" + e2.substr(1) + "$")) : r2.names.push(new RegExp("^" + e2 + "$")));
769
+ }, r2.enabled = function(e2) {
770
+ if ("*" === e2[e2.length - 1]) return true;
771
+ let t4, n2;
772
+ for (t4 = 0, n2 = r2.skips.length; t4 < n2; t4++) if (r2.skips[t4].test(e2)) return false;
773
+ for (t4 = 0, n2 = r2.names.length; t4 < n2; t4++) if (r2.names[t4].test(e2)) return true;
774
+ return false;
775
+ }, r2.humanize = e("ms"), r2.destroy = function() {
776
+ console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
777
+ }, Object.keys(t3).forEach((e2) => {
778
+ r2[e2] = t3[e2];
779
+ }), r2.names = [], r2.skips = [], r2.formatters = {}, r2.selectColor = function(e2) {
780
+ let t4 = 0;
781
+ for (let n2 = 0; n2 < e2.length; n2++) t4 = (t4 << 5) - t4 + e2.charCodeAt(n2), t4 |= 0;
782
+ return r2.colors[n(t4) % r2.colors.length];
783
+ }, r2.enable(r2.load()), r2;
784
+ };
785
+ }, { ms: 11 }], 6: [function(e, t2) {
786
+ function n2(e2, t3) {
787
+ for (const n3 in t3) Object.defineProperty(e2, n3, { value: t3[n3], enumerable: true, configurable: true });
788
+ return e2;
789
+ }
790
+ t2.exports = function(e2, t3, r2) {
791
+ if (!e2 || "string" == typeof e2) throw new TypeError("Please pass an Error to err-code");
792
+ r2 || (r2 = {}), "object" == typeof t3 && (r2 = t3, t3 = ""), t3 && (r2.code = t3);
793
+ try {
794
+ return n2(e2, r2);
795
+ } catch (t4) {
796
+ r2.message = e2.message, r2.stack = e2.stack;
797
+ const a = function() {
798
+ };
799
+ a.prototype = Object.create(Object.getPrototypeOf(e2));
800
+ const o = n2(new a(), r2);
801
+ return o;
802
+ }
803
+ };
804
+ }, {}], 7: [function(e, t2) {
805
+ function n2(e2) {
806
+ console && console.warn && console.warn(e2);
807
+ }
808
+ function r2() {
809
+ r2.init.call(this);
810
+ }
811
+ function a(e2) {
812
+ if ("function" != typeof e2) throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof e2);
813
+ }
814
+ function o(e2) {
815
+ return void 0 === e2._maxListeners ? r2.defaultMaxListeners : e2._maxListeners;
816
+ }
817
+ function i(e2, t3, r3, i2) {
818
+ var d2, s2, l2;
819
+ if (a(r3), s2 = e2._events, void 0 === s2 ? (s2 = e2._events = /* @__PURE__ */ Object.create(null), e2._eventsCount = 0) : (void 0 !== s2.newListener && (e2.emit("newListener", t3, r3.listener ? r3.listener : r3), s2 = e2._events), l2 = s2[t3]), void 0 === l2) l2 = s2[t3] = r3, ++e2._eventsCount;
820
+ else if ("function" == typeof l2 ? l2 = s2[t3] = i2 ? [r3, l2] : [l2, r3] : i2 ? l2.unshift(r3) : l2.push(r3), d2 = o(e2), 0 < d2 && l2.length > d2 && !l2.warned) {
821
+ l2.warned = true;
822
+ var c2 = new Error("Possible EventEmitter memory leak detected. " + l2.length + " " + (t3 + " listeners added. Use emitter.setMaxListeners() to increase limit"));
823
+ c2.name = "MaxListenersExceededWarning", c2.emitter = e2, c2.type = t3, c2.count = l2.length, n2(c2);
824
+ }
825
+ return e2;
826
+ }
827
+ function d() {
828
+ if (!this.fired) return this.target.removeListener(this.type, this.wrapFn), this.fired = true, 0 === arguments.length ? this.listener.call(this.target) : this.listener.apply(this.target, arguments);
829
+ }
830
+ function s(e2, t3, n3) {
831
+ var r3 = { fired: false, wrapFn: void 0, target: e2, type: t3, listener: n3 }, a2 = d.bind(r3);
832
+ return a2.listener = n3, r3.wrapFn = a2, a2;
833
+ }
834
+ function l(e2, t3, n3) {
835
+ var r3 = e2._events;
836
+ if (r3 === void 0) return [];
837
+ var a2 = r3[t3];
838
+ return void 0 === a2 ? [] : "function" == typeof a2 ? n3 ? [a2.listener || a2] : [a2] : n3 ? f(a2) : u(a2, a2.length);
839
+ }
840
+ function c(e2) {
841
+ var t3 = this._events;
842
+ if (t3 !== void 0) {
843
+ var n3 = t3[e2];
844
+ if ("function" == typeof n3) return 1;
845
+ if (void 0 !== n3) return n3.length;
846
+ }
847
+ return 0;
848
+ }
849
+ function u(e2, t3) {
850
+ for (var n3 = Array(t3), r3 = 0; r3 < t3; ++r3) n3[r3] = e2[r3];
851
+ return n3;
852
+ }
853
+ function p(e2, t3) {
854
+ for (; t3 + 1 < e2.length; t3++) e2[t3] = e2[t3 + 1];
855
+ e2.pop();
856
+ }
857
+ function f(e2) {
858
+ for (var t3 = Array(e2.length), n3 = 0; n3 < t3.length; ++n3) t3[n3] = e2[n3].listener || e2[n3];
859
+ return t3;
860
+ }
861
+ function g(e2, t3, n3) {
862
+ "function" == typeof e2.on && _(e2, "error", t3, n3);
863
+ }
864
+ function _(e2, t3, n3, r3) {
865
+ if ("function" == typeof e2.on) r3.once ? e2.once(t3, n3) : e2.on(t3, n3);
866
+ else if ("function" == typeof e2.addEventListener) e2.addEventListener(t3, function a2(o2) {
867
+ r3.once && e2.removeEventListener(t3, a2), n3(o2);
868
+ });
869
+ else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof e2);
870
+ }
871
+ var h, m = "object" == typeof Reflect ? Reflect : null, b = m && "function" == typeof m.apply ? m.apply : function(e2, t3, n3) {
872
+ return Function.prototype.apply.call(e2, t3, n3);
873
+ };
874
+ h = m && "function" == typeof m.ownKeys ? m.ownKeys : Object.getOwnPropertySymbols ? function(e2) {
875
+ return Object.getOwnPropertyNames(e2).concat(Object.getOwnPropertySymbols(e2));
876
+ } : function(e2) {
877
+ return Object.getOwnPropertyNames(e2);
878
+ };
879
+ var y = Number.isNaN || function(e2) {
880
+ return e2 !== e2;
881
+ };
882
+ t2.exports = r2, t2.exports.once = function(e2, t3) {
883
+ return new Promise(function(n3, r3) {
884
+ function a2(n4) {
885
+ e2.removeListener(t3, o2), r3(n4);
886
+ }
887
+ function o2() {
888
+ "function" == typeof e2.removeListener && e2.removeListener("error", a2), n3([].slice.call(arguments));
889
+ }
890
+ _(e2, t3, o2, { once: true }), "error" !== t3 && g(e2, a2, { once: true });
891
+ });
892
+ }, r2.EventEmitter = r2, r2.prototype._events = void 0, r2.prototype._eventsCount = 0, r2.prototype._maxListeners = void 0;
893
+ var C = 10;
894
+ Object.defineProperty(r2, "defaultMaxListeners", { enumerable: true, get: function() {
895
+ return C;
896
+ }, set: function(e2) {
897
+ if ("number" != typeof e2 || 0 > e2 || y(e2)) throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + e2 + ".");
898
+ C = e2;
899
+ } }), r2.init = function() {
900
+ (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
901
+ }, r2.prototype.setMaxListeners = function(e2) {
902
+ if ("number" != typeof e2 || 0 > e2 || y(e2)) throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + e2 + ".");
903
+ return this._maxListeners = e2, this;
904
+ }, r2.prototype.getMaxListeners = function() {
905
+ return o(this);
906
+ }, r2.prototype.emit = function(e2) {
907
+ for (var t3 = [], n3 = 1; n3 < arguments.length; n3++) t3.push(arguments[n3]);
908
+ var r3 = "error" === e2, a2 = this._events;
909
+ if (a2 !== void 0) r3 = r3 && a2.error === void 0;
910
+ else if (!r3) return false;
911
+ if (r3) {
912
+ var o2;
913
+ if (0 < t3.length && (o2 = t3[0]), o2 instanceof Error) throw o2;
914
+ var d2 = new Error("Unhandled error." + (o2 ? " (" + o2.message + ")" : ""));
915
+ throw d2.context = o2, d2;
916
+ }
917
+ var s2 = a2[e2];
918
+ if (s2 === void 0) return false;
919
+ if ("function" == typeof s2) b(s2, this, t3);
920
+ else for (var l2 = s2.length, c2 = u(s2, l2), n3 = 0; n3 < l2; ++n3) b(c2[n3], this, t3);
921
+ return true;
922
+ }, r2.prototype.addListener = function(e2, t3) {
923
+ return i(this, e2, t3, false);
924
+ }, r2.prototype.on = r2.prototype.addListener, r2.prototype.prependListener = function(e2, t3) {
925
+ return i(this, e2, t3, true);
926
+ }, r2.prototype.once = function(e2, t3) {
927
+ return a(t3), this.on(e2, s(this, e2, t3)), this;
928
+ }, r2.prototype.prependOnceListener = function(e2, t3) {
929
+ return a(t3), this.prependListener(e2, s(this, e2, t3)), this;
930
+ }, r2.prototype.removeListener = function(e2, t3) {
931
+ var n3, r3, o2, d2, s2;
932
+ if (a(t3), r3 = this._events, void 0 === r3) return this;
933
+ if (n3 = r3[e2], void 0 === n3) return this;
934
+ if (n3 === t3 || n3.listener === t3) 0 == --this._eventsCount ? this._events = /* @__PURE__ */ Object.create(null) : (delete r3[e2], r3.removeListener && this.emit("removeListener", e2, n3.listener || t3));
935
+ else if ("function" != typeof n3) {
936
+ for (o2 = -1, d2 = n3.length - 1; 0 <= d2; d2--) if (n3[d2] === t3 || n3[d2].listener === t3) {
937
+ s2 = n3[d2].listener, o2 = d2;
938
+ break;
939
+ }
940
+ if (0 > o2) return this;
941
+ 0 === o2 ? n3.shift() : p(n3, o2), 1 === n3.length && (r3[e2] = n3[0]), void 0 !== r3.removeListener && this.emit("removeListener", e2, s2 || t3);
942
+ }
943
+ return this;
944
+ }, r2.prototype.off = r2.prototype.removeListener, r2.prototype.removeAllListeners = function(e2) {
945
+ var t3, n3, r3;
946
+ if (n3 = this._events, void 0 === n3) return this;
947
+ if (void 0 === n3.removeListener) return 0 === arguments.length ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : void 0 !== n3[e2] && (0 == --this._eventsCount ? this._events = /* @__PURE__ */ Object.create(null) : delete n3[e2]), this;
948
+ if (0 === arguments.length) {
949
+ var a2, o2 = Object.keys(n3);
950
+ for (r3 = 0; r3 < o2.length; ++r3) a2 = o2[r3], "removeListener" !== a2 && this.removeAllListeners(a2);
951
+ return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this;
952
+ }
953
+ if (t3 = n3[e2], "function" == typeof t3) this.removeListener(e2, t3);
954
+ else if (void 0 !== t3) for (r3 = t3.length - 1; 0 <= r3; r3--) this.removeListener(e2, t3[r3]);
955
+ return this;
956
+ }, r2.prototype.listeners = function(e2) {
957
+ return l(this, e2, true);
958
+ }, r2.prototype.rawListeners = function(e2) {
959
+ return l(this, e2, false);
960
+ }, r2.listenerCount = function(e2, t3) {
961
+ return "function" == typeof e2.listenerCount ? e2.listenerCount(t3) : c.call(e2, t3);
962
+ }, r2.prototype.listenerCount = c, r2.prototype.eventNames = function() {
963
+ return 0 < this._eventsCount ? h(this._events) : [];
964
+ };
965
+ }, {}], 8: [function(e, t2) {
966
+ t2.exports = function() {
967
+ if ("undefined" == typeof globalThis) return null;
968
+ var e2 = { RTCPeerConnection: globalThis.RTCPeerConnection || globalThis.mozRTCPeerConnection || globalThis.webkitRTCPeerConnection, RTCSessionDescription: globalThis.RTCSessionDescription || globalThis.mozRTCSessionDescription || globalThis.webkitRTCSessionDescription, RTCIceCandidate: globalThis.RTCIceCandidate || globalThis.mozRTCIceCandidate || globalThis.webkitRTCIceCandidate };
969
+ return e2.RTCPeerConnection ? e2 : null;
970
+ };
971
+ }, {}], 9: [function(e, a, o) {
972
+ o.read = function(t2, n2, a2, o2, l) {
973
+ var c, u, p = 8 * l - o2 - 1, f = (1 << p) - 1, g = f >> 1, _ = -7, h = a2 ? l - 1 : 0, b = a2 ? -1 : 1, d = t2[n2 + h];
974
+ for (h += b, c = d & (1 << -_) - 1, d >>= -_, _ += p; 0 < _; c = 256 * c + t2[n2 + h], h += b, _ -= 8) ;
975
+ for (u = c & (1 << -_) - 1, c >>= -_, _ += o2; 0 < _; u = 256 * u + t2[n2 + h], h += b, _ -= 8) ;
976
+ if (0 === c) c = 1 - g;
977
+ else {
978
+ if (c === f) return u ? NaN : (d ? -1 : 1) * (1 / 0);
979
+ u += r(2, o2), c -= g;
980
+ }
981
+ return (d ? -1 : 1) * u * r(2, c - o2);
982
+ }, o.write = function(a2, o2, l, u, p, f) {
983
+ var h, b, y, g = Math.LN2, _ = Math.log, C = 8 * f - p - 1, R = (1 << C) - 1, E = R >> 1, w = 23 === p ? r(2, -24) - r(2, -77) : 0, S = u ? 0 : f - 1, T = u ? 1 : -1, d = 0 > o2 || 0 === o2 && 0 > 1 / o2 ? 1 : 0;
984
+ for (o2 = n(o2), isNaN(o2) || o2 === 1 / 0 ? (b = isNaN(o2) ? 1 : 0, h = R) : (h = t(_(o2) / g), 1 > o2 * (y = r(2, -h)) && (h--, y *= 2), o2 += 1 <= h + E ? w / y : w * r(2, 1 - E), 2 <= o2 * y && (h++, y /= 2), h + E >= R ? (b = 0, h = R) : 1 <= h + E ? (b = (o2 * y - 1) * r(2, p), h += E) : (b = o2 * r(2, E - 1) * r(2, p), h = 0)); 8 <= p; a2[l + S] = 255 & b, S += T, b /= 256, p -= 8) ;
985
+ for (h = h << p | b, C += p; 0 < C; a2[l + S] = 255 & h, S += T, h /= 256, C -= 8) ;
986
+ a2[l + S - T] |= 128 * d;
987
+ };
988
+ }, {}], 10: [function(e, t2) {
989
+ t2.exports = "function" == typeof Object.create ? function(e2, t3) {
990
+ t3 && (e2.super_ = t3, e2.prototype = Object.create(t3.prototype, { constructor: { value: e2, enumerable: false, writable: true, configurable: true } }));
991
+ } : function(e2, t3) {
992
+ if (t3) {
993
+ e2.super_ = t3;
994
+ var n2 = function() {
995
+ };
996
+ n2.prototype = t3.prototype, e2.prototype = new n2(), e2.prototype.constructor = e2;
997
+ }
998
+ };
999
+ }, {}], 11: [function(e, t2) {
1000
+ var r2 = Math.round;
1001
+ function a(e2) {
1002
+ if (e2 += "", !(100 < e2.length)) {
1003
+ var t3 = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e2);
1004
+ if (t3) {
1005
+ var r3 = parseFloat(t3[1]), n2 = (t3[2] || "ms").toLowerCase();
1006
+ return "years" === n2 || "year" === n2 || "yrs" === n2 || "yr" === n2 || "y" === n2 ? 315576e5 * r3 : "weeks" === n2 || "week" === n2 || "w" === n2 ? 6048e5 * r3 : "days" === n2 || "day" === n2 || "d" === n2 ? 864e5 * r3 : "hours" === n2 || "hour" === n2 || "hrs" === n2 || "hr" === n2 || "h" === n2 ? 36e5 * r3 : "minutes" === n2 || "minute" === n2 || "mins" === n2 || "min" === n2 || "m" === n2 ? 6e4 * r3 : "seconds" === n2 || "second" === n2 || "secs" === n2 || "sec" === n2 || "s" === n2 ? 1e3 * r3 : "milliseconds" === n2 || "millisecond" === n2 || "msecs" === n2 || "msec" === n2 || "ms" === n2 ? r3 : void 0;
1007
+ }
1008
+ }
1009
+ }
1010
+ function o(e2) {
1011
+ var t3 = n(e2);
1012
+ return 864e5 <= t3 ? r2(e2 / 864e5) + "d" : 36e5 <= t3 ? r2(e2 / 36e5) + "h" : 6e4 <= t3 ? r2(e2 / 6e4) + "m" : 1e3 <= t3 ? r2(e2 / 1e3) + "s" : e2 + "ms";
1013
+ }
1014
+ function i(e2) {
1015
+ var t3 = n(e2);
1016
+ return 864e5 <= t3 ? s(e2, t3, 864e5, "day") : 36e5 <= t3 ? s(e2, t3, 36e5, "hour") : 6e4 <= t3 ? s(e2, t3, 6e4, "minute") : 1e3 <= t3 ? s(e2, t3, 1e3, "second") : e2 + " ms";
1017
+ }
1018
+ function s(e2, t3, a2, n2) {
1019
+ return r2(e2 / a2) + " " + n2 + (t3 >= 1.5 * a2 ? "s" : "");
1020
+ }
1021
+ t2.exports = function(e2, t3) {
1022
+ t3 = t3 || {};
1023
+ var n2 = typeof e2;
1024
+ if ("string" == n2 && 0 < e2.length) return a(e2);
1025
+ if ("number" === n2 && isFinite(e2)) return t3.long ? i(e2) : o(e2);
1026
+ throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(e2));
1027
+ };
1028
+ }, {}], 12: [function(e, t2) {
1029
+ function n2() {
1030
+ throw new Error("setTimeout has not been defined");
1031
+ }
1032
+ function r2() {
1033
+ throw new Error("clearTimeout has not been defined");
1034
+ }
1035
+ function a(t3) {
1036
+ if (c === setTimeout) return setTimeout(t3, 0);
1037
+ if ((c === n2 || !c) && setTimeout) return c = setTimeout, setTimeout(t3, 0);
1038
+ try {
1039
+ return c(t3, 0);
1040
+ } catch (n3) {
1041
+ try {
1042
+ return c.call(null, t3, 0);
1043
+ } catch (n4) {
1044
+ return c.call(this, t3, 0);
1045
+ }
1046
+ }
1047
+ }
1048
+ function o(t3) {
1049
+ if (u === clearTimeout) return clearTimeout(t3);
1050
+ if ((u === r2 || !u) && clearTimeout) return u = clearTimeout, clearTimeout(t3);
1051
+ try {
1052
+ return u(t3);
1053
+ } catch (n3) {
1054
+ try {
1055
+ return u.call(null, t3);
1056
+ } catch (n4) {
1057
+ return u.call(this, t3);
1058
+ }
1059
+ }
1060
+ }
1061
+ function i() {
1062
+ _ && f && (_ = false, f.length ? g = f.concat(g) : h = -1, g.length && d());
1063
+ }
1064
+ function d() {
1065
+ if (!_) {
1066
+ var e2 = a(i);
1067
+ _ = true;
1068
+ for (var t3 = g.length; t3; ) {
1069
+ for (f = g, g = []; ++h < t3; ) f && f[h].run();
1070
+ h = -1, t3 = g.length;
1071
+ }
1072
+ f = null, _ = false, o(e2);
1073
+ }
1074
+ }
1075
+ function s(e2, t3) {
1076
+ this.fun = e2, this.array = t3;
1077
+ }
1078
+ function l() {
1079
+ }
1080
+ var c, u, p = t2.exports = {};
1081
+ (function() {
1082
+ try {
1083
+ c = "function" == typeof setTimeout ? setTimeout : n2;
1084
+ } catch (t3) {
1085
+ c = n2;
1086
+ }
1087
+ try {
1088
+ u = "function" == typeof clearTimeout ? clearTimeout : r2;
1089
+ } catch (t3) {
1090
+ u = r2;
1091
+ }
1092
+ })();
1093
+ var f, g = [], _ = false, h = -1;
1094
+ p.nextTick = function(e2) {
1095
+ var t3 = Array(arguments.length - 1);
1096
+ if (1 < arguments.length) for (var n3 = 1; n3 < arguments.length; n3++) t3[n3 - 1] = arguments[n3];
1097
+ g.push(new s(e2, t3)), 1 !== g.length || _ || a(d);
1098
+ }, s.prototype.run = function() {
1099
+ this.fun.apply(null, this.array);
1100
+ }, p.title = "browser", p.browser = true, p.env = {}, p.argv = [], p.version = "", p.versions = {}, p.on = l, p.addListener = l, p.once = l, p.off = l, p.removeListener = l, p.removeAllListeners = l, p.emit = l, p.prependListener = l, p.prependOnceListener = l, p.listeners = function() {
1101
+ return [];
1102
+ }, p.binding = function() {
1103
+ throw new Error("process.binding is not supported");
1104
+ }, p.cwd = function() {
1105
+ return "/";
1106
+ }, p.chdir = function() {
1107
+ throw new Error("process.chdir is not supported");
1108
+ }, p.umask = function() {
1109
+ return 0;
1110
+ };
1111
+ }, {}], 13: [function(e, t2) {
1112
+ (function(e2) {
1113
+ (function() {
1114
+ let n2;
1115
+ t2.exports = "function" == typeof queueMicrotask ? queueMicrotask.bind("undefined" == typeof window ? e2 : window) : (e3) => (n2 || (n2 = Promise.resolve())).then(e3).catch((e4) => setTimeout(() => {
1116
+ throw e4;
1117
+ }, 0));
1118
+ }).call(this);
1119
+ }).call(this, "undefined" == typeof global ? "undefined" == typeof self ? "undefined" == typeof window ? {} : window : self : global);
1120
+ }, {}], 14: [function(e, t2) {
1121
+ (function(n2, r2) {
1122
+ (function() {
1123
+ var a = e("safe-buffer").Buffer, o = r2.crypto || r2.msCrypto;
1124
+ t2.exports = o && o.getRandomValues ? function(e2, t3) {
1125
+ if (e2 > 4294967295) throw new RangeError("requested too many random bytes");
1126
+ var r3 = a.allocUnsafe(e2);
1127
+ if (0 < e2) if (65536 < e2) for (var i = 0; i < e2; i += 65536) o.getRandomValues(r3.slice(i, i + 65536));
1128
+ else o.getRandomValues(r3);
1129
+ return "function" == typeof t3 ? n2.nextTick(function() {
1130
+ t3(null, r3);
1131
+ }) : r3;
1132
+ } : function() {
1133
+ throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11");
1134
+ };
1135
+ }).call(this);
1136
+ }).call(this, e("_process"), "undefined" == typeof global ? "undefined" == typeof self ? "undefined" == typeof window ? {} : window : self : global);
1137
+ }, { _process: 12, "safe-buffer": 30 }], 15: [function(e, t2) {
1138
+ function n2(e2, t3) {
1139
+ e2.prototype = Object.create(t3.prototype), e2.prototype.constructor = e2, e2.__proto__ = t3;
1140
+ }
1141
+ function r2(e2, t3, r3) {
1142
+ function a2(e3, n3, r4) {
1143
+ return "string" == typeof t3 ? t3 : t3(e3, n3, r4);
1144
+ }
1145
+ r3 || (r3 = Error);
1146
+ var o2 = (function(e3) {
1147
+ function t4(t5, n3, r4) {
1148
+ return e3.call(this, a2(t5, n3, r4)) || this;
1149
+ }
1150
+ return n2(t4, e3), t4;
1151
+ })(r3);
1152
+ o2.prototype.name = r3.name, o2.prototype.code = e2, s[e2] = o2;
1153
+ }
1154
+ function a(e2, t3) {
1155
+ if (Array.isArray(e2)) {
1156
+ var n3 = e2.length;
1157
+ return e2 = e2.map(function(e3) {
1158
+ return e3 + "";
1159
+ }), 2 < n3 ? "one of ".concat(t3, " ").concat(e2.slice(0, n3 - 1).join(", "), ", or ") + e2[n3 - 1] : 2 === n3 ? "one of ".concat(t3, " ").concat(e2[0], " or ").concat(e2[1]) : "of ".concat(t3, " ").concat(e2[0]);
1160
+ }
1161
+ return "of ".concat(t3, " ").concat(e2 + "");
1162
+ }
1163
+ function o(e2, t3, n3) {
1164
+ return e2.substr(0 , t3.length) === t3;
1165
+ }
1166
+ function i(e2, t3, n3) {
1167
+ return (void 0 === n3 || n3 > e2.length) && (n3 = e2.length), e2.substring(n3 - t3.length, n3) === t3;
1168
+ }
1169
+ function d(e2, t3, n3) {
1170
+ return "number" != typeof n3 && (n3 = 0), !(n3 + t3.length > e2.length) && -1 !== e2.indexOf(t3, n3);
1171
+ }
1172
+ var s = {};
1173
+ r2("ERR_INVALID_OPT_VALUE", function(e2, t3) {
1174
+ return 'The value "' + t3 + '" is invalid for option "' + e2 + '"';
1175
+ }, TypeError), r2("ERR_INVALID_ARG_TYPE", function(e2, t3, n3) {
1176
+ var r3;
1177
+ "string" == typeof t3 && o(t3, "not ") ? (r3 = "must not be", t3 = t3.replace(/^not /, "")) : r3 = "must be";
1178
+ var s2;
1179
+ if (i(e2, " argument")) s2 = "The ".concat(e2, " ").concat(r3, " ").concat(a(t3, "type"));
1180
+ else {
1181
+ var l = d(e2, ".") ? "property" : "argument";
1182
+ s2 = 'The "'.concat(e2, '" ').concat(l, " ").concat(r3, " ").concat(a(t3, "type"));
1183
+ }
1184
+ return s2 += ". Received type ".concat(typeof n3), s2;
1185
+ }, TypeError), r2("ERR_STREAM_PUSH_AFTER_EOF", "stream.push() after EOF"), r2("ERR_METHOD_NOT_IMPLEMENTED", function(e2) {
1186
+ return "The " + e2 + " method is not implemented";
1187
+ }), r2("ERR_STREAM_PREMATURE_CLOSE", "Premature close"), r2("ERR_STREAM_DESTROYED", function(e2) {
1188
+ return "Cannot call " + e2 + " after a stream was destroyed";
1189
+ }), r2("ERR_MULTIPLE_CALLBACK", "Callback called multiple times"), r2("ERR_STREAM_CANNOT_PIPE", "Cannot pipe, not readable"), r2("ERR_STREAM_WRITE_AFTER_END", "write after end"), r2("ERR_STREAM_NULL_VALUES", "May not write null values to stream", TypeError), r2("ERR_UNKNOWN_ENCODING", function(e2) {
1190
+ return "Unknown encoding: " + e2;
1191
+ }, TypeError), r2("ERR_STREAM_UNSHIFT_AFTER_END_EVENT", "stream.unshift() after end event"), t2.exports.codes = s;
1192
+ }, {}], 16: [function(e, t2) {
1193
+ (function(n2) {
1194
+ (function() {
1195
+ function r2(e2) {
1196
+ return this instanceof r2 ? void (d.call(this, e2), s.call(this, e2), this.allowHalfOpen = true, e2 && (false === e2.readable && (this.readable = false), false === e2.writable && (this.writable = false), false === e2.allowHalfOpen && (this.allowHalfOpen = false, this.once("end", a)))) : new r2(e2);
1197
+ }
1198
+ function a() {
1199
+ this._writableState.ended || n2.nextTick(o, this);
1200
+ }
1201
+ function o(e2) {
1202
+ e2.end();
1203
+ }
1204
+ var i = Object.keys || function(e2) {
1205
+ var t3 = [];
1206
+ for (var n3 in e2) t3.push(n3);
1207
+ return t3;
1208
+ };
1209
+ t2.exports = r2;
1210
+ var d = e("./_stream_readable"), s = e("./_stream_writable");
1211
+ e("inherits")(r2, d);
1212
+ for (var l, c = i(s.prototype), u = 0; u < c.length; u++) l = c[u], r2.prototype[l] || (r2.prototype[l] = s.prototype[l]);
1213
+ Object.defineProperty(r2.prototype, "writableHighWaterMark", { enumerable: false, get: function() {
1214
+ return this._writableState.highWaterMark;
1215
+ } }), Object.defineProperty(r2.prototype, "writableBuffer", { enumerable: false, get: function() {
1216
+ return this._writableState && this._writableState.getBuffer();
1217
+ } }), Object.defineProperty(r2.prototype, "writableLength", { enumerable: false, get: function() {
1218
+ return this._writableState.length;
1219
+ } }), Object.defineProperty(r2.prototype, "destroyed", { enumerable: false, get: function() {
1220
+ return void 0 !== this._readableState && void 0 !== this._writableState && this._readableState.destroyed && this._writableState.destroyed;
1221
+ }, set: function(e2) {
1222
+ void 0 === this._readableState || void 0 === this._writableState || (this._readableState.destroyed = e2, this._writableState.destroyed = e2);
1223
+ } });
1224
+ }).call(this);
1225
+ }).call(this, e("_process"));
1226
+ }, { "./_stream_readable": 18, "./_stream_writable": 20, _process: 12, inherits: 10 }], 17: [function(e, t2) {
1227
+ function n2(e2) {
1228
+ return this instanceof n2 ? void r2.call(this, e2) : new n2(e2);
1229
+ }
1230
+ t2.exports = n2;
1231
+ var r2 = e("./_stream_transform");
1232
+ e("inherits")(n2, r2), n2.prototype._transform = function(e2, t3, n3) {
1233
+ n3(null, e2);
1234
+ };
1235
+ }, { "./_stream_transform": 19, inherits: 10 }], 18: [function(e, t2) {
1236
+ (function(n2, r2) {
1237
+ (function() {
1238
+ function a(e2) {
1239
+ return P.from(e2);
1240
+ }
1241
+ function o(e2) {
1242
+ return P.isBuffer(e2) || e2 instanceof M;
1243
+ }
1244
+ function i(e2, t3, n3) {
1245
+ return "function" == typeof e2.prependListener ? e2.prependListener(t3, n3) : void (e2._events && e2._events[t3] ? Array.isArray(e2._events[t3]) ? e2._events[t3].unshift(n3) : e2._events[t3] = [n3, e2._events[t3]] : e2.on(t3, n3));
1246
+ }
1247
+ function d(t3, n3, r3) {
1248
+ A = A || e("./_stream_duplex"), t3 = t3 || {}, "boolean" != typeof r3 && (r3 = n3 instanceof A), this.objectMode = !!t3.objectMode, r3 && (this.objectMode = this.objectMode || !!t3.readableObjectMode), this.highWaterMark = H(this, t3, "readableHighWaterMark", r3), this.buffer = new j(), this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.ended = false, this.endEmitted = false, this.reading = false, this.sync = true, this.needReadable = false, this.emittedReadable = false, this.readableListening = false, this.resumeScheduled = false, this.paused = true, this.emitClose = false !== t3.emitClose, this.autoDestroy = !!t3.autoDestroy, this.destroyed = false, this.defaultEncoding = t3.defaultEncoding || "utf8", this.awaitDrain = 0, this.readingMore = false, this.decoder = null, this.encoding = null, t3.encoding && (!F && (F = e("string_decoder/").StringDecoder), this.decoder = new F(t3.encoding), this.encoding = t3.encoding);
1249
+ }
1250
+ function s(t3) {
1251
+ if (A = A || e("./_stream_duplex"), !(this instanceof s)) return new s(t3);
1252
+ var n3 = this instanceof A;
1253
+ this._readableState = new d(t3, this, n3), this.readable = true, t3 && ("function" == typeof t3.read && (this._read = t3.read), "function" == typeof t3.destroy && (this._destroy = t3.destroy)), I.call(this);
1254
+ }
1255
+ function l(e2, t3, n3, r3, o2) {
1256
+ x("readableAddChunk", t3);
1257
+ var i2 = e2._readableState;
1258
+ if (null === t3) i2.reading = false, g(e2, i2);
1259
+ else {
1260
+ var d2;
1261
+ if (o2 || (d2 = u(i2, t3)), d2) X(e2, d2);
1262
+ else if (!(i2.objectMode || t3 && 0 < t3.length)) r3 || (i2.reading = false, m(e2, i2));
1263
+ else if ("string" == typeof t3 || i2.objectMode || Object.getPrototypeOf(t3) === P.prototype || (t3 = a(t3)), r3) i2.endEmitted ? X(e2, new K()) : c(e2, i2, t3, true);
1264
+ else if (i2.ended) X(e2, new z());
1265
+ else {
1266
+ if (i2.destroyed) return false;
1267
+ i2.reading = false, i2.decoder && !n3 ? (t3 = i2.decoder.write(t3), i2.objectMode || 0 !== t3.length ? c(e2, i2, t3, false) : m(e2, i2)) : c(e2, i2, t3, false);
1268
+ }
1269
+ }
1270
+ return !i2.ended && (i2.length < i2.highWaterMark || 0 === i2.length);
1271
+ }
1272
+ function c(e2, t3, n3, r3) {
1273
+ t3.flowing && 0 === t3.length && !t3.sync ? (t3.awaitDrain = 0, e2.emit("data", n3)) : (t3.length += t3.objectMode ? 1 : n3.length, r3 ? t3.buffer.unshift(n3) : t3.buffer.push(n3), t3.needReadable && _(e2)), m(e2, t3);
1274
+ }
1275
+ function u(e2, t3) {
1276
+ var n3;
1277
+ return o(t3) || "string" == typeof t3 || void 0 === t3 || e2.objectMode || (n3 = new V("chunk", ["string", "Buffer", "Uint8Array"], t3)), n3;
1278
+ }
1279
+ function p(e2) {
1280
+ return 1073741824 <= e2 ? e2 = 1073741824 : (e2--, e2 |= e2 >>> 1, e2 |= e2 >>> 2, e2 |= e2 >>> 4, e2 |= e2 >>> 8, e2 |= e2 >>> 16, e2++), e2;
1281
+ }
1282
+ function f(e2, t3) {
1283
+ return 0 >= e2 || 0 === t3.length && t3.ended ? 0 : t3.objectMode ? 1 : e2 === e2 ? (e2 > t3.highWaterMark && (t3.highWaterMark = p(e2)), e2 <= t3.length ? e2 : t3.ended ? t3.length : (t3.needReadable = true, 0)) : t3.flowing && t3.length ? t3.buffer.head.data.length : t3.length;
1284
+ }
1285
+ function g(e2, t3) {
1286
+ if (x("onEofChunk"), !t3.ended) {
1287
+ if (t3.decoder) {
1288
+ var n3 = t3.decoder.end();
1289
+ n3 && n3.length && (t3.buffer.push(n3), t3.length += t3.objectMode ? 1 : n3.length);
1290
+ }
1291
+ t3.ended = true, t3.sync ? _(e2) : (t3.needReadable = false, !t3.emittedReadable && (t3.emittedReadable = true, h(e2)));
1292
+ }
1293
+ }
1294
+ function _(e2) {
1295
+ var t3 = e2._readableState;
1296
+ x("emitReadable", t3.needReadable, t3.emittedReadable), t3.needReadable = false, t3.emittedReadable || (x("emitReadable", t3.flowing), t3.emittedReadable = true, n2.nextTick(h, e2));
1297
+ }
1298
+ function h(e2) {
1299
+ var t3 = e2._readableState;
1300
+ x("emitReadable_", t3.destroyed, t3.length, t3.ended), !t3.destroyed && (t3.length || t3.ended) && (e2.emit("readable"), t3.emittedReadable = false), t3.needReadable = !t3.flowing && !t3.ended && t3.length <= t3.highWaterMark, S(e2);
1301
+ }
1302
+ function m(e2, t3) {
1303
+ t3.readingMore || (t3.readingMore = true, n2.nextTick(b, e2, t3));
1304
+ }
1305
+ function b(e2, t3) {
1306
+ for (; !t3.reading && !t3.ended && (t3.length < t3.highWaterMark || t3.flowing && 0 === t3.length); ) {
1307
+ var n3 = t3.length;
1308
+ if (x("maybeReadMore read 0"), e2.read(0), n3 === t3.length) break;
1309
+ }
1310
+ t3.readingMore = false;
1311
+ }
1312
+ function y(e2) {
1313
+ return function() {
1314
+ var t3 = e2._readableState;
1315
+ x("pipeOnDrain", t3.awaitDrain), t3.awaitDrain && t3.awaitDrain--, 0 === t3.awaitDrain && D(e2, "data") && (t3.flowing = true, S(e2));
1316
+ };
1317
+ }
1318
+ function C(e2) {
1319
+ var t3 = e2._readableState;
1320
+ t3.readableListening = 0 < e2.listenerCount("readable"), t3.resumeScheduled && !t3.paused ? t3.flowing = true : 0 < e2.listenerCount("data") && e2.resume();
1321
+ }
1322
+ function R(e2) {
1323
+ x("readable nexttick read 0"), e2.read(0);
1324
+ }
1325
+ function E(e2, t3) {
1326
+ t3.resumeScheduled || (t3.resumeScheduled = true, n2.nextTick(w, e2, t3));
1327
+ }
1328
+ function w(e2, t3) {
1329
+ x("resume", t3.reading), t3.reading || e2.read(0), t3.resumeScheduled = false, e2.emit("resume"), S(e2), t3.flowing && !t3.reading && e2.read(0);
1330
+ }
1331
+ function S(e2) {
1332
+ var t3 = e2._readableState;
1333
+ for (x("flow", t3.flowing); t3.flowing && null !== e2.read(); ) ;
1334
+ }
1335
+ function T(e2, t3) {
1336
+ if (0 === t3.length) return null;
1337
+ var n3;
1338
+ return t3.objectMode ? n3 = t3.buffer.shift() : !e2 || e2 >= t3.length ? (n3 = t3.decoder ? t3.buffer.join("") : 1 === t3.buffer.length ? t3.buffer.first() : t3.buffer.concat(t3.length), t3.buffer.clear()) : n3 = t3.buffer.consume(e2, t3.decoder), n3;
1339
+ }
1340
+ function v(e2) {
1341
+ var t3 = e2._readableState;
1342
+ x("endReadable", t3.endEmitted), t3.endEmitted || (t3.ended = true, n2.nextTick(k, t3, e2));
1343
+ }
1344
+ function k(e2, t3) {
1345
+ if (x("endReadableNT", e2.endEmitted, e2.length), !e2.endEmitted && 0 === e2.length && (e2.endEmitted = true, t3.readable = false, t3.emit("end"), e2.autoDestroy)) {
1346
+ var n3 = t3._writableState;
1347
+ (!n3 || n3.autoDestroy && n3.finished) && t3.destroy();
1348
+ }
1349
+ }
1350
+ function L(e2, t3) {
1351
+ for (var n3 = 0, r3 = e2.length; n3 < r3; n3++) if (e2[n3] === t3) return n3;
1352
+ return -1;
1353
+ }
1354
+ t2.exports = s;
1355
+ var A;
1356
+ s.ReadableState = d;
1357
+ var x; e("events").EventEmitter; var D = function(e2, t3) {
1358
+ return e2.listeners(t3).length;
1359
+ }, I = e("./internal/streams/stream"), P = e("buffer").Buffer, M = r2.Uint8Array || function() {
1360
+ }, O = e("util");
1361
+ x = O && O.debuglog ? O.debuglog("stream") : function() {
1362
+ };
1363
+ var F, B, U, j = e("./internal/streams/buffer_list"), q = e("./internal/streams/destroy"), W = e("./internal/streams/state"), H = W.getHighWaterMark, Y2 = e("../errors").codes, V = Y2.ERR_INVALID_ARG_TYPE, z = Y2.ERR_STREAM_PUSH_AFTER_EOF, G = Y2.ERR_METHOD_NOT_IMPLEMENTED, K = Y2.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
1364
+ e("inherits")(s, I);
1365
+ var X = q.errorOrDestroy, $2 = ["error", "close", "destroy", "pause", "resume"];
1366
+ Object.defineProperty(s.prototype, "destroyed", { enumerable: false, get: function() {
1367
+ return void 0 !== this._readableState && this._readableState.destroyed;
1368
+ }, set: function(e2) {
1369
+ this._readableState && (this._readableState.destroyed = e2);
1370
+ } }), s.prototype.destroy = q.destroy, s.prototype._undestroy = q.undestroy, s.prototype._destroy = function(e2, t3) {
1371
+ t3(e2);
1372
+ }, s.prototype.push = function(e2, t3) {
1373
+ var n3, r3 = this._readableState;
1374
+ return r3.objectMode ? n3 = true : "string" == typeof e2 && (t3 = t3 || r3.defaultEncoding, t3 !== r3.encoding && (e2 = P.from(e2, t3), t3 = ""), n3 = true), l(this, e2, t3, false, n3);
1375
+ }, s.prototype.unshift = function(e2) {
1376
+ return l(this, e2, null, true, false);
1377
+ }, s.prototype.isPaused = function() {
1378
+ return false === this._readableState.flowing;
1379
+ }, s.prototype.setEncoding = function(t3) {
1380
+ F || (F = e("string_decoder/").StringDecoder);
1381
+ var n3 = new F(t3);
1382
+ this._readableState.decoder = n3, this._readableState.encoding = this._readableState.decoder.encoding;
1383
+ for (var r3 = this._readableState.buffer.head, a2 = ""; null !== r3; ) a2 += n3.write(r3.data), r3 = r3.next;
1384
+ return this._readableState.buffer.clear(), "" !== a2 && this._readableState.buffer.push(a2), this._readableState.length = a2.length, this;
1385
+ };
1386
+ s.prototype.read = function(e2) {
1387
+ x("read", e2), e2 = parseInt(e2, 10);
1388
+ var t3 = this._readableState, r3 = e2;
1389
+ if (0 !== e2 && (t3.emittedReadable = false), 0 === e2 && t3.needReadable && ((0 === t3.highWaterMark ? 0 < t3.length : t3.length >= t3.highWaterMark) || t3.ended)) return x("read: emitReadable", t3.length, t3.ended), 0 === t3.length && t3.ended ? v(this) : _(this), null;
1390
+ if (e2 = f(e2, t3), 0 === e2 && t3.ended) return 0 === t3.length && v(this), null;
1391
+ var a2 = t3.needReadable;
1392
+ x("need readable", a2), (0 === t3.length || t3.length - e2 < t3.highWaterMark) && (a2 = true, x("length less than watermark", a2)), t3.ended || t3.reading ? (a2 = false, x("reading or ended", a2)) : a2 && (x("do read"), t3.reading = true, t3.sync = true, 0 === t3.length && (t3.needReadable = true), this._read(t3.highWaterMark), t3.sync = false, !t3.reading && (e2 = f(r3, t3)));
1393
+ var o2;
1394
+ return o2 = 0 < e2 ? T(e2, t3) : null, null === o2 ? (t3.needReadable = t3.length <= t3.highWaterMark, e2 = 0) : (t3.length -= e2, t3.awaitDrain = 0), 0 === t3.length && (!t3.ended && (t3.needReadable = true), r3 !== e2 && t3.ended && v(this)), null !== o2 && this.emit("data", o2), o2;
1395
+ }, s.prototype._read = function() {
1396
+ X(this, new G("_read()"));
1397
+ }, s.prototype.pipe = function(e2, t3) {
1398
+ function r3(e3, t4) {
1399
+ x("onunpipe"), e3 === p2 && t4 && false === t4.hasUnpiped && (t4.hasUnpiped = true, o2());
1400
+ }
1401
+ function a2() {
1402
+ x("onend"), e2.end();
1403
+ }
1404
+ function o2() {
1405
+ x("cleanup"), e2.removeListener("close", l2), e2.removeListener("finish", c2), e2.removeListener("drain", h2), e2.removeListener("error", s2), e2.removeListener("unpipe", r3), p2.removeListener("end", a2), p2.removeListener("end", u2), p2.removeListener("data", d2), m2 = true, f2.awaitDrain && (!e2._writableState || e2._writableState.needDrain) && h2();
1406
+ }
1407
+ function d2(t4) {
1408
+ x("ondata");
1409
+ var n3 = e2.write(t4);
1410
+ x("dest.write", n3), false === n3 && ((1 === f2.pipesCount && f2.pipes === e2 || 1 < f2.pipesCount && -1 !== L(f2.pipes, e2)) && !m2 && (x("false write response, pause", f2.awaitDrain), f2.awaitDrain++), p2.pause());
1411
+ }
1412
+ function s2(t4) {
1413
+ x("onerror", t4), u2(), e2.removeListener("error", s2), 0 === D(e2, "error") && X(e2, t4);
1414
+ }
1415
+ function l2() {
1416
+ e2.removeListener("finish", c2), u2();
1417
+ }
1418
+ function c2() {
1419
+ x("onfinish"), e2.removeListener("close", l2), u2();
1420
+ }
1421
+ function u2() {
1422
+ x("unpipe"), p2.unpipe(e2);
1423
+ }
1424
+ var p2 = this, f2 = this._readableState;
1425
+ switch (f2.pipesCount) {
1426
+ case 0:
1427
+ f2.pipes = e2;
1428
+ break;
1429
+ case 1:
1430
+ f2.pipes = [f2.pipes, e2];
1431
+ break;
1432
+ default:
1433
+ f2.pipes.push(e2);
1434
+ }
1435
+ f2.pipesCount += 1, x("pipe count=%d opts=%j", f2.pipesCount, t3);
1436
+ var g2 = (!t3 || false !== t3.end) && e2 !== n2.stdout && e2 !== n2.stderr, _2 = g2 ? a2 : u2;
1437
+ f2.endEmitted ? n2.nextTick(_2) : p2.once("end", _2), e2.on("unpipe", r3);
1438
+ var h2 = y(p2);
1439
+ e2.on("drain", h2);
1440
+ var m2 = false;
1441
+ return p2.on("data", d2), i(e2, "error", s2), e2.once("close", l2), e2.once("finish", c2), e2.emit("pipe", p2), f2.flowing || (x("pipe resume"), p2.resume()), e2;
1442
+ }, s.prototype.unpipe = function(e2) {
1443
+ var t3 = this._readableState, n3 = { hasUnpiped: false };
1444
+ if (0 === t3.pipesCount) return this;
1445
+ if (1 === t3.pipesCount) return e2 && e2 !== t3.pipes ? this : (e2 || (e2 = t3.pipes), t3.pipes = null, t3.pipesCount = 0, t3.flowing = false, e2 && e2.emit("unpipe", this, n3), this);
1446
+ if (!e2) {
1447
+ var r3 = t3.pipes, a2 = t3.pipesCount;
1448
+ t3.pipes = null, t3.pipesCount = 0, t3.flowing = false;
1449
+ for (var o2 = 0; o2 < a2; o2++) r3[o2].emit("unpipe", this, { hasUnpiped: false });
1450
+ return this;
1451
+ }
1452
+ var d2 = L(t3.pipes, e2);
1453
+ return -1 === d2 ? this : (t3.pipes.splice(d2, 1), t3.pipesCount -= 1, 1 === t3.pipesCount && (t3.pipes = t3.pipes[0]), e2.emit("unpipe", this, n3), this);
1454
+ }, s.prototype.on = function(e2, t3) {
1455
+ var r3 = I.prototype.on.call(this, e2, t3), a2 = this._readableState;
1456
+ return "data" === e2 ? (a2.readableListening = 0 < this.listenerCount("readable"), false !== a2.flowing && this.resume()) : "readable" == e2 && !a2.endEmitted && !a2.readableListening && (a2.readableListening = a2.needReadable = true, a2.flowing = false, a2.emittedReadable = false, x("on readable", a2.length, a2.reading), a2.length ? _(this) : !a2.reading && n2.nextTick(R, this)), r3;
1457
+ }, s.prototype.addListener = s.prototype.on, s.prototype.removeListener = function(e2, t3) {
1458
+ var r3 = I.prototype.removeListener.call(this, e2, t3);
1459
+ return "readable" === e2 && n2.nextTick(C, this), r3;
1460
+ }, s.prototype.removeAllListeners = function(e2) {
1461
+ var t3 = I.prototype.removeAllListeners.apply(this, arguments);
1462
+ return ("readable" === e2 || void 0 === e2) && n2.nextTick(C, this), t3;
1463
+ }, s.prototype.resume = function() {
1464
+ var e2 = this._readableState;
1465
+ return e2.flowing || (x("resume"), e2.flowing = !e2.readableListening, E(this, e2)), e2.paused = false, this;
1466
+ }, s.prototype.pause = function() {
1467
+ return x("call pause flowing=%j", this._readableState.flowing), false !== this._readableState.flowing && (x("pause"), this._readableState.flowing = false, this.emit("pause")), this._readableState.paused = true, this;
1468
+ }, s.prototype.wrap = function(e2) {
1469
+ var t3 = this, r3 = this._readableState, a2 = false;
1470
+ for (var o2 in e2.on("end", function() {
1471
+ if (x("wrapped end"), r3.decoder && !r3.ended) {
1472
+ var e3 = r3.decoder.end();
1473
+ e3 && e3.length && t3.push(e3);
1474
+ }
1475
+ t3.push(null);
1476
+ }), e2.on("data", function(n3) {
1477
+ if ((x("wrapped data"), r3.decoder && (n3 = r3.decoder.write(n3)), !(r3.objectMode && (null === n3 || void 0 === n3))) && (r3.objectMode || n3 && n3.length)) {
1478
+ var o3 = t3.push(n3);
1479
+ o3 || (a2 = true, e2.pause());
1480
+ }
1481
+ }), e2) void 0 === this[o2] && "function" == typeof e2[o2] && (this[o2] = /* @__PURE__ */ (function(t4) {
1482
+ return function() {
1483
+ return e2[t4].apply(e2, arguments);
1484
+ };
1485
+ })(o2));
1486
+ for (var i2 = 0; i2 < $2.length; i2++) e2.on($2[i2], this.emit.bind(this, $2[i2]));
1487
+ return this._read = function(t4) {
1488
+ x("wrapped _read", t4), a2 && (a2 = false, e2.resume());
1489
+ }, this;
1490
+ }, "function" == typeof Symbol && (s.prototype[Symbol.asyncIterator] = function() {
1491
+ return void 0 === B && (B = e("./internal/streams/async_iterator")), B(this);
1492
+ }), Object.defineProperty(s.prototype, "readableHighWaterMark", { enumerable: false, get: function() {
1493
+ return this._readableState.highWaterMark;
1494
+ } }), Object.defineProperty(s.prototype, "readableBuffer", { enumerable: false, get: function() {
1495
+ return this._readableState && this._readableState.buffer;
1496
+ } }), Object.defineProperty(s.prototype, "readableFlowing", { enumerable: false, get: function() {
1497
+ return this._readableState.flowing;
1498
+ }, set: function(e2) {
1499
+ this._readableState && (this._readableState.flowing = e2);
1500
+ } }), s._fromList = T, Object.defineProperty(s.prototype, "readableLength", { enumerable: false, get: function() {
1501
+ return this._readableState.length;
1502
+ } }), "function" == typeof Symbol && (s.from = function(t3, n3) {
1503
+ return void 0 === U && (U = e("./internal/streams/from")), U(s, t3, n3);
1504
+ });
1505
+ }).call(this);
1506
+ }).call(this, e("_process"), "undefined" == typeof global ? "undefined" == typeof self ? "undefined" == typeof window ? {} : window : self : global);
1507
+ }, { "../errors": 15, "./_stream_duplex": 16, "./internal/streams/async_iterator": 21, "./internal/streams/buffer_list": 22, "./internal/streams/destroy": 23, "./internal/streams/from": 25, "./internal/streams/state": 27, "./internal/streams/stream": 28, _process: 12, buffer: 3, events: 7, inherits: 10, "string_decoder/": 31, util: 2 }], 19: [function(e, t2) {
1508
+ function n2(e2, t3) {
1509
+ var n3 = this._transformState;
1510
+ n3.transforming = false;
1511
+ var r3 = n3.writecb;
1512
+ if (null === r3) return this.emit("error", new s());
1513
+ n3.writechunk = null, n3.writecb = null, null != t3 && this.push(t3), r3(e2);
1514
+ var a2 = this._readableState;
1515
+ a2.reading = false, (a2.needReadable || a2.length < a2.highWaterMark) && this._read(a2.highWaterMark);
1516
+ }
1517
+ function r2(e2) {
1518
+ return this instanceof r2 ? void (u.call(this, e2), this._transformState = { afterTransform: n2.bind(this), needTransform: false, transforming: false, writecb: null, writechunk: null, writeencoding: null }, this._readableState.needReadable = true, this._readableState.sync = false, e2 && ("function" == typeof e2.transform && (this._transform = e2.transform), "function" == typeof e2.flush && (this._flush = e2.flush)), this.on("prefinish", a)) : new r2(e2);
1519
+ }
1520
+ function a() {
1521
+ var e2 = this;
1522
+ "function" != typeof this._flush || this._readableState.destroyed ? o(this, null, null) : this._flush(function(t3, n3) {
1523
+ o(e2, t3, n3);
1524
+ });
1525
+ }
1526
+ function o(e2, t3, n3) {
1527
+ if (t3) return e2.emit("error", t3);
1528
+ if (null != n3 && e2.push(n3), e2._writableState.length) throw new c();
1529
+ if (e2._transformState.transforming) throw new l();
1530
+ return e2.push(null);
1531
+ }
1532
+ t2.exports = r2;
1533
+ var i = e("../errors").codes, d = i.ERR_METHOD_NOT_IMPLEMENTED, s = i.ERR_MULTIPLE_CALLBACK, l = i.ERR_TRANSFORM_ALREADY_TRANSFORMING, c = i.ERR_TRANSFORM_WITH_LENGTH_0, u = e("./_stream_duplex");
1534
+ e("inherits")(r2, u), r2.prototype.push = function(e2, t3) {
1535
+ return this._transformState.needTransform = false, u.prototype.push.call(this, e2, t3);
1536
+ }, r2.prototype._transform = function(e2, t3, n3) {
1537
+ n3(new d("_transform()"));
1538
+ }, r2.prototype._write = function(e2, t3, n3) {
1539
+ var r3 = this._transformState;
1540
+ if (r3.writecb = n3, r3.writechunk = e2, r3.writeencoding = t3, !r3.transforming) {
1541
+ var a2 = this._readableState;
1542
+ (r3.needTransform || a2.needReadable || a2.length < a2.highWaterMark) && this._read(a2.highWaterMark);
1543
+ }
1544
+ }, r2.prototype._read = function() {
1545
+ var e2 = this._transformState;
1546
+ null === e2.writechunk || e2.transforming ? e2.needTransform = true : (e2.transforming = true, this._transform(e2.writechunk, e2.writeencoding, e2.afterTransform));
1547
+ }, r2.prototype._destroy = function(e2, t3) {
1548
+ u.prototype._destroy.call(this, e2, function(e3) {
1549
+ t3(e3);
1550
+ });
1551
+ };
1552
+ }, { "../errors": 15, "./_stream_duplex": 16, inherits: 10 }], 20: [function(e, t2) {
1553
+ (function(n2, r2) {
1554
+ (function() {
1555
+ function a(e2) {
1556
+ var t3 = this;
1557
+ this.next = null, this.entry = null, this.finish = function() {
1558
+ v(t3, e2);
1559
+ };
1560
+ }
1561
+ function o(e2) {
1562
+ return x.from(e2);
1563
+ }
1564
+ function i(e2) {
1565
+ return x.isBuffer(e2) || e2 instanceof N;
1566
+ }
1567
+ function d() {
1568
+ }
1569
+ function s(t3, n3, r3) {
1570
+ k = k || e("./_stream_duplex"), t3 = t3 || {}, "boolean" != typeof r3 && (r3 = n3 instanceof k), this.objectMode = !!t3.objectMode, r3 && (this.objectMode = this.objectMode || !!t3.writableObjectMode), this.highWaterMark = P(this, t3, "writableHighWaterMark", r3), this.finalCalled = false, this.needDrain = false, this.ending = false, this.ended = false, this.finished = false, this.destroyed = false;
1571
+ var o2 = false === t3.decodeStrings;
1572
+ this.decodeStrings = !o2, this.defaultEncoding = t3.defaultEncoding || "utf8", this.length = 0, this.writing = false, this.corked = 0, this.sync = true, this.bufferProcessing = false, this.onwrite = function(e2) {
1573
+ m(n3, e2);
1574
+ }, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = false, this.errorEmitted = false, this.emitClose = false !== t3.emitClose, this.autoDestroy = !!t3.autoDestroy, this.bufferedRequestCount = 0, this.corkedRequestsFree = new a(this);
1575
+ }
1576
+ function l(t3) {
1577
+ k = k || e("./_stream_duplex");
1578
+ var n3 = this instanceof k;
1579
+ return n3 || V.call(l, this) ? void (this._writableState = new s(t3, this, n3), this.writable = true, t3 && ("function" == typeof t3.write && (this._write = t3.write), "function" == typeof t3.writev && (this._writev = t3.writev), "function" == typeof t3.destroy && (this._destroy = t3.destroy), "function" == typeof t3.final && (this._final = t3.final)), A.call(this)) : new l(t3);
1580
+ }
1581
+ function c(e2, t3) {
1582
+ var r3 = new W();
1583
+ Y2(e2, r3), n2.nextTick(t3, r3);
1584
+ }
1585
+ function u(e2, t3, r3, a2) {
1586
+ var o2;
1587
+ return null === r3 ? o2 = new q() : "string" != typeof r3 && !t3.objectMode && (o2 = new O("chunk", ["string", "Buffer"], r3)), !o2 || (Y2(e2, o2), n2.nextTick(a2, o2), false);
1588
+ }
1589
+ function p(e2, t3, n3) {
1590
+ return e2.objectMode || false === e2.decodeStrings || "string" != typeof t3 || (t3 = x.from(t3, n3)), t3;
1591
+ }
1592
+ function f(e2, t3, n3, r3, a2, o2) {
1593
+ if (!n3) {
1594
+ var i2 = p(t3, r3, a2);
1595
+ r3 !== i2 && (n3 = true, a2 = "buffer", r3 = i2);
1596
+ }
1597
+ var d2 = t3.objectMode ? 1 : r3.length;
1598
+ t3.length += d2;
1599
+ var s2 = t3.length < t3.highWaterMark;
1600
+ if (s2 || (t3.needDrain = true), t3.writing || t3.corked) {
1601
+ var l2 = t3.lastBufferedRequest;
1602
+ t3.lastBufferedRequest = { chunk: r3, encoding: a2, isBuf: n3, callback: o2, next: null }, l2 ? l2.next = t3.lastBufferedRequest : t3.bufferedRequest = t3.lastBufferedRequest, t3.bufferedRequestCount += 1;
1603
+ } else g(e2, t3, false, d2, r3, a2, o2);
1604
+ return s2;
1605
+ }
1606
+ function g(e2, t3, n3, r3, a2, o2, i2) {
1607
+ t3.writelen = r3, t3.writecb = i2, t3.writing = true, t3.sync = true, t3.destroyed ? t3.onwrite(new j("write")) : n3 ? e2._writev(a2, t3.onwrite) : e2._write(a2, o2, t3.onwrite), t3.sync = false;
1608
+ }
1609
+ function _(e2, t3, r3, a2, o2) {
1610
+ --t3.pendingcb, r3 ? (n2.nextTick(o2, a2), n2.nextTick(S, e2, t3), e2._writableState.errorEmitted = true, Y2(e2, a2)) : (o2(a2), e2._writableState.errorEmitted = true, Y2(e2, a2), S(e2, t3));
1611
+ }
1612
+ function h(e2) {
1613
+ e2.writing = false, e2.writecb = null, e2.length -= e2.writelen, e2.writelen = 0;
1614
+ }
1615
+ function m(e2, t3) {
1616
+ var r3 = e2._writableState, a2 = r3.sync, o2 = r3.writecb;
1617
+ if ("function" != typeof o2) throw new B();
1618
+ if (h(r3), t3) _(e2, r3, a2, t3, o2);
1619
+ else {
1620
+ var i2 = R(r3) || e2.destroyed;
1621
+ i2 || r3.corked || r3.bufferProcessing || !r3.bufferedRequest || C(e2, r3), a2 ? n2.nextTick(b, e2, r3, i2, o2) : b(e2, r3, i2, o2);
1622
+ }
1623
+ }
1624
+ function b(e2, t3, n3, r3) {
1625
+ n3 || y(e2, t3), t3.pendingcb--, r3(), S(e2, t3);
1626
+ }
1627
+ function y(e2, t3) {
1628
+ 0 === t3.length && t3.needDrain && (t3.needDrain = false, e2.emit("drain"));
1629
+ }
1630
+ function C(e2, t3) {
1631
+ t3.bufferProcessing = true;
1632
+ var n3 = t3.bufferedRequest;
1633
+ if (e2._writev && n3 && n3.next) {
1634
+ var r3 = t3.bufferedRequestCount, o2 = Array(r3), i2 = t3.corkedRequestsFree;
1635
+ i2.entry = n3;
1636
+ for (var d2 = 0, s2 = true; n3; ) o2[d2] = n3, n3.isBuf || (s2 = false), n3 = n3.next, d2 += 1;
1637
+ o2.allBuffers = s2, g(e2, t3, true, t3.length, o2, "", i2.finish), t3.pendingcb++, t3.lastBufferedRequest = null, i2.next ? (t3.corkedRequestsFree = i2.next, i2.next = null) : t3.corkedRequestsFree = new a(t3), t3.bufferedRequestCount = 0;
1638
+ } else {
1639
+ for (; n3; ) {
1640
+ var l2 = n3.chunk, c2 = n3.encoding, u2 = n3.callback, p2 = t3.objectMode ? 1 : l2.length;
1641
+ if (g(e2, t3, false, p2, l2, c2, u2), n3 = n3.next, t3.bufferedRequestCount--, t3.writing) break;
1642
+ }
1643
+ null === n3 && (t3.lastBufferedRequest = null);
1644
+ }
1645
+ t3.bufferedRequest = n3, t3.bufferProcessing = false;
1646
+ }
1647
+ function R(e2) {
1648
+ return e2.ending && 0 === e2.length && null === e2.bufferedRequest && !e2.finished && !e2.writing;
1649
+ }
1650
+ function E(e2, t3) {
1651
+ e2._final(function(n3) {
1652
+ t3.pendingcb--, n3 && Y2(e2, n3), t3.prefinished = true, e2.emit("prefinish"), S(e2, t3);
1653
+ });
1654
+ }
1655
+ function w(e2, t3) {
1656
+ t3.prefinished || t3.finalCalled || ("function" != typeof e2._final || t3.destroyed ? (t3.prefinished = true, e2.emit("prefinish")) : (t3.pendingcb++, t3.finalCalled = true, n2.nextTick(E, e2, t3)));
1657
+ }
1658
+ function S(e2, t3) {
1659
+ var n3 = R(t3);
1660
+ if (n3 && (w(e2, t3), 0 === t3.pendingcb && (t3.finished = true, e2.emit("finish"), t3.autoDestroy))) {
1661
+ var r3 = e2._readableState;
1662
+ (!r3 || r3.autoDestroy && r3.endEmitted) && e2.destroy();
1663
+ }
1664
+ return n3;
1665
+ }
1666
+ function T(e2, t3, r3) {
1667
+ t3.ending = true, S(e2, t3), r3 && (t3.finished ? n2.nextTick(r3) : e2.once("finish", r3)), t3.ended = true, e2.writable = false;
1668
+ }
1669
+ function v(e2, t3, n3) {
1670
+ var r3 = e2.entry;
1671
+ for (e2.entry = null; r3; ) {
1672
+ var a2 = r3.callback;
1673
+ t3.pendingcb--, a2(n3), r3 = r3.next;
1674
+ }
1675
+ t3.corkedRequestsFree.next = e2;
1676
+ }
1677
+ t2.exports = l;
1678
+ var k;
1679
+ l.WritableState = s;
1680
+ var L = { deprecate: e("util-deprecate") }, A = e("./internal/streams/stream"), x = e("buffer").Buffer, N = r2.Uint8Array || function() {
1681
+ }, D = e("./internal/streams/destroy"), I = e("./internal/streams/state"), P = I.getHighWaterMark, M = e("../errors").codes, O = M.ERR_INVALID_ARG_TYPE, F = M.ERR_METHOD_NOT_IMPLEMENTED, B = M.ERR_MULTIPLE_CALLBACK, U = M.ERR_STREAM_CANNOT_PIPE, j = M.ERR_STREAM_DESTROYED, q = M.ERR_STREAM_NULL_VALUES, W = M.ERR_STREAM_WRITE_AFTER_END, H = M.ERR_UNKNOWN_ENCODING, Y2 = D.errorOrDestroy;
1682
+ e("inherits")(l, A), s.prototype.getBuffer = function() {
1683
+ for (var e2 = this.bufferedRequest, t3 = []; e2; ) t3.push(e2), e2 = e2.next;
1684
+ return t3;
1685
+ }, (function() {
1686
+ try {
1687
+ Object.defineProperty(s.prototype, "buffer", { get: L.deprecate(function() {
1688
+ return this.getBuffer();
1689
+ }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") });
1690
+ } catch (e2) {
1691
+ }
1692
+ })();
1693
+ var V;
1694
+ "function" == typeof Symbol && Symbol.hasInstance && "function" == typeof Function.prototype[Symbol.hasInstance] ? (V = Function.prototype[Symbol.hasInstance], Object.defineProperty(l, Symbol.hasInstance, { value: function(e2) {
1695
+ return !!V.call(this, e2) || !(this !== l) && e2 && e2._writableState instanceof s;
1696
+ } })) : V = function(e2) {
1697
+ return e2 instanceof this;
1698
+ }, l.prototype.pipe = function() {
1699
+ Y2(this, new U());
1700
+ }, l.prototype.write = function(e2, t3, n3) {
1701
+ var r3 = this._writableState, a2 = false, s2 = !r3.objectMode && i(e2);
1702
+ return s2 && !x.isBuffer(e2) && (e2 = o(e2)), "function" == typeof t3 && (n3 = t3, t3 = null), s2 ? t3 = "buffer" : !t3 && (t3 = r3.defaultEncoding), "function" != typeof n3 && (n3 = d), r3.ending ? c(this, n3) : (s2 || u(this, r3, e2, n3)) && (r3.pendingcb++, a2 = f(this, r3, s2, e2, t3, n3)), a2;
1703
+ }, l.prototype.cork = function() {
1704
+ this._writableState.corked++;
1705
+ }, l.prototype.uncork = function() {
1706
+ var e2 = this._writableState;
1707
+ e2.corked && (e2.corked--, !e2.writing && !e2.corked && !e2.bufferProcessing && e2.bufferedRequest && C(this, e2));
1708
+ }, l.prototype.setDefaultEncoding = function(e2) {
1709
+ if ("string" == typeof e2 && (e2 = e2.toLowerCase()), !(-1 < ["hex", "utf8", "utf-8", "ascii", "binary", "base64", "ucs2", "ucs-2", "utf16le", "utf-16le", "raw"].indexOf((e2 + "").toLowerCase()))) throw new H(e2);
1710
+ return this._writableState.defaultEncoding = e2, this;
1711
+ }, Object.defineProperty(l.prototype, "writableBuffer", { enumerable: false, get: function() {
1712
+ return this._writableState && this._writableState.getBuffer();
1713
+ } }), Object.defineProperty(l.prototype, "writableHighWaterMark", { enumerable: false, get: function() {
1714
+ return this._writableState.highWaterMark;
1715
+ } }), l.prototype._write = function(e2, t3, n3) {
1716
+ n3(new F("_write()"));
1717
+ }, l.prototype._writev = null, l.prototype.end = function(e2, t3, n3) {
1718
+ var r3 = this._writableState;
1719
+ return "function" == typeof e2 ? (n3 = e2, e2 = null, t3 = null) : "function" == typeof t3 && (n3 = t3, t3 = null), null !== e2 && void 0 !== e2 && this.write(e2, t3), r3.corked && (r3.corked = 1, this.uncork()), r3.ending || T(this, r3, n3), this;
1720
+ }, Object.defineProperty(l.prototype, "writableLength", { enumerable: false, get: function() {
1721
+ return this._writableState.length;
1722
+ } }), Object.defineProperty(l.prototype, "destroyed", { enumerable: false, get: function() {
1723
+ return void 0 !== this._writableState && this._writableState.destroyed;
1724
+ }, set: function(e2) {
1725
+ this._writableState && (this._writableState.destroyed = e2);
1726
+ } }), l.prototype.destroy = D.destroy, l.prototype._undestroy = D.undestroy, l.prototype._destroy = function(e2, t3) {
1727
+ t3(e2);
1728
+ };
1729
+ }).call(this);
1730
+ }).call(this, e("_process"), "undefined" == typeof global ? "undefined" == typeof self ? "undefined" == typeof window ? {} : window : self : global);
1731
+ }, { "../errors": 15, "./_stream_duplex": 16, "./internal/streams/destroy": 23, "./internal/streams/state": 27, "./internal/streams/stream": 28, _process: 12, buffer: 3, inherits: 10, "util-deprecate": 32 }], 21: [function(e, t2) {
1732
+ (function(n2) {
1733
+ (function() {
1734
+ function r2(e2, t3, n3) {
1735
+ return t3 in e2 ? Object.defineProperty(e2, t3, { value: n3, enumerable: true, configurable: true, writable: true }) : e2[t3] = n3, e2;
1736
+ }
1737
+ function a(e2, t3) {
1738
+ return { value: e2, done: t3 };
1739
+ }
1740
+ function o(e2) {
1741
+ var t3 = e2[c];
1742
+ if (null !== t3) {
1743
+ var n3 = e2[h].read();
1744
+ null !== n3 && (e2[g] = null, e2[c] = null, e2[u] = null, t3(a(n3, false)));
1745
+ }
1746
+ }
1747
+ function i(e2) {
1748
+ n2.nextTick(o, e2);
1749
+ }
1750
+ function d(e2, t3) {
1751
+ return function(n3, r3) {
1752
+ e2.then(function() {
1753
+ return t3[f] ? void n3(a(void 0, true)) : void t3[_](n3, r3);
1754
+ }, r3);
1755
+ };
1756
+ }
1757
+ var s, l = e("./end-of-stream"), c = /* @__PURE__ */ Symbol("lastResolve"), u = /* @__PURE__ */ Symbol("lastReject"), p = /* @__PURE__ */ Symbol("error"), f = /* @__PURE__ */ Symbol("ended"), g = /* @__PURE__ */ Symbol("lastPromise"), _ = /* @__PURE__ */ Symbol("handlePromise"), h = /* @__PURE__ */ Symbol("stream"), m = Object.getPrototypeOf(function() {
1758
+ }), b = Object.setPrototypeOf((s = { get stream() {
1759
+ return this[h];
1760
+ }, next: function() {
1761
+ var e2 = this, t3 = this[p];
1762
+ if (null !== t3) return Promise.reject(t3);
1763
+ if (this[f]) return Promise.resolve(a(void 0, true));
1764
+ if (this[h].destroyed) return new Promise(function(t4, r4) {
1765
+ n2.nextTick(function() {
1766
+ e2[p] ? r4(e2[p]) : t4(a(void 0, true));
1767
+ });
1768
+ });
1769
+ var r3, o2 = this[g];
1770
+ if (o2) r3 = new Promise(d(o2, this));
1771
+ else {
1772
+ var i2 = this[h].read();
1773
+ if (null !== i2) return Promise.resolve(a(i2, false));
1774
+ r3 = new Promise(this[_]);
1775
+ }
1776
+ return this[g] = r3, r3;
1777
+ } }, r2(s, Symbol.asyncIterator, function() {
1778
+ return this;
1779
+ }), r2(s, "return", function() {
1780
+ var e2 = this;
1781
+ return new Promise(function(t3, n3) {
1782
+ e2[h].destroy(null, function(e3) {
1783
+ return e3 ? void n3(e3) : void t3(a(void 0, true));
1784
+ });
1785
+ });
1786
+ }), s), m);
1787
+ t2.exports = function(e2) {
1788
+ var t3, n3 = Object.create(b, (t3 = {}, r2(t3, h, { value: e2, writable: true }), r2(t3, c, { value: null, writable: true }), r2(t3, u, { value: null, writable: true }), r2(t3, p, { value: null, writable: true }), r2(t3, f, { value: e2._readableState.endEmitted, writable: true }), r2(t3, _, { value: function(e3, t4) {
1789
+ var r3 = n3[h].read();
1790
+ r3 ? (n3[g] = null, n3[c] = null, n3[u] = null, e3(a(r3, false))) : (n3[c] = e3, n3[u] = t4);
1791
+ }, writable: true }), t3));
1792
+ return n3[g] = null, l(e2, function(e3) {
1793
+ if (e3 && "ERR_STREAM_PREMATURE_CLOSE" !== e3.code) {
1794
+ var t4 = n3[u];
1795
+ return null !== t4 && (n3[g] = null, n3[c] = null, n3[u] = null, t4(e3)), void (n3[p] = e3);
1796
+ }
1797
+ var r3 = n3[c];
1798
+ null !== r3 && (n3[g] = null, n3[c] = null, n3[u] = null, r3(a(void 0, true))), n3[f] = true;
1799
+ }), e2.on("readable", i.bind(null, n3)), n3;
1800
+ };
1801
+ }).call(this);
1802
+ }).call(this, e("_process"));
1803
+ }, { "./end-of-stream": 24, _process: 12 }], 22: [function(e, t2) {
1804
+ function n2(e2, t3) {
1805
+ var n3 = Object.keys(e2);
1806
+ if (Object.getOwnPropertySymbols) {
1807
+ var r3 = Object.getOwnPropertySymbols(e2);
1808
+ t3 && (r3 = r3.filter(function(t4) {
1809
+ return Object.getOwnPropertyDescriptor(e2, t4).enumerable;
1810
+ })), n3.push.apply(n3, r3);
1811
+ }
1812
+ return n3;
1813
+ }
1814
+ function r2(e2) {
1815
+ for (var t3, r3 = 1; r3 < arguments.length; r3++) t3 = null == arguments[r3] ? {} : arguments[r3], r3 % 2 ? n2(Object(t3), true).forEach(function(n3) {
1816
+ a(e2, n3, t3[n3]);
1817
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t3)) : n2(Object(t3)).forEach(function(n3) {
1818
+ Object.defineProperty(e2, n3, Object.getOwnPropertyDescriptor(t3, n3));
1819
+ });
1820
+ return e2;
1821
+ }
1822
+ function a(e2, t3, n3) {
1823
+ return t3 in e2 ? Object.defineProperty(e2, t3, { value: n3, enumerable: true, configurable: true, writable: true }) : e2[t3] = n3, e2;
1824
+ }
1825
+ function o(e2, t3) {
1826
+ if (!(e2 instanceof t3)) throw new TypeError("Cannot call a class as a function");
1827
+ }
1828
+ function i(e2, t3) {
1829
+ for (var n3, r3 = 0; r3 < t3.length; r3++) n3 = t3[r3], n3.enumerable = n3.enumerable || false, n3.configurable = true, "value" in n3 && (n3.writable = true), Object.defineProperty(e2, n3.key, n3);
1830
+ }
1831
+ function d(e2, t3, n3) {
1832
+ return t3 && i(e2.prototype, t3), e2;
1833
+ }
1834
+ function s(e2, t3, n3) {
1835
+ u.prototype.copy.call(e2, t3, n3);
1836
+ }
1837
+ var l = e("buffer"), u = l.Buffer, p = e("util"), f = p.inspect, g = f && f.custom || "inspect";
1838
+ t2.exports = (function() {
1839
+ function e2() {
1840
+ o(this, e2), this.head = null, this.tail = null, this.length = 0;
1841
+ }
1842
+ return d(e2, [{ key: "push", value: function(e3) {
1843
+ var t3 = { data: e3, next: null };
1844
+ 0 < this.length ? this.tail.next = t3 : this.head = t3, this.tail = t3, ++this.length;
1845
+ } }, { key: "unshift", value: function(e3) {
1846
+ var t3 = { data: e3, next: this.head };
1847
+ 0 === this.length && (this.tail = t3), this.head = t3, ++this.length;
1848
+ } }, { key: "shift", value: function() {
1849
+ if (0 !== this.length) {
1850
+ var e3 = this.head.data;
1851
+ return this.head = 1 === this.length ? this.tail = null : this.head.next, --this.length, e3;
1852
+ }
1853
+ } }, { key: "clear", value: function() {
1854
+ this.head = this.tail = null, this.length = 0;
1855
+ } }, { key: "join", value: function(e3) {
1856
+ if (0 === this.length) return "";
1857
+ for (var t3 = this.head, n3 = "" + t3.data; t3 = t3.next; ) n3 += e3 + t3.data;
1858
+ return n3;
1859
+ } }, { key: "concat", value: function(e3) {
1860
+ if (0 === this.length) return u.alloc(0);
1861
+ for (var t3 = u.allocUnsafe(e3 >>> 0), n3 = this.head, r3 = 0; n3; ) s(n3.data, t3, r3), r3 += n3.data.length, n3 = n3.next;
1862
+ return t3;
1863
+ } }, { key: "consume", value: function(e3, t3) {
1864
+ var n3;
1865
+ return e3 < this.head.data.length ? (n3 = this.head.data.slice(0, e3), this.head.data = this.head.data.slice(e3)) : e3 === this.head.data.length ? n3 = this.shift() : n3 = t3 ? this._getString(e3) : this._getBuffer(e3), n3;
1866
+ } }, { key: "first", value: function() {
1867
+ return this.head.data;
1868
+ } }, { key: "_getString", value: function(e3) {
1869
+ var t3 = this.head, r3 = 1, a2 = t3.data;
1870
+ for (e3 -= a2.length; t3 = t3.next; ) {
1871
+ var o2 = t3.data, i2 = e3 > o2.length ? o2.length : e3;
1872
+ if (a2 += i2 === o2.length ? o2 : o2.slice(0, e3), e3 -= i2, 0 === e3) {
1873
+ i2 === o2.length ? (++r3, this.head = t3.next ? t3.next : this.tail = null) : (this.head = t3, t3.data = o2.slice(i2));
1874
+ break;
1875
+ }
1876
+ ++r3;
1877
+ }
1878
+ return this.length -= r3, a2;
1879
+ } }, { key: "_getBuffer", value: function(e3) {
1880
+ var t3 = u.allocUnsafe(e3), r3 = this.head, a2 = 1;
1881
+ for (r3.data.copy(t3), e3 -= r3.data.length; r3 = r3.next; ) {
1882
+ var o2 = r3.data, i2 = e3 > o2.length ? o2.length : e3;
1883
+ if (o2.copy(t3, t3.length - e3, 0, i2), e3 -= i2, 0 === e3) {
1884
+ i2 === o2.length ? (++a2, this.head = r3.next ? r3.next : this.tail = null) : (this.head = r3, r3.data = o2.slice(i2));
1885
+ break;
1886
+ }
1887
+ ++a2;
1888
+ }
1889
+ return this.length -= a2, t3;
1890
+ } }, { key: g, value: function(e3, t3) {
1891
+ return f(this, r2({}, t3, { depth: 0, customInspect: false }));
1892
+ } }]), e2;
1893
+ })();
1894
+ }, { buffer: 3, util: 2 }], 23: [function(e, t2) {
1895
+ (function(e2) {
1896
+ (function() {
1897
+ function n2(e3, t3) {
1898
+ a(e3, t3), r2(e3);
1899
+ }
1900
+ function r2(e3) {
1901
+ e3._writableState && !e3._writableState.emitClose || e3._readableState && !e3._readableState.emitClose || e3.emit("close");
1902
+ }
1903
+ function a(e3, t3) {
1904
+ e3.emit("error", t3);
1905
+ }
1906
+ t2.exports = { destroy: function(t3, o) {
1907
+ var i = this, d = this._readableState && this._readableState.destroyed, s = this._writableState && this._writableState.destroyed;
1908
+ return d || s ? (o ? o(t3) : t3 && (this._writableState ? !this._writableState.errorEmitted && (this._writableState.errorEmitted = true, e2.nextTick(a, this, t3)) : e2.nextTick(a, this, t3)), this) : (this._readableState && (this._readableState.destroyed = true), this._writableState && (this._writableState.destroyed = true), this._destroy(t3 || null, function(t4) {
1909
+ !o && t4 ? i._writableState ? i._writableState.errorEmitted ? e2.nextTick(r2, i) : (i._writableState.errorEmitted = true, e2.nextTick(n2, i, t4)) : e2.nextTick(n2, i, t4) : o ? (e2.nextTick(r2, i), o(t4)) : e2.nextTick(r2, i);
1910
+ }), this);
1911
+ }, undestroy: function() {
1912
+ this._readableState && (this._readableState.destroyed = false, this._readableState.reading = false, this._readableState.ended = false, this._readableState.endEmitted = false), this._writableState && (this._writableState.destroyed = false, this._writableState.ended = false, this._writableState.ending = false, this._writableState.finalCalled = false, this._writableState.prefinished = false, this._writableState.finished = false, this._writableState.errorEmitted = false);
1913
+ }, errorOrDestroy: function(e3, t3) {
1914
+ var n3 = e3._readableState, r3 = e3._writableState;
1915
+ n3 && n3.autoDestroy || r3 && r3.autoDestroy ? e3.destroy(t3) : e3.emit("error", t3);
1916
+ } };
1917
+ }).call(this);
1918
+ }).call(this, e("_process"));
1919
+ }, { _process: 12 }], 24: [function(e, t2) {
1920
+ function n2(e2) {
1921
+ var t3 = false;
1922
+ return function() {
1923
+ if (!t3) {
1924
+ t3 = true;
1925
+ for (var n3 = arguments.length, r3 = Array(n3), a2 = 0; a2 < n3; a2++) r3[a2] = arguments[a2];
1926
+ e2.apply(this, r3);
1927
+ }
1928
+ };
1929
+ }
1930
+ function r2() {
1931
+ }
1932
+ function a(e2) {
1933
+ return e2.setHeader && "function" == typeof e2.abort;
1934
+ }
1935
+ function o(e2, t3, d) {
1936
+ if ("function" == typeof t3) return o(e2, null, t3);
1937
+ t3 || (t3 = {}), d = n2(d || r2);
1938
+ var s = t3.readable || false !== t3.readable && e2.readable, l = t3.writable || false !== t3.writable && e2.writable, c = function() {
1939
+ e2.writable || p();
1940
+ }, u = e2._writableState && e2._writableState.finished, p = function() {
1941
+ l = false, u = true, s || d.call(e2);
1942
+ }, f = e2._readableState && e2._readableState.endEmitted, g = function() {
1943
+ s = false, f = true, l || d.call(e2);
1944
+ }, _ = function(t4) {
1945
+ d.call(e2, t4);
1946
+ }, h = function() {
1947
+ var t4;
1948
+ return s && !f ? (e2._readableState && e2._readableState.ended || (t4 = new i()), d.call(e2, t4)) : l && !u ? (e2._writableState && e2._writableState.ended || (t4 = new i()), d.call(e2, t4)) : void 0;
1949
+ }, m = function() {
1950
+ e2.req.on("finish", p);
1951
+ };
1952
+ return a(e2) ? (e2.on("complete", p), e2.on("abort", h), e2.req ? m() : e2.on("request", m)) : l && !e2._writableState && (e2.on("end", c), e2.on("close", c)), e2.on("end", g), e2.on("finish", p), false !== t3.error && e2.on("error", _), e2.on("close", h), function() {
1953
+ e2.removeListener("complete", p), e2.removeListener("abort", h), e2.removeListener("request", m), e2.req && e2.req.removeListener("finish", p), e2.removeListener("end", c), e2.removeListener("close", c), e2.removeListener("finish", p), e2.removeListener("end", g), e2.removeListener("error", _), e2.removeListener("close", h);
1954
+ };
1955
+ }
1956
+ var i = e("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;
1957
+ t2.exports = o;
1958
+ }, { "../../../errors": 15 }], 25: [function(e, t2) {
1959
+ t2.exports = function() {
1960
+ throw new Error("Readable.from is not available in the browser");
1961
+ };
1962
+ }, {}], 26: [function(e, t2) {
1963
+ function n2(e2) {
1964
+ var t3 = false;
1965
+ return function() {
1966
+ t3 || (t3 = true, e2.apply(void 0, arguments));
1967
+ };
1968
+ }
1969
+ function r2(e2) {
1970
+ if (e2) throw e2;
1971
+ }
1972
+ function a(e2) {
1973
+ return e2.setHeader && "function" == typeof e2.abort;
1974
+ }
1975
+ function o(t3, r3, o2, i2) {
1976
+ i2 = n2(i2);
1977
+ var d2 = false;
1978
+ t3.on("close", function() {
1979
+ d2 = true;
1980
+ }), l === void 0 && (l = e("./end-of-stream")), l(t3, { readable: r3, writable: o2 }, function(e2) {
1981
+ return e2 ? i2(e2) : void (d2 = true, i2());
1982
+ });
1983
+ var s2 = false;
1984
+ return function(e2) {
1985
+ if (!d2) return s2 ? void 0 : (s2 = true, a(t3) ? t3.abort() : "function" == typeof t3.destroy ? t3.destroy() : void i2(e2 || new p("pipe")));
1986
+ };
1987
+ }
1988
+ function i(e2) {
1989
+ e2();
1990
+ }
1991
+ function d(e2, t3) {
1992
+ return e2.pipe(t3);
1993
+ }
1994
+ function s(e2) {
1995
+ return e2.length ? "function" == typeof e2[e2.length - 1] ? e2.pop() : r2 : r2;
1996
+ }
1997
+ var l, c = e("../../../errors").codes, u = c.ERR_MISSING_ARGS, p = c.ERR_STREAM_DESTROYED;
1998
+ t2.exports = function() {
1999
+ for (var e2 = arguments.length, t3 = Array(e2), n3 = 0; n3 < e2; n3++) t3[n3] = arguments[n3];
2000
+ var r3 = s(t3);
2001
+ if (Array.isArray(t3[0]) && (t3 = t3[0]), 2 > t3.length) throw new u("streams");
2002
+ var a2, l2 = t3.map(function(e3, n4) {
2003
+ var d2 = n4 < t3.length - 1;
2004
+ return o(e3, d2, 0 < n4, function(e4) {
2005
+ a2 || (a2 = e4), e4 && l2.forEach(i), d2 || (l2.forEach(i), r3(a2));
2006
+ });
2007
+ });
2008
+ return t3.reduce(d);
2009
+ };
2010
+ }, { "../../../errors": 15, "./end-of-stream": 24 }], 27: [function(e, n2) {
2011
+ function r2(e2, t2, n3) {
2012
+ return null == e2.highWaterMark ? t2 ? e2[n3] : null : e2.highWaterMark;
2013
+ }
2014
+ var a = e("../../../errors").codes.ERR_INVALID_OPT_VALUE;
2015
+ n2.exports = { getHighWaterMark: function(e2, n3, o, i) {
2016
+ var d = r2(n3, i, o);
2017
+ if (null != d) {
2018
+ if (!(isFinite(d) && t(d) === d) || 0 > d) {
2019
+ var s = i ? o : "highWaterMark";
2020
+ throw new a(s, d);
2021
+ }
2022
+ return t(d);
2023
+ }
2024
+ return e2.objectMode ? 16 : 16384;
2025
+ } };
2026
+ }, { "../../../errors": 15 }], 28: [function(e, t2) {
2027
+ t2.exports = e("events").EventEmitter;
2028
+ }, { events: 7 }], 29: [function(e, t2, n2) {
2029
+ n2 = t2.exports = e("./lib/_stream_readable.js"), n2.Stream = n2, n2.Readable = n2, n2.Writable = e("./lib/_stream_writable.js"), n2.Duplex = e("./lib/_stream_duplex.js"), n2.Transform = e("./lib/_stream_transform.js"), n2.PassThrough = e("./lib/_stream_passthrough.js"), n2.finished = e("./lib/internal/streams/end-of-stream.js"), n2.pipeline = e("./lib/internal/streams/pipeline.js");
2030
+ }, { "./lib/_stream_duplex.js": 16, "./lib/_stream_passthrough.js": 17, "./lib/_stream_readable.js": 18, "./lib/_stream_transform.js": 19, "./lib/_stream_writable.js": 20, "./lib/internal/streams/end-of-stream.js": 24, "./lib/internal/streams/pipeline.js": 26 }], 30: [function(e, t2, n2) {
2031
+ function r2(e2, t3) {
2032
+ for (var n3 in e2) t3[n3] = e2[n3];
2033
+ }
2034
+ function a(e2, t3, n3) {
2035
+ return i(e2, t3, n3);
2036
+ }
2037
+ var o = e("buffer"), i = o.Buffer;
2038
+ i.from && i.alloc && i.allocUnsafe && i.allocUnsafeSlow ? t2.exports = o : (r2(o, n2), n2.Buffer = a), a.prototype = Object.create(i.prototype), r2(i, a), a.from = function(e2, t3, n3) {
2039
+ if ("number" == typeof e2) throw new TypeError("Argument must not be a number");
2040
+ return i(e2, t3, n3);
2041
+ }, a.alloc = function(e2, t3, n3) {
2042
+ if ("number" != typeof e2) throw new TypeError("Argument must be a number");
2043
+ var r3 = i(e2);
2044
+ return void 0 === t3 ? r3.fill(0) : "string" == typeof n3 ? r3.fill(t3, n3) : r3.fill(t3), r3;
2045
+ }, a.allocUnsafe = function(e2) {
2046
+ if ("number" != typeof e2) throw new TypeError("Argument must be a number");
2047
+ return i(e2);
2048
+ }, a.allocUnsafeSlow = function(e2) {
2049
+ if ("number" != typeof e2) throw new TypeError("Argument must be a number");
2050
+ return o.SlowBuffer(e2);
2051
+ };
2052
+ }, { buffer: 3 }], 31: [function(e, t2, n2) {
2053
+ function r2(e2) {
2054
+ if (!e2) return "utf8";
2055
+ for (var t3; ; ) switch (e2) {
2056
+ case "utf8":
2057
+ case "utf-8":
2058
+ return "utf8";
2059
+ case "ucs2":
2060
+ case "ucs-2":
2061
+ case "utf16le":
2062
+ case "utf-16le":
2063
+ return "utf16le";
2064
+ case "latin1":
2065
+ case "binary":
2066
+ return "latin1";
2067
+ case "base64":
2068
+ case "ascii":
2069
+ case "hex":
2070
+ return e2;
2071
+ default:
2072
+ if (t3) return;
2073
+ e2 = ("" + e2).toLowerCase(), t3 = true;
2074
+ }
2075
+ }
2076
+ function a(e2) {
2077
+ var t3 = r2(e2);
2078
+ if ("string" != typeof t3 && (m.isEncoding === b || !b(e2))) throw new Error("Unknown encoding: " + e2);
2079
+ return t3 || e2;
2080
+ }
2081
+ function o(e2) {
2082
+ this.encoding = a(e2);
2083
+ var t3;
2084
+ switch (this.encoding) {
2085
+ case "utf16le":
2086
+ this.text = u, this.end = p, t3 = 4;
2087
+ break;
2088
+ case "utf8":
2089
+ this.fillLast = c, t3 = 4;
2090
+ break;
2091
+ case "base64":
2092
+ this.text = f, this.end = g, t3 = 3;
2093
+ break;
2094
+ default:
2095
+ return this.write = _, void (this.end = h);
2096
+ }
2097
+ this.lastNeed = 0, this.lastTotal = 0, this.lastChar = m.allocUnsafe(t3);
2098
+ }
2099
+ function d(e2) {
2100
+ if (127 >= e2) return 0;
2101
+ return 6 == e2 >> 5 ? 2 : 14 == e2 >> 4 ? 3 : 30 == e2 >> 3 ? 4 : 2 == e2 >> 6 ? -1 : -2;
2102
+ }
2103
+ function s(e2, t3, n3) {
2104
+ var r3 = t3.length - 1;
2105
+ if (r3 < n3) return 0;
2106
+ var a2 = d(t3[r3]);
2107
+ return 0 <= a2 ? (0 < a2 && (e2.lastNeed = a2 - 1), a2) : --r3 < n3 || -2 === a2 ? 0 : (a2 = d(t3[r3]), 0 <= a2) ? (0 < a2 && (e2.lastNeed = a2 - 2), a2) : --r3 < n3 || -2 === a2 ? 0 : (a2 = d(t3[r3]), 0 <= a2 ? (0 < a2 && (2 === a2 ? a2 = 0 : e2.lastNeed = a2 - 3), a2) : 0);
2108
+ }
2109
+ function l(e2, t3) {
2110
+ if (128 != (192 & t3[0])) return e2.lastNeed = 0, "\uFFFD";
2111
+ if (1 < e2.lastNeed && 1 < t3.length) {
2112
+ if (128 != (192 & t3[1])) return e2.lastNeed = 1, "\uFFFD";
2113
+ if (2 < e2.lastNeed && 2 < t3.length && 128 != (192 & t3[2])) return e2.lastNeed = 2, "\uFFFD";
2114
+ }
2115
+ }
2116
+ function c(e2) {
2117
+ var t3 = this.lastTotal - this.lastNeed, n3 = l(this, e2);
2118
+ return void 0 === n3 ? this.lastNeed <= e2.length ? (e2.copy(this.lastChar, t3, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal)) : void (e2.copy(this.lastChar, t3, 0, e2.length), this.lastNeed -= e2.length) : n3;
2119
+ }
2120
+ function u(e2, t3) {
2121
+ if (0 == (e2.length - t3) % 2) {
2122
+ var n3 = e2.toString("utf16le", t3);
2123
+ if (n3) {
2124
+ var r3 = n3.charCodeAt(n3.length - 1);
2125
+ if (55296 <= r3 && 56319 >= r3) return this.lastNeed = 2, this.lastTotal = 4, this.lastChar[0] = e2[e2.length - 2], this.lastChar[1] = e2[e2.length - 1], n3.slice(0, -1);
2126
+ }
2127
+ return n3;
2128
+ }
2129
+ return this.lastNeed = 1, this.lastTotal = 2, this.lastChar[0] = e2[e2.length - 1], e2.toString("utf16le", t3, e2.length - 1);
2130
+ }
2131
+ function p(e2) {
2132
+ var t3 = e2 && e2.length ? this.write(e2) : "";
2133
+ if (this.lastNeed) {
2134
+ var n3 = this.lastTotal - this.lastNeed;
2135
+ return t3 + this.lastChar.toString("utf16le", 0, n3);
2136
+ }
2137
+ return t3;
2138
+ }
2139
+ function f(e2, t3) {
2140
+ var r3 = (e2.length - t3) % 3;
2141
+ return 0 == r3 ? e2.toString("base64", t3) : (this.lastNeed = 3 - r3, this.lastTotal = 3, 1 == r3 ? this.lastChar[0] = e2[e2.length - 1] : (this.lastChar[0] = e2[e2.length - 2], this.lastChar[1] = e2[e2.length - 1]), e2.toString("base64", t3, e2.length - r3));
2142
+ }
2143
+ function g(e2) {
2144
+ var t3 = e2 && e2.length ? this.write(e2) : "";
2145
+ return this.lastNeed ? t3 + this.lastChar.toString("base64", 0, 3 - this.lastNeed) : t3;
2146
+ }
2147
+ function _(e2) {
2148
+ return e2.toString(this.encoding);
2149
+ }
2150
+ function h(e2) {
2151
+ return e2 && e2.length ? this.write(e2) : "";
2152
+ }
2153
+ var m = e("safe-buffer").Buffer, b = m.isEncoding || function(e2) {
2154
+ switch (e2 = "" + e2, e2 && e2.toLowerCase()) {
2155
+ case "hex":
2156
+ case "utf8":
2157
+ case "utf-8":
2158
+ case "ascii":
2159
+ case "binary":
2160
+ case "base64":
2161
+ case "ucs2":
2162
+ case "ucs-2":
2163
+ case "utf16le":
2164
+ case "utf-16le":
2165
+ case "raw":
2166
+ return true;
2167
+ default:
2168
+ return false;
2169
+ }
2170
+ };
2171
+ n2.StringDecoder = o, o.prototype.write = function(e2) {
2172
+ if (0 === e2.length) return "";
2173
+ var t3, n3;
2174
+ if (this.lastNeed) {
2175
+ if (t3 = this.fillLast(e2), void 0 === t3) return "";
2176
+ n3 = this.lastNeed, this.lastNeed = 0;
2177
+ } else n3 = 0;
2178
+ return n3 < e2.length ? t3 ? t3 + this.text(e2, n3) : this.text(e2, n3) : t3 || "";
2179
+ }, o.prototype.end = function(e2) {
2180
+ var t3 = e2 && e2.length ? this.write(e2) : "";
2181
+ return this.lastNeed ? t3 + "\uFFFD" : t3;
2182
+ }, o.prototype.text = function(e2, t3) {
2183
+ var n3 = s(this, e2, t3);
2184
+ if (!this.lastNeed) return e2.toString("utf8", t3);
2185
+ this.lastTotal = n3;
2186
+ var r3 = e2.length - (n3 - this.lastNeed);
2187
+ return e2.copy(this.lastChar, 0, r3), e2.toString("utf8", t3, r3);
2188
+ }, o.prototype.fillLast = function(e2) {
2189
+ return this.lastNeed <= e2.length ? (e2.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed), this.lastChar.toString(this.encoding, 0, this.lastTotal)) : void (e2.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, e2.length), this.lastNeed -= e2.length);
2190
+ };
2191
+ }, { "safe-buffer": 30 }], 32: [function(e, t2) {
2192
+ (function(e2) {
2193
+ (function() {
2194
+ function n2(t3) {
2195
+ try {
2196
+ if (!e2.localStorage) return false;
2197
+ } catch (e3) {
2198
+ return false;
2199
+ }
2200
+ var n3 = e2.localStorage[t3];
2201
+ return null != n3 && "true" === (n3 + "").toLowerCase();
2202
+ }
2203
+ t2.exports = function(e3, t3) {
2204
+ function r2() {
2205
+ if (!a) {
2206
+ if (n2("throwDeprecation")) throw new Error(t3);
2207
+ else n2("traceDeprecation") ? console.trace(t3) : console.warn(t3);
2208
+ a = true;
2209
+ }
2210
+ return e3.apply(this, arguments);
2211
+ }
2212
+ if (n2("noDeprecation")) return e3;
2213
+ var a = false;
2214
+ return r2;
2215
+ };
2216
+ }).call(this);
2217
+ }).call(this, "undefined" == typeof global ? "undefined" == typeof self ? "undefined" == typeof window ? {} : window : self : global);
2218
+ }, {}], "/": [function(e, t2) {
2219
+ function n2(e2) {
2220
+ return e2.replace(/a=ice-options:trickle\s\n/g, "");
2221
+ }
2222
+ function r2(e2) {
2223
+ console.warn(e2);
2224
+ }
2225
+ const a = e("debug")("simple-peer"), o = e("get-browser-rtc"), i = e("randombytes"), d = e("readable-stream"), s = e("queue-microtask"), l = e("err-code"), { Buffer: c } = e("buffer"), u = 65536;
2226
+ class p extends d.Duplex {
2227
+ constructor(e2) {
2228
+ if (e2 = Object.assign({ allowHalfOpen: false }, e2), super(e2), this._id = i(4).toString("hex").slice(0, 7), this._debug("new peer %o", e2), this.channelName = e2.initiator ? e2.channelName || i(20).toString("hex") : null, this.initiator = e2.initiator || false, this.channelConfig = e2.channelConfig || p.channelConfig, this.channelNegotiated = this.channelConfig.negotiated, this.config = Object.assign({}, p.config, e2.config), this.offerOptions = e2.offerOptions || {}, this.answerOptions = e2.answerOptions || {}, this.sdpTransform = e2.sdpTransform || ((e3) => e3), this.streams = e2.streams || (e2.stream ? [e2.stream] : []), this.trickle = void 0 === e2.trickle || e2.trickle, this.allowHalfTrickle = void 0 !== e2.allowHalfTrickle && e2.allowHalfTrickle, this.iceCompleteTimeout = e2.iceCompleteTimeout || 5e3, this.destroyed = false, this.destroying = false, this._connected = false, this.remoteAddress = void 0, this.remoteFamily = void 0, this.remotePort = void 0, this.localAddress = void 0, this.localFamily = void 0, this.localPort = void 0, this._wrtc = e2.wrtc && "object" == typeof e2.wrtc ? e2.wrtc : o(), !this._wrtc) if ("undefined" == typeof window) throw l(new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"), "ERR_WEBRTC_SUPPORT");
2229
+ else throw l(new Error("No WebRTC support: Not a supported browser"), "ERR_WEBRTC_SUPPORT");
2230
+ this._pcReady = false, this._channelReady = false, this._iceComplete = false, this._iceCompleteTimer = null, this._channel = null, this._pendingCandidates = [], this._isNegotiating = false, this._firstNegotiation = true, this._batchedNegotiation = false, this._queuedNegotiation = false, this._sendersAwaitingStable = [], this._senderMap = /* @__PURE__ */ new Map(), this._closingInterval = null, this._remoteTracks = [], this._remoteStreams = [], this._chunk = null, this._cb = null, this._interval = null;
2231
+ try {
2232
+ this._pc = new this._wrtc.RTCPeerConnection(this.config);
2233
+ } catch (e3) {
2234
+ return void this.destroy(l(e3, "ERR_PC_CONSTRUCTOR"));
2235
+ }
2236
+ this._isReactNativeWebrtc = "number" == typeof this._pc._peerConnectionId, this._pc.oniceconnectionstatechange = () => {
2237
+ this._onIceStateChange();
2238
+ }, this._pc.onicegatheringstatechange = () => {
2239
+ this._onIceStateChange();
2240
+ }, this._pc.onconnectionstatechange = () => {
2241
+ this._onConnectionStateChange();
2242
+ }, this._pc.onsignalingstatechange = () => {
2243
+ this._onSignalingStateChange();
2244
+ }, this._pc.onicecandidate = (e3) => {
2245
+ this._onIceCandidate(e3);
2246
+ }, "object" == typeof this._pc.peerIdentity && this._pc.peerIdentity.catch((e3) => {
2247
+ this.destroy(l(e3, "ERR_PC_PEER_IDENTITY"));
2248
+ }), this.initiator || this.channelNegotiated ? this._setupData({ channel: this._pc.createDataChannel(this.channelName, this.channelConfig) }) : this._pc.ondatachannel = (e3) => {
2249
+ this._setupData(e3);
2250
+ }, this.streams && this.streams.forEach((e3) => {
2251
+ this.addStream(e3);
2252
+ }), this._pc.ontrack = (e3) => {
2253
+ this._onTrack(e3);
2254
+ }, this._debug("initial negotiation"), this._needsNegotiation(), this._onFinishBound = () => {
2255
+ this._onFinish();
2256
+ }, this.once("finish", this._onFinishBound);
2257
+ }
2258
+ get bufferSize() {
2259
+ return this._channel && this._channel.bufferedAmount || 0;
2260
+ }
2261
+ get connected() {
2262
+ return this._connected && "open" === this._channel.readyState;
2263
+ }
2264
+ address() {
2265
+ return { port: this.localPort, family: this.localFamily, address: this.localAddress };
2266
+ }
2267
+ signal(e2) {
2268
+ if (!this.destroying) {
2269
+ if (this.destroyed) throw l(new Error("cannot signal after peer is destroyed"), "ERR_DESTROYED");
2270
+ if ("string" == typeof e2) try {
2271
+ e2 = JSON.parse(e2);
2272
+ } catch (t3) {
2273
+ e2 = {};
2274
+ }
2275
+ this._debug("signal()"), e2.renegotiate && this.initiator && (this._debug("got request to renegotiate"), this._needsNegotiation()), e2.transceiverRequest && this.initiator && (this._debug("got request for transceiver"), this.addTransceiver(e2.transceiverRequest.kind, e2.transceiverRequest.init)), e2.candidate && (this._pc.remoteDescription && this._pc.remoteDescription.type ? this._addIceCandidate(e2.candidate) : this._pendingCandidates.push(e2.candidate)), e2.sdp && this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(e2)).then(() => {
2276
+ this.destroyed || (this._pendingCandidates.forEach((e3) => {
2277
+ this._addIceCandidate(e3);
2278
+ }), this._pendingCandidates = [], "offer" === this._pc.remoteDescription.type && this._createAnswer());
2279
+ }).catch((e3) => {
2280
+ this.destroy(l(e3, "ERR_SET_REMOTE_DESCRIPTION"));
2281
+ }), e2.sdp || e2.candidate || e2.renegotiate || e2.transceiverRequest || this.destroy(l(new Error("signal() called with invalid signal data"), "ERR_SIGNALING"));
2282
+ }
2283
+ }
2284
+ _addIceCandidate(e2) {
2285
+ const t3 = new this._wrtc.RTCIceCandidate(e2);
2286
+ this._pc.addIceCandidate(t3).catch((e3) => {
2287
+ !t3.address || t3.address.endsWith(".local") ? r2("Ignoring unsupported ICE candidate.") : this.destroy(l(e3, "ERR_ADD_ICE_CANDIDATE"));
2288
+ });
2289
+ }
2290
+ send(e2) {
2291
+ if (!this.destroying) {
2292
+ if (this.destroyed) throw l(new Error("cannot send after peer is destroyed"), "ERR_DESTROYED");
2293
+ this._channel.send(e2);
2294
+ }
2295
+ }
2296
+ addTransceiver(e2, t3) {
2297
+ if (!this.destroying) {
2298
+ if (this.destroyed) throw l(new Error("cannot addTransceiver after peer is destroyed"), "ERR_DESTROYED");
2299
+ if (this._debug("addTransceiver()"), this.initiator) try {
2300
+ this._pc.addTransceiver(e2, t3), this._needsNegotiation();
2301
+ } catch (e3) {
2302
+ this.destroy(l(e3, "ERR_ADD_TRANSCEIVER"));
2303
+ }
2304
+ else this.emit("signal", { type: "transceiverRequest", transceiverRequest: { kind: e2, init: t3 } });
2305
+ }
2306
+ }
2307
+ addStream(e2) {
2308
+ if (!this.destroying) {
2309
+ if (this.destroyed) throw l(new Error("cannot addStream after peer is destroyed"), "ERR_DESTROYED");
2310
+ this._debug("addStream()"), e2.getTracks().forEach((t3) => {
2311
+ this.addTrack(t3, e2);
2312
+ });
2313
+ }
2314
+ }
2315
+ addTrack(e2, t3) {
2316
+ if (this.destroying) return;
2317
+ if (this.destroyed) throw l(new Error("cannot addTrack after peer is destroyed"), "ERR_DESTROYED");
2318
+ this._debug("addTrack()");
2319
+ const n3 = this._senderMap.get(e2) || /* @__PURE__ */ new Map();
2320
+ let r3 = n3.get(t3);
2321
+ if (!r3) r3 = this._pc.addTrack(e2, t3), n3.set(t3, r3), this._senderMap.set(e2, n3), this._needsNegotiation();
2322
+ else if (r3.removed) throw l(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."), "ERR_SENDER_REMOVED");
2323
+ else throw l(new Error("Track has already been added to that stream."), "ERR_SENDER_ALREADY_ADDED");
2324
+ }
2325
+ replaceTrack(e2, t3, n3) {
2326
+ if (this.destroying) return;
2327
+ if (this.destroyed) throw l(new Error("cannot replaceTrack after peer is destroyed"), "ERR_DESTROYED");
2328
+ this._debug("replaceTrack()");
2329
+ const r3 = this._senderMap.get(e2), a2 = r3 ? r3.get(n3) : null;
2330
+ if (!a2) throw l(new Error("Cannot replace track that was never added."), "ERR_TRACK_NOT_ADDED");
2331
+ t3 && this._senderMap.set(t3, r3), null == a2.replaceTrack ? this.destroy(l(new Error("replaceTrack is not supported in this browser"), "ERR_UNSUPPORTED_REPLACETRACK")) : a2.replaceTrack(t3);
2332
+ }
2333
+ removeTrack(e2, t3) {
2334
+ if (this.destroying) return;
2335
+ if (this.destroyed) throw l(new Error("cannot removeTrack after peer is destroyed"), "ERR_DESTROYED");
2336
+ this._debug("removeSender()");
2337
+ const n3 = this._senderMap.get(e2), r3 = n3 ? n3.get(t3) : null;
2338
+ if (!r3) throw l(new Error("Cannot remove track that was never added."), "ERR_TRACK_NOT_ADDED");
2339
+ try {
2340
+ r3.removed = true, this._pc.removeTrack(r3);
2341
+ } catch (e3) {
2342
+ "NS_ERROR_UNEXPECTED" === e3.name ? this._sendersAwaitingStable.push(r3) : this.destroy(l(e3, "ERR_REMOVE_TRACK"));
2343
+ }
2344
+ this._needsNegotiation();
2345
+ }
2346
+ removeStream(e2) {
2347
+ if (!this.destroying) {
2348
+ if (this.destroyed) throw l(new Error("cannot removeStream after peer is destroyed"), "ERR_DESTROYED");
2349
+ this._debug("removeSenders()"), e2.getTracks().forEach((t3) => {
2350
+ this.removeTrack(t3, e2);
2351
+ });
2352
+ }
2353
+ }
2354
+ _needsNegotiation() {
2355
+ this._debug("_needsNegotiation"), this._batchedNegotiation || (this._batchedNegotiation = true, s(() => {
2356
+ this._batchedNegotiation = false, this.initiator || !this._firstNegotiation ? (this._debug("starting batched negotiation"), this.negotiate()) : this._debug("non-initiator initial negotiation request discarded"), this._firstNegotiation = false;
2357
+ }));
2358
+ }
2359
+ negotiate() {
2360
+ if (!this.destroying) {
2361
+ if (this.destroyed) throw l(new Error("cannot negotiate after peer is destroyed"), "ERR_DESTROYED");
2362
+ this.initiator ? this._isNegotiating ? (this._queuedNegotiation = true, this._debug("already negotiating, queueing")) : (this._debug("start negotiation"), setTimeout(() => {
2363
+ this._createOffer();
2364
+ }, 0)) : this._isNegotiating ? (this._queuedNegotiation = true, this._debug("already negotiating, queueing")) : (this._debug("requesting negotiation from initiator"), this.emit("signal", { type: "renegotiate", renegotiate: true })), this._isNegotiating = true;
2365
+ }
2366
+ }
2367
+ destroy(e2) {
2368
+ this._destroy(e2, () => {
2369
+ });
2370
+ }
2371
+ _destroy(e2, t3) {
2372
+ this.destroyed || this.destroying || (this.destroying = true, this._debug("destroying (error: %s)", e2 && (e2.message || e2)), s(() => {
2373
+ if (this.destroyed = true, this.destroying = false, this._debug("destroy (error: %s)", e2 && (e2.message || e2)), this.readable = this.writable = false, this._readableState.ended || this.push(null), this._writableState.finished || this.end(), this._connected = false, this._pcReady = false, this._channelReady = false, this._remoteTracks = null, this._remoteStreams = null, this._senderMap = null, clearInterval(this._closingInterval), this._closingInterval = null, clearInterval(this._interval), this._interval = null, this._chunk = null, this._cb = null, this._onFinishBound && this.removeListener("finish", this._onFinishBound), this._onFinishBound = null, this._channel) {
2374
+ try {
2375
+ this._channel.close();
2376
+ } catch (e3) {
2377
+ }
2378
+ this._channel.onmessage = null, this._channel.onopen = null, this._channel.onclose = null, this._channel.onerror = null;
2379
+ }
2380
+ if (this._pc) {
2381
+ try {
2382
+ this._pc.close();
2383
+ } catch (e3) {
2384
+ }
2385
+ this._pc.oniceconnectionstatechange = null, this._pc.onicegatheringstatechange = null, this._pc.onsignalingstatechange = null, this._pc.onicecandidate = null, this._pc.ontrack = null, this._pc.ondatachannel = null;
2386
+ }
2387
+ this._pc = null, this._channel = null, e2 && this.emit("error", e2), this.emit("close"), t3();
2388
+ }));
2389
+ }
2390
+ _setupData(e2) {
2391
+ if (!e2.channel) return this.destroy(l(new Error("Data channel event is missing `channel` property"), "ERR_DATA_CHANNEL"));
2392
+ this._channel = e2.channel, this._channel.binaryType = "arraybuffer", "number" == typeof this._channel.bufferedAmountLowThreshold && (this._channel.bufferedAmountLowThreshold = u), this.channelName = this._channel.label, this._channel.onmessage = (e3) => {
2393
+ this._onChannelMessage(e3);
2394
+ }, this._channel.onbufferedamountlow = () => {
2395
+ this._onChannelBufferedAmountLow();
2396
+ }, this._channel.onopen = () => {
2397
+ this._onChannelOpen();
2398
+ }, this._channel.onclose = () => {
2399
+ this._onChannelClose();
2400
+ }, this._channel.onerror = (e3) => {
2401
+ const t4 = e3.error instanceof Error ? e3.error : new Error(`Datachannel error: ${e3.message} ${e3.filename}:${e3.lineno}:${e3.colno}`);
2402
+ this.destroy(l(t4, "ERR_DATA_CHANNEL"));
2403
+ };
2404
+ let t3 = false;
2405
+ this._closingInterval = setInterval(() => {
2406
+ this._channel && "closing" === this._channel.readyState ? (t3 && this._onChannelClose(), t3 = true) : t3 = false;
2407
+ }, 5e3);
2408
+ }
2409
+ _read() {
2410
+ }
2411
+ _write(e2, t3, n3) {
2412
+ if (this.destroyed) return n3(l(new Error("cannot write after peer is destroyed"), "ERR_DATA_CHANNEL"));
2413
+ if (this._connected) {
2414
+ try {
2415
+ this.send(e2);
2416
+ } catch (e3) {
2417
+ return this.destroy(l(e3, "ERR_DATA_CHANNEL"));
2418
+ }
2419
+ this._channel.bufferedAmount > u ? (this._debug("start backpressure: bufferedAmount %d", this._channel.bufferedAmount), this._cb = n3) : n3(null);
2420
+ } else this._debug("write before connect"), this._chunk = e2, this._cb = n3;
2421
+ }
2422
+ _onFinish() {
2423
+ if (!this.destroyed) {
2424
+ const e2 = () => {
2425
+ setTimeout(() => this.destroy(), 1e3);
2426
+ };
2427
+ this._connected ? e2() : this.once("connect", e2);
2428
+ }
2429
+ }
2430
+ _startIceCompleteTimeout() {
2431
+ this.destroyed || this._iceCompleteTimer || (this._debug("started iceComplete timeout"), this._iceCompleteTimer = setTimeout(() => {
2432
+ this._iceComplete || (this._iceComplete = true, this._debug("iceComplete timeout completed"), this.emit("iceTimeout"), this.emit("_iceComplete"));
2433
+ }, this.iceCompleteTimeout));
2434
+ }
2435
+ _createOffer() {
2436
+ this.destroyed || this._pc.createOffer(this.offerOptions).then((e2) => {
2437
+ if (this.destroyed) return;
2438
+ this.trickle || this.allowHalfTrickle || (e2.sdp = n2(e2.sdp)), e2.sdp = this.sdpTransform(e2.sdp);
2439
+ const t3 = () => {
2440
+ if (!this.destroyed) {
2441
+ const t4 = this._pc.localDescription || e2;
2442
+ this._debug("signal"), this.emit("signal", { type: t4.type, sdp: t4.sdp });
2443
+ }
2444
+ };
2445
+ this._pc.setLocalDescription(e2).then(() => {
2446
+ this._debug("createOffer success"), this.destroyed || (this.trickle || this._iceComplete ? t3() : this.once("_iceComplete", t3));
2447
+ }).catch((e3) => {
2448
+ this.destroy(l(e3, "ERR_SET_LOCAL_DESCRIPTION"));
2449
+ });
2450
+ }).catch((e2) => {
2451
+ this.destroy(l(e2, "ERR_CREATE_OFFER"));
2452
+ });
2453
+ }
2454
+ _requestMissingTransceivers() {
2455
+ this._pc.getTransceivers && this._pc.getTransceivers().forEach((e2) => {
2456
+ e2.mid || !e2.sender.track || e2.requested || (e2.requested = true, this.addTransceiver(e2.sender.track.kind));
2457
+ });
2458
+ }
2459
+ _createAnswer() {
2460
+ this.destroyed || this._pc.createAnswer(this.answerOptions).then((e2) => {
2461
+ if (this.destroyed) return;
2462
+ this.trickle || this.allowHalfTrickle || (e2.sdp = n2(e2.sdp)), e2.sdp = this.sdpTransform(e2.sdp);
2463
+ const t3 = () => {
2464
+ if (!this.destroyed) {
2465
+ const t4 = this._pc.localDescription || e2;
2466
+ this._debug("signal"), this.emit("signal", { type: t4.type, sdp: t4.sdp }), this.initiator || this._requestMissingTransceivers();
2467
+ }
2468
+ };
2469
+ this._pc.setLocalDescription(e2).then(() => {
2470
+ this.destroyed || (this.trickle || this._iceComplete ? t3() : this.once("_iceComplete", t3));
2471
+ }).catch((e3) => {
2472
+ this.destroy(l(e3, "ERR_SET_LOCAL_DESCRIPTION"));
2473
+ });
2474
+ }).catch((e2) => {
2475
+ this.destroy(l(e2, "ERR_CREATE_ANSWER"));
2476
+ });
2477
+ }
2478
+ _onConnectionStateChange() {
2479
+ this.destroyed || "failed" === this._pc.connectionState && this.destroy(l(new Error("Connection failed."), "ERR_CONNECTION_FAILURE"));
2480
+ }
2481
+ _onIceStateChange() {
2482
+ if (this.destroyed) return;
2483
+ const e2 = this._pc.iceConnectionState, t3 = this._pc.iceGatheringState;
2484
+ this._debug("iceStateChange (connection: %s) (gathering: %s)", e2, t3), this.emit("iceStateChange", e2, t3), ("connected" === e2 || "completed" === e2) && (this._pcReady = true, this._maybeReady()), "failed" === e2 && this.destroy(l(new Error("Ice connection failed."), "ERR_ICE_CONNECTION_FAILURE")), "closed" === e2 && this.destroy(l(new Error("Ice connection closed."), "ERR_ICE_CONNECTION_CLOSED"));
2485
+ }
2486
+ getStats(e2) {
2487
+ const t3 = (e3) => ("[object Array]" === Object.prototype.toString.call(e3.values) && e3.values.forEach((t4) => {
2488
+ Object.assign(e3, t4);
2489
+ }), e3);
2490
+ 0 === this._pc.getStats.length || this._isReactNativeWebrtc ? this._pc.getStats().then((n3) => {
2491
+ const r3 = [];
2492
+ n3.forEach((e3) => {
2493
+ r3.push(t3(e3));
2494
+ }), e2(null, r3);
2495
+ }, (t4) => e2(t4)) : 0 < this._pc.getStats.length ? this._pc.getStats((n3) => {
2496
+ if (this.destroyed) return;
2497
+ const r3 = [];
2498
+ n3.result().forEach((e3) => {
2499
+ const n4 = {};
2500
+ e3.names().forEach((t4) => {
2501
+ n4[t4] = e3.stat(t4);
2502
+ }), n4.id = e3.id, n4.type = e3.type, n4.timestamp = e3.timestamp, r3.push(t3(n4));
2503
+ }), e2(null, r3);
2504
+ }, (t4) => e2(t4)) : e2(null, []);
2505
+ }
2506
+ _maybeReady() {
2507
+ if (this._debug("maybeReady pc %s channel %s", this._pcReady, this._channelReady), this._connected || this._connecting || !this._pcReady || !this._channelReady) return;
2508
+ this._connecting = true;
2509
+ const e2 = () => {
2510
+ this.destroyed || this.getStats((t3, n3) => {
2511
+ if (this.destroyed) return;
2512
+ t3 && (n3 = []);
2513
+ const r3 = {}, a2 = {}, o2 = {};
2514
+ let i2 = false;
2515
+ n3.forEach((e3) => {
2516
+ ("remotecandidate" === e3.type || "remote-candidate" === e3.type) && (r3[e3.id] = e3), ("localcandidate" === e3.type || "local-candidate" === e3.type) && (a2[e3.id] = e3), ("candidatepair" === e3.type || "candidate-pair" === e3.type) && (o2[e3.id] = e3);
2517
+ });
2518
+ const d2 = (e3) => {
2519
+ i2 = true;
2520
+ let t4 = a2[e3.localCandidateId];
2521
+ t4 && (t4.ip || t4.address) ? (this.localAddress = t4.ip || t4.address, this.localPort = +t4.port) : t4 && t4.ipAddress ? (this.localAddress = t4.ipAddress, this.localPort = +t4.portNumber) : "string" == typeof e3.googLocalAddress && (t4 = e3.googLocalAddress.split(":"), this.localAddress = t4[0], this.localPort = +t4[1]), this.localAddress && (this.localFamily = this.localAddress.includes(":") ? "IPv6" : "IPv4");
2522
+ let n4 = r3[e3.remoteCandidateId];
2523
+ n4 && (n4.ip || n4.address) ? (this.remoteAddress = n4.ip || n4.address, this.remotePort = +n4.port) : n4 && n4.ipAddress ? (this.remoteAddress = n4.ipAddress, this.remotePort = +n4.portNumber) : "string" == typeof e3.googRemoteAddress && (n4 = e3.googRemoteAddress.split(":"), this.remoteAddress = n4[0], this.remotePort = +n4[1]), this.remoteAddress && (this.remoteFamily = this.remoteAddress.includes(":") ? "IPv6" : "IPv4"), this._debug("connect local: %s:%s remote: %s:%s", this.localAddress, this.localPort, this.remoteAddress, this.remotePort);
2524
+ };
2525
+ if (n3.forEach((e3) => {
2526
+ "transport" === e3.type && e3.selectedCandidatePairId && d2(o2[e3.selectedCandidatePairId]), ("googCandidatePair" === e3.type && "true" === e3.googActiveConnection || ("candidatepair" === e3.type || "candidate-pair" === e3.type) && e3.selected) && d2(e3);
2527
+ }), !i2 && (!Object.keys(o2).length || Object.keys(a2).length)) return void setTimeout(e2, 100);
2528
+ if (this._connecting = false, this._connected = true, this._chunk) {
2529
+ try {
2530
+ this.send(this._chunk);
2531
+ } catch (e4) {
2532
+ return this.destroy(l(e4, "ERR_DATA_CHANNEL"));
2533
+ }
2534
+ this._chunk = null, this._debug('sent chunk from "write before connect"');
2535
+ const e3 = this._cb;
2536
+ this._cb = null, e3(null);
2537
+ }
2538
+ "number" != typeof this._channel.bufferedAmountLowThreshold && (this._interval = setInterval(() => this._onInterval(), 150), this._interval.unref && this._interval.unref()), this._debug("connect"), this.emit("connect");
2539
+ });
2540
+ };
2541
+ e2();
2542
+ }
2543
+ _onInterval() {
2544
+ this._cb && this._channel && !(this._channel.bufferedAmount > u) && this._onChannelBufferedAmountLow();
2545
+ }
2546
+ _onSignalingStateChange() {
2547
+ this.destroyed || ("stable" === this._pc.signalingState && (this._isNegotiating = false, this._debug("flushing sender queue", this._sendersAwaitingStable), this._sendersAwaitingStable.forEach((e2) => {
2548
+ this._pc.removeTrack(e2), this._queuedNegotiation = true;
2549
+ }), this._sendersAwaitingStable = [], this._queuedNegotiation ? (this._debug("flushing negotiation queue"), this._queuedNegotiation = false, this._needsNegotiation()) : (this._debug("negotiated"), this.emit("negotiated"))), this._debug("signalingStateChange %s", this._pc.signalingState), this.emit("signalingStateChange", this._pc.signalingState));
2550
+ }
2551
+ _onIceCandidate(e2) {
2552
+ this.destroyed || (e2.candidate && this.trickle ? this.emit("signal", { type: "candidate", candidate: { candidate: e2.candidate.candidate, sdpMLineIndex: e2.candidate.sdpMLineIndex, sdpMid: e2.candidate.sdpMid } }) : !e2.candidate && !this._iceComplete && (this._iceComplete = true, this.emit("_iceComplete")), e2.candidate && this._startIceCompleteTimeout());
2553
+ }
2554
+ _onChannelMessage(e2) {
2555
+ if (this.destroyed) return;
2556
+ let t3 = e2.data;
2557
+ t3 instanceof ArrayBuffer && (t3 = c.from(t3)), this.push(t3);
2558
+ }
2559
+ _onChannelBufferedAmountLow() {
2560
+ if (!this.destroyed && this._cb) {
2561
+ this._debug("ending backpressure: bufferedAmount %d", this._channel.bufferedAmount);
2562
+ const e2 = this._cb;
2563
+ this._cb = null, e2(null);
2564
+ }
2565
+ }
2566
+ _onChannelOpen() {
2567
+ this._connected || this.destroyed || (this._debug("on channel open"), this._channelReady = true, this._maybeReady());
2568
+ }
2569
+ _onChannelClose() {
2570
+ this.destroyed || (this._debug("on channel close"), this.destroy());
2571
+ }
2572
+ _onTrack(e2) {
2573
+ this.destroyed || e2.streams.forEach((t3) => {
2574
+ this._debug("on track"), this.emit("track", e2.track, t3), this._remoteTracks.push({ track: e2.track, stream: t3 }), this._remoteStreams.some((e3) => e3.id === t3.id) || (this._remoteStreams.push(t3), s(() => {
2575
+ this._debug("on stream"), this.emit("stream", t3);
2576
+ }));
2577
+ });
2578
+ }
2579
+ _debug() {
2580
+ const e2 = [].slice.call(arguments);
2581
+ e2[0] = "[" + this._id + "] " + e2[0], a.apply(null, e2);
2582
+ }
2583
+ }
2584
+ p.WEBRTC_SUPPORT = !!o(), p.config = { iceServers: [{ urls: ["stun:stun.l.google.com:19302", "stun:global.stun.twilio.com:3478"] }], sdpSemantics: "unified-plan" }, p.channelConfig = {}, t2.exports = p;
2585
+ }, { buffer: 3, debug: 4, "err-code": 6, "get-browser-rtc": 8, "queue-microtask": 13, randombytes: 14, "readable-stream": 29 }] }, {}, [])("/");
2586
+ });
2587
+ }
2588
+ });
2589
+
2590
+ // ../../node_modules/lib0/websocket.js
2591
+ var reconnectTimeoutBase = 1200;
2592
+ var maxReconnectTimeout = 2500;
2593
+ var messageReconnectTimeout = 3e4;
2594
+ var setupWS = (wsclient) => {
2595
+ if (wsclient.shouldConnect && wsclient.ws === null) {
2596
+ const websocket = new WebSocket(wsclient.url);
2597
+ const binaryType = wsclient.binaryType;
2598
+ let pingTimeout = null;
2599
+ if (binaryType) {
2600
+ websocket.binaryType = binaryType;
2601
+ }
2602
+ wsclient.ws = websocket;
2603
+ wsclient.connecting = true;
2604
+ wsclient.connected = false;
2605
+ websocket.onmessage = (event) => {
2606
+ wsclient.lastMessageReceived = getUnixTime();
2607
+ const data = event.data;
2608
+ const message = typeof data === "string" ? JSON.parse(data) : data;
2609
+ if (message && message.type === "pong") {
2610
+ clearTimeout(pingTimeout);
2611
+ pingTimeout = setTimeout(sendPing, messageReconnectTimeout / 2);
2612
+ }
2613
+ wsclient.emit("message", [message, wsclient]);
2614
+ };
2615
+ const onclose = (error) => {
2616
+ if (wsclient.ws !== null) {
2617
+ wsclient.ws = null;
2618
+ wsclient.connecting = false;
2619
+ if (wsclient.connected) {
2620
+ wsclient.connected = false;
2621
+ wsclient.emit("disconnect", [{ type: "disconnect", error }, wsclient]);
2622
+ } else {
2623
+ wsclient.unsuccessfulReconnects++;
2624
+ }
2625
+ setTimeout(setupWS, min(log10(wsclient.unsuccessfulReconnects + 1) * reconnectTimeoutBase, maxReconnectTimeout), wsclient);
2626
+ }
2627
+ clearTimeout(pingTimeout);
2628
+ };
2629
+ const sendPing = () => {
2630
+ if (wsclient.ws === websocket) {
2631
+ wsclient.send({
2632
+ type: "ping"
2633
+ });
2634
+ }
2635
+ };
2636
+ websocket.onclose = () => onclose(null);
2637
+ websocket.onerror = (error) => onclose(error);
2638
+ websocket.onopen = () => {
2639
+ wsclient.lastMessageReceived = getUnixTime();
2640
+ wsclient.connecting = false;
2641
+ wsclient.connected = true;
2642
+ wsclient.unsuccessfulReconnects = 0;
2643
+ wsclient.emit("connect", [{ type: "connect" }, wsclient]);
2644
+ pingTimeout = setTimeout(sendPing, messageReconnectTimeout / 2);
2645
+ };
2646
+ }
2647
+ };
2648
+ var WebsocketClient = class extends Observable {
2649
+ /**
2650
+ * @param {string} url
2651
+ * @param {object} opts
2652
+ * @param {'arraybuffer' | 'blob' | null} [opts.binaryType] Set `ws.binaryType`
2653
+ */
2654
+ constructor(url, { binaryType } = {}) {
2655
+ super();
2656
+ this.url = url;
2657
+ this.ws = null;
2658
+ this.binaryType = binaryType || null;
2659
+ this.connected = false;
2660
+ this.connecting = false;
2661
+ this.unsuccessfulReconnects = 0;
2662
+ this.lastMessageReceived = 0;
2663
+ this.shouldConnect = true;
2664
+ this._checkInterval = setInterval(() => {
2665
+ if (this.connected && messageReconnectTimeout < getUnixTime() - this.lastMessageReceived) {
2666
+ this.ws.close();
2667
+ }
2668
+ }, messageReconnectTimeout / 2);
2669
+ setupWS(this);
2670
+ }
2671
+ /**
2672
+ * @param {any} message
2673
+ */
2674
+ send(message) {
2675
+ if (this.ws) {
2676
+ this.ws.send(JSON.stringify(message));
2677
+ }
2678
+ }
2679
+ destroy() {
2680
+ clearInterval(this._checkInterval);
2681
+ this.disconnect();
2682
+ super.destroy();
2683
+ }
2684
+ disconnect() {
2685
+ this.shouldConnect = false;
2686
+ if (this.ws !== null) {
2687
+ this.ws.close();
2688
+ }
2689
+ }
2690
+ connect() {
2691
+ this.shouldConnect = true;
2692
+ if (!this.connected && this.ws === null) {
2693
+ setupWS(this);
2694
+ }
2695
+ }
2696
+ };
2697
+ var getRandomValues = crypto.getRandomValues.bind(crypto);
2698
+
2699
+ // ../../node_modules/lib0/random.js
2700
+ var rand = Math.random;
2701
+ var uint32 = () => getRandomValues(new Uint32Array(1))[0];
2702
+ var uuidv4Template = "10000000-1000-4000-8000" + -1e11;
2703
+ var uuidv4 = () => uuidv4Template.replace(
2704
+ /[018]/g,
2705
+ /** @param {number} c */
2706
+ (c) => (c ^ uint32() & 15 >> c / 4).toString(16)
2707
+ );
2708
+
2709
+ // ../../node_modules/lib0/pair.js
2710
+ var Pair = class {
2711
+ /**
2712
+ * @param {L} left
2713
+ * @param {R} right
2714
+ */
2715
+ constructor(left, right) {
2716
+ this.left = left;
2717
+ this.right = right;
2718
+ }
2719
+ };
2720
+ var create4 = (left, right) => new Pair(left, right);
2721
+
2722
+ // ../../node_modules/lib0/prng.js
2723
+ var bool = (gen) => gen.next() >= 0.5;
2724
+ var int53 = (gen, min2, max) => floor(gen.next() * (max + 1 - min2) + min2);
2725
+ var int32 = (gen, min2, max) => floor(gen.next() * (max + 1 - min2) + min2);
2726
+ var int31 = (gen, min2, max) => int32(gen, min2, max);
2727
+ var letter = (gen) => fromCharCode(int31(gen, 97, 122));
2728
+ var word = (gen, minLen = 0, maxLen = 20) => {
2729
+ const len = int31(gen, minLen, maxLen);
2730
+ let str = "";
2731
+ for (let i = 0; i < len; i++) {
2732
+ str += letter(gen);
2733
+ }
2734
+ return str;
2735
+ };
2736
+ var oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)];
2737
+
2738
+ // ../../node_modules/lib0/schema.js
2739
+ var schemaSymbol = /* @__PURE__ */ Symbol("0schema");
2740
+ var ValidationError = class {
2741
+ constructor() {
2742
+ this._rerrs = [];
2743
+ }
2744
+ /**
2745
+ * @param {string?} path
2746
+ * @param {string} expected
2747
+ * @param {string} has
2748
+ * @param {string?} message
2749
+ */
2750
+ extend(path, expected, has, message = null) {
2751
+ this._rerrs.push({ path, expected, has, message });
2752
+ }
2753
+ toString() {
2754
+ const s = [];
2755
+ for (let i = this._rerrs.length - 1; i > 0; i--) {
2756
+ const r = this._rerrs[i];
2757
+ s.push(repeat(" ", (this._rerrs.length - i) * 2) + `${r.path != null ? `[${r.path}] ` : ""}${r.has} doesn't match ${r.expected}. ${r.message}`);
2758
+ }
2759
+ return s.join("\n");
2760
+ }
2761
+ };
2762
+ var shapeExtends = (a, b) => {
2763
+ if (a === b) return true;
2764
+ if (a == null || b == null || a.constructor !== b.constructor) return false;
2765
+ if (a[EqualityTraitSymbol]) return equals(a, b);
2766
+ if (isArray(a)) {
2767
+ return every(
2768
+ a,
2769
+ (aitem) => some(b, (bitem) => shapeExtends(aitem, bitem))
2770
+ );
2771
+ } else if (isObject(a)) {
2772
+ return every2(
2773
+ a,
2774
+ (aitem, akey) => shapeExtends(aitem, b[akey])
2775
+ );
2776
+ }
2777
+ return false;
2778
+ };
2779
+ var Schema = class {
2780
+ // this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore
2781
+ /**
2782
+ * If true, the more things are added to the shape the more objects this schema will accept (e.g.
2783
+ * union). By default, the more objects are added, the the fewer objects this schema will accept.
2784
+ * @protected
2785
+ */
2786
+ static _dilutes = false;
2787
+ /**
2788
+ * @param {Schema<any>} other
2789
+ */
2790
+ extends(other) {
2791
+ let [a, b] = [
2792
+ /** @type {any} */
2793
+ this.shape,
2794
+ /** @type {any} */
2795
+ other.shape
2796
+ ];
2797
+ if (
2798
+ /** @type {typeof Schema<any>} */
2799
+ this.constructor._dilutes
2800
+ ) [b, a] = [a, b];
2801
+ return shapeExtends(a, b);
2802
+ }
2803
+ /**
2804
+ * Overwrite this when necessary. By default, we only check the `shape` property which every shape
2805
+ * should have.
2806
+ * @param {Schema<any>} other
2807
+ */
2808
+ equals(other) {
2809
+ return this.constructor === other.constructor && equalityDeep(this.shape, other.shape);
2810
+ }
2811
+ [schemaSymbol]() {
2812
+ return true;
2813
+ }
2814
+ /**
2815
+ * @param {object} other
2816
+ */
2817
+ [EqualityTraitSymbol](other) {
2818
+ return this.equals(
2819
+ /** @type {any} */
2820
+ other
2821
+ );
2822
+ }
2823
+ /**
2824
+ * Use `schema.validate(obj)` with a typed parameter that is already of typed to be an instance of
2825
+ * Schema. Validate will check the structure of the parameter and return true iff the instance
2826
+ * really is an instance of Schema.
2827
+ *
2828
+ * @param {T} o
2829
+ * @return {boolean}
2830
+ */
2831
+ validate(o) {
2832
+ return this.check(o);
2833
+ }
2834
+ /* c8 ignore start */
2835
+ /**
2836
+ * Similar to validate, but this method accepts untyped parameters.
2837
+ *
2838
+ * @param {any} _o
2839
+ * @param {ValidationError} [_err]
2840
+ * @return {_o is T}
2841
+ */
2842
+ check(_o, _err) {
2843
+ methodUnimplemented();
2844
+ }
2845
+ /* c8 ignore stop */
2846
+ /**
2847
+ * @type {Schema<T?>}
2848
+ */
2849
+ get nullable() {
2850
+ return $union(this, $null);
2851
+ }
2852
+ /**
2853
+ * @type {$Optional<Schema<T>>}
2854
+ */
2855
+ get optional() {
2856
+ return new $Optional(
2857
+ /** @type {Schema<T>} */
2858
+ this
2859
+ );
2860
+ }
2861
+ /**
2862
+ * Cast a variable to a specific type. Returns the casted value, or throws an exception otherwise.
2863
+ * Use this if you know that the type is of a specific type and you just want to convince the type
2864
+ * system.
2865
+ *
2866
+ * **Do not rely on these error messages!**
2867
+ * Performs an assertion check only if not in a production environment.
2868
+ *
2869
+ * @template OO
2870
+ * @param {OO} o
2871
+ * @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)}
2872
+ */
2873
+ cast(o) {
2874
+ assert(o, this);
2875
+ return (
2876
+ /** @type {any} */
2877
+ o
2878
+ );
2879
+ }
2880
+ /**
2881
+ * EXPECTO PATRONUM!! 🪄
2882
+ * This function protects against type errors. Though it may not work in the real world.
2883
+ *
2884
+ * "After all this time?"
2885
+ * "Always." - Snape, talking about type safety
2886
+ *
2887
+ * Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed.
2888
+ * Use this if you know that the type is of a specific type and you just want to convince the type
2889
+ * system.
2890
+ *
2891
+ * Can be useful when defining lambdas: `s.lambda(s.$number, s.$void).expect((n) => n + 1)`
2892
+ *
2893
+ * **Do not rely on these error messages!**
2894
+ * Performs an assertion check if not in a production environment.
2895
+ *
2896
+ * @param {T} o
2897
+ * @return {o extends T ? T : never}
2898
+ */
2899
+ expect(o) {
2900
+ assert(o, this);
2901
+ return o;
2902
+ }
2903
+ };
2904
+ var $ConstructedBy = class extends Schema {
2905
+ /**
2906
+ * @param {C} c
2907
+ * @param {((o:Instance<C>)=>boolean)|null} check
2908
+ */
2909
+ constructor(c, check) {
2910
+ super();
2911
+ this.shape = c;
2912
+ this._c = check;
2913
+ }
2914
+ /**
2915
+ * @param {any} o
2916
+ * @param {ValidationError} [err]
2917
+ * @return {o is C extends ((...args:any[]) => infer T) ? T : (C extends (new (...args:any[]) => any) ? InstanceType<C> : never)} o
2918
+ */
2919
+ check(o, err = void 0) {
2920
+ const c = o?.constructor === this.shape && (this._c == null || this._c(o));
2921
+ !c && err?.extend(null, this.shape.name, o?.constructor.name, o?.constructor !== this.shape ? "Constructor match failed" : "Check failed");
2922
+ return c;
2923
+ }
2924
+ };
2925
+ var $constructedBy = (c, check = null) => new $ConstructedBy(c, check);
2926
+ $constructedBy($ConstructedBy);
2927
+ var $Custom = class extends Schema {
2928
+ /**
2929
+ * @param {(o:any) => boolean} check
2930
+ */
2931
+ constructor(check) {
2932
+ super();
2933
+ this.shape = check;
2934
+ }
2935
+ /**
2936
+ * @param {any} o
2937
+ * @param {ValidationError} err
2938
+ * @return {o is any}
2939
+ */
2940
+ check(o, err) {
2941
+ const c = this.shape(o);
2942
+ !c && err?.extend(null, "custom prop", o?.constructor.name, "failed to check custom prop");
2943
+ return c;
2944
+ }
2945
+ };
2946
+ var $custom = (check) => new $Custom(check);
2947
+ $constructedBy($Custom);
2948
+ var $Literal = class extends Schema {
2949
+ /**
2950
+ * @param {Array<T>} literals
2951
+ */
2952
+ constructor(literals) {
2953
+ super();
2954
+ this.shape = literals;
2955
+ }
2956
+ /**
2957
+ *
2958
+ * @param {any} o
2959
+ * @param {ValidationError} [err]
2960
+ * @return {o is T}
2961
+ */
2962
+ check(o, err) {
2963
+ const c = this.shape.some((a) => a === o);
2964
+ !c && err?.extend(null, this.shape.join(" | "), o.toString());
2965
+ return c;
2966
+ }
2967
+ };
2968
+ var $literal = (...literals) => new $Literal(literals);
2969
+ var $$literal = $constructedBy($Literal);
2970
+ var _regexEscape = (
2971
+ /** @type {any} */
2972
+ RegExp.escape || /** @type {(str:string) => string} */
2973
+ ((str) => str.replace(/[().|&,$^[\]]/g, (s) => "\\" + s))
2974
+ );
2975
+ var _schemaStringTemplateToRegex = (s) => {
2976
+ if ($string.check(s)) {
2977
+ return [_regexEscape(s)];
2978
+ }
2979
+ if ($$literal.check(s)) {
2980
+ return (
2981
+ /** @type {Array<string|number>} */
2982
+ s.shape.map((v) => v + "")
2983
+ );
2984
+ }
2985
+ if ($$number.check(s)) {
2986
+ return ["[+-]?\\d+.?\\d*"];
2987
+ }
2988
+ if ($$string.check(s)) {
2989
+ return [".*"];
2990
+ }
2991
+ if ($$union.check(s)) {
2992
+ return s.shape.map(_schemaStringTemplateToRegex).flat(1);
2993
+ }
2994
+ unexpectedCase();
2995
+ };
2996
+ var $StringTemplate = class extends Schema {
2997
+ /**
2998
+ * @param {T} shape
2999
+ */
3000
+ constructor(shape) {
3001
+ super();
3002
+ this.shape = shape;
3003
+ this._r = new RegExp("^" + shape.map(_schemaStringTemplateToRegex).map((opts) => `(${opts.join("|")})`).join("") + "$");
3004
+ }
3005
+ /**
3006
+ * @param {any} o
3007
+ * @param {ValidationError} [err]
3008
+ * @return {o is CastStringTemplateArgsToTemplate<T>}
3009
+ */
3010
+ check(o, err) {
3011
+ const c = this._r.exec(o) != null;
3012
+ !c && err?.extend(null, this._r.toString(), o.toString(), "String doesn't match string template.");
3013
+ return c;
3014
+ }
3015
+ };
3016
+ $constructedBy($StringTemplate);
3017
+ var isOptionalSymbol = /* @__PURE__ */ Symbol("optional");
3018
+ var $Optional = class extends Schema {
3019
+ /**
3020
+ * @param {S} shape
3021
+ */
3022
+ constructor(shape) {
3023
+ super();
3024
+ this.shape = shape;
3025
+ }
3026
+ /**
3027
+ * @param {any} o
3028
+ * @param {ValidationError} [err]
3029
+ * @return {o is (Unwrap<S>|undefined)}
3030
+ */
3031
+ check(o, err) {
3032
+ const c = o === void 0 || this.shape.check(o);
3033
+ !c && err?.extend(null, "undefined (optional)", "()");
3034
+ return c;
3035
+ }
3036
+ get [isOptionalSymbol]() {
3037
+ return true;
3038
+ }
3039
+ };
3040
+ var $$optional = $constructedBy($Optional);
3041
+ var $Never = class extends Schema {
3042
+ /**
3043
+ * @param {any} _o
3044
+ * @param {ValidationError} [err]
3045
+ * @return {_o is never}
3046
+ */
3047
+ check(_o, err) {
3048
+ err?.extend(null, "never", typeof _o);
3049
+ return false;
3050
+ }
3051
+ };
3052
+ $constructedBy($Never);
3053
+ var $Object = class _$Object extends Schema {
3054
+ /**
3055
+ * @param {S} shape
3056
+ * @param {boolean} partial
3057
+ */
3058
+ constructor(shape, partial = false) {
3059
+ super();
3060
+ this.shape = shape;
3061
+ this._isPartial = partial;
3062
+ }
3063
+ static _dilutes = true;
3064
+ /**
3065
+ * @type {Schema<Partial<$ObjectToType<S>>>}
3066
+ */
3067
+ get partial() {
3068
+ return new _$Object(this.shape, true);
3069
+ }
3070
+ /**
3071
+ * @param {any} o
3072
+ * @param {ValidationError} err
3073
+ * @return {o is $ObjectToType<S>}
3074
+ */
3075
+ check(o, err) {
3076
+ if (o == null) {
3077
+ err?.extend(null, "object", "null");
3078
+ return false;
3079
+ }
3080
+ return every2(this.shape, (vv, vk) => {
3081
+ const c = this._isPartial && !hasProperty(o, vk) || vv.check(o[vk], err);
3082
+ !c && err?.extend(vk.toString(), vv.toString(), typeof o[vk], "Object property does not match");
3083
+ return c;
3084
+ });
3085
+ }
3086
+ };
3087
+ var $object = (def) => (
3088
+ /** @type {any} */
3089
+ new $Object(def)
3090
+ );
3091
+ var $$object = $constructedBy($Object);
3092
+ var $objectAny = $custom((o) => o != null && (o.constructor === Object || o.constructor == null));
3093
+ var $Record = class extends Schema {
3094
+ /**
3095
+ * @param {Keys} keys
3096
+ * @param {Values} values
3097
+ */
3098
+ constructor(keys, values) {
3099
+ super();
3100
+ this.shape = {
3101
+ keys,
3102
+ values
3103
+ };
3104
+ }
3105
+ /**
3106
+ * @param {any} o
3107
+ * @param {ValidationError} err
3108
+ * @return {o is { [key in Unwrap<Keys>]: Unwrap<Values> }}
3109
+ */
3110
+ check(o, err) {
3111
+ return o != null && every2(o, (vv, vk) => {
3112
+ const ck = this.shape.keys.check(vk, err);
3113
+ !ck && err?.extend(vk + "", "Record", typeof o, ck ? "Key doesn't match schema" : "Value doesn't match value");
3114
+ return ck && this.shape.values.check(vv, err);
3115
+ });
3116
+ }
3117
+ };
3118
+ var $record = (keys, values) => new $Record(keys, values);
3119
+ var $$record = $constructedBy($Record);
3120
+ var $Tuple = class extends Schema {
3121
+ /**
3122
+ * @param {S} shape
3123
+ */
3124
+ constructor(shape) {
3125
+ super();
3126
+ this.shape = shape;
3127
+ }
3128
+ /**
3129
+ * @param {any} o
3130
+ * @param {ValidationError} err
3131
+ * @return {o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never }}
3132
+ */
3133
+ check(o, err) {
3134
+ return o != null && every2(this.shape, (vv, vk) => {
3135
+ const c = (
3136
+ /** @type {Schema<any>} */
3137
+ vv.check(o[vk], err)
3138
+ );
3139
+ !c && err?.extend(vk.toString(), "Tuple", typeof vv);
3140
+ return c;
3141
+ });
3142
+ }
3143
+ };
3144
+ var $tuple = (...def) => new $Tuple(def);
3145
+ $constructedBy($Tuple);
3146
+ var $Array = class extends Schema {
3147
+ /**
3148
+ * @param {Array<S>} v
3149
+ */
3150
+ constructor(v) {
3151
+ super();
3152
+ this.shape = v.length === 1 ? v[0] : new $Union(v);
3153
+ }
3154
+ /**
3155
+ * @param {any} o
3156
+ * @param {ValidationError} [err]
3157
+ * @return {o is Array<S extends Schema<infer T> ? T : never>} o
3158
+ */
3159
+ check(o, err) {
3160
+ const c = isArray(o) && every(o, (oi) => this.shape.check(oi));
3161
+ !c && err?.extend(null, "Array", "");
3162
+ return c;
3163
+ }
3164
+ };
3165
+ var $array = (...def) => new $Array(def);
3166
+ var $$array = $constructedBy($Array);
3167
+ var $arrayAny = $custom((o) => isArray(o));
3168
+ var $InstanceOf = class extends Schema {
3169
+ /**
3170
+ * @param {new (...args:any) => T} constructor
3171
+ * @param {((o:T) => boolean)|null} check
3172
+ */
3173
+ constructor(constructor, check) {
3174
+ super();
3175
+ this.shape = constructor;
3176
+ this._c = check;
3177
+ }
3178
+ /**
3179
+ * @param {any} o
3180
+ * @param {ValidationError} err
3181
+ * @return {o is T}
3182
+ */
3183
+ check(o, err) {
3184
+ const c = o instanceof this.shape && (this._c == null || this._c(o));
3185
+ !c && err?.extend(null, this.shape.name, o?.constructor.name);
3186
+ return c;
3187
+ }
3188
+ };
3189
+ var $instanceOf = (c, check = null) => new $InstanceOf(c, check);
3190
+ $constructedBy($InstanceOf);
3191
+ var $$schema = $instanceOf(Schema);
3192
+ var $Lambda = class extends Schema {
3193
+ /**
3194
+ * @param {Args} args
3195
+ */
3196
+ constructor(args) {
3197
+ super();
3198
+ this.len = args.length - 1;
3199
+ this.args = $tuple(...args.slice(-1));
3200
+ this.res = args[this.len];
3201
+ }
3202
+ /**
3203
+ * @param {any} f
3204
+ * @param {ValidationError} err
3205
+ * @return {f is _LArgsToLambdaDef<Args>}
3206
+ */
3207
+ check(f, err) {
3208
+ const c = f.constructor === Function && f.length <= this.len;
3209
+ !c && err?.extend(null, "function", typeof f);
3210
+ return c;
3211
+ }
3212
+ };
3213
+ var $$lambda = $constructedBy($Lambda);
3214
+ var $function = $custom((o) => typeof o === "function");
3215
+ var $Intersection = class extends Schema {
3216
+ /**
3217
+ * @param {T} v
3218
+ */
3219
+ constructor(v) {
3220
+ super();
3221
+ this.shape = v;
3222
+ }
3223
+ /**
3224
+ * @param {any} o
3225
+ * @param {ValidationError} [err]
3226
+ * @return {o is Intersect<UnwrapArray<T>>}
3227
+ */
3228
+ check(o, err) {
3229
+ const c = every(this.shape, (check) => check.check(o, err));
3230
+ !c && err?.extend(null, "Intersectinon", typeof o);
3231
+ return c;
3232
+ }
3233
+ };
3234
+ $constructedBy($Intersection, (o) => o.shape.length > 0);
3235
+ var $Union = class extends Schema {
3236
+ static _dilutes = true;
3237
+ /**
3238
+ * @param {Array<Schema<S>>} v
3239
+ */
3240
+ constructor(v) {
3241
+ super();
3242
+ this.shape = v;
3243
+ }
3244
+ /**
3245
+ * @param {any} o
3246
+ * @param {ValidationError} [err]
3247
+ * @return {o is S}
3248
+ */
3249
+ check(o, err) {
3250
+ const c = some(this.shape, (vv) => vv.check(o, err));
3251
+ err?.extend(null, "Union", typeof o);
3252
+ return c;
3253
+ }
3254
+ };
3255
+ var $union = (...schemas) => schemas.findIndex(($s) => $$union.check($s)) >= 0 ? $union(...schemas.map(($s) => $($s)).map(($s) => $$union.check($s) ? $s.shape : [$s]).flat(1)) : schemas.length === 1 ? schemas[0] : new $Union(schemas);
3256
+ var $$union = (
3257
+ /** @type {Schema<$Union<any>>} */
3258
+ $constructedBy($Union)
3259
+ );
3260
+ var _t = () => true;
3261
+ var $any = $custom(_t);
3262
+ var $$any = (
3263
+ /** @type {Schema<Schema<any>>} */
3264
+ $constructedBy($Custom, (o) => o.shape === _t)
3265
+ );
3266
+ var $bigint = $custom((o) => typeof o === "bigint");
3267
+ var $$bigint = (
3268
+ /** @type {Schema<Schema<BigInt>>} */
3269
+ $custom((o) => o === $bigint)
3270
+ );
3271
+ var $symbol = $custom((o) => typeof o === "symbol");
3272
+ (
3273
+ /** @type {Schema<Schema<Symbol>>} */
3274
+ $custom((o) => o === $symbol)
3275
+ );
3276
+ var $number = $custom((o) => typeof o === "number");
3277
+ var $$number = (
3278
+ /** @type {Schema<Schema<number>>} */
3279
+ $custom((o) => o === $number)
3280
+ );
3281
+ var $string = $custom((o) => typeof o === "string");
3282
+ var $$string = (
3283
+ /** @type {Schema<Schema<string>>} */
3284
+ $custom((o) => o === $string)
3285
+ );
3286
+ var $boolean = $custom((o) => typeof o === "boolean");
3287
+ var $$boolean = (
3288
+ /** @type {Schema<Schema<Boolean>>} */
3289
+ $custom((o) => o === $boolean)
3290
+ );
3291
+ var $undefined = $literal(void 0);
3292
+ (
3293
+ /** @type {Schema<Schema<undefined>>} */
3294
+ $constructedBy($Literal, (o) => o.shape.length === 1 && o.shape[0] === void 0)
3295
+ );
3296
+ $literal(void 0);
3297
+ var $null = $literal(null);
3298
+ var $$null = (
3299
+ /** @type {Schema<Schema<null>>} */
3300
+ $constructedBy($Literal, (o) => o.shape.length === 1 && o.shape[0] === null)
3301
+ );
3302
+ $constructedBy(Uint8Array);
3303
+ (
3304
+ /** @type {Schema<Schema<Uint8Array>>} */
3305
+ $constructedBy($ConstructedBy, (o) => o.shape === Uint8Array)
3306
+ );
3307
+ var $primitive = $union($number, $string, $null, $undefined, $bigint, $boolean, $symbol);
3308
+ (() => {
3309
+ const $jsonArr = (
3310
+ /** @type {$Array<$any>} */
3311
+ $array($any)
3312
+ );
3313
+ const $jsonRecord = (
3314
+ /** @type {$Record<$string,$any>} */
3315
+ $record($string, $any)
3316
+ );
3317
+ const $json2 = $union($number, $string, $null, $boolean, $jsonArr, $jsonRecord);
3318
+ $jsonArr.shape = $json2;
3319
+ $jsonRecord.shape.values = $json2;
3320
+ return $json2;
3321
+ })();
3322
+ var $ = (o) => {
3323
+ if ($$schema.check(o)) {
3324
+ return (
3325
+ /** @type {any} */
3326
+ o
3327
+ );
3328
+ } else if ($objectAny.check(o)) {
3329
+ const o2 = {};
3330
+ for (const k in o) {
3331
+ o2[k] = $(o[k]);
3332
+ }
3333
+ return (
3334
+ /** @type {any} */
3335
+ $object(o2)
3336
+ );
3337
+ } else if ($arrayAny.check(o)) {
3338
+ return (
3339
+ /** @type {any} */
3340
+ $union(...o.map($))
3341
+ );
3342
+ } else if ($primitive.check(o)) {
3343
+ return (
3344
+ /** @type {any} */
3345
+ $literal(o)
3346
+ );
3347
+ } else if ($function.check(o)) {
3348
+ return (
3349
+ /** @type {any} */
3350
+ $constructedBy(
3351
+ /** @type {any} */
3352
+ o
3353
+ )
3354
+ );
3355
+ }
3356
+ unexpectedCase();
3357
+ };
3358
+ var assert = production ? () => {
3359
+ } : (o, schema) => {
3360
+ const err = new ValidationError();
3361
+ if (!schema.check(o, err)) {
3362
+ throw create3(`Expected value to be of type ${schema.constructor.name}.
3363
+ ${err.toString()}`);
3364
+ }
3365
+ };
3366
+ var PatternMatcher = class {
3367
+ /**
3368
+ * @param {Schema<State>} [$state]
3369
+ */
3370
+ constructor($state) {
3371
+ this.patterns = [];
3372
+ this.$state = $state;
3373
+ }
3374
+ /**
3375
+ * @template P
3376
+ * @template R
3377
+ * @param {P} pattern
3378
+ * @param {(o:NoInfer<Unwrap<ReadSchema<P>>>,s:State)=>R} handler
3379
+ * @return {PatternMatcher<State,Patterns|Pattern<Unwrap<ReadSchema<P>>,R>>}
3380
+ */
3381
+ if(pattern, handler) {
3382
+ this.patterns.push({ if: $(pattern), h: handler });
3383
+ return this;
3384
+ }
3385
+ /**
3386
+ * @template R
3387
+ * @param {(o:any,s:State)=>R} h
3388
+ */
3389
+ else(h) {
3390
+ return this.if($any, h);
3391
+ }
3392
+ /**
3393
+ * @return {State extends undefined
3394
+ * ? <In extends Unwrap<Patterns['if']>>(o:In,state?:undefined)=>PatternMatchResult<Patterns,In>
3395
+ * : <In extends Unwrap<Patterns['if']>>(o:In,state:State)=>PatternMatchResult<Patterns,In>}
3396
+ */
3397
+ done() {
3398
+ return (
3399
+ /** @type {any} */
3400
+ (o, s) => {
3401
+ for (let i = 0; i < this.patterns.length; i++) {
3402
+ const p = this.patterns[i];
3403
+ if (p.if.check(o)) {
3404
+ return p.h(o, s);
3405
+ }
3406
+ }
3407
+ throw create3("Unhandled pattern");
3408
+ }
3409
+ );
3410
+ }
3411
+ };
3412
+ var match = (state) => new PatternMatcher(
3413
+ /** @type {any} */
3414
+ state
3415
+ );
3416
+ var _random = (
3417
+ /** @type {any} */
3418
+ match(
3419
+ /** @type {Schema<prng.PRNG>} */
3420
+ $any
3421
+ ).if($$number, (_o, gen) => int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER)).if($$string, (_o, gen) => word(gen)).if($$boolean, (_o, gen) => bool(gen)).if($$bigint, (_o, gen) => BigInt(int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER))).if($$union, (o, gen) => random(gen, oneOf(gen, o.shape))).if($$object, (o, gen) => {
3422
+ const res = {};
3423
+ for (const k in o.shape) {
3424
+ let prop = o.shape[k];
3425
+ if ($$optional.check(prop)) {
3426
+ if (bool(gen)) {
3427
+ continue;
3428
+ }
3429
+ prop = prop.shape;
3430
+ }
3431
+ res[k] = _random(prop, gen);
3432
+ }
3433
+ return res;
3434
+ }).if($$array, (o, gen) => {
3435
+ const arr = [];
3436
+ const n = int32(gen, 0, 42);
3437
+ for (let i = 0; i < n; i++) {
3438
+ arr.push(random(gen, o.shape));
3439
+ }
3440
+ return arr;
3441
+ }).if($$literal, (o, gen) => {
3442
+ return oneOf(gen, o.shape);
3443
+ }).if($$null, (o, gen) => {
3444
+ return null;
3445
+ }).if($$lambda, (o, gen) => {
3446
+ const res = random(gen, o.res);
3447
+ return () => res;
3448
+ }).if($$any, (o, gen) => random(gen, oneOf(gen, [
3449
+ $number,
3450
+ $string,
3451
+ $null,
3452
+ $undefined,
3453
+ $bigint,
3454
+ $boolean,
3455
+ $array($number),
3456
+ $record($union("a", "b", "c"), $number)
3457
+ ]))).if($$record, (o, gen) => {
3458
+ const res = {};
3459
+ const keysN = int53(gen, 0, 3);
3460
+ for (let i = 0; i < keysN; i++) {
3461
+ const key = random(gen, o.shape.keys);
3462
+ const val = random(gen, o.shape.values);
3463
+ res[key] = val;
3464
+ }
3465
+ return res;
3466
+ }).done()
3467
+ );
3468
+ var random = (gen, schema) => (
3469
+ /** @type {any} */
3470
+ _random($(schema), gen)
3471
+ );
3472
+
3473
+ // ../../node_modules/lib0/dom.js
3474
+ var doc = (
3475
+ /** @type {Document} */
3476
+ typeof document !== "undefined" ? document : {}
3477
+ );
3478
+ $custom((el) => el.nodeType === DOCUMENT_FRAGMENT_NODE);
3479
+ (
3480
+ /** @type {DOMParser} */
3481
+ typeof DOMParser !== "undefined" ? new DOMParser() : null
3482
+ );
3483
+ $custom((el) => el.nodeType === ELEMENT_NODE);
3484
+ $custom((el) => el.nodeType === TEXT_NODE);
3485
+ var mapToStyleString = (m) => map(m, (value, key) => `${key}:${value};`).join("");
3486
+ var ELEMENT_NODE = doc.ELEMENT_NODE;
3487
+ var TEXT_NODE = doc.TEXT_NODE;
3488
+ var DOCUMENT_NODE = doc.DOCUMENT_NODE;
3489
+ var DOCUMENT_FRAGMENT_NODE = doc.DOCUMENT_FRAGMENT_NODE;
3490
+ $custom((el) => el.nodeType === DOCUMENT_NODE);
3491
+
3492
+ // ../../node_modules/lib0/json.js
3493
+ var stringify = JSON.stringify;
3494
+
3495
+ // ../../node_modules/lib0/symbol.js
3496
+ var create5 = Symbol;
3497
+
3498
+ // ../../node_modules/lib0/logging.common.js
3499
+ var BOLD = create5();
3500
+ var UNBOLD = create5();
3501
+ var BLUE = create5();
3502
+ var GREY = create5();
3503
+ var GREEN = create5();
3504
+ var RED = create5();
3505
+ var PURPLE = create5();
3506
+ var ORANGE = create5();
3507
+ var UNCOLOR = create5();
3508
+ var computeNoColorLoggingArgs = (args) => {
3509
+ if (args.length === 1 && args[0]?.constructor === Function) {
3510
+ args = /** @type {Array<string|Symbol|Object|number>} */
3511
+ /** @type {[function]} */
3512
+ args[0]();
3513
+ }
3514
+ const strBuilder = [];
3515
+ const logArgs = [];
3516
+ let i = 0;
3517
+ for (; i < args.length; i++) {
3518
+ const arg = args[i];
3519
+ if (arg === void 0) {
3520
+ break;
3521
+ } else if (arg.constructor === String || arg.constructor === Number) {
3522
+ strBuilder.push(arg);
3523
+ } else if (arg.constructor === Object) {
3524
+ break;
3525
+ }
3526
+ }
3527
+ if (i > 0) {
3528
+ logArgs.push(strBuilder.join(""));
3529
+ }
3530
+ for (; i < args.length; i++) {
3531
+ const arg = args[i];
3532
+ if (!(arg instanceof Symbol)) {
3533
+ logArgs.push(arg);
3534
+ }
3535
+ }
3536
+ return logArgs;
3537
+ };
3538
+ var loggingColors = [GREEN, PURPLE, ORANGE, BLUE];
3539
+ var nextColor = 0;
3540
+ var lastLoggingTime = getUnixTime();
3541
+ var createModuleLogger = (_print, moduleName) => {
3542
+ const color = loggingColors[nextColor];
3543
+ const debugRegexVar = getVariable("log");
3544
+ const doLogging = debugRegexVar !== null && (debugRegexVar === "*" || debugRegexVar === "true" || new RegExp(debugRegexVar, "gi").test(moduleName));
3545
+ nextColor = (nextColor + 1) % loggingColors.length;
3546
+ moduleName += ": ";
3547
+ return !doLogging ? nop : (...args) => {
3548
+ if (args.length === 1 && args[0]?.constructor === Function) {
3549
+ args = args[0]();
3550
+ }
3551
+ const timeNow = getUnixTime();
3552
+ const timeDiff = timeNow - lastLoggingTime;
3553
+ lastLoggingTime = timeNow;
3554
+ _print(
3555
+ color,
3556
+ moduleName,
3557
+ UNCOLOR,
3558
+ ...args.map((arg) => {
3559
+ if (arg != null && arg.constructor === Uint8Array) {
3560
+ arg = Array.from(arg);
3561
+ }
3562
+ const t = typeof arg;
3563
+ switch (t) {
3564
+ case "string":
3565
+ case "symbol":
3566
+ return arg;
3567
+ default: {
3568
+ return stringify(arg);
3569
+ }
3570
+ }
3571
+ }),
3572
+ color,
3573
+ " +" + timeDiff + "ms"
3574
+ );
3575
+ };
3576
+ };
3577
+
3578
+ // ../../node_modules/lib0/logging.js
3579
+ var _browserStyleMap = {
3580
+ [BOLD]: create4("font-weight", "bold"),
3581
+ [UNBOLD]: create4("font-weight", "normal"),
3582
+ [BLUE]: create4("color", "blue"),
3583
+ [GREEN]: create4("color", "green"),
3584
+ [GREY]: create4("color", "grey"),
3585
+ [RED]: create4("color", "red"),
3586
+ [PURPLE]: create4("color", "purple"),
3587
+ [ORANGE]: create4("color", "orange"),
3588
+ // not well supported in chrome when debugging node with inspector - TODO: deprecate
3589
+ [UNCOLOR]: create4("color", "black")
3590
+ };
3591
+ var computeBrowserLoggingArgs = (args) => {
3592
+ if (args.length === 1 && args[0]?.constructor === Function) {
3593
+ args = /** @type {Array<string|Symbol|Object|number>} */
3594
+ /** @type {[function]} */
3595
+ args[0]();
3596
+ }
3597
+ const strBuilder = [];
3598
+ const styles = [];
3599
+ const currentStyle = create();
3600
+ let logArgs = [];
3601
+ let i = 0;
3602
+ for (; i < args.length; i++) {
3603
+ const arg = args[i];
3604
+ const style = _browserStyleMap[arg];
3605
+ if (style !== void 0) {
3606
+ currentStyle.set(style.left, style.right);
3607
+ } else {
3608
+ if (arg === void 0) {
3609
+ break;
3610
+ }
3611
+ if (arg.constructor === String || arg.constructor === Number) {
3612
+ const style2 = mapToStyleString(currentStyle);
3613
+ if (i > 0 || style2.length > 0) {
3614
+ strBuilder.push("%c" + arg);
3615
+ styles.push(style2);
3616
+ } else {
3617
+ strBuilder.push(arg);
3618
+ }
3619
+ } else {
3620
+ break;
3621
+ }
3622
+ }
3623
+ }
3624
+ if (i > 0) {
3625
+ logArgs = styles;
3626
+ logArgs.unshift(strBuilder.join(""));
3627
+ }
3628
+ for (; i < args.length; i++) {
3629
+ const arg = args[i];
3630
+ if (!(arg instanceof Symbol)) {
3631
+ logArgs.push(arg);
3632
+ }
3633
+ }
3634
+ return logArgs;
3635
+ };
3636
+ var computeLoggingArgs = supportsColor ? computeBrowserLoggingArgs : computeNoColorLoggingArgs;
3637
+ var print = (...args) => {
3638
+ console.log(...computeLoggingArgs(args));
3639
+ vconsoles.forEach((vc) => vc.print(args));
3640
+ };
3641
+ var vconsoles = create2();
3642
+ var createModuleLogger2 = (moduleName) => createModuleLogger(print, moduleName);
3643
+
3644
+ // ../../node_modules/lib0/promise.js
3645
+ Promise.all.bind(Promise);
3646
+ var reject = (reason) => Promise.reject(reason);
3647
+ var resolve = (res) => Promise.resolve(res);
3648
+
3649
+ // ../../node_modules/lib0/mutex.js
3650
+ var createMutex = () => {
3651
+ let token = true;
3652
+ return (f, g) => {
3653
+ if (token) {
3654
+ token = false;
3655
+ try {
3656
+ f();
3657
+ } finally {
3658
+ token = true;
3659
+ }
3660
+ } else if (g !== void 0) {
3661
+ g();
3662
+ }
3663
+ };
3664
+ };
3665
+
3666
+ // ../../node_modules/y-webrtc/src/y-webrtc.js
3667
+ var import_simplepeer_min = __toESM(require_simplepeer_min(), 1);
3668
+
3669
+ // ../../node_modules/y-webrtc/src/crypto.js
3670
+ var deriveKey = (secret, roomName) => {
3671
+ const secretBuffer = encodeUtf8(secret).buffer;
3672
+ const salt = encodeUtf8(roomName).buffer;
3673
+ return crypto.subtle.importKey(
3674
+ "raw",
3675
+ secretBuffer,
3676
+ "PBKDF2",
3677
+ false,
3678
+ ["deriveKey"]
3679
+ ).then(
3680
+ (keyMaterial) => crypto.subtle.deriveKey(
3681
+ {
3682
+ name: "PBKDF2",
3683
+ salt,
3684
+ iterations: 1e5,
3685
+ hash: "SHA-256"
3686
+ },
3687
+ keyMaterial,
3688
+ {
3689
+ name: "AES-GCM",
3690
+ length: 256
3691
+ },
3692
+ true,
3693
+ ["encrypt", "decrypt"]
3694
+ )
3695
+ );
3696
+ };
3697
+ var encrypt = (data, key) => {
3698
+ if (!key) {
3699
+ return (
3700
+ /** @type {PromiseLike<Uint8Array>} */
3701
+ resolve(data)
3702
+ );
3703
+ }
3704
+ const iv = crypto.getRandomValues(new Uint8Array(12));
3705
+ return crypto.subtle.encrypt(
3706
+ {
3707
+ name: "AES-GCM",
3708
+ iv
3709
+ },
3710
+ key,
3711
+ data
3712
+ ).then((cipher) => {
3713
+ const encryptedDataEncoder = createEncoder();
3714
+ writeVarString(encryptedDataEncoder, "AES-GCM");
3715
+ writeVarUint8Array(encryptedDataEncoder, iv);
3716
+ writeVarUint8Array(encryptedDataEncoder, new Uint8Array(cipher));
3717
+ return toUint8Array(encryptedDataEncoder);
3718
+ });
3719
+ };
3720
+ var encryptJson = (data, key) => {
3721
+ const dataEncoder = createEncoder();
3722
+ writeAny(dataEncoder, data);
3723
+ return encrypt(toUint8Array(dataEncoder), key);
3724
+ };
3725
+ var decrypt = (data, key) => {
3726
+ if (!key) {
3727
+ return (
3728
+ /** @type {PromiseLike<Uint8Array>} */
3729
+ resolve(data)
3730
+ );
3731
+ }
3732
+ const dataDecoder = createDecoder(data);
3733
+ const algorithm = readVarString(dataDecoder);
3734
+ if (algorithm !== "AES-GCM") {
3735
+ reject(create3("Unknown encryption algorithm"));
3736
+ }
3737
+ const iv = readVarUint8Array(dataDecoder);
3738
+ const cipher = readVarUint8Array(dataDecoder);
3739
+ return crypto.subtle.decrypt(
3740
+ {
3741
+ name: "AES-GCM",
3742
+ iv
3743
+ },
3744
+ key,
3745
+ cipher
3746
+ ).then((data2) => new Uint8Array(data2));
3747
+ };
3748
+ var decryptJson = (data, key) => decrypt(data, key).then(
3749
+ (decryptedValue) => readAny(createDecoder(new Uint8Array(decryptedValue)))
3750
+ );
3751
+
3752
+ // ../../node_modules/y-webrtc/src/y-webrtc.js
3753
+ var log = createModuleLogger2("y-webrtc");
3754
+ var messageSync = 0;
3755
+ var messageQueryAwareness = 3;
3756
+ var messageAwareness = 1;
3757
+ var messageBcPeerId = 4;
3758
+ var signalingConns = /* @__PURE__ */ new Map();
3759
+ var rooms = /* @__PURE__ */ new Map();
3760
+ var checkIsSynced = (room) => {
3761
+ let synced = true;
3762
+ room.webrtcConns.forEach((peer) => {
3763
+ if (!peer.synced) {
3764
+ synced = false;
3765
+ }
3766
+ });
3767
+ if (!synced && room.synced || synced && !room.synced) {
3768
+ room.synced = synced;
3769
+ room.provider.emit("synced", [{ synced }]);
3770
+ log("synced ", BOLD, room.name, UNBOLD, " with all peers");
3771
+ }
3772
+ };
3773
+ var readMessage = (room, buf, syncedCallback) => {
3774
+ const decoder = createDecoder(buf);
3775
+ const encoder = createEncoder();
3776
+ const messageType = readVarUint(decoder);
3777
+ if (room === void 0) {
3778
+ return null;
3779
+ }
3780
+ const awareness = room.awareness;
3781
+ const doc2 = room.doc;
3782
+ let sendReply = false;
3783
+ switch (messageType) {
3784
+ case messageSync: {
3785
+ writeVarUint(encoder, messageSync);
3786
+ const syncMessageType = readSyncMessage(decoder, encoder, doc2, room);
3787
+ if (syncMessageType === messageYjsSyncStep2 && !room.synced) {
3788
+ syncedCallback();
3789
+ }
3790
+ if (syncMessageType === messageYjsSyncStep1) {
3791
+ sendReply = true;
3792
+ }
3793
+ break;
3794
+ }
3795
+ case messageQueryAwareness:
3796
+ writeVarUint(encoder, messageAwareness);
3797
+ writeVarUint8Array(encoder, encodeAwarenessUpdate(awareness, Array.from(awareness.getStates().keys())));
3798
+ sendReply = true;
3799
+ break;
3800
+ case messageAwareness:
3801
+ applyAwarenessUpdate(awareness, readVarUint8Array(decoder), room);
3802
+ break;
3803
+ case messageBcPeerId: {
3804
+ const add = readUint8(decoder) === 1;
3805
+ const peerName = readVarString(decoder);
3806
+ if (peerName !== room.peerId && (room.bcConns.has(peerName) && !add || !room.bcConns.has(peerName) && add)) {
3807
+ const removed = [];
3808
+ const added = [];
3809
+ if (add) {
3810
+ room.bcConns.add(peerName);
3811
+ added.push(peerName);
3812
+ } else {
3813
+ room.bcConns.delete(peerName);
3814
+ removed.push(peerName);
3815
+ }
3816
+ room.provider.emit("peers", [{
3817
+ added,
3818
+ removed,
3819
+ webrtcPeers: Array.from(room.webrtcConns.keys()),
3820
+ bcPeers: Array.from(room.bcConns)
3821
+ }]);
3822
+ broadcastBcPeerId(room);
3823
+ }
3824
+ break;
3825
+ }
3826
+ default:
3827
+ console.error("Unable to compute message");
3828
+ return encoder;
3829
+ }
3830
+ if (!sendReply) {
3831
+ return null;
3832
+ }
3833
+ return encoder;
3834
+ };
3835
+ var readPeerMessage = (peerConn, buf) => {
3836
+ const room = peerConn.room;
3837
+ log("received message from ", BOLD, peerConn.remotePeerId, GREY, " (", room.name, ")", UNBOLD, UNCOLOR);
3838
+ return readMessage(room, buf, () => {
3839
+ peerConn.synced = true;
3840
+ log("synced ", BOLD, room.name, UNBOLD, " with ", BOLD, peerConn.remotePeerId);
3841
+ checkIsSynced(room);
3842
+ });
3843
+ };
3844
+ var sendWebrtcConn = (webrtcConn, encoder) => {
3845
+ log("send message to ", BOLD, webrtcConn.remotePeerId, UNBOLD, GREY, " (", webrtcConn.room.name, ")", UNCOLOR);
3846
+ try {
3847
+ webrtcConn.peer.send(toUint8Array(encoder));
3848
+ } catch (e) {
3849
+ }
3850
+ };
3851
+ var broadcastWebrtcConn = (room, m) => {
3852
+ log("broadcast message in ", BOLD, room.name, UNBOLD);
3853
+ room.webrtcConns.forEach((conn) => {
3854
+ try {
3855
+ conn.peer.send(m);
3856
+ } catch (e) {
3857
+ }
3858
+ });
3859
+ };
3860
+ var WebrtcConn = class {
3861
+ /**
3862
+ * @param {SignalingConn} signalingConn
3863
+ * @param {boolean} initiator
3864
+ * @param {string} remotePeerId
3865
+ * @param {Room} room
3866
+ */
3867
+ constructor(signalingConn, initiator, remotePeerId, room) {
3868
+ log("establishing connection to ", BOLD, remotePeerId);
3869
+ this.room = room;
3870
+ this.remotePeerId = remotePeerId;
3871
+ this.glareToken = void 0;
3872
+ this.closed = false;
3873
+ this.connected = false;
3874
+ this.synced = false;
3875
+ this.peer = new import_simplepeer_min.default({ initiator, ...room.provider.peerOpts });
3876
+ this.peer.on("signal", (signal) => {
3877
+ if (this.glareToken === void 0) {
3878
+ this.glareToken = Date.now() + Math.random();
3879
+ }
3880
+ publishSignalingMessage(signalingConn, room, { to: remotePeerId, from: room.peerId, type: "signal", token: this.glareToken, signal });
3881
+ });
3882
+ this.peer.on("connect", () => {
3883
+ log("connected to ", BOLD, remotePeerId);
3884
+ this.connected = true;
3885
+ const provider = room.provider;
3886
+ const doc2 = provider.doc;
3887
+ const awareness = room.awareness;
3888
+ const encoder = createEncoder();
3889
+ writeVarUint(encoder, messageSync);
3890
+ writeSyncStep1(encoder, doc2);
3891
+ sendWebrtcConn(this, encoder);
3892
+ const awarenessStates = awareness.getStates();
3893
+ if (awarenessStates.size > 0) {
3894
+ const encoder2 = createEncoder();
3895
+ writeVarUint(encoder2, messageAwareness);
3896
+ writeVarUint8Array(encoder2, encodeAwarenessUpdate(awareness, Array.from(awarenessStates.keys())));
3897
+ sendWebrtcConn(this, encoder2);
3898
+ }
3899
+ });
3900
+ this.peer.on("close", () => {
3901
+ this.connected = false;
3902
+ this.closed = true;
3903
+ if (room.webrtcConns.has(this.remotePeerId)) {
3904
+ room.webrtcConns.delete(this.remotePeerId);
3905
+ room.provider.emit("peers", [{
3906
+ removed: [this.remotePeerId],
3907
+ added: [],
3908
+ webrtcPeers: Array.from(room.webrtcConns.keys()),
3909
+ bcPeers: Array.from(room.bcConns)
3910
+ }]);
3911
+ }
3912
+ checkIsSynced(room);
3913
+ this.peer.destroy();
3914
+ log("closed connection to ", BOLD, remotePeerId);
3915
+ announceSignalingInfo(room);
3916
+ });
3917
+ this.peer.on("error", (err) => {
3918
+ log("Error in connection to ", BOLD, remotePeerId, ": ", err);
3919
+ announceSignalingInfo(room);
3920
+ });
3921
+ this.peer.on("data", (data) => {
3922
+ const answer = readPeerMessage(this, data);
3923
+ if (answer !== null) {
3924
+ sendWebrtcConn(this, answer);
3925
+ }
3926
+ });
3927
+ }
3928
+ destroy() {
3929
+ this.peer.destroy();
3930
+ }
3931
+ };
3932
+ var broadcastBcMessage = (room, m) => encrypt(m, room.key).then(
3933
+ (data) => room.mux(
3934
+ () => publish(room.name, data)
3935
+ )
3936
+ );
3937
+ var broadcastRoomMessage = (room, m) => {
3938
+ if (room.bcconnected) {
3939
+ broadcastBcMessage(room, m);
3940
+ }
3941
+ broadcastWebrtcConn(room, m);
3942
+ };
3943
+ var announceSignalingInfo = (room) => {
3944
+ signalingConns.forEach((conn) => {
3945
+ if (conn.connected) {
3946
+ conn.send({ type: "subscribe", topics: [room.name] });
3947
+ if (room.webrtcConns.size < room.provider.maxConns) {
3948
+ publishSignalingMessage(conn, room, { type: "announce", from: room.peerId });
3949
+ }
3950
+ }
3951
+ });
3952
+ };
3953
+ var broadcastBcPeerId = (room) => {
3954
+ if (room.provider.filterBcConns) {
3955
+ const encoderPeerIdBc = createEncoder();
3956
+ writeVarUint(encoderPeerIdBc, messageBcPeerId);
3957
+ writeUint8(encoderPeerIdBc, 1);
3958
+ writeVarString(encoderPeerIdBc, room.peerId);
3959
+ broadcastBcMessage(room, toUint8Array(encoderPeerIdBc));
3960
+ }
3961
+ };
3962
+ var Room = class {
3963
+ /**
3964
+ * @param {Y.Doc} doc
3965
+ * @param {WebrtcProvider} provider
3966
+ * @param {string} name
3967
+ * @param {CryptoKey|null} key
3968
+ */
3969
+ constructor(doc2, provider, name, key) {
3970
+ this.peerId = uuidv4();
3971
+ this.doc = doc2;
3972
+ this.awareness = provider.awareness;
3973
+ this.provider = provider;
3974
+ this.synced = false;
3975
+ this.name = name;
3976
+ this.key = key;
3977
+ this.webrtcConns = /* @__PURE__ */ new Map();
3978
+ this.bcConns = /* @__PURE__ */ new Set();
3979
+ this.mux = createMutex();
3980
+ this.bcconnected = false;
3981
+ this._bcSubscriber = (data) => decrypt(new Uint8Array(data), key).then(
3982
+ (m) => this.mux(() => {
3983
+ const reply = readMessage(this, m, () => {
3984
+ });
3985
+ if (reply) {
3986
+ broadcastBcMessage(this, toUint8Array(reply));
3987
+ }
3988
+ })
3989
+ );
3990
+ this._docUpdateHandler = (update, _origin) => {
3991
+ const encoder = createEncoder();
3992
+ writeVarUint(encoder, messageSync);
3993
+ writeUpdate(encoder, update);
3994
+ broadcastRoomMessage(this, toUint8Array(encoder));
3995
+ };
3996
+ this._awarenessUpdateHandler = ({ added, updated, removed }, _origin) => {
3997
+ const changedClients = added.concat(updated).concat(removed);
3998
+ const encoderAwareness = createEncoder();
3999
+ writeVarUint(encoderAwareness, messageAwareness);
4000
+ writeVarUint8Array(encoderAwareness, encodeAwarenessUpdate(this.awareness, changedClients));
4001
+ broadcastRoomMessage(this, toUint8Array(encoderAwareness));
4002
+ };
4003
+ this._beforeUnloadHandler = () => {
4004
+ removeAwarenessStates(this.awareness, [doc2.clientID], "window unload");
4005
+ rooms.forEach((room) => {
4006
+ room.disconnect();
4007
+ });
4008
+ };
4009
+ if (typeof window !== "undefined") {
4010
+ window.addEventListener("beforeunload", this._beforeUnloadHandler);
4011
+ } else if (typeof process !== "undefined") {
4012
+ process.on("exit", this._beforeUnloadHandler);
4013
+ }
4014
+ }
4015
+ connect() {
4016
+ this.doc.on("update", this._docUpdateHandler);
4017
+ this.awareness.on("update", this._awarenessUpdateHandler);
4018
+ announceSignalingInfo(this);
4019
+ const roomName = this.name;
4020
+ subscribe(roomName, this._bcSubscriber);
4021
+ this.bcconnected = true;
4022
+ broadcastBcPeerId(this);
4023
+ const encoderSync = createEncoder();
4024
+ writeVarUint(encoderSync, messageSync);
4025
+ writeSyncStep1(encoderSync, this.doc);
4026
+ broadcastBcMessage(this, toUint8Array(encoderSync));
4027
+ const encoderState = createEncoder();
4028
+ writeVarUint(encoderState, messageSync);
4029
+ writeSyncStep2(encoderState, this.doc);
4030
+ broadcastBcMessage(this, toUint8Array(encoderState));
4031
+ const encoderAwarenessQuery = createEncoder();
4032
+ writeVarUint(encoderAwarenessQuery, messageQueryAwareness);
4033
+ broadcastBcMessage(this, toUint8Array(encoderAwarenessQuery));
4034
+ const encoderAwarenessState = createEncoder();
4035
+ writeVarUint(encoderAwarenessState, messageAwareness);
4036
+ writeVarUint8Array(encoderAwarenessState, encodeAwarenessUpdate(this.awareness, [this.doc.clientID]));
4037
+ broadcastBcMessage(this, toUint8Array(encoderAwarenessState));
4038
+ }
4039
+ disconnect() {
4040
+ signalingConns.forEach((conn) => {
4041
+ if (conn.connected) {
4042
+ conn.send({ type: "unsubscribe", topics: [this.name] });
4043
+ }
4044
+ });
4045
+ removeAwarenessStates(this.awareness, [this.doc.clientID], "disconnect");
4046
+ const encoderPeerIdBc = createEncoder();
4047
+ writeVarUint(encoderPeerIdBc, messageBcPeerId);
4048
+ writeUint8(encoderPeerIdBc, 0);
4049
+ writeVarString(encoderPeerIdBc, this.peerId);
4050
+ broadcastBcMessage(this, toUint8Array(encoderPeerIdBc));
4051
+ unsubscribe(this.name, this._bcSubscriber);
4052
+ this.bcconnected = false;
4053
+ this.doc.off("update", this._docUpdateHandler);
4054
+ this.awareness.off("update", this._awarenessUpdateHandler);
4055
+ this.webrtcConns.forEach((conn) => conn.destroy());
4056
+ }
4057
+ destroy() {
4058
+ this.disconnect();
4059
+ if (typeof window !== "undefined") {
4060
+ window.removeEventListener("beforeunload", this._beforeUnloadHandler);
4061
+ } else if (typeof process !== "undefined") {
4062
+ process.off("exit", this._beforeUnloadHandler);
4063
+ }
4064
+ }
4065
+ };
4066
+ var openRoom = (doc2, provider, name, key) => {
4067
+ if (rooms.has(name)) {
4068
+ throw create3(`A Yjs Doc connected to room "${name}" already exists!`);
4069
+ }
4070
+ const room = new Room(doc2, provider, name, key);
4071
+ rooms.set(
4072
+ name,
4073
+ /** @type {Room} */
4074
+ room
4075
+ );
4076
+ return room;
4077
+ };
4078
+ var publishSignalingMessage = (conn, room, data) => {
4079
+ if (room.key) {
4080
+ encryptJson(data, room.key).then((data2) => {
4081
+ conn.send({ type: "publish", topic: room.name, data: toBase64(data2) });
4082
+ });
4083
+ } else {
4084
+ conn.send({ type: "publish", topic: room.name, data });
4085
+ }
4086
+ };
4087
+ var SignalingConn = class extends WebsocketClient {
4088
+ constructor(url) {
4089
+ super(url);
4090
+ this.providers = /* @__PURE__ */ new Set();
4091
+ this.on("connect", () => {
4092
+ log(`connected (${url})`);
4093
+ const topics = Array.from(rooms.keys());
4094
+ this.send({ type: "subscribe", topics });
4095
+ rooms.forEach(
4096
+ (room) => publishSignalingMessage(this, room, { type: "announce", from: room.peerId })
4097
+ );
4098
+ });
4099
+ this.on("message", (m) => {
4100
+ switch (m.type) {
4101
+ case "publish": {
4102
+ const roomName = m.topic;
4103
+ const room = rooms.get(roomName);
4104
+ if (room == null || typeof roomName !== "string") {
4105
+ return;
4106
+ }
4107
+ const execMessage = (data) => {
4108
+ const webrtcConns = room.webrtcConns;
4109
+ const peerId = room.peerId;
4110
+ if (data == null || data.from === peerId || data.to !== void 0 && data.to !== peerId || room.bcConns.has(data.from)) {
4111
+ return;
4112
+ }
4113
+ const emitPeerChange = webrtcConns.has(data.from) ? () => {
4114
+ } : () => room.provider.emit("peers", [{
4115
+ removed: [],
4116
+ added: [data.from],
4117
+ webrtcPeers: Array.from(room.webrtcConns.keys()),
4118
+ bcPeers: Array.from(room.bcConns)
4119
+ }]);
4120
+ switch (data.type) {
4121
+ case "announce":
4122
+ if (webrtcConns.size < room.provider.maxConns) {
4123
+ setIfUndefined(webrtcConns, data.from, () => new WebrtcConn(this, true, data.from, room));
4124
+ emitPeerChange();
4125
+ }
4126
+ break;
4127
+ case "signal":
4128
+ if (data.signal.type === "offer") {
4129
+ const existingConn = webrtcConns.get(data.from);
4130
+ if (existingConn) {
4131
+ const remoteToken = data.token;
4132
+ const localToken = existingConn.glareToken;
4133
+ if (localToken && localToken > remoteToken) {
4134
+ log("offer rejected: ", data.from);
4135
+ return;
4136
+ }
4137
+ existingConn.glareToken = void 0;
4138
+ }
4139
+ }
4140
+ if (data.signal.type === "answer") {
4141
+ log("offer answered by: ", data.from);
4142
+ const existingConn = webrtcConns.get(data.from);
4143
+ existingConn.glareToken = void 0;
4144
+ }
4145
+ if (data.to === peerId) {
4146
+ setIfUndefined(webrtcConns, data.from, () => new WebrtcConn(this, false, data.from, room)).peer.signal(data.signal);
4147
+ emitPeerChange();
4148
+ }
4149
+ break;
4150
+ }
4151
+ };
4152
+ if (room.key) {
4153
+ if (typeof m.data === "string") {
4154
+ decryptJson(fromBase64(m.data), room.key).then(execMessage);
4155
+ }
4156
+ } else {
4157
+ execMessage(m.data);
4158
+ }
4159
+ }
4160
+ }
4161
+ });
4162
+ this.on("disconnect", () => log(`disconnect (${url})`));
4163
+ }
4164
+ };
4165
+ var emitStatus = (provider) => {
4166
+ provider.emit("status", [{
4167
+ connected: provider.connected
4168
+ }]);
4169
+ };
4170
+ var WebrtcProvider = class extends ObservableV2 {
4171
+ /**
4172
+ * @param {string} roomName
4173
+ * @param {Y.Doc} doc
4174
+ * @param {ProviderOptions?} opts
4175
+ */
4176
+ constructor(roomName, doc2, {
4177
+ signaling = ["wss://y-webrtc-eu.fly.dev"],
4178
+ password = null,
4179
+ awareness = new Awareness(doc2),
4180
+ maxConns = 20 + floor(rand() * 15),
4181
+ // the random factor reduces the chance that n clients form a cluster
4182
+ filterBcConns = true,
4183
+ peerOpts = {}
4184
+ // simple-peer options. See https://github.com/feross/simple-peer#peer--new-peeropts
4185
+ } = {}) {
4186
+ super();
4187
+ this.roomName = roomName;
4188
+ this.doc = doc2;
4189
+ this.filterBcConns = filterBcConns;
4190
+ this.awareness = awareness;
4191
+ this.shouldConnect = false;
4192
+ this.signalingUrls = signaling;
4193
+ this.signalingConns = [];
4194
+ this.maxConns = maxConns;
4195
+ this.peerOpts = peerOpts;
4196
+ this.key = password ? deriveKey(password, roomName) : (
4197
+ /** @type {PromiseLike<null>} */
4198
+ resolve(null)
4199
+ );
4200
+ this.room = null;
4201
+ this.key.then((key) => {
4202
+ this.room = openRoom(doc2, this, roomName, key);
4203
+ if (this.shouldConnect) {
4204
+ this.room.connect();
4205
+ } else {
4206
+ this.room.disconnect();
4207
+ }
4208
+ emitStatus(this);
4209
+ });
4210
+ this.connect();
4211
+ this.destroy = this.destroy.bind(this);
4212
+ doc2.on("destroy", this.destroy);
4213
+ }
4214
+ /**
4215
+ * Indicates whether the provider is looking for other peers.
4216
+ *
4217
+ * Other peers can be found via signaling servers or via broadcastchannel (cross browser-tab
4218
+ * communication). You never know when you are connected to all peers. You also don't know if
4219
+ * there are other peers. connected doesn't mean that you are connected to any physical peers
4220
+ * working on the same resource as you. It does not change unless you call provider.disconnect()
4221
+ *
4222
+ * `this.on('status', (event) => { console.log(event.connected) })`
4223
+ *
4224
+ * @type {boolean}
4225
+ */
4226
+ get connected() {
4227
+ return this.room !== null && this.shouldConnect;
4228
+ }
4229
+ connect() {
4230
+ this.shouldConnect = true;
4231
+ this.signalingUrls.forEach((url) => {
4232
+ const signalingConn = setIfUndefined(signalingConns, url, () => new SignalingConn(url));
4233
+ this.signalingConns.push(signalingConn);
4234
+ signalingConn.providers.add(this);
4235
+ });
4236
+ if (this.room) {
4237
+ this.room.connect();
4238
+ emitStatus(this);
4239
+ }
4240
+ }
4241
+ disconnect() {
4242
+ this.shouldConnect = false;
4243
+ this.signalingConns.forEach((conn) => {
4244
+ conn.providers.delete(this);
4245
+ if (conn.providers.size === 0) {
4246
+ conn.destroy();
4247
+ signalingConns.delete(conn.url);
4248
+ }
4249
+ });
4250
+ if (this.room) {
4251
+ this.room.disconnect();
4252
+ emitStatus(this);
4253
+ }
4254
+ }
4255
+ destroy() {
4256
+ this.doc.off("destroy", this.destroy);
4257
+ this.key.then(() => {
4258
+ this.room.destroy();
4259
+ rooms.delete(this.roomName);
4260
+ });
4261
+ super.destroy();
4262
+ }
4263
+ };
4264
+ /*! Bundled license information:
4265
+
4266
+ simple-peer/simplepeer.min.js:
4267
+ (*!
4268
+ * The buffer module from node.js, for the browser.
4269
+ *
4270
+ * @author Feross Aboukhadijeh <https://feross.org>
4271
+ * @license MIT
4272
+ *)
4273
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
4274
+ (*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
4275
+ (*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
4276
+ (*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
4277
+ */
4278
+
4279
+ export { Room, SignalingConn, WebrtcConn, WebrtcProvider };