@smapiot/piral-cloud-node 0.18.0 → 1.13.0-pre.20240129.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.
@@ -1,9 +1,26 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
8
  var __getProtoOf = Object.getPrototypeOf;
6
9
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
7
24
  var __esm = (fn, res) => function __init() {
8
25
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
26
  };
@@ -22,33 +39,12 @@ var __copyProps = (to, from, except, desc) => {
22
39
  }
23
40
  return to;
24
41
  };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
42
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
29
43
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var __accessCheck = (obj, member, msg) => {
31
- if (!member.has(obj))
32
- throw TypeError("Cannot " + msg);
33
- };
34
- var __privateGet = (obj, member, getter) => {
35
- __accessCheck(obj, member, "read from private field");
36
- return getter ? getter.call(obj) : member.get(obj);
37
- };
38
- var __privateAdd = (obj, member, value) => {
39
- if (member.has(obj))
40
- throw TypeError("Cannot add the same private member more than once");
41
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
42
- };
43
- var __privateSet = (obj, member, value, setter) => {
44
- __accessCheck(obj, member, "write to private field");
45
- setter ? setter.call(obj, value) : member.set(obj, value);
46
- return value;
47
- };
48
44
 
49
- // ../../node_modules/web-streams-polyfill/dist/ponyfill.es2018.js
45
+ // ../../../node_modules/web-streams-polyfill/dist/ponyfill.es2018.js
50
46
  var require_ponyfill_es2018 = __commonJS({
51
- "../../node_modules/web-streams-polyfill/dist/ponyfill.es2018.js"(exports, module2) {
47
+ "../../../node_modules/web-streams-polyfill/dist/ponyfill.es2018.js"(exports, module2) {
52
48
  (function(global2, factory) {
53
49
  typeof exports === "object" && typeof module2 !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory(global2.WebStreamsPolyfill = {}));
54
50
  })(exports, function(exports2) {
@@ -57,30 +53,27 @@ var require_ponyfill_es2018 = __commonJS({
57
53
  function noop2() {
58
54
  return void 0;
59
55
  }
60
- function getGlobals() {
61
- if (typeof self !== "undefined") {
62
- return self;
63
- } else if (typeof window !== "undefined") {
64
- return window;
65
- } else if (typeof global !== "undefined") {
66
- return global;
67
- }
68
- return void 0;
69
- }
70
- const globals = getGlobals();
71
56
  function typeIsObject(x2) {
72
57
  return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
73
58
  }
74
59
  const rethrowAssertionErrorRejection = noop2;
60
+ function setFunctionName(fn, name) {
61
+ try {
62
+ Object.defineProperty(fn, "name", {
63
+ value: name,
64
+ configurable: true
65
+ });
66
+ } catch (_a) {
67
+ }
68
+ }
75
69
  const originalPromise = Promise;
76
70
  const originalPromiseThen = Promise.prototype.then;
77
- const originalPromiseResolve = Promise.resolve.bind(originalPromise);
78
71
  const originalPromiseReject = Promise.reject.bind(originalPromise);
79
72
  function newPromise(executor) {
80
73
  return new originalPromise(executor);
81
74
  }
82
75
  function promiseResolvedWith(value) {
83
- return originalPromiseResolve(value);
76
+ return newPromise((resolve) => resolve(value));
84
77
  }
85
78
  function promiseRejectedWith(reason) {
86
79
  return originalPromiseReject(reason);
@@ -103,14 +96,15 @@ var require_ponyfill_es2018 = __commonJS({
103
96
  function setPromiseIsHandledToTrue(promise) {
104
97
  PerformPromiseThen(promise, void 0, rethrowAssertionErrorRejection);
105
98
  }
106
- const queueMicrotask = (() => {
107
- const globalQueueMicrotask = globals && globals.queueMicrotask;
108
- if (typeof globalQueueMicrotask === "function") {
109
- return globalQueueMicrotask;
99
+ let _queueMicrotask = (callback) => {
100
+ if (typeof queueMicrotask === "function") {
101
+ _queueMicrotask = queueMicrotask;
102
+ } else {
103
+ const resolvedPromise = promiseResolvedWith(void 0);
104
+ _queueMicrotask = (cb) => PerformPromiseThen(resolvedPromise, cb);
110
105
  }
111
- const resolvedPromise = promiseResolvedWith(void 0);
112
- return (fn) => PerformPromiseThen(resolvedPromise, fn);
113
- })();
106
+ return _queueMicrotask(callback);
107
+ };
114
108
  function reflectCall(F2, V, args) {
115
109
  if (typeof F2 !== "function") {
116
110
  throw new TypeError("Argument is not a function");
@@ -198,6 +192,11 @@ var require_ponyfill_es2018 = __commonJS({
198
192
  return front._elements[cursor];
199
193
  }
200
194
  }
195
+ const AbortSteps = SymbolPolyfill("[[AbortSteps]]");
196
+ const ErrorSteps = SymbolPolyfill("[[ErrorSteps]]");
197
+ const CancelSteps = SymbolPolyfill("[[CancelSteps]]");
198
+ const PullSteps = SymbolPolyfill("[[PullSteps]]");
199
+ const ReleaseSteps = SymbolPolyfill("[[ReleaseSteps]]");
201
200
  function ReadableStreamReaderGenericInitialize(reader, stream) {
202
201
  reader._ownerReadableStream = stream;
203
202
  stream._reader = reader;
@@ -214,12 +213,14 @@ var require_ponyfill_es2018 = __commonJS({
214
213
  return ReadableStreamCancel(stream, reason);
215
214
  }
216
215
  function ReadableStreamReaderGenericRelease(reader) {
217
- if (reader._ownerReadableStream._state === "readable") {
216
+ const stream = reader._ownerReadableStream;
217
+ if (stream._state === "readable") {
218
218
  defaultReaderClosedPromiseReject(reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
219
219
  } else {
220
220
  defaultReaderClosedPromiseResetToRejected(reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
221
221
  }
222
- reader._ownerReadableStream._reader = void 0;
222
+ stream._readableStreamController[ReleaseSteps]();
223
+ stream._reader = void 0;
223
224
  reader._ownerReadableStream = void 0;
224
225
  }
225
226
  function readerLockException(name) {
@@ -259,10 +260,6 @@ var require_ponyfill_es2018 = __commonJS({
259
260
  reader._closedPromise_resolve = void 0;
260
261
  reader._closedPromise_reject = void 0;
261
262
  }
262
- const AbortSteps = SymbolPolyfill("[[AbortSteps]]");
263
- const ErrorSteps = SymbolPolyfill("[[ErrorSteps]]");
264
- const CancelSteps = SymbolPolyfill("[[CancelSteps]]");
265
- const PullSteps = SymbolPolyfill("[[PullSteps]]");
266
263
  const NumberIsFinite = Number.isFinite || function(x2) {
267
264
  return typeof x2 === "number" && isFinite(x2);
268
265
  };
@@ -412,10 +409,7 @@ var require_ponyfill_es2018 = __commonJS({
412
409
  if (this._ownerReadableStream === void 0) {
413
410
  return;
414
411
  }
415
- if (this._readRequests.length > 0) {
416
- throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");
417
- }
418
- ReadableStreamReaderGenericRelease(this);
412
+ ReadableStreamDefaultReaderRelease(this);
419
413
  }
420
414
  }
421
415
  Object.defineProperties(ReadableStreamDefaultReader.prototype, {
@@ -424,6 +418,9 @@ var require_ponyfill_es2018 = __commonJS({
424
418
  releaseLock: { enumerable: true },
425
419
  closed: { enumerable: true }
426
420
  });
421
+ setFunctionName(ReadableStreamDefaultReader.prototype.cancel, "cancel");
422
+ setFunctionName(ReadableStreamDefaultReader.prototype.read, "read");
423
+ setFunctionName(ReadableStreamDefaultReader.prototype.releaseLock, "releaseLock");
427
424
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
428
425
  Object.defineProperty(ReadableStreamDefaultReader.prototype, SymbolPolyfill.toStringTag, {
429
426
  value: "ReadableStreamDefaultReader",
@@ -450,6 +447,18 @@ var require_ponyfill_es2018 = __commonJS({
450
447
  stream._readableStreamController[PullSteps](readRequest);
451
448
  }
452
449
  }
450
+ function ReadableStreamDefaultReaderRelease(reader) {
451
+ ReadableStreamReaderGenericRelease(reader);
452
+ const e2 = new TypeError("Reader was released");
453
+ ReadableStreamDefaultReaderErrorReadRequests(reader, e2);
454
+ }
455
+ function ReadableStreamDefaultReaderErrorReadRequests(reader, e2) {
456
+ const readRequests = reader._readRequests;
457
+ reader._readRequests = new SimpleQueue();
458
+ readRequests.forEach((readRequest) => {
459
+ readRequest._errorSteps(e2);
460
+ });
461
+ }
453
462
  function defaultReaderBrandCheckException(name) {
454
463
  return new TypeError(`ReadableStreamDefaultReader.prototype.${name} can only be used on a ReadableStreamDefaultReader`);
455
464
  }
@@ -476,9 +485,6 @@ var require_ponyfill_es2018 = __commonJS({
476
485
  return Promise.resolve({ value: void 0, done: true });
477
486
  }
478
487
  const reader = this._reader;
479
- if (reader._ownerReadableStream === void 0) {
480
- return promiseRejectedWith(readerLockException("iterate"));
481
- }
482
488
  let resolvePromise;
483
489
  let rejectPromise;
484
490
  const promise = newPromise((resolve, reject) => {
@@ -488,7 +494,7 @@ var require_ponyfill_es2018 = __commonJS({
488
494
  const readRequest = {
489
495
  _chunkSteps: (chunk) => {
490
496
  this._ongoingPromise = void 0;
491
- queueMicrotask(() => resolvePromise({ value: chunk, done: false }));
497
+ _queueMicrotask(() => resolvePromise({ value: chunk, done: false }));
492
498
  },
493
499
  _closeSteps: () => {
494
500
  this._ongoingPromise = void 0;
@@ -512,9 +518,6 @@ var require_ponyfill_es2018 = __commonJS({
512
518
  }
513
519
  this._isFinished = true;
514
520
  const reader = this._reader;
515
- if (reader._ownerReadableStream === void 0) {
516
- return promiseRejectedWith(readerLockException("finish iterating"));
517
- }
518
521
  if (!this._preventCancel) {
519
522
  const result = ReadableStreamReaderGenericCancel(reader, value);
520
523
  ReadableStreamReaderGenericRelease(reader);
@@ -557,7 +560,7 @@ var require_ponyfill_es2018 = __commonJS({
557
560
  }
558
561
  try {
559
562
  return x2._asyncIteratorImpl instanceof ReadableStreamAsyncIteratorImpl;
560
- } catch (_a4) {
563
+ } catch (_a) {
561
564
  return false;
562
565
  }
563
566
  }
@@ -573,12 +576,24 @@ var require_ponyfill_es2018 = __commonJS({
573
576
  function CopyDataBlockBytes(dest, destOffset, src, srcOffset, n) {
574
577
  new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset);
575
578
  }
576
- function TransferArrayBuffer(O) {
577
- return O;
578
- }
579
- function IsDetachedBuffer(O) {
580
- return false;
581
- }
579
+ let TransferArrayBuffer = (O) => {
580
+ if (typeof O.transfer === "function") {
581
+ TransferArrayBuffer = (buffer) => buffer.transfer();
582
+ } else if (typeof structuredClone === "function") {
583
+ TransferArrayBuffer = (buffer) => structuredClone(buffer, { transfer: [buffer] });
584
+ } else {
585
+ TransferArrayBuffer = (buffer) => buffer;
586
+ }
587
+ return TransferArrayBuffer(O);
588
+ };
589
+ let IsDetachedBuffer = (O) => {
590
+ if (typeof O.detached === "boolean") {
591
+ IsDetachedBuffer = (buffer) => buffer.detached;
592
+ } else {
593
+ IsDetachedBuffer = (buffer) => buffer.byteLength === 0;
594
+ }
595
+ return IsDetachedBuffer(O);
596
+ };
582
597
  function ArrayBufferSlice(buffer, begin, end) {
583
598
  if (buffer.slice) {
584
599
  return buffer.slice(begin, end);
@@ -588,6 +603,62 @@ var require_ponyfill_es2018 = __commonJS({
588
603
  CopyDataBlockBytes(slice, 0, buffer, begin, length);
589
604
  return slice;
590
605
  }
606
+ function GetMethod(receiver, prop) {
607
+ const func = receiver[prop];
608
+ if (func === void 0 || func === null) {
609
+ return void 0;
610
+ }
611
+ if (typeof func !== "function") {
612
+ throw new TypeError(`${String(prop)} is not a function`);
613
+ }
614
+ return func;
615
+ }
616
+ function CreateAsyncFromSyncIterator(syncIteratorRecord) {
617
+ const syncIterable = {
618
+ [SymbolPolyfill.iterator]: () => syncIteratorRecord.iterator
619
+ };
620
+ const asyncIterator = async function* () {
621
+ return yield* syncIterable;
622
+ }();
623
+ const nextMethod = asyncIterator.next;
624
+ return { iterator: asyncIterator, nextMethod, done: false };
625
+ }
626
+ function GetIterator(obj, hint = "sync", method) {
627
+ if (method === void 0) {
628
+ if (hint === "async") {
629
+ method = GetMethod(obj, SymbolPolyfill.asyncIterator);
630
+ if (method === void 0) {
631
+ const syncMethod = GetMethod(obj, SymbolPolyfill.iterator);
632
+ const syncIteratorRecord = GetIterator(obj, "sync", syncMethod);
633
+ return CreateAsyncFromSyncIterator(syncIteratorRecord);
634
+ }
635
+ } else {
636
+ method = GetMethod(obj, SymbolPolyfill.iterator);
637
+ }
638
+ }
639
+ if (method === void 0) {
640
+ throw new TypeError("The object is not iterable");
641
+ }
642
+ const iterator = reflectCall(method, obj, []);
643
+ if (!typeIsObject(iterator)) {
644
+ throw new TypeError("The iterator method must return an object");
645
+ }
646
+ const nextMethod = iterator.next;
647
+ return { iterator, nextMethod, done: false };
648
+ }
649
+ function IteratorNext(iteratorRecord) {
650
+ const result = reflectCall(iteratorRecord.nextMethod, iteratorRecord.iterator, []);
651
+ if (!typeIsObject(result)) {
652
+ throw new TypeError("The iterator.next() method must return an object");
653
+ }
654
+ return result;
655
+ }
656
+ function IteratorComplete(iterResult) {
657
+ return Boolean(iterResult.done);
658
+ }
659
+ function IteratorValue(iterResult) {
660
+ return iterResult.value;
661
+ }
591
662
  function IsNonNegativeNumber(v) {
592
663
  if (typeof v !== "number") {
593
664
  return false;
@@ -627,6 +698,18 @@ var require_ponyfill_es2018 = __commonJS({
627
698
  container._queue = new SimpleQueue();
628
699
  container._queueTotalSize = 0;
629
700
  }
701
+ function isDataViewConstructor(ctor) {
702
+ return ctor === DataView;
703
+ }
704
+ function isDataView(view) {
705
+ return isDataViewConstructor(view.constructor);
706
+ }
707
+ function arrayBufferViewElementSize(ctor) {
708
+ if (isDataViewConstructor(ctor)) {
709
+ return 1;
710
+ }
711
+ return ctor.BYTES_PER_ELEMENT;
712
+ }
630
713
  class ReadableStreamBYOBRequest {
631
714
  constructor() {
632
715
  throw new TypeError("Illegal constructor");
@@ -646,8 +729,9 @@ var require_ponyfill_es2018 = __commonJS({
646
729
  if (this._associatedReadableByteStreamController === void 0) {
647
730
  throw new TypeError("This BYOB request has been invalidated");
648
731
  }
649
- if (IsDetachedBuffer(this._view.buffer))
650
- ;
732
+ if (IsDetachedBuffer(this._view.buffer)) {
733
+ throw new TypeError(`The BYOB request's buffer has been detached and so cannot be used as a response`);
734
+ }
651
735
  ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten);
652
736
  }
653
737
  respondWithNewView(view) {
@@ -661,8 +745,9 @@ var require_ponyfill_es2018 = __commonJS({
661
745
  if (this._associatedReadableByteStreamController === void 0) {
662
746
  throw new TypeError("This BYOB request has been invalidated");
663
747
  }
664
- if (IsDetachedBuffer(view.buffer))
665
- ;
748
+ if (IsDetachedBuffer(view.buffer)) {
749
+ throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
750
+ }
666
751
  ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view);
667
752
  }
668
753
  }
@@ -671,6 +756,8 @@ var require_ponyfill_es2018 = __commonJS({
671
756
  respondWithNewView: { enumerable: true },
672
757
  view: { enumerable: true }
673
758
  });
759
+ setFunctionName(ReadableStreamBYOBRequest.prototype.respond, "respond");
760
+ setFunctionName(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView");
674
761
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
675
762
  Object.defineProperty(ReadableStreamBYOBRequest.prototype, SymbolPolyfill.toStringTag, {
676
763
  value: "ReadableStreamBYOBRequest",
@@ -745,11 +832,7 @@ var require_ponyfill_es2018 = __commonJS({
745
832
  [PullSteps](readRequest) {
746
833
  const stream = this._controlledReadableByteStream;
747
834
  if (this._queueTotalSize > 0) {
748
- const entry = this._queue.shift();
749
- this._queueTotalSize -= entry.byteLength;
750
- ReadableByteStreamControllerHandleQueueDrain(this);
751
- const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
752
- readRequest._chunkSteps(view);
835
+ ReadableByteStreamControllerFillReadRequestFromQueue(this, readRequest);
753
836
  return;
754
837
  }
755
838
  const autoAllocateChunkSize = this._autoAllocateChunkSize;
@@ -767,6 +850,7 @@ var require_ponyfill_es2018 = __commonJS({
767
850
  byteOffset: 0,
768
851
  byteLength: autoAllocateChunkSize,
769
852
  bytesFilled: 0,
853
+ minimumFill: 1,
770
854
  elementSize: 1,
771
855
  viewConstructor: Uint8Array,
772
856
  readerType: "default"
@@ -776,6 +860,14 @@ var require_ponyfill_es2018 = __commonJS({
776
860
  ReadableStreamAddReadRequest(stream, readRequest);
777
861
  ReadableByteStreamControllerCallPullIfNeeded(this);
778
862
  }
863
+ [ReleaseSteps]() {
864
+ if (this._pendingPullIntos.length > 0) {
865
+ const firstPullInto = this._pendingPullIntos.peek();
866
+ firstPullInto.readerType = "none";
867
+ this._pendingPullIntos = new SimpleQueue();
868
+ this._pendingPullIntos.push(firstPullInto);
869
+ }
870
+ }
779
871
  }
780
872
  Object.defineProperties(ReadableByteStreamController.prototype, {
781
873
  close: { enumerable: true },
@@ -784,6 +876,9 @@ var require_ponyfill_es2018 = __commonJS({
784
876
  byobRequest: { enumerable: true },
785
877
  desiredSize: { enumerable: true }
786
878
  });
879
+ setFunctionName(ReadableByteStreamController.prototype.close, "close");
880
+ setFunctionName(ReadableByteStreamController.prototype.enqueue, "enqueue");
881
+ setFunctionName(ReadableByteStreamController.prototype.error, "error");
787
882
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
788
883
  Object.defineProperty(ReadableByteStreamController.prototype, SymbolPolyfill.toStringTag, {
789
884
  value: "ReadableByteStreamController",
@@ -825,8 +920,10 @@ var require_ponyfill_es2018 = __commonJS({
825
920
  controller._pullAgain = false;
826
921
  ReadableByteStreamControllerCallPullIfNeeded(controller);
827
922
  }
923
+ return null;
828
924
  }, (e2) => {
829
925
  ReadableByteStreamControllerError(controller, e2);
926
+ return null;
830
927
  });
831
928
  }
832
929
  function ReadableByteStreamControllerClearPendingPullIntos(controller) {
@@ -854,15 +951,30 @@ var require_ponyfill_es2018 = __commonJS({
854
951
  controller._queue.push({ buffer, byteOffset, byteLength });
855
952
  controller._queueTotalSize += byteLength;
856
953
  }
954
+ function ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, buffer, byteOffset, byteLength) {
955
+ let clonedChunk;
956
+ try {
957
+ clonedChunk = ArrayBufferSlice(buffer, byteOffset, byteOffset + byteLength);
958
+ } catch (cloneE) {
959
+ ReadableByteStreamControllerError(controller, cloneE);
960
+ throw cloneE;
961
+ }
962
+ ReadableByteStreamControllerEnqueueChunkToQueue(controller, clonedChunk, 0, byteLength);
963
+ }
964
+ function ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstDescriptor) {
965
+ if (firstDescriptor.bytesFilled > 0) {
966
+ ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, firstDescriptor.buffer, firstDescriptor.byteOffset, firstDescriptor.bytesFilled);
967
+ }
968
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
969
+ }
857
970
  function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) {
858
- const elementSize = pullIntoDescriptor.elementSize;
859
- const currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize;
860
971
  const maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled);
861
972
  const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy;
862
- const maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize;
863
973
  let totalBytesToCopyRemaining = maxBytesToCopy;
864
974
  let ready = false;
865
- if (maxAlignedBytes > currentAlignedBytes) {
975
+ const remainderBytes = maxBytesFilled % pullIntoDescriptor.elementSize;
976
+ const maxAlignedBytes = maxBytesFilled - remainderBytes;
977
+ if (maxAlignedBytes >= pullIntoDescriptor.minimumFill) {
866
978
  totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled;
867
979
  ready = true;
868
980
  }
@@ -915,20 +1027,36 @@ var require_ponyfill_es2018 = __commonJS({
915
1027
  }
916
1028
  }
917
1029
  }
918
- function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest) {
919
- const stream = controller._controlledReadableByteStream;
920
- let elementSize = 1;
921
- if (view.constructor !== DataView) {
922
- elementSize = view.constructor.BYTES_PER_ELEMENT;
1030
+ function ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller) {
1031
+ const reader = controller._controlledReadableByteStream._reader;
1032
+ while (reader._readRequests.length > 0) {
1033
+ if (controller._queueTotalSize === 0) {
1034
+ return;
1035
+ }
1036
+ const readRequest = reader._readRequests.shift();
1037
+ ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest);
923
1038
  }
1039
+ }
1040
+ function ReadableByteStreamControllerPullInto(controller, view, min, readIntoRequest) {
1041
+ const stream = controller._controlledReadableByteStream;
924
1042
  const ctor = view.constructor;
925
- const buffer = TransferArrayBuffer(view.buffer);
1043
+ const elementSize = arrayBufferViewElementSize(ctor);
1044
+ const { byteOffset, byteLength } = view;
1045
+ const minimumFill = min * elementSize;
1046
+ let buffer;
1047
+ try {
1048
+ buffer = TransferArrayBuffer(view.buffer);
1049
+ } catch (e2) {
1050
+ readIntoRequest._errorSteps(e2);
1051
+ return;
1052
+ }
926
1053
  const pullIntoDescriptor = {
927
1054
  buffer,
928
1055
  bufferByteLength: buffer.byteLength,
929
- byteOffset: view.byteOffset,
930
- byteLength: view.byteLength,
1056
+ byteOffset,
1057
+ byteLength,
931
1058
  bytesFilled: 0,
1059
+ minimumFill,
932
1060
  elementSize,
933
1061
  viewConstructor: ctor,
934
1062
  readerType: "byob"
@@ -962,6 +1090,9 @@ var require_ponyfill_es2018 = __commonJS({
962
1090
  ReadableByteStreamControllerCallPullIfNeeded(controller);
963
1091
  }
964
1092
  function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) {
1093
+ if (firstDescriptor.readerType === "none") {
1094
+ ReadableByteStreamControllerShiftPendingPullInto(controller);
1095
+ }
965
1096
  const stream = controller._controlledReadableByteStream;
966
1097
  if (ReadableStreamHasBYOBReader(stream)) {
967
1098
  while (ReadableStreamGetNumReadIntoRequests(stream) > 0) {
@@ -972,15 +1103,19 @@ var require_ponyfill_es2018 = __commonJS({
972
1103
  }
973
1104
  function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) {
974
1105
  ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor);
975
- if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) {
1106
+ if (pullIntoDescriptor.readerType === "none") {
1107
+ ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, pullIntoDescriptor);
1108
+ ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller);
1109
+ return;
1110
+ }
1111
+ if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.minimumFill) {
976
1112
  return;
977
1113
  }
978
1114
  ReadableByteStreamControllerShiftPendingPullInto(controller);
979
1115
  const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize;
980
1116
  if (remainderSize > 0) {
981
1117
  const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled;
982
- const remainder = ArrayBufferSlice(pullIntoDescriptor.buffer, end - remainderSize, end);
983
- ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength);
1118
+ ReadableByteStreamControllerEnqueueClonedChunkToQueue(controller, pullIntoDescriptor.buffer, end - remainderSize, remainderSize);
984
1119
  }
985
1120
  pullIntoDescriptor.bytesFilled -= remainderSize;
986
1121
  ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor);
@@ -991,7 +1126,7 @@ var require_ponyfill_es2018 = __commonJS({
991
1126
  ReadableByteStreamControllerInvalidateBYOBRequest(controller);
992
1127
  const state = controller._controlledReadableByteStream._state;
993
1128
  if (state === "closed") {
994
- ReadableByteStreamControllerRespondInClosedState(controller);
1129
+ ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor);
995
1130
  } else {
996
1131
  ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor);
997
1132
  }
@@ -1039,7 +1174,7 @@ var require_ponyfill_es2018 = __commonJS({
1039
1174
  }
1040
1175
  if (controller._pendingPullIntos.length > 0) {
1041
1176
  const firstPendingPullInto = controller._pendingPullIntos.peek();
1042
- if (firstPendingPullInto.bytesFilled > 0) {
1177
+ if (firstPendingPullInto.bytesFilled % firstPendingPullInto.elementSize !== 0) {
1043
1178
  const e2 = new TypeError("Insufficient bytes to fill elements in the given buffer");
1044
1179
  ReadableByteStreamControllerError(controller, e2);
1045
1180
  throw e2;
@@ -1053,18 +1188,24 @@ var require_ponyfill_es2018 = __commonJS({
1053
1188
  if (controller._closeRequested || stream._state !== "readable") {
1054
1189
  return;
1055
1190
  }
1056
- const buffer = chunk.buffer;
1057
- const byteOffset = chunk.byteOffset;
1058
- const byteLength = chunk.byteLength;
1191
+ const { buffer, byteOffset, byteLength } = chunk;
1192
+ if (IsDetachedBuffer(buffer)) {
1193
+ throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
1194
+ }
1059
1195
  const transferredBuffer = TransferArrayBuffer(buffer);
1060
1196
  if (controller._pendingPullIntos.length > 0) {
1061
1197
  const firstPendingPullInto = controller._pendingPullIntos.peek();
1062
- if (IsDetachedBuffer(firstPendingPullInto.buffer))
1063
- ;
1198
+ if (IsDetachedBuffer(firstPendingPullInto.buffer)) {
1199
+ throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
1200
+ }
1201
+ ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1064
1202
  firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer);
1203
+ if (firstPendingPullInto.readerType === "none") {
1204
+ ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(controller, firstPendingPullInto);
1205
+ }
1065
1206
  }
1066
- ReadableByteStreamControllerInvalidateBYOBRequest(controller);
1067
1207
  if (ReadableStreamHasDefaultReader(stream)) {
1208
+ ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller);
1068
1209
  if (ReadableStreamGetNumReadRequests(stream) === 0) {
1069
1210
  ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength);
1070
1211
  } else {
@@ -1092,6 +1233,13 @@ var require_ponyfill_es2018 = __commonJS({
1092
1233
  ReadableByteStreamControllerClearAlgorithms(controller);
1093
1234
  ReadableStreamError(stream, e2);
1094
1235
  }
1236
+ function ReadableByteStreamControllerFillReadRequestFromQueue(controller, readRequest) {
1237
+ const entry = controller._queue.shift();
1238
+ controller._queueTotalSize -= entry.byteLength;
1239
+ ReadableByteStreamControllerHandleQueueDrain(controller);
1240
+ const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength);
1241
+ readRequest._chunkSteps(view);
1242
+ }
1095
1243
  function ReadableByteStreamControllerGetBYOBRequest(controller) {
1096
1244
  if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) {
1097
1245
  const firstDescriptor = controller._pendingPullIntos.peek();
@@ -1174,23 +1322,31 @@ var require_ponyfill_es2018 = __commonJS({
1174
1322
  uponPromise(promiseResolvedWith(startResult), () => {
1175
1323
  controller._started = true;
1176
1324
  ReadableByteStreamControllerCallPullIfNeeded(controller);
1325
+ return null;
1177
1326
  }, (r2) => {
1178
1327
  ReadableByteStreamControllerError(controller, r2);
1328
+ return null;
1179
1329
  });
1180
1330
  }
1181
1331
  function SetUpReadableByteStreamControllerFromUnderlyingSource(stream, underlyingByteSource, highWaterMark) {
1182
1332
  const controller = Object.create(ReadableByteStreamController.prototype);
1183
- let startAlgorithm = () => void 0;
1184
- let pullAlgorithm = () => promiseResolvedWith(void 0);
1185
- let cancelAlgorithm = () => promiseResolvedWith(void 0);
1333
+ let startAlgorithm;
1334
+ let pullAlgorithm;
1335
+ let cancelAlgorithm;
1186
1336
  if (underlyingByteSource.start !== void 0) {
1187
1337
  startAlgorithm = () => underlyingByteSource.start(controller);
1338
+ } else {
1339
+ startAlgorithm = () => void 0;
1188
1340
  }
1189
1341
  if (underlyingByteSource.pull !== void 0) {
1190
1342
  pullAlgorithm = () => underlyingByteSource.pull(controller);
1343
+ } else {
1344
+ pullAlgorithm = () => promiseResolvedWith(void 0);
1191
1345
  }
1192
1346
  if (underlyingByteSource.cancel !== void 0) {
1193
1347
  cancelAlgorithm = (reason) => underlyingByteSource.cancel(reason);
1348
+ } else {
1349
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
1194
1350
  }
1195
1351
  const autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize;
1196
1352
  if (autoAllocateChunkSize === 0) {
@@ -1208,6 +1364,28 @@ var require_ponyfill_es2018 = __commonJS({
1208
1364
  function byteStreamControllerBrandCheckException(name) {
1209
1365
  return new TypeError(`ReadableByteStreamController.prototype.${name} can only be used on a ReadableByteStreamController`);
1210
1366
  }
1367
+ function convertReaderOptions(options, context) {
1368
+ assertDictionary(options, context);
1369
+ const mode = options === null || options === void 0 ? void 0 : options.mode;
1370
+ return {
1371
+ mode: mode === void 0 ? void 0 : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`)
1372
+ };
1373
+ }
1374
+ function convertReadableStreamReaderMode(mode, context) {
1375
+ mode = `${mode}`;
1376
+ if (mode !== "byob") {
1377
+ throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`);
1378
+ }
1379
+ return mode;
1380
+ }
1381
+ function convertByobReadOptions(options, context) {
1382
+ var _a;
1383
+ assertDictionary(options, context);
1384
+ const min = (_a = options === null || options === void 0 ? void 0 : options.min) !== null && _a !== void 0 ? _a : 1;
1385
+ return {
1386
+ min: convertUnsignedLongLongWithEnforceRange(min, `${context} has member 'min' that`)
1387
+ };
1388
+ }
1211
1389
  function AcquireReadableStreamBYOBReader(stream) {
1212
1390
  return new ReadableStreamBYOBReader(stream);
1213
1391
  }
@@ -1264,7 +1442,7 @@ var require_ponyfill_es2018 = __commonJS({
1264
1442
  }
1265
1443
  return ReadableStreamReaderGenericCancel(this, reason);
1266
1444
  }
1267
- read(view) {
1445
+ read(view, rawOptions = {}) {
1268
1446
  if (!IsReadableStreamBYOBReader(this)) {
1269
1447
  return promiseRejectedWith(byobReaderBrandCheckException("read"));
1270
1448
  }
@@ -1277,8 +1455,26 @@ var require_ponyfill_es2018 = __commonJS({
1277
1455
  if (view.buffer.byteLength === 0) {
1278
1456
  return promiseRejectedWith(new TypeError(`view's buffer must have non-zero byteLength`));
1279
1457
  }
1280
- if (IsDetachedBuffer(view.buffer))
1281
- ;
1458
+ if (IsDetachedBuffer(view.buffer)) {
1459
+ return promiseRejectedWith(new TypeError("view's buffer has been detached"));
1460
+ }
1461
+ let options;
1462
+ try {
1463
+ options = convertByobReadOptions(rawOptions, "options");
1464
+ } catch (e2) {
1465
+ return promiseRejectedWith(e2);
1466
+ }
1467
+ const min = options.min;
1468
+ if (min === 0) {
1469
+ return promiseRejectedWith(new TypeError("options.min must be greater than 0"));
1470
+ }
1471
+ if (!isDataView(view)) {
1472
+ if (min > view.length) {
1473
+ return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's length"));
1474
+ }
1475
+ } else if (min > view.byteLength) {
1476
+ return promiseRejectedWith(new RangeError("options.min must be less than or equal to view's byteLength"));
1477
+ }
1282
1478
  if (this._ownerReadableStream === void 0) {
1283
1479
  return promiseRejectedWith(readerLockException("read from"));
1284
1480
  }
@@ -1293,7 +1489,7 @@ var require_ponyfill_es2018 = __commonJS({
1293
1489
  _closeSteps: (chunk) => resolvePromise({ value: chunk, done: true }),
1294
1490
  _errorSteps: (e2) => rejectPromise(e2)
1295
1491
  };
1296
- ReadableStreamBYOBReaderRead(this, view, readIntoRequest);
1492
+ ReadableStreamBYOBReaderRead(this, view, min, readIntoRequest);
1297
1493
  return promise;
1298
1494
  }
1299
1495
  releaseLock() {
@@ -1303,10 +1499,7 @@ var require_ponyfill_es2018 = __commonJS({
1303
1499
  if (this._ownerReadableStream === void 0) {
1304
1500
  return;
1305
1501
  }
1306
- if (this._readIntoRequests.length > 0) {
1307
- throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");
1308
- }
1309
- ReadableStreamReaderGenericRelease(this);
1502
+ ReadableStreamBYOBReaderRelease(this);
1310
1503
  }
1311
1504
  }
1312
1505
  Object.defineProperties(ReadableStreamBYOBReader.prototype, {
@@ -1315,6 +1508,9 @@ var require_ponyfill_es2018 = __commonJS({
1315
1508
  releaseLock: { enumerable: true },
1316
1509
  closed: { enumerable: true }
1317
1510
  });
1511
+ setFunctionName(ReadableStreamBYOBReader.prototype.cancel, "cancel");
1512
+ setFunctionName(ReadableStreamBYOBReader.prototype.read, "read");
1513
+ setFunctionName(ReadableStreamBYOBReader.prototype.releaseLock, "releaseLock");
1318
1514
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
1319
1515
  Object.defineProperty(ReadableStreamBYOBReader.prototype, SymbolPolyfill.toStringTag, {
1320
1516
  value: "ReadableStreamBYOBReader",
@@ -1330,15 +1526,27 @@ var require_ponyfill_es2018 = __commonJS({
1330
1526
  }
1331
1527
  return x2 instanceof ReadableStreamBYOBReader;
1332
1528
  }
1333
- function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest) {
1529
+ function ReadableStreamBYOBReaderRead(reader, view, min, readIntoRequest) {
1334
1530
  const stream = reader._ownerReadableStream;
1335
1531
  stream._disturbed = true;
1336
1532
  if (stream._state === "errored") {
1337
1533
  readIntoRequest._errorSteps(stream._storedError);
1338
1534
  } else {
1339
- ReadableByteStreamControllerPullInto(stream._readableStreamController, view, readIntoRequest);
1535
+ ReadableByteStreamControllerPullInto(stream._readableStreamController, view, min, readIntoRequest);
1340
1536
  }
1341
1537
  }
1538
+ function ReadableStreamBYOBReaderRelease(reader) {
1539
+ ReadableStreamReaderGenericRelease(reader);
1540
+ const e2 = new TypeError("Reader was released");
1541
+ ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2);
1542
+ }
1543
+ function ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2) {
1544
+ const readIntoRequests = reader._readIntoRequests;
1545
+ reader._readIntoRequests = new SimpleQueue();
1546
+ readIntoRequests.forEach((readIntoRequest) => {
1547
+ readIntoRequest._errorSteps(e2);
1548
+ });
1549
+ }
1342
1550
  function byobReaderBrandCheckException(name) {
1343
1551
  return new TypeError(`ReadableStreamBYOBReader.prototype.${name} can only be used on a ReadableStreamBYOBReader`);
1344
1552
  }
@@ -1414,7 +1622,7 @@ var require_ponyfill_es2018 = __commonJS({
1414
1622
  }
1415
1623
  try {
1416
1624
  return typeof value.aborted === "boolean";
1417
- } catch (_a4) {
1625
+ } catch (_a) {
1418
1626
  return false;
1419
1627
  }
1420
1628
  }
@@ -1483,6 +1691,9 @@ var require_ponyfill_es2018 = __commonJS({
1483
1691
  getWriter: { enumerable: true },
1484
1692
  locked: { enumerable: true }
1485
1693
  });
1694
+ setFunctionName(WritableStream.prototype.abort, "abort");
1695
+ setFunctionName(WritableStream.prototype.close, "close");
1696
+ setFunctionName(WritableStream.prototype.getWriter, "getWriter");
1486
1697
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
1487
1698
  Object.defineProperty(WritableStream.prototype, SymbolPolyfill.toStringTag, {
1488
1699
  value: "WritableStream",
@@ -1527,12 +1738,12 @@ var require_ponyfill_es2018 = __commonJS({
1527
1738
  return true;
1528
1739
  }
1529
1740
  function WritableStreamAbort(stream, reason) {
1530
- var _a4;
1741
+ var _a;
1531
1742
  if (stream._state === "closed" || stream._state === "errored") {
1532
1743
  return promiseResolvedWith(void 0);
1533
1744
  }
1534
1745
  stream._writableStreamController._abortReason = reason;
1535
- (_a4 = stream._writableStreamController._abortController) === null || _a4 === void 0 ? void 0 : _a4.abort();
1746
+ (_a = stream._writableStreamController._abortController) === null || _a === void 0 ? void 0 : _a.abort(reason);
1536
1747
  const state = stream._state;
1537
1748
  if (state === "closed" || state === "errored") {
1538
1749
  return promiseResolvedWith(void 0);
@@ -1632,9 +1843,11 @@ var require_ponyfill_es2018 = __commonJS({
1632
1843
  uponPromise(promise, () => {
1633
1844
  abortRequest._resolve();
1634
1845
  WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
1846
+ return null;
1635
1847
  }, (reason) => {
1636
1848
  abortRequest._reject(reason);
1637
1849
  WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream);
1850
+ return null;
1638
1851
  });
1639
1852
  }
1640
1853
  function WritableStreamFinishInFlightWrite(stream) {
@@ -1813,6 +2026,10 @@ var require_ponyfill_es2018 = __commonJS({
1813
2026
  desiredSize: { enumerable: true },
1814
2027
  ready: { enumerable: true }
1815
2028
  });
2029
+ setFunctionName(WritableStreamDefaultWriter.prototype.abort, "abort");
2030
+ setFunctionName(WritableStreamDefaultWriter.prototype.close, "close");
2031
+ setFunctionName(WritableStreamDefaultWriter.prototype.releaseLock, "releaseLock");
2032
+ setFunctionName(WritableStreamDefaultWriter.prototype.write, "write");
1816
2033
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
1817
2034
  Object.defineProperty(WritableStreamDefaultWriter.prototype, SymbolPolyfill.toStringTag, {
1818
2035
  value: "WritableStreamDefaultWriter",
@@ -1981,28 +2198,38 @@ var require_ponyfill_es2018 = __commonJS({
1981
2198
  uponPromise(startPromise, () => {
1982
2199
  controller._started = true;
1983
2200
  WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
2201
+ return null;
1984
2202
  }, (r2) => {
1985
2203
  controller._started = true;
1986
2204
  WritableStreamDealWithRejection(stream, r2);
2205
+ return null;
1987
2206
  });
1988
2207
  }
1989
2208
  function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream, underlyingSink, highWaterMark, sizeAlgorithm) {
1990
2209
  const controller = Object.create(WritableStreamDefaultController.prototype);
1991
- let startAlgorithm = () => void 0;
1992
- let writeAlgorithm = () => promiseResolvedWith(void 0);
1993
- let closeAlgorithm = () => promiseResolvedWith(void 0);
1994
- let abortAlgorithm = () => promiseResolvedWith(void 0);
2210
+ let startAlgorithm;
2211
+ let writeAlgorithm;
2212
+ let closeAlgorithm;
2213
+ let abortAlgorithm;
1995
2214
  if (underlyingSink.start !== void 0) {
1996
2215
  startAlgorithm = () => underlyingSink.start(controller);
2216
+ } else {
2217
+ startAlgorithm = () => void 0;
1997
2218
  }
1998
2219
  if (underlyingSink.write !== void 0) {
1999
2220
  writeAlgorithm = (chunk) => underlyingSink.write(chunk, controller);
2221
+ } else {
2222
+ writeAlgorithm = () => promiseResolvedWith(void 0);
2000
2223
  }
2001
2224
  if (underlyingSink.close !== void 0) {
2002
2225
  closeAlgorithm = () => underlyingSink.close();
2226
+ } else {
2227
+ closeAlgorithm = () => promiseResolvedWith(void 0);
2003
2228
  }
2004
2229
  if (underlyingSink.abort !== void 0) {
2005
2230
  abortAlgorithm = (reason) => underlyingSink.abort(reason);
2231
+ } else {
2232
+ abortAlgorithm = () => promiseResolvedWith(void 0);
2006
2233
  }
2007
2234
  SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm);
2008
2235
  }
@@ -2077,8 +2304,10 @@ var require_ponyfill_es2018 = __commonJS({
2077
2304
  WritableStreamDefaultControllerClearAlgorithms(controller);
2078
2305
  uponPromise(sinkClosePromise, () => {
2079
2306
  WritableStreamFinishInFlightClose(stream);
2307
+ return null;
2080
2308
  }, (reason) => {
2081
2309
  WritableStreamFinishInFlightCloseWithError(stream, reason);
2310
+ return null;
2082
2311
  });
2083
2312
  }
2084
2313
  function WritableStreamDefaultControllerProcessWrite(controller, chunk) {
@@ -2094,11 +2323,13 @@ var require_ponyfill_es2018 = __commonJS({
2094
2323
  WritableStreamUpdateBackpressure(stream, backpressure);
2095
2324
  }
2096
2325
  WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller);
2326
+ return null;
2097
2327
  }, (reason) => {
2098
2328
  if (stream._state === "writable") {
2099
2329
  WritableStreamDefaultControllerClearAlgorithms(controller);
2100
2330
  }
2101
2331
  WritableStreamFinishInFlightWriteWithError(stream, reason);
2332
+ return null;
2102
2333
  });
2103
2334
  }
2104
2335
  function WritableStreamDefaultControllerGetBackpressure(controller) {
@@ -2199,19 +2430,36 @@ var require_ponyfill_es2018 = __commonJS({
2199
2430
  writer._readyPromise_reject = void 0;
2200
2431
  writer._readyPromiseState = "fulfilled";
2201
2432
  }
2202
- const NativeDOMException = typeof DOMException !== "undefined" ? DOMException : void 0;
2433
+ function getGlobals() {
2434
+ if (typeof globalThis !== "undefined") {
2435
+ return globalThis;
2436
+ } else if (typeof self !== "undefined") {
2437
+ return self;
2438
+ } else if (typeof global !== "undefined") {
2439
+ return global;
2440
+ }
2441
+ return void 0;
2442
+ }
2443
+ const globals = getGlobals();
2203
2444
  function isDOMExceptionConstructor(ctor) {
2204
2445
  if (!(typeof ctor === "function" || typeof ctor === "object")) {
2205
2446
  return false;
2206
2447
  }
2448
+ if (ctor.name !== "DOMException") {
2449
+ return false;
2450
+ }
2207
2451
  try {
2208
2452
  new ctor();
2209
2453
  return true;
2210
- } catch (_a4) {
2454
+ } catch (_a) {
2211
2455
  return false;
2212
2456
  }
2213
2457
  }
2214
- function createDOMExceptionPolyfill() {
2458
+ function getFromGlobal() {
2459
+ const ctor = globals === null || globals === void 0 ? void 0 : globals.DOMException;
2460
+ return isDOMExceptionConstructor(ctor) ? ctor : void 0;
2461
+ }
2462
+ function createPolyfill() {
2215
2463
  const ctor = function DOMException3(message, name) {
2216
2464
  this.message = message || "";
2217
2465
  this.name = name || "Error";
@@ -2219,11 +2467,12 @@ var require_ponyfill_es2018 = __commonJS({
2219
2467
  Error.captureStackTrace(this, this.constructor);
2220
2468
  }
2221
2469
  };
2470
+ setFunctionName(ctor, "DOMException");
2222
2471
  ctor.prototype = Object.create(Error.prototype);
2223
2472
  Object.defineProperty(ctor.prototype, "constructor", { value: ctor, writable: true, configurable: true });
2224
2473
  return ctor;
2225
2474
  }
2226
- const DOMException$1 = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill();
2475
+ const DOMException2 = getFromGlobal() || createPolyfill();
2227
2476
  function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventCancel, signal) {
2228
2477
  const reader = AcquireReadableStreamDefaultReader(source);
2229
2478
  const writer = AcquireWritableStreamDefaultWriter(dest);
@@ -2234,7 +2483,7 @@ var require_ponyfill_es2018 = __commonJS({
2234
2483
  let abortAlgorithm;
2235
2484
  if (signal !== void 0) {
2236
2485
  abortAlgorithm = () => {
2237
- const error = new DOMException$1("Aborted", "AbortError");
2486
+ const error = signal.reason !== void 0 ? signal.reason : new DOMException2("Aborted", "AbortError");
2238
2487
  const actions = [];
2239
2488
  if (!preventAbort) {
2240
2489
  actions.push(() => {
@@ -2295,6 +2544,7 @@ var require_ponyfill_es2018 = __commonJS({
2295
2544
  } else {
2296
2545
  shutdown(true, storedError);
2297
2546
  }
2547
+ return null;
2298
2548
  });
2299
2549
  isOrBecomesErrored(dest, writer._closedPromise, (storedError) => {
2300
2550
  if (!preventCancel) {
@@ -2302,6 +2552,7 @@ var require_ponyfill_es2018 = __commonJS({
2302
2552
  } else {
2303
2553
  shutdown(true, storedError);
2304
2554
  }
2555
+ return null;
2305
2556
  });
2306
2557
  isOrBecomesClosed(source, reader._closedPromise, () => {
2307
2558
  if (!preventClose) {
@@ -2309,6 +2560,7 @@ var require_ponyfill_es2018 = __commonJS({
2309
2560
  } else {
2310
2561
  shutdown();
2311
2562
  }
2563
+ return null;
2312
2564
  });
2313
2565
  if (WritableStreamCloseQueuedOrInFlight(dest) || dest._state === "closed") {
2314
2566
  const destClosed = new TypeError("the destination writable stream closed before all data could be piped to it");
@@ -2349,6 +2601,7 @@ var require_ponyfill_es2018 = __commonJS({
2349
2601
  }
2350
2602
  function doTheRest() {
2351
2603
  uponPromise(action(), () => finalize(originalIsError, originalError), (newError) => finalize(true, newError));
2604
+ return null;
2352
2605
  }
2353
2606
  }
2354
2607
  function shutdown(isError, error) {
@@ -2373,6 +2626,7 @@ var require_ponyfill_es2018 = __commonJS({
2373
2626
  } else {
2374
2627
  resolve(void 0);
2375
2628
  }
2629
+ return null;
2376
2630
  }
2377
2631
  });
2378
2632
  }
@@ -2432,6 +2686,8 @@ var require_ponyfill_es2018 = __commonJS({
2432
2686
  ReadableStreamDefaultControllerCallPullIfNeeded(this);
2433
2687
  }
2434
2688
  }
2689
+ [ReleaseSteps]() {
2690
+ }
2435
2691
  }
2436
2692
  Object.defineProperties(ReadableStreamDefaultController.prototype, {
2437
2693
  close: { enumerable: true },
@@ -2439,6 +2695,9 @@ var require_ponyfill_es2018 = __commonJS({
2439
2695
  error: { enumerable: true },
2440
2696
  desiredSize: { enumerable: true }
2441
2697
  });
2698
+ setFunctionName(ReadableStreamDefaultController.prototype.close, "close");
2699
+ setFunctionName(ReadableStreamDefaultController.prototype.enqueue, "enqueue");
2700
+ setFunctionName(ReadableStreamDefaultController.prototype.error, "error");
2442
2701
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
2443
2702
  Object.defineProperty(ReadableStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
2444
2703
  value: "ReadableStreamDefaultController",
@@ -2471,8 +2730,10 @@ var require_ponyfill_es2018 = __commonJS({
2471
2730
  controller._pullAgain = false;
2472
2731
  ReadableStreamDefaultControllerCallPullIfNeeded(controller);
2473
2732
  }
2733
+ return null;
2474
2734
  }, (e2) => {
2475
2735
  ReadableStreamDefaultControllerError(controller, e2);
2736
+ return null;
2476
2737
  });
2477
2738
  }
2478
2739
  function ReadableStreamDefaultControllerShouldCallPull(controller) {
@@ -2582,23 +2843,31 @@ var require_ponyfill_es2018 = __commonJS({
2582
2843
  uponPromise(promiseResolvedWith(startResult), () => {
2583
2844
  controller._started = true;
2584
2845
  ReadableStreamDefaultControllerCallPullIfNeeded(controller);
2846
+ return null;
2585
2847
  }, (r2) => {
2586
2848
  ReadableStreamDefaultControllerError(controller, r2);
2849
+ return null;
2587
2850
  });
2588
2851
  }
2589
2852
  function SetUpReadableStreamDefaultControllerFromUnderlyingSource(stream, underlyingSource, highWaterMark, sizeAlgorithm) {
2590
2853
  const controller = Object.create(ReadableStreamDefaultController.prototype);
2591
- let startAlgorithm = () => void 0;
2592
- let pullAlgorithm = () => promiseResolvedWith(void 0);
2593
- let cancelAlgorithm = () => promiseResolvedWith(void 0);
2854
+ let startAlgorithm;
2855
+ let pullAlgorithm;
2856
+ let cancelAlgorithm;
2594
2857
  if (underlyingSource.start !== void 0) {
2595
2858
  startAlgorithm = () => underlyingSource.start(controller);
2859
+ } else {
2860
+ startAlgorithm = () => void 0;
2596
2861
  }
2597
2862
  if (underlyingSource.pull !== void 0) {
2598
2863
  pullAlgorithm = () => underlyingSource.pull(controller);
2864
+ } else {
2865
+ pullAlgorithm = () => promiseResolvedWith(void 0);
2599
2866
  }
2600
2867
  if (underlyingSource.cancel !== void 0) {
2601
2868
  cancelAlgorithm = (reason) => underlyingSource.cancel(reason);
2869
+ } else {
2870
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
2602
2871
  }
2603
2872
  SetUpReadableStreamDefaultController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm);
2604
2873
  }
@@ -2633,7 +2902,7 @@ var require_ponyfill_es2018 = __commonJS({
2633
2902
  reading = true;
2634
2903
  const readRequest = {
2635
2904
  _chunkSteps: (chunk) => {
2636
- queueMicrotask(() => {
2905
+ _queueMicrotask(() => {
2637
2906
  readAgain = false;
2638
2907
  const chunk1 = chunk;
2639
2908
  const chunk2 = chunk;
@@ -2698,6 +2967,7 @@ var require_ponyfill_es2018 = __commonJS({
2698
2967
  if (!canceled1 || !canceled2) {
2699
2968
  resolveCancelPromise(void 0);
2700
2969
  }
2970
+ return null;
2701
2971
  });
2702
2972
  return [branch1, branch2];
2703
2973
  }
@@ -2719,13 +2989,14 @@ var require_ponyfill_es2018 = __commonJS({
2719
2989
  function forwardReaderError(thisReader) {
2720
2990
  uponRejection(thisReader._closedPromise, (r2) => {
2721
2991
  if (thisReader !== reader) {
2722
- return;
2992
+ return null;
2723
2993
  }
2724
2994
  ReadableByteStreamControllerError(branch1._readableStreamController, r2);
2725
2995
  ReadableByteStreamControllerError(branch2._readableStreamController, r2);
2726
2996
  if (!canceled1 || !canceled2) {
2727
2997
  resolveCancelPromise(void 0);
2728
2998
  }
2999
+ return null;
2729
3000
  });
2730
3001
  }
2731
3002
  function pullWithDefaultReader() {
@@ -2736,7 +3007,7 @@ var require_ponyfill_es2018 = __commonJS({
2736
3007
  }
2737
3008
  const readRequest = {
2738
3009
  _chunkSteps: (chunk) => {
2739
- queueMicrotask(() => {
3010
+ _queueMicrotask(() => {
2740
3011
  readAgainForBranch1 = false;
2741
3012
  readAgainForBranch2 = false;
2742
3013
  const chunk1 = chunk;
@@ -2799,7 +3070,7 @@ var require_ponyfill_es2018 = __commonJS({
2799
3070
  const otherBranch = forBranch2 ? branch1 : branch2;
2800
3071
  const readIntoRequest = {
2801
3072
  _chunkSteps: (chunk) => {
2802
- queueMicrotask(() => {
3073
+ _queueMicrotask(() => {
2803
3074
  readAgainForBranch1 = false;
2804
3075
  readAgainForBranch2 = false;
2805
3076
  const byobCanceled = forBranch2 ? canceled2 : canceled1;
@@ -2855,7 +3126,7 @@ var require_ponyfill_es2018 = __commonJS({
2855
3126
  reading = false;
2856
3127
  }
2857
3128
  };
2858
- ReadableStreamBYOBReaderRead(reader, view, readIntoRequest);
3129
+ ReadableStreamBYOBReaderRead(reader, view, 1, readIntoRequest);
2859
3130
  }
2860
3131
  function pull1Algorithm() {
2861
3132
  if (reading) {
@@ -2913,6 +3184,100 @@ var require_ponyfill_es2018 = __commonJS({
2913
3184
  forwardReaderError(reader);
2914
3185
  return [branch1, branch2];
2915
3186
  }
3187
+ function isReadableStreamLike(stream) {
3188
+ return typeIsObject(stream) && typeof stream.getReader !== "undefined";
3189
+ }
3190
+ function ReadableStreamFrom(source) {
3191
+ if (isReadableStreamLike(source)) {
3192
+ return ReadableStreamFromDefaultReader(source.getReader());
3193
+ }
3194
+ return ReadableStreamFromIterable(source);
3195
+ }
3196
+ function ReadableStreamFromIterable(asyncIterable) {
3197
+ let stream;
3198
+ const iteratorRecord = GetIterator(asyncIterable, "async");
3199
+ const startAlgorithm = noop2;
3200
+ function pullAlgorithm() {
3201
+ let nextResult;
3202
+ try {
3203
+ nextResult = IteratorNext(iteratorRecord);
3204
+ } catch (e2) {
3205
+ return promiseRejectedWith(e2);
3206
+ }
3207
+ const nextPromise = promiseResolvedWith(nextResult);
3208
+ return transformPromiseWith(nextPromise, (iterResult) => {
3209
+ if (!typeIsObject(iterResult)) {
3210
+ throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
3211
+ }
3212
+ const done = IteratorComplete(iterResult);
3213
+ if (done) {
3214
+ ReadableStreamDefaultControllerClose(stream._readableStreamController);
3215
+ } else {
3216
+ const value = IteratorValue(iterResult);
3217
+ ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
3218
+ }
3219
+ });
3220
+ }
3221
+ function cancelAlgorithm(reason) {
3222
+ const iterator = iteratorRecord.iterator;
3223
+ let returnMethod;
3224
+ try {
3225
+ returnMethod = GetMethod(iterator, "return");
3226
+ } catch (e2) {
3227
+ return promiseRejectedWith(e2);
3228
+ }
3229
+ if (returnMethod === void 0) {
3230
+ return promiseResolvedWith(void 0);
3231
+ }
3232
+ let returnResult;
3233
+ try {
3234
+ returnResult = reflectCall(returnMethod, iterator, [reason]);
3235
+ } catch (e2) {
3236
+ return promiseRejectedWith(e2);
3237
+ }
3238
+ const returnPromise = promiseResolvedWith(returnResult);
3239
+ return transformPromiseWith(returnPromise, (iterResult) => {
3240
+ if (!typeIsObject(iterResult)) {
3241
+ throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
3242
+ }
3243
+ return void 0;
3244
+ });
3245
+ }
3246
+ stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
3247
+ return stream;
3248
+ }
3249
+ function ReadableStreamFromDefaultReader(reader) {
3250
+ let stream;
3251
+ const startAlgorithm = noop2;
3252
+ function pullAlgorithm() {
3253
+ let readPromise;
3254
+ try {
3255
+ readPromise = reader.read();
3256
+ } catch (e2) {
3257
+ return promiseRejectedWith(e2);
3258
+ }
3259
+ return transformPromiseWith(readPromise, (readResult) => {
3260
+ if (!typeIsObject(readResult)) {
3261
+ throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
3262
+ }
3263
+ if (readResult.done) {
3264
+ ReadableStreamDefaultControllerClose(stream._readableStreamController);
3265
+ } else {
3266
+ const value = readResult.value;
3267
+ ReadableStreamDefaultControllerEnqueue(stream._readableStreamController, value);
3268
+ }
3269
+ });
3270
+ }
3271
+ function cancelAlgorithm(reason) {
3272
+ try {
3273
+ return promiseResolvedWith(reader.cancel(reason));
3274
+ } catch (e2) {
3275
+ return promiseRejectedWith(e2);
3276
+ }
3277
+ }
3278
+ stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
3279
+ return stream;
3280
+ }
2916
3281
  function convertUnderlyingDefaultOrByteSource(source, context) {
2917
3282
  assertDictionary(source, context);
2918
3283
  const original = source;
@@ -2948,20 +3313,6 @@ var require_ponyfill_es2018 = __commonJS({
2948
3313
  }
2949
3314
  return type;
2950
3315
  }
2951
- function convertReaderOptions(options, context) {
2952
- assertDictionary(options, context);
2953
- const mode = options === null || options === void 0 ? void 0 : options.mode;
2954
- return {
2955
- mode: mode === void 0 ? void 0 : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`)
2956
- };
2957
- }
2958
- function convertReadableStreamReaderMode(mode, context) {
2959
- mode = `${mode}`;
2960
- if (mode !== "byob") {
2961
- throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`);
2962
- }
2963
- return mode;
2964
- }
2965
3316
  function convertIteratorOptions(options, context) {
2966
3317
  assertDictionary(options, context);
2967
3318
  const preventCancel = options === null || options === void 0 ? void 0 : options.preventCancel;
@@ -3100,7 +3451,13 @@ var require_ponyfill_es2018 = __commonJS({
3100
3451
  const options = convertIteratorOptions(rawOptions, "First parameter");
3101
3452
  return AcquireReadableStreamAsyncIterator(this, options.preventCancel);
3102
3453
  }
3454
+ static from(asyncIterable) {
3455
+ return ReadableStreamFrom(asyncIterable);
3456
+ }
3103
3457
  }
3458
+ Object.defineProperties(ReadableStream2, {
3459
+ from: { enumerable: true }
3460
+ });
3104
3461
  Object.defineProperties(ReadableStream2.prototype, {
3105
3462
  cancel: { enumerable: true },
3106
3463
  getReader: { enumerable: true },
@@ -3110,6 +3467,13 @@ var require_ponyfill_es2018 = __commonJS({
3110
3467
  values: { enumerable: true },
3111
3468
  locked: { enumerable: true }
3112
3469
  });
3470
+ setFunctionName(ReadableStream2.from, "from");
3471
+ setFunctionName(ReadableStream2.prototype.cancel, "cancel");
3472
+ setFunctionName(ReadableStream2.prototype.getReader, "getReader");
3473
+ setFunctionName(ReadableStream2.prototype.pipeThrough, "pipeThrough");
3474
+ setFunctionName(ReadableStream2.prototype.pipeTo, "pipeTo");
3475
+ setFunctionName(ReadableStream2.prototype.tee, "tee");
3476
+ setFunctionName(ReadableStream2.prototype.values, "values");
3113
3477
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
3114
3478
  Object.defineProperty(ReadableStream2.prototype, SymbolPolyfill.toStringTag, {
3115
3479
  value: "ReadableStream",
@@ -3169,10 +3533,11 @@ var require_ponyfill_es2018 = __commonJS({
3169
3533
  ReadableStreamClose(stream);
3170
3534
  const reader = stream._reader;
3171
3535
  if (reader !== void 0 && IsReadableStreamBYOBReader(reader)) {
3172
- reader._readIntoRequests.forEach((readIntoRequest) => {
3536
+ const readIntoRequests = reader._readIntoRequests;
3537
+ reader._readIntoRequests = new SimpleQueue();
3538
+ readIntoRequests.forEach((readIntoRequest) => {
3173
3539
  readIntoRequest._closeSteps(void 0);
3174
3540
  });
3175
- reader._readIntoRequests = new SimpleQueue();
3176
3541
  }
3177
3542
  const sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
3178
3543
  return transformPromiseWith(sourceCancelPromise, noop2);
@@ -3185,10 +3550,11 @@ var require_ponyfill_es2018 = __commonJS({
3185
3550
  }
3186
3551
  defaultReaderClosedPromiseResolve(reader);
3187
3552
  if (IsReadableStreamDefaultReader(reader)) {
3188
- reader._readRequests.forEach((readRequest) => {
3553
+ const readRequests = reader._readRequests;
3554
+ reader._readRequests = new SimpleQueue();
3555
+ readRequests.forEach((readRequest) => {
3189
3556
  readRequest._closeSteps();
3190
3557
  });
3191
- reader._readRequests = new SimpleQueue();
3192
3558
  }
3193
3559
  }
3194
3560
  function ReadableStreamError(stream, e2) {
@@ -3200,15 +3566,9 @@ var require_ponyfill_es2018 = __commonJS({
3200
3566
  }
3201
3567
  defaultReaderClosedPromiseReject(reader, e2);
3202
3568
  if (IsReadableStreamDefaultReader(reader)) {
3203
- reader._readRequests.forEach((readRequest) => {
3204
- readRequest._errorSteps(e2);
3205
- });
3206
- reader._readRequests = new SimpleQueue();
3569
+ ReadableStreamDefaultReaderErrorReadRequests(reader, e2);
3207
3570
  } else {
3208
- reader._readIntoRequests.forEach((readIntoRequest) => {
3209
- readIntoRequest._errorSteps(e2);
3210
- });
3211
- reader._readIntoRequests = new SimpleQueue();
3571
+ ReadableStreamBYOBReaderErrorReadIntoRequests(reader, e2);
3212
3572
  }
3213
3573
  }
3214
3574
  function streamBrandCheckException$1(name) {
@@ -3225,13 +3585,7 @@ var require_ponyfill_es2018 = __commonJS({
3225
3585
  const byteLengthSizeFunction = (chunk) => {
3226
3586
  return chunk.byteLength;
3227
3587
  };
3228
- try {
3229
- Object.defineProperty(byteLengthSizeFunction, "name", {
3230
- value: "size",
3231
- configurable: true
3232
- });
3233
- } catch (_a4) {
3234
- }
3588
+ setFunctionName(byteLengthSizeFunction, "size");
3235
3589
  class ByteLengthQueuingStrategy {
3236
3590
  constructor(options) {
3237
3591
  assertRequiredArgument(options, 1, "ByteLengthQueuingStrategy");
@@ -3276,13 +3630,7 @@ var require_ponyfill_es2018 = __commonJS({
3276
3630
  const countSizeFunction = () => {
3277
3631
  return 1;
3278
3632
  };
3279
- try {
3280
- Object.defineProperty(countSizeFunction, "name", {
3281
- value: "size",
3282
- configurable: true
3283
- });
3284
- } catch (_a4) {
3285
- }
3633
+ setFunctionName(countSizeFunction, "size");
3286
3634
  class CountQueuingStrategy {
3287
3635
  constructor(options) {
3288
3636
  assertRequiredArgument(options, 1, "CountQueuingStrategy");
@@ -3326,12 +3674,14 @@ var require_ponyfill_es2018 = __commonJS({
3326
3674
  }
3327
3675
  function convertTransformer(original, context) {
3328
3676
  assertDictionary(original, context);
3677
+ const cancel = original === null || original === void 0 ? void 0 : original.cancel;
3329
3678
  const flush = original === null || original === void 0 ? void 0 : original.flush;
3330
3679
  const readableType = original === null || original === void 0 ? void 0 : original.readableType;
3331
3680
  const start = original === null || original === void 0 ? void 0 : original.start;
3332
3681
  const transform = original === null || original === void 0 ? void 0 : original.transform;
3333
3682
  const writableType = original === null || original === void 0 ? void 0 : original.writableType;
3334
3683
  return {
3684
+ cancel: cancel === void 0 ? void 0 : convertTransformerCancelCallback(cancel, original, `${context} has member 'cancel' that`),
3335
3685
  flush: flush === void 0 ? void 0 : convertTransformerFlushCallback(flush, original, `${context} has member 'flush' that`),
3336
3686
  readableType,
3337
3687
  start: start === void 0 ? void 0 : convertTransformerStartCallback(start, original, `${context} has member 'start' that`),
@@ -3351,6 +3701,10 @@ var require_ponyfill_es2018 = __commonJS({
3351
3701
  assertFunction(fn, context);
3352
3702
  return (chunk, controller) => promiseCall(fn, original, [chunk, controller]);
3353
3703
  }
3704
+ function convertTransformerCancelCallback(fn, original, context) {
3705
+ assertFunction(fn, context);
3706
+ return (reason) => promiseCall(fn, original, [reason]);
3707
+ }
3354
3708
  class TransformStream {
3355
3709
  constructor(rawTransformer = {}, rawWritableStrategy = {}, rawReadableStrategy = {}) {
3356
3710
  if (rawTransformer === void 0) {
@@ -3422,8 +3776,7 @@ var require_ponyfill_es2018 = __commonJS({
3422
3776
  return TransformStreamDefaultSourcePullAlgorithm(stream);
3423
3777
  }
3424
3778
  function cancelAlgorithm(reason) {
3425
- TransformStreamErrorWritableAndUnblockWrite(stream, reason);
3426
- return promiseResolvedWith(void 0);
3779
+ return TransformStreamDefaultSourceCancelAlgorithm(stream, reason);
3427
3780
  }
3428
3781
  stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
3429
3782
  stream._backpressure = void 0;
@@ -3448,6 +3801,9 @@ var require_ponyfill_es2018 = __commonJS({
3448
3801
  function TransformStreamErrorWritableAndUnblockWrite(stream, e2) {
3449
3802
  TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController);
3450
3803
  WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e2);
3804
+ TransformStreamUnblockWrite(stream);
3805
+ }
3806
+ function TransformStreamUnblockWrite(stream) {
3451
3807
  if (stream._backpressure) {
3452
3808
  TransformStreamSetBackpressure(stream, false);
3453
3809
  }
@@ -3497,6 +3853,9 @@ var require_ponyfill_es2018 = __commonJS({
3497
3853
  terminate: { enumerable: true },
3498
3854
  desiredSize: { enumerable: true }
3499
3855
  });
3856
+ setFunctionName(TransformStreamDefaultController.prototype.enqueue, "enqueue");
3857
+ setFunctionName(TransformStreamDefaultController.prototype.error, "error");
3858
+ setFunctionName(TransformStreamDefaultController.prototype.terminate, "terminate");
3500
3859
  if (typeof SymbolPolyfill.toStringTag === "symbol") {
3501
3860
  Object.defineProperty(TransformStreamDefaultController.prototype, SymbolPolyfill.toStringTag, {
3502
3861
  value: "TransformStreamDefaultController",
@@ -3512,34 +3871,49 @@ var require_ponyfill_es2018 = __commonJS({
3512
3871
  }
3513
3872
  return x2 instanceof TransformStreamDefaultController;
3514
3873
  }
3515
- function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm) {
3874
+ function SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm) {
3516
3875
  controller._controlledTransformStream = stream;
3517
3876
  stream._transformStreamController = controller;
3518
3877
  controller._transformAlgorithm = transformAlgorithm;
3519
3878
  controller._flushAlgorithm = flushAlgorithm;
3879
+ controller._cancelAlgorithm = cancelAlgorithm;
3880
+ controller._finishPromise = void 0;
3881
+ controller._finishPromise_resolve = void 0;
3882
+ controller._finishPromise_reject = void 0;
3520
3883
  }
3521
3884
  function SetUpTransformStreamDefaultControllerFromTransformer(stream, transformer) {
3522
3885
  const controller = Object.create(TransformStreamDefaultController.prototype);
3523
- let transformAlgorithm = (chunk) => {
3524
- try {
3525
- TransformStreamDefaultControllerEnqueue(controller, chunk);
3526
- return promiseResolvedWith(void 0);
3527
- } catch (transformResultE) {
3528
- return promiseRejectedWith(transformResultE);
3529
- }
3530
- };
3531
- let flushAlgorithm = () => promiseResolvedWith(void 0);
3886
+ let transformAlgorithm;
3887
+ let flushAlgorithm;
3888
+ let cancelAlgorithm;
3532
3889
  if (transformer.transform !== void 0) {
3533
3890
  transformAlgorithm = (chunk) => transformer.transform(chunk, controller);
3891
+ } else {
3892
+ transformAlgorithm = (chunk) => {
3893
+ try {
3894
+ TransformStreamDefaultControllerEnqueue(controller, chunk);
3895
+ return promiseResolvedWith(void 0);
3896
+ } catch (transformResultE) {
3897
+ return promiseRejectedWith(transformResultE);
3898
+ }
3899
+ };
3534
3900
  }
3535
3901
  if (transformer.flush !== void 0) {
3536
3902
  flushAlgorithm = () => transformer.flush(controller);
3903
+ } else {
3904
+ flushAlgorithm = () => promiseResolvedWith(void 0);
3905
+ }
3906
+ if (transformer.cancel !== void 0) {
3907
+ cancelAlgorithm = (reason) => transformer.cancel(reason);
3908
+ } else {
3909
+ cancelAlgorithm = () => promiseResolvedWith(void 0);
3537
3910
  }
3538
- SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm);
3911
+ SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm, cancelAlgorithm);
3539
3912
  }
3540
3913
  function TransformStreamDefaultControllerClearAlgorithms(controller) {
3541
3914
  controller._transformAlgorithm = void 0;
3542
3915
  controller._flushAlgorithm = void 0;
3916
+ controller._cancelAlgorithm = void 0;
3543
3917
  }
3544
3918
  function TransformStreamDefaultControllerEnqueue(controller, chunk) {
3545
3919
  const stream = controller._controlledTransformStream;
@@ -3591,31 +3965,112 @@ var require_ponyfill_es2018 = __commonJS({
3591
3965
  return TransformStreamDefaultControllerPerformTransform(controller, chunk);
3592
3966
  }
3593
3967
  function TransformStreamDefaultSinkAbortAlgorithm(stream, reason) {
3594
- TransformStreamError(stream, reason);
3595
- return promiseResolvedWith(void 0);
3968
+ const controller = stream._transformStreamController;
3969
+ if (controller._finishPromise !== void 0) {
3970
+ return controller._finishPromise;
3971
+ }
3972
+ const readable = stream._readable;
3973
+ controller._finishPromise = newPromise((resolve, reject) => {
3974
+ controller._finishPromise_resolve = resolve;
3975
+ controller._finishPromise_reject = reject;
3976
+ });
3977
+ const cancelPromise = controller._cancelAlgorithm(reason);
3978
+ TransformStreamDefaultControllerClearAlgorithms(controller);
3979
+ uponPromise(cancelPromise, () => {
3980
+ if (readable._state === "errored") {
3981
+ defaultControllerFinishPromiseReject(controller, readable._storedError);
3982
+ } else {
3983
+ ReadableStreamDefaultControllerError(readable._readableStreamController, reason);
3984
+ defaultControllerFinishPromiseResolve(controller);
3985
+ }
3986
+ return null;
3987
+ }, (r2) => {
3988
+ ReadableStreamDefaultControllerError(readable._readableStreamController, r2);
3989
+ defaultControllerFinishPromiseReject(controller, r2);
3990
+ return null;
3991
+ });
3992
+ return controller._finishPromise;
3596
3993
  }
3597
3994
  function TransformStreamDefaultSinkCloseAlgorithm(stream) {
3598
- const readable = stream._readable;
3599
3995
  const controller = stream._transformStreamController;
3996
+ if (controller._finishPromise !== void 0) {
3997
+ return controller._finishPromise;
3998
+ }
3999
+ const readable = stream._readable;
4000
+ controller._finishPromise = newPromise((resolve, reject) => {
4001
+ controller._finishPromise_resolve = resolve;
4002
+ controller._finishPromise_reject = reject;
4003
+ });
3600
4004
  const flushPromise = controller._flushAlgorithm();
3601
4005
  TransformStreamDefaultControllerClearAlgorithms(controller);
3602
- return transformPromiseWith(flushPromise, () => {
4006
+ uponPromise(flushPromise, () => {
3603
4007
  if (readable._state === "errored") {
3604
- throw readable._storedError;
4008
+ defaultControllerFinishPromiseReject(controller, readable._storedError);
4009
+ } else {
4010
+ ReadableStreamDefaultControllerClose(readable._readableStreamController);
4011
+ defaultControllerFinishPromiseResolve(controller);
3605
4012
  }
3606
- ReadableStreamDefaultControllerClose(readable._readableStreamController);
4013
+ return null;
3607
4014
  }, (r2) => {
3608
- TransformStreamError(stream, r2);
3609
- throw readable._storedError;
4015
+ ReadableStreamDefaultControllerError(readable._readableStreamController, r2);
4016
+ defaultControllerFinishPromiseReject(controller, r2);
4017
+ return null;
3610
4018
  });
4019
+ return controller._finishPromise;
3611
4020
  }
3612
4021
  function TransformStreamDefaultSourcePullAlgorithm(stream) {
3613
4022
  TransformStreamSetBackpressure(stream, false);
3614
4023
  return stream._backpressureChangePromise;
3615
4024
  }
4025
+ function TransformStreamDefaultSourceCancelAlgorithm(stream, reason) {
4026
+ const controller = stream._transformStreamController;
4027
+ if (controller._finishPromise !== void 0) {
4028
+ return controller._finishPromise;
4029
+ }
4030
+ const writable = stream._writable;
4031
+ controller._finishPromise = newPromise((resolve, reject) => {
4032
+ controller._finishPromise_resolve = resolve;
4033
+ controller._finishPromise_reject = reject;
4034
+ });
4035
+ const cancelPromise = controller._cancelAlgorithm(reason);
4036
+ TransformStreamDefaultControllerClearAlgorithms(controller);
4037
+ uponPromise(cancelPromise, () => {
4038
+ if (writable._state === "errored") {
4039
+ defaultControllerFinishPromiseReject(controller, writable._storedError);
4040
+ } else {
4041
+ WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, reason);
4042
+ TransformStreamUnblockWrite(stream);
4043
+ defaultControllerFinishPromiseResolve(controller);
4044
+ }
4045
+ return null;
4046
+ }, (r2) => {
4047
+ WritableStreamDefaultControllerErrorIfNeeded(writable._writableStreamController, r2);
4048
+ TransformStreamUnblockWrite(stream);
4049
+ defaultControllerFinishPromiseReject(controller, r2);
4050
+ return null;
4051
+ });
4052
+ return controller._finishPromise;
4053
+ }
3616
4054
  function defaultControllerBrandCheckException(name) {
3617
4055
  return new TypeError(`TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`);
3618
4056
  }
4057
+ function defaultControllerFinishPromiseResolve(controller) {
4058
+ if (controller._finishPromise_resolve === void 0) {
4059
+ return;
4060
+ }
4061
+ controller._finishPromise_resolve();
4062
+ controller._finishPromise_resolve = void 0;
4063
+ controller._finishPromise_reject = void 0;
4064
+ }
4065
+ function defaultControllerFinishPromiseReject(controller, reason) {
4066
+ if (controller._finishPromise_reject === void 0) {
4067
+ return;
4068
+ }
4069
+ setPromiseIsHandledToTrue(controller._finishPromise);
4070
+ controller._finishPromise_reject(reason);
4071
+ controller._finishPromise_resolve = void 0;
4072
+ controller._finishPromise_reject = void 0;
4073
+ }
3619
4074
  function streamBrandCheckException(name) {
3620
4075
  return new TypeError(`TransformStream.prototype.${name} can only be used on a TransformStream`);
3621
4076
  }
@@ -3632,23 +4087,22 @@ var require_ponyfill_es2018 = __commonJS({
3632
4087
  exports2.WritableStream = WritableStream;
3633
4088
  exports2.WritableStreamDefaultController = WritableStreamDefaultController;
3634
4089
  exports2.WritableStreamDefaultWriter = WritableStreamDefaultWriter;
3635
- Object.defineProperty(exports2, "__esModule", { value: true });
3636
4090
  });
3637
4091
  }
3638
4092
  });
3639
4093
 
3640
- // ../../node_modules/fetch-blob/streams.cjs
4094
+ // ../../../node_modules/fetch-blob/streams.cjs
3641
4095
  var require_streams = __commonJS({
3642
- "../../node_modules/fetch-blob/streams.cjs"() {
4096
+ "../../../node_modules/fetch-blob/streams.cjs"() {
3643
4097
  var POOL_SIZE2 = 65536;
3644
4098
  if (!globalThis.ReadableStream) {
3645
4099
  try {
3646
- const process2 = require("process");
4100
+ const process2 = require("node:process");
3647
4101
  const { emitWarning } = process2;
3648
4102
  try {
3649
4103
  process2.emitWarning = () => {
3650
4104
  };
3651
- Object.assign(globalThis, require("stream/web"));
4105
+ Object.assign(globalThis, require("node:stream/web"));
3652
4106
  process2.emitWarning = emitWarning;
3653
4107
  } catch (error) {
3654
4108
  process2.emitWarning = emitWarning;
@@ -3659,9 +4113,9 @@ var require_streams = __commonJS({
3659
4113
  }
3660
4114
  }
3661
4115
  try {
3662
- const { Blob: Blob2 } = require("buffer");
3663
- if (Blob2 && !Blob2.prototype.stream) {
3664
- Blob2.prototype.stream = function name(params) {
4116
+ const { Blob: Blob3 } = require("buffer");
4117
+ if (Blob3 && !Blob3.prototype.stream) {
4118
+ Blob3.prototype.stream = function name(params) {
3665
4119
  let position = 0;
3666
4120
  const blob = this;
3667
4121
  return new ReadableStream({
@@ -3683,7 +4137,7 @@ var require_streams = __commonJS({
3683
4137
  }
3684
4138
  });
3685
4139
 
3686
- // ../../node_modules/fetch-blob/index.js
4140
+ // ../../../node_modules/fetch-blob/index.js
3687
4141
  async function* toIterator(parts, clone2 = true) {
3688
4142
  for (const part of parts) {
3689
4143
  if ("stream" in part) {
@@ -3712,17 +4166,17 @@ async function* toIterator(parts, clone2 = true) {
3712
4166
  }
3713
4167
  }
3714
4168
  }
3715
- var import_streams, POOL_SIZE, _parts, _type, _size, _endings, _a, _Blob, Blob, fetch_blob_default;
4169
+ var import_streams, POOL_SIZE, _Blob, Blob2, fetch_blob_default;
3716
4170
  var init_fetch_blob = __esm({
3717
- "../../node_modules/fetch-blob/index.js"() {
4171
+ "../../../node_modules/fetch-blob/index.js"() {
3718
4172
  import_streams = __toESM(require_streams(), 1);
3719
4173
  POOL_SIZE = 65536;
3720
- _Blob = (_a = class {
4174
+ _Blob = class Blob {
4175
+ #parts = [];
4176
+ #type = "";
4177
+ #size = 0;
4178
+ #endings = "transparent";
3721
4179
  constructor(blobParts = [], options = {}) {
3722
- __privateAdd(this, _parts, []);
3723
- __privateAdd(this, _type, "");
3724
- __privateAdd(this, _size, 0);
3725
- __privateAdd(this, _endings, "transparent");
3726
4180
  if (typeof blobParts !== "object" || blobParts === null) {
3727
4181
  throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
3728
4182
  }
@@ -3741,28 +4195,28 @@ var init_fetch_blob = __esm({
3741
4195
  part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
3742
4196
  } else if (element instanceof ArrayBuffer) {
3743
4197
  part = new Uint8Array(element.slice(0));
3744
- } else if (element instanceof _a) {
4198
+ } else if (element instanceof Blob) {
3745
4199
  part = element;
3746
4200
  } else {
3747
4201
  part = encoder.encode(`${element}`);
3748
4202
  }
3749
- __privateSet(this, _size, __privateGet(this, _size) + (ArrayBuffer.isView(part) ? part.byteLength : part.size));
3750
- __privateGet(this, _parts).push(part);
4203
+ this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
4204
+ this.#parts.push(part);
3751
4205
  }
3752
- __privateSet(this, _endings, `${options.endings === void 0 ? "transparent" : options.endings}`);
4206
+ this.#endings = `${options.endings === void 0 ? "transparent" : options.endings}`;
3753
4207
  const type = options.type === void 0 ? "" : String(options.type);
3754
- __privateSet(this, _type, /^[\x20-\x7E]*$/.test(type) ? type : "");
4208
+ this.#type = /^[\x20-\x7E]*$/.test(type) ? type : "";
3755
4209
  }
3756
4210
  get size() {
3757
- return __privateGet(this, _size);
4211
+ return this.#size;
3758
4212
  }
3759
4213
  get type() {
3760
- return __privateGet(this, _type);
4214
+ return this.#type;
3761
4215
  }
3762
4216
  async text() {
3763
4217
  const decoder = new TextDecoder();
3764
4218
  let str = "";
3765
- for await (const part of toIterator(__privateGet(this, _parts), false)) {
4219
+ for await (const part of toIterator(this.#parts, false)) {
3766
4220
  str += decoder.decode(part, { stream: true });
3767
4221
  }
3768
4222
  str += decoder.decode();
@@ -3771,14 +4225,14 @@ var init_fetch_blob = __esm({
3771
4225
  async arrayBuffer() {
3772
4226
  const data = new Uint8Array(this.size);
3773
4227
  let offset = 0;
3774
- for await (const chunk of toIterator(__privateGet(this, _parts), false)) {
4228
+ for await (const chunk of toIterator(this.#parts, false)) {
3775
4229
  data.set(chunk, offset);
3776
4230
  offset += chunk.length;
3777
4231
  }
3778
4232
  return data.buffer;
3779
4233
  }
3780
4234
  stream() {
3781
- const it = toIterator(__privateGet(this, _parts), true);
4235
+ const it = toIterator(this.#parts, true);
3782
4236
  return new globalThis.ReadableStream({
3783
4237
  type: "bytes",
3784
4238
  async pull(ctrl) {
@@ -3795,7 +4249,7 @@ var init_fetch_blob = __esm({
3795
4249
  let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
3796
4250
  let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
3797
4251
  const span = Math.max(relativeEnd - relativeStart, 0);
3798
- const parts = __privateGet(this, _parts);
4252
+ const parts = this.#parts;
3799
4253
  const blobParts = [];
3800
4254
  let added = 0;
3801
4255
  for (const part of parts) {
@@ -3820,9 +4274,9 @@ var init_fetch_blob = __esm({
3820
4274
  relativeStart = 0;
3821
4275
  }
3822
4276
  }
3823
- const blob = new _a([], { type: String(type).toLowerCase() });
3824
- __privateSet(blob, _size, span);
3825
- __privateSet(blob, _parts, blobParts);
4277
+ const blob = new Blob([], { type: String(type).toLowerCase() });
4278
+ blob.#size = span;
4279
+ blob.#parts = blobParts;
3826
4280
  return blob;
3827
4281
  }
3828
4282
  get [Symbol.toStringTag]() {
@@ -3831,43 +4285,43 @@ var init_fetch_blob = __esm({
3831
4285
  static [Symbol.hasInstance](object) {
3832
4286
  return object && typeof object === "object" && typeof object.constructor === "function" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
3833
4287
  }
3834
- }, _parts = new WeakMap(), _type = new WeakMap(), _size = new WeakMap(), _endings = new WeakMap(), _a);
4288
+ };
3835
4289
  Object.defineProperties(_Blob.prototype, {
3836
4290
  size: { enumerable: true },
3837
4291
  type: { enumerable: true },
3838
4292
  slice: { enumerable: true }
3839
4293
  });
3840
- Blob = _Blob;
3841
- fetch_blob_default = Blob;
4294
+ Blob2 = _Blob;
4295
+ fetch_blob_default = Blob2;
3842
4296
  }
3843
4297
  });
3844
4298
 
3845
- // ../../node_modules/fetch-blob/file.js
3846
- var _lastModified, _name, _a2, _File, File, file_default;
4299
+ // ../../../node_modules/fetch-blob/file.js
4300
+ var _File, File2, file_default;
3847
4301
  var init_file = __esm({
3848
- "../../node_modules/fetch-blob/file.js"() {
4302
+ "../../../node_modules/fetch-blob/file.js"() {
3849
4303
  init_fetch_blob();
3850
- _File = (_a2 = class extends fetch_blob_default {
4304
+ _File = class File extends fetch_blob_default {
4305
+ #lastModified = 0;
4306
+ #name = "";
3851
4307
  constructor(fileBits, fileName, options = {}) {
3852
4308
  if (arguments.length < 2) {
3853
4309
  throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
3854
4310
  }
3855
4311
  super(fileBits, options);
3856
- __privateAdd(this, _lastModified, 0);
3857
- __privateAdd(this, _name, "");
3858
4312
  if (options === null)
3859
4313
  options = {};
3860
4314
  const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
3861
4315
  if (!Number.isNaN(lastModified)) {
3862
- __privateSet(this, _lastModified, lastModified);
4316
+ this.#lastModified = lastModified;
3863
4317
  }
3864
- __privateSet(this, _name, String(fileName));
4318
+ this.#name = String(fileName);
3865
4319
  }
3866
4320
  get name() {
3867
- return __privateGet(this, _name);
4321
+ return this.#name;
3868
4322
  }
3869
4323
  get lastModified() {
3870
- return __privateGet(this, _lastModified);
4324
+ return this.#lastModified;
3871
4325
  }
3872
4326
  get [Symbol.toStringTag]() {
3873
4327
  return "File";
@@ -3875,13 +4329,13 @@ var init_file = __esm({
3875
4329
  static [Symbol.hasInstance](object) {
3876
4330
  return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
3877
4331
  }
3878
- }, _lastModified = new WeakMap(), _name = new WeakMap(), _a2);
3879
- File = _File;
3880
- file_default = File;
4332
+ };
4333
+ File2 = _File;
4334
+ file_default = File2;
3881
4335
  }
3882
4336
  });
3883
4337
 
3884
- // ../../node_modules/formdata-polyfill/esm.min.js
4338
+ // ../../../node_modules/formdata-polyfill/esm.min.js
3885
4339
  function formDataToBlob(F2, B = fetch_blob_default) {
3886
4340
  var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c = [], p = `--${b}\r
3887
4341
  Content-Disposition: form-data; name="`;
@@ -3895,9 +4349,9 @@ Content-Type: ${v.type || "application/octet-stream"}\r
3895
4349
  c.push(`--${b}--`);
3896
4350
  return new B(c, { type: "multipart/form-data; boundary=" + b });
3897
4351
  }
3898
- var t, i, h, r, m, f, e, x, _d, _a3, FormData;
4352
+ var t, i, h, r, m, f, e, x, FormData;
3899
4353
  var init_esm_min = __esm({
3900
- "../../node_modules/formdata-polyfill/esm.min.js"() {
4354
+ "../../../node_modules/formdata-polyfill/esm.min.js"() {
3901
4355
  init_fetch_blob();
3902
4356
  init_file();
3903
4357
  ({ toStringTag: t, iterator: i, hasInstance: h } = Symbol);
@@ -3910,9 +4364,9 @@ var init_esm_min = __esm({
3910
4364
  throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
3911
4365
  }
3912
4366
  };
3913
- FormData = (_a3 = class {
4367
+ FormData = class FormData2 {
4368
+ #d = [];
3914
4369
  constructor(...a) {
3915
- __privateAdd(this, _d, []);
3916
4370
  if (a.length)
3917
4371
  throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
3918
4372
  }
@@ -3927,17 +4381,17 @@ var init_esm_min = __esm({
3927
4381
  }
3928
4382
  append(...a) {
3929
4383
  x("append", arguments, 2);
3930
- __privateGet(this, _d).push(f(...a));
4384
+ this.#d.push(f(...a));
3931
4385
  }
3932
4386
  delete(a) {
3933
4387
  x("delete", arguments, 1);
3934
4388
  a += "";
3935
- __privateSet(this, _d, __privateGet(this, _d).filter(([b]) => b !== a));
4389
+ this.#d = this.#d.filter(([b]) => b !== a);
3936
4390
  }
3937
4391
  get(a) {
3938
4392
  x("get", arguments, 1);
3939
4393
  a += "";
3940
- for (var b = __privateGet(this, _d), l = b.length, c = 0; c < l; c++)
4394
+ for (var b = this.#d, l = b.length, c = 0; c < l; c++)
3941
4395
  if (b[c][0] === a)
3942
4396
  return b[c][1];
3943
4397
  return null;
@@ -3946,13 +4400,13 @@ var init_esm_min = __esm({
3946
4400
  x("getAll", arguments, 1);
3947
4401
  b = [];
3948
4402
  a += "";
3949
- __privateGet(this, _d).forEach((c) => c[0] === a && b.push(c[1]));
4403
+ this.#d.forEach((c) => c[0] === a && b.push(c[1]));
3950
4404
  return b;
3951
4405
  }
3952
4406
  has(a) {
3953
4407
  x("has", arguments, 1);
3954
4408
  a += "";
3955
- return __privateGet(this, _d).some((b) => b[0] === a);
4409
+ return this.#d.some((b) => b[0] === a);
3956
4410
  }
3957
4411
  forEach(a, b) {
3958
4412
  x("forEach", arguments, 1);
@@ -3963,14 +4417,14 @@ var init_esm_min = __esm({
3963
4417
  x("set", arguments, 2);
3964
4418
  var b = [], c = true;
3965
4419
  a = f(...a);
3966
- __privateGet(this, _d).forEach((d) => {
4420
+ this.#d.forEach((d) => {
3967
4421
  d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
3968
4422
  });
3969
4423
  c && b.push(a);
3970
- __privateSet(this, _d, b);
4424
+ this.#d = b;
3971
4425
  }
3972
4426
  *entries() {
3973
- yield* __privateGet(this, _d);
4427
+ yield* this.#d;
3974
4428
  }
3975
4429
  *keys() {
3976
4430
  for (var [a] of this)
@@ -3980,13 +4434,13 @@ var init_esm_min = __esm({
3980
4434
  for (var [, a] of this)
3981
4435
  yield a;
3982
4436
  }
3983
- }, _d = new WeakMap(), _a3);
4437
+ };
3984
4438
  }
3985
4439
  });
3986
4440
 
3987
- // ../../node_modules/node-domexception/index.js
4441
+ // ../../../node_modules/node-domexception/index.js
3988
4442
  var require_node_domexception = __commonJS({
3989
- "../../node_modules/node-domexception/index.js"(exports, module2) {
4443
+ "../../../node_modules/node-domexception/index.js"(exports, module2) {
3990
4444
  if (!globalThis.DOMException) {
3991
4445
  try {
3992
4446
  const { MessageChannel } = require("worker_threads"), port = new MessageChannel().port1, ab = new ArrayBuffer();
@@ -3999,49 +4453,46 @@ var require_node_domexception = __commonJS({
3999
4453
  }
4000
4454
  });
4001
4455
 
4002
- // ../../node_modules/fetch-blob/from.js
4003
- var import_node_fs, import_node_domexception, stat, _path, _start, _BlobDataItem, BlobDataItem;
4456
+ // ../../../node_modules/fetch-blob/from.js
4457
+ var import_node_fs, import_node_domexception, stat, BlobDataItem;
4004
4458
  var init_from = __esm({
4005
- "../../node_modules/fetch-blob/from.js"() {
4006
- import_node_fs = require("fs");
4459
+ "../../../node_modules/fetch-blob/from.js"() {
4460
+ import_node_fs = require("node:fs");
4007
4461
  import_node_domexception = __toESM(require_node_domexception(), 1);
4008
4462
  init_file();
4009
4463
  init_fetch_blob();
4010
4464
  ({ stat } = import_node_fs.promises);
4011
- _BlobDataItem = class {
4465
+ BlobDataItem = class {
4466
+ #path;
4467
+ #start;
4012
4468
  constructor(options) {
4013
- __privateAdd(this, _path, void 0);
4014
- __privateAdd(this, _start, void 0);
4015
- __privateSet(this, _path, options.path);
4016
- __privateSet(this, _start, options.start);
4469
+ this.#path = options.path;
4470
+ this.#start = options.start;
4017
4471
  this.size = options.size;
4018
4472
  this.lastModified = options.lastModified;
4019
4473
  }
4020
4474
  slice(start, end) {
4021
- return new _BlobDataItem({
4022
- path: __privateGet(this, _path),
4475
+ return new BlobDataItem({
4476
+ path: this.#path,
4023
4477
  lastModified: this.lastModified,
4024
4478
  size: end - start,
4025
- start: __privateGet(this, _start) + start
4479
+ start: this.#start + start
4026
4480
  });
4027
4481
  }
4028
4482
  async *stream() {
4029
- const { mtimeMs } = await stat(__privateGet(this, _path));
4483
+ const { mtimeMs } = await stat(this.#path);
4030
4484
  if (mtimeMs > this.lastModified) {
4031
4485
  throw new import_node_domexception.default("The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired.", "NotReadableError");
4032
4486
  }
4033
- yield* (0, import_node_fs.createReadStream)(__privateGet(this, _path), {
4034
- start: __privateGet(this, _start),
4035
- end: __privateGet(this, _start) + this.size - 1
4487
+ yield* (0, import_node_fs.createReadStream)(this.#path, {
4488
+ start: this.#start,
4489
+ end: this.#start + this.size - 1
4036
4490
  });
4037
4491
  }
4038
4492
  get [Symbol.toStringTag]() {
4039
4493
  return "Blob";
4040
4494
  }
4041
4495
  };
4042
- BlobDataItem = _BlobDataItem;
4043
- _path = new WeakMap();
4044
- _start = new WeakMap();
4045
4496
  }
4046
4497
  });
4047
4498
 
@@ -4412,24 +4863,21 @@ function fetchWithoutToken(client, url, init = {}) {
4412
4863
  } else if (!headers.has("content-type")) {
4413
4864
  headers.append("content-type", "application/json");
4414
4865
  }
4415
- return client.fetch(url, {
4416
- ...init,
4866
+ return client.fetch(url, __spreadProps(__spreadValues({}, init), {
4417
4867
  headers
4418
- });
4868
+ }));
4419
4869
  }
4420
4870
  function fetchWithToken(client, url, init = {}) {
4421
4871
  return client.getAuthorizationHeader().then((header) => {
4422
4872
  if (!init.headers) {
4423
4873
  init.headers = {};
4424
4874
  }
4425
- const headers = {
4426
- ...init.headers,
4875
+ const headers = __spreadProps(__spreadValues({}, init.headers), {
4427
4876
  authorization: header
4428
- };
4429
- return fetchWithoutToken(client, url, {
4430
- ...init,
4431
- headers
4432
4877
  });
4878
+ return fetchWithoutToken(client, url, __spreadProps(__spreadValues({}, init), {
4879
+ headers
4880
+ }));
4433
4881
  });
4434
4882
  }
4435
4883
 
@@ -4438,8 +4886,7 @@ function getJsonResponse(res) {
4438
4886
  const json = res.json();
4439
4887
  if (!res.ok) {
4440
4888
  return json.then((err) => {
4441
- var _a4;
4442
- throw new Error((_a4 = err == null ? void 0 : err.message) != null ? _a4 : res.statusText);
4889
+ throw new Error((err == null ? void 0 : err.message) ?? res.statusText);
4443
4890
  });
4444
4891
  }
4445
4892
  return json;
@@ -4476,20 +4923,20 @@ var FeedServiceApiClient = class {
4476
4923
  return fetchWithToken(this.http, this.getUrl(path), init).then(getJsonResponse);
4477
4924
  }
4478
4925
  doGet(path, init = {}) {
4479
- return this.doAny(path, { ...init, method: "GET" });
4926
+ return this.doAny(path, __spreadProps(__spreadValues({}, init), { method: "GET" }));
4480
4927
  }
4481
4928
  doPost(path, content, init = {}) {
4482
- const { FormData: FormData2 } = this.http;
4483
- const body = content instanceof FormData2 ? content : JSON.stringify(content);
4484
- return this.doAny(path, { ...init, method: "POST", body });
4929
+ const { FormData: FormData3 } = this.http;
4930
+ const body = content instanceof FormData3 ? content : JSON.stringify(content);
4931
+ return this.doAny(path, __spreadProps(__spreadValues({}, init), { method: "POST", body }));
4485
4932
  }
4486
4933
  doPut(path, content, init = {}) {
4487
- const { FormData: FormData2 } = this.http;
4488
- const body = content instanceof FormData2 ? content : JSON.stringify(content);
4489
- return this.doAny(path, { ...init, method: "PUT", body });
4934
+ const { FormData: FormData3 } = this.http;
4935
+ const body = content instanceof FormData3 ? content : JSON.stringify(content);
4936
+ return this.doAny(path, __spreadProps(__spreadValues({}, init), { method: "PUT", body }));
4490
4937
  }
4491
4938
  doDelete(path, init = {}) {
4492
- return this.doAny(path, { ...init, method: "DELETE" });
4939
+ return this.doAny(path, __spreadProps(__spreadValues({}, init), { method: "DELETE" }));
4493
4940
  }
4494
4941
  getPilets(ac = mac()) {
4495
4942
  return this.doQueryCurrentPilets("cloud", ac);
@@ -4507,8 +4954,8 @@ var FeedServiceApiClient = class {
4507
4954
  return this.doPut(`feed/${feed}/page/${version}?tag=${tag}`, content, mri(ac));
4508
4955
  }
4509
4956
  doPublishPage(feed, content, ac = mac()) {
4510
- const { FormData: FormData2 } = this.http;
4511
- const form = new FormData2();
4957
+ const { FormData: FormData3 } = this.http;
4958
+ const form = new FormData3();
4512
4959
  form.append("version", content.version);
4513
4960
  form.append("type", content.type);
4514
4961
  form.append("embed", content.embed);
@@ -4534,8 +4981,8 @@ var FeedServiceApiClient = class {
4534
4981
  return this.doGet(`feed/${feed}/pilets/${name}/versions?${queryString}`, mri(ac));
4535
4982
  }
4536
4983
  doPublishPilet(feed, tag, file, ac = mac()) {
4537
- const { FormData: FormData2 } = this.http;
4538
- const form = new FormData2();
4984
+ const { FormData: FormData3 } = this.http;
4985
+ const form = new FormData3();
4539
4986
  form.append("file", file);
4540
4987
  form.append("tag", tag);
4541
4988
  return this.doPost(`pilet/${feed}`, form, mri(ac));
@@ -4866,13 +5313,13 @@ var FeedServiceApiClient = class {
4866
5313
  };
4867
5314
 
4868
5315
  // node_modules/node-fetch/src/index.js
4869
- var import_node_http2 = __toESM(require("http"), 1);
4870
- var import_node_https = __toESM(require("https"), 1);
4871
- var import_node_zlib = __toESM(require("zlib"), 1);
4872
- var import_node_stream2 = __toESM(require("stream"), 1);
4873
- var import_node_buffer2 = require("buffer");
5316
+ var import_node_http2 = __toESM(require("node:http"), 1);
5317
+ var import_node_https = __toESM(require("node:https"), 1);
5318
+ var import_node_zlib = __toESM(require("node:zlib"), 1);
5319
+ var import_node_stream2 = __toESM(require("node:stream"), 1);
5320
+ var import_node_buffer2 = require("node:buffer");
4874
5321
 
4875
- // ../../node_modules/data-uri-to-buffer/dist/index.js
5322
+ // ../../../node_modules/data-uri-to-buffer/dist/index.js
4876
5323
  function dataUriToBuffer(uri) {
4877
5324
  if (!/^data:/i.test(uri)) {
4878
5325
  throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
@@ -4890,7 +5337,7 @@ function dataUriToBuffer(uri) {
4890
5337
  for (let i2 = 1; i2 < meta.length; i2++) {
4891
5338
  if (meta[i2] === "base64") {
4892
5339
  base64 = true;
4893
- } else {
5340
+ } else if (meta[i2]) {
4894
5341
  typeFull += `;${meta[i2]}`;
4895
5342
  if (meta[i2].indexOf("charset=") === 0) {
4896
5343
  charset = meta[i2].substring(8);
@@ -4912,9 +5359,9 @@ function dataUriToBuffer(uri) {
4912
5359
  var dist_default = dataUriToBuffer;
4913
5360
 
4914
5361
  // node_modules/node-fetch/src/body.js
4915
- var import_node_stream = __toESM(require("stream"), 1);
4916
- var import_node_util = require("util");
4917
- var import_node_buffer = require("buffer");
5362
+ var import_node_stream = __toESM(require("node:stream"), 1);
5363
+ var import_node_util = require("node:util");
5364
+ var import_node_buffer = require("node:buffer");
4918
5365
  init_fetch_blob();
4919
5366
  init_esm_min();
4920
5367
 
@@ -5062,12 +5509,8 @@ Object.defineProperties(Body.prototype, {
5062
5509
  blob: { enumerable: true },
5063
5510
  json: { enumerable: true },
5064
5511
  text: { enumerable: true },
5065
- data: { get: (0, import_node_util.deprecate)(
5066
- () => {
5067
- },
5068
- "data doesn't exist, use json(), text(), arrayBuffer(), or body instead",
5069
- "https://github.com/node-fetch/node-fetch/issues/1000 (response)"
5070
- ) }
5512
+ data: { get: (0, import_node_util.deprecate)(() => {
5513
+ }, "data doesn't exist, use json(), text(), arrayBuffer(), or body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (response)") }
5071
5514
  });
5072
5515
  async function consumeBody(data) {
5073
5516
  if (data[INTERNALS].disturbed) {
@@ -5130,11 +5573,7 @@ var clone = (instance, highWaterMark) => {
5130
5573
  }
5131
5574
  return body;
5132
5575
  };
5133
- var getNonSpecFormDataBoundary = (0, import_node_util.deprecate)(
5134
- (body) => body.getBoundary(),
5135
- "form-data doesn't follow the spec and requires special treatment. Use alternative package",
5136
- "https://github.com/node-fetch/node-fetch/issues/1167"
5137
- );
5576
+ var getNonSpecFormDataBoundary = (0, import_node_util.deprecate)((body) => body.getBoundary(), "form-data doesn't follow the spec and requires special treatment. Use alternative package", "https://github.com/node-fetch/node-fetch/issues/1167");
5138
5577
  var extractContentType = (body, request) => {
5139
5578
  if (body === null) {
5140
5579
  return null;
@@ -5187,8 +5626,8 @@ var writeToStream = async (dest, { body }) => {
5187
5626
  };
5188
5627
 
5189
5628
  // node_modules/node-fetch/src/headers.js
5190
- var import_node_util2 = require("util");
5191
- var import_node_http = __toESM(require("http"), 1);
5629
+ var import_node_util2 = require("node:util");
5630
+ var import_node_http = __toESM(require("node:http"), 1);
5192
5631
  var validateHeaderName = typeof import_node_http.default.validateHeaderName === "function" ? import_node_http.default.validateHeaderName : (name) => {
5193
5632
  if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) {
5194
5633
  const error = new TypeError(`Header name must be a valid HTTP token [${name}]`);
@@ -5249,21 +5688,14 @@ var Headers = class extends URLSearchParams {
5249
5688
  return (name, value) => {
5250
5689
  validateHeaderName(name);
5251
5690
  validateHeaderValue(name, String(value));
5252
- return URLSearchParams.prototype[p].call(
5253
- target,
5254
- String(name).toLowerCase(),
5255
- String(value)
5256
- );
5691
+ return URLSearchParams.prototype[p].call(target, String(name).toLowerCase(), String(value));
5257
5692
  };
5258
5693
  case "delete":
5259
5694
  case "has":
5260
5695
  case "getAll":
5261
5696
  return (name) => {
5262
5697
  validateHeaderName(name);
5263
- return URLSearchParams.prototype[p].call(
5264
- target,
5265
- String(name).toLowerCase()
5266
- );
5698
+ return URLSearchParams.prototype[p].call(target, String(name).toLowerCase());
5267
5699
  };
5268
5700
  case "keys":
5269
5701
  return () => {
@@ -5329,30 +5761,25 @@ var Headers = class extends URLSearchParams {
5329
5761
  }, {});
5330
5762
  }
5331
5763
  };
5332
- Object.defineProperties(
5333
- Headers.prototype,
5334
- ["get", "entries", "forEach", "values"].reduce((result, property) => {
5335
- result[property] = { enumerable: true };
5336
- return result;
5337
- }, {})
5338
- );
5764
+ Object.defineProperties(Headers.prototype, ["get", "entries", "forEach", "values"].reduce((result, property) => {
5765
+ result[property] = { enumerable: true };
5766
+ return result;
5767
+ }, {}));
5339
5768
  function fromRawHeaders(headers = []) {
5340
- return new Headers(
5341
- headers.reduce((result, value, index, array) => {
5342
- if (index % 2 === 0) {
5343
- result.push(array.slice(index, index + 2));
5344
- }
5345
- return result;
5346
- }, []).filter(([name, value]) => {
5347
- try {
5348
- validateHeaderName(name);
5349
- validateHeaderValue(name, String(value));
5350
- return true;
5351
- } catch {
5352
- return false;
5353
- }
5354
- })
5355
- );
5769
+ return new Headers(headers.reduce((result, value, index, array) => {
5770
+ if (index % 2 === 0) {
5771
+ result.push(array.slice(index, index + 2));
5772
+ }
5773
+ return result;
5774
+ }, []).filter(([name, value]) => {
5775
+ try {
5776
+ validateHeaderName(name);
5777
+ validateHeaderValue(name, String(value));
5778
+ return true;
5779
+ } catch {
5780
+ return false;
5781
+ }
5782
+ }));
5356
5783
  }
5357
5784
 
5358
5785
  // node_modules/node-fetch/src/utils/is-redirect.js
@@ -5446,10 +5873,9 @@ var Response = class extends Body {
5446
5873
  if (!headers.has("content-type")) {
5447
5874
  headers.set("content-type", "application/json");
5448
5875
  }
5449
- return new Response(body, {
5450
- ...init,
5876
+ return new Response(body, __spreadProps(__spreadValues({}, init), {
5451
5877
  headers
5452
- });
5878
+ }));
5453
5879
  }
5454
5880
  get [Symbol.toStringTag]() {
5455
5881
  return "Response";
@@ -5467,8 +5893,8 @@ Object.defineProperties(Response.prototype, {
5467
5893
  });
5468
5894
 
5469
5895
  // node_modules/node-fetch/src/request.js
5470
- var import_node_url = require("url");
5471
- var import_node_util3 = require("util");
5896
+ var import_node_url = require("node:url");
5897
+ var import_node_util3 = require("node:util");
5472
5898
 
5473
5899
  // node_modules/node-fetch/src/utils/get-search.js
5474
5900
  var getSearch = (parsedURL) => {
@@ -5481,7 +5907,7 @@ var getSearch = (parsedURL) => {
5481
5907
  };
5482
5908
 
5483
5909
  // node_modules/node-fetch/src/utils/referrer.js
5484
- var import_node_net = require("net");
5910
+ var import_node_net = require("node:net");
5485
5911
  function stripURLForUseAsAReferrer(url, originOnly = false) {
5486
5912
  if (url == null) {
5487
5913
  return "no-referrer";
@@ -5625,12 +6051,8 @@ var INTERNALS3 = Symbol("Request internals");
5625
6051
  var isRequest = (object) => {
5626
6052
  return typeof object === "object" && typeof object[INTERNALS3] === "object";
5627
6053
  };
5628
- var doBadDataWarn = (0, import_node_util3.deprecate)(
5629
- () => {
5630
- },
5631
- ".data is not a valid RequestInit property, use .body instead",
5632
- "https://github.com/node-fetch/node-fetch/issues/1000 (request)"
5633
- );
6054
+ var doBadDataWarn = (0, import_node_util3.deprecate)(() => {
6055
+ }, ".data is not a valid RequestInit property, use .body instead", "https://github.com/node-fetch/node-fetch/issues/1000 (request)");
5634
6056
  var Request = class extends Body {
5635
6057
  constructor(input, init = {}) {
5636
6058
  let parsedURL;
@@ -5786,9 +6208,6 @@ var getNodeRequestOptions = (request) => {
5786
6208
  if (typeof agent === "function") {
5787
6209
  agent = agent(parsedURL);
5788
6210
  }
5789
- if (!headers.has("Connection") && !agent) {
5790
- headers.set("Connection", "close");
5791
- }
5792
6211
  const search = getSearch(parsedURL);
5793
6212
  const options = {
5794
6213
  path: parsedURL.pathname + search,
@@ -6137,3 +6556,10 @@ function createServiceClient(options) {
6137
6556
  /*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
6138
6557
  /*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
6139
6558
  /*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
6559
+ /**
6560
+ * @license
6561
+ * web-streams-polyfill v3.3.2
6562
+ * Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
6563
+ * This code is released under the MIT license.
6564
+ * SPDX-License-Identifier: MIT
6565
+ */