UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3,857 lines • 147 kB
import { a as __require, n as __esmMin, s as __toESM, t as __commonJSMin } from "./rolldown-runtime-C_OpTf0N.mjs";
import { createReadStream, promises, statSync } from "node:fs";
import { basename } from "node:path";
//#region node_modules/.pnpm/web-streams-polyfill@3.3.3/node_modules/web-streams-polyfill/dist/ponyfill.es2018.js
var require_ponyfill_es2018 = /* @__PURE__ */ __commonJSMin(((n, a, o) => {
	/**
	* @license
	* web-streams-polyfill v3.3.3
	* Copyright 2024 Mattias Buelens, Diwank Singh Tomer and other contributors.
	* This code is released under the MIT license.
	* SPDX-License-Identifier: MIT
	*/
	(function(o, s) {
		typeof n === "object" && typeof a !== "undefined" ? s(n) : typeof define === "function" && define.amd ? define(["exports"], s) : (o = typeof globalThis !== "undefined" ? globalThis : o || self, s(o.WebStreamsPolyfill = {}));
	})(o, (function(n) {
		"use strict";
		function noop() {}
		function typeIsObject(n) {
			return typeof n === "object" && n !== null || typeof n === "function";
		}
		const a = noop;
		function setFunctionName(n, a) {
			try {
				Object.defineProperty(n, "name", {
					value: a,
					configurable: true
				});
			} catch (n) {}
		}
		const o = Promise;
		const s = Promise.prototype.then;
		const c = Promise.reject.bind(o);
		function newPromise(n) {
			return new o(n);
		}
		function promiseResolvedWith(n) {
			return newPromise((a) => a(n));
		}
		function promiseRejectedWith(n) {
			return c(n);
		}
		function PerformPromiseThen(n, a, o) {
			return s.call(n, a, o);
		}
		function uponPromise(n, o, s) {
			PerformPromiseThen(PerformPromiseThen(n, o, s), void 0, a);
		}
		function uponFulfillment(n, a) {
			uponPromise(n, a);
		}
		function uponRejection(n, a) {
			uponPromise(n, void 0, a);
		}
		function transformPromiseWith(n, a, o) {
			return PerformPromiseThen(n, a, o);
		}
		function setPromiseIsHandledToTrue(n) {
			PerformPromiseThen(n, void 0, a);
		}
		let _queueMicrotask = (n) => {
			if (typeof queueMicrotask === "function") _queueMicrotask = queueMicrotask;
			else {
				const n = promiseResolvedWith(void 0);
				_queueMicrotask = (a) => PerformPromiseThen(n, a);
			}
			return _queueMicrotask(n);
		};
		function reflectCall(n, a, o) {
			if (typeof n !== "function") throw new TypeError("Argument is not a function");
			return Function.prototype.apply.call(n, a, o);
		}
		function promiseCall(n, a, o) {
			try {
				return promiseResolvedWith(reflectCall(n, a, o));
			} catch (n) {
				return promiseRejectedWith(n);
			}
		}
		const l = 16384;
		/**
		* Simple queue structure.
		*
		* Avoids scalability issues with using a packed array directly by using
		* multiple arrays in a linked list and keeping the array size bounded.
		*/
		class SimpleQueue {
			constructor() {
				this._cursor = 0;
				this._size = 0;
				this._front = {
					_elements: [],
					_next: void 0
				};
				this._back = this._front;
				this._cursor = 0;
				this._size = 0;
			}
			get length() {
				return this._size;
			}
			push(n) {
				const a = this._back;
				let o = a;
				if (a._elements.length === 16383) o = {
					_elements: [],
					_next: void 0
				};
				a._elements.push(n);
				if (o !== a) {
					this._back = o;
					a._next = o;
				}
				++this._size;
			}
			shift() {
				const n = this._front;
				let a = n;
				const o = this._cursor;
				let s = o + 1;
				const c = n._elements;
				const u = c[o];
				if (s === l) {
					a = n._next;
					s = 0;
				}
				--this._size;
				this._cursor = s;
				if (n !== a) this._front = a;
				c[o] = void 0;
				return u;
			}
			forEach(n) {
				let a = this._cursor;
				let o = this._front;
				let s = o._elements;
				while (a !== s.length || o._next !== void 0) {
					if (a === s.length) {
						o = o._next;
						s = o._elements;
						a = 0;
						if (s.length === 0) break;
					}
					n(s[a]);
					++a;
				}
			}
			peek() {
				const n = this._front;
				const a = this._cursor;
				return n._elements[a];
			}
		}
		const u = Symbol("[[AbortSteps]]");
		const d = Symbol("[[ErrorSteps]]");
		const p = Symbol("[[CancelSteps]]");
		const g = Symbol("[[PullSteps]]");
		const _ = Symbol("[[ReleaseSteps]]");
		function ReadableStreamReaderGenericInitialize(n, a) {
			n._ownerReadableStream = a;
			a._reader = n;
			if (a._state === "readable") defaultReaderClosedPromiseInitialize(n);
			else if (a._state === "closed") defaultReaderClosedPromiseInitializeAsResolved(n);
			else defaultReaderClosedPromiseInitializeAsRejected(n, a._storedError);
		}
		function ReadableStreamReaderGenericCancel(n, a) {
			const o = n._ownerReadableStream;
			return ReadableStreamCancel(o, a);
		}
		function ReadableStreamReaderGenericRelease(n) {
			const a = n._ownerReadableStream;
			if (a._state === "readable") defaultReaderClosedPromiseReject(n, /* @__PURE__ */ new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
			else defaultReaderClosedPromiseResetToRejected(n, /* @__PURE__ */ new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`));
			a._readableStreamController[_]();
			a._reader = void 0;
			n._ownerReadableStream = void 0;
		}
		function readerLockException(n) {
			return /* @__PURE__ */ new TypeError("Cannot " + n + " a stream using a released reader");
		}
		function defaultReaderClosedPromiseInitialize(n) {
			n._closedPromise = newPromise((a, o) => {
				n._closedPromise_resolve = a;
				n._closedPromise_reject = o;
			});
		}
		function defaultReaderClosedPromiseInitializeAsRejected(n, a) {
			defaultReaderClosedPromiseInitialize(n);
			defaultReaderClosedPromiseReject(n, a);
		}
		function defaultReaderClosedPromiseInitializeAsResolved(n) {
			defaultReaderClosedPromiseInitialize(n);
			defaultReaderClosedPromiseResolve(n);
		}
		function defaultReaderClosedPromiseReject(n, a) {
			if (n._closedPromise_reject === void 0) return;
			setPromiseIsHandledToTrue(n._closedPromise);
			n._closedPromise_reject(a);
			n._closedPromise_resolve = void 0;
			n._closedPromise_reject = void 0;
		}
		function defaultReaderClosedPromiseResetToRejected(n, a) {
			defaultReaderClosedPromiseInitializeAsRejected(n, a);
		}
		function defaultReaderClosedPromiseResolve(n) {
			if (n._closedPromise_resolve === void 0) return;
			n._closedPromise_resolve(void 0);
			n._closedPromise_resolve = void 0;
			n._closedPromise_reject = void 0;
		}
		const v = Number.isFinite || function(n) {
			return typeof n === "number" && isFinite(n);
		};
		const y = Math.trunc || function(n) {
			return n < 0 ? Math.ceil(n) : Math.floor(n);
		};
		function isDictionary(n) {
			return typeof n === "object" || typeof n === "function";
		}
		function assertDictionary(n, a) {
			if (n !== void 0 && !isDictionary(n)) throw new TypeError(`${a} is not an object.`);
		}
		function assertFunction(n, a) {
			if (typeof n !== "function") throw new TypeError(`${a} is not a function.`);
		}
		function isObject(n) {
			return typeof n === "object" && n !== null || typeof n === "function";
		}
		function assertObject(n, a) {
			if (!isObject(n)) throw new TypeError(`${a} is not an object.`);
		}
		function assertRequiredArgument(n, a, o) {
			if (n === void 0) throw new TypeError(`Parameter ${a} is required in '${o}'.`);
		}
		function assertRequiredField(n, a, o) {
			if (n === void 0) throw new TypeError(`${a} is required in '${o}'.`);
		}
		function convertUnrestrictedDouble(n) {
			return Number(n);
		}
		function censorNegativeZero(n) {
			return n === 0 ? 0 : n;
		}
		function integerPart(n) {
			return censorNegativeZero(y(n));
		}
		function convertUnsignedLongLongWithEnforceRange(n, a) {
			const o = 0;
			const s = Number.MAX_SAFE_INTEGER;
			let c = Number(n);
			c = censorNegativeZero(c);
			if (!v(c)) throw new TypeError(`${a} is not a finite number`);
			c = integerPart(c);
			if (c < o || c > s) throw new TypeError(`${a} is outside the accepted range of ${o} to ${s}, inclusive`);
			if (!v(c) || c === 0) return 0;
			return c;
		}
		function assertReadableStream(n, a) {
			if (!IsReadableStream(n)) throw new TypeError(`${a} is not a ReadableStream.`);
		}
		function AcquireReadableStreamDefaultReader(n) {
			return new ReadableStreamDefaultReader(n);
		}
		function ReadableStreamAddReadRequest(n, a) {
			n._reader._readRequests.push(a);
		}
		function ReadableStreamFulfillReadRequest(n, a, o) {
			const s = n._reader._readRequests.shift();
			if (o) s._closeSteps();
			else s._chunkSteps(a);
		}
		function ReadableStreamGetNumReadRequests(n) {
			return n._reader._readRequests.length;
		}
		function ReadableStreamHasDefaultReader(n) {
			const a = n._reader;
			if (a === void 0) return false;
			if (!IsReadableStreamDefaultReader(a)) return false;
			return true;
		}
		/**
		* A default reader vended by a {@link ReadableStream}.
		*
		* @public
		*/
		class ReadableStreamDefaultReader {
			constructor(n) {
				assertRequiredArgument(n, 1, "ReadableStreamDefaultReader");
				assertReadableStream(n, "First parameter");
				if (IsReadableStreamLocked(n)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
				ReadableStreamReaderGenericInitialize(this, n);
				this._readRequests = new SimpleQueue();
			}
			/**
			* Returns a promise that will be fulfilled when the stream becomes closed,
			* or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing.
			*/
			get closed() {
				if (!IsReadableStreamDefaultReader(this)) return promiseRejectedWith(defaultReaderBrandCheckException("closed"));
				return this._closedPromise;
			}
			/**
			* If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
			*/
			cancel(n = void 0) {
				if (!IsReadableStreamDefaultReader(this)) return promiseRejectedWith(defaultReaderBrandCheckException("cancel"));
				if (this._ownerReadableStream === void 0) return promiseRejectedWith(readerLockException("cancel"));
				return ReadableStreamReaderGenericCancel(this, n);
			}
			/**
			* Returns a promise that allows access to the next chunk from the stream's internal queue, if available.
			*
			* If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source.
			*/
			read() {
				if (!IsReadableStreamDefaultReader(this)) return promiseRejectedWith(defaultReaderBrandCheckException("read"));
				if (this._ownerReadableStream === void 0) return promiseRejectedWith(readerLockException("read from"));
				let n;
				let a;
				const o = newPromise((o, s) => {
					n = o;
					a = s;
				});
				ReadableStreamDefaultReaderRead(this, {
					_chunkSteps: (a) => n({
						value: a,
						done: false
					}),
					_closeSteps: () => n({
						value: void 0,
						done: true
					}),
					_errorSteps: (n) => a(n)
				});
				return o;
			}
			/**
			* Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
			* If the associated stream is errored when the lock is released, the reader will appear errored in the same way
			* from now on; otherwise, the reader will appear closed.
			*
			* A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
			* the reader's {@link ReadableStreamDefaultReader.read | read()} method has not yet been settled. Attempting to
			* do so will throw a `TypeError` and leave the reader locked to the stream.
			*/
			releaseLock() {
				if (!IsReadableStreamDefaultReader(this)) throw defaultReaderBrandCheckException("releaseLock");
				if (this._ownerReadableStream === void 0) return;
				ReadableStreamDefaultReaderRelease(this);
			}
		}
		Object.defineProperties(ReadableStreamDefaultReader.prototype, {
			cancel: { enumerable: true },
			read: { enumerable: true },
			releaseLock: { enumerable: true },
			closed: { enumerable: true }
		});
		setFunctionName(ReadableStreamDefaultReader.prototype.cancel, "cancel");
		setFunctionName(ReadableStreamDefaultReader.prototype.read, "read");
		setFunctionName(ReadableStreamDefaultReader.prototype.releaseLock, "releaseLock");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, {
			value: "ReadableStreamDefaultReader",
			configurable: true
		});
		function IsReadableStreamDefaultReader(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_readRequests")) return false;
			return n instanceof ReadableStreamDefaultReader;
		}
		function ReadableStreamDefaultReaderRead(n, a) {
			const o = n._ownerReadableStream;
			o._disturbed = true;
			if (o._state === "closed") a._closeSteps();
			else if (o._state === "errored") a._errorSteps(o._storedError);
			else o._readableStreamController[g](a);
		}
		function ReadableStreamDefaultReaderRelease(n) {
			ReadableStreamReaderGenericRelease(n);
			ReadableStreamDefaultReaderErrorReadRequests(n, /* @__PURE__ */ new TypeError("Reader was released"));
		}
		function ReadableStreamDefaultReaderErrorReadRequests(n, a) {
			const o = n._readRequests;
			n._readRequests = new SimpleQueue();
			o.forEach((n) => {
				n._errorSteps(a);
			});
		}
		function defaultReaderBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`ReadableStreamDefaultReader.prototype.${n} can only be used on a ReadableStreamDefaultReader`);
		}
		const b = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {}).prototype);
		class ReadableStreamAsyncIteratorImpl {
			constructor(n, a) {
				this._ongoingPromise = void 0;
				this._isFinished = false;
				this._reader = n;
				this._preventCancel = a;
			}
			next() {
				const nextSteps = () => this._nextSteps();
				this._ongoingPromise = this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, nextSteps, nextSteps) : nextSteps();
				return this._ongoingPromise;
			}
			return(n) {
				const returnSteps = () => this._returnSteps(n);
				return this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, returnSteps, returnSteps) : returnSteps();
			}
			_nextSteps() {
				if (this._isFinished) return Promise.resolve({
					value: void 0,
					done: true
				});
				const n = this._reader;
				let a;
				let o;
				const s = newPromise((n, s) => {
					a = n;
					o = s;
				});
				ReadableStreamDefaultReaderRead(n, {
					_chunkSteps: (n) => {
						this._ongoingPromise = void 0;
						_queueMicrotask(() => a({
							value: n,
							done: false
						}));
					},
					_closeSteps: () => {
						this._ongoingPromise = void 0;
						this._isFinished = true;
						ReadableStreamReaderGenericRelease(n);
						a({
							value: void 0,
							done: true
						});
					},
					_errorSteps: (a) => {
						this._ongoingPromise = void 0;
						this._isFinished = true;
						ReadableStreamReaderGenericRelease(n);
						o(a);
					}
				});
				return s;
			}
			_returnSteps(n) {
				if (this._isFinished) return Promise.resolve({
					value: n,
					done: true
				});
				this._isFinished = true;
				const a = this._reader;
				if (!this._preventCancel) {
					const o = ReadableStreamReaderGenericCancel(a, n);
					ReadableStreamReaderGenericRelease(a);
					return transformPromiseWith(o, () => ({
						value: n,
						done: true
					}));
				}
				ReadableStreamReaderGenericRelease(a);
				return promiseResolvedWith({
					value: n,
					done: true
				});
			}
		}
		const S = {
			next() {
				if (!IsReadableStreamAsyncIterator(this)) return promiseRejectedWith(streamAsyncIteratorBrandCheckException("next"));
				return this._asyncIteratorImpl.next();
			},
			return(n) {
				if (!IsReadableStreamAsyncIterator(this)) return promiseRejectedWith(streamAsyncIteratorBrandCheckException("return"));
				return this._asyncIteratorImpl.return(n);
			}
		};
		Object.setPrototypeOf(S, b);
		function AcquireReadableStreamAsyncIterator(n, a) {
			const o = AcquireReadableStreamDefaultReader(n);
			const s = new ReadableStreamAsyncIteratorImpl(o, a);
			const c = Object.create(S);
			c._asyncIteratorImpl = s;
			return c;
		}
		function IsReadableStreamAsyncIterator(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_asyncIteratorImpl")) return false;
			try {
				return n._asyncIteratorImpl instanceof ReadableStreamAsyncIteratorImpl;
			} catch (n) {
				return false;
			}
		}
		function streamAsyncIteratorBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`ReadableStreamAsyncIterator.${n} can only be used on a ReadableSteamAsyncIterator`);
		}
		const C = Number.isNaN || function(n) {
			return n !== n;
		};
		var w, T, E;
		function CreateArrayFromList(n) {
			return n.slice();
		}
		function CopyDataBlockBytes(n, a, o, s, c) {
			new Uint8Array(n).set(new Uint8Array(o, s, c), a);
		}
		let TransferArrayBuffer = (n) => {
			if (typeof n.transfer === "function") TransferArrayBuffer = (n) => n.transfer();
			else if (typeof structuredClone === "function") TransferArrayBuffer = (n) => structuredClone(n, { transfer: [n] });
			else TransferArrayBuffer = (n) => n;
			return TransferArrayBuffer(n);
		};
		let IsDetachedBuffer = (n) => {
			if (typeof n.detached === "boolean") IsDetachedBuffer = (n) => n.detached;
			else IsDetachedBuffer = (n) => n.byteLength === 0;
			return IsDetachedBuffer(n);
		};
		function ArrayBufferSlice(n, a, o) {
			if (n.slice) return n.slice(a, o);
			const s = o - a;
			const c = new ArrayBuffer(s);
			CopyDataBlockBytes(c, 0, n, a, s);
			return c;
		}
		function GetMethod(n, a) {
			const o = n[a];
			if (o === void 0 || o === null) return;
			if (typeof o !== "function") throw new TypeError(`${String(a)} is not a function`);
			return o;
		}
		function CreateAsyncFromSyncIterator(n) {
			const a = { [Symbol.iterator]: () => n.iterator };
			const o = async function* () {
				return yield* a;
			}();
			return {
				iterator: o,
				nextMethod: o.next,
				done: false
			};
		}
		const D = (E = (w = Symbol.asyncIterator) !== null && w !== void 0 ? w : (T = Symbol.for) === null || T === void 0 ? void 0 : T.call(Symbol, "Symbol.asyncIterator")) !== null && E !== void 0 ? E : "@@asyncIterator";
		function GetIterator(n, a = "sync", o) {
			if (o === void 0) {
				if (a === "async") {
					o = GetMethod(n, D);
					if (o === void 0) return CreateAsyncFromSyncIterator(GetIterator(n, "sync", GetMethod(n, Symbol.iterator)));
				} else o = GetMethod(n, Symbol.iterator);
			}
			if (o === void 0) throw new TypeError("The object is not iterable");
			const s = reflectCall(o, n, []);
			if (!typeIsObject(s)) throw new TypeError("The iterator method must return an object");
			return {
				iterator: s,
				nextMethod: s.next,
				done: false
			};
		}
		function IteratorNext(n) {
			const a = reflectCall(n.nextMethod, n.iterator, []);
			if (!typeIsObject(a)) throw new TypeError("The iterator.next() method must return an object");
			return a;
		}
		function IteratorComplete(n) {
			return Boolean(n.done);
		}
		function IteratorValue(n) {
			return n.value;
		}
		function IsNonNegativeNumber(n) {
			if (typeof n !== "number") return false;
			if (C(n)) return false;
			if (n < 0) return false;
			return true;
		}
		function CloneAsUint8Array(n) {
			const a = ArrayBufferSlice(n.buffer, n.byteOffset, n.byteOffset + n.byteLength);
			return new Uint8Array(a);
		}
		function DequeueValue(n) {
			const a = n._queue.shift();
			n._queueTotalSize -= a.size;
			if (n._queueTotalSize < 0) n._queueTotalSize = 0;
			return a.value;
		}
		function EnqueueValueWithSize(n, a, o) {
			if (!IsNonNegativeNumber(o) || o === Infinity) throw new RangeError("Size must be a finite, non-NaN, non-negative number.");
			n._queue.push({
				value: a,
				size: o
			});
			n._queueTotalSize += o;
		}
		function PeekQueueValue(n) {
			return n._queue.peek().value;
		}
		function ResetQueue(n) {
			n._queue = new SimpleQueue();
			n._queueTotalSize = 0;
		}
		function isDataViewConstructor(n) {
			return n === DataView;
		}
		function isDataView(n) {
			return isDataViewConstructor(n.constructor);
		}
		function arrayBufferViewElementSize(n) {
			if (isDataViewConstructor(n)) return 1;
			return n.BYTES_PER_ELEMENT;
		}
		/**
		* A pull-into request in a {@link ReadableByteStreamController}.
		*
		* @public
		*/
		class ReadableStreamBYOBRequest {
			constructor() {
				throw new TypeError("Illegal constructor");
			}
			/**
			* Returns the view for writing in to, or `null` if the BYOB request has already been responded to.
			*/
			get view() {
				if (!IsReadableStreamBYOBRequest(this)) throw byobRequestBrandCheckException("view");
				return this._view;
			}
			respond(n) {
				if (!IsReadableStreamBYOBRequest(this)) throw byobRequestBrandCheckException("respond");
				assertRequiredArgument(n, 1, "respond");
				n = convertUnsignedLongLongWithEnforceRange(n, "First parameter");
				if (this._associatedReadableByteStreamController === void 0) throw new TypeError("This BYOB request has been invalidated");
				if (IsDetachedBuffer(this._view.buffer)) throw new TypeError(`The BYOB request's buffer has been detached and so cannot be used as a response`);
				ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, n);
			}
			respondWithNewView(n) {
				if (!IsReadableStreamBYOBRequest(this)) throw byobRequestBrandCheckException("respondWithNewView");
				assertRequiredArgument(n, 1, "respondWithNewView");
				if (!ArrayBuffer.isView(n)) throw new TypeError("You can only respond with array buffer views");
				if (this._associatedReadableByteStreamController === void 0) throw new TypeError("This BYOB request has been invalidated");
				if (IsDetachedBuffer(n.buffer)) throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
				ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, n);
			}
		}
		Object.defineProperties(ReadableStreamBYOBRequest.prototype, {
			respond: { enumerable: true },
			respondWithNewView: { enumerable: true },
			view: { enumerable: true }
		});
		setFunctionName(ReadableStreamBYOBRequest.prototype.respond, "respond");
		setFunctionName(ReadableStreamBYOBRequest.prototype.respondWithNewView, "respondWithNewView");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, {
			value: "ReadableStreamBYOBRequest",
			configurable: true
		});
		/**
		* Allows control of a {@link ReadableStream | readable byte stream}'s state and internal queue.
		*
		* @public
		*/
		class ReadableByteStreamController {
			constructor() {
				throw new TypeError("Illegal constructor");
			}
			/**
			* Returns the current BYOB pull request, or `null` if there isn't one.
			*/
			get byobRequest() {
				if (!IsReadableByteStreamController(this)) throw byteStreamControllerBrandCheckException("byobRequest");
				return ReadableByteStreamControllerGetBYOBRequest(this);
			}
			/**
			* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
			* over-full. An underlying byte source ought to use this information to determine when and how to apply backpressure.
			*/
			get desiredSize() {
				if (!IsReadableByteStreamController(this)) throw byteStreamControllerBrandCheckException("desiredSize");
				return ReadableByteStreamControllerGetDesiredSize(this);
			}
			/**
			* Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
			* the stream, but once those are read, the stream will become closed.
			*/
			close() {
				if (!IsReadableByteStreamController(this)) throw byteStreamControllerBrandCheckException("close");
				if (this._closeRequested) throw new TypeError("The stream has already been closed; do not close it again!");
				const n = this._controlledReadableByteStream._state;
				if (n !== "readable") throw new TypeError(`The stream (in ${n} state) is not in the readable state and cannot be closed`);
				ReadableByteStreamControllerClose(this);
			}
			enqueue(n) {
				if (!IsReadableByteStreamController(this)) throw byteStreamControllerBrandCheckException("enqueue");
				assertRequiredArgument(n, 1, "enqueue");
				if (!ArrayBuffer.isView(n)) throw new TypeError("chunk must be an array buffer view");
				if (n.byteLength === 0) throw new TypeError("chunk must have non-zero byteLength");
				if (n.buffer.byteLength === 0) throw new TypeError(`chunk's buffer must have non-zero byteLength`);
				if (this._closeRequested) throw new TypeError("stream is closed or draining");
				const a = this._controlledReadableByteStream._state;
				if (a !== "readable") throw new TypeError(`The stream (in ${a} state) is not in the readable state and cannot be enqueued to`);
				ReadableByteStreamControllerEnqueue(this, n);
			}
			/**
			* Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
			*/
			error(n = void 0) {
				if (!IsReadableByteStreamController(this)) throw byteStreamControllerBrandCheckException("error");
				ReadableByteStreamControllerError(this, n);
			}
			/** @internal */
			[p](n) {
				ReadableByteStreamControllerClearPendingPullIntos(this);
				ResetQueue(this);
				const a = this._cancelAlgorithm(n);
				ReadableByteStreamControllerClearAlgorithms(this);
				return a;
			}
			/** @internal */
			[g](n) {
				const a = this._controlledReadableByteStream;
				if (this._queueTotalSize > 0) {
					ReadableByteStreamControllerFillReadRequestFromQueue(this, n);
					return;
				}
				const o = this._autoAllocateChunkSize;
				if (o !== void 0) {
					let a;
					try {
						a = new ArrayBuffer(o);
					} catch (a) {
						n._errorSteps(a);
						return;
					}
					const s = {
						buffer: a,
						bufferByteLength: o,
						byteOffset: 0,
						byteLength: o,
						bytesFilled: 0,
						minimumFill: 1,
						elementSize: 1,
						viewConstructor: Uint8Array,
						readerType: "default"
					};
					this._pendingPullIntos.push(s);
				}
				ReadableStreamAddReadRequest(a, n);
				ReadableByteStreamControllerCallPullIfNeeded(this);
			}
			/** @internal */
			[_]() {
				if (this._pendingPullIntos.length > 0) {
					const n = this._pendingPullIntos.peek();
					n.readerType = "none";
					this._pendingPullIntos = new SimpleQueue();
					this._pendingPullIntos.push(n);
				}
			}
		}
		Object.defineProperties(ReadableByteStreamController.prototype, {
			close: { enumerable: true },
			enqueue: { enumerable: true },
			error: { enumerable: true },
			byobRequest: { enumerable: true },
			desiredSize: { enumerable: true }
		});
		setFunctionName(ReadableByteStreamController.prototype.close, "close");
		setFunctionName(ReadableByteStreamController.prototype.enqueue, "enqueue");
		setFunctionName(ReadableByteStreamController.prototype.error, "error");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(ReadableByteStreamController.prototype, Symbol.toStringTag, {
			value: "ReadableByteStreamController",
			configurable: true
		});
		function IsReadableByteStreamController(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_controlledReadableByteStream")) return false;
			return n instanceof ReadableByteStreamController;
		}
		function IsReadableStreamBYOBRequest(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_associatedReadableByteStreamController")) return false;
			return n instanceof ReadableStreamBYOBRequest;
		}
		function ReadableByteStreamControllerCallPullIfNeeded(n) {
			if (!ReadableByteStreamControllerShouldCallPull(n)) return;
			if (n._pulling) {
				n._pullAgain = true;
				return;
			}
			n._pulling = true;
			uponPromise(n._pullAlgorithm(), () => {
				n._pulling = false;
				if (n._pullAgain) {
					n._pullAgain = false;
					ReadableByteStreamControllerCallPullIfNeeded(n);
				}
				return null;
			}, (a) => {
				ReadableByteStreamControllerError(n, a);
				return null;
			});
		}
		function ReadableByteStreamControllerClearPendingPullIntos(n) {
			ReadableByteStreamControllerInvalidateBYOBRequest(n);
			n._pendingPullIntos = new SimpleQueue();
		}
		function ReadableByteStreamControllerCommitPullIntoDescriptor(n, a) {
			let o = false;
			if (n._state === "closed") o = true;
			const s = ReadableByteStreamControllerConvertPullIntoDescriptor(a);
			if (a.readerType === "default") ReadableStreamFulfillReadRequest(n, s, o);
			else ReadableStreamFulfillReadIntoRequest(n, s, o);
		}
		function ReadableByteStreamControllerConvertPullIntoDescriptor(n) {
			const a = n.bytesFilled;
			const o = n.elementSize;
			return new n.viewConstructor(n.buffer, n.byteOffset, a / o);
		}
		function ReadableByteStreamControllerEnqueueChunkToQueue(n, a, o, s) {
			n._queue.push({
				buffer: a,
				byteOffset: o,
				byteLength: s
			});
			n._queueTotalSize += s;
		}
		function ReadableByteStreamControllerEnqueueClonedChunkToQueue(n, a, o, s) {
			let c;
			try {
				c = ArrayBufferSlice(a, o, o + s);
			} catch (a) {
				ReadableByteStreamControllerError(n, a);
				throw a;
			}
			ReadableByteStreamControllerEnqueueChunkToQueue(n, c, 0, s);
		}
		function ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(n, a) {
			if (a.bytesFilled > 0) ReadableByteStreamControllerEnqueueClonedChunkToQueue(n, a.buffer, a.byteOffset, a.bytesFilled);
			ReadableByteStreamControllerShiftPendingPullInto(n);
		}
		function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(n, a) {
			const o = Math.min(n._queueTotalSize, a.byteLength - a.bytesFilled);
			const s = a.bytesFilled + o;
			let c = o;
			let l = false;
			const u = s - s % a.elementSize;
			if (u >= a.minimumFill) {
				c = u - a.bytesFilled;
				l = true;
			}
			const d = n._queue;
			while (c > 0) {
				const o = d.peek();
				const s = Math.min(c, o.byteLength);
				const l = a.byteOffset + a.bytesFilled;
				CopyDataBlockBytes(a.buffer, l, o.buffer, o.byteOffset, s);
				if (o.byteLength === s) d.shift();
				else {
					o.byteOffset += s;
					o.byteLength -= s;
				}
				n._queueTotalSize -= s;
				ReadableByteStreamControllerFillHeadPullIntoDescriptor(n, s, a);
				c -= s;
			}
			return l;
		}
		function ReadableByteStreamControllerFillHeadPullIntoDescriptor(n, a, o) {
			o.bytesFilled += a;
		}
		function ReadableByteStreamControllerHandleQueueDrain(n) {
			if (n._queueTotalSize === 0 && n._closeRequested) {
				ReadableByteStreamControllerClearAlgorithms(n);
				ReadableStreamClose(n._controlledReadableByteStream);
			} else ReadableByteStreamControllerCallPullIfNeeded(n);
		}
		function ReadableByteStreamControllerInvalidateBYOBRequest(n) {
			if (n._byobRequest === null) return;
			n._byobRequest._associatedReadableByteStreamController = void 0;
			n._byobRequest._view = null;
			n._byobRequest = null;
		}
		function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n) {
			while (n._pendingPullIntos.length > 0) {
				if (n._queueTotalSize === 0) return;
				const a = n._pendingPullIntos.peek();
				if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(n, a)) {
					ReadableByteStreamControllerShiftPendingPullInto(n);
					ReadableByteStreamControllerCommitPullIntoDescriptor(n._controlledReadableByteStream, a);
				}
			}
		}
		function ReadableByteStreamControllerProcessReadRequestsUsingQueue(n) {
			const a = n._controlledReadableByteStream._reader;
			while (a._readRequests.length > 0) {
				if (n._queueTotalSize === 0) return;
				ReadableByteStreamControllerFillReadRequestFromQueue(n, a._readRequests.shift());
			}
		}
		function ReadableByteStreamControllerPullInto(n, a, o, s) {
			const c = n._controlledReadableByteStream;
			const l = a.constructor;
			const u = arrayBufferViewElementSize(l);
			const { byteOffset: d, byteLength: p } = a;
			const g = o * u;
			let _;
			try {
				_ = TransferArrayBuffer(a.buffer);
			} catch (n) {
				s._errorSteps(n);
				return;
			}
			const v = {
				buffer: _,
				bufferByteLength: _.byteLength,
				byteOffset: d,
				byteLength: p,
				bytesFilled: 0,
				minimumFill: g,
				elementSize: u,
				viewConstructor: l,
				readerType: "byob"
			};
			if (n._pendingPullIntos.length > 0) {
				n._pendingPullIntos.push(v);
				ReadableStreamAddReadIntoRequest(c, s);
				return;
			}
			if (c._state === "closed") {
				const n = new l(v.buffer, v.byteOffset, 0);
				s._closeSteps(n);
				return;
			}
			if (n._queueTotalSize > 0) {
				if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(n, v)) {
					const a = ReadableByteStreamControllerConvertPullIntoDescriptor(v);
					ReadableByteStreamControllerHandleQueueDrain(n);
					s._chunkSteps(a);
					return;
				}
				if (n._closeRequested) {
					const a = /* @__PURE__ */ new TypeError("Insufficient bytes to fill elements in the given buffer");
					ReadableByteStreamControllerError(n, a);
					s._errorSteps(a);
					return;
				}
			}
			n._pendingPullIntos.push(v);
			ReadableStreamAddReadIntoRequest(c, s);
			ReadableByteStreamControllerCallPullIfNeeded(n);
		}
		function ReadableByteStreamControllerRespondInClosedState(n, a) {
			if (a.readerType === "none") ReadableByteStreamControllerShiftPendingPullInto(n);
			const o = n._controlledReadableByteStream;
			if (ReadableStreamHasBYOBReader(o)) while (ReadableStreamGetNumReadIntoRequests(o) > 0) ReadableByteStreamControllerCommitPullIntoDescriptor(o, ReadableByteStreamControllerShiftPendingPullInto(n));
		}
		function ReadableByteStreamControllerRespondInReadableState(n, a, o) {
			ReadableByteStreamControllerFillHeadPullIntoDescriptor(n, a, o);
			if (o.readerType === "none") {
				ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(n, o);
				ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n);
				return;
			}
			if (o.bytesFilled < o.minimumFill) return;
			ReadableByteStreamControllerShiftPendingPullInto(n);
			const s = o.bytesFilled % o.elementSize;
			if (s > 0) {
				const a = o.byteOffset + o.bytesFilled;
				ReadableByteStreamControllerEnqueueClonedChunkToQueue(n, o.buffer, a - s, s);
			}
			o.bytesFilled -= s;
			ReadableByteStreamControllerCommitPullIntoDescriptor(n._controlledReadableByteStream, o);
			ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n);
		}
		function ReadableByteStreamControllerRespondInternal(n, a) {
			const o = n._pendingPullIntos.peek();
			ReadableByteStreamControllerInvalidateBYOBRequest(n);
			if (n._controlledReadableByteStream._state === "closed") ReadableByteStreamControllerRespondInClosedState(n, o);
			else ReadableByteStreamControllerRespondInReadableState(n, a, o);
			ReadableByteStreamControllerCallPullIfNeeded(n);
		}
		function ReadableByteStreamControllerShiftPendingPullInto(n) {
			return n._pendingPullIntos.shift();
		}
		function ReadableByteStreamControllerShouldCallPull(n) {
			const a = n._controlledReadableByteStream;
			if (a._state !== "readable") return false;
			if (n._closeRequested) return false;
			if (!n._started) return false;
			if (ReadableStreamHasDefaultReader(a) && ReadableStreamGetNumReadRequests(a) > 0) return true;
			if (ReadableStreamHasBYOBReader(a) && ReadableStreamGetNumReadIntoRequests(a) > 0) return true;
			if (ReadableByteStreamControllerGetDesiredSize(n) > 0) return true;
			return false;
		}
		function ReadableByteStreamControllerClearAlgorithms(n) {
			n._pullAlgorithm = void 0;
			n._cancelAlgorithm = void 0;
		}
		function ReadableByteStreamControllerClose(n) {
			const a = n._controlledReadableByteStream;
			if (n._closeRequested || a._state !== "readable") return;
			if (n._queueTotalSize > 0) {
				n._closeRequested = true;
				return;
			}
			if (n._pendingPullIntos.length > 0) {
				const a = n._pendingPullIntos.peek();
				if (a.bytesFilled % a.elementSize !== 0) {
					const a = /* @__PURE__ */ new TypeError("Insufficient bytes to fill elements in the given buffer");
					ReadableByteStreamControllerError(n, a);
					throw a;
				}
			}
			ReadableByteStreamControllerClearAlgorithms(n);
			ReadableStreamClose(a);
		}
		function ReadableByteStreamControllerEnqueue(n, a) {
			const o = n._controlledReadableByteStream;
			if (n._closeRequested || o._state !== "readable") return;
			const { buffer: s, byteOffset: c, byteLength: l } = a;
			if (IsDetachedBuffer(s)) throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
			const u = TransferArrayBuffer(s);
			if (n._pendingPullIntos.length > 0) {
				const a = n._pendingPullIntos.peek();
				if (IsDetachedBuffer(a.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
				ReadableByteStreamControllerInvalidateBYOBRequest(n);
				a.buffer = TransferArrayBuffer(a.buffer);
				if (a.readerType === "none") ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue(n, a);
			}
			if (ReadableStreamHasDefaultReader(o)) {
				ReadableByteStreamControllerProcessReadRequestsUsingQueue(n);
				if (ReadableStreamGetNumReadRequests(o) === 0) ReadableByteStreamControllerEnqueueChunkToQueue(n, u, c, l);
				else {
					if (n._pendingPullIntos.length > 0) ReadableByteStreamControllerShiftPendingPullInto(n);
					ReadableStreamFulfillReadRequest(o, new Uint8Array(u, c, l), false);
				}
			} else if (ReadableStreamHasBYOBReader(o)) {
				ReadableByteStreamControllerEnqueueChunkToQueue(n, u, c, l);
				ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(n);
			} else ReadableByteStreamControllerEnqueueChunkToQueue(n, u, c, l);
			ReadableByteStreamControllerCallPullIfNeeded(n);
		}
		function ReadableByteStreamControllerError(n, a) {
			const o = n._controlledReadableByteStream;
			if (o._state !== "readable") return;
			ReadableByteStreamControllerClearPendingPullIntos(n);
			ResetQueue(n);
			ReadableByteStreamControllerClearAlgorithms(n);
			ReadableStreamError(o, a);
		}
		function ReadableByteStreamControllerFillReadRequestFromQueue(n, a) {
			const o = n._queue.shift();
			n._queueTotalSize -= o.byteLength;
			ReadableByteStreamControllerHandleQueueDrain(n);
			const s = new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
			a._chunkSteps(s);
		}
		function ReadableByteStreamControllerGetBYOBRequest(n) {
			if (n._byobRequest === null && n._pendingPullIntos.length > 0) {
				const a = n._pendingPullIntos.peek();
				const o = new Uint8Array(a.buffer, a.byteOffset + a.bytesFilled, a.byteLength - a.bytesFilled);
				const s = Object.create(ReadableStreamBYOBRequest.prototype);
				SetUpReadableStreamBYOBRequest(s, n, o);
				n._byobRequest = s;
			}
			return n._byobRequest;
		}
		function ReadableByteStreamControllerGetDesiredSize(n) {
			const a = n._controlledReadableByteStream._state;
			if (a === "errored") return null;
			if (a === "closed") return 0;
			return n._strategyHWM - n._queueTotalSize;
		}
		function ReadableByteStreamControllerRespond(n, a) {
			const o = n._pendingPullIntos.peek();
			if (n._controlledReadableByteStream._state === "closed") {
				if (a !== 0) throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
			} else {
				if (a === 0) throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");
				if (o.bytesFilled + a > o.byteLength) throw new RangeError("bytesWritten out of range");
			}
			o.buffer = TransferArrayBuffer(o.buffer);
			ReadableByteStreamControllerRespondInternal(n, a);
		}
		function ReadableByteStreamControllerRespondWithNewView(n, a) {
			const o = n._pendingPullIntos.peek();
			if (n._controlledReadableByteStream._state === "closed") {
				if (a.byteLength !== 0) throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
			} else if (a.byteLength === 0) throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
			if (o.byteOffset + o.bytesFilled !== a.byteOffset) throw new RangeError("The region specified by view does not match byobRequest");
			if (o.bufferByteLength !== a.buffer.byteLength) throw new RangeError("The buffer of view has different capacity than byobRequest");
			if (o.bytesFilled + a.byteLength > o.byteLength) throw new RangeError("The region specified by view is larger than byobRequest");
			const s = a.byteLength;
			o.buffer = TransferArrayBuffer(a.buffer);
			ReadableByteStreamControllerRespondInternal(n, s);
		}
		function SetUpReadableByteStreamController(n, a, o, s, c, l, u) {
			a._controlledReadableByteStream = n;
			a._pullAgain = false;
			a._pulling = false;
			a._byobRequest = null;
			a._queue = a._queueTotalSize = void 0;
			ResetQueue(a);
			a._closeRequested = false;
			a._started = false;
			a._strategyHWM = l;
			a._pullAlgorithm = s;
			a._cancelAlgorithm = c;
			a._autoAllocateChunkSize = u;
			a._pendingPullIntos = new SimpleQueue();
			n._readableStreamController = a;
			uponPromise(promiseResolvedWith(o()), () => {
				a._started = true;
				ReadableByteStreamControllerCallPullIfNeeded(a);
				return null;
			}, (n) => {
				ReadableByteStreamControllerError(a, n);
				return null;
			});
		}
		function SetUpReadableByteStreamControllerFromUnderlyingSource(n, a, o) {
			const s = Object.create(ReadableByteStreamController.prototype);
			let startAlgorithm;
			let pullAlgorithm;
			let cancelAlgorithm;
			if (a.start !== void 0) startAlgorithm = () => a.start(s);
			else startAlgorithm = () => void 0;
			if (a.pull !== void 0) pullAlgorithm = () => a.pull(s);
			else pullAlgorithm = () => promiseResolvedWith(void 0);
			if (a.cancel !== void 0) cancelAlgorithm = (n) => a.cancel(n);
			else cancelAlgorithm = () => promiseResolvedWith(void 0);
			const c = a.autoAllocateChunkSize;
			if (c === 0) throw new TypeError("autoAllocateChunkSize must be greater than 0");
			SetUpReadableByteStreamController(n, s, startAlgorithm, pullAlgorithm, cancelAlgorithm, o, c);
		}
		function SetUpReadableStreamBYOBRequest(n, a, o) {
			n._associatedReadableByteStreamController = a;
			n._view = o;
		}
		function byobRequestBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`ReadableStreamBYOBRequest.prototype.${n} can only be used on a ReadableStreamBYOBRequest`);
		}
		function byteStreamControllerBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`ReadableByteStreamController.prototype.${n} can only be used on a ReadableByteStreamController`);
		}
		function convertReaderOptions(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.mode;
			return { mode: o === void 0 ? void 0 : convertReadableStreamReaderMode(o, `${a} has member 'mode' that`) };
		}
		function convertReadableStreamReaderMode(n, a) {
			n = `${n}`;
			if (n !== "byob") throw new TypeError(`${a} '${n}' is not a valid enumeration value for ReadableStreamReaderMode`);
			return n;
		}
		function convertByobReadOptions(n, a) {
			var o;
			assertDictionary(n, a);
			return { min: convertUnsignedLongLongWithEnforceRange((o = n === null || n === void 0 ? void 0 : n.min) !== null && o !== void 0 ? o : 1, `${a} has member 'min' that`) };
		}
		function AcquireReadableStreamBYOBReader(n) {
			return new ReadableStreamBYOBReader(n);
		}
		function ReadableStreamAddReadIntoRequest(n, a) {
			n._reader._readIntoRequests.push(a);
		}
		function ReadableStreamFulfillReadIntoRequest(n, a, o) {
			const s = n._reader._readIntoRequests.shift();
			if (o) s._closeSteps(a);
			else s._chunkSteps(a);
		}
		function ReadableStreamGetNumReadIntoRequests(n) {
			return n._reader._readIntoRequests.length;
		}
		function ReadableStreamHasBYOBReader(n) {
			const a = n._reader;
			if (a === void 0) return false;
			if (!IsReadableStreamBYOBReader(a)) return false;
			return true;
		}
		/**
		* A BYOB reader vended by a {@link ReadableStream}.
		*
		* @public
		*/
		class ReadableStreamBYOBReader {
			constructor(n) {
				assertRequiredArgument(n, 1, "ReadableStreamBYOBReader");
				assertReadableStream(n, "First parameter");
				if (IsReadableStreamLocked(n)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
				if (!IsReadableByteStreamController(n._readableStreamController)) throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");
				ReadableStreamReaderGenericInitialize(this, n);
				this._readIntoRequests = new SimpleQueue();
			}
			/**
			* Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
			* the reader's lock is released before the stream finishes closing.
			*/
			get closed() {
				if (!IsReadableStreamBYOBReader(this)) return promiseRejectedWith(byobReaderBrandCheckException("closed"));
				return this._closedPromise;
			}
			/**
			* If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}.
			*/
			cancel(n = void 0) {
				if (!IsReadableStreamBYOBReader(this)) return promiseRejectedWith(byobReaderBrandCheckException("cancel"));
				if (this._ownerReadableStream === void 0) return promiseRejectedWith(readerLockException("cancel"));
				return ReadableStreamReaderGenericCancel(this, n);
			}
			read(n, a = {}) {
				if (!IsReadableStreamBYOBReader(this)) return promiseRejectedWith(byobReaderBrandCheckException("read"));
				if (!ArrayBuffer.isView(n)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("view must be an array buffer view"));
				if (n.byteLength === 0) return promiseRejectedWith(/* @__PURE__ */ new TypeError("view must have non-zero byteLength"));
				if (n.buffer.byteLength === 0) return promiseRejectedWith(/* @__PURE__ */ new TypeError(`view's buffer must have non-zero byteLength`));
				if (IsDetachedBuffer(n.buffer)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("view's buffer has been detached"));
				let o;
				try {
					o = convertByobReadOptions(a, "options");
				} catch (n) {
					return promiseRejectedWith(n);
				}
				const s = o.min;
				if (s === 0) return promiseRejectedWith(/* @__PURE__ */ new TypeError("options.min must be greater than 0"));
				if (!isDataView(n)) {
					if (s > n.length) return promiseRejectedWith(/* @__PURE__ */ new RangeError("options.min must be less than or equal to view's length"));
				} else if (s > n.byteLength) return promiseRejectedWith(/* @__PURE__ */ new RangeError("options.min must be less than or equal to view's byteLength"));
				if (this._ownerReadableStream === void 0) return promiseRejectedWith(readerLockException("read from"));
				let c;
				let l;
				const u = newPromise((n, a) => {
					c = n;
					l = a;
				});
				ReadableStreamBYOBReaderRead(this, n, s, {
					_chunkSteps: (n) => c({
						value: n,
						done: false
					}),
					_closeSteps: (n) => c({
						value: n,
						done: true
					}),
					_errorSteps: (n) => l(n)
				});
				return u;
			}
			/**
			* Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active.
			* If the associated stream is errored when the lock is released, the reader will appear errored in the same way
			* from now on; otherwise, the reader will appear closed.
			*
			* A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by
			* the reader's {@link ReadableStreamBYOBReader.read | read()} method has not yet been settled. Attempting to
			* do so will throw a `TypeError` and leave the reader locked to the stream.
			*/
			releaseLock() {
				if (!IsReadableStreamBYOBReader(this)) throw byobReaderBrandCheckException("releaseLock");
				if (this._ownerReadableStream === void 0) return;
				ReadableStreamBYOBReaderRelease(this);
			}
		}
		Object.defineProperties(ReadableStreamBYOBReader.prototype, {
			cancel: { enumerable: true },
			read: { enumerable: true },
			releaseLock: { enumerable: true },
			closed: { enumerable: true }
		});
		setFunctionName(ReadableStreamBYOBReader.prototype.cancel, "cancel");
		setFunctionName(ReadableStreamBYOBReader.prototype.read, "read");
		setFunctionName(ReadableStreamBYOBReader.prototype.releaseLock, "releaseLock");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(ReadableStreamBYOBReader.prototype, Symbol.toStringTag, {
			value: "ReadableStreamBYOBReader",
			configurable: true
		});
		function IsReadableStreamBYOBReader(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_readIntoRequests")) return false;
			return n instanceof ReadableStreamBYOBReader;
		}
		function ReadableStreamBYOBReaderRead(n, a, o, s) {
			const c = n._ownerReadableStream;
			c._disturbed = true;
			if (c._state === "errored") s._errorSteps(c._storedError);
			else ReadableByteStreamControllerPullInto(c._readableStreamController, a, o, s);
		}
		function ReadableStreamBYOBReaderRelease(n) {
			ReadableStreamReaderGenericRelease(n);
			ReadableStreamBYOBReaderErrorReadIntoRequests(n, /* @__PURE__ */ new TypeError("Reader was released"));
		}
		function ReadableStreamBYOBReaderErrorReadIntoRequests(n, a) {
			const o = n._readIntoRequests;
			n._readIntoRequests = new SimpleQueue();
			o.forEach((n) => {
				n._errorSteps(a);
			});
		}
		function byobReaderBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`ReadableStreamBYOBReader.prototype.${n} can only be used on a ReadableStreamBYOBReader`);
		}
		function ExtractHighWaterMark(n, a) {
			const { highWaterMark: o } = n;
			if (o === void 0) return a;
			if (C(o) || o < 0) throw new RangeError("Invalid highWaterMark");
			return o;
		}
		function ExtractSizeAlgorithm(n) {
			const { size: a } = n;
			if (!a) return () => 1;
			return a;
		}
		function convertQueuingStrategy(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.highWaterMark;
			const s = n === null || n === void 0 ? void 0 : n.size;
			return {
				highWaterMark: o === void 0 ? void 0 : convertUnrestrictedDouble(o),
				size: s === void 0 ? void 0 : convertQueuingStrategySize(s, `${a} has member 'size' that`)
			};
		}
		function convertQueuingStrategySize(n, a) {
			assertFunction(n, a);
			return (a) => convertUnrestrictedDouble(n(a));
		}
		function convertUnderlyingSink(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.abort;
			const s = n === null || n === void 0 ? void 0 : n.close;
			const c = n === null || n === void 0 ? void 0 : n.start;
			const l = n === null || n === void 0 ? void 0 : n.type;
			const u = n === null || n === void 0 ? void 0 : n.write;
			return {
				abort: o === void 0 ? void 0 : convertUnderlyingSinkAbortCallback(o, n, `${a} has member 'abort' that`),
				close: s === void 0 ? void 0 : convertUnderlyingSinkCloseCallback(s, n, `${a} has member 'close' that`),
				start: c === void 0 ? void 0 : convertUnderlyingSinkStartCallback(c, n, `${a} has member 'start' that`),
				write: u === void 0 ? void 0 : convertUnderlyingSinkWriteCallback(u, n, `${a} has member 'write' that`),
				type: l
			};
		}
		function convertUnderlyingSinkAbortCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => promiseCall(n, a, [o]);
		}
		function convertUnderlyingSinkCloseCallback(n, a, o) {
			assertFunction(n, o);
			return () => promiseCall(n, a, []);
		}
		function convertUnderlyingSinkStartCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => reflectCall(n, a, [o]);
		}
		function convertUnderlyingSinkWriteCallback(n, a, o) {
			assertFunction(n, o);
			return (o, s) => promiseCall(n, a, [o, s]);
		}
		function assertWritableStream(n, a) {
			if (!IsWritableStream(n)) throw new TypeError(`${a} is not a WritableStream.`);
		}
		function isAbortSignal(n) {
			if (typeof n !== "object" || n === null) return false;
			try {
				return typeof n.aborted === "boolean";
			} catch (n) {
				return false;
			}
		}
		const O = typeof AbortController === "function";
		/**
		* Construct a new AbortController, if supported by the platform.
		*
		* @internal
		*/
		function createAbortController() {
			if (O) return new AbortController();
		}
		/**
		* A writable stream represents a destination for data, into which you can write.
		*
		* @public
		*/
		class WritableStream {
			constructor(n = {}, a = {}) {
				if (n === void 0) n = null;
				else assertObject(n, "First parameter");
				const o = convertQueuingStrategy(a, "Second parameter");
				const s = convertUnderlyingSink(n, "First parameter");
				InitializeWritableStream(this);
				if (s.type !== void 0) throw new RangeError("Invalid type is specified");
				const c = ExtractSizeAlgorithm(o);
				const l = ExtractHighWaterMark(o, 1);
				SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, s, l, c);
			}
			/**
			* Returns whether or not the writable stream is locked to a writer.
			*/
			get locked() {
				if (!IsWritableStream(this)) throw streamBrandCheckException$2("locked");
				return IsWritableStreamLocked(this);
			}
			/**
			* Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be
			* immediately moved to an errored state, with any queued-up writes discarded. This will also execute any abort
			* mechanism of the underlying sink.
			*
			* The returned promise will fulfill if the stream shuts down successfully, or reject if the underlying sink signaled
			* that there was an error doing so. Additionally, it will reject with a `TypeError` (without attempting to cancel
			* the stream) if the stream is currently locked.
			*/
			abort(n = void 0) {
				if (!IsWritableStream(this)) return promiseRejectedWith(streamBrandCheckException$2("abort"));
				if (IsWritableStreamLocked(this)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("Cannot abort a stream that already has a writer"));
				return WritableStreamAbort(this, n);
			}
			/**
			* Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its
			* close behavior. During this time any further attempts to write will fail (without erroring the stream).
			*
			* The method returns a promise that will fulfill if all remaining chunks are successfully written and the stream
			* successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with
			* a `TypeError` (without attempting to cancel the stream) if the stream is currently locked.
			*/
			close() {
				if (!IsWritableStream(this)) return promiseRejectedWith(streamBrandCheckException$2("close"));
				if (IsWritableStreamLocked(this)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("Cannot close a stream that already has a writer"));
				if (WritableStreamCloseQueuedOrInFlight(this)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("Cannot close an already-closing stream"));
				return WritableStreamClose(this);
			}
			/**
			* Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream
			* is locked, no other writer can be acquired until this one is released.
			*
			* This functionality is especially useful for creating abstractions that desire the ability to write to a stream
			* without interruption or interleaving. By getting a writer for the stream, you can ensure nobody else can write at
			* the same time, which would cause the resulting written data to be unpredictable and probably useless.
			*/
			getWriter() {
				if (!IsWritableStream(this)) throw streamBrandCheckException$2("getWriter");
				return AcquireWritableStreamDefaultWriter(this);
			}
		}
		Object.defineProperties(WritableStream.prototype, {
			abort: { enumerable: true },
			close: { enumerable: true },
			getWriter: { enumerable: true },
			locked: { enumerable: true }
		});
		setFunctionName(WritableStream.prototype.abort, "abort");
		setFunctionName(WritableStream.prototype.close, "close");
		setFunctionName(WritableStream.prototype.getWriter, "getWriter");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(WritableStream.prototype, Symbol.toStringTag, {
			value: "WritableStream",
			configurable: true
		});
		function AcquireWritableStreamDefaultWriter(n) {
			return new WritableStreamDefaultWriter(n);
		}
		function CreateWritableStream(n, a, o, s, c = 1, l = () => 1) {
			const u = Object.create(WritableStream.prototype);
			InitializeWritableStream(u);
			SetUpWritableStreamDefaultController(u, Object.create(WritableStreamDefaultController.prototype), n, a, o, s, c, l);
			return u;
		}
		function InitializeWritableStream(n) {
			n._state = "writable";
			n._storedError = void 0;
			n._writer = void 0;
			n._writableStreamController = void 0;
			n._writeRequests = new SimpleQueue();
			n._inFlightWriteRequest = void 0;
			n._closeRequest = void 0;
			n._inFlightCloseRequest = void 0;
			n._pendingAbortRequest = void 0;
			n._backpressure = false;
		}
		function IsWritableStream(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_writableStreamController")) return false;
			return n instanceof WritableStream;
		}
		function IsWritableStreamLocked(n) {
			if (n._writer === void 0) return false;
			return true;
		}
		function WritableStreamAbort(n, a) {
			var o;
			if (n._state === "closed" || n._state === "errored") return promiseResolvedWith(void 0);
			n._writableStreamController._abortReason = a;
			(o = n._writableStreamController._abortController) === null || o === void 0 || o.abort(a);
			const s = n._state;
			if (s === "closed" || s === "errored") return promiseResolvedWith(void 0);
			if (n._pendingAbortRequest !== void 0) return n._pendingAbortRequest._promise;
			let c = false;
			if (s === "erroring") {
				c = true;
				a = void 0;
			}
			const l = newPromise((o, s) => {
				n._pendingAbortRequest = {
					_promise: void 0,
					_resolve: o,
					_reject: s,
					_reason: a,
					_wasAlreadyErroring: c
				};
			});
			n._pendingAbortRequest._promise = l;
			if (!c) WritableStreamStartErroring(n, a);
			return l;
		}
		function WritableStreamClose(n) {
			const a = n._state;
			if (a === "closed" || a === "errored") return promiseRejectedWith(/* @__PURE__ */ new TypeError(`The stream (in ${a} state) is not in the writable state and cannot be closed`));
			const o = newPromise((a, o) => {
				n._closeRequest = {
					_resolve: a,
					_reject: o
				};
			});
			const s = n._writer;
			if (s !== void 0 && n._backpressure && a === "writable") defaultWriterReadyPromiseResolve(s);
			WritableStreamDefaultControllerClose(n._writableStreamController);
			return o;
		}
		function WritableStreamAddWriteRequest(n) {
			return newPromise((a, o) => {
				const s = {
					_resolve: a,
					_reject: o
				};
				n._writeRequests.push(s);
			});
		}
		function WritableStreamDealWithRejection(n, a) {
			if (n._state === "writable") {
				WritableStreamStartErroring(n, a);
				return;
			}
			WritableStreamFinishErroring(n);
		}
		function WritableStreamStartErroring(n, a) {
			const o = n._writableStreamController;
			n._state = "erroring";
			n._storedError = a;
			const s = n._writer;
			if (s !== void 0) WritableStreamDefaultWriterEnsureReadyPromiseRejected(s, a);
			if (!WritableStreamHasOperationMarkedInFlight(n) && o._started) WritableStreamFinishErroring(n);
		}
		function WritableStreamFinishErroring(n) {
			n._state = "errored";
			n._writableStreamController[d]();
			const a = n._storedError;
			n._writeRequests.forEach((n) => {
				n._reject(a);
			});
			n._writeRequests = new SimpleQueue();
			if (n._pendingAbortRequest === void 0) {
				WritableStreamRejectCloseAndClosedPromiseIfNeeded(n);
				return;
			}
			const o = n._pendingAbortRequest;
			n._pendingAbortRequest = void 0;
			if (o._wasAlreadyErroring) {
				o._reject(a);
				WritableStreamRejectCloseAndClosedPromiseIfNeeded(n);
				return;
			}
			uponPromise(n._writableStreamController[u](o._reason), () => {
				o._resolve();
				WritableStreamRejectCloseAndClosedPromiseIfNeeded(n);
				return null;
			}, (a) => {
				o._reject(a);
				WritableStreamRejectCloseAndClosedPromiseIfNeeded(n);
				return null;
			});
		}
		function WritableStreamFinishInFlightWrite(n) {
			n._inFlightWriteRequest._resolve(void 0);
			n._inFlightWriteRequest = void 0;
		}
		function WritableStreamFinishInFlightWriteWithError(n, a) {
			n._inFlightWriteRequest._reject(a);
			n._inFlightWriteRequest = void 0;
			WritableStreamDealWithRejection(n, a);
		}
		function WritableStreamFinishInFlightClose(n) {
			n._inFlightCloseRequest._resolve(void 0);
			n._inFlightCloseRequest = void 0;
			if (n._state === "erroring") {
				n._storedError = void 0;
				if (n._pendingAbortRequest !== void 0) {
					n._pendingAbortRequest._resolve();
					n._pendingAbortRequest = void 0;
				}
			}
			n._state = "closed";
			const a = n._writer;
			if (a !== void 0) defaultWriterClosedPromiseResolve(a);
		}
		function WritableStreamFinishInFlightCloseWithError(n, a) {
			n._inFlightCloseRequest._reject(a);
			n._inFlightCloseRequest = void 0;
			if (n._pendingAbortRequest !== void 0) {
				n._pendingAbortRequest._reject(a);
				n._pendingAbortRequest = void 0;
			}
			WritableStreamDealWithRejection(n, a);
		}
		function WritableStreamCloseQueuedOrInFlight(n) {
			if (n._closeRequest === void 0 && n._inFlightCloseRequest === void 0) return false;
			return true;
		}
		function WritableStreamHasOperationMarkedInFlight(n) {
			if (n._inFlightWriteRequest === void 0 && n._inFlightCloseRequest === void 0) return false;
			return true;
		}
		function WritableStreamMarkCloseRequestInFlight(n) {
			n._inFlightCloseRequest = n._closeRequest;
			n._closeRequest = void 0;
		}
		function WritableStreamMarkFirstWriteRequestInFlight(n) {
			n._inFlightWriteRequest = n._writeRequests.shift();
		}
		function WritableStreamRejectCloseAndClosedPromiseIfNeeded(n) {
			if (n._closeRequest !== void 0) {
				n._closeRequest._reject(n._storedError);
				n._closeRequest = void 0;
			}
			const a = n._writer;
			if (a !== void 0) defaultWriterClosedPromiseReject(a, n._storedError);
		}
		function WritableStreamUpdateBackpressure(n, a) {
			const o = n._writer;
			if (o !== void 0 && a !== n._backpressure) {
				if (a) defaultWriterReadyPromiseReset(o);
				else defaultWriterReadyPromiseResolve(o);
			}
			n._backpressure = a;
		}
		/**
		* A default writer vended by a {@link WritableStream}.
		*
		* @public
		*/
		class WritableStreamDefaultWriter {
			constructor(n) {
				assertRequiredArgument(n, 1, "WritableStreamDefaultWriter");
				assertWritableStream(n, "First parameter");
				if (IsWritableStreamLocked(n)) throw new TypeError("This stream has already been locked for exclusive writing by another writer");
				this._ownerWritableStream = n;
				n._writer = this;
				const a = n._state;
				if (a === "writable") {
					if (!WritableStreamCloseQueuedOrInFlight(n) && n._backpressure) defaultWriterReadyPromiseInitialize(this);
					else defaultWriterReadyPromiseInitializeAsResolved(this);
					defaultWriterClosedPromiseInitialize(this);
				} else if (a === "erroring") {
					defaultWriterReadyPromiseInitializeAsRejected(this, n._storedError);
					defaultWriterClosedPromiseInitialize(this);
				} else if (a === "closed") {
					defaultWriterReadyPromiseInitializeAsResolved(this);
					defaultWriterClosedPromiseInitializeAsResolved(this);
				} else {
					const a = n._storedError;
					defaultWriterReadyPromiseInitializeAsRejected(this, a);
					defaultWriterClosedPromiseInitializeAsRejected(this, a);
				}
			}
			/**
			* Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
			* the writer’s lock is released before the stream finishes closing.
			*/
			get closed() {
				if (!IsWritableStreamDefaultWriter(this)) return promiseRejectedWith(defaultWriterBrandCheckException("closed"));
				return this._closedPromise;
			}
			/**
			* Returns the desired size to fill the stream’s internal queue. It can be negative, if the queue is over-full.
			* A producer can use this information to determine the right amount of data to write.
			*
			* It will be `null` if the stream cannot be successfully written to (due to either being errored, or having an abort
			* queued up). It will return zero if the stream is closed. And the getter will throw an exception if invoked when
			* the writer’s lock is released.
			*/
			get desiredSize() {
				if (!IsWritableStreamDefaultWriter(this)) throw defaultWriterBrandCheckException("desiredSize");
				if (this._ownerWritableStream === void 0) throw defaultWriterLockException("desiredSize");
				return WritableStreamDefaultWriterGetDesiredSize(this);
			}
			/**
			* Returns a promise that will be fulfilled when the desired size to fill the stream’s internal queue transitions
			* from non-positive to positive, signaling that it is no longer applying backpressure. Once the desired size dips
			* back to zero or below, the getter will return a new promise that stays pending until the next transition.
			*
			* If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become
			* rejected.
			*/
			get ready() {
				if (!IsWritableStreamDefaultWriter(this)) return promiseRejectedWith(defaultWriterBrandCheckException("ready"));
				return this._readyPromise;
			}
			/**
			* If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}.
			*/
			abort(n = void 0) {
				if (!IsWritableStreamDefaultWriter(this)) return promiseRejectedWith(defaultWriterBrandCheckException("abort"));
				if (this._ownerWritableStream === void 0) return promiseRejectedWith(defaultWriterLockException("abort"));
				return WritableStreamDefaultWriterAbort(this, n);
			}
			/**
			* If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}.
			*/
			close() {
				if (!IsWritableStreamDefaultWriter(this)) return promiseRejectedWith(defaultWriterBrandCheckException("close"));
				const n = this._ownerWritableStream;
				if (n === void 0) return promiseRejectedWith(defaultWriterLockException("close"));
				if (WritableStreamCloseQueuedOrInFlight(n)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("Cannot close an already-closing stream"));
				return WritableStreamDefaultWriterClose(this);
			}
			/**
			* Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active.
			* If the associated stream is errored when the lock is released, the writer will appear errored in the same way from
			* now on; otherwise, the writer will appear closed.
			*
			* Note that the lock can still be released even if some ongoing writes have not yet finished (i.e. even if the
			* promises returned from previous calls to {@link WritableStreamDefaultWriter.write | write()} have not yet settled).
			* It’s not necessary to hold the lock on the writer for the duration of the write; the lock instead simply prevents
			* other producers from writing in an interleaved manner.
			*/
			releaseLock() {
				if (!IsWritableStreamDefaultWriter(this)) throw defaultWriterBrandCheckException("releaseLock");
				if (this._ownerWritableStream === void 0) return;
				WritableStreamDefaultWriterRelease(this);
			}
			write(n = void 0) {
				if (!IsWritableStreamDefaultWriter(this)) return promiseRejectedWith(defaultWriterBrandCheckException("write"));
				if (this._ownerWritableStream === void 0) return promiseRejectedWith(defaultWriterLockException("write to"));
				return WritableStreamDefaultWriterWrite(this, n);
			}
		}
		Object.defineProperties(WritableStreamDefaultWriter.prototype, {
			abort: { enumerable: true },
			close: { enumerable: true },
			releaseLock: { enumerable: true },
			write: { enumerable: true },
			closed: { enumerable: true },
			desiredSize: { enumerable: true },
			ready: { enumerable: true }
		});
		setFunctionName(WritableStreamDefaultWriter.prototype.abort, "abort");
		setFunctionName(WritableStreamDefaultWriter.prototype.close, "close");
		setFunctionName(WritableStreamDefaultWriter.prototype.releaseLock, "releaseLock");
		setFunctionName(WritableStreamDefaultWriter.prototype.write, "write");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(WritableStreamDefaultWriter.prototype, Symbol.toStringTag, {
			value: "WritableStreamDefaultWriter",
			configurable: true
		});
		function IsWritableStreamDefaultWriter(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_ownerWritableStream")) return false;
			return n instanceof WritableStreamDefaultWriter;
		}
		function WritableStreamDefaultWriterAbort(n, a) {
			const o = n._ownerWritableStream;
			return WritableStreamAbort(o, a);
		}
		function WritableStreamDefaultWriterClose(n) {
			const a = n._ownerWritableStream;
			return WritableStreamClose(a);
		}
		function WritableStreamDefaultWriterCloseWithErrorPropagation(n) {
			const a = n._ownerWritableStream;
			const o = a._state;
			if (WritableStreamCloseQueuedOrInFlight(a) || o === "closed") return promiseResolvedWith(void 0);
			if (o === "errored") return promiseRejectedWith(a._storedError);
			return WritableStreamDefaultWriterClose(n);
		}
		function WritableStreamDefaultWriterEnsureClosedPromiseRejected(n, a) {
			if (n._closedPromiseState === "pending") defaultWriterClosedPromiseReject(n, a);
			else defaultWriterClosedPromiseResetToRejected(n, a);
		}
		function WritableStreamDefaultWriterEnsureReadyPromiseRejected(n, a) {
			if (n._readyPromiseState === "pending") defaultWriterReadyPromiseReject(n, a);
			else defaultWriterReadyPromiseResetToRejected(n, a);
		}
		function WritableStreamDefaultWriterGetDesiredSize(n) {
			const a = n._ownerWritableStream;
			const o = a._state;
			if (o === "errored" || o === "erroring") return null;
			if (o === "closed") return 0;
			return WritableStreamDefaultControllerGetDesiredSize(a._writableStreamController);
		}
		function WritableStreamDefaultWriterRelease(n) {
			const a = n._ownerWritableStream;
			const o = /* @__PURE__ */ new TypeError(`Writer was released and can no longer be used to monitor the stream's closedness`);
			WritableStreamDefaultWriterEnsureReadyPromiseRejected(n, o);
			WritableStreamDefaultWriterEnsureClosedPromiseRejected(n, o);
			a._writer = void 0;
			n._ownerWritableStream = void 0;
		}
		function WritableStreamDefaultWriterWrite(n, a) {
			const o = n._ownerWritableStream;
			const s = o._writableStreamController;
			const c = WritableStreamDefaultControllerGetChunkSize(s, a);
			if (o !== n._ownerWritableStream) return promiseRejectedWith(defaultWriterLockException("write to"));
			const l = o._state;
			if (l === "errored") return promiseRejectedWith(o._storedError);
			if (WritableStreamCloseQueuedOrInFlight(o) || l === "closed") return promiseRejectedWith(/* @__PURE__ */ new TypeError("The stream is closing or closed and cannot be written to"));
			if (l === "erroring") return promiseRejectedWith(o._storedError);
			const u = WritableStreamAddWriteRequest(o);
			WritableStreamDefaultControllerWrite(s, a, c);
			return u;
		}
		const k = {};
		/**
		* Allows control of a {@link WritableStream | writable stream}'s state and internal queue.
		*
		* @public
		*/
		class WritableStreamDefaultController {
			constructor() {
				throw new TypeError("Illegal constructor");
			}
			/**
			* The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted.
			*
			* @deprecated
			*  This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177.
			*  Use {@link WritableStreamDefaultController.signal}'s `reason` instead.
			*/
			get abortReason() {
				if (!IsWritableStreamDefaultController(this)) throw defaultControllerBrandCheckException$2("abortReason");
				return this._abortReason;
			}
			/**
			* An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted.
			*/
			get signal() {
				if (!IsWritableStreamDefaultController(this)) throw defaultControllerBrandCheckException$2("signal");
				if (this._abortController === void 0) throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");
				return this._abortController.signal;
			}
			/**
			* Closes the controlled writable stream, making all future interactions with it fail with the given error `e`.
			*
			* This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying
			* sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the
			* normal lifecycle of interactions with the underlying sink.
			*/
			error(n = void 0) {
				if (!IsWritableStreamDefaultController(this)) throw defaultControllerBrandCheckException$2("error");
				if (this._controlledWritableStream._state !== "writable") return;
				WritableStreamDefaultControllerError(this, n);
			}
			/** @internal */
			[u](n) {
				const a = this._abortAlgorithm(n);
				WritableStreamDefaultControllerClearAlgorithms(this);
				return a;
			}
			/** @internal */
			[d]() {
				ResetQueue(this);
			}
		}
		Object.defineProperties(WritableStreamDefaultController.prototype, {
			abortReason: { enumerable: true },
			signal: { enumerable: true },
			error: { enumerable: true }
		});
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, {
			value: "WritableStreamDefaultController",
			configurable: true
		});
		function IsWritableStreamDefaultController(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_controlledWritableStream")) return false;
			return n instanceof WritableStreamDefaultController;
		}
		function SetUpWritableStreamDefaultController(n, a, o, s, c, l, u, d) {
			a._controlledWritableStream = n;
			n._writableStreamController = a;
			a._queue = void 0;
			a._queueTotalSize = void 0;
			ResetQueue(a);
			a._abortReason = void 0;
			a._abortController = createAbortController();
			a._started = false;
			a._strategySizeAlgorithm = d;
			a._strategyHWM = u;
			a._writeAlgorithm = s;
			a._closeAlgorithm = c;
			a._abortAlgorithm = l;
			WritableStreamUpdateBackpressure(n, WritableStreamDefaultControllerGetBackpressure(a));
			uponPromise(promiseResolvedWith(o()), () => {
				a._started = true;
				WritableStreamDefaultControllerAdvanceQueueIfNeeded(a);
				return null;
			}, (o) => {
				a._started = true;
				WritableStreamDealWithRejection(n, o);
				return null;
			});
		}
		function SetUpWritableStreamDefaultControllerFromUnderlyingSink(n, a, o, s) {
			const c = Object.create(WritableStreamDefaultController.prototype);
			let startAlgorithm;
			let writeAlgorithm;
			let closeAlgorithm;
			let abortAlgorithm;
			if (a.start !== void 0) startAlgorithm = () => a.start(c);
			else startAlgorithm = () => void 0;
			if (a.write !== void 0) writeAlgorithm = (n) => a.write(n, c);
			else writeAlgorithm = () => promiseResolvedWith(void 0);
			if (a.close !== void 0) closeAlgorithm = () => a.close();
			else closeAlgorithm = () => promiseResolvedWith(void 0);
			if (a.abort !== void 0) abortAlgorithm = (n) => a.abort(n);
			else abortAlgorithm = () => promiseResolvedWith(void 0);
			SetUpWritableStreamDefaultController(n, c, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, o, s);
		}
		function WritableStreamDefaultControllerClearAlgorithms(n) {
			n._writeAlgorithm = void 0;
			n._closeAlgorithm = void 0;
			n._abortAlgorithm = void 0;
			n._strategySizeAlgorithm = void 0;
		}
		function WritableStreamDefaultControllerClose(n) {
			EnqueueValueWithSize(n, k, 0);
			WritableStreamDefaultControllerAdvanceQueueIfNeeded(n);
		}
		function WritableStreamDefaultControllerGetChunkSize(n, a) {
			try {
				return n._strategySizeAlgorithm(a);
			} catch (a) {
				WritableStreamDefaultControllerErrorIfNeeded(n, a);
				return 1;
			}
		}
		function WritableStreamDefaultControllerGetDesiredSize(n) {
			return n._strategyHWM - n._queueTotalSize;
		}
		function WritableStreamDefaultControllerWrite(n, a, o) {
			try {
				EnqueueValueWithSize(n, a, o);
			} catch (a) {
				WritableStreamDefaultControllerErrorIfNeeded(n, a);
				return;
			}
			const s = n._controlledWritableStream;
			if (!WritableStreamCloseQueuedOrInFlight(s) && s._state === "writable") WritableStreamUpdateBackpressure(s, WritableStreamDefaultControllerGetBackpressure(n));
			WritableStreamDefaultControllerAdvanceQueueIfNeeded(n);
		}
		function WritableStreamDefaultControllerAdvanceQueueIfNeeded(n) {
			const a = n._controlledWritableStream;
			if (!n._started) return;
			if (a._inFlightWriteRequest !== void 0) return;
			if (a._state === "erroring") {
				WritableStreamFinishErroring(a);
				return;
			}
			if (n._queue.length === 0) return;
			const o = PeekQueueValue(n);
			if (o === k) WritableStreamDefaultControllerProcessClose(n);
			else WritableStreamDefaultControllerProcessWrite(n, o);
		}
		function WritableStreamDefaultControllerErrorIfNeeded(n, a) {
			if (n._controlledWritableStream._state === "writable") WritableStreamDefaultControllerError(n, a);
		}
		function WritableStreamDefaultControllerProcessClose(n) {
			const a = n._controlledWritableStream;
			WritableStreamMarkCloseRequestInFlight(a);
			DequeueValue(n);
			const o = n._closeAlgorithm();
			WritableStreamDefaultControllerClearAlgorithms(n);
			uponPromise(o, () => {
				WritableStreamFinishInFlightClose(a);
				return null;
			}, (n) => {
				WritableStreamFinishInFlightCloseWithError(a, n);
				return null;
			});
		}
		function WritableStreamDefaultControllerProcessWrite(n, a) {
			const o = n._controlledWritableStream;
			WritableStreamMarkFirstWriteRequestInFlight(o);
			uponPromise(n._writeAlgorithm(a), () => {
				WritableStreamFinishInFlightWrite(o);
				const a = o._state;
				DequeueValue(n);
				if (!WritableStreamCloseQueuedOrInFlight(o) && a === "writable") {
					const a = WritableStreamDefaultControllerGetBackpressure(n);
					WritableStreamUpdateBackpressure(o, a);
				}
				WritableStreamDefaultControllerAdvanceQueueIfNeeded(n);
				return null;
			}, (a) => {
				if (o._state === "writable") WritableStreamDefaultControllerClearAlgorithms(n);
				WritableStreamFinishInFlightWriteWithError(o, a);
				return null;
			});
		}
		function WritableStreamDefaultControllerGetBackpressure(n) {
			return WritableStreamDefaultControllerGetDesiredSize(n) <= 0;
		}
		function WritableStreamDefaultControllerError(n, a) {
			const o = n._controlledWritableStream;
			WritableStreamDefaultControllerClearAlgorithms(n);
			WritableStreamStartErroring(o, a);
		}
		function streamBrandCheckException$2(n) {
			return /* @__PURE__ */ new TypeError(`WritableStream.prototype.${n} can only be used on a WritableStream`);
		}
		function defaultControllerBrandCheckException$2(n) {
			return /* @__PURE__ */ new TypeError(`WritableStreamDefaultController.prototype.${n} can only be used on a WritableStreamDefaultController`);
		}
		function defaultWriterBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`WritableStreamDefaultWriter.prototype.${n} can only be used on a WritableStreamDefaultWriter`);
		}
		function defaultWriterLockException(n) {
			return /* @__PURE__ */ new TypeError("Cannot " + n + " a stream using a released writer");
		}
		function defaultWriterClosedPromiseInitialize(n) {
			n._closedPromise = newPromise((a, o) => {
				n._closedPromise_resolve = a;
				n._closedPromise_reject = o;
				n._closedPromiseState = "pending";
			});
		}
		function defaultWriterClosedPromiseInitializeAsRejected(n, a) {
			defaultWriterClosedPromiseInitialize(n);
			defaultWriterClosedPromiseReject(n, a);
		}
		function defaultWriterClosedPromiseInitializeAsResolved(n) {
			defaultWriterClosedPromiseInitialize(n);
			defaultWriterClosedPromiseResolve(n);
		}
		function defaultWriterClosedPromiseReject(n, a) {
			if (n._closedPromise_reject === void 0) return;
			setPromiseIsHandledToTrue(n._closedPromise);
			n._closedPromise_reject(a);
			n._closedPromise_resolve = void 0;
			n._closedPromise_reject = void 0;
			n._closedPromiseState = "rejected";
		}
		function defaultWriterClosedPromiseResetToRejected(n, a) {
			defaultWriterClosedPromiseInitializeAsRejected(n, a);
		}
		function defaultWriterClosedPromiseResolve(n) {
			if (n._closedPromise_resolve === void 0) return;
			n._closedPromise_resolve(void 0);
			n._closedPromise_resolve = void 0;
			n._closedPromise_reject = void 0;
			n._closedPromiseState = "resolved";
		}
		function defaultWriterReadyPromiseInitialize(n) {
			n._readyPromise = newPromise((a, o) => {
				n._readyPromise_resolve = a;
				n._readyPromise_reject = o;
			});
			n._readyPromiseState = "pending";
		}
		function defaultWriterReadyPromiseInitializeAsRejected(n, a) {
			defaultWriterReadyPromiseInitialize(n);
			defaultWriterReadyPromiseReject(n, a);
		}
		function defaultWriterReadyPromiseInitializeAsResolved(n) {
			defaultWriterReadyPromiseInitialize(n);
			defaultWriterReadyPromiseResolve(n);
		}
		function defaultWriterReadyPromiseReject(n, a) {
			if (n._readyPromise_reject === void 0) return;
			setPromiseIsHandledToTrue(n._readyPromise);
			n._readyPromise_reject(a);
			n._readyPromise_resolve = void 0;
			n._readyPromise_reject = void 0;
			n._readyPromiseState = "rejected";
		}
		function defaultWriterReadyPromiseReset(n) {
			defaultWriterReadyPromiseInitialize(n);
		}
		function defaultWriterReadyPromiseResetToRejected(n, a) {
			defaultWriterReadyPromiseInitializeAsRejected(n, a);
		}
		function defaultWriterReadyPromiseResolve(n) {
			if (n._readyPromise_resolve === void 0) return;
			n._readyPromise_resolve(void 0);
			n._readyPromise_resolve = void 0;
			n._readyPromise_reject = void 0;
			n._readyPromiseState = "fulfilled";
		}
		function getGlobals() {
			if (typeof globalThis !== "undefined") return globalThis;
			else if (typeof self !== "undefined") return self;
			else if (typeof global !== "undefined") return global;
		}
		const A = getGlobals();
		function isDOMExceptionConstructor(n) {
			if (!(typeof n === "function" || typeof n === "object")) return false;
			if (n.name !== "DOMException") return false;
			try {
				new n();
				return true;
			} catch (n) {
				return false;
			}
		}
		/**
		* Support:
		* - Web browsers
		* - Node 18 and higher (https://github.com/nodejs/node/commit/e4b1fb5e6422c1ff151234bb9de792d45dd88d87)
		*/
		function getFromGlobal() {
			const n = A === null || A === void 0 ? void 0 : A.DOMException;
			return isDOMExceptionConstructor(n) ? n : void 0;
		}
		/**
		* Support:
		* - All platforms
		*/
		function createPolyfill() {
			const n = function DOMException(n, a) {
				this.message = n || "";
				this.name = a || "Error";
				if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
			};
			setFunctionName(n, "DOMException");
			n.prototype = Object.create(Error.prototype);
			Object.defineProperty(n.prototype, "constructor", {
				value: n,
				writable: true,
				configurable: true
			});
			return n;
		}
		const j = getFromGlobal() || createPolyfill();
		function ReadableStreamPipeTo(n, a, o, s, c, l) {
			const u = AcquireReadableStreamDefaultReader(n);
			const d = AcquireWritableStreamDefaultWriter(a);
			n._disturbed = true;
			let p = false;
			let g = promiseResolvedWith(void 0);
			return newPromise((_, v) => {
				let abortAlgorithm;
				if (l !== void 0) {
					abortAlgorithm = () => {
						const o = l.reason !== void 0 ? l.reason : new j("Aborted", "AbortError");
						const u = [];
						if (!s) u.push(() => {
							if (a._state === "writable") return WritableStreamAbort(a, o);
							return promiseResolvedWith(void 0);
						});
						if (!c) u.push(() => {
							if (n._state === "readable") return ReadableStreamCancel(n, o);
							return promiseResolvedWith(void 0);
						});
						shutdownWithAction(() => Promise.all(u.map((n) => n())), true, o);
					};
					if (l.aborted) {
						abortAlgorithm();
						return;
					}
					l.addEventListener("abort", abortAlgorithm);
				}
				function pipeLoop() {
					return newPromise((n, a) => {
						function next(o) {
							if (o) n();
							else PerformPromiseThen(pipeStep(), next, a);
						}
						next(false);
					});
				}
				function pipeStep() {
					if (p) return promiseResolvedWith(true);
					return PerformPromiseThen(d._readyPromise, () => {
						return newPromise((n, a) => {
							ReadableStreamDefaultReaderRead(u, {
								_chunkSteps: (a) => {
									g = PerformPromiseThen(WritableStreamDefaultWriterWrite(d, a), void 0, noop);
									n(false);
								},
								_closeSteps: () => n(true),
								_errorSteps: a
							});
						});
					});
				}
				isOrBecomesErrored(n, u._closedPromise, (n) => {
					if (!s) shutdownWithAction(() => WritableStreamAbort(a, n), true, n);
					else shutdown(true, n);
					return null;
				});
				isOrBecomesErrored(a, d._closedPromise, (a) => {
					if (!c) shutdownWithAction(() => ReadableStreamCancel(n, a), true, a);
					else shutdown(true, a);
					return null;
				});
				isOrBecomesClosed(n, u._closedPromise, () => {
					if (!o) shutdownWithAction(() => WritableStreamDefaultWriterCloseWithErrorPropagation(d));
					else shutdown();
					return null;
				});
				if (WritableStreamCloseQueuedOrInFlight(a) || a._state === "closed") {
					const a = /* @__PURE__ */ new TypeError("the destination writable stream closed before all data could be piped to it");
					if (!c) shutdownWithAction(() => ReadableStreamCancel(n, a), true, a);
					else shutdown(true, a);
				}
				setPromiseIsHandledToTrue(pipeLoop());
				function waitForWritesToFinish() {
					const n = g;
					return PerformPromiseThen(g, () => n !== g ? waitForWritesToFinish() : void 0);
				}
				function isOrBecomesErrored(n, a, o) {
					if (n._state === "errored") o(n._storedError);
					else uponRejection(a, o);
				}
				function isOrBecomesClosed(n, a, o) {
					if (n._state === "closed") o();
					else uponFulfillment(a, o);
				}
				function shutdownWithAction(n, o, s) {
					if (p) return;
					p = true;
					if (a._state === "writable" && !WritableStreamCloseQueuedOrInFlight(a)) uponFulfillment(waitForWritesToFinish(), doTheRest);
					else doTheRest();
					function doTheRest() {
						uponPromise(n(), () => finalize(o, s), (n) => finalize(true, n));
						return null;
					}
				}
				function shutdown(n, o) {
					if (p) return;
					p = true;
					if (a._state === "writable" && !WritableStreamCloseQueuedOrInFlight(a)) uponFulfillment(waitForWritesToFinish(), () => finalize(n, o));
					else finalize(n, o);
				}
				function finalize(n, a) {
					WritableStreamDefaultWriterRelease(d);
					ReadableStreamReaderGenericRelease(u);
					if (l !== void 0) l.removeEventListener("abort", abortAlgorithm);
					if (n) v(a);
					else _(void 0);
					return null;
				}
			});
		}
		/**
		* Allows control of a {@link ReadableStream | readable stream}'s state and internal queue.
		*
		* @public
		*/
		class ReadableStreamDefaultController {
			constructor() {
				throw new TypeError("Illegal constructor");
			}
			/**
			* Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is
			* over-full. An underlying source ought to use this information to determine when and how to apply backpressure.
			*/
			get desiredSize() {
				if (!IsReadableStreamDefaultController(this)) throw defaultControllerBrandCheckException$1("desiredSize");
				return ReadableStreamDefaultControllerGetDesiredSize(this);
			}
			/**
			* Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from
			* the stream, but once those are read, the stream will become closed.
			*/
			close() {
				if (!IsReadableStreamDefaultController(this)) throw defaultControllerBrandCheckException$1("close");
				if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) throw new TypeError("The stream is not in a state that permits close");
				ReadableStreamDefaultControllerClose(this);
			}
			enqueue(n = void 0) {
				if (!IsReadableStreamDefaultController(this)) throw defaultControllerBrandCheckException$1("enqueue");
				if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) throw new TypeError("The stream is not in a state that permits enqueue");
				return ReadableStreamDefaultControllerEnqueue(this, n);
			}
			/**
			* Errors the controlled readable stream, making all future interactions with it fail with the given error `e`.
			*/
			error(n = void 0) {
				if (!IsReadableStreamDefaultController(this)) throw defaultControllerBrandCheckException$1("error");
				ReadableStreamDefaultControllerError(this, n);
			}
			/** @internal */
			[p](n) {
				ResetQueue(this);
				const a = this._cancelAlgorithm(n);
				ReadableStreamDefaultControllerClearAlgorithms(this);
				return a;
			}
			/** @internal */
			[g](n) {
				const a = this._controlledReadableStream;
				if (this._queue.length > 0) {
					const o = DequeueValue(this);
					if (this._closeRequested && this._queue.length === 0) {
						ReadableStreamDefaultControllerClearAlgorithms(this);
						ReadableStreamClose(a);
					} else ReadableStreamDefaultControllerCallPullIfNeeded(this);
					n._chunkSteps(o);
				} else {
					ReadableStreamAddReadRequest(a, n);
					ReadableStreamDefaultControllerCallPullIfNeeded(this);
				}
			}
			/** @internal */
			[_]() {}
		}
		Object.defineProperties(ReadableStreamDefaultController.prototype, {
			close: { enumerable: true },
			enqueue: { enumerable: true },
			error: { enumerable: true },
			desiredSize: { enumerable: true }
		});
		setFunctionName(ReadableStreamDefaultController.prototype.close, "close");
		setFunctionName(ReadableStreamDefaultController.prototype.enqueue, "enqueue");
		setFunctionName(ReadableStreamDefaultController.prototype.error, "error");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(ReadableStreamDefaultController.prototype, Symbol.toStringTag, {
			value: "ReadableStreamDefaultController",
			configurable: true
		});
		function IsReadableStreamDefaultController(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_controlledReadableStream")) return false;
			return n instanceof ReadableStreamDefaultController;
		}
		function ReadableStreamDefaultControllerCallPullIfNeeded(n) {
			if (!ReadableStreamDefaultControllerShouldCallPull(n)) return;
			if (n._pulling) {
				n._pullAgain = true;
				return;
			}
			n._pulling = true;
			uponPromise(n._pullAlgorithm(), () => {
				n._pulling = false;
				if (n._pullAgain) {
					n._pullAgain = false;
					ReadableStreamDefaultControllerCallPullIfNeeded(n);
				}
				return null;
			}, (a) => {
				ReadableStreamDefaultControllerError(n, a);
				return null;
			});
		}
		function ReadableStreamDefaultControllerShouldCallPull(n) {
			const a = n._controlledReadableStream;
			if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(n)) return false;
			if (!n._started) return false;
			if (IsReadableStreamLocked(a) && ReadableStreamGetNumReadRequests(a) > 0) return true;
			if (ReadableStreamDefaultControllerGetDesiredSize(n) > 0) return true;
			return false;
		}
		function ReadableStreamDefaultControllerClearAlgorithms(n) {
			n._pullAlgorithm = void 0;
			n._cancelAlgorithm = void 0;
			n._strategySizeAlgorithm = void 0;
		}
		function ReadableStreamDefaultControllerClose(n) {
			if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(n)) return;
			const a = n._controlledReadableStream;
			n._closeRequested = true;
			if (n._queue.length === 0) {
				ReadableStreamDefaultControllerClearAlgorithms(n);
				ReadableStreamClose(a);
			}
		}
		function ReadableStreamDefaultControllerEnqueue(n, a) {
			if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(n)) return;
			const o = n._controlledReadableStream;
			if (IsReadableStreamLocked(o) && ReadableStreamGetNumReadRequests(o) > 0) ReadableStreamFulfillReadRequest(o, a, false);
			else {
				let o;
				try {
					o = n._strategySizeAlgorithm(a);
				} catch (a) {
					ReadableStreamDefaultControllerError(n, a);
					throw a;
				}
				try {
					EnqueueValueWithSize(n, a, o);
				} catch (a) {
					ReadableStreamDefaultControllerError(n, a);
					throw a;
				}
			}
			ReadableStreamDefaultControllerCallPullIfNeeded(n);
		}
		function ReadableStreamDefaultControllerError(n, a) {
			const o = n._controlledReadableStream;
			if (o._state !== "readable") return;
			ResetQueue(n);
			ReadableStreamDefaultControllerClearAlgorithms(n);
			ReadableStreamError(o, a);
		}
		function ReadableStreamDefaultControllerGetDesiredSize(n) {
			const a = n._controlledReadableStream._state;
			if (a === "errored") return null;
			if (a === "closed") return 0;
			return n._strategyHWM - n._queueTotalSize;
		}
		function ReadableStreamDefaultControllerHasBackpressure(n) {
			if (ReadableStreamDefaultControllerShouldCallPull(n)) return false;
			return true;
		}
		function ReadableStreamDefaultControllerCanCloseOrEnqueue(n) {
			const a = n._controlledReadableStream._state;
			if (!n._closeRequested && a === "readable") return true;
			return false;
		}
		function SetUpReadableStreamDefaultController(n, a, o, s, c, l, u) {
			a._controlledReadableStream = n;
			a._queue = void 0;
			a._queueTotalSize = void 0;
			ResetQueue(a);
			a._started = false;
			a._closeRequested = false;
			a._pullAgain = false;
			a._pulling = false;
			a._strategySizeAlgorithm = u;
			a._strategyHWM = l;
			a._pullAlgorithm = s;
			a._cancelAlgorithm = c;
			n._readableStreamController = a;
			uponPromise(promiseResolvedWith(o()), () => {
				a._started = true;
				ReadableStreamDefaultControllerCallPullIfNeeded(a);
				return null;
			}, (n) => {
				ReadableStreamDefaultControllerError(a, n);
				return null;
			});
		}
		function SetUpReadableStreamDefaultControllerFromUnderlyingSource(n, a, o, s) {
			const c = Object.create(ReadableStreamDefaultController.prototype);
			let startAlgorithm;
			let pullAlgorithm;
			let cancelAlgorithm;
			if (a.start !== void 0) startAlgorithm = () => a.start(c);
			else startAlgorithm = () => void 0;
			if (a.pull !== void 0) pullAlgorithm = () => a.pull(c);
			else pullAlgorithm = () => promiseResolvedWith(void 0);
			if (a.cancel !== void 0) cancelAlgorithm = (n) => a.cancel(n);
			else cancelAlgorithm = () => promiseResolvedWith(void 0);
			SetUpReadableStreamDefaultController(n, c, startAlgorithm, pullAlgorithm, cancelAlgorithm, o, s);
		}
		function defaultControllerBrandCheckException$1(n) {
			return /* @__PURE__ */ new TypeError(`ReadableStreamDefaultController.prototype.${n} can only be used on a ReadableStreamDefaultController`);
		}
		function ReadableStreamTee(n, a) {
			if (IsReadableByteStreamController(n._readableStreamController)) return ReadableByteStreamTee(n);
			return ReadableStreamDefaultTee(n);
		}
		function ReadableStreamDefaultTee(n, a) {
			const o = AcquireReadableStreamDefaultReader(n);
			let s = false;
			let c = false;
			let l = false;
			let u = false;
			let d;
			let p;
			let g;
			let _;
			let v;
			const y = newPromise((n) => {
				v = n;
			});
			function pullAlgorithm() {
				if (s) {
					c = true;
					return promiseResolvedWith(void 0);
				}
				s = true;
				ReadableStreamDefaultReaderRead(o, {
					_chunkSteps: (n) => {
						_queueMicrotask(() => {
							c = false;
							const a = n;
							const o = n;
							if (!l) ReadableStreamDefaultControllerEnqueue(g._readableStreamController, a);
							if (!u) ReadableStreamDefaultControllerEnqueue(_._readableStreamController, o);
							s = false;
							if (c) pullAlgorithm();
						});
					},
					_closeSteps: () => {
						s = false;
						if (!l) ReadableStreamDefaultControllerClose(g._readableStreamController);
						if (!u) ReadableStreamDefaultControllerClose(_._readableStreamController);
						if (!l || !u) v(void 0);
					},
					_errorSteps: () => {
						s = false;
					}
				});
				return promiseResolvedWith(void 0);
			}
			function cancel1Algorithm(a) {
				l = true;
				d = a;
				if (u) {
					const a = ReadableStreamCancel(n, CreateArrayFromList([d, p]));
					v(a);
				}
				return y;
			}
			function cancel2Algorithm(a) {
				u = true;
				p = a;
				if (l) {
					const a = ReadableStreamCancel(n, CreateArrayFromList([d, p]));
					v(a);
				}
				return y;
			}
			function startAlgorithm() {}
			g = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel1Algorithm);
			_ = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel2Algorithm);
			uponRejection(o._closedPromise, (n) => {
				ReadableStreamDefaultControllerError(g._readableStreamController, n);
				ReadableStreamDefaultControllerError(_._readableStreamController, n);
				if (!l || !u) v(void 0);
				return null;
			});
			return [g, _];
		}
		function ReadableByteStreamTee(n) {
			let a = AcquireReadableStreamDefaultReader(n);
			let o = false;
			let s = false;
			let c = false;
			let l = false;
			let u = false;
			let d;
			let p;
			let g;
			let _;
			let v;
			const y = newPromise((n) => {
				v = n;
			});
			function forwardReaderError(n) {
				uponRejection(n._closedPromise, (o) => {
					if (n !== a) return null;
					ReadableByteStreamControllerError(g._readableStreamController, o);
					ReadableByteStreamControllerError(_._readableStreamController, o);
					if (!l || !u) v(void 0);
					return null;
				});
			}
			function pullWithDefaultReader() {
				if (IsReadableStreamBYOBReader(a)) {
					ReadableStreamReaderGenericRelease(a);
					a = AcquireReadableStreamDefaultReader(n);
					forwardReaderError(a);
				}
				ReadableStreamDefaultReaderRead(a, {
					_chunkSteps: (a) => {
						_queueMicrotask(() => {
							s = false;
							c = false;
							const d = a;
							let p = a;
							if (!l && !u) try {
								p = CloneAsUint8Array(a);
							} catch (a) {
								ReadableByteStreamControllerError(g._readableStreamController, a);
								ReadableByteStreamControllerError(_._readableStreamController, a);
								v(ReadableStreamCancel(n, a));
								return;
							}
							if (!l) ReadableByteStreamControllerEnqueue(g._readableStreamController, d);
							if (!u) ReadableByteStreamControllerEnqueue(_._readableStreamController, p);
							o = false;
							if (s) pull1Algorithm();
							else if (c) pull2Algorithm();
						});
					},
					_closeSteps: () => {
						o = false;
						if (!l) ReadableByteStreamControllerClose(g._readableStreamController);
						if (!u) ReadableByteStreamControllerClose(_._readableStreamController);
						if (g._readableStreamController._pendingPullIntos.length > 0) ReadableByteStreamControllerRespond(g._readableStreamController, 0);
						if (_._readableStreamController._pendingPullIntos.length > 0) ReadableByteStreamControllerRespond(_._readableStreamController, 0);
						if (!l || !u) v(void 0);
					},
					_errorSteps: () => {
						o = false;
					}
				});
			}
			function pullWithBYOBReader(d, p) {
				if (IsReadableStreamDefaultReader(a)) {
					ReadableStreamReaderGenericRelease(a);
					a = AcquireReadableStreamBYOBReader(n);
					forwardReaderError(a);
				}
				const y = p ? _ : g;
				const b = p ? g : _;
				ReadableStreamBYOBReaderRead(a, d, 1, {
					_chunkSteps: (a) => {
						_queueMicrotask(() => {
							s = false;
							c = false;
							const d = p ? u : l;
							if (!(p ? l : u)) {
								let o;
								try {
									o = CloneAsUint8Array(a);
								} catch (a) {
									ReadableByteStreamControllerError(y._readableStreamController, a);
									ReadableByteStreamControllerError(b._readableStreamController, a);
									v(ReadableStreamCancel(n, a));
									return;
								}
								if (!d) ReadableByteStreamControllerRespondWithNewView(y._readableStreamController, a);
								ReadableByteStreamControllerEnqueue(b._readableStreamController, o);
							} else if (!d) ReadableByteStreamControllerRespondWithNewView(y._readableStreamController, a);
							o = false;
							if (s) pull1Algorithm();
							else if (c) pull2Algorithm();
						});
					},
					_closeSteps: (n) => {
						o = false;
						const a = p ? u : l;
						const s = p ? l : u;
						if (!a) ReadableByteStreamControllerClose(y._readableStreamController);
						if (!s) ReadableByteStreamControllerClose(b._readableStreamController);
						if (n !== void 0) {
							if (!a) ReadableByteStreamControllerRespondWithNewView(y._readableStreamController, n);
							if (!s && b._readableStreamController._pendingPullIntos.length > 0) ReadableByteStreamControllerRespond(b._readableStreamController, 0);
						}
						if (!a || !s) v(void 0);
					},
					_errorSteps: () => {
						o = false;
					}
				});
			}
			function pull1Algorithm() {
				if (o) {
					s = true;
					return promiseResolvedWith(void 0);
				}
				o = true;
				const n = ReadableByteStreamControllerGetBYOBRequest(g._readableStreamController);
				if (n === null) pullWithDefaultReader();
				else pullWithBYOBReader(n._view, false);
				return promiseResolvedWith(void 0);
			}
			function pull2Algorithm() {
				if (o) {
					c = true;
					return promiseResolvedWith(void 0);
				}
				o = true;
				const n = ReadableByteStreamControllerGetBYOBRequest(_._readableStreamController);
				if (n === null) pullWithDefaultReader();
				else pullWithBYOBReader(n._view, true);
				return promiseResolvedWith(void 0);
			}
			function cancel1Algorithm(a) {
				l = true;
				d = a;
				if (u) {
					const a = ReadableStreamCancel(n, CreateArrayFromList([d, p]));
					v(a);
				}
				return y;
			}
			function cancel2Algorithm(a) {
				u = true;
				p = a;
				if (l) {
					const a = ReadableStreamCancel(n, CreateArrayFromList([d, p]));
					v(a);
				}
				return y;
			}
			function startAlgorithm() {}
			g = CreateReadableByteStream(startAlgorithm, pull1Algorithm, cancel1Algorithm);
			_ = CreateReadableByteStream(startAlgorithm, pull2Algorithm, cancel2Algorithm);
			forwardReaderError(a);
			return [g, _];
		}
		function isReadableStreamLike(n) {
			return typeIsObject(n) && typeof n.getReader !== "undefined";
		}
		function ReadableStreamFrom(n) {
			if (isReadableStreamLike(n)) return ReadableStreamFromDefaultReader(n.getReader());
			return ReadableStreamFromIterable(n);
		}
		function ReadableStreamFromIterable(n) {
			let a;
			const o = GetIterator(n, "async");
			const s = noop;
			function pullAlgorithm() {
				let n;
				try {
					n = IteratorNext(o);
				} catch (n) {
					return promiseRejectedWith(n);
				}
				return transformPromiseWith(promiseResolvedWith(n), (n) => {
					if (!typeIsObject(n)) throw new TypeError("The promise returned by the iterator.next() method must fulfill with an object");
					if (IteratorComplete(n)) ReadableStreamDefaultControllerClose(a._readableStreamController);
					else {
						const o = IteratorValue(n);
						ReadableStreamDefaultControllerEnqueue(a._readableStreamController, o);
					}
				});
			}
			function cancelAlgorithm(n) {
				const a = o.iterator;
				let s;
				try {
					s = GetMethod(a, "return");
				} catch (n) {
					return promiseRejectedWith(n);
				}
				if (s === void 0) return promiseResolvedWith(void 0);
				let c;
				try {
					c = reflectCall(s, a, [n]);
				} catch (n) {
					return promiseRejectedWith(n);
				}
				return transformPromiseWith(promiseResolvedWith(c), (n) => {
					if (!typeIsObject(n)) throw new TypeError("The promise returned by the iterator.return() method must fulfill with an object");
				});
			}
			a = CreateReadableStream(s, pullAlgorithm, cancelAlgorithm, 0);
			return a;
		}
		function ReadableStreamFromDefaultReader(n) {
			let a;
			const o = noop;
			function pullAlgorithm() {
				let o;
				try {
					o = n.read();
				} catch (n) {
					return promiseRejectedWith(n);
				}
				return transformPromiseWith(o, (n) => {
					if (!typeIsObject(n)) throw new TypeError("The promise returned by the reader.read() method must fulfill with an object");
					if (n.done) ReadableStreamDefaultControllerClose(a._readableStreamController);
					else {
						const o = n.value;
						ReadableStreamDefaultControllerEnqueue(a._readableStreamController, o);
					}
				});
			}
			function cancelAlgorithm(a) {
				try {
					return promiseResolvedWith(n.cancel(a));
				} catch (n) {
					return promiseRejectedWith(n);
				}
			}
			a = CreateReadableStream(o, pullAlgorithm, cancelAlgorithm, 0);
			return a;
		}
		function convertUnderlyingDefaultOrByteSource(n, a) {
			assertDictionary(n, a);
			const o = n;
			const s = o === null || o === void 0 ? void 0 : o.autoAllocateChunkSize;
			const c = o === null || o === void 0 ? void 0 : o.cancel;
			const l = o === null || o === void 0 ? void 0 : o.pull;
			const u = o === null || o === void 0 ? void 0 : o.start;
			const d = o === null || o === void 0 ? void 0 : o.type;
			return {
				autoAllocateChunkSize: s === void 0 ? void 0 : convertUnsignedLongLongWithEnforceRange(s, `${a} has member 'autoAllocateChunkSize' that`),
				cancel: c === void 0 ? void 0 : convertUnderlyingSourceCancelCallback(c, o, `${a} has member 'cancel' that`),
				pull: l === void 0 ? void 0 : convertUnderlyingSourcePullCallback(l, o, `${a} has member 'pull' that`),
				start: u === void 0 ? void 0 : convertUnderlyingSourceStartCallback(u, o, `${a} has member 'start' that`),
				type: d === void 0 ? void 0 : convertReadableStreamType(d, `${a} has member 'type' that`)
			};
		}
		function convertUnderlyingSourceCancelCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => promiseCall(n, a, [o]);
		}
		function convertUnderlyingSourcePullCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => promiseCall(n, a, [o]);
		}
		function convertUnderlyingSourceStartCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => reflectCall(n, a, [o]);
		}
		function convertReadableStreamType(n, a) {
			n = `${n}`;
			if (n !== "bytes") throw new TypeError(`${a} '${n}' is not a valid enumeration value for ReadableStreamType`);
			return n;
		}
		function convertIteratorOptions(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.preventCancel;
			return { preventCancel: Boolean(o) };
		}
		function convertPipeOptions(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.preventAbort;
			const s = n === null || n === void 0 ? void 0 : n.preventCancel;
			const c = n === null || n === void 0 ? void 0 : n.preventClose;
			const l = n === null || n === void 0 ? void 0 : n.signal;
			if (l !== void 0) assertAbortSignal(l, `${a} has member 'signal' that`);
			return {
				preventAbort: Boolean(o),
				preventCancel: Boolean(s),
				preventClose: Boolean(c),
				signal: l
			};
		}
		function assertAbortSignal(n, a) {
			if (!isAbortSignal(n)) throw new TypeError(`${a} is not an AbortSignal.`);
		}
		function convertReadableWritablePair(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.readable;
			assertRequiredField(o, "readable", "ReadableWritablePair");
			assertReadableStream(o, `${a} has member 'readable' that`);
			const s = n === null || n === void 0 ? void 0 : n.writable;
			assertRequiredField(s, "writable", "ReadableWritablePair");
			assertWritableStream(s, `${a} has member 'writable' that`);
			return {
				readable: o,
				writable: s
			};
		}
		/**
		* A readable stream represents a source of data, from which you can read.
		*
		* @public
		*/
		class ReadableStream {
			constructor(n = {}, a = {}) {
				if (n === void 0) n = null;
				else assertObject(n, "First parameter");
				const o = convertQueuingStrategy(a, "Second parameter");
				const s = convertUnderlyingDefaultOrByteSource(n, "First parameter");
				InitializeReadableStream(this);
				if (s.type === "bytes") {
					if (o.size !== void 0) throw new RangeError("The strategy for a byte stream cannot have a size function");
					const n = ExtractHighWaterMark(o, 0);
					SetUpReadableByteStreamControllerFromUnderlyingSource(this, s, n);
				} else {
					const n = ExtractSizeAlgorithm(o);
					const a = ExtractHighWaterMark(o, 1);
					SetUpReadableStreamDefaultControllerFromUnderlyingSource(this, s, a, n);
				}
			}
			/**
			* Whether or not the readable stream is locked to a {@link ReadableStreamDefaultReader | reader}.
			*/
			get locked() {
				if (!IsReadableStream(this)) throw streamBrandCheckException$1("locked");
				return IsReadableStreamLocked(this);
			}
			/**
			* Cancels the stream, signaling a loss of interest in the stream by a consumer.
			*
			* The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()}
			* method, which might or might not use it.
			*/
			cancel(n = void 0) {
				if (!IsReadableStream(this)) return promiseRejectedWith(streamBrandCheckException$1("cancel"));
				if (IsReadableStreamLocked(this)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("Cannot cancel a stream that already has a reader"));
				return ReadableStreamCancel(this, n);
			}
			getReader(n = void 0) {
				if (!IsReadableStream(this)) throw streamBrandCheckException$1("getReader");
				if (convertReaderOptions(n, "First parameter").mode === void 0) return AcquireReadableStreamDefaultReader(this);
				return AcquireReadableStreamBYOBReader(this);
			}
			pipeThrough(n, a = {}) {
				if (!IsReadableStream(this)) throw streamBrandCheckException$1("pipeThrough");
				assertRequiredArgument(n, 1, "pipeThrough");
				const o = convertReadableWritablePair(n, "First parameter");
				const s = convertPipeOptions(a, "Second parameter");
				if (IsReadableStreamLocked(this)) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");
				if (IsWritableStreamLocked(o.writable)) throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");
				setPromiseIsHandledToTrue(ReadableStreamPipeTo(this, o.writable, s.preventClose, s.preventAbort, s.preventCancel, s.signal));
				return o.readable;
			}
			pipeTo(n, a = {}) {
				if (!IsReadableStream(this)) return promiseRejectedWith(streamBrandCheckException$1("pipeTo"));
				if (n === void 0) return promiseRejectedWith(`Parameter 1 is required in 'pipeTo'.`);
				if (!IsWritableStream(n)) return promiseRejectedWith(/* @__PURE__ */ new TypeError(`ReadableStream.prototype.pipeTo's first argument must be a WritableStream`));
				let o;
				try {
					o = convertPipeOptions(a, "Second parameter");
				} catch (n) {
					return promiseRejectedWith(n);
				}
				if (IsReadableStreamLocked(this)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream"));
				if (IsWritableStreamLocked(n)) return promiseRejectedWith(/* @__PURE__ */ new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream"));
				return ReadableStreamPipeTo(this, n, o.preventClose, o.preventAbort, o.preventCancel, o.signal);
			}
			/**
			* Tees this readable stream, returning a two-element array containing the two resulting branches as
			* new {@link ReadableStream} instances.
			*
			* Teeing a stream will lock it, preventing any other consumer from acquiring a reader.
			* To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be
			* propagated to the stream's underlying source.
			*
			* Note that the chunks seen in each branch will be the same object. If the chunks are not immutable,
			* this could allow interference between the two branches.
			*/
			tee() {
				if (!IsReadableStream(this)) throw streamBrandCheckException$1("tee");
				return CreateArrayFromList(ReadableStreamTee(this));
			}
			values(n = void 0) {
				if (!IsReadableStream(this)) throw streamBrandCheckException$1("values");
				const a = convertIteratorOptions(n, "First parameter");
				return AcquireReadableStreamAsyncIterator(this, a.preventCancel);
			}
			[D](n) {
				return this.values(n);
			}
			/**
			* Creates a new ReadableStream wrapping the provided iterable or async iterable.
			*
			* This can be used to adapt various kinds of objects into a readable stream,
			* such as an array, an async generator, or a Node.js readable stream.
			*/
			static from(n) {
				return ReadableStreamFrom(n);
			}
		}
		Object.defineProperties(ReadableStream, { from: { enumerable: true } });
		Object.defineProperties(ReadableStream.prototype, {
			cancel: { enumerable: true },
			getReader: { enumerable: true },
			pipeThrough: { enumerable: true },
			pipeTo: { enumerable: true },
			tee: { enumerable: true },
			values: { enumerable: true },
			locked: { enumerable: true }
		});
		setFunctionName(ReadableStream.from, "from");
		setFunctionName(ReadableStream.prototype.cancel, "cancel");
		setFunctionName(ReadableStream.prototype.getReader, "getReader");
		setFunctionName(ReadableStream.prototype.pipeThrough, "pipeThrough");
		setFunctionName(ReadableStream.prototype.pipeTo, "pipeTo");
		setFunctionName(ReadableStream.prototype.tee, "tee");
		setFunctionName(ReadableStream.prototype.values, "values");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(ReadableStream.prototype, Symbol.toStringTag, {
			value: "ReadableStream",
			configurable: true
		});
		Object.defineProperty(ReadableStream.prototype, D, {
			value: ReadableStream.prototype.values,
			writable: true,
			configurable: true
		});
		function CreateReadableStream(n, a, o, s = 1, c = () => 1) {
			const l = Object.create(ReadableStream.prototype);
			InitializeReadableStream(l);
			SetUpReadableStreamDefaultController(l, Object.create(ReadableStreamDefaultController.prototype), n, a, o, s, c);
			return l;
		}
		function CreateReadableByteStream(n, a, o) {
			const s = Object.create(ReadableStream.prototype);
			InitializeReadableStream(s);
			SetUpReadableByteStreamController(s, Object.create(ReadableByteStreamController.prototype), n, a, o, 0, void 0);
			return s;
		}
		function InitializeReadableStream(n) {
			n._state = "readable";
			n._reader = void 0;
			n._storedError = void 0;
			n._disturbed = false;
		}
		function IsReadableStream(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_readableStreamController")) return false;
			return n instanceof ReadableStream;
		}
		function IsReadableStreamLocked(n) {
			if (n._reader === void 0) return false;
			return true;
		}
		function ReadableStreamCancel(n, a) {
			n._disturbed = true;
			if (n._state === "closed") return promiseResolvedWith(void 0);
			if (n._state === "errored") return promiseRejectedWith(n._storedError);
			ReadableStreamClose(n);
			const o = n._reader;
			if (o !== void 0 && IsReadableStreamBYOBReader(o)) {
				const n = o._readIntoRequests;
				o._readIntoRequests = new SimpleQueue();
				n.forEach((n) => {
					n._closeSteps(void 0);
				});
			}
			return transformPromiseWith(n._readableStreamController[p](a), noop);
		}
		function ReadableStreamClose(n) {
			n._state = "closed";
			const a = n._reader;
			if (a === void 0) return;
			defaultReaderClosedPromiseResolve(a);
			if (IsReadableStreamDefaultReader(a)) {
				const n = a._readRequests;
				a._readRequests = new SimpleQueue();
				n.forEach((n) => {
					n._closeSteps();
				});
			}
		}
		function ReadableStreamError(n, a) {
			n._state = "errored";
			n._storedError = a;
			const o = n._reader;
			if (o === void 0) return;
			defaultReaderClosedPromiseReject(o, a);
			if (IsReadableStreamDefaultReader(o)) ReadableStreamDefaultReaderErrorReadRequests(o, a);
			else ReadableStreamBYOBReaderErrorReadIntoRequests(o, a);
		}
		function streamBrandCheckException$1(n) {
			return /* @__PURE__ */ new TypeError(`ReadableStream.prototype.${n} can only be used on a ReadableStream`);
		}
		function convertQueuingStrategyInit(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.highWaterMark;
			assertRequiredField(o, "highWaterMark", "QueuingStrategyInit");
			return { highWaterMark: convertUnrestrictedDouble(o) };
		}
		const byteLengthSizeFunction = (n) => {
			return n.byteLength;
		};
		setFunctionName(byteLengthSizeFunction, "size");
		/**
		* A queuing strategy that counts the number of bytes in each chunk.
		*
		* @public
		*/
		class ByteLengthQueuingStrategy {
			constructor(n) {
				assertRequiredArgument(n, 1, "ByteLengthQueuingStrategy");
				n = convertQueuingStrategyInit(n, "First parameter");
				this._byteLengthQueuingStrategyHighWaterMark = n.highWaterMark;
			}
			/**
			* Returns the high water mark provided to the constructor.
			*/
			get highWaterMark() {
				if (!IsByteLengthQueuingStrategy(this)) throw byteLengthBrandCheckException("highWaterMark");
				return this._byteLengthQueuingStrategyHighWaterMark;
			}
			/**
			* Measures the size of `chunk` by returning the value of its `byteLength` property.
			*/
			get size() {
				if (!IsByteLengthQueuingStrategy(this)) throw byteLengthBrandCheckException("size");
				return byteLengthSizeFunction;
			}
		}
		Object.defineProperties(ByteLengthQueuingStrategy.prototype, {
			highWaterMark: { enumerable: true },
			size: { enumerable: true }
		});
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, {
			value: "ByteLengthQueuingStrategy",
			configurable: true
		});
		function byteLengthBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`ByteLengthQueuingStrategy.prototype.${n} can only be used on a ByteLengthQueuingStrategy`);
		}
		function IsByteLengthQueuingStrategy(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_byteLengthQueuingStrategyHighWaterMark")) return false;
			return n instanceof ByteLengthQueuingStrategy;
		}
		const countSizeFunction = () => {
			return 1;
		};
		setFunctionName(countSizeFunction, "size");
		/**
		* A queuing strategy that counts the number of chunks.
		*
		* @public
		*/
		class CountQueuingStrategy {
			constructor(n) {
				assertRequiredArgument(n, 1, "CountQueuingStrategy");
				n = convertQueuingStrategyInit(n, "First parameter");
				this._countQueuingStrategyHighWaterMark = n.highWaterMark;
			}
			/**
			* Returns the high water mark provided to the constructor.
			*/
			get highWaterMark() {
				if (!IsCountQueuingStrategy(this)) throw countBrandCheckException("highWaterMark");
				return this._countQueuingStrategyHighWaterMark;
			}
			/**
			* Measures the size of `chunk` by always returning 1.
			* This ensures that the total queue size is a count of the number of chunks in the queue.
			*/
			get size() {
				if (!IsCountQueuingStrategy(this)) throw countBrandCheckException("size");
				return countSizeFunction;
			}
		}
		Object.defineProperties(CountQueuingStrategy.prototype, {
			highWaterMark: { enumerable: true },
			size: { enumerable: true }
		});
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, {
			value: "CountQueuingStrategy",
			configurable: true
		});
		function countBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`CountQueuingStrategy.prototype.${n} can only be used on a CountQueuingStrategy`);
		}
		function IsCountQueuingStrategy(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_countQueuingStrategyHighWaterMark")) return false;
			return n instanceof CountQueuingStrategy;
		}
		function convertTransformer(n, a) {
			assertDictionary(n, a);
			const o = n === null || n === void 0 ? void 0 : n.cancel;
			const s = n === null || n === void 0 ? void 0 : n.flush;
			const c = n === null || n === void 0 ? void 0 : n.readableType;
			const l = n === null || n === void 0 ? void 0 : n.start;
			const u = n === null || n === void 0 ? void 0 : n.transform;
			const d = n === null || n === void 0 ? void 0 : n.writableType;
			return {
				cancel: o === void 0 ? void 0 : convertTransformerCancelCallback(o, n, `${a} has member 'cancel' that`),
				flush: s === void 0 ? void 0 : convertTransformerFlushCallback(s, n, `${a} has member 'flush' that`),
				readableType: c,
				start: l === void 0 ? void 0 : convertTransformerStartCallback(l, n, `${a} has member 'start' that`),
				transform: u === void 0 ? void 0 : convertTransformerTransformCallback(u, n, `${a} has member 'transform' that`),
				writableType: d
			};
		}
		function convertTransformerFlushCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => promiseCall(n, a, [o]);
		}
		function convertTransformerStartCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => reflectCall(n, a, [o]);
		}
		function convertTransformerTransformCallback(n, a, o) {
			assertFunction(n, o);
			return (o, s) => promiseCall(n, a, [o, s]);
		}
		function convertTransformerCancelCallback(n, a, o) {
			assertFunction(n, o);
			return (o) => promiseCall(n, a, [o]);
		}
		/**
		* A transform stream consists of a pair of streams: a {@link WritableStream | writable stream},
		* known as its writable side, and a {@link ReadableStream | readable stream}, known as its readable side.
		* In a manner specific to the transform stream in question, writes to the writable side result in new data being
		* made available for reading from the readable side.
		*
		* @public
		*/
		class TransformStream {
			constructor(n = {}, a = {}, o = {}) {
				if (n === void 0) n = null;
				const s = convertQueuingStrategy(a, "Second parameter");
				const c = convertQueuingStrategy(o, "Third parameter");
				const l = convertTransformer(n, "First parameter");
				if (l.readableType !== void 0) throw new RangeError("Invalid readableType specified");
				if (l.writableType !== void 0) throw new RangeError("Invalid writableType specified");
				const u = ExtractHighWaterMark(c, 0);
				const d = ExtractSizeAlgorithm(c);
				const p = ExtractHighWaterMark(s, 1);
				const g = ExtractSizeAlgorithm(s);
				let _;
				const v = newPromise((n) => {
					_ = n;
				});
				InitializeTransformStream(this, v, p, g, u, d);
				SetUpTransformStreamDefaultControllerFromTransformer(this, l);
				if (l.start !== void 0) _(l.start(this._transformStreamController));
				else _(void 0);
			}
			/**
			* The readable side of the transform stream.
			*/
			get readable() {
				if (!IsTransformStream(this)) throw streamBrandCheckException("readable");
				return this._readable;
			}
			/**
			* The writable side of the transform stream.
			*/
			get writable() {
				if (!IsTransformStream(this)) throw streamBrandCheckException("writable");
				return this._writable;
			}
		}
		Object.defineProperties(TransformStream.prototype, {
			readable: { enumerable: true },
			writable: { enumerable: true }
		});
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, {
			value: "TransformStream",
			configurable: true
		});
		function InitializeTransformStream(n, a, o, s, c, l) {
			function startAlgorithm() {
				return a;
			}
			function writeAlgorithm(a) {
				return TransformStreamDefaultSinkWriteAlgorithm(n, a);
			}
			function abortAlgorithm(a) {
				return TransformStreamDefaultSinkAbortAlgorithm(n, a);
			}
			function closeAlgorithm() {
				return TransformStreamDefaultSinkCloseAlgorithm(n);
			}
			n._writable = CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, o, s);
			function pullAlgorithm() {
				return TransformStreamDefaultSourcePullAlgorithm(n);
			}
			function cancelAlgorithm(a) {
				return TransformStreamDefaultSourceCancelAlgorithm(n, a);
			}
			n._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, c, l);
			n._backpressure = void 0;
			n._backpressureChangePromise = void 0;
			n._backpressureChangePromise_resolve = void 0;
			TransformStreamSetBackpressure(n, true);
			n._transformStreamController = void 0;
		}
		function IsTransformStream(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_transformStreamController")) return false;
			return n instanceof TransformStream;
		}
		function TransformStreamError(n, a) {
			ReadableStreamDefaultControllerError(n._readable._readableStreamController, a);
			TransformStreamErrorWritableAndUnblockWrite(n, a);
		}
		function TransformStreamErrorWritableAndUnblockWrite(n, a) {
			TransformStreamDefaultControllerClearAlgorithms(n._transformStreamController);
			WritableStreamDefaultControllerErrorIfNeeded(n._writable._writableStreamController, a);
			TransformStreamUnblockWrite(n);
		}
		function TransformStreamUnblockWrite(n) {
			if (n._backpressure) TransformStreamSetBackpressure(n, false);
		}
		function TransformStreamSetBackpressure(n, a) {
			if (n._backpressureChangePromise !== void 0) n._backpressureChangePromise_resolve();
			n._backpressureChangePromise = newPromise((a) => {
				n._backpressureChangePromise_resolve = a;
			});
			n._backpressure = a;
		}
		/**
		* Allows control of the {@link ReadableStream} and {@link WritableStream} of the associated {@link TransformStream}.
		*
		* @public
		*/
		class TransformStreamDefaultController {
			constructor() {
				throw new TypeError("Illegal constructor");
			}
			/**
			* Returns the desired size to fill the readable side’s internal queue. It can be negative, if the queue is over-full.
			*/
			get desiredSize() {
				if (!IsTransformStreamDefaultController(this)) throw defaultControllerBrandCheckException("desiredSize");
				const n = this._controlledTransformStream._readable._readableStreamController;
				return ReadableStreamDefaultControllerGetDesiredSize(n);
			}
			enqueue(n = void 0) {
				if (!IsTransformStreamDefaultController(this)) throw defaultControllerBrandCheckException("enqueue");
				TransformStreamDefaultControllerEnqueue(this, n);
			}
			/**
			* Errors both the readable side and the writable side of the controlled transform stream, making all future
			* interactions with it fail with the given error `e`. Any chunks queued for transformation will be discarded.
			*/
			error(n = void 0) {
				if (!IsTransformStreamDefaultController(this)) throw defaultControllerBrandCheckException("error");
				TransformStreamDefaultControllerError(this, n);
			}
			/**
			* Closes the readable side and errors the writable side of the controlled transform stream. This is useful when the
			* transformer only needs to consume a portion of the chunks written to the writable side.
			*/
			terminate() {
				if (!IsTransformStreamDefaultController(this)) throw defaultControllerBrandCheckException("terminate");
				TransformStreamDefaultControllerTerminate(this);
			}
		}
		Object.defineProperties(TransformStreamDefaultController.prototype, {
			enqueue: { enumerable: true },
			error: { enumerable: true },
			terminate: { enumerable: true },
			desiredSize: { enumerable: true }
		});
		setFunctionName(TransformStreamDefaultController.prototype.enqueue, "enqueue");
		setFunctionName(TransformStreamDefaultController.prototype.error, "error");
		setFunctionName(TransformStreamDefaultController.prototype.terminate, "terminate");
		if (typeof Symbol.toStringTag === "symbol") Object.defineProperty(TransformStreamDefaultController.prototype, Symbol.toStringTag, {
			value: "TransformStreamDefaultController",
			configurable: true
		});
		function IsTransformStreamDefaultController(n) {
			if (!typeIsObject(n)) return false;
			if (!Object.prototype.hasOwnProperty.call(n, "_controlledTransformStream")) return false;
			return n instanceof TransformStreamDefaultController;
		}
		function SetUpTransformStreamDefaultController(n, a, o, s, c) {
			a._controlledTransformStream = n;
			n._transformStreamController = a;
			a._transformAlgorithm = o;
			a._flushAlgorithm = s;
			a._cancelAlgorithm = c;
			a._finishPromise = void 0;
			a._finishPromise_resolve = void 0;
			a._finishPromise_reject = void 0;
		}
		function SetUpTransformStreamDefaultControllerFromTransformer(n, a) {
			const o = Object.create(TransformStreamDefaultController.prototype);
			let transformAlgorithm;
			let flushAlgorithm;
			let cancelAlgorithm;
			if (a.transform !== void 0) transformAlgorithm = (n) => a.transform(n, o);
			else transformAlgorithm = (n) => {
				try {
					TransformStreamDefaultControllerEnqueue(o, n);
					return promiseResolvedWith(void 0);
				} catch (n) {
					return promiseRejectedWith(n);
				}
			};
			if (a.flush !== void 0) flushAlgorithm = () => a.flush(o);
			else flushAlgorithm = () => promiseResolvedWith(void 0);
			if (a.cancel !== void 0) cancelAlgorithm = (n) => a.cancel(n);
			else cancelAlgorithm = () => promiseResolvedWith(void 0);
			SetUpTransformStreamDefaultController(n, o, transformAlgorithm, flushAlgorithm, cancelAlgorithm);
		}
		function TransformStreamDefaultControllerClearAlgorithms(n) {
			n._transformAlgorithm = void 0;
			n._flushAlgorithm = void 0;
			n._cancelAlgorithm = void 0;
		}
		function TransformStreamDefaultControllerEnqueue(n, a) {
			const o = n._controlledTransformStream;
			const s = o._readable._readableStreamController;
			if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(s)) throw new TypeError("Readable side is not in a state that permits enqueue");
			try {
				ReadableStreamDefaultControllerEnqueue(s, a);
			} catch (n) {
				TransformStreamErrorWritableAndUnblockWrite(o, n);
				throw o._readable._storedError;
			}
			if (ReadableStreamDefaultControllerHasBackpressure(s) !== o._backpressure) TransformStreamSetBackpressure(o, true);
		}
		function TransformStreamDefaultControllerError(n, a) {
			TransformStreamError(n._controlledTransformStream, a);
		}
		function TransformStreamDefaultControllerPerformTransform(n, a) {
			return transformPromiseWith(n._transformAlgorithm(a), void 0, (a) => {
				TransformStreamError(n._controlledTransformStream, a);
				throw a;
			});
		}
		function TransformStreamDefaultControllerTerminate(n) {
			const a = n._controlledTransformStream;
			const o = a._readable._readableStreamController;
			ReadableStreamDefaultControllerClose(o);
			TransformStreamErrorWritableAndUnblockWrite(a, /* @__PURE__ */ new TypeError("TransformStream terminated"));
		}
		function TransformStreamDefaultSinkWriteAlgorithm(n, a) {
			const o = n._transformStreamController;
			if (n._backpressure) {
				const s = n._backpressureChangePromise;
				return transformPromiseWith(s, () => {
					const s = n._writable;
					if (s._state === "erroring") throw s._storedError;
					return TransformStreamDefaultControllerPerformTransform(o, a);
				});
			}
			return TransformStreamDefaultControllerPerformTransform(o, a);
		}
		function TransformStreamDefaultSinkAbortAlgorithm(n, a) {
			const o = n._transformStreamController;
			if (o._finishPromise !== void 0) return o._finishPromise;
			const s = n._readable;
			o._finishPromise = newPromise((n, a) => {
				o._finishPromise_resolve = n;
				o._finishPromise_reject = a;
			});
			const c = o._cancelAlgorithm(a);
			TransformStreamDefaultControllerClearAlgorithms(o);
			uponPromise(c, () => {
				if (s._state === "errored") defaultControllerFinishPromiseReject(o, s._storedError);
				else {
					ReadableStreamDefaultControllerError(s._readableStreamController, a);
					defaultControllerFinishPromiseResolve(o);
				}
				return null;
			}, (n) => {
				ReadableStreamDefaultControllerError(s._readableStreamController, n);
				defaultControllerFinishPromiseReject(o, n);
				return null;
			});
			return o._finishPromise;
		}
		function TransformStreamDefaultSinkCloseAlgorithm(n) {
			const a = n._transformStreamController;
			if (a._finishPromise !== void 0) return a._finishPromise;
			const o = n._readable;
			a._finishPromise = newPromise((n, o) => {
				a._finishPromise_resolve = n;
				a._finishPromise_reject = o;
			});
			const s = a._flushAlgorithm();
			TransformStreamDefaultControllerClearAlgorithms(a);
			uponPromise(s, () => {
				if (o._state === "errored") defaultControllerFinishPromiseReject(a, o._storedError);
				else {
					ReadableStreamDefaultControllerClose(o._readableStreamController);
					defaultControllerFinishPromiseResolve(a);
				}
				return null;
			}, (n) => {
				ReadableStreamDefaultControllerError(o._readableStreamController, n);
				defaultControllerFinishPromiseReject(a, n);
				return null;
			});
			return a._finishPromise;
		}
		function TransformStreamDefaultSourcePullAlgorithm(n) {
			TransformStreamSetBackpressure(n, false);
			return n._backpressureChangePromise;
		}
		function TransformStreamDefaultSourceCancelAlgorithm(n, a) {
			const o = n._transformStreamController;
			if (o._finishPromise !== void 0) return o._finishPromise;
			const s = n._writable;
			o._finishPromise = newPromise((n, a) => {
				o._finishPromise_resolve = n;
				o._finishPromise_reject = a;
			});
			const c = o._cancelAlgorithm(a);
			TransformStreamDefaultControllerClearAlgorithms(o);
			uponPromise(c, () => {
				if (s._state === "errored") defaultControllerFinishPromiseReject(o, s._storedError);
				else {
					WritableStreamDefaultControllerErrorIfNeeded(s._writableStreamController, a);
					TransformStreamUnblockWrite(n);
					defaultControllerFinishPromiseResolve(o);
				}
				return null;
			}, (a) => {
				WritableStreamDefaultControllerErrorIfNeeded(s._writableStreamController, a);
				TransformStreamUnblockWrite(n);
				defaultControllerFinishPromiseReject(o, a);
				return null;
			});
			return o._finishPromise;
		}
		function defaultControllerBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`TransformStreamDefaultController.prototype.${n} can only be used on a TransformStreamDefaultController`);
		}
		function defaultControllerFinishPromiseResolve(n) {
			if (n._finishPromise_resolve === void 0) return;
			n._finishPromise_resolve();
			n._finishPromise_resolve = void 0;
			n._finishPromise_reject = void 0;
		}
		function defaultControllerFinishPromiseReject(n, a) {
			if (n._finishPromise_reject === void 0) return;
			setPromiseIsHandledToTrue(n._finishPromise);
			n._finishPromise_reject(a);
			n._finishPromise_resolve = void 0;
			n._finishPromise_reject = void 0;
		}
		function streamBrandCheckException(n) {
			return /* @__PURE__ */ new TypeError(`TransformStream.prototype.${n} can only be used on a TransformStream`);
		}
		n.ByteLengthQueuingStrategy = ByteLengthQueuingStrategy;
		n.CountQueuingStrategy = CountQueuingStrategy;
		n.ReadableByteStreamController = ReadableByteStreamController;
		n.ReadableStream = ReadableStream;
		n.ReadableStreamBYOBReader = ReadableStreamBYOBReader;
		n.ReadableStreamBYOBRequest = ReadableStreamBYOBRequest;
		n.ReadableStreamDefaultController = ReadableStreamDefaultController;
		n.ReadableStreamDefaultReader = ReadableStreamDefaultReader;
		n.TransformStream = TransformStream;
		n.TransformStreamDefaultController = TransformStreamDefaultController;
		n.WritableStream = WritableStream;
		n.WritableStreamDefaultController = WritableStreamDefaultController;
		n.WritableStreamDefaultWriter = WritableStreamDefaultWriter;
	}));
}));
//#endregion
//#region node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/streams.cjs
var require_streams = /* @__PURE__ */ __commonJSMin((() => {
	/* c8 ignore start */
	const n = 65536;
	if (!globalThis.ReadableStream) try {
		const n = __require("node:process");
		const { emitWarning: a } = n;
		try {
			n.emitWarning = () => {};
			Object.assign(globalThis, __require("node:stream/web"));
			n.emitWarning = a;
		} catch (o) {
			n.emitWarning = a;
			throw o;
		}
	} catch (n) {
		Object.assign(globalThis, require_ponyfill_es2018());
	}
	try {
		const { Blob: a } = __require("buffer");
		if (a && !a.prototype.stream) a.prototype.stream = function name(a) {
			let o = 0;
			const s = this;
			return new ReadableStream({
				type: "bytes",
				async pull(a) {
					const c = await s.slice(o, Math.min(s.size, o + n)).arrayBuffer();
					o += c.byteLength;
					a.enqueue(new Uint8Array(c));
					if (o === s.size) a.close();
				}
			});
		};
	} catch (n) {}
}));
/* c8 ignore end */
//#endregion
//#region node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/index.js
/*! fetch-blob. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
/** @param {(Blob | Uint8Array)[]} parts */
async function* toIterator(n, a = true) {
	for (const o of n) if ("stream" in o) yield* o.stream();
	else if (ArrayBuffer.isView(o)) {
		if (a) {
			let n = o.byteOffset;
			const a = o.byteOffset + o.byteLength;
			while (n !== a) {
				const s = Math.min(a - n, POOL_SIZE);
				const c = o.buffer.slice(n, n + s);
				n += c.byteLength;
				yield new Uint8Array(c);
			}
		} else yield o;
	} else {
		let n = 0, a = o;
		while (n !== a.size) {
			const o = await a.slice(n, Math.min(a.size, n + POOL_SIZE)).arrayBuffer();
			n += o.byteLength;
			yield new Uint8Array(o);
		}
	}
}
var import_streams, POOL_SIZE, _Blob, Blob;
var init_fetch_blob = __esmMin((() => {
	import_streams = require_streams();
	POOL_SIZE = 65536;
	_Blob = class Blob {
		/** @type {Array.<(Blob|Uint8Array)>} */
		#e = [];
		#t = "";
		#n = 0;
		#r = "transparent";
		/**
		* The Blob() constructor returns a new Blob object. The content
		* of the blob consists of the concatenation of the values given
		* in the parameter array.
		*
		* @param {*} blobParts
		* @param {{ type?: string, endings?: string }} [options]
		*/
		constructor(n = [], a = {}) {
			if (typeof n !== "object" || n === null) throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
			if (typeof n[Symbol.iterator] !== "function") throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
			if (typeof a !== "object" && typeof a !== "function") throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
			if (a === null) a = {};
			const o = new TextEncoder();
			for (const a of n) {
				let n;
				if (ArrayBuffer.isView(a)) n = new Uint8Array(a.buffer.slice(a.byteOffset, a.byteOffset + a.byteLength));
				else if (a instanceof ArrayBuffer) n = new Uint8Array(a.slice(0));
				else if (a instanceof Blob) n = a;
				else n = o.encode(`${a}`);
				this.#n += ArrayBuffer.isView(n) ? n.byteLength : n.size;
				this.#e.push(n);
			}
			this.#r = `${a.endings === void 0 ? "transparent" : a.endings}`;
			const s = a.type === void 0 ? "" : String(a.type);
			this.#t = /^[\x20-\x7E]*$/.test(s) ? s : "";
		}
		/**
		* The Blob interface's size property returns the
		* size of the Blob in bytes.
		*/
		get size() {
			return this.#n;
		}
		/**
		* The type property of a Blob object returns the MIME type of the file.
		*/
		get type() {
			return this.#t;
		}
		/**
		* The text() method in the Blob interface returns a Promise
		* that resolves with a string containing the contents of
		* the blob, interpreted as UTF-8.
		*
		* @return {Promise<string>}
		*/
		async text() {
			const n = new TextDecoder();
			let a = "";
			for await (const o of toIterator(this.#e, false)) a += n.decode(o, { stream: true });
			a += n.decode();
			return a;
		}
		/**
		* The arrayBuffer() method in the Blob interface returns a
		* Promise that resolves with the contents of the blob as
		* binary data contained in an ArrayBuffer.
		*
		* @return {Promise<ArrayBuffer>}
		*/
		async arrayBuffer() {
			const n = new Uint8Array(this.size);
			let a = 0;
			for await (const o of toIterator(this.#e, false)) {
				n.set(o, a);
				a += o.length;
			}
			return n.buffer;
		}
		stream() {
			const n = toIterator(this.#e, true);
			return new globalThis.ReadableStream({
				type: "bytes",
				async pull(a) {
					const o = await n.next();
					o.done ? a.close() : a.enqueue(o.value);
				},
				async cancel() {
					await n.return();
				}
			});
		}
		/**
		* The Blob interface's slice() method creates and returns a
		* new Blob object which contains data from a subset of the
		* blob on which it's called.
		*
		* @param {number} [start]
		* @param {number} [end]
		* @param {string} [type]
		*/
		slice(n = 0, a = this.size, o = "") {
			const { size: s } = this;
			let c = n < 0 ? Math.max(s + n, 0) : Math.min(n, s);
			let l = a < 0 ? Math.max(s + a, 0) : Math.min(a, s);
			const u = Math.max(l - c, 0);
			const d = this.#e;
			const p = [];
			let g = 0;
			for (const n of d) {
				if (g >= u) break;
				const a = ArrayBuffer.isView(n) ? n.byteLength : n.size;
				if (c && a <= c) {
					c -= a;
					l -= a;
				} else {
					let o;
					if (ArrayBuffer.isView(n)) {
						o = n.subarray(c, Math.min(a, l));
						g += o.byteLength;
					} else {
						o = n.slice(c, Math.min(a, l));
						g += o.size;
					}
					l -= a;
					p.push(o);
					c = 0;
				}
			}
			const _ = new Blob([], { type: String(o).toLowerCase() });
			_.#n = u;
			_.#e = p;
			return _;
		}
		get [Symbol.toStringTag]() {
			return "Blob";
		}
		static [Symbol.hasInstance](n) {
			return n && typeof n === "object" && typeof n.constructor === "function" && (typeof n.stream === "function" || typeof n.arrayBuffer === "function") && /^(Blob|File)$/.test(n[Symbol.toStringTag]);
		}
	};
	Object.defineProperties(_Blob.prototype, {
		size: { enumerable: true },
		type: { enumerable: true },
		slice: { enumerable: true }
	});
	Blob = _Blob;
}));
//#endregion
//#region node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js
var _File, File;
var init_file = __esmMin((() => {
	init_fetch_blob();
	_File = class File extends Blob {
		#e = 0;
		#t = "";
		/**
		* @param {*[]} fileBits
		* @param {string} fileName
		* @param {{lastModified?: number, type?: string}} options
		*/ constructor(n, a, o = {}) {
			if (arguments.length < 2) throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
			super(n, o);
			if (o === null) o = {};
			const s = o.lastModified === void 0 ? Date.now() : Number(o.lastModified);
			if (!Number.isNaN(s)) this.#e = s;
			this.#t = String(a);
		}
		get name() {
			return this.#t;
		}
		get lastModified() {
			return this.#e;
		}
		get [Symbol.toStringTag]() {
			return "File";
		}
		static [Symbol.hasInstance](n) {
			return !!n && n instanceof Blob && /^(File)$/.test(n[Symbol.toStringTag]);
		}
	};
	File = _File;
}));
//#endregion
//#region node_modules/.pnpm/formdata-polyfill@4.0.10/node_modules/formdata-polyfill/esm.min.js
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
/** @param {FormData} F */
function formDataToBlob(n, a = Blob) {
	var o = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), s = [], c = `--${o}\r\nContent-Disposition: form-data; name="`;
	n.forEach((n, a) => typeof n == "string" ? s.push(c + e(a) + `"\r\n\r\n${n.replace(/\r(?!\n)|(?<!\r)\n/g, "\r\n")}\r\n`) : s.push(c + e(a) + `"; filename="${e(n.name, 1)}"\r\nContent-Type: ${n.type || "application/octet-stream"}\r\n\r\n`, n, "\r\n"));
	s.push(`--${o}--`);
	return new a(s, { type: "multipart/form-data; boundary=" + o });
}
var t, i, h, r, m, f, e, x, FormData;
var init_esm_min = __esmMin((() => {
	init_fetch_blob();
	init_file();
	({toStringTag: t, iterator: i, hasInstance: h} = Symbol), r = Math.random, m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","), f = (n, a, o) => (n += "", /^(Blob|File)$/.test(a && a[t]) ? [(o = o !== void 0 ? o + "" : a[t] == "File" ? a.name : "blob", n), a.name !== o || a[t] == "blob" ? new File([a], o, a) : a] : [n, a + ""]), e = (n, a) => (a ? n : n.replace(/\r?\n|\r/g, "\r\n")).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), x = (n, a, o) => {
		if (a.length < o) throw new TypeError(`Failed to execute '${n}' on 'FormData': ${o} arguments required, but only ${a.length} present.`);
	};
	FormData = class FormData {
		#e = [];
		constructor(...n) {
			if (n.length) throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
		}
		get [t]() {
			return "FormData";
		}
		[i]() {
			return this.entries();
		}
		static [h](n) {
			return n && typeof n === "object" && n[t] === "FormData" && !m.some((a) => typeof n[a] != "function");
		}
		append(...n) {
			x("append", arguments, 2);
			this.#e.push(f(...n));
		}
		delete(n) {
			x("delete", arguments, 1);
			n += "";
			this.#e = this.#e.filter(([a]) => a !== n);
		}
		get(n) {
			x("get", arguments, 1);
			n += "";
			for (var a = this.#e, o = a.length, s = 0; s < o; s++) if (a[s][0] === n) return a[s][1];
			return null;
		}
		getAll(n, a) {
			x("getAll", arguments, 1);
			a = [];
			n += "";
			this.#e.forEach((o) => o[0] === n && a.push(o[1]));
			return a;
		}
		has(n) {
			x("has", arguments, 1);
			n += "";
			return this.#e.some((a) => a[0] === n);
		}
		forEach(n, a) {
			x("forEach", arguments, 1);
			for (var [o, s] of this) n.call(a, s, o, this);
		}
		set(...n) {
			x("set", arguments, 2);
			var a = [], o = !0;
			n = f(...n);
			this.#e.forEach((s) => {
				s[0] === n[0] ? o && (o = !a.push(n)) : a.push(s);
			});
			o && a.push(n);
			this.#e = a;
		}
		*entries() {
			yield* this.#e;
		}
		*keys() {
			for (var [n] of this) yield n;
		}
		*values() {
			for (var [, n] of this) yield n;
		}
	};
}));
//#endregion
//#region node_modules/.pnpm/@nolyfill+domexception@1.0.28/node_modules/@nolyfill/domexception/index.js
var require_domexception = /* @__PURE__ */ __commonJSMin(((n, a) => {
	Object.defineProperty(n, "__esModule", { value: !0 }), Object.defineProperty(n, "DOMException", {
		enumerable: !0,
		get: function() {
			return DOMException;
		}
	});
	(typeof n.default === "object" && n.default !== null || typeof n.default === "function") && Object.assign(n.default, n);
	a.exports = n.default;
}));
//#endregion
//#region node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/from.js
var import_domexception, stat$1;
var init_from = __esmMin((() => {
	import_domexception = /* @__PURE__ */ __toESM(require_domexception(), 1);
	init_file();
	init_fetch_blob();
	({stat: stat$1} = promises);
}));
//#endregion
export { File as a, init_fetch_blob as c, init_esm_min as i, FormData as n, init_file as o, formDataToBlob as r, Blob as s, init_from as t };