@feedmepos/mf-common 1.6.4 → 1.6.6-rc.1

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.
@@ -0,0 +1,3963 @@
1
+ var _o = (i, n, a) => {
2
+ if (!n.has(i))
3
+ throw TypeError("Cannot " + a);
4
+ };
5
+ var F = (i, n, a) => (_o(i, n, "read from private field"), a ? a.call(i) : n.get(i)), Ae = (i, n, a) => {
6
+ if (n.has(i))
7
+ throw TypeError("Cannot add the same private member more than once");
8
+ n instanceof WeakSet ? n.add(i) : n.set(i, a);
9
+ }, ae = (i, n, a, u) => (_o(i, n, "write to private field"), u ? u.call(i, a) : n.set(i, a), a);
10
+ import { resolve as So } from "path";
11
+ import { readFileSync as Ti } from "fs";
12
+ import ht from "node:http";
13
+ import Pi from "node:https";
14
+ import Je from "node:zlib";
15
+ import se, { PassThrough as Kt, pipeline as Ze } from "node:stream";
16
+ import { Buffer as $ } from "node:buffer";
17
+ import { types as Xt, promisify as vi, deprecate as or } from "node:util";
18
+ import { format as Ei } from "node:url";
19
+ import { isIP as Ai } from "node:net";
20
+ import "node:fs";
21
+ import "node:path";
22
+ const Bi = (i) => {
23
+ const n = i.join("|");
24
+ return new RegExp(`^(${n})(\\/.*)?$`);
25
+ }, Wi = ({
26
+ externals: i
27
+ }) => {
28
+ const n = Bi(i);
29
+ return {
30
+ name: "externalize",
31
+ setup(a) {
32
+ a.onResolve({ filter: n }, (u) => ({
33
+ path: u.path,
34
+ namespace: "externalize"
35
+ })), a.onLoad({ filter: n }, () => ({
36
+ contents: ""
37
+ }));
38
+ }
39
+ };
40
+ }, ki = (i) => {
41
+ const n = "/@id/", a = new RegExp(
42
+ `${n}(${i.join("|")})`,
43
+ "g"
44
+ );
45
+ return {
46
+ name: "vite-plugin-remove-prefix",
47
+ transform: (u) => a.test(u) ? u.replace(
48
+ a,
49
+ (l, h) => h
50
+ ) : u
51
+ };
52
+ }, qi = (i) => {
53
+ const { externals: n } = i;
54
+ return {
55
+ name: "vite-plugin-externalize",
56
+ enforce: "pre",
57
+ apply: "serve",
58
+ config: (a) => {
59
+ var u;
60
+ const l = { ...a };
61
+ return l.optimizeDeps && l.optimizeDeps.esbuildOptions && ((u = l.optimizeDeps.esbuildOptions).plugins ?? (u.plugins = []), l.optimizeDeps.esbuildOptions.plugins.push(
62
+ Wi({ externals: n })
63
+ )), l;
64
+ },
65
+ configResolved: (a) => {
66
+ if (a.optimizeDeps && a.optimizeDeps.include) {
67
+ const l = a.optimizeDeps.include.filter(
68
+ (h) => !n.includes(h)
69
+ );
70
+ a.optimizeDeps.include = l;
71
+ }
72
+ a.optimizeDeps && (a.optimizeDeps.exclude = a.optimizeDeps.exclude || [], a.optimizeDeps.exclude.push(...n));
73
+ const u = ki(n);
74
+ a.plugins.push(u);
75
+ },
76
+ // Supresses the following warning:
77
+ // Failed to resolve import [dependency] from [sourceFile]. Does the file exist?
78
+ resolveId: (a) => n.includes(a) ? { id: a, external: !0 } : null,
79
+ // Supresses the following warning:
80
+ // The following dependencies are imported but could not be resolved:
81
+ // [dependency] (imported by [sourceFile])
82
+ load: (a) => n.includes(a) ? "export default {};" : null
83
+ };
84
+ };
85
+ function Oi(i) {
86
+ if (!/^data:/i.test(i))
87
+ throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
88
+ i = i.replace(/\r?\n/g, "");
89
+ const n = i.indexOf(",");
90
+ if (n === -1 || n <= 4)
91
+ throw new TypeError("malformed data: URI");
92
+ const a = i.substring(5, n).split(";");
93
+ let u = "", l = !1;
94
+ const h = a[0] || "text/plain";
95
+ let c = h;
96
+ for (let E = 1; E < a.length; E++)
97
+ a[E] === "base64" ? l = !0 : a[E] && (c += `;${a[E]}`, a[E].indexOf("charset=") === 0 && (u = a[E].substring(8)));
98
+ !a[0] && !u.length && (c += ";charset=US-ASCII", u = "US-ASCII");
99
+ const T = l ? "base64" : "ascii", v = unescape(i.substring(n + 1)), _ = Buffer.from(v, T);
100
+ return _.type = h, _.typeFull = c, _.charset = u, _;
101
+ }
102
+ var Vr = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Jt = { exports: {} };
103
+ /**
104
+ * @license
105
+ * web-streams-polyfill v3.3.3
106
+ * Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
107
+ * This code is released under the MIT license.
108
+ * SPDX-License-Identifier: MIT
109
+ */
110
+ var wo;
111
+ function zi() {
112
+ return wo || (wo = 1, function(i, n) {
113
+ (function(a, u) {
114
+ u(n);
115
+ })(Vr, function(a) {
116
+ function u() {
117
+ }
118
+ function l(e) {
119
+ return typeof e == "object" && e !== null || typeof e == "function";
120
+ }
121
+ const h = u;
122
+ function c(e, t) {
123
+ try {
124
+ Object.defineProperty(e, "name", {
125
+ value: t,
126
+ configurable: !0
127
+ });
128
+ } catch {
129
+ }
130
+ }
131
+ const T = Promise, v = Promise.prototype.then, _ = Promise.reject.bind(T);
132
+ function E(e) {
133
+ return new T(e);
134
+ }
135
+ function w(e) {
136
+ return E((t) => t(e));
137
+ }
138
+ function m(e) {
139
+ return _(e);
140
+ }
141
+ function W(e, t, r) {
142
+ return v.call(e, t, r);
143
+ }
144
+ function p(e, t, r) {
145
+ W(W(e, t, r), void 0, h);
146
+ }
147
+ function j(e, t) {
148
+ p(e, t);
149
+ }
150
+ function R(e, t) {
151
+ p(e, void 0, t);
152
+ }
153
+ function B(e, t, r) {
154
+ return W(e, t, r);
155
+ }
156
+ function L(e) {
157
+ W(e, void 0, h);
158
+ }
159
+ let Y = (e) => {
160
+ if (typeof queueMicrotask == "function")
161
+ Y = queueMicrotask;
162
+ else {
163
+ const t = w(void 0);
164
+ Y = (r) => W(t, r);
165
+ }
166
+ return Y(e);
167
+ };
168
+ function O(e, t, r) {
169
+ if (typeof e != "function")
170
+ throw new TypeError("Argument is not a function");
171
+ return Function.prototype.apply.call(e, t, r);
172
+ }
173
+ function z(e, t, r) {
174
+ try {
175
+ return w(O(e, t, r));
176
+ } catch (o) {
177
+ return m(o);
178
+ }
179
+ }
180
+ const M = 16384;
181
+ class U {
182
+ constructor() {
183
+ this._cursor = 0, this._size = 0, this._front = {
184
+ _elements: [],
185
+ _next: void 0
186
+ }, this._back = this._front, this._cursor = 0, this._size = 0;
187
+ }
188
+ get length() {
189
+ return this._size;
190
+ }
191
+ // For exception safety, this method is structured in order:
192
+ // 1. Read state
193
+ // 2. Calculate required state mutations
194
+ // 3. Perform state mutations
195
+ push(t) {
196
+ const r = this._back;
197
+ let o = r;
198
+ r._elements.length === M - 1 && (o = {
199
+ _elements: [],
200
+ _next: void 0
201
+ }), r._elements.push(t), o !== r && (this._back = o, r._next = o), ++this._size;
202
+ }
203
+ // Like push(), shift() follows the read -> calculate -> mutate pattern for
204
+ // exception safety.
205
+ shift() {
206
+ const t = this._front;
207
+ let r = t;
208
+ const o = this._cursor;
209
+ let s = o + 1;
210
+ const f = t._elements, d = f[o];
211
+ return s === M && (r = t._next, s = 0), --this._size, this._cursor = s, t !== r && (this._front = r), f[o] = void 0, d;
212
+ }
213
+ // The tricky thing about forEach() is that it can be called
214
+ // re-entrantly. The queue may be mutated inside the callback. It is easy to
215
+ // see that push() within the callback has no negative effects since the end
216
+ // of the queue is checked for on every iteration. If shift() is called
217
+ // repeatedly within the callback then the next iteration may return an
218
+ // element that has been removed. In this case the callback will be called
219
+ // with undefined values until we either "catch up" with elements that still
220
+ // exist or reach the back of the queue.
221
+ forEach(t) {
222
+ let r = this._cursor, o = this._front, s = o._elements;
223
+ for (; (r !== s.length || o._next !== void 0) && !(r === s.length && (o = o._next, s = o._elements, r = 0, s.length === 0)); )
224
+ t(s[r]), ++r;
225
+ }
226
+ // Return the element that would be returned if shift() was called now,
227
+ // without modifying the queue.
228
+ peek() {
229
+ const t = this._front, r = this._cursor;
230
+ return t._elements[r];
231
+ }
232
+ }
233
+ const _t = Symbol("[[AbortSteps]]"), en = Symbol("[[ErrorSteps]]"), ir = Symbol("[[CancelSteps]]"), sr = Symbol("[[PullSteps]]"), lr = Symbol("[[ReleaseSteps]]");
234
+ function tn(e, t) {
235
+ e._ownerReadableStream = t, t._reader = e, t._state === "readable" ? fr(e) : t._state === "closed" ? zo(e) : rn(e, t._storedError);
236
+ }
237
+ function ur(e, t) {
238
+ const r = e._ownerReadableStream;
239
+ return ee(r, t);
240
+ }
241
+ function le(e) {
242
+ const t = e._ownerReadableStream;
243
+ t._state === "readable" ? dr(e, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")) : Fo(e, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")), t._readableStreamController[lr](), t._reader = void 0, e._ownerReadableStream = void 0;
244
+ }
245
+ function St(e) {
246
+ return new TypeError("Cannot " + e + " a stream using a released reader");
247
+ }
248
+ function fr(e) {
249
+ e._closedPromise = E((t, r) => {
250
+ e._closedPromise_resolve = t, e._closedPromise_reject = r;
251
+ });
252
+ }
253
+ function rn(e, t) {
254
+ fr(e), dr(e, t);
255
+ }
256
+ function zo(e) {
257
+ fr(e), nn(e);
258
+ }
259
+ function dr(e, t) {
260
+ e._closedPromise_reject !== void 0 && (L(e._closedPromise), e._closedPromise_reject(t), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0);
261
+ }
262
+ function Fo(e, t) {
263
+ rn(e, t);
264
+ }
265
+ function nn(e) {
266
+ e._closedPromise_resolve !== void 0 && (e._closedPromise_resolve(void 0), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0);
267
+ }
268
+ const on = Number.isFinite || function(e) {
269
+ return typeof e == "number" && isFinite(e);
270
+ }, Io = Math.trunc || function(e) {
271
+ return e < 0 ? Math.ceil(e) : Math.floor(e);
272
+ };
273
+ function jo(e) {
274
+ return typeof e == "object" || typeof e == "function";
275
+ }
276
+ function ne(e, t) {
277
+ if (e !== void 0 && !jo(e))
278
+ throw new TypeError(`${t} is not an object.`);
279
+ }
280
+ function G(e, t) {
281
+ if (typeof e != "function")
282
+ throw new TypeError(`${t} is not a function.`);
283
+ }
284
+ function Lo(e) {
285
+ return typeof e == "object" && e !== null || typeof e == "function";
286
+ }
287
+ function an(e, t) {
288
+ if (!Lo(e))
289
+ throw new TypeError(`${t} is not an object.`);
290
+ }
291
+ function ue(e, t, r) {
292
+ if (e === void 0)
293
+ throw new TypeError(`Parameter ${t} is required in '${r}'.`);
294
+ }
295
+ function cr(e, t, r) {
296
+ if (e === void 0)
297
+ throw new TypeError(`${t} is required in '${r}'.`);
298
+ }
299
+ function hr(e) {
300
+ return Number(e);
301
+ }
302
+ function sn(e) {
303
+ return e === 0 ? 0 : e;
304
+ }
305
+ function Do(e) {
306
+ return sn(Io(e));
307
+ }
308
+ function mr(e, t) {
309
+ const o = Number.MAX_SAFE_INTEGER;
310
+ let s = Number(e);
311
+ if (s = sn(s), !on(s))
312
+ throw new TypeError(`${t} is not a finite number`);
313
+ if (s = Do(s), s < 0 || s > o)
314
+ throw new TypeError(`${t} is outside the accepted range of 0 to ${o}, inclusive`);
315
+ return !on(s) || s === 0 ? 0 : s;
316
+ }
317
+ function br(e, t) {
318
+ if (!Te(e))
319
+ throw new TypeError(`${t} is not a ReadableStream.`);
320
+ }
321
+ function Le(e) {
322
+ return new ge(e);
323
+ }
324
+ function ln(e, t) {
325
+ e._reader._readRequests.push(t);
326
+ }
327
+ function pr(e, t, r) {
328
+ const s = e._reader._readRequests.shift();
329
+ r ? s._closeSteps() : s._chunkSteps(t);
330
+ }
331
+ function wt(e) {
332
+ return e._reader._readRequests.length;
333
+ }
334
+ function un(e) {
335
+ const t = e._reader;
336
+ return !(t === void 0 || !_e(t));
337
+ }
338
+ class ge {
339
+ constructor(t) {
340
+ if (ue(t, 1, "ReadableStreamDefaultReader"), br(t, "First parameter"), Pe(t))
341
+ throw new TypeError("This stream has already been locked for exclusive reading by another reader");
342
+ tn(this, t), this._readRequests = new U();
343
+ }
344
+ /**
345
+ * Returns a promise that will be fulfilled when the stream becomes closed,
346
+ * or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing.
347
+ */
348
+ get closed() {
349
+ return _e(this) ? this._closedPromise : m(Rt("closed"));
350
+ }
351
+ /**
352
+ * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
353
+ */
354
+ cancel(t = void 0) {
355
+ return _e(this) ? this._ownerReadableStream === void 0 ? m(St("cancel")) : ur(this, t) : m(Rt("cancel"));
356
+ }
357
+ /**
358
+ * Returns a promise that allows access to the next chunk from the stream's internal queue, if available.
359
+ *
360
+ * If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
361
+ */
362
+ read() {
363
+ if (!_e(this))
364
+ return m(Rt("read"));
365
+ if (this._ownerReadableStream === void 0)
366
+ return m(St("read from"));
367
+ let t, r;
368
+ const o = E((f, d) => {
369
+ t = f, r = d;
370
+ });
371
+ return tt(this, {
372
+ _chunkSteps: (f) => t({ value: f, done: !1 }),
373
+ _closeSteps: () => t({ value: void 0, done: !0 }),
374
+ _errorSteps: (f) => r(f)
375
+ }), o;
376
+ }
377
+ /**
378
+ * Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
379
+ * If the associated stream is errored when the lock is released, the reader will appear errored in the same way
380
+ * from now on; otherwise, the reader will appear closed.
381
+ *
382
+ * A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
383
+ * the reader's {@link ReadableStreamDefaultReader.read | read()} method has not yet been settled. Attempting to
384
+ * do so will throw a `TypeError` and leave the reader locked to the stream.
385
+ */
386
+ releaseLock() {
387
+ if (!_e(this))
388
+ throw Rt("releaseLock");
389
+ this._ownerReadableStream !== void 0 && $o(this);
390
+ }
391
+ }
392
+ Object.defineProperties(ge.prototype, {
393
+ cancel: { enumerable: !0 },
394
+ read: { enumerable: !0 },
395
+ releaseLock: { enumerable: !0 },
396
+ closed: { enumerable: !0 }
397
+ }), c(ge.prototype.cancel, "cancel"), c(ge.prototype.read, "read"), c(ge.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ge.prototype, Symbol.toStringTag, {
398
+ value: "ReadableStreamDefaultReader",
399
+ configurable: !0
400
+ });
401
+ function _e(e) {
402
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_readRequests") ? !1 : e instanceof ge;
403
+ }
404
+ function tt(e, t) {
405
+ const r = e._ownerReadableStream;
406
+ r._disturbed = !0, r._state === "closed" ? t._closeSteps() : r._state === "errored" ? t._errorSteps(r._storedError) : r._readableStreamController[sr](t);
407
+ }
408
+ function $o(e) {
409
+ le(e);
410
+ const t = new TypeError("Reader was released");
411
+ fn(e, t);
412
+ }
413
+ function fn(e, t) {
414
+ const r = e._readRequests;
415
+ e._readRequests = new U(), r.forEach((o) => {
416
+ o._errorSteps(t);
417
+ });
418
+ }
419
+ function Rt(e) {
420
+ return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`);
421
+ }
422
+ const Mo = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {
423
+ }).prototype);
424
+ class dn {
425
+ constructor(t, r) {
426
+ this._ongoingPromise = void 0, this._isFinished = !1, this._reader = t, this._preventCancel = r;
427
+ }
428
+ next() {
429
+ const t = () => this._nextSteps();
430
+ return this._ongoingPromise = this._ongoingPromise ? B(this._ongoingPromise, t, t) : t(), this._ongoingPromise;
431
+ }
432
+ return(t) {
433
+ const r = () => this._returnSteps(t);
434
+ return this._ongoingPromise ? B(this._ongoingPromise, r, r) : r();
435
+ }
436
+ _nextSteps() {
437
+ if (this._isFinished)
438
+ return Promise.resolve({ value: void 0, done: !0 });
439
+ const t = this._reader;
440
+ let r, o;
441
+ const s = E((d, b) => {
442
+ r = d, o = b;
443
+ });
444
+ return tt(t, {
445
+ _chunkSteps: (d) => {
446
+ this._ongoingPromise = void 0, Y(() => r({ value: d, done: !1 }));
447
+ },
448
+ _closeSteps: () => {
449
+ this._ongoingPromise = void 0, this._isFinished = !0, le(t), r({ value: void 0, done: !0 });
450
+ },
451
+ _errorSteps: (d) => {
452
+ this._ongoingPromise = void 0, this._isFinished = !0, le(t), o(d);
453
+ }
454
+ }), s;
455
+ }
456
+ _returnSteps(t) {
457
+ if (this._isFinished)
458
+ return Promise.resolve({ value: t, done: !0 });
459
+ this._isFinished = !0;
460
+ const r = this._reader;
461
+ if (!this._preventCancel) {
462
+ const o = ur(r, t);
463
+ return le(r), B(o, () => ({ value: t, done: !0 }));
464
+ }
465
+ return le(r), w({ value: t, done: !0 });
466
+ }
467
+ }
468
+ const cn = {
469
+ next() {
470
+ return hn(this) ? this._asyncIteratorImpl.next() : m(mn("next"));
471
+ },
472
+ return(e) {
473
+ return hn(this) ? this._asyncIteratorImpl.return(e) : m(mn("return"));
474
+ }
475
+ };
476
+ Object.setPrototypeOf(cn, Mo);
477
+ function Uo(e, t) {
478
+ const r = Le(e), o = new dn(r, t), s = Object.create(cn);
479
+ return s._asyncIteratorImpl = o, s;
480
+ }
481
+ function hn(e) {
482
+ if (!l(e) || !Object.prototype.hasOwnProperty.call(e, "_asyncIteratorImpl"))
483
+ return !1;
484
+ try {
485
+ return e._asyncIteratorImpl instanceof dn;
486
+ } catch {
487
+ return !1;
488
+ }
489
+ }
490
+ function mn(e) {
491
+ return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`);
492
+ }
493
+ const bn = Number.isNaN || function(e) {
494
+ return e !== e;
495
+ };
496
+ var yr, gr, _r;
497
+ function rt(e) {
498
+ return e.slice();
499
+ }
500
+ function pn(e, t, r, o, s) {
501
+ new Uint8Array(e).set(new Uint8Array(r, o, s), t);
502
+ }
503
+ let fe = (e) => (typeof e.transfer == "function" ? fe = (t) => t.transfer() : typeof structuredClone == "function" ? fe = (t) => structuredClone(t, { transfer: [t] }) : fe = (t) => t, fe(e)), Se = (e) => (typeof e.detached == "boolean" ? Se = (t) => t.detached : Se = (t) => t.byteLength === 0, Se(e));
504
+ function yn(e, t, r) {
505
+ if (e.slice)
506
+ return e.slice(t, r);
507
+ const o = r - t, s = new ArrayBuffer(o);
508
+ return pn(s, 0, e, t, o), s;
509
+ }
510
+ function Ct(e, t) {
511
+ const r = e[t];
512
+ if (r != null) {
513
+ if (typeof r != "function")
514
+ throw new TypeError(`${String(t)} is not a function`);
515
+ return r;
516
+ }
517
+ }
518
+ function xo(e) {
519
+ const t = {
520
+ [Symbol.iterator]: () => e.iterator
521
+ }, r = async function* () {
522
+ return yield* t;
523
+ }(), o = r.next;
524
+ return { iterator: r, nextMethod: o, done: !1 };
525
+ }
526
+ const Sr = (_r = (yr = Symbol.asyncIterator) !== null && yr !== void 0 ? yr : (gr = Symbol.for) === null || gr === void 0 ? void 0 : gr.call(Symbol, "Symbol.asyncIterator")) !== null && _r !== void 0 ? _r : "@@asyncIterator";
527
+ function gn(e, t = "sync", r) {
528
+ if (r === void 0)
529
+ if (t === "async") {
530
+ if (r = Ct(e, Sr), r === void 0) {
531
+ const f = Ct(e, Symbol.iterator), d = gn(e, "sync", f);
532
+ return xo(d);
533
+ }
534
+ } else
535
+ r = Ct(e, Symbol.iterator);
536
+ if (r === void 0)
537
+ throw new TypeError("The object is not iterable");
538
+ const o = O(r, e, []);
539
+ if (!l(o))
540
+ throw new TypeError("The iterator method must return an object");
541
+ const s = o.next;
542
+ return { iterator: o, nextMethod: s, done: !1 };
543
+ }
544
+ function No(e) {
545
+ const t = O(e.nextMethod, e.iterator, []);
546
+ if (!l(t))
547
+ throw new TypeError("The iterator.next() method must return an object");
548
+ return t;
549
+ }
550
+ function Ho(e) {
551
+ return !!e.done;
552
+ }
553
+ function Qo(e) {
554
+ return e.value;
555
+ }
556
+ function Vo(e) {
557
+ return !(typeof e != "number" || bn(e) || e < 0);
558
+ }
559
+ function _n(e) {
560
+ const t = yn(e.buffer, e.byteOffset, e.byteOffset + e.byteLength);
561
+ return new Uint8Array(t);
562
+ }
563
+ function wr(e) {
564
+ const t = e._queue.shift();
565
+ return e._queueTotalSize -= t.size, e._queueTotalSize < 0 && (e._queueTotalSize = 0), t.value;
566
+ }
567
+ function Rr(e, t, r) {
568
+ if (!Vo(r) || r === 1 / 0)
569
+ throw new RangeError("Size must be a finite, non-NaN, non-negative number.");
570
+ e._queue.push({ value: t, size: r }), e._queueTotalSize += r;
571
+ }
572
+ function Yo(e) {
573
+ return e._queue.peek().value;
574
+ }
575
+ function we(e) {
576
+ e._queue = new U(), e._queueTotalSize = 0;
577
+ }
578
+ function Sn(e) {
579
+ return e === DataView;
580
+ }
581
+ function Go(e) {
582
+ return Sn(e.constructor);
583
+ }
584
+ function Jo(e) {
585
+ return Sn(e) ? 1 : e.BYTES_PER_ELEMENT;
586
+ }
587
+ class Be {
588
+ constructor() {
589
+ throw new TypeError("Illegal constructor");
590
+ }
591
+ /**
592
+ * Returns the view for writing in to, or `null` if the BYOB request has already been responded to.
593
+ */
594
+ get view() {
595
+ if (!Cr(this))
596
+ throw Ar("view");
597
+ return this._view;
598
+ }
599
+ respond(t) {
600
+ if (!Cr(this))
601
+ throw Ar("respond");
602
+ if (ue(t, 1, "respond"), t = mr(t, "First parameter"), this._associatedReadableByteStreamController === void 0)
603
+ throw new TypeError("This BYOB request has been invalidated");
604
+ if (Se(this._view.buffer))
605
+ throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");
606
+ Et(this._associatedReadableByteStreamController, t);
607
+ }
608
+ respondWithNewView(t) {
609
+ if (!Cr(this))
610
+ throw Ar("respondWithNewView");
611
+ if (ue(t, 1, "respondWithNewView"), !ArrayBuffer.isView(t))
612
+ throw new TypeError("You can only respond with array buffer views");
613
+ if (this._associatedReadableByteStreamController === void 0)
614
+ throw new TypeError("This BYOB request has been invalidated");
615
+ if (Se(t.buffer))
616
+ throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
617
+ At(this._associatedReadableByteStreamController, t);
618
+ }
619
+ }
620
+ Object.defineProperties(Be.prototype, {
621
+ respond: { enumerable: !0 },
622
+ respondWithNewView: { enumerable: !0 },
623
+ view: { enumerable: !0 }
624
+ }), c(Be.prototype.respond, "respond"), c(Be.prototype.respondWithNewView, "respondWithNewView"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Be.prototype, Symbol.toStringTag, {
625
+ value: "ReadableStreamBYOBRequest",
626
+ configurable: !0
627
+ });
628
+ class de {
629
+ constructor() {
630
+ throw new TypeError("Illegal constructor");
631
+ }
632
+ /**
633
+ * Returns the current BYOB pull request, or `null` if there isn't one.
634
+ */
635
+ get byobRequest() {
636
+ if (!We(this))
637
+ throw ot("byobRequest");
638
+ return Er(this);
639
+ }
640
+ /**
641
+ * Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
642
+ * over-full. An underlying byte source ought to use this information to determine when and how to apply backpressure.
643
+ */
644
+ get desiredSize() {
645
+ if (!We(this))
646
+ throw ot("desiredSize");
647
+ return Wn(this);
648
+ }
649
+ /**
650
+ * Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
651
+ * the stream, but once those are read, the stream will become closed.
652
+ */
653
+ close() {
654
+ if (!We(this))
655
+ throw ot("close");
656
+ if (this._closeRequested)
657
+ throw new TypeError("The stream has already been closed; do not close it again!");
658
+ const t = this._controlledReadableByteStream._state;
659
+ if (t !== "readable")
660
+ throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be closed`);
661
+ nt(this);
662
+ }
663
+ enqueue(t) {
664
+ if (!We(this))
665
+ throw ot("enqueue");
666
+ if (ue(t, 1, "enqueue"), !ArrayBuffer.isView(t))
667
+ throw new TypeError("chunk must be an array buffer view");
668
+ if (t.byteLength === 0)
669
+ throw new TypeError("chunk must have non-zero byteLength");
670
+ if (t.buffer.byteLength === 0)
671
+ throw new TypeError("chunk's buffer must have non-zero byteLength");
672
+ if (this._closeRequested)
673
+ throw new TypeError("stream is closed or draining");
674
+ const r = this._controlledReadableByteStream._state;
675
+ if (r !== "readable")
676
+ throw new TypeError(`The stream (in ${r} state) is not in the readable state and cannot be enqueued to`);
677
+ vt(this, t);
678
+ }
679
+ /**
680
+ * Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
681
+ */
682
+ error(t = void 0) {
683
+ if (!We(this))
684
+ throw ot("error");
685
+ J(this, t);
686
+ }
687
+ /** @internal */
688
+ [ir](t) {
689
+ wn(this), we(this);
690
+ const r = this._cancelAlgorithm(t);
691
+ return Pt(this), r;
692
+ }
693
+ /** @internal */
694
+ [sr](t) {
695
+ const r = this._controlledReadableByteStream;
696
+ if (this._queueTotalSize > 0) {
697
+ Bn(this, t);
698
+ return;
699
+ }
700
+ const o = this._autoAllocateChunkSize;
701
+ if (o !== void 0) {
702
+ let s;
703
+ try {
704
+ s = new ArrayBuffer(o);
705
+ } catch (d) {
706
+ t._errorSteps(d);
707
+ return;
708
+ }
709
+ const f = {
710
+ buffer: s,
711
+ bufferByteLength: o,
712
+ byteOffset: 0,
713
+ byteLength: o,
714
+ bytesFilled: 0,
715
+ minimumFill: 1,
716
+ elementSize: 1,
717
+ viewConstructor: Uint8Array,
718
+ readerType: "default"
719
+ };
720
+ this._pendingPullIntos.push(f);
721
+ }
722
+ ln(r, t), ke(this);
723
+ }
724
+ /** @internal */
725
+ [lr]() {
726
+ if (this._pendingPullIntos.length > 0) {
727
+ const t = this._pendingPullIntos.peek();
728
+ t.readerType = "none", this._pendingPullIntos = new U(), this._pendingPullIntos.push(t);
729
+ }
730
+ }
731
+ }
732
+ Object.defineProperties(de.prototype, {
733
+ close: { enumerable: !0 },
734
+ enqueue: { enumerable: !0 },
735
+ error: { enumerable: !0 },
736
+ byobRequest: { enumerable: !0 },
737
+ desiredSize: { enumerable: !0 }
738
+ }), c(de.prototype.close, "close"), c(de.prototype.enqueue, "enqueue"), c(de.prototype.error, "error"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(de.prototype, Symbol.toStringTag, {
739
+ value: "ReadableByteStreamController",
740
+ configurable: !0
741
+ });
742
+ function We(e) {
743
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_controlledReadableByteStream") ? !1 : e instanceof de;
744
+ }
745
+ function Cr(e) {
746
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_associatedReadableByteStreamController") ? !1 : e instanceof Be;
747
+ }
748
+ function ke(e) {
749
+ if (!ta(e))
750
+ return;
751
+ if (e._pulling) {
752
+ e._pullAgain = !0;
753
+ return;
754
+ }
755
+ e._pulling = !0;
756
+ const r = e._pullAlgorithm();
757
+ p(r, () => (e._pulling = !1, e._pullAgain && (e._pullAgain = !1, ke(e)), null), (o) => (J(e, o), null));
758
+ }
759
+ function wn(e) {
760
+ Pr(e), e._pendingPullIntos = new U();
761
+ }
762
+ function Tr(e, t) {
763
+ let r = !1;
764
+ e._state === "closed" && (r = !0);
765
+ const o = Rn(t);
766
+ t.readerType === "default" ? pr(e, o, r) : sa(e, o, r);
767
+ }
768
+ function Rn(e) {
769
+ const t = e.bytesFilled, r = e.elementSize;
770
+ return new e.viewConstructor(e.buffer, e.byteOffset, t / r);
771
+ }
772
+ function Tt(e, t, r, o) {
773
+ e._queue.push({ buffer: t, byteOffset: r, byteLength: o }), e._queueTotalSize += o;
774
+ }
775
+ function Cn(e, t, r, o) {
776
+ let s;
777
+ try {
778
+ s = yn(t, r, r + o);
779
+ } catch (f) {
780
+ throw J(e, f), f;
781
+ }
782
+ Tt(e, s, 0, o);
783
+ }
784
+ function Tn(e, t) {
785
+ t.bytesFilled > 0 && Cn(e, t.buffer, t.byteOffset, t.bytesFilled), De(e);
786
+ }
787
+ function Pn(e, t) {
788
+ const r = Math.min(e._queueTotalSize, t.byteLength - t.bytesFilled), o = t.bytesFilled + r;
789
+ let s = r, f = !1;
790
+ const d = o % t.elementSize, b = o - d;
791
+ b >= t.minimumFill && (s = b - t.bytesFilled, f = !0);
792
+ const S = e._queue;
793
+ for (; s > 0; ) {
794
+ const y = S.peek(), C = Math.min(s, y.byteLength), P = t.byteOffset + t.bytesFilled;
795
+ pn(t.buffer, P, y.buffer, y.byteOffset, C), y.byteLength === C ? S.shift() : (y.byteOffset += C, y.byteLength -= C), e._queueTotalSize -= C, vn(e, C, t), s -= C;
796
+ }
797
+ return f;
798
+ }
799
+ function vn(e, t, r) {
800
+ r.bytesFilled += t;
801
+ }
802
+ function En(e) {
803
+ e._queueTotalSize === 0 && e._closeRequested ? (Pt(e), ft(e._controlledReadableByteStream)) : ke(e);
804
+ }
805
+ function Pr(e) {
806
+ e._byobRequest !== null && (e._byobRequest._associatedReadableByteStreamController = void 0, e._byobRequest._view = null, e._byobRequest = null);
807
+ }
808
+ function vr(e) {
809
+ for (; e._pendingPullIntos.length > 0; ) {
810
+ if (e._queueTotalSize === 0)
811
+ return;
812
+ const t = e._pendingPullIntos.peek();
813
+ Pn(e, t) && (De(e), Tr(e._controlledReadableByteStream, t));
814
+ }
815
+ }
816
+ function Zo(e) {
817
+ const t = e._controlledReadableByteStream._reader;
818
+ for (; t._readRequests.length > 0; ) {
819
+ if (e._queueTotalSize === 0)
820
+ return;
821
+ const r = t._readRequests.shift();
822
+ Bn(e, r);
823
+ }
824
+ }
825
+ function Ko(e, t, r, o) {
826
+ const s = e._controlledReadableByteStream, f = t.constructor, d = Jo(f), { byteOffset: b, byteLength: S } = t, y = r * d;
827
+ let C;
828
+ try {
829
+ C = fe(t.buffer);
830
+ } catch (k) {
831
+ o._errorSteps(k);
832
+ return;
833
+ }
834
+ const P = {
835
+ buffer: C,
836
+ bufferByteLength: C.byteLength,
837
+ byteOffset: b,
838
+ byteLength: S,
839
+ bytesFilled: 0,
840
+ minimumFill: y,
841
+ elementSize: d,
842
+ viewConstructor: f,
843
+ readerType: "byob"
844
+ };
845
+ if (e._pendingPullIntos.length > 0) {
846
+ e._pendingPullIntos.push(P), On(s, o);
847
+ return;
848
+ }
849
+ if (s._state === "closed") {
850
+ const k = new f(P.buffer, P.byteOffset, 0);
851
+ o._closeSteps(k);
852
+ return;
853
+ }
854
+ if (e._queueTotalSize > 0) {
855
+ if (Pn(e, P)) {
856
+ const k = Rn(P);
857
+ En(e), o._chunkSteps(k);
858
+ return;
859
+ }
860
+ if (e._closeRequested) {
861
+ const k = new TypeError("Insufficient bytes to fill elements in the given buffer");
862
+ J(e, k), o._errorSteps(k);
863
+ return;
864
+ }
865
+ }
866
+ e._pendingPullIntos.push(P), On(s, o), ke(e);
867
+ }
868
+ function Xo(e, t) {
869
+ t.readerType === "none" && De(e);
870
+ const r = e._controlledReadableByteStream;
871
+ if (Br(r))
872
+ for (; zn(r) > 0; ) {
873
+ const o = De(e);
874
+ Tr(r, o);
875
+ }
876
+ }
877
+ function ea(e, t, r) {
878
+ if (vn(e, t, r), r.readerType === "none") {
879
+ Tn(e, r), vr(e);
880
+ return;
881
+ }
882
+ if (r.bytesFilled < r.minimumFill)
883
+ return;
884
+ De(e);
885
+ const o = r.bytesFilled % r.elementSize;
886
+ if (o > 0) {
887
+ const s = r.byteOffset + r.bytesFilled;
888
+ Cn(e, r.buffer, s - o, o);
889
+ }
890
+ r.bytesFilled -= o, Tr(e._controlledReadableByteStream, r), vr(e);
891
+ }
892
+ function An(e, t) {
893
+ const r = e._pendingPullIntos.peek();
894
+ Pr(e), e._controlledReadableByteStream._state === "closed" ? Xo(e, r) : ea(e, t, r), ke(e);
895
+ }
896
+ function De(e) {
897
+ return e._pendingPullIntos.shift();
898
+ }
899
+ function ta(e) {
900
+ const t = e._controlledReadableByteStream;
901
+ return t._state !== "readable" || e._closeRequested || !e._started ? !1 : !!(un(t) && wt(t) > 0 || Br(t) && zn(t) > 0 || Wn(e) > 0);
902
+ }
903
+ function Pt(e) {
904
+ e._pullAlgorithm = void 0, e._cancelAlgorithm = void 0;
905
+ }
906
+ function nt(e) {
907
+ const t = e._controlledReadableByteStream;
908
+ if (!(e._closeRequested || t._state !== "readable")) {
909
+ if (e._queueTotalSize > 0) {
910
+ e._closeRequested = !0;
911
+ return;
912
+ }
913
+ if (e._pendingPullIntos.length > 0) {
914
+ const r = e._pendingPullIntos.peek();
915
+ if (r.bytesFilled % r.elementSize !== 0) {
916
+ const o = new TypeError("Insufficient bytes to fill elements in the given buffer");
917
+ throw J(e, o), o;
918
+ }
919
+ }
920
+ Pt(e), ft(t);
921
+ }
922
+ }
923
+ function vt(e, t) {
924
+ const r = e._controlledReadableByteStream;
925
+ if (e._closeRequested || r._state !== "readable")
926
+ return;
927
+ const { buffer: o, byteOffset: s, byteLength: f } = t;
928
+ if (Se(o))
929
+ throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
930
+ const d = fe(o);
931
+ if (e._pendingPullIntos.length > 0) {
932
+ const b = e._pendingPullIntos.peek();
933
+ if (Se(b.buffer))
934
+ throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
935
+ Pr(e), b.buffer = fe(b.buffer), b.readerType === "none" && Tn(e, b);
936
+ }
937
+ if (un(r))
938
+ if (Zo(e), wt(r) === 0)
939
+ Tt(e, d, s, f);
940
+ else {
941
+ e._pendingPullIntos.length > 0 && De(e);
942
+ const b = new Uint8Array(d, s, f);
943
+ pr(r, b, !1);
944
+ }
945
+ else
946
+ Br(r) ? (Tt(e, d, s, f), vr(e)) : Tt(e, d, s, f);
947
+ ke(e);
948
+ }
949
+ function J(e, t) {
950
+ const r = e._controlledReadableByteStream;
951
+ r._state === "readable" && (wn(e), we(e), Pt(e), oo(r, t));
952
+ }
953
+ function Bn(e, t) {
954
+ const r = e._queue.shift();
955
+ e._queueTotalSize -= r.byteLength, En(e);
956
+ const o = new Uint8Array(r.buffer, r.byteOffset, r.byteLength);
957
+ t._chunkSteps(o);
958
+ }
959
+ function Er(e) {
960
+ if (e._byobRequest === null && e._pendingPullIntos.length > 0) {
961
+ const t = e._pendingPullIntos.peek(), r = new Uint8Array(t.buffer, t.byteOffset + t.bytesFilled, t.byteLength - t.bytesFilled), o = Object.create(Be.prototype);
962
+ na(o, e, r), e._byobRequest = o;
963
+ }
964
+ return e._byobRequest;
965
+ }
966
+ function Wn(e) {
967
+ const t = e._controlledReadableByteStream._state;
968
+ return t === "errored" ? null : t === "closed" ? 0 : e._strategyHWM - e._queueTotalSize;
969
+ }
970
+ function Et(e, t) {
971
+ const r = e._pendingPullIntos.peek();
972
+ if (e._controlledReadableByteStream._state === "closed") {
973
+ if (t !== 0)
974
+ throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
975
+ } else {
976
+ if (t === 0)
977
+ throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");
978
+ if (r.bytesFilled + t > r.byteLength)
979
+ throw new RangeError("bytesWritten out of range");
980
+ }
981
+ r.buffer = fe(r.buffer), An(e, t);
982
+ }
983
+ function At(e, t) {
984
+ const r = e._pendingPullIntos.peek();
985
+ if (e._controlledReadableByteStream._state === "closed") {
986
+ if (t.byteLength !== 0)
987
+ throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
988
+ } else if (t.byteLength === 0)
989
+ throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
990
+ if (r.byteOffset + r.bytesFilled !== t.byteOffset)
991
+ throw new RangeError("The region specified by view does not match byobRequest");
992
+ if (r.bufferByteLength !== t.buffer.byteLength)
993
+ throw new RangeError("The buffer of view has different capacity than byobRequest");
994
+ if (r.bytesFilled + t.byteLength > r.byteLength)
995
+ throw new RangeError("The region specified by view is larger than byobRequest");
996
+ const s = t.byteLength;
997
+ r.buffer = fe(t.buffer), An(e, s);
998
+ }
999
+ function kn(e, t, r, o, s, f, d) {
1000
+ t._controlledReadableByteStream = e, t._pullAgain = !1, t._pulling = !1, t._byobRequest = null, t._queue = t._queueTotalSize = void 0, we(t), t._closeRequested = !1, t._started = !1, t._strategyHWM = f, t._pullAlgorithm = o, t._cancelAlgorithm = s, t._autoAllocateChunkSize = d, t._pendingPullIntos = new U(), e._readableStreamController = t;
1001
+ const b = r();
1002
+ p(w(b), () => (t._started = !0, ke(t), null), (S) => (J(t, S), null));
1003
+ }
1004
+ function ra(e, t, r) {
1005
+ const o = Object.create(de.prototype);
1006
+ let s, f, d;
1007
+ t.start !== void 0 ? s = () => t.start(o) : s = () => {
1008
+ }, t.pull !== void 0 ? f = () => t.pull(o) : f = () => w(void 0), t.cancel !== void 0 ? d = (S) => t.cancel(S) : d = () => w(void 0);
1009
+ const b = t.autoAllocateChunkSize;
1010
+ if (b === 0)
1011
+ throw new TypeError("autoAllocateChunkSize must be greater than 0");
1012
+ kn(e, o, s, f, d, r, b);
1013
+ }
1014
+ function na(e, t, r) {
1015
+ e._associatedReadableByteStreamController = t, e._view = r;
1016
+ }
1017
+ function Ar(e) {
1018
+ return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`);
1019
+ }
1020
+ function ot(e) {
1021
+ return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`);
1022
+ }
1023
+ function oa(e, t) {
1024
+ ne(e, t);
1025
+ const r = e == null ? void 0 : e.mode;
1026
+ return {
1027
+ mode: r === void 0 ? void 0 : aa(r, `${t} has member 'mode' that`)
1028
+ };
1029
+ }
1030
+ function aa(e, t) {
1031
+ if (e = `${e}`, e !== "byob")
1032
+ throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamReaderMode`);
1033
+ return e;
1034
+ }
1035
+ function ia(e, t) {
1036
+ var r;
1037
+ ne(e, t);
1038
+ const o = (r = e == null ? void 0 : e.min) !== null && r !== void 0 ? r : 1;
1039
+ return {
1040
+ min: mr(o, `${t} has member 'min' that`)
1041
+ };
1042
+ }
1043
+ function qn(e) {
1044
+ return new Re(e);
1045
+ }
1046
+ function On(e, t) {
1047
+ e._reader._readIntoRequests.push(t);
1048
+ }
1049
+ function sa(e, t, r) {
1050
+ const s = e._reader._readIntoRequests.shift();
1051
+ r ? s._closeSteps(t) : s._chunkSteps(t);
1052
+ }
1053
+ function zn(e) {
1054
+ return e._reader._readIntoRequests.length;
1055
+ }
1056
+ function Br(e) {
1057
+ const t = e._reader;
1058
+ return !(t === void 0 || !qe(t));
1059
+ }
1060
+ class Re {
1061
+ constructor(t) {
1062
+ if (ue(t, 1, "ReadableStreamBYOBReader"), br(t, "First parameter"), Pe(t))
1063
+ throw new TypeError("This stream has already been locked for exclusive reading by another reader");
1064
+ if (!We(t._readableStreamController))
1065
+ throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");
1066
+ tn(this, t), this._readIntoRequests = new U();
1067
+ }
1068
+ /**
1069
+ * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
1070
+ * the reader's lock is released before the stream finishes closing.
1071
+ */
1072
+ get closed() {
1073
+ return qe(this) ? this._closedPromise : m(Bt("closed"));
1074
+ }
1075
+ /**
1076
+ * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
1077
+ */
1078
+ cancel(t = void 0) {
1079
+ return qe(this) ? this._ownerReadableStream === void 0 ? m(St("cancel")) : ur(this, t) : m(Bt("cancel"));
1080
+ }
1081
+ read(t, r = {}) {
1082
+ if (!qe(this))
1083
+ return m(Bt("read"));
1084
+ if (!ArrayBuffer.isView(t))
1085
+ return m(new TypeError("view must be an array buffer view"));
1086
+ if (t.byteLength === 0)
1087
+ return m(new TypeError("view must have non-zero byteLength"));
1088
+ if (t.buffer.byteLength === 0)
1089
+ return m(new TypeError("view's buffer must have non-zero byteLength"));
1090
+ if (Se(t.buffer))
1091
+ return m(new TypeError("view's buffer has been detached"));
1092
+ let o;
1093
+ try {
1094
+ o = ia(r, "options");
1095
+ } catch (y) {
1096
+ return m(y);
1097
+ }
1098
+ const s = o.min;
1099
+ if (s === 0)
1100
+ return m(new TypeError("options.min must be greater than 0"));
1101
+ if (Go(t)) {
1102
+ if (s > t.byteLength)
1103
+ return m(new RangeError("options.min must be less than or equal to view's byteLength"));
1104
+ } else if (s > t.length)
1105
+ return m(new RangeError("options.min must be less than or equal to view's length"));
1106
+ if (this._ownerReadableStream === void 0)
1107
+ return m(St("read from"));
1108
+ let f, d;
1109
+ const b = E((y, C) => {
1110
+ f = y, d = C;
1111
+ });
1112
+ return Fn(this, t, s, {
1113
+ _chunkSteps: (y) => f({ value: y, done: !1 }),
1114
+ _closeSteps: (y) => f({ value: y, done: !0 }),
1115
+ _errorSteps: (y) => d(y)
1116
+ }), b;
1117
+ }
1118
+ /**
1119
+ * Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
1120
+ * If the associated stream is errored when the lock is released, the reader will appear errored in the same way
1121
+ * from now on; otherwise, the reader will appear closed.
1122
+ *
1123
+ * A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
1124
+ * the reader's {@link ReadableStreamBYOBReader.read | read()} method has not yet been settled. Attempting to
1125
+ * do so will throw a `TypeError` and leave the reader locked to the stream.
1126
+ */
1127
+ releaseLock() {
1128
+ if (!qe(this))
1129
+ throw Bt("releaseLock");
1130
+ this._ownerReadableStream !== void 0 && la(this);
1131
+ }
1132
+ }
1133
+ Object.defineProperties(Re.prototype, {
1134
+ cancel: { enumerable: !0 },
1135
+ read: { enumerable: !0 },
1136
+ releaseLock: { enumerable: !0 },
1137
+ closed: { enumerable: !0 }
1138
+ }), c(Re.prototype.cancel, "cancel"), c(Re.prototype.read, "read"), c(Re.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Re.prototype, Symbol.toStringTag, {
1139
+ value: "ReadableStreamBYOBReader",
1140
+ configurable: !0
1141
+ });
1142
+ function qe(e) {
1143
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_readIntoRequests") ? !1 : e instanceof Re;
1144
+ }
1145
+ function Fn(e, t, r, o) {
1146
+ const s = e._ownerReadableStream;
1147
+ s._disturbed = !0, s._state === "errored" ? o._errorSteps(s._storedError) : Ko(s._readableStreamController, t, r, o);
1148
+ }
1149
+ function la(e) {
1150
+ le(e);
1151
+ const t = new TypeError("Reader was released");
1152
+ In(e, t);
1153
+ }
1154
+ function In(e, t) {
1155
+ const r = e._readIntoRequests;
1156
+ e._readIntoRequests = new U(), r.forEach((o) => {
1157
+ o._errorSteps(t);
1158
+ });
1159
+ }
1160
+ function Bt(e) {
1161
+ return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`);
1162
+ }
1163
+ function at(e, t) {
1164
+ const { highWaterMark: r } = e;
1165
+ if (r === void 0)
1166
+ return t;
1167
+ if (bn(r) || r < 0)
1168
+ throw new RangeError("Invalid highWaterMark");
1169
+ return r;
1170
+ }
1171
+ function Wt(e) {
1172
+ const { size: t } = e;
1173
+ return t || (() => 1);
1174
+ }
1175
+ function kt(e, t) {
1176
+ ne(e, t);
1177
+ const r = e == null ? void 0 : e.highWaterMark, o = e == null ? void 0 : e.size;
1178
+ return {
1179
+ highWaterMark: r === void 0 ? void 0 : hr(r),
1180
+ size: o === void 0 ? void 0 : ua(o, `${t} has member 'size' that`)
1181
+ };
1182
+ }
1183
+ function ua(e, t) {
1184
+ return G(e, t), (r) => hr(e(r));
1185
+ }
1186
+ function fa(e, t) {
1187
+ ne(e, t);
1188
+ const r = e == null ? void 0 : e.abort, o = e == null ? void 0 : e.close, s = e == null ? void 0 : e.start, f = e == null ? void 0 : e.type, d = e == null ? void 0 : e.write;
1189
+ return {
1190
+ abort: r === void 0 ? void 0 : da(r, e, `${t} has member 'abort' that`),
1191
+ close: o === void 0 ? void 0 : ca(o, e, `${t} has member 'close' that`),
1192
+ start: s === void 0 ? void 0 : ha(s, e, `${t} has member 'start' that`),
1193
+ write: d === void 0 ? void 0 : ma(d, e, `${t} has member 'write' that`),
1194
+ type: f
1195
+ };
1196
+ }
1197
+ function da(e, t, r) {
1198
+ return G(e, r), (o) => z(e, t, [o]);
1199
+ }
1200
+ function ca(e, t, r) {
1201
+ return G(e, r), () => z(e, t, []);
1202
+ }
1203
+ function ha(e, t, r) {
1204
+ return G(e, r), (o) => O(e, t, [o]);
1205
+ }
1206
+ function ma(e, t, r) {
1207
+ return G(e, r), (o, s) => z(e, t, [o, s]);
1208
+ }
1209
+ function jn(e, t) {
1210
+ if (!$e(e))
1211
+ throw new TypeError(`${t} is not a WritableStream.`);
1212
+ }
1213
+ function ba(e) {
1214
+ if (typeof e != "object" || e === null)
1215
+ return !1;
1216
+ try {
1217
+ return typeof e.aborted == "boolean";
1218
+ } catch {
1219
+ return !1;
1220
+ }
1221
+ }
1222
+ const pa = typeof AbortController == "function";
1223
+ function ya() {
1224
+ if (pa)
1225
+ return new AbortController();
1226
+ }
1227
+ class Ce {
1228
+ constructor(t = {}, r = {}) {
1229
+ t === void 0 ? t = null : an(t, "First parameter");
1230
+ const o = kt(r, "Second parameter"), s = fa(t, "First parameter");
1231
+ if (Dn(this), s.type !== void 0)
1232
+ throw new RangeError("Invalid type is specified");
1233
+ const d = Wt(o), b = at(o, 1);
1234
+ ka(this, s, b, d);
1235
+ }
1236
+ /**
1237
+ * Returns whether or not the writable stream is locked to a writer.
1238
+ */
1239
+ get locked() {
1240
+ if (!$e(this))
1241
+ throw It("locked");
1242
+ return Me(this);
1243
+ }
1244
+ /**
1245
+ * Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be
1246
+ * immediately moved to an errored state, with any queued-up writes discarded. This will also execute any abort
1247
+ * mechanism of the underlying sink.
1248
+ *
1249
+ * The returned promise will fulfill if the stream shuts down successfully, or reject if the underlying sink signaled
1250
+ * that there was an error doing so. Additionally, it will reject with a `TypeError` (without attempting to cancel
1251
+ * the stream) if the stream is currently locked.
1252
+ */
1253
+ abort(t = void 0) {
1254
+ return $e(this) ? Me(this) ? m(new TypeError("Cannot abort a stream that already has a writer")) : qt(this, t) : m(It("abort"));
1255
+ }
1256
+ /**
1257
+ * Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its
1258
+ * close behavior. During this time any further attempts to write will fail (without erroring the stream).
1259
+ *
1260
+ * The method returns a promise that will fulfill if all remaining chunks are successfully written and the stream
1261
+ * successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with
1262
+ * a `TypeError` (without attempting to cancel the stream) if the stream is currently locked.
1263
+ */
1264
+ close() {
1265
+ return $e(this) ? Me(this) ? m(new TypeError("Cannot close a stream that already has a writer")) : oe(this) ? m(new TypeError("Cannot close an already-closing stream")) : $n(this) : m(It("close"));
1266
+ }
1267
+ /**
1268
+ * Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream
1269
+ * is locked, no other writer can be acquired until this one is released.
1270
+ *
1271
+ * This functionality is especially useful for creating abstractions that desire the ability to write to a stream
1272
+ * without interruption or interleaving. By getting a writer for the stream, you can ensure nobody else can write at
1273
+ * the same time, which would cause the resulting written data to be unpredictable and probably useless.
1274
+ */
1275
+ getWriter() {
1276
+ if (!$e(this))
1277
+ throw It("getWriter");
1278
+ return Ln(this);
1279
+ }
1280
+ }
1281
+ Object.defineProperties(Ce.prototype, {
1282
+ abort: { enumerable: !0 },
1283
+ close: { enumerable: !0 },
1284
+ getWriter: { enumerable: !0 },
1285
+ locked: { enumerable: !0 }
1286
+ }), c(Ce.prototype.abort, "abort"), c(Ce.prototype.close, "close"), c(Ce.prototype.getWriter, "getWriter"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Ce.prototype, Symbol.toStringTag, {
1287
+ value: "WritableStream",
1288
+ configurable: !0
1289
+ });
1290
+ function Ln(e) {
1291
+ return new ce(e);
1292
+ }
1293
+ function ga(e, t, r, o, s = 1, f = () => 1) {
1294
+ const d = Object.create(Ce.prototype);
1295
+ Dn(d);
1296
+ const b = Object.create(Ue.prototype);
1297
+ return Qn(d, b, e, t, r, o, s, f), d;
1298
+ }
1299
+ function Dn(e) {
1300
+ e._state = "writable", e._storedError = void 0, e._writer = void 0, e._writableStreamController = void 0, e._writeRequests = new U(), e._inFlightWriteRequest = void 0, e._closeRequest = void 0, e._inFlightCloseRequest = void 0, e._pendingAbortRequest = void 0, e._backpressure = !1;
1301
+ }
1302
+ function $e(e) {
1303
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_writableStreamController") ? !1 : e instanceof Ce;
1304
+ }
1305
+ function Me(e) {
1306
+ return e._writer !== void 0;
1307
+ }
1308
+ function qt(e, t) {
1309
+ var r;
1310
+ if (e._state === "closed" || e._state === "errored")
1311
+ return w(void 0);
1312
+ e._writableStreamController._abortReason = t, (r = e._writableStreamController._abortController) === null || r === void 0 || r.abort(t);
1313
+ const o = e._state;
1314
+ if (o === "closed" || o === "errored")
1315
+ return w(void 0);
1316
+ if (e._pendingAbortRequest !== void 0)
1317
+ return e._pendingAbortRequest._promise;
1318
+ let s = !1;
1319
+ o === "erroring" && (s = !0, t = void 0);
1320
+ const f = E((d, b) => {
1321
+ e._pendingAbortRequest = {
1322
+ _promise: void 0,
1323
+ _resolve: d,
1324
+ _reject: b,
1325
+ _reason: t,
1326
+ _wasAlreadyErroring: s
1327
+ };
1328
+ });
1329
+ return e._pendingAbortRequest._promise = f, s || kr(e, t), f;
1330
+ }
1331
+ function $n(e) {
1332
+ const t = e._state;
1333
+ if (t === "closed" || t === "errored")
1334
+ return m(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));
1335
+ const r = E((s, f) => {
1336
+ const d = {
1337
+ _resolve: s,
1338
+ _reject: f
1339
+ };
1340
+ e._closeRequest = d;
1341
+ }), o = e._writer;
1342
+ return o !== void 0 && e._backpressure && t === "writable" && Dr(o), qa(e._writableStreamController), r;
1343
+ }
1344
+ function _a(e) {
1345
+ return E((r, o) => {
1346
+ const s = {
1347
+ _resolve: r,
1348
+ _reject: o
1349
+ };
1350
+ e._writeRequests.push(s);
1351
+ });
1352
+ }
1353
+ function Wr(e, t) {
1354
+ if (e._state === "writable") {
1355
+ kr(e, t);
1356
+ return;
1357
+ }
1358
+ qr(e);
1359
+ }
1360
+ function kr(e, t) {
1361
+ const r = e._writableStreamController;
1362
+ e._state = "erroring", e._storedError = t;
1363
+ const o = e._writer;
1364
+ o !== void 0 && Un(o, t), !Ta(e) && r._started && qr(e);
1365
+ }
1366
+ function qr(e) {
1367
+ e._state = "errored", e._writableStreamController[en]();
1368
+ const t = e._storedError;
1369
+ if (e._writeRequests.forEach((s) => {
1370
+ s._reject(t);
1371
+ }), e._writeRequests = new U(), e._pendingAbortRequest === void 0) {
1372
+ Ot(e);
1373
+ return;
1374
+ }
1375
+ const r = e._pendingAbortRequest;
1376
+ if (e._pendingAbortRequest = void 0, r._wasAlreadyErroring) {
1377
+ r._reject(t), Ot(e);
1378
+ return;
1379
+ }
1380
+ const o = e._writableStreamController[_t](r._reason);
1381
+ p(o, () => (r._resolve(), Ot(e), null), (s) => (r._reject(s), Ot(e), null));
1382
+ }
1383
+ function Sa(e) {
1384
+ e._inFlightWriteRequest._resolve(void 0), e._inFlightWriteRequest = void 0;
1385
+ }
1386
+ function wa(e, t) {
1387
+ e._inFlightWriteRequest._reject(t), e._inFlightWriteRequest = void 0, Wr(e, t);
1388
+ }
1389
+ function Ra(e) {
1390
+ e._inFlightCloseRequest._resolve(void 0), e._inFlightCloseRequest = void 0, e._state === "erroring" && (e._storedError = void 0, e._pendingAbortRequest !== void 0 && (e._pendingAbortRequest._resolve(), e._pendingAbortRequest = void 0)), e._state = "closed";
1391
+ const r = e._writer;
1392
+ r !== void 0 && Jn(r);
1393
+ }
1394
+ function Ca(e, t) {
1395
+ e._inFlightCloseRequest._reject(t), e._inFlightCloseRequest = void 0, e._pendingAbortRequest !== void 0 && (e._pendingAbortRequest._reject(t), e._pendingAbortRequest = void 0), Wr(e, t);
1396
+ }
1397
+ function oe(e) {
1398
+ return !(e._closeRequest === void 0 && e._inFlightCloseRequest === void 0);
1399
+ }
1400
+ function Ta(e) {
1401
+ return !(e._inFlightWriteRequest === void 0 && e._inFlightCloseRequest === void 0);
1402
+ }
1403
+ function Pa(e) {
1404
+ e._inFlightCloseRequest = e._closeRequest, e._closeRequest = void 0;
1405
+ }
1406
+ function va(e) {
1407
+ e._inFlightWriteRequest = e._writeRequests.shift();
1408
+ }
1409
+ function Ot(e) {
1410
+ e._closeRequest !== void 0 && (e._closeRequest._reject(e._storedError), e._closeRequest = void 0);
1411
+ const t = e._writer;
1412
+ t !== void 0 && jr(t, e._storedError);
1413
+ }
1414
+ function Or(e, t) {
1415
+ const r = e._writer;
1416
+ r !== void 0 && t !== e._backpressure && (t ? Da(r) : Dr(r)), e._backpressure = t;
1417
+ }
1418
+ class ce {
1419
+ constructor(t) {
1420
+ if (ue(t, 1, "WritableStreamDefaultWriter"), jn(t, "First parameter"), Me(t))
1421
+ throw new TypeError("This stream has already been locked for exclusive writing by another writer");
1422
+ this._ownerWritableStream = t, t._writer = this;
1423
+ const r = t._state;
1424
+ if (r === "writable")
1425
+ !oe(t) && t._backpressure ? Lt(this) : Zn(this), jt(this);
1426
+ else if (r === "erroring")
1427
+ Lr(this, t._storedError), jt(this);
1428
+ else if (r === "closed")
1429
+ Zn(this), ja(this);
1430
+ else {
1431
+ const o = t._storedError;
1432
+ Lr(this, o), Gn(this, o);
1433
+ }
1434
+ }
1435
+ /**
1436
+ * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
1437
+ * the writer’s lock is released before the stream finishes closing.
1438
+ */
1439
+ get closed() {
1440
+ return Oe(this) ? this._closedPromise : m(ze("closed"));
1441
+ }
1442
+ /**
1443
+ * Returns the desired size to fill the stream’s internal queue. It can be negative, if the queue is over-full.
1444
+ * A producer can use this information to determine the right amount of data to write.
1445
+ *
1446
+ * It will be `null` if the stream cannot be successfully written to (due to either being errored, or having an abort
1447
+ * queued up). It will return zero if the stream is closed. And the getter will throw an exception if invoked when
1448
+ * the writer’s lock is released.
1449
+ */
1450
+ get desiredSize() {
1451
+ if (!Oe(this))
1452
+ throw ze("desiredSize");
1453
+ if (this._ownerWritableStream === void 0)
1454
+ throw st("desiredSize");
1455
+ return Wa(this);
1456
+ }
1457
+ /**
1458
+ * Returns a promise that will be fulfilled when the desired size to fill the stream’s internal queue transitions
1459
+ * from non-positive to positive, signaling that it is no longer applying backpressure. Once the desired size dips
1460
+ * back to zero or below, the getter will return a new promise that stays pending until the next transition.
1461
+ *
1462
+ * If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become
1463
+ * rejected.
1464
+ */
1465
+ get ready() {
1466
+ return Oe(this) ? this._readyPromise : m(ze("ready"));
1467
+ }
1468
+ /**
1469
+ * If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
1470
+ */
1471
+ abort(t = void 0) {
1472
+ return Oe(this) ? this._ownerWritableStream === void 0 ? m(st("abort")) : Ea(this, t) : m(ze("abort"));
1473
+ }
1474
+ /**
1475
+ * If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}.
1476
+ */
1477
+ close() {
1478
+ if (!Oe(this))
1479
+ return m(ze("close"));
1480
+ const t = this._ownerWritableStream;
1481
+ return t === void 0 ? m(st("close")) : oe(t) ? m(new TypeError("Cannot close an already-closing stream")) : Mn(this);
1482
+ }
1483
+ /**
1484
+ * Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active.
1485
+ * If the associated stream is errored when the lock is released, the writer will appear errored in the same way from
1486
+ * now on; otherwise, the writer will appear closed.
1487
+ *
1488
+ * Note that the lock can still be released even if some ongoing writes have not yet finished (i.e. even if the
1489
+ * promises returned from previous calls to {@link WritableStreamDefaultWriter.write | write()} have not yet settled).
1490
+ * It’s not necessary to hold the lock on the writer for the duration of the write; the lock instead simply prevents
1491
+ * other producers from writing in an interleaved manner.
1492
+ */
1493
+ releaseLock() {
1494
+ if (!Oe(this))
1495
+ throw ze("releaseLock");
1496
+ this._ownerWritableStream !== void 0 && xn(this);
1497
+ }
1498
+ write(t = void 0) {
1499
+ return Oe(this) ? this._ownerWritableStream === void 0 ? m(st("write to")) : Nn(this, t) : m(ze("write"));
1500
+ }
1501
+ }
1502
+ Object.defineProperties(ce.prototype, {
1503
+ abort: { enumerable: !0 },
1504
+ close: { enumerable: !0 },
1505
+ releaseLock: { enumerable: !0 },
1506
+ write: { enumerable: !0 },
1507
+ closed: { enumerable: !0 },
1508
+ desiredSize: { enumerable: !0 },
1509
+ ready: { enumerable: !0 }
1510
+ }), c(ce.prototype.abort, "abort"), c(ce.prototype.close, "close"), c(ce.prototype.releaseLock, "releaseLock"), c(ce.prototype.write, "write"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ce.prototype, Symbol.toStringTag, {
1511
+ value: "WritableStreamDefaultWriter",
1512
+ configurable: !0
1513
+ });
1514
+ function Oe(e) {
1515
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_ownerWritableStream") ? !1 : e instanceof ce;
1516
+ }
1517
+ function Ea(e, t) {
1518
+ const r = e._ownerWritableStream;
1519
+ return qt(r, t);
1520
+ }
1521
+ function Mn(e) {
1522
+ const t = e._ownerWritableStream;
1523
+ return $n(t);
1524
+ }
1525
+ function Aa(e) {
1526
+ const t = e._ownerWritableStream, r = t._state;
1527
+ return oe(t) || r === "closed" ? w(void 0) : r === "errored" ? m(t._storedError) : Mn(e);
1528
+ }
1529
+ function Ba(e, t) {
1530
+ e._closedPromiseState === "pending" ? jr(e, t) : La(e, t);
1531
+ }
1532
+ function Un(e, t) {
1533
+ e._readyPromiseState === "pending" ? Kn(e, t) : $a(e, t);
1534
+ }
1535
+ function Wa(e) {
1536
+ const t = e._ownerWritableStream, r = t._state;
1537
+ return r === "errored" || r === "erroring" ? null : r === "closed" ? 0 : Vn(t._writableStreamController);
1538
+ }
1539
+ function xn(e) {
1540
+ const t = e._ownerWritableStream, r = new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");
1541
+ Un(e, r), Ba(e, r), t._writer = void 0, e._ownerWritableStream = void 0;
1542
+ }
1543
+ function Nn(e, t) {
1544
+ const r = e._ownerWritableStream, o = r._writableStreamController, s = Oa(o, t);
1545
+ if (r !== e._ownerWritableStream)
1546
+ return m(st("write to"));
1547
+ const f = r._state;
1548
+ if (f === "errored")
1549
+ return m(r._storedError);
1550
+ if (oe(r) || f === "closed")
1551
+ return m(new TypeError("The stream is closing or closed and cannot be written to"));
1552
+ if (f === "erroring")
1553
+ return m(r._storedError);
1554
+ const d = _a(r);
1555
+ return za(o, t, s), d;
1556
+ }
1557
+ const Hn = {};
1558
+ class Ue {
1559
+ constructor() {
1560
+ throw new TypeError("Illegal constructor");
1561
+ }
1562
+ /**
1563
+ * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
1564
+ *
1565
+ * @deprecated
1566
+ * This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
1567
+ * Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
1568
+ */
1569
+ get abortReason() {
1570
+ if (!zr(this))
1571
+ throw Ir("abortReason");
1572
+ return this._abortReason;
1573
+ }
1574
+ /**
1575
+ * An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
1576
+ */
1577
+ get signal() {
1578
+ if (!zr(this))
1579
+ throw Ir("signal");
1580
+ if (this._abortController === void 0)
1581
+ throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");
1582
+ return this._abortController.signal;
1583
+ }
1584
+ /**
1585
+ * Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
1586
+ *
1587
+ * This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying
1588
+ * sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the
1589
+ * normal lifecycle of interactions with the underlying sink.
1590
+ */
1591
+ error(t = void 0) {
1592
+ if (!zr(this))
1593
+ throw Ir("error");
1594
+ this._controlledWritableStream._state === "writable" && Yn(this, t);
1595
+ }
1596
+ /** @internal */
1597
+ [_t](t) {
1598
+ const r = this._abortAlgorithm(t);
1599
+ return zt(this), r;
1600
+ }
1601
+ /** @internal */
1602
+ [en]() {
1603
+ we(this);
1604
+ }
1605
+ }
1606
+ Object.defineProperties(Ue.prototype, {
1607
+ abortReason: { enumerable: !0 },
1608
+ signal: { enumerable: !0 },
1609
+ error: { enumerable: !0 }
1610
+ }), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Ue.prototype, Symbol.toStringTag, {
1611
+ value: "WritableStreamDefaultController",
1612
+ configurable: !0
1613
+ });
1614
+ function zr(e) {
1615
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_controlledWritableStream") ? !1 : e instanceof Ue;
1616
+ }
1617
+ function Qn(e, t, r, o, s, f, d, b) {
1618
+ t._controlledWritableStream = e, e._writableStreamController = t, t._queue = void 0, t._queueTotalSize = void 0, we(t), t._abortReason = void 0, t._abortController = ya(), t._started = !1, t._strategySizeAlgorithm = b, t._strategyHWM = d, t._writeAlgorithm = o, t._closeAlgorithm = s, t._abortAlgorithm = f;
1619
+ const S = Fr(t);
1620
+ Or(e, S);
1621
+ const y = r(), C = w(y);
1622
+ p(C, () => (t._started = !0, Ft(t), null), (P) => (t._started = !0, Wr(e, P), null));
1623
+ }
1624
+ function ka(e, t, r, o) {
1625
+ const s = Object.create(Ue.prototype);
1626
+ let f, d, b, S;
1627
+ t.start !== void 0 ? f = () => t.start(s) : f = () => {
1628
+ }, t.write !== void 0 ? d = (y) => t.write(y, s) : d = () => w(void 0), t.close !== void 0 ? b = () => t.close() : b = () => w(void 0), t.abort !== void 0 ? S = (y) => t.abort(y) : S = () => w(void 0), Qn(e, s, f, d, b, S, r, o);
1629
+ }
1630
+ function zt(e) {
1631
+ e._writeAlgorithm = void 0, e._closeAlgorithm = void 0, e._abortAlgorithm = void 0, e._strategySizeAlgorithm = void 0;
1632
+ }
1633
+ function qa(e) {
1634
+ Rr(e, Hn, 0), Ft(e);
1635
+ }
1636
+ function Oa(e, t) {
1637
+ try {
1638
+ return e._strategySizeAlgorithm(t);
1639
+ } catch (r) {
1640
+ return it(e, r), 1;
1641
+ }
1642
+ }
1643
+ function Vn(e) {
1644
+ return e._strategyHWM - e._queueTotalSize;
1645
+ }
1646
+ function za(e, t, r) {
1647
+ try {
1648
+ Rr(e, t, r);
1649
+ } catch (s) {
1650
+ it(e, s);
1651
+ return;
1652
+ }
1653
+ const o = e._controlledWritableStream;
1654
+ if (!oe(o) && o._state === "writable") {
1655
+ const s = Fr(e);
1656
+ Or(o, s);
1657
+ }
1658
+ Ft(e);
1659
+ }
1660
+ function Ft(e) {
1661
+ const t = e._controlledWritableStream;
1662
+ if (!e._started || t._inFlightWriteRequest !== void 0)
1663
+ return;
1664
+ if (t._state === "erroring") {
1665
+ qr(t);
1666
+ return;
1667
+ }
1668
+ if (e._queue.length === 0)
1669
+ return;
1670
+ const o = Yo(e);
1671
+ o === Hn ? Fa(e) : Ia(e, o);
1672
+ }
1673
+ function it(e, t) {
1674
+ e._controlledWritableStream._state === "writable" && Yn(e, t);
1675
+ }
1676
+ function Fa(e) {
1677
+ const t = e._controlledWritableStream;
1678
+ Pa(t), wr(e);
1679
+ const r = e._closeAlgorithm();
1680
+ zt(e), p(r, () => (Ra(t), null), (o) => (Ca(t, o), null));
1681
+ }
1682
+ function Ia(e, t) {
1683
+ const r = e._controlledWritableStream;
1684
+ va(r);
1685
+ const o = e._writeAlgorithm(t);
1686
+ p(o, () => {
1687
+ Sa(r);
1688
+ const s = r._state;
1689
+ if (wr(e), !oe(r) && s === "writable") {
1690
+ const f = Fr(e);
1691
+ Or(r, f);
1692
+ }
1693
+ return Ft(e), null;
1694
+ }, (s) => (r._state === "writable" && zt(e), wa(r, s), null));
1695
+ }
1696
+ function Fr(e) {
1697
+ return Vn(e) <= 0;
1698
+ }
1699
+ function Yn(e, t) {
1700
+ const r = e._controlledWritableStream;
1701
+ zt(e), kr(r, t);
1702
+ }
1703
+ function It(e) {
1704
+ return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`);
1705
+ }
1706
+ function Ir(e) {
1707
+ return new TypeError(`WritableStreamDefaultController.prototype.${e} can only be used on a WritableStreamDefaultController`);
1708
+ }
1709
+ function ze(e) {
1710
+ return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`);
1711
+ }
1712
+ function st(e) {
1713
+ return new TypeError("Cannot " + e + " a stream using a released writer");
1714
+ }
1715
+ function jt(e) {
1716
+ e._closedPromise = E((t, r) => {
1717
+ e._closedPromise_resolve = t, e._closedPromise_reject = r, e._closedPromiseState = "pending";
1718
+ });
1719
+ }
1720
+ function Gn(e, t) {
1721
+ jt(e), jr(e, t);
1722
+ }
1723
+ function ja(e) {
1724
+ jt(e), Jn(e);
1725
+ }
1726
+ function jr(e, t) {
1727
+ e._closedPromise_reject !== void 0 && (L(e._closedPromise), e._closedPromise_reject(t), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0, e._closedPromiseState = "rejected");
1728
+ }
1729
+ function La(e, t) {
1730
+ Gn(e, t);
1731
+ }
1732
+ function Jn(e) {
1733
+ e._closedPromise_resolve !== void 0 && (e._closedPromise_resolve(void 0), e._closedPromise_resolve = void 0, e._closedPromise_reject = void 0, e._closedPromiseState = "resolved");
1734
+ }
1735
+ function Lt(e) {
1736
+ e._readyPromise = E((t, r) => {
1737
+ e._readyPromise_resolve = t, e._readyPromise_reject = r;
1738
+ }), e._readyPromiseState = "pending";
1739
+ }
1740
+ function Lr(e, t) {
1741
+ Lt(e), Kn(e, t);
1742
+ }
1743
+ function Zn(e) {
1744
+ Lt(e), Dr(e);
1745
+ }
1746
+ function Kn(e, t) {
1747
+ e._readyPromise_reject !== void 0 && (L(e._readyPromise), e._readyPromise_reject(t), e._readyPromise_resolve = void 0, e._readyPromise_reject = void 0, e._readyPromiseState = "rejected");
1748
+ }
1749
+ function Da(e) {
1750
+ Lt(e);
1751
+ }
1752
+ function $a(e, t) {
1753
+ Lr(e, t);
1754
+ }
1755
+ function Dr(e) {
1756
+ e._readyPromise_resolve !== void 0 && (e._readyPromise_resolve(void 0), e._readyPromise_resolve = void 0, e._readyPromise_reject = void 0, e._readyPromiseState = "fulfilled");
1757
+ }
1758
+ function Ma() {
1759
+ if (typeof globalThis < "u")
1760
+ return globalThis;
1761
+ if (typeof self < "u")
1762
+ return self;
1763
+ if (typeof Vr < "u")
1764
+ return Vr;
1765
+ }
1766
+ const $r = Ma();
1767
+ function Ua(e) {
1768
+ if (!(typeof e == "function" || typeof e == "object") || e.name !== "DOMException")
1769
+ return !1;
1770
+ try {
1771
+ return new e(), !0;
1772
+ } catch {
1773
+ return !1;
1774
+ }
1775
+ }
1776
+ function xa() {
1777
+ const e = $r == null ? void 0 : $r.DOMException;
1778
+ return Ua(e) ? e : void 0;
1779
+ }
1780
+ function Na() {
1781
+ const e = function(r, o) {
1782
+ this.message = r || "", this.name = o || "Error", Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
1783
+ };
1784
+ return c(e, "DOMException"), e.prototype = Object.create(Error.prototype), Object.defineProperty(e.prototype, "constructor", { value: e, writable: !0, configurable: !0 }), e;
1785
+ }
1786
+ const Ha = xa() || Na();
1787
+ function Xn(e, t, r, o, s, f) {
1788
+ const d = Le(e), b = Ln(t);
1789
+ e._disturbed = !0;
1790
+ let S = !1, y = w(void 0);
1791
+ return E((C, P) => {
1792
+ let k;
1793
+ if (f !== void 0) {
1794
+ if (k = () => {
1795
+ const g = f.reason !== void 0 ? f.reason : new Ha("Aborted", "AbortError"), A = [];
1796
+ o || A.push(() => t._state === "writable" ? qt(t, g) : w(void 0)), s || A.push(() => e._state === "readable" ? ee(e, g) : w(void 0)), N(() => Promise.all(A.map((q) => q())), !0, g);
1797
+ }, f.aborted) {
1798
+ k();
1799
+ return;
1800
+ }
1801
+ f.addEventListener("abort", k);
1802
+ }
1803
+ function te() {
1804
+ return E((g, A) => {
1805
+ function q(Q) {
1806
+ Q ? g() : W(Qe(), q, A);
1807
+ }
1808
+ q(!1);
1809
+ });
1810
+ }
1811
+ function Qe() {
1812
+ return S ? w(!0) : W(b._readyPromise, () => E((g, A) => {
1813
+ tt(d, {
1814
+ _chunkSteps: (q) => {
1815
+ y = W(Nn(b, q), void 0, u), g(!1);
1816
+ },
1817
+ _closeSteps: () => g(!0),
1818
+ _errorSteps: A
1819
+ });
1820
+ }));
1821
+ }
1822
+ if (me(e, d._closedPromise, (g) => (o ? Z(!0, g) : N(() => qt(t, g), !0, g), null)), me(t, b._closedPromise, (g) => (s ? Z(!0, g) : N(() => ee(e, g), !0, g), null)), x(e, d._closedPromise, () => (r ? Z() : N(() => Aa(b)), null)), oe(t) || t._state === "closed") {
1823
+ const g = new TypeError("the destination writable stream closed before all data could be piped to it");
1824
+ s ? Z(!0, g) : N(() => ee(e, g), !0, g);
1825
+ }
1826
+ L(te());
1827
+ function Ee() {
1828
+ const g = y;
1829
+ return W(y, () => g !== y ? Ee() : void 0);
1830
+ }
1831
+ function me(g, A, q) {
1832
+ g._state === "errored" ? q(g._storedError) : R(A, q);
1833
+ }
1834
+ function x(g, A, q) {
1835
+ g._state === "closed" ? q() : j(A, q);
1836
+ }
1837
+ function N(g, A, q) {
1838
+ if (S)
1839
+ return;
1840
+ S = !0, t._state === "writable" && !oe(t) ? j(Ee(), Q) : Q();
1841
+ function Q() {
1842
+ return p(g(), () => be(A, q), (Ve) => be(!0, Ve)), null;
1843
+ }
1844
+ }
1845
+ function Z(g, A) {
1846
+ S || (S = !0, t._state === "writable" && !oe(t) ? j(Ee(), () => be(g, A)) : be(g, A));
1847
+ }
1848
+ function be(g, A) {
1849
+ return xn(b), le(d), f !== void 0 && f.removeEventListener("abort", k), g ? P(A) : C(void 0), null;
1850
+ }
1851
+ });
1852
+ }
1853
+ class he {
1854
+ constructor() {
1855
+ throw new TypeError("Illegal constructor");
1856
+ }
1857
+ /**
1858
+ * Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
1859
+ * over-full. An underlying source ought to use this information to determine when and how to apply backpressure.
1860
+ */
1861
+ get desiredSize() {
1862
+ if (!Dt(this))
1863
+ throw Mt("desiredSize");
1864
+ return Mr(this);
1865
+ }
1866
+ /**
1867
+ * Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
1868
+ * the stream, but once those are read, the stream will become closed.
1869
+ */
1870
+ close() {
1871
+ if (!Dt(this))
1872
+ throw Mt("close");
1873
+ if (!Ne(this))
1874
+ throw new TypeError("The stream is not in a state that permits close");
1875
+ Fe(this);
1876
+ }
1877
+ enqueue(t = void 0) {
1878
+ if (!Dt(this))
1879
+ throw Mt("enqueue");
1880
+ if (!Ne(this))
1881
+ throw new TypeError("The stream is not in a state that permits enqueue");
1882
+ return xe(this, t);
1883
+ }
1884
+ /**
1885
+ * Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
1886
+ */
1887
+ error(t = void 0) {
1888
+ if (!Dt(this))
1889
+ throw Mt("error");
1890
+ X(this, t);
1891
+ }
1892
+ /** @internal */
1893
+ [ir](t) {
1894
+ we(this);
1895
+ const r = this._cancelAlgorithm(t);
1896
+ return $t(this), r;
1897
+ }
1898
+ /** @internal */
1899
+ [sr](t) {
1900
+ const r = this._controlledReadableStream;
1901
+ if (this._queue.length > 0) {
1902
+ const o = wr(this);
1903
+ this._closeRequested && this._queue.length === 0 ? ($t(this), ft(r)) : lt(this), t._chunkSteps(o);
1904
+ } else
1905
+ ln(r, t), lt(this);
1906
+ }
1907
+ /** @internal */
1908
+ [lr]() {
1909
+ }
1910
+ }
1911
+ Object.defineProperties(he.prototype, {
1912
+ close: { enumerable: !0 },
1913
+ enqueue: { enumerable: !0 },
1914
+ error: { enumerable: !0 },
1915
+ desiredSize: { enumerable: !0 }
1916
+ }), c(he.prototype.close, "close"), c(he.prototype.enqueue, "enqueue"), c(he.prototype.error, "error"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(he.prototype, Symbol.toStringTag, {
1917
+ value: "ReadableStreamDefaultController",
1918
+ configurable: !0
1919
+ });
1920
+ function Dt(e) {
1921
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_controlledReadableStream") ? !1 : e instanceof he;
1922
+ }
1923
+ function lt(e) {
1924
+ if (!eo(e))
1925
+ return;
1926
+ if (e._pulling) {
1927
+ e._pullAgain = !0;
1928
+ return;
1929
+ }
1930
+ e._pulling = !0;
1931
+ const r = e._pullAlgorithm();
1932
+ p(r, () => (e._pulling = !1, e._pullAgain && (e._pullAgain = !1, lt(e)), null), (o) => (X(e, o), null));
1933
+ }
1934
+ function eo(e) {
1935
+ const t = e._controlledReadableStream;
1936
+ return !Ne(e) || !e._started ? !1 : !!(Pe(t) && wt(t) > 0 || Mr(e) > 0);
1937
+ }
1938
+ function $t(e) {
1939
+ e._pullAlgorithm = void 0, e._cancelAlgorithm = void 0, e._strategySizeAlgorithm = void 0;
1940
+ }
1941
+ function Fe(e) {
1942
+ if (!Ne(e))
1943
+ return;
1944
+ const t = e._controlledReadableStream;
1945
+ e._closeRequested = !0, e._queue.length === 0 && ($t(e), ft(t));
1946
+ }
1947
+ function xe(e, t) {
1948
+ if (!Ne(e))
1949
+ return;
1950
+ const r = e._controlledReadableStream;
1951
+ if (Pe(r) && wt(r) > 0)
1952
+ pr(r, t, !1);
1953
+ else {
1954
+ let o;
1955
+ try {
1956
+ o = e._strategySizeAlgorithm(t);
1957
+ } catch (s) {
1958
+ throw X(e, s), s;
1959
+ }
1960
+ try {
1961
+ Rr(e, t, o);
1962
+ } catch (s) {
1963
+ throw X(e, s), s;
1964
+ }
1965
+ }
1966
+ lt(e);
1967
+ }
1968
+ function X(e, t) {
1969
+ const r = e._controlledReadableStream;
1970
+ r._state === "readable" && (we(e), $t(e), oo(r, t));
1971
+ }
1972
+ function Mr(e) {
1973
+ const t = e._controlledReadableStream._state;
1974
+ return t === "errored" ? null : t === "closed" ? 0 : e._strategyHWM - e._queueTotalSize;
1975
+ }
1976
+ function Qa(e) {
1977
+ return !eo(e);
1978
+ }
1979
+ function Ne(e) {
1980
+ const t = e._controlledReadableStream._state;
1981
+ return !e._closeRequested && t === "readable";
1982
+ }
1983
+ function to(e, t, r, o, s, f, d) {
1984
+ t._controlledReadableStream = e, t._queue = void 0, t._queueTotalSize = void 0, we(t), t._started = !1, t._closeRequested = !1, t._pullAgain = !1, t._pulling = !1, t._strategySizeAlgorithm = d, t._strategyHWM = f, t._pullAlgorithm = o, t._cancelAlgorithm = s, e._readableStreamController = t;
1985
+ const b = r();
1986
+ p(w(b), () => (t._started = !0, lt(t), null), (S) => (X(t, S), null));
1987
+ }
1988
+ function Va(e, t, r, o) {
1989
+ const s = Object.create(he.prototype);
1990
+ let f, d, b;
1991
+ t.start !== void 0 ? f = () => t.start(s) : f = () => {
1992
+ }, t.pull !== void 0 ? d = () => t.pull(s) : d = () => w(void 0), t.cancel !== void 0 ? b = (S) => t.cancel(S) : b = () => w(void 0), to(e, s, f, d, b, r, o);
1993
+ }
1994
+ function Mt(e) {
1995
+ return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`);
1996
+ }
1997
+ function Ya(e, t) {
1998
+ return We(e._readableStreamController) ? Ja(e) : Ga(e);
1999
+ }
2000
+ function Ga(e, t) {
2001
+ const r = Le(e);
2002
+ let o = !1, s = !1, f = !1, d = !1, b, S, y, C, P;
2003
+ const k = E((x) => {
2004
+ P = x;
2005
+ });
2006
+ function te() {
2007
+ return o ? (s = !0, w(void 0)) : (o = !0, tt(r, {
2008
+ _chunkSteps: (N) => {
2009
+ Y(() => {
2010
+ s = !1;
2011
+ const Z = N, be = N;
2012
+ f || xe(y._readableStreamController, Z), d || xe(C._readableStreamController, be), o = !1, s && te();
2013
+ });
2014
+ },
2015
+ _closeSteps: () => {
2016
+ o = !1, f || Fe(y._readableStreamController), d || Fe(C._readableStreamController), (!f || !d) && P(void 0);
2017
+ },
2018
+ _errorSteps: () => {
2019
+ o = !1;
2020
+ }
2021
+ }), w(void 0));
2022
+ }
2023
+ function Qe(x) {
2024
+ if (f = !0, b = x, d) {
2025
+ const N = rt([b, S]), Z = ee(e, N);
2026
+ P(Z);
2027
+ }
2028
+ return k;
2029
+ }
2030
+ function Ee(x) {
2031
+ if (d = !0, S = x, f) {
2032
+ const N = rt([b, S]), Z = ee(e, N);
2033
+ P(Z);
2034
+ }
2035
+ return k;
2036
+ }
2037
+ function me() {
2038
+ }
2039
+ return y = ut(me, te, Qe), C = ut(me, te, Ee), R(r._closedPromise, (x) => (X(y._readableStreamController, x), X(C._readableStreamController, x), (!f || !d) && P(void 0), null)), [y, C];
2040
+ }
2041
+ function Ja(e) {
2042
+ let t = Le(e), r = !1, o = !1, s = !1, f = !1, d = !1, b, S, y, C, P;
2043
+ const k = E((g) => {
2044
+ P = g;
2045
+ });
2046
+ function te(g) {
2047
+ R(g._closedPromise, (A) => (g !== t || (J(y._readableStreamController, A), J(C._readableStreamController, A), (!f || !d) && P(void 0)), null));
2048
+ }
2049
+ function Qe() {
2050
+ qe(t) && (le(t), t = Le(e), te(t)), tt(t, {
2051
+ _chunkSteps: (A) => {
2052
+ Y(() => {
2053
+ o = !1, s = !1;
2054
+ const q = A;
2055
+ let Q = A;
2056
+ if (!f && !d)
2057
+ try {
2058
+ Q = _n(A);
2059
+ } catch (Ve) {
2060
+ J(y._readableStreamController, Ve), J(C._readableStreamController, Ve), P(ee(e, Ve));
2061
+ return;
2062
+ }
2063
+ f || vt(y._readableStreamController, q), d || vt(C._readableStreamController, Q), r = !1, o ? me() : s && x();
2064
+ });
2065
+ },
2066
+ _closeSteps: () => {
2067
+ r = !1, f || nt(y._readableStreamController), d || nt(C._readableStreamController), y._readableStreamController._pendingPullIntos.length > 0 && Et(y._readableStreamController, 0), C._readableStreamController._pendingPullIntos.length > 0 && Et(C._readableStreamController, 0), (!f || !d) && P(void 0);
2068
+ },
2069
+ _errorSteps: () => {
2070
+ r = !1;
2071
+ }
2072
+ });
2073
+ }
2074
+ function Ee(g, A) {
2075
+ _e(t) && (le(t), t = qn(e), te(t));
2076
+ const q = A ? C : y, Q = A ? y : C;
2077
+ Fn(t, g, 1, {
2078
+ _chunkSteps: (Ye) => {
2079
+ Y(() => {
2080
+ o = !1, s = !1;
2081
+ const Ge = A ? d : f;
2082
+ if (A ? f : d)
2083
+ Ge || At(q._readableStreamController, Ye);
2084
+ else {
2085
+ let go;
2086
+ try {
2087
+ go = _n(Ye);
2088
+ } catch (Qr) {
2089
+ J(q._readableStreamController, Qr), J(Q._readableStreamController, Qr), P(ee(e, Qr));
2090
+ return;
2091
+ }
2092
+ Ge || At(q._readableStreamController, Ye), vt(Q._readableStreamController, go);
2093
+ }
2094
+ r = !1, o ? me() : s && x();
2095
+ });
2096
+ },
2097
+ _closeSteps: (Ye) => {
2098
+ r = !1;
2099
+ const Ge = A ? d : f, Gt = A ? f : d;
2100
+ Ge || nt(q._readableStreamController), Gt || nt(Q._readableStreamController), Ye !== void 0 && (Ge || At(q._readableStreamController, Ye), !Gt && Q._readableStreamController._pendingPullIntos.length > 0 && Et(Q._readableStreamController, 0)), (!Ge || !Gt) && P(void 0);
2101
+ },
2102
+ _errorSteps: () => {
2103
+ r = !1;
2104
+ }
2105
+ });
2106
+ }
2107
+ function me() {
2108
+ if (r)
2109
+ return o = !0, w(void 0);
2110
+ r = !0;
2111
+ const g = Er(y._readableStreamController);
2112
+ return g === null ? Qe() : Ee(g._view, !1), w(void 0);
2113
+ }
2114
+ function x() {
2115
+ if (r)
2116
+ return s = !0, w(void 0);
2117
+ r = !0;
2118
+ const g = Er(C._readableStreamController);
2119
+ return g === null ? Qe() : Ee(g._view, !0), w(void 0);
2120
+ }
2121
+ function N(g) {
2122
+ if (f = !0, b = g, d) {
2123
+ const A = rt([b, S]), q = ee(e, A);
2124
+ P(q);
2125
+ }
2126
+ return k;
2127
+ }
2128
+ function Z(g) {
2129
+ if (d = !0, S = g, f) {
2130
+ const A = rt([b, S]), q = ee(e, A);
2131
+ P(q);
2132
+ }
2133
+ return k;
2134
+ }
2135
+ function be() {
2136
+ }
2137
+ return y = no(be, me, N), C = no(be, x, Z), te(t), [y, C];
2138
+ }
2139
+ function Za(e) {
2140
+ return l(e) && typeof e.getReader < "u";
2141
+ }
2142
+ function Ka(e) {
2143
+ return Za(e) ? ei(e.getReader()) : Xa(e);
2144
+ }
2145
+ function Xa(e) {
2146
+ let t;
2147
+ const r = gn(e, "async"), o = u;
2148
+ function s() {
2149
+ let d;
2150
+ try {
2151
+ d = No(r);
2152
+ } catch (S) {
2153
+ return m(S);
2154
+ }
2155
+ const b = w(d);
2156
+ return B(b, (S) => {
2157
+ if (!l(S))
2158
+ throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
2159
+ if (Ho(S))
2160
+ Fe(t._readableStreamController);
2161
+ else {
2162
+ const C = Qo(S);
2163
+ xe(t._readableStreamController, C);
2164
+ }
2165
+ });
2166
+ }
2167
+ function f(d) {
2168
+ const b = r.iterator;
2169
+ let S;
2170
+ try {
2171
+ S = Ct(b, "return");
2172
+ } catch (P) {
2173
+ return m(P);
2174
+ }
2175
+ if (S === void 0)
2176
+ return w(void 0);
2177
+ let y;
2178
+ try {
2179
+ y = O(S, b, [d]);
2180
+ } catch (P) {
2181
+ return m(P);
2182
+ }
2183
+ const C = w(y);
2184
+ return B(C, (P) => {
2185
+ if (!l(P))
2186
+ throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
2187
+ });
2188
+ }
2189
+ return t = ut(o, s, f, 0), t;
2190
+ }
2191
+ function ei(e) {
2192
+ let t;
2193
+ const r = u;
2194
+ function o() {
2195
+ let f;
2196
+ try {
2197
+ f = e.read();
2198
+ } catch (d) {
2199
+ return m(d);
2200
+ }
2201
+ return B(f, (d) => {
2202
+ if (!l(d))
2203
+ throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
2204
+ if (d.done)
2205
+ Fe(t._readableStreamController);
2206
+ else {
2207
+ const b = d.value;
2208
+ xe(t._readableStreamController, b);
2209
+ }
2210
+ });
2211
+ }
2212
+ function s(f) {
2213
+ try {
2214
+ return w(e.cancel(f));
2215
+ } catch (d) {
2216
+ return m(d);
2217
+ }
2218
+ }
2219
+ return t = ut(r, o, s, 0), t;
2220
+ }
2221
+ function ti(e, t) {
2222
+ ne(e, t);
2223
+ const r = e, o = r == null ? void 0 : r.autoAllocateChunkSize, s = r == null ? void 0 : r.cancel, f = r == null ? void 0 : r.pull, d = r == null ? void 0 : r.start, b = r == null ? void 0 : r.type;
2224
+ return {
2225
+ autoAllocateChunkSize: o === void 0 ? void 0 : mr(o, `${t} has member 'autoAllocateChunkSize' that`),
2226
+ cancel: s === void 0 ? void 0 : ri(s, r, `${t} has member 'cancel' that`),
2227
+ pull: f === void 0 ? void 0 : ni(f, r, `${t} has member 'pull' that`),
2228
+ start: d === void 0 ? void 0 : oi(d, r, `${t} has member 'start' that`),
2229
+ type: b === void 0 ? void 0 : ai(b, `${t} has member 'type' that`)
2230
+ };
2231
+ }
2232
+ function ri(e, t, r) {
2233
+ return G(e, r), (o) => z(e, t, [o]);
2234
+ }
2235
+ function ni(e, t, r) {
2236
+ return G(e, r), (o) => z(e, t, [o]);
2237
+ }
2238
+ function oi(e, t, r) {
2239
+ return G(e, r), (o) => O(e, t, [o]);
2240
+ }
2241
+ function ai(e, t) {
2242
+ if (e = `${e}`, e !== "bytes")
2243
+ throw new TypeError(`${t} '${e}' is not a valid enumeration value for ReadableStreamType`);
2244
+ return e;
2245
+ }
2246
+ function ii(e, t) {
2247
+ return ne(e, t), { preventCancel: !!(e == null ? void 0 : e.preventCancel) };
2248
+ }
2249
+ function ro(e, t) {
2250
+ ne(e, t);
2251
+ const r = e == null ? void 0 : e.preventAbort, o = e == null ? void 0 : e.preventCancel, s = e == null ? void 0 : e.preventClose, f = e == null ? void 0 : e.signal;
2252
+ return f !== void 0 && si(f, `${t} has member 'signal' that`), {
2253
+ preventAbort: !!r,
2254
+ preventCancel: !!o,
2255
+ preventClose: !!s,
2256
+ signal: f
2257
+ };
2258
+ }
2259
+ function si(e, t) {
2260
+ if (!ba(e))
2261
+ throw new TypeError(`${t} is not an AbortSignal.`);
2262
+ }
2263
+ function li(e, t) {
2264
+ ne(e, t);
2265
+ const r = e == null ? void 0 : e.readable;
2266
+ cr(r, "readable", "ReadableWritablePair"), br(r, `${t} has member 'readable' that`);
2267
+ const o = e == null ? void 0 : e.writable;
2268
+ return cr(o, "writable", "ReadableWritablePair"), jn(o, `${t} has member 'writable' that`), { readable: r, writable: o };
2269
+ }
2270
+ class D {
2271
+ constructor(t = {}, r = {}) {
2272
+ t === void 0 ? t = null : an(t, "First parameter");
2273
+ const o = kt(r, "Second parameter"), s = ti(t, "First parameter");
2274
+ if (Ur(this), s.type === "bytes") {
2275
+ if (o.size !== void 0)
2276
+ throw new RangeError("The strategy for a byte stream cannot have a size function");
2277
+ const f = at(o, 0);
2278
+ ra(this, s, f);
2279
+ } else {
2280
+ const f = Wt(o), d = at(o, 1);
2281
+ Va(this, s, d, f);
2282
+ }
2283
+ }
2284
+ /**
2285
+ * Whether or not the readable stream is locked to a {@link ReadableStreamDefaultReader | reader}.
2286
+ */
2287
+ get locked() {
2288
+ if (!Te(this))
2289
+ throw Ie("locked");
2290
+ return Pe(this);
2291
+ }
2292
+ /**
2293
+ * Cancels the stream, signaling a loss of interest in the stream by a consumer.
2294
+ *
2295
+ * The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()}
2296
+ * method, which might or might not use it.
2297
+ */
2298
+ cancel(t = void 0) {
2299
+ return Te(this) ? Pe(this) ? m(new TypeError("Cannot cancel a stream that already has a reader")) : ee(this, t) : m(Ie("cancel"));
2300
+ }
2301
+ getReader(t = void 0) {
2302
+ if (!Te(this))
2303
+ throw Ie("getReader");
2304
+ return oa(t, "First parameter").mode === void 0 ? Le(this) : qn(this);
2305
+ }
2306
+ pipeThrough(t, r = {}) {
2307
+ if (!Te(this))
2308
+ throw Ie("pipeThrough");
2309
+ ue(t, 1, "pipeThrough");
2310
+ const o = li(t, "First parameter"), s = ro(r, "Second parameter");
2311
+ if (Pe(this))
2312
+ throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");
2313
+ if (Me(o.writable))
2314
+ throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");
2315
+ const f = Xn(this, o.writable, s.preventClose, s.preventAbort, s.preventCancel, s.signal);
2316
+ return L(f), o.readable;
2317
+ }
2318
+ pipeTo(t, r = {}) {
2319
+ if (!Te(this))
2320
+ return m(Ie("pipeTo"));
2321
+ if (t === void 0)
2322
+ return m("Parameter 1 is required in 'pipeTo'.");
2323
+ if (!$e(t))
2324
+ return m(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));
2325
+ let o;
2326
+ try {
2327
+ o = ro(r, "Second parameter");
2328
+ } catch (s) {
2329
+ return m(s);
2330
+ }
2331
+ return Pe(this) ? m(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")) : Me(t) ? m(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")) : Xn(this, t, o.preventClose, o.preventAbort, o.preventCancel, o.signal);
2332
+ }
2333
+ /**
2334
+ * Tees this readable stream, returning a two-element array containing the two resulting branches as
2335
+ * new {@link ReadableStream} instances.
2336
+ *
2337
+ * Teeing a stream will lock it, preventing any other consumer from acquiring a reader.
2338
+ * To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be
2339
+ * propagated to the stream's underlying source.
2340
+ *
2341
+ * Note that the chunks seen in each branch will be the same object. If the chunks are not immutable,
2342
+ * this could allow interference between the two branches.
2343
+ */
2344
+ tee() {
2345
+ if (!Te(this))
2346
+ throw Ie("tee");
2347
+ const t = Ya(this);
2348
+ return rt(t);
2349
+ }
2350
+ values(t = void 0) {
2351
+ if (!Te(this))
2352
+ throw Ie("values");
2353
+ const r = ii(t, "First parameter");
2354
+ return Uo(this, r.preventCancel);
2355
+ }
2356
+ [Sr](t) {
2357
+ return this.values(t);
2358
+ }
2359
+ /**
2360
+ * Creates a new ReadableStream wrapping the provided iterable or async iterable.
2361
+ *
2362
+ * This can be used to adapt various kinds of objects into a readable stream,
2363
+ * such as an array, an async generator, or a Node.js readable stream.
2364
+ */
2365
+ static from(t) {
2366
+ return Ka(t);
2367
+ }
2368
+ }
2369
+ Object.defineProperties(D, {
2370
+ from: { enumerable: !0 }
2371
+ }), Object.defineProperties(D.prototype, {
2372
+ cancel: { enumerable: !0 },
2373
+ getReader: { enumerable: !0 },
2374
+ pipeThrough: { enumerable: !0 },
2375
+ pipeTo: { enumerable: !0 },
2376
+ tee: { enumerable: !0 },
2377
+ values: { enumerable: !0 },
2378
+ locked: { enumerable: !0 }
2379
+ }), c(D.from, "from"), c(D.prototype.cancel, "cancel"), c(D.prototype.getReader, "getReader"), c(D.prototype.pipeThrough, "pipeThrough"), c(D.prototype.pipeTo, "pipeTo"), c(D.prototype.tee, "tee"), c(D.prototype.values, "values"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(D.prototype, Symbol.toStringTag, {
2380
+ value: "ReadableStream",
2381
+ configurable: !0
2382
+ }), Object.defineProperty(D.prototype, Sr, {
2383
+ value: D.prototype.values,
2384
+ writable: !0,
2385
+ configurable: !0
2386
+ });
2387
+ function ut(e, t, r, o = 1, s = () => 1) {
2388
+ const f = Object.create(D.prototype);
2389
+ Ur(f);
2390
+ const d = Object.create(he.prototype);
2391
+ return to(f, d, e, t, r, o, s), f;
2392
+ }
2393
+ function no(e, t, r) {
2394
+ const o = Object.create(D.prototype);
2395
+ Ur(o);
2396
+ const s = Object.create(de.prototype);
2397
+ return kn(o, s, e, t, r, 0, void 0), o;
2398
+ }
2399
+ function Ur(e) {
2400
+ e._state = "readable", e._reader = void 0, e._storedError = void 0, e._disturbed = !1;
2401
+ }
2402
+ function Te(e) {
2403
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_readableStreamController") ? !1 : e instanceof D;
2404
+ }
2405
+ function Pe(e) {
2406
+ return e._reader !== void 0;
2407
+ }
2408
+ function ee(e, t) {
2409
+ if (e._disturbed = !0, e._state === "closed")
2410
+ return w(void 0);
2411
+ if (e._state === "errored")
2412
+ return m(e._storedError);
2413
+ ft(e);
2414
+ const r = e._reader;
2415
+ if (r !== void 0 && qe(r)) {
2416
+ const s = r._readIntoRequests;
2417
+ r._readIntoRequests = new U(), s.forEach((f) => {
2418
+ f._closeSteps(void 0);
2419
+ });
2420
+ }
2421
+ const o = e._readableStreamController[ir](t);
2422
+ return B(o, u);
2423
+ }
2424
+ function ft(e) {
2425
+ e._state = "closed";
2426
+ const t = e._reader;
2427
+ if (t !== void 0 && (nn(t), _e(t))) {
2428
+ const r = t._readRequests;
2429
+ t._readRequests = new U(), r.forEach((o) => {
2430
+ o._closeSteps();
2431
+ });
2432
+ }
2433
+ }
2434
+ function oo(e, t) {
2435
+ e._state = "errored", e._storedError = t;
2436
+ const r = e._reader;
2437
+ r !== void 0 && (dr(r, t), _e(r) ? fn(r, t) : In(r, t));
2438
+ }
2439
+ function Ie(e) {
2440
+ return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`);
2441
+ }
2442
+ function ao(e, t) {
2443
+ ne(e, t);
2444
+ const r = e == null ? void 0 : e.highWaterMark;
2445
+ return cr(r, "highWaterMark", "QueuingStrategyInit"), {
2446
+ highWaterMark: hr(r)
2447
+ };
2448
+ }
2449
+ const io = (e) => e.byteLength;
2450
+ c(io, "size");
2451
+ class Ut {
2452
+ constructor(t) {
2453
+ ue(t, 1, "ByteLengthQueuingStrategy"), t = ao(t, "First parameter"), this._byteLengthQueuingStrategyHighWaterMark = t.highWaterMark;
2454
+ }
2455
+ /**
2456
+ * Returns the high water mark provided to the constructor.
2457
+ */
2458
+ get highWaterMark() {
2459
+ if (!lo(this))
2460
+ throw so("highWaterMark");
2461
+ return this._byteLengthQueuingStrategyHighWaterMark;
2462
+ }
2463
+ /**
2464
+ * Measures the size of `chunk` by returning the value of its `byteLength` property.
2465
+ */
2466
+ get size() {
2467
+ if (!lo(this))
2468
+ throw so("size");
2469
+ return io;
2470
+ }
2471
+ }
2472
+ Object.defineProperties(Ut.prototype, {
2473
+ highWaterMark: { enumerable: !0 },
2474
+ size: { enumerable: !0 }
2475
+ }), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Ut.prototype, Symbol.toStringTag, {
2476
+ value: "ByteLengthQueuingStrategy",
2477
+ configurable: !0
2478
+ });
2479
+ function so(e) {
2480
+ return new TypeError(`ByteLengthQueuingStrategy.prototype.${e} can only be used on a ByteLengthQueuingStrategy`);
2481
+ }
2482
+ function lo(e) {
2483
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_byteLengthQueuingStrategyHighWaterMark") ? !1 : e instanceof Ut;
2484
+ }
2485
+ const uo = () => 1;
2486
+ c(uo, "size");
2487
+ class xt {
2488
+ constructor(t) {
2489
+ ue(t, 1, "CountQueuingStrategy"), t = ao(t, "First parameter"), this._countQueuingStrategyHighWaterMark = t.highWaterMark;
2490
+ }
2491
+ /**
2492
+ * Returns the high water mark provided to the constructor.
2493
+ */
2494
+ get highWaterMark() {
2495
+ if (!co(this))
2496
+ throw fo("highWaterMark");
2497
+ return this._countQueuingStrategyHighWaterMark;
2498
+ }
2499
+ /**
2500
+ * Measures the size of `chunk` by always returning 1.
2501
+ * This ensures that the total queue size is a count of the number of chunks in the queue.
2502
+ */
2503
+ get size() {
2504
+ if (!co(this))
2505
+ throw fo("size");
2506
+ return uo;
2507
+ }
2508
+ }
2509
+ Object.defineProperties(xt.prototype, {
2510
+ highWaterMark: { enumerable: !0 },
2511
+ size: { enumerable: !0 }
2512
+ }), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(xt.prototype, Symbol.toStringTag, {
2513
+ value: "CountQueuingStrategy",
2514
+ configurable: !0
2515
+ });
2516
+ function fo(e) {
2517
+ return new TypeError(`CountQueuingStrategy.prototype.${e} can only be used on a CountQueuingStrategy`);
2518
+ }
2519
+ function co(e) {
2520
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_countQueuingStrategyHighWaterMark") ? !1 : e instanceof xt;
2521
+ }
2522
+ function ui(e, t) {
2523
+ ne(e, t);
2524
+ const r = e == null ? void 0 : e.cancel, o = e == null ? void 0 : e.flush, s = e == null ? void 0 : e.readableType, f = e == null ? void 0 : e.start, d = e == null ? void 0 : e.transform, b = e == null ? void 0 : e.writableType;
2525
+ return {
2526
+ cancel: r === void 0 ? void 0 : hi(r, e, `${t} has member 'cancel' that`),
2527
+ flush: o === void 0 ? void 0 : fi(o, e, `${t} has member 'flush' that`),
2528
+ readableType: s,
2529
+ start: f === void 0 ? void 0 : di(f, e, `${t} has member 'start' that`),
2530
+ transform: d === void 0 ? void 0 : ci(d, e, `${t} has member 'transform' that`),
2531
+ writableType: b
2532
+ };
2533
+ }
2534
+ function fi(e, t, r) {
2535
+ return G(e, r), (o) => z(e, t, [o]);
2536
+ }
2537
+ function di(e, t, r) {
2538
+ return G(e, r), (o) => O(e, t, [o]);
2539
+ }
2540
+ function ci(e, t, r) {
2541
+ return G(e, r), (o, s) => z(e, t, [o, s]);
2542
+ }
2543
+ function hi(e, t, r) {
2544
+ return G(e, r), (o) => z(e, t, [o]);
2545
+ }
2546
+ class Nt {
2547
+ constructor(t = {}, r = {}, o = {}) {
2548
+ t === void 0 && (t = null);
2549
+ const s = kt(r, "Second parameter"), f = kt(o, "Third parameter"), d = ui(t, "First parameter");
2550
+ if (d.readableType !== void 0)
2551
+ throw new RangeError("Invalid readableType specified");
2552
+ if (d.writableType !== void 0)
2553
+ throw new RangeError("Invalid writableType specified");
2554
+ const b = at(f, 0), S = Wt(f), y = at(s, 1), C = Wt(s);
2555
+ let P;
2556
+ const k = E((te) => {
2557
+ P = te;
2558
+ });
2559
+ mi(this, k, y, C, b, S), pi(this, d), d.start !== void 0 ? P(d.start(this._transformStreamController)) : P(void 0);
2560
+ }
2561
+ /**
2562
+ * The readable side of the transform stream.
2563
+ */
2564
+ get readable() {
2565
+ if (!ho(this))
2566
+ throw yo("readable");
2567
+ return this._readable;
2568
+ }
2569
+ /**
2570
+ * The writable side of the transform stream.
2571
+ */
2572
+ get writable() {
2573
+ if (!ho(this))
2574
+ throw yo("writable");
2575
+ return this._writable;
2576
+ }
2577
+ }
2578
+ Object.defineProperties(Nt.prototype, {
2579
+ readable: { enumerable: !0 },
2580
+ writable: { enumerable: !0 }
2581
+ }), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Nt.prototype, Symbol.toStringTag, {
2582
+ value: "TransformStream",
2583
+ configurable: !0
2584
+ });
2585
+ function mi(e, t, r, o, s, f) {
2586
+ function d() {
2587
+ return t;
2588
+ }
2589
+ function b(k) {
2590
+ return _i(e, k);
2591
+ }
2592
+ function S(k) {
2593
+ return Si(e, k);
2594
+ }
2595
+ function y() {
2596
+ return wi(e);
2597
+ }
2598
+ e._writable = ga(d, b, y, S, r, o);
2599
+ function C() {
2600
+ return Ri(e);
2601
+ }
2602
+ function P(k) {
2603
+ return Ci(e, k);
2604
+ }
2605
+ e._readable = ut(d, C, P, s, f), e._backpressure = void 0, e._backpressureChangePromise = void 0, e._backpressureChangePromise_resolve = void 0, Ht(e, !0), e._transformStreamController = void 0;
2606
+ }
2607
+ function ho(e) {
2608
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_transformStreamController") ? !1 : e instanceof Nt;
2609
+ }
2610
+ function mo(e, t) {
2611
+ X(e._readable._readableStreamController, t), xr(e, t);
2612
+ }
2613
+ function xr(e, t) {
2614
+ Vt(e._transformStreamController), it(e._writable._writableStreamController, t), Nr(e);
2615
+ }
2616
+ function Nr(e) {
2617
+ e._backpressure && Ht(e, !1);
2618
+ }
2619
+ function Ht(e, t) {
2620
+ e._backpressureChangePromise !== void 0 && e._backpressureChangePromise_resolve(), e._backpressureChangePromise = E((r) => {
2621
+ e._backpressureChangePromise_resolve = r;
2622
+ }), e._backpressure = t;
2623
+ }
2624
+ class ve {
2625
+ constructor() {
2626
+ throw new TypeError("Illegal constructor");
2627
+ }
2628
+ /**
2629
+ * Returns the desired size to fill the readable side’s internal queue. It can be negative, if the queue is over-full.
2630
+ */
2631
+ get desiredSize() {
2632
+ if (!Qt(this))
2633
+ throw Yt("desiredSize");
2634
+ const t = this._controlledTransformStream._readable._readableStreamController;
2635
+ return Mr(t);
2636
+ }
2637
+ enqueue(t = void 0) {
2638
+ if (!Qt(this))
2639
+ throw Yt("enqueue");
2640
+ bo(this, t);
2641
+ }
2642
+ /**
2643
+ * Errors both the readable side and the writable side of the controlled transform stream, making all future
2644
+ * interactions with it fail with the given error `e`. Any chunks queued for transformation will be discarded.
2645
+ */
2646
+ error(t = void 0) {
2647
+ if (!Qt(this))
2648
+ throw Yt("error");
2649
+ yi(this, t);
2650
+ }
2651
+ /**
2652
+ * Closes the readable side and errors the writable side of the controlled transform stream. This is useful when the
2653
+ * transformer only needs to consume a portion of the chunks written to the writable side.
2654
+ */
2655
+ terminate() {
2656
+ if (!Qt(this))
2657
+ throw Yt("terminate");
2658
+ gi(this);
2659
+ }
2660
+ }
2661
+ Object.defineProperties(ve.prototype, {
2662
+ enqueue: { enumerable: !0 },
2663
+ error: { enumerable: !0 },
2664
+ terminate: { enumerable: !0 },
2665
+ desiredSize: { enumerable: !0 }
2666
+ }), c(ve.prototype.enqueue, "enqueue"), c(ve.prototype.error, "error"), c(ve.prototype.terminate, "terminate"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ve.prototype, Symbol.toStringTag, {
2667
+ value: "TransformStreamDefaultController",
2668
+ configurable: !0
2669
+ });
2670
+ function Qt(e) {
2671
+ return !l(e) || !Object.prototype.hasOwnProperty.call(e, "_controlledTransformStream") ? !1 : e instanceof ve;
2672
+ }
2673
+ function bi(e, t, r, o, s) {
2674
+ t._controlledTransformStream = e, e._transformStreamController = t, t._transformAlgorithm = r, t._flushAlgorithm = o, t._cancelAlgorithm = s, t._finishPromise = void 0, t._finishPromise_resolve = void 0, t._finishPromise_reject = void 0;
2675
+ }
2676
+ function pi(e, t) {
2677
+ const r = Object.create(ve.prototype);
2678
+ let o, s, f;
2679
+ t.transform !== void 0 ? o = (d) => t.transform(d, r) : o = (d) => {
2680
+ try {
2681
+ return bo(r, d), w(void 0);
2682
+ } catch (b) {
2683
+ return m(b);
2684
+ }
2685
+ }, t.flush !== void 0 ? s = () => t.flush(r) : s = () => w(void 0), t.cancel !== void 0 ? f = (d) => t.cancel(d) : f = () => w(void 0), bi(e, r, o, s, f);
2686
+ }
2687
+ function Vt(e) {
2688
+ e._transformAlgorithm = void 0, e._flushAlgorithm = void 0, e._cancelAlgorithm = void 0;
2689
+ }
2690
+ function bo(e, t) {
2691
+ const r = e._controlledTransformStream, o = r._readable._readableStreamController;
2692
+ if (!Ne(o))
2693
+ throw new TypeError("Readable side is not in a state that permits enqueue");
2694
+ try {
2695
+ xe(o, t);
2696
+ } catch (f) {
2697
+ throw xr(r, f), r._readable._storedError;
2698
+ }
2699
+ Qa(o) !== r._backpressure && Ht(r, !0);
2700
+ }
2701
+ function yi(e, t) {
2702
+ mo(e._controlledTransformStream, t);
2703
+ }
2704
+ function po(e, t) {
2705
+ const r = e._transformAlgorithm(t);
2706
+ return B(r, void 0, (o) => {
2707
+ throw mo(e._controlledTransformStream, o), o;
2708
+ });
2709
+ }
2710
+ function gi(e) {
2711
+ const t = e._controlledTransformStream, r = t._readable._readableStreamController;
2712
+ Fe(r);
2713
+ const o = new TypeError("TransformStream terminated");
2714
+ xr(t, o);
2715
+ }
2716
+ function _i(e, t) {
2717
+ const r = e._transformStreamController;
2718
+ if (e._backpressure) {
2719
+ const o = e._backpressureChangePromise;
2720
+ return B(o, () => {
2721
+ const s = e._writable;
2722
+ if (s._state === "erroring")
2723
+ throw s._storedError;
2724
+ return po(r, t);
2725
+ });
2726
+ }
2727
+ return po(r, t);
2728
+ }
2729
+ function Si(e, t) {
2730
+ const r = e._transformStreamController;
2731
+ if (r._finishPromise !== void 0)
2732
+ return r._finishPromise;
2733
+ const o = e._readable;
2734
+ r._finishPromise = E((f, d) => {
2735
+ r._finishPromise_resolve = f, r._finishPromise_reject = d;
2736
+ });
2737
+ const s = r._cancelAlgorithm(t);
2738
+ return Vt(r), p(s, () => (o._state === "errored" ? He(r, o._storedError) : (X(o._readableStreamController, t), Hr(r)), null), (f) => (X(o._readableStreamController, f), He(r, f), null)), r._finishPromise;
2739
+ }
2740
+ function wi(e) {
2741
+ const t = e._transformStreamController;
2742
+ if (t._finishPromise !== void 0)
2743
+ return t._finishPromise;
2744
+ const r = e._readable;
2745
+ t._finishPromise = E((s, f) => {
2746
+ t._finishPromise_resolve = s, t._finishPromise_reject = f;
2747
+ });
2748
+ const o = t._flushAlgorithm();
2749
+ return Vt(t), p(o, () => (r._state === "errored" ? He(t, r._storedError) : (Fe(r._readableStreamController), Hr(t)), null), (s) => (X(r._readableStreamController, s), He(t, s), null)), t._finishPromise;
2750
+ }
2751
+ function Ri(e) {
2752
+ return Ht(e, !1), e._backpressureChangePromise;
2753
+ }
2754
+ function Ci(e, t) {
2755
+ const r = e._transformStreamController;
2756
+ if (r._finishPromise !== void 0)
2757
+ return r._finishPromise;
2758
+ const o = e._writable;
2759
+ r._finishPromise = E((f, d) => {
2760
+ r._finishPromise_resolve = f, r._finishPromise_reject = d;
2761
+ });
2762
+ const s = r._cancelAlgorithm(t);
2763
+ return Vt(r), p(s, () => (o._state === "errored" ? He(r, o._storedError) : (it(o._writableStreamController, t), Nr(e), Hr(r)), null), (f) => (it(o._writableStreamController, f), Nr(e), He(r, f), null)), r._finishPromise;
2764
+ }
2765
+ function Yt(e) {
2766
+ return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`);
2767
+ }
2768
+ function Hr(e) {
2769
+ e._finishPromise_resolve !== void 0 && (e._finishPromise_resolve(), e._finishPromise_resolve = void 0, e._finishPromise_reject = void 0);
2770
+ }
2771
+ function He(e, t) {
2772
+ e._finishPromise_reject !== void 0 && (L(e._finishPromise), e._finishPromise_reject(t), e._finishPromise_resolve = void 0, e._finishPromise_reject = void 0);
2773
+ }
2774
+ function yo(e) {
2775
+ return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`);
2776
+ }
2777
+ a.ByteLengthQueuingStrategy = Ut, a.CountQueuingStrategy = xt, a.ReadableByteStreamController = de, a.ReadableStream = D, a.ReadableStreamBYOBReader = Re, a.ReadableStreamBYOBRequest = Be, a.ReadableStreamDefaultController = he, a.ReadableStreamDefaultReader = ge, a.TransformStream = Nt, a.TransformStreamDefaultController = ve, a.WritableStream = Ce, a.WritableStreamDefaultController = Ue, a.WritableStreamDefaultWriter = ce;
2778
+ });
2779
+ }(Jt, Jt.exports)), Jt.exports;
2780
+ }
2781
+ const Fi = 65536;
2782
+ if (!globalThis.ReadableStream)
2783
+ try {
2784
+ const i = require("node:process"), { emitWarning: n } = i;
2785
+ try {
2786
+ i.emitWarning = () => {
2787
+ }, Object.assign(globalThis, require("node:stream/web")), i.emitWarning = n;
2788
+ } catch (a) {
2789
+ throw i.emitWarning = n, a;
2790
+ }
2791
+ } catch {
2792
+ Object.assign(globalThis, zi());
2793
+ }
2794
+ try {
2795
+ const { Blob: i } = require("buffer");
2796
+ i && !i.prototype.stream && (i.prototype.stream = function(a) {
2797
+ let u = 0;
2798
+ const l = this;
2799
+ return new ReadableStream({
2800
+ type: "bytes",
2801
+ async pull(h) {
2802
+ const T = await l.slice(u, Math.min(l.size, u + Fi)).arrayBuffer();
2803
+ u += T.byteLength, h.enqueue(new Uint8Array(T)), u === l.size && h.close();
2804
+ }
2805
+ });
2806
+ });
2807
+ } catch {
2808
+ }
2809
+ /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
2810
+ const Ro = 65536;
2811
+ async function* Yr(i, n = !0) {
2812
+ for (const a of i)
2813
+ if ("stream" in a)
2814
+ yield* (
2815
+ /** @type {AsyncIterableIterator<Uint8Array>} */
2816
+ a.stream()
2817
+ );
2818
+ else if (ArrayBuffer.isView(a))
2819
+ if (n) {
2820
+ let u = a.byteOffset;
2821
+ const l = a.byteOffset + a.byteLength;
2822
+ for (; u !== l; ) {
2823
+ const h = Math.min(l - u, Ro), c = a.buffer.slice(u, u + h);
2824
+ u += c.byteLength, yield new Uint8Array(c);
2825
+ }
2826
+ } else
2827
+ yield a;
2828
+ else {
2829
+ let u = 0, l = (
2830
+ /** @type {Blob} */
2831
+ a
2832
+ );
2833
+ for (; u !== l.size; ) {
2834
+ const c = await l.slice(u, Math.min(l.size, u + Ro)).arrayBuffer();
2835
+ u += c.byteLength, yield new Uint8Array(c);
2836
+ }
2837
+ }
2838
+ }
2839
+ var pe, pt, Xe, nr, et;
2840
+ const Ao = (et = class {
2841
+ /**
2842
+ * The Blob() constructor returns a new Blob object. The content
2843
+ * of the blob consists of the concatenation of the values given
2844
+ * in the parameter array.
2845
+ *
2846
+ * @param {*} blobParts
2847
+ * @param {{ type?: string, endings?: string }} [options]
2848
+ */
2849
+ constructor(n = [], a = {}) {
2850
+ /** @type {Array.<(Blob|Uint8Array)>} */
2851
+ Ae(this, pe, []);
2852
+ Ae(this, pt, "");
2853
+ Ae(this, Xe, 0);
2854
+ Ae(this, nr, "transparent");
2855
+ if (typeof n != "object" || n === null)
2856
+ throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
2857
+ if (typeof n[Symbol.iterator] != "function")
2858
+ throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
2859
+ if (typeof a != "object" && typeof a != "function")
2860
+ throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
2861
+ a === null && (a = {});
2862
+ const u = new TextEncoder();
2863
+ for (const h of n) {
2864
+ let c;
2865
+ ArrayBuffer.isView(h) ? c = new Uint8Array(h.buffer.slice(h.byteOffset, h.byteOffset + h.byteLength)) : h instanceof ArrayBuffer ? c = new Uint8Array(h.slice(0)) : h instanceof et ? c = h : c = u.encode(`${h}`), ae(this, Xe, F(this, Xe) + (ArrayBuffer.isView(c) ? c.byteLength : c.size)), F(this, pe).push(c);
2866
+ }
2867
+ ae(this, nr, `${a.endings === void 0 ? "transparent" : a.endings}`);
2868
+ const l = a.type === void 0 ? "" : String(a.type);
2869
+ ae(this, pt, /^[\x20-\x7E]*$/.test(l) ? l : "");
2870
+ }
2871
+ /**
2872
+ * The Blob interface's size property returns the
2873
+ * size of the Blob in bytes.
2874
+ */
2875
+ get size() {
2876
+ return F(this, Xe);
2877
+ }
2878
+ /**
2879
+ * The type property of a Blob object returns the MIME type of the file.
2880
+ */
2881
+ get type() {
2882
+ return F(this, pt);
2883
+ }
2884
+ /**
2885
+ * The text() method in the Blob interface returns a Promise
2886
+ * that resolves with a string containing the contents of
2887
+ * the blob, interpreted as UTF-8.
2888
+ *
2889
+ * @return {Promise<string>}
2890
+ */
2891
+ async text() {
2892
+ const n = new TextDecoder();
2893
+ let a = "";
2894
+ for await (const u of Yr(F(this, pe), !1))
2895
+ a += n.decode(u, { stream: !0 });
2896
+ return a += n.decode(), a;
2897
+ }
2898
+ /**
2899
+ * The arrayBuffer() method in the Blob interface returns a
2900
+ * Promise that resolves with the contents of the blob as
2901
+ * binary data contained in an ArrayBuffer.
2902
+ *
2903
+ * @return {Promise<ArrayBuffer>}
2904
+ */
2905
+ async arrayBuffer() {
2906
+ const n = new Uint8Array(this.size);
2907
+ let a = 0;
2908
+ for await (const u of Yr(F(this, pe), !1))
2909
+ n.set(u, a), a += u.length;
2910
+ return n.buffer;
2911
+ }
2912
+ stream() {
2913
+ const n = Yr(F(this, pe), !0);
2914
+ return new globalThis.ReadableStream({
2915
+ // @ts-ignore
2916
+ type: "bytes",
2917
+ async pull(a) {
2918
+ const u = await n.next();
2919
+ u.done ? a.close() : a.enqueue(u.value);
2920
+ },
2921
+ async cancel() {
2922
+ await n.return();
2923
+ }
2924
+ });
2925
+ }
2926
+ /**
2927
+ * The Blob interface's slice() method creates and returns a
2928
+ * new Blob object which contains data from a subset of the
2929
+ * blob on which it's called.
2930
+ *
2931
+ * @param {number} [start]
2932
+ * @param {number} [end]
2933
+ * @param {string} [type]
2934
+ */
2935
+ slice(n = 0, a = this.size, u = "") {
2936
+ const { size: l } = this;
2937
+ let h = n < 0 ? Math.max(l + n, 0) : Math.min(n, l), c = a < 0 ? Math.max(l + a, 0) : Math.min(a, l);
2938
+ const T = Math.max(c - h, 0), v = F(this, pe), _ = [];
2939
+ let E = 0;
2940
+ for (const m of v) {
2941
+ if (E >= T)
2942
+ break;
2943
+ const W = ArrayBuffer.isView(m) ? m.byteLength : m.size;
2944
+ if (h && W <= h)
2945
+ h -= W, c -= W;
2946
+ else {
2947
+ let p;
2948
+ ArrayBuffer.isView(m) ? (p = m.subarray(h, Math.min(W, c)), E += p.byteLength) : (p = m.slice(h, Math.min(W, c)), E += p.size), c -= W, _.push(p), h = 0;
2949
+ }
2950
+ }
2951
+ const w = new et([], { type: String(u).toLowerCase() });
2952
+ return ae(w, Xe, T), ae(w, pe, _), w;
2953
+ }
2954
+ get [Symbol.toStringTag]() {
2955
+ return "Blob";
2956
+ }
2957
+ static [Symbol.hasInstance](n) {
2958
+ return n && typeof n == "object" && typeof n.constructor == "function" && (typeof n.stream == "function" || typeof n.arrayBuffer == "function") && /^(Blob|File)$/.test(n[Symbol.toStringTag]);
2959
+ }
2960
+ }, pe = new WeakMap(), pt = new WeakMap(), Xe = new WeakMap(), nr = new WeakMap(), et);
2961
+ Object.defineProperties(Ao.prototype, {
2962
+ size: { enumerable: !0 },
2963
+ type: { enumerable: !0 },
2964
+ slice: { enumerable: !0 }
2965
+ });
2966
+ const Ii = Ao, er = Ii;
2967
+ var yt, gt, vo;
2968
+ const ji = (vo = class extends er {
2969
+ /**
2970
+ * @param {*[]} fileBits
2971
+ * @param {string} fileName
2972
+ * @param {{lastModified?: number, type?: string}} options
2973
+ */
2974
+ // @ts-ignore
2975
+ constructor(a, u, l = {}) {
2976
+ if (arguments.length < 2)
2977
+ throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
2978
+ super(a, l);
2979
+ Ae(this, yt, 0);
2980
+ Ae(this, gt, "");
2981
+ l === null && (l = {});
2982
+ const h = l.lastModified === void 0 ? Date.now() : Number(l.lastModified);
2983
+ Number.isNaN(h) || ae(this, yt, h), ae(this, gt, String(u));
2984
+ }
2985
+ get name() {
2986
+ return F(this, gt);
2987
+ }
2988
+ get lastModified() {
2989
+ return F(this, yt);
2990
+ }
2991
+ get [Symbol.toStringTag]() {
2992
+ return "File";
2993
+ }
2994
+ static [Symbol.hasInstance](a) {
2995
+ return !!a && a instanceof er && /^(File)$/.test(a[Symbol.toStringTag]);
2996
+ }
2997
+ }, yt = new WeakMap(), gt = new WeakMap(), vo), Li = ji;
2998
+ /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
2999
+ var { toStringTag: ct, iterator: Di, hasInstance: $i } = Symbol, Co = Math.random, Mi = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","), To = (i, n, a) => (i += "", /^(Blob|File)$/.test(n && n[ct]) ? [(a = a !== void 0 ? a + "" : n[ct] == "File" ? n.name : "blob", i), n.name !== a || n[ct] == "blob" ? new Li([n], a, n) : n] : [i, n + ""]), Gr = (i, n) => (n ? i : i.replace(/\r?\n|\r/g, `\r
3000
+ `)).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), je = (i, n, a) => {
3001
+ if (n.length < a)
3002
+ throw new TypeError(`Failed to execute '${i}' on 'FormData': ${a} arguments required, but only ${n.length} present.`);
3003
+ }, K, Eo;
3004
+ const Zr = (Eo = class {
3005
+ constructor(...n) {
3006
+ Ae(this, K, []);
3007
+ if (n.length)
3008
+ throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.");
3009
+ }
3010
+ get [ct]() {
3011
+ return "FormData";
3012
+ }
3013
+ [Di]() {
3014
+ return this.entries();
3015
+ }
3016
+ static [$i](n) {
3017
+ return n && typeof n == "object" && n[ct] === "FormData" && !Mi.some((a) => typeof n[a] != "function");
3018
+ }
3019
+ append(...n) {
3020
+ je("append", arguments, 2), F(this, K).push(To(...n));
3021
+ }
3022
+ delete(n) {
3023
+ je("delete", arguments, 1), n += "", ae(this, K, F(this, K).filter(([a]) => a !== n));
3024
+ }
3025
+ get(n) {
3026
+ je("get", arguments, 1), n += "";
3027
+ for (var a = F(this, K), u = a.length, l = 0; l < u; l++)
3028
+ if (a[l][0] === n)
3029
+ return a[l][1];
3030
+ return null;
3031
+ }
3032
+ getAll(n, a) {
3033
+ return je("getAll", arguments, 1), a = [], n += "", F(this, K).forEach((u) => u[0] === n && a.push(u[1])), a;
3034
+ }
3035
+ has(n) {
3036
+ return je("has", arguments, 1), n += "", F(this, K).some((a) => a[0] === n);
3037
+ }
3038
+ forEach(n, a) {
3039
+ je("forEach", arguments, 1);
3040
+ for (var [u, l] of this)
3041
+ n.call(a, l, u, this);
3042
+ }
3043
+ set(...n) {
3044
+ je("set", arguments, 2);
3045
+ var a = [], u = !0;
3046
+ n = To(...n), F(this, K).forEach((l) => {
3047
+ l[0] === n[0] ? u && (u = !a.push(n)) : a.push(l);
3048
+ }), u && a.push(n), ae(this, K, a);
3049
+ }
3050
+ *entries() {
3051
+ yield* F(this, K);
3052
+ }
3053
+ *keys() {
3054
+ for (var [n] of this)
3055
+ yield n;
3056
+ }
3057
+ *values() {
3058
+ for (var [, n] of this)
3059
+ yield n;
3060
+ }
3061
+ }, K = new WeakMap(), Eo);
3062
+ function Ui(i, n = er) {
3063
+ var a = `${Co()}${Co()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), u = [], l = `--${a}\r
3064
+ Content-Disposition: form-data; name="`;
3065
+ return i.forEach((h, c) => typeof h == "string" ? u.push(l + Gr(c) + `"\r
3066
+ \r
3067
+ ${h.replace(new RegExp("\\r(?!\\n)|(?<!\\r)\\n", "g"), `\r
3068
+ `)}\r
3069
+ `) : u.push(l + Gr(c) + `"; filename="${Gr(h.name, 1)}"\r
3070
+ Content-Type: ${h.type || "application/octet-stream"}\r
3071
+ \r
3072
+ `, h, `\r
3073
+ `)), u.push(`--${a}--`), new n(u, { type: "multipart/form-data; boundary=" + a });
3074
+ }
3075
+ class ar extends Error {
3076
+ constructor(n, a) {
3077
+ super(n), Error.captureStackTrace(this, this.constructor), this.type = a;
3078
+ }
3079
+ get name() {
3080
+ return this.constructor.name;
3081
+ }
3082
+ get [Symbol.toStringTag]() {
3083
+ return this.constructor.name;
3084
+ }
3085
+ }
3086
+ class ie extends ar {
3087
+ /**
3088
+ * @param {string} message - Error message for human
3089
+ * @param {string} [type] - Error type for machine
3090
+ * @param {SystemError} [systemError] - For Node.js system error
3091
+ */
3092
+ constructor(n, a, u) {
3093
+ super(n, a), u && (this.code = this.errno = u.code, this.erroredSysCall = u.syscall);
3094
+ }
3095
+ }
3096
+ const tr = Symbol.toStringTag, Bo = (i) => typeof i == "object" && typeof i.append == "function" && typeof i.delete == "function" && typeof i.get == "function" && typeof i.getAll == "function" && typeof i.has == "function" && typeof i.set == "function" && typeof i.sort == "function" && i[tr] === "URLSearchParams", rr = (i) => i && typeof i == "object" && typeof i.arrayBuffer == "function" && typeof i.type == "string" && typeof i.stream == "function" && typeof i.constructor == "function" && /^(Blob|File)$/.test(i[tr]), xi = (i) => typeof i == "object" && (i[tr] === "AbortSignal" || i[tr] === "EventTarget"), Ni = (i, n) => {
3097
+ const a = new URL(n).hostname, u = new URL(i).hostname;
3098
+ return a === u || a.endsWith(`.${u}`);
3099
+ }, Hi = (i, n) => {
3100
+ const a = new URL(n).protocol, u = new URL(i).protocol;
3101
+ return a === u;
3102
+ }, Qi = vi(se.pipeline), H = Symbol("Body internals");
3103
+ class mt {
3104
+ constructor(n, {
3105
+ size: a = 0
3106
+ } = {}) {
3107
+ let u = null;
3108
+ n === null ? n = null : Bo(n) ? n = $.from(n.toString()) : rr(n) || $.isBuffer(n) || (Xt.isAnyArrayBuffer(n) ? n = $.from(n) : ArrayBuffer.isView(n) ? n = $.from(n.buffer, n.byteOffset, n.byteLength) : n instanceof se || (n instanceof Zr ? (n = Ui(n), u = n.type.split("=")[1]) : n = $.from(String(n))));
3109
+ let l = n;
3110
+ $.isBuffer(n) ? l = se.Readable.from(n) : rr(n) && (l = se.Readable.from(n.stream())), this[H] = {
3111
+ body: n,
3112
+ stream: l,
3113
+ boundary: u,
3114
+ disturbed: !1,
3115
+ error: null
3116
+ }, this.size = a, n instanceof se && n.on("error", (h) => {
3117
+ const c = h instanceof ar ? h : new ie(`Invalid response body while trying to fetch ${this.url}: ${h.message}`, "system", h);
3118
+ this[H].error = c;
3119
+ });
3120
+ }
3121
+ get body() {
3122
+ return this[H].stream;
3123
+ }
3124
+ get bodyUsed() {
3125
+ return this[H].disturbed;
3126
+ }
3127
+ /**
3128
+ * Decode response as ArrayBuffer
3129
+ *
3130
+ * @return Promise
3131
+ */
3132
+ async arrayBuffer() {
3133
+ const { buffer: n, byteOffset: a, byteLength: u } = await Jr(this);
3134
+ return n.slice(a, a + u);
3135
+ }
3136
+ async formData() {
3137
+ const n = this.headers.get("content-type");
3138
+ if (n.startsWith("application/x-www-form-urlencoded")) {
3139
+ const u = new Zr(), l = new URLSearchParams(await this.text());
3140
+ for (const [h, c] of l)
3141
+ u.append(h, c);
3142
+ return u;
3143
+ }
3144
+ const { toFormData: a } = await import("./multipart-parser-513ff2e8.js");
3145
+ return a(this.body, n);
3146
+ }
3147
+ /**
3148
+ * Return raw response as Blob
3149
+ *
3150
+ * @return Promise
3151
+ */
3152
+ async blob() {
3153
+ const n = this.headers && this.headers.get("content-type") || this[H].body && this[H].body.type || "", a = await this.arrayBuffer();
3154
+ return new er([a], {
3155
+ type: n
3156
+ });
3157
+ }
3158
+ /**
3159
+ * Decode response as json
3160
+ *
3161
+ * @return Promise
3162
+ */
3163
+ async json() {
3164
+ const n = await this.text();
3165
+ return JSON.parse(n);
3166
+ }
3167
+ /**
3168
+ * Decode response as text
3169
+ *
3170
+ * @return Promise
3171
+ */
3172
+ async text() {
3173
+ const n = await Jr(this);
3174
+ return new TextDecoder().decode(n);
3175
+ }
3176
+ /**
3177
+ * Decode response as buffer (non-spec api)
3178
+ *
3179
+ * @return Promise
3180
+ */
3181
+ buffer() {
3182
+ return Jr(this);
3183
+ }
3184
+ }
3185
+ mt.prototype.buffer = or(mt.prototype.buffer, "Please use 'response.arrayBuffer()' instead of 'response.buffer()'", "node-fetch#buffer");
3186
+ Object.defineProperties(mt.prototype, {
3187
+ body: { enumerable: !0 },
3188
+ bodyUsed: { enumerable: !0 },
3189
+ arrayBuffer: { enumerable: !0 },
3190
+ blob: { enumerable: !0 },
3191
+ json: { enumerable: !0 },
3192
+ text: { enumerable: !0 },
3193
+ data: { get: or(
3194
+ () => {
3195
+ },
3196
+ "data doesn't exist, use json(), text(), arrayBuffer(), or body instead",
3197
+ "https://github.com/node-fetch/node-fetch/issues/1000 (response)"
3198
+ ) }
3199
+ });
3200
+ async function Jr(i) {
3201
+ if (i[H].disturbed)
3202
+ throw new TypeError(`body used already for: ${i.url}`);
3203
+ if (i[H].disturbed = !0, i[H].error)
3204
+ throw i[H].error;
3205
+ const { body: n } = i;
3206
+ if (n === null)
3207
+ return $.alloc(0);
3208
+ if (!(n instanceof se))
3209
+ return $.alloc(0);
3210
+ const a = [];
3211
+ let u = 0;
3212
+ try {
3213
+ for await (const l of n) {
3214
+ if (i.size > 0 && u + l.length > i.size) {
3215
+ const h = new ie(`content size at ${i.url} over limit: ${i.size}`, "max-size");
3216
+ throw n.destroy(h), h;
3217
+ }
3218
+ u += l.length, a.push(l);
3219
+ }
3220
+ } catch (l) {
3221
+ throw l instanceof ar ? l : new ie(`Invalid response body while trying to fetch ${i.url}: ${l.message}`, "system", l);
3222
+ }
3223
+ if (n.readableEnded === !0 || n._readableState.ended === !0)
3224
+ try {
3225
+ return a.every((l) => typeof l == "string") ? $.from(a.join("")) : $.concat(a, u);
3226
+ } catch (l) {
3227
+ throw new ie(`Could not create Buffer from response body for ${i.url}: ${l.message}`, "system", l);
3228
+ }
3229
+ else
3230
+ throw new ie(`Premature close of server response while trying to fetch ${i.url}`);
3231
+ }
3232
+ const Xr = (i, n) => {
3233
+ let a, u, { body: l } = i[H];
3234
+ if (i.bodyUsed)
3235
+ throw new Error("cannot clone body after it is used");
3236
+ return l instanceof se && typeof l.getBoundary != "function" && (a = new Kt({ highWaterMark: n }), u = new Kt({ highWaterMark: n }), l.pipe(a), l.pipe(u), i[H].stream = a, l = u), l;
3237
+ }, Vi = or(
3238
+ (i) => i.getBoundary(),
3239
+ "form-data doesn't follow the spec and requires special treatment. Use alternative package",
3240
+ "https://github.com/node-fetch/node-fetch/issues/1167"
3241
+ ), Wo = (i, n) => i === null ? null : typeof i == "string" ? "text/plain;charset=UTF-8" : Bo(i) ? "application/x-www-form-urlencoded;charset=UTF-8" : rr(i) ? i.type || null : $.isBuffer(i) || Xt.isAnyArrayBuffer(i) || ArrayBuffer.isView(i) ? null : i instanceof Zr ? `multipart/form-data; boundary=${n[H].boundary}` : i && typeof i.getBoundary == "function" ? `multipart/form-data;boundary=${Vi(i)}` : i instanceof se ? null : "text/plain;charset=UTF-8", Yi = (i) => {
3242
+ const { body: n } = i[H];
3243
+ return n === null ? 0 : rr(n) ? n.size : $.isBuffer(n) ? n.length : n && typeof n.getLengthSync == "function" && n.hasKnownLength && n.hasKnownLength() ? n.getLengthSync() : null;
3244
+ }, Gi = async (i, { body: n }) => {
3245
+ n === null ? i.end() : await Qi(n, i);
3246
+ }, Zt = typeof ht.validateHeaderName == "function" ? ht.validateHeaderName : (i) => {
3247
+ if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(i)) {
3248
+ const n = new TypeError(`Header name must be a valid HTTP token [${i}]`);
3249
+ throw Object.defineProperty(n, "code", { value: "ERR_INVALID_HTTP_TOKEN" }), n;
3250
+ }
3251
+ }, Kr = typeof ht.validateHeaderValue == "function" ? ht.validateHeaderValue : (i, n) => {
3252
+ if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(n)) {
3253
+ const a = new TypeError(`Invalid character in header content ["${i}"]`);
3254
+ throw Object.defineProperty(a, "code", { value: "ERR_INVALID_CHAR" }), a;
3255
+ }
3256
+ };
3257
+ class ye extends URLSearchParams {
3258
+ /**
3259
+ * Headers class
3260
+ *
3261
+ * @constructor
3262
+ * @param {HeadersInit} [init] - Response headers
3263
+ */
3264
+ constructor(n) {
3265
+ let a = [];
3266
+ if (n instanceof ye) {
3267
+ const u = n.raw();
3268
+ for (const [l, h] of Object.entries(u))
3269
+ a.push(...h.map((c) => [l, c]));
3270
+ } else if (n != null)
3271
+ if (typeof n == "object" && !Xt.isBoxedPrimitive(n)) {
3272
+ const u = n[Symbol.iterator];
3273
+ if (u == null)
3274
+ a.push(...Object.entries(n));
3275
+ else {
3276
+ if (typeof u != "function")
3277
+ throw new TypeError("Header pairs must be iterable");
3278
+ a = [...n].map((l) => {
3279
+ if (typeof l != "object" || Xt.isBoxedPrimitive(l))
3280
+ throw new TypeError("Each header pair must be an iterable object");
3281
+ return [...l];
3282
+ }).map((l) => {
3283
+ if (l.length !== 2)
3284
+ throw new TypeError("Each header pair must be a name/value tuple");
3285
+ return [...l];
3286
+ });
3287
+ }
3288
+ } else
3289
+ throw new TypeError("Failed to construct 'Headers': The provided value is not of type '(sequence<sequence<ByteString>> or record<ByteString, ByteString>)");
3290
+ return a = a.length > 0 ? a.map(([u, l]) => (Zt(u), Kr(u, String(l)), [String(u).toLowerCase(), String(l)])) : void 0, super(a), new Proxy(this, {
3291
+ get(u, l, h) {
3292
+ switch (l) {
3293
+ case "append":
3294
+ case "set":
3295
+ return (c, T) => (Zt(c), Kr(c, String(T)), URLSearchParams.prototype[l].call(
3296
+ u,
3297
+ String(c).toLowerCase(),
3298
+ String(T)
3299
+ ));
3300
+ case "delete":
3301
+ case "has":
3302
+ case "getAll":
3303
+ return (c) => (Zt(c), URLSearchParams.prototype[l].call(
3304
+ u,
3305
+ String(c).toLowerCase()
3306
+ ));
3307
+ case "keys":
3308
+ return () => (u.sort(), new Set(URLSearchParams.prototype.keys.call(u)).keys());
3309
+ default:
3310
+ return Reflect.get(u, l, h);
3311
+ }
3312
+ }
3313
+ });
3314
+ }
3315
+ get [Symbol.toStringTag]() {
3316
+ return this.constructor.name;
3317
+ }
3318
+ toString() {
3319
+ return Object.prototype.toString.call(this);
3320
+ }
3321
+ get(n) {
3322
+ const a = this.getAll(n);
3323
+ if (a.length === 0)
3324
+ return null;
3325
+ let u = a.join(", ");
3326
+ return /^content-encoding$/i.test(n) && (u = u.toLowerCase()), u;
3327
+ }
3328
+ forEach(n, a = void 0) {
3329
+ for (const u of this.keys())
3330
+ Reflect.apply(n, a, [this.get(u), u, this]);
3331
+ }
3332
+ *values() {
3333
+ for (const n of this.keys())
3334
+ yield this.get(n);
3335
+ }
3336
+ /**
3337
+ * @type {() => IterableIterator<[string, string]>}
3338
+ */
3339
+ *entries() {
3340
+ for (const n of this.keys())
3341
+ yield [n, this.get(n)];
3342
+ }
3343
+ [Symbol.iterator]() {
3344
+ return this.entries();
3345
+ }
3346
+ /**
3347
+ * Node-fetch non-spec method
3348
+ * returning all headers and their values as array
3349
+ * @returns {Record<string, string[]>}
3350
+ */
3351
+ raw() {
3352
+ return [...this.keys()].reduce((n, a) => (n[a] = this.getAll(a), n), {});
3353
+ }
3354
+ /**
3355
+ * For better console.log(headers) and also to convert Headers into Node.js Request compatible format
3356
+ */
3357
+ [Symbol.for("nodejs.util.inspect.custom")]() {
3358
+ return [...this.keys()].reduce((n, a) => {
3359
+ const u = this.getAll(a);
3360
+ return a === "host" ? n[a] = u[0] : n[a] = u.length > 1 ? u : u[0], n;
3361
+ }, {});
3362
+ }
3363
+ }
3364
+ Object.defineProperties(
3365
+ ye.prototype,
3366
+ ["get", "entries", "forEach", "values"].reduce((i, n) => (i[n] = { enumerable: !0 }, i), {})
3367
+ );
3368
+ function Ji(i = []) {
3369
+ return new ye(
3370
+ i.reduce((n, a, u, l) => (u % 2 === 0 && n.push(l.slice(u, u + 2)), n), []).filter(([n, a]) => {
3371
+ try {
3372
+ return Zt(n), Kr(n, String(a)), !0;
3373
+ } catch {
3374
+ return !1;
3375
+ }
3376
+ })
3377
+ );
3378
+ }
3379
+ const Zi = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]), ko = (i) => Zi.has(i), re = Symbol("Response internals");
3380
+ class V extends mt {
3381
+ constructor(n = null, a = {}) {
3382
+ super(n, a);
3383
+ const u = a.status != null ? a.status : 200, l = new ye(a.headers);
3384
+ if (n !== null && !l.has("Content-Type")) {
3385
+ const h = Wo(n, this);
3386
+ h && l.append("Content-Type", h);
3387
+ }
3388
+ this[re] = {
3389
+ type: "default",
3390
+ url: a.url,
3391
+ status: u,
3392
+ statusText: a.statusText || "",
3393
+ headers: l,
3394
+ counter: a.counter,
3395
+ highWaterMark: a.highWaterMark
3396
+ };
3397
+ }
3398
+ get type() {
3399
+ return this[re].type;
3400
+ }
3401
+ get url() {
3402
+ return this[re].url || "";
3403
+ }
3404
+ get status() {
3405
+ return this[re].status;
3406
+ }
3407
+ /**
3408
+ * Convenience property representing if the request ended normally
3409
+ */
3410
+ get ok() {
3411
+ return this[re].status >= 200 && this[re].status < 300;
3412
+ }
3413
+ get redirected() {
3414
+ return this[re].counter > 0;
3415
+ }
3416
+ get statusText() {
3417
+ return this[re].statusText;
3418
+ }
3419
+ get headers() {
3420
+ return this[re].headers;
3421
+ }
3422
+ get highWaterMark() {
3423
+ return this[re].highWaterMark;
3424
+ }
3425
+ /**
3426
+ * Clone this response
3427
+ *
3428
+ * @return Response
3429
+ */
3430
+ clone() {
3431
+ return new V(Xr(this, this.highWaterMark), {
3432
+ type: this.type,
3433
+ url: this.url,
3434
+ status: this.status,
3435
+ statusText: this.statusText,
3436
+ headers: this.headers,
3437
+ ok: this.ok,
3438
+ redirected: this.redirected,
3439
+ size: this.size,
3440
+ highWaterMark: this.highWaterMark
3441
+ });
3442
+ }
3443
+ /**
3444
+ * @param {string} url The URL that the new response is to originate from.
3445
+ * @param {number} status An optional status code for the response (e.g., 302.)
3446
+ * @returns {Response} A Response object.
3447
+ */
3448
+ static redirect(n, a = 302) {
3449
+ if (!ko(a))
3450
+ throw new RangeError('Failed to execute "redirect" on "response": Invalid status code');
3451
+ return new V(null, {
3452
+ headers: {
3453
+ location: new URL(n).toString()
3454
+ },
3455
+ status: a
3456
+ });
3457
+ }
3458
+ static error() {
3459
+ const n = new V(null, { status: 0, statusText: "" });
3460
+ return n[re].type = "error", n;
3461
+ }
3462
+ static json(n = void 0, a = {}) {
3463
+ const u = JSON.stringify(n);
3464
+ if (u === void 0)
3465
+ throw new TypeError("data is not JSON serializable");
3466
+ const l = new ye(a && a.headers);
3467
+ return l.has("content-type") || l.set("content-type", "application/json"), new V(u, {
3468
+ ...a,
3469
+ headers: l
3470
+ });
3471
+ }
3472
+ get [Symbol.toStringTag]() {
3473
+ return "Response";
3474
+ }
3475
+ }
3476
+ Object.defineProperties(V.prototype, {
3477
+ type: { enumerable: !0 },
3478
+ url: { enumerable: !0 },
3479
+ status: { enumerable: !0 },
3480
+ ok: { enumerable: !0 },
3481
+ redirected: { enumerable: !0 },
3482
+ statusText: { enumerable: !0 },
3483
+ headers: { enumerable: !0 },
3484
+ clone: { enumerable: !0 }
3485
+ });
3486
+ const Ki = (i) => {
3487
+ if (i.search)
3488
+ return i.search;
3489
+ const n = i.href.length - 1, a = i.hash || (i.href[n] === "#" ? "#" : "");
3490
+ return i.href[n - a.length] === "?" ? "?" : "";
3491
+ };
3492
+ function Po(i, n = !1) {
3493
+ return i == null || (i = new URL(i), /^(about|blob|data):$/.test(i.protocol)) ? "no-referrer" : (i.username = "", i.password = "", i.hash = "", n && (i.pathname = "", i.search = ""), i);
3494
+ }
3495
+ const qo = /* @__PURE__ */ new Set([
3496
+ "",
3497
+ "no-referrer",
3498
+ "no-referrer-when-downgrade",
3499
+ "same-origin",
3500
+ "origin",
3501
+ "strict-origin",
3502
+ "origin-when-cross-origin",
3503
+ "strict-origin-when-cross-origin",
3504
+ "unsafe-url"
3505
+ ]), Xi = "strict-origin-when-cross-origin";
3506
+ function es(i) {
3507
+ if (!qo.has(i))
3508
+ throw new TypeError(`Invalid referrerPolicy: ${i}`);
3509
+ return i;
3510
+ }
3511
+ function ts(i) {
3512
+ if (/^(http|ws)s:$/.test(i.protocol))
3513
+ return !0;
3514
+ const n = i.host.replace(/(^\[)|(]$)/g, ""), a = Ai(n);
3515
+ return a === 4 && /^127\./.test(n) || a === 6 && /^(((0+:){7})|(::(0+:){0,6}))0*1$/.test(n) ? !0 : i.host === "localhost" || i.host.endsWith(".localhost") ? !1 : i.protocol === "file:";
3516
+ }
3517
+ function Ke(i) {
3518
+ return /^about:(blank|srcdoc)$/.test(i) || i.protocol === "data:" || /^(blob|filesystem):$/.test(i.protocol) ? !0 : ts(i);
3519
+ }
3520
+ function rs(i, { referrerURLCallback: n, referrerOriginCallback: a } = {}) {
3521
+ if (i.referrer === "no-referrer" || i.referrerPolicy === "")
3522
+ return null;
3523
+ const u = i.referrerPolicy;
3524
+ if (i.referrer === "about:client")
3525
+ return "no-referrer";
3526
+ const l = i.referrer;
3527
+ let h = Po(l), c = Po(l, !0);
3528
+ h.toString().length > 4096 && (h = c), n && (h = n(h)), a && (c = a(c));
3529
+ const T = new URL(i.url);
3530
+ switch (u) {
3531
+ case "no-referrer":
3532
+ return "no-referrer";
3533
+ case "origin":
3534
+ return c;
3535
+ case "unsafe-url":
3536
+ return h;
3537
+ case "strict-origin":
3538
+ return Ke(h) && !Ke(T) ? "no-referrer" : c.toString();
3539
+ case "strict-origin-when-cross-origin":
3540
+ return h.origin === T.origin ? h : Ke(h) && !Ke(T) ? "no-referrer" : c;
3541
+ case "same-origin":
3542
+ return h.origin === T.origin ? h : "no-referrer";
3543
+ case "origin-when-cross-origin":
3544
+ return h.origin === T.origin ? h : c;
3545
+ case "no-referrer-when-downgrade":
3546
+ return Ke(h) && !Ke(T) ? "no-referrer" : h;
3547
+ default:
3548
+ throw new TypeError(`Invalid referrerPolicy: ${u}`);
3549
+ }
3550
+ }
3551
+ function ns(i) {
3552
+ const n = (i.get("referrer-policy") || "").split(/[,\s]+/);
3553
+ let a = "";
3554
+ for (const u of n)
3555
+ u && qo.has(u) && (a = u);
3556
+ return a;
3557
+ }
3558
+ const I = Symbol("Request internals"), dt = (i) => typeof i == "object" && typeof i[I] == "object", os = or(
3559
+ () => {
3560
+ },
3561
+ ".data is not a valid RequestInit property, use .body instead",
3562
+ "https://github.com/node-fetch/node-fetch/issues/1000 (request)"
3563
+ );
3564
+ class bt extends mt {
3565
+ constructor(n, a = {}) {
3566
+ let u;
3567
+ if (dt(n) ? u = new URL(n.url) : (u = new URL(n), n = {}), u.username !== "" || u.password !== "")
3568
+ throw new TypeError(`${u} is an url with embedded credentials.`);
3569
+ let l = a.method || n.method || "GET";
3570
+ if (/^(delete|get|head|options|post|put)$/i.test(l) && (l = l.toUpperCase()), !dt(a) && "data" in a && os(), (a.body != null || dt(n) && n.body !== null) && (l === "GET" || l === "HEAD"))
3571
+ throw new TypeError("Request with GET/HEAD method cannot have body");
3572
+ const h = a.body ? a.body : dt(n) && n.body !== null ? Xr(n) : null;
3573
+ super(h, {
3574
+ size: a.size || n.size || 0
3575
+ });
3576
+ const c = new ye(a.headers || n.headers || {});
3577
+ if (h !== null && !c.has("Content-Type")) {
3578
+ const _ = Wo(h, this);
3579
+ _ && c.set("Content-Type", _);
3580
+ }
3581
+ let T = dt(n) ? n.signal : null;
3582
+ if ("signal" in a && (T = a.signal), T != null && !xi(T))
3583
+ throw new TypeError("Expected signal to be an instanceof AbortSignal or EventTarget");
3584
+ let v = a.referrer == null ? n.referrer : a.referrer;
3585
+ if (v === "")
3586
+ v = "no-referrer";
3587
+ else if (v) {
3588
+ const _ = new URL(v);
3589
+ v = /^about:(\/\/)?client$/.test(_) ? "client" : _;
3590
+ } else
3591
+ v = void 0;
3592
+ this[I] = {
3593
+ method: l,
3594
+ redirect: a.redirect || n.redirect || "follow",
3595
+ headers: c,
3596
+ parsedURL: u,
3597
+ signal: T,
3598
+ referrer: v
3599
+ }, this.follow = a.follow === void 0 ? n.follow === void 0 ? 20 : n.follow : a.follow, this.compress = a.compress === void 0 ? n.compress === void 0 ? !0 : n.compress : a.compress, this.counter = a.counter || n.counter || 0, this.agent = a.agent || n.agent, this.highWaterMark = a.highWaterMark || n.highWaterMark || 16384, this.insecureHTTPParser = a.insecureHTTPParser || n.insecureHTTPParser || !1, this.referrerPolicy = a.referrerPolicy || n.referrerPolicy || "";
3600
+ }
3601
+ /** @returns {string} */
3602
+ get method() {
3603
+ return this[I].method;
3604
+ }
3605
+ /** @returns {string} */
3606
+ get url() {
3607
+ return Ei(this[I].parsedURL);
3608
+ }
3609
+ /** @returns {Headers} */
3610
+ get headers() {
3611
+ return this[I].headers;
3612
+ }
3613
+ get redirect() {
3614
+ return this[I].redirect;
3615
+ }
3616
+ /** @returns {AbortSignal} */
3617
+ get signal() {
3618
+ return this[I].signal;
3619
+ }
3620
+ // https://fetch.spec.whatwg.org/#dom-request-referrer
3621
+ get referrer() {
3622
+ if (this[I].referrer === "no-referrer")
3623
+ return "";
3624
+ if (this[I].referrer === "client")
3625
+ return "about:client";
3626
+ if (this[I].referrer)
3627
+ return this[I].referrer.toString();
3628
+ }
3629
+ get referrerPolicy() {
3630
+ return this[I].referrerPolicy;
3631
+ }
3632
+ set referrerPolicy(n) {
3633
+ this[I].referrerPolicy = es(n);
3634
+ }
3635
+ /**
3636
+ * Clone this request
3637
+ *
3638
+ * @return Request
3639
+ */
3640
+ clone() {
3641
+ return new bt(this);
3642
+ }
3643
+ get [Symbol.toStringTag]() {
3644
+ return "Request";
3645
+ }
3646
+ }
3647
+ Object.defineProperties(bt.prototype, {
3648
+ method: { enumerable: !0 },
3649
+ url: { enumerable: !0 },
3650
+ headers: { enumerable: !0 },
3651
+ redirect: { enumerable: !0 },
3652
+ clone: { enumerable: !0 },
3653
+ signal: { enumerable: !0 },
3654
+ referrer: { enumerable: !0 },
3655
+ referrerPolicy: { enumerable: !0 }
3656
+ });
3657
+ const as = (i) => {
3658
+ const { parsedURL: n } = i[I], a = new ye(i[I].headers);
3659
+ a.has("Accept") || a.set("Accept", "*/*");
3660
+ let u = null;
3661
+ if (i.body === null && /^(post|put)$/i.test(i.method) && (u = "0"), i.body !== null) {
3662
+ const T = Yi(i);
3663
+ typeof T == "number" && !Number.isNaN(T) && (u = String(T));
3664
+ }
3665
+ u && a.set("Content-Length", u), i.referrerPolicy === "" && (i.referrerPolicy = Xi), i.referrer && i.referrer !== "no-referrer" ? i[I].referrer = rs(i) : i[I].referrer = "no-referrer", i[I].referrer instanceof URL && a.set("Referer", i.referrer), a.has("User-Agent") || a.set("User-Agent", "node-fetch"), i.compress && !a.has("Accept-Encoding") && a.set("Accept-Encoding", "gzip, deflate, br");
3666
+ let { agent: l } = i;
3667
+ typeof l == "function" && (l = l(n));
3668
+ const h = Ki(n), c = {
3669
+ // Overwrite search to retain trailing ? (issue #776)
3670
+ path: n.pathname + h,
3671
+ // The following options are not expressed in the URL
3672
+ method: i.method,
3673
+ headers: a[Symbol.for("nodejs.util.inspect.custom")](),
3674
+ insecureHTTPParser: i.insecureHTTPParser,
3675
+ agent: l
3676
+ };
3677
+ return {
3678
+ /** @type {URL} */
3679
+ parsedURL: n,
3680
+ options: c
3681
+ };
3682
+ };
3683
+ class is extends ar {
3684
+ constructor(n, a = "aborted") {
3685
+ super(n, a);
3686
+ }
3687
+ }
3688
+ /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
3689
+ if (!globalThis.DOMException)
3690
+ try {
3691
+ const { MessageChannel: i } = require("worker_threads"), n = new i().port1, a = new ArrayBuffer();
3692
+ n.postMessage(a, [a, a]);
3693
+ } catch (i) {
3694
+ i.constructor.name === "DOMException" && (globalThis.DOMException = i.constructor);
3695
+ }
3696
+ const ss = /* @__PURE__ */ new Set(["data:", "http:", "https:"]);
3697
+ async function Oo(i, n) {
3698
+ return new Promise((a, u) => {
3699
+ const l = new bt(i, n), { parsedURL: h, options: c } = as(l);
3700
+ if (!ss.has(h.protocol))
3701
+ throw new TypeError(`node-fetch cannot load ${i}. URL scheme "${h.protocol.replace(/:$/, "")}" is not supported.`);
3702
+ if (h.protocol === "data:") {
3703
+ const p = Oi(l.url), j = new V(p, { headers: { "Content-Type": p.typeFull } });
3704
+ a(j);
3705
+ return;
3706
+ }
3707
+ const T = (h.protocol === "https:" ? Pi : ht).request, { signal: v } = l;
3708
+ let _ = null;
3709
+ const E = () => {
3710
+ const p = new is("The operation was aborted.");
3711
+ u(p), l.body && l.body instanceof se.Readable && l.body.destroy(p), !(!_ || !_.body) && _.body.emit("error", p);
3712
+ };
3713
+ if (v && v.aborted) {
3714
+ E();
3715
+ return;
3716
+ }
3717
+ const w = () => {
3718
+ E(), W();
3719
+ }, m = T(h.toString(), c);
3720
+ v && v.addEventListener("abort", w);
3721
+ const W = () => {
3722
+ m.abort(), v && v.removeEventListener("abort", w);
3723
+ };
3724
+ m.on("error", (p) => {
3725
+ u(new ie(`request to ${l.url} failed, reason: ${p.message}`, "system", p)), W();
3726
+ }), ls(m, (p) => {
3727
+ _ && _.body && _.body.destroy(p);
3728
+ }), process.version < "v14" && m.on("socket", (p) => {
3729
+ let j;
3730
+ p.prependListener("end", () => {
3731
+ j = p._eventsCount;
3732
+ }), p.prependListener("close", (R) => {
3733
+ if (_ && j < p._eventsCount && !R) {
3734
+ const B = new Error("Premature close");
3735
+ B.code = "ERR_STREAM_PREMATURE_CLOSE", _.body.emit("error", B);
3736
+ }
3737
+ });
3738
+ }), m.on("response", (p) => {
3739
+ m.setTimeout(0);
3740
+ const j = Ji(p.rawHeaders);
3741
+ if (ko(p.statusCode)) {
3742
+ const O = j.get("Location");
3743
+ let z = null;
3744
+ try {
3745
+ z = O === null ? null : new URL(O, l.url);
3746
+ } catch {
3747
+ if (l.redirect !== "manual") {
3748
+ u(new ie(`uri requested responds with an invalid redirect URL: ${O}`, "invalid-redirect")), W();
3749
+ return;
3750
+ }
3751
+ }
3752
+ switch (l.redirect) {
3753
+ case "error":
3754
+ u(new ie(`uri requested responds with a redirect, redirect mode is set to error: ${l.url}`, "no-redirect")), W();
3755
+ return;
3756
+ case "manual":
3757
+ break;
3758
+ case "follow": {
3759
+ if (z === null)
3760
+ break;
3761
+ if (l.counter >= l.follow) {
3762
+ u(new ie(`maximum redirect reached at: ${l.url}`, "max-redirect")), W();
3763
+ return;
3764
+ }
3765
+ const M = {
3766
+ headers: new ye(l.headers),
3767
+ follow: l.follow,
3768
+ counter: l.counter + 1,
3769
+ agent: l.agent,
3770
+ compress: l.compress,
3771
+ method: l.method,
3772
+ body: Xr(l),
3773
+ signal: l.signal,
3774
+ size: l.size,
3775
+ referrer: l.referrer,
3776
+ referrerPolicy: l.referrerPolicy
3777
+ };
3778
+ if (!Ni(l.url, z) || !Hi(l.url, z))
3779
+ for (const _t of ["authorization", "www-authenticate", "cookie", "cookie2"])
3780
+ M.headers.delete(_t);
3781
+ if (p.statusCode !== 303 && l.body && n.body instanceof se.Readable) {
3782
+ u(new ie("Cannot follow redirect with body being a readable stream", "unsupported-redirect")), W();
3783
+ return;
3784
+ }
3785
+ (p.statusCode === 303 || (p.statusCode === 301 || p.statusCode === 302) && l.method === "POST") && (M.method = "GET", M.body = void 0, M.headers.delete("content-length"));
3786
+ const U = ns(j);
3787
+ U && (M.referrerPolicy = U), a(Oo(new bt(z, M))), W();
3788
+ return;
3789
+ }
3790
+ default:
3791
+ return u(new TypeError(`Redirect option '${l.redirect}' is not a valid value of RequestRedirect`));
3792
+ }
3793
+ }
3794
+ v && p.once("end", () => {
3795
+ v.removeEventListener("abort", w);
3796
+ });
3797
+ let R = Ze(p, new Kt(), (O) => {
3798
+ O && u(O);
3799
+ });
3800
+ process.version < "v12.10" && p.on("aborted", w);
3801
+ const B = {
3802
+ url: l.url,
3803
+ status: p.statusCode,
3804
+ statusText: p.statusMessage,
3805
+ headers: j,
3806
+ size: l.size,
3807
+ counter: l.counter,
3808
+ highWaterMark: l.highWaterMark
3809
+ }, L = j.get("Content-Encoding");
3810
+ if (!l.compress || l.method === "HEAD" || L === null || p.statusCode === 204 || p.statusCode === 304) {
3811
+ _ = new V(R, B), a(_);
3812
+ return;
3813
+ }
3814
+ const Y = {
3815
+ flush: Je.Z_SYNC_FLUSH,
3816
+ finishFlush: Je.Z_SYNC_FLUSH
3817
+ };
3818
+ if (L === "gzip" || L === "x-gzip") {
3819
+ R = Ze(R, Je.createGunzip(Y), (O) => {
3820
+ O && u(O);
3821
+ }), _ = new V(R, B), a(_);
3822
+ return;
3823
+ }
3824
+ if (L === "deflate" || L === "x-deflate") {
3825
+ const O = Ze(p, new Kt(), (z) => {
3826
+ z && u(z);
3827
+ });
3828
+ O.once("data", (z) => {
3829
+ (z[0] & 15) === 8 ? R = Ze(R, Je.createInflate(), (M) => {
3830
+ M && u(M);
3831
+ }) : R = Ze(R, Je.createInflateRaw(), (M) => {
3832
+ M && u(M);
3833
+ }), _ = new V(R, B), a(_);
3834
+ }), O.once("end", () => {
3835
+ _ || (_ = new V(R, B), a(_));
3836
+ });
3837
+ return;
3838
+ }
3839
+ if (L === "br") {
3840
+ R = Ze(R, Je.createBrotliDecompress(), (O) => {
3841
+ O && u(O);
3842
+ }), _ = new V(R, B), a(_);
3843
+ return;
3844
+ }
3845
+ _ = new V(R, B), a(_);
3846
+ }), Gi(m, l).catch(u);
3847
+ });
3848
+ }
3849
+ function ls(i, n) {
3850
+ const a = $.from(`0\r
3851
+ \r
3852
+ `);
3853
+ let u = !1, l = !1, h;
3854
+ i.on("response", (c) => {
3855
+ const { headers: T } = c;
3856
+ u = T["transfer-encoding"] === "chunked" && !T["content-length"];
3857
+ }), i.on("socket", (c) => {
3858
+ const T = () => {
3859
+ if (u && !l) {
3860
+ const _ = new Error("Premature close");
3861
+ _.code = "ERR_STREAM_PREMATURE_CLOSE", n(_);
3862
+ }
3863
+ }, v = (_) => {
3864
+ l = $.compare(_.slice(-5), a) === 0, !l && h && (l = $.compare(h.slice(-3), a.slice(0, 3)) === 0 && $.compare(_.slice(-2), a.slice(3)) === 0), h = _;
3865
+ };
3866
+ c.prependListener("close", T), c.on("data", v), i.on("close", () => {
3867
+ c.removeListener("close", T), c.removeListener("data", v);
3868
+ });
3869
+ });
3870
+ }
3871
+ const us = "@feedmepos/mf-", Ps = async (i, { command: n, mode: a }, u = {}) => {
3872
+ var m, W, p, j;
3873
+ const l = JSON.parse(
3874
+ Ti(So(process.cwd(), "package.json"), "utf-8")
3875
+ ), h = Object.keys(l.dependencies).filter((R) => R.startsWith(us)).reduce((R, B) => (R[B] = l.dependencies[B], R), {});
3876
+ (m = u.includeFmmfPackages) == null || m.forEach((R) => {
3877
+ h[R] = l.dependencies[R] ?? "latest";
3878
+ }), (W = u.excludeFmmfPackages) == null || W.forEach((R) => {
3879
+ delete h[R];
3880
+ });
3881
+ const c = {
3882
+ "@vue/devtools-api": "6.5.0/lib/esm/index.js",
3883
+ vue: "3.4.27/dist/vue.esm-browser.prod.min.js",
3884
+ "vue-router": "4.2.5/dist/vue-router.esm-browser.min.js",
3885
+ pinia: "2.1.7/+esm"
3886
+ };
3887
+ let T = [...Object.keys(c), ...Object.keys(h)];
3888
+ const v = { ...i };
3889
+ n == "build" && a.startsWith("fmmf") && (T = [...Object.keys(h), ...Object.keys(c)], v.build = {
3890
+ emptyOutDir: !0,
3891
+ lib: {
3892
+ entry: {
3893
+ app: So(process.cwd(), "src/app.ts")
3894
+ },
3895
+ formats: ["es"]
3896
+ },
3897
+ rollupOptions: {
3898
+ external: T
3899
+ }
3900
+ }), v.plugins ?? (v.plugins = []), v.plugins.push(qi({ externals: T })), v.build ?? (v.build = {}), (p = v.build).rollupOptions ?? (p.rollupOptions = {}), (j = v.build.rollupOptions).external ?? (j.external = T);
3901
+ const _ = h;
3902
+ await Promise.all(
3903
+ Object.keys(_).map(async (R) => {
3904
+ let B = "latest";
3905
+ const L = u.isDev;
3906
+ if (console.log("Use beta", L), L) {
3907
+ const Y = await Oo(`https://cdn.jsdelivr.net/npm/${R}@beta/dist/app.js`).then((O) => O.ok).catch(() => !1);
3908
+ console.log(`Package ${R} has beta: ${Y}`), Y && (B = "beta");
3909
+ }
3910
+ return _[R] = `https://cdn.jsdelivr.net/npm/${R}@${B}/dist/app.js`;
3911
+ })
3912
+ );
3913
+ const E = {
3914
+ imports: {
3915
+ ..._,
3916
+ ...Object.keys(c).reduce((R, B) => (R[B] = `https://cdn.jsdelivr.net/npm/${B}@${c[B]}`, R), {})
3917
+ },
3918
+ scopes: u.importMapScopes ?? {}
3919
+ };
3920
+ u.replaceFmmfPackages && Object.entries(u.replaceFmmfPackages).forEach(([R, B]) => {
3921
+ if (R.startsWith("@feedmepos/mf-") || R === "@feedmepos/ui-library")
3922
+ E.imports[R] = B;
3923
+ else
3924
+ throw new Error(`Invalid replaceFmmfPackages key: ${R}, must start with @feedmepos/mf-`);
3925
+ });
3926
+ const w = {
3927
+ name: "vite-plugin-feedme-microfrontend",
3928
+ enforce: "pre",
3929
+ config: async () => {
3930
+ },
3931
+ transformIndexHtml: {
3932
+ enforce: "pre",
3933
+ transform(R) {
3934
+ return {
3935
+ html: R,
3936
+ tags: [
3937
+ {
3938
+ tag: "script",
3939
+ attrs: {
3940
+ type: "importmap"
3941
+ },
3942
+ children: JSON.stringify(E, null, 2),
3943
+ injectTo: "head-prepend"
3944
+ },
3945
+ {
3946
+ tag: "script",
3947
+ attrs: {
3948
+ src: "https://cdn.jsdelivr.net/npm/es-module-shims@1.8.0/dist/es-module-shims.min.js"
3949
+ },
3950
+ injectTo: "head-prepend"
3951
+ }
3952
+ ]
3953
+ };
3954
+ }
3955
+ }
3956
+ };
3957
+ return v.plugins.push(w), v;
3958
+ };
3959
+ export {
3960
+ Zr as F,
3961
+ Li as a,
3962
+ Ps as f
3963
+ };