@storm-software/linting-tools
Version:
⚡ A package containing various linting tools used to validate syntax, enforce design standards, and format code in a Storm workspace.
1,028 lines (1,023 loc) • 177 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunkUB72K2YDcjs = require('./chunk-UB72K2YD.cjs');
// ../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs
var require_node_fetch_native_DhEqb06g = _chunkUB72K2YDcjs.__commonJS.call(void 0, {
"../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DhEqb06g.cjs"(exports) {
"use strict";
_chunkUB72K2YDcjs.init_cjs_shims.call(void 0, );
var l = Object.defineProperty;
var o = (e, t) => l(e, "name", { value: t, configurable: true });
var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
function getDefaultExportFromCjs(e) {
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
}
o(getDefaultExportFromCjs, "getDefaultExportFromCjs"), exports.commonjsGlobal = commonjsGlobal, exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
}
});
// ../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs
var require_node = _chunkUB72K2YDcjs.__commonJS.call(void 0, {
"../../node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs"(exports) {
"use strict";
_chunkUB72K2YDcjs.init_cjs_shims.call(void 0, );
var ys = Object.defineProperty;
var Po = (c) => {
throw TypeError(c);
};
var u = (c, l) => ys(c, "name", { value: l, configurable: true });
var vo = (c, l, d) => l.has(c) || Po("Cannot " + d);
var D = (c, l, d) => (vo(c, l, "read from private field"), d ? d.call(c) : l.get(c));
var ye = (c, l, d) => l.has(c) ? Po("Cannot add the same private member more than once") : l instanceof WeakSet ? l.add(c) : l.set(c, d);
var ne = (c, l, d, g) => (vo(c, l, "write to private field"), g ? g.call(c, d) : l.set(c, d), d);
var Pe;
var gt;
var ot;
var Zt;
var Oe;
var _t;
var St;
var it;
var oe;
var st;
var xe;
var Ue;
var at;
Object.defineProperty(exports, "__esModule", { value: true });
var http = _chunkUB72K2YDcjs.__require.call(void 0, "http");
var https = _chunkUB72K2YDcjs.__require.call(void 0, "https");
var zlib = _chunkUB72K2YDcjs.__require.call(void 0, "zlib");
var Stream = _chunkUB72K2YDcjs.__require.call(void 0, "stream");
var require$$0 = _chunkUB72K2YDcjs.__require.call(void 0, "buffer");
var require$$0$1 = _chunkUB72K2YDcjs.__require.call(void 0, "util");
var _commonjsHelpers = require_node_fetch_native_DhEqb06g();
var require$$1 = _chunkUB72K2YDcjs.__require.call(void 0, "url");
var require$$0$2 = _chunkUB72K2YDcjs.__require.call(void 0, "net");
var node_fs = _chunkUB72K2YDcjs.__require.call(void 0, "fs");
var node_path = _chunkUB72K2YDcjs.__require.call(void 0, "path");
function _interopDefaultCompat(c) {
return c && typeof c == "object" && "default" in c ? c.default : c;
}
u(_interopDefaultCompat, "_interopDefaultCompat");
var http__default = _interopDefaultCompat(http);
var https__default = _interopDefaultCompat(https);
var zlib__default = _interopDefaultCompat(zlib);
var Stream__default = _interopDefaultCompat(Stream);
function dataUriToBuffer(c) {
if (!/^data:/i.test(c)) throw new TypeError('`uri` does not appear to be a Data URI (must begin with "data:")');
c = c.replace(/\r?\n/g, "");
const l = c.indexOf(",");
if (l === -1 || l <= 4) throw new TypeError("malformed data: URI");
const d = c.substring(5, l).split(";");
let g = "", b = false;
const R = d[0] || "text/plain";
let w = R;
for (let I = 1; I < d.length; I++) d[I] === "base64" ? b = true : d[I] && (w += `;${d[I]}`, d[I].indexOf("charset=") === 0 && (g = d[I].substring(8)));
!d[0] && !g.length && (w += ";charset=US-ASCII", g = "US-ASCII");
const A = b ? "base64" : "ascii", z = unescape(c.substring(l + 1)), B = Buffer.from(z, A);
return B.type = R, B.typeFull = w, B.charset = g, B;
}
u(dataUriToBuffer, "dataUriToBuffer");
var streams = {};
var ponyfill_es2018$1 = { exports: {} };
var ponyfill_es2018 = ponyfill_es2018$1.exports;
var hasRequiredPonyfill_es2018;
function requirePonyfill_es2018() {
return hasRequiredPonyfill_es2018 || (hasRequiredPonyfill_es2018 = 1, function(c, l) {
(function(d, g) {
g(l);
})(ponyfill_es2018, function(d) {
function g() {
}
u(g, "noop");
function b(n) {
return typeof n == "object" && n !== null || typeof n == "function";
}
u(b, "typeIsObject");
const R = g;
function w(n, o) {
try {
Object.defineProperty(n, "name", { value: o, configurable: true });
} catch (e2) {
}
}
u(w, "setFunctionName");
const A = Promise, z = Promise.prototype.then, B = Promise.reject.bind(A);
function I(n) {
return new A(n);
}
u(I, "newPromise");
function k(n) {
return I((o) => o(n));
}
u(k, "promiseResolvedWith");
function T(n) {
return B(n);
}
u(T, "promiseRejectedWith");
function $(n, o, a) {
return z.call(n, o, a);
}
u($, "PerformPromiseThen");
function v(n, o, a) {
$($(n, o, a), void 0, R);
}
u(v, "uponPromise");
function K(n, o) {
v(n, o);
}
u(K, "uponFulfillment");
function U(n, o) {
v(n, void 0, o);
}
u(U, "uponRejection");
function N(n, o, a) {
return $(n, o, a);
}
u(N, "transformPromiseWith");
function J(n) {
$(n, void 0, R);
}
u(J, "setPromiseIsHandledToTrue");
let ge = u((n) => {
if (typeof queueMicrotask == "function") ge = queueMicrotask;
else {
const o = k(void 0);
ge = u((a) => $(o, a), "_queueMicrotask");
}
return ge(n);
}, "_queueMicrotask");
function M(n, o, a) {
if (typeof n != "function") throw new TypeError("Argument is not a function");
return Function.prototype.apply.call(n, o, a);
}
u(M, "reflectCall");
function H(n, o, a) {
try {
return k(M(n, o, a));
} catch (p) {
return T(p);
}
}
u(H, "promiseCall");
const Y = 16384, Dr = class Dr {
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(o) {
const a = this._back;
let p = a;
a._elements.length === Y - 1 && (p = { _elements: [], _next: void 0 }), a._elements.push(o), p !== a && (this._back = p, a._next = p), ++this._size;
}
shift() {
const o = this._front;
let a = o;
const p = this._cursor;
let y = p + 1;
const _ = o._elements, S = _[p];
return y === Y && (a = o._next, y = 0), --this._size, this._cursor = y, o !== a && (this._front = a), _[p] = void 0, S;
}
forEach(o) {
let a = this._cursor, p = this._front, y = p._elements;
for (; (a !== y.length || p._next !== void 0) && !(a === y.length && (p = p._next, y = p._elements, a = 0, y.length === 0)); ) o(y[a]), ++a;
}
peek() {
const o = this._front, a = this._cursor;
return o._elements[a];
}
};
u(Dr, "SimpleQueue");
let Q = Dr;
const wt = Symbol("[[AbortSteps]]"), un = Symbol("[[ErrorSteps]]"), er = Symbol("[[CancelSteps]]"), tr = Symbol("[[PullSteps]]"), rr = Symbol("[[ReleaseSteps]]");
function ln(n, o) {
n._ownerReadableStream = o, o._reader = n, o._state === "readable" ? or(n) : o._state === "closed" ? Eo(n) : fn(n, o._storedError);
}
u(ln, "ReadableStreamReaderGenericInitialize");
function nr(n, o) {
const a = n._ownerReadableStream;
return le(a, o);
}
u(nr, "ReadableStreamReaderGenericCancel");
function _e(n) {
const o = n._ownerReadableStream;
o._state === "readable" ? ir(n, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")) : Ao(n, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")), o._readableStreamController[rr](), o._reader = void 0, n._ownerReadableStream = void 0;
}
u(_e, "ReadableStreamReaderGenericRelease");
function Rt(n) {
return new TypeError("Cannot " + n + " a stream using a released reader");
}
u(Rt, "readerLockException");
function or(n) {
n._closedPromise = I((o, a) => {
n._closedPromise_resolve = o, n._closedPromise_reject = a;
});
}
u(or, "defaultReaderClosedPromiseInitialize");
function fn(n, o) {
or(n), ir(n, o);
}
u(fn, "defaultReaderClosedPromiseInitializeAsRejected");
function Eo(n) {
or(n), cn(n);
}
u(Eo, "defaultReaderClosedPromiseInitializeAsResolved");
function ir(n, o) {
n._closedPromise_reject !== void 0 && (J(n._closedPromise), n._closedPromise_reject(o), n._closedPromise_resolve = void 0, n._closedPromise_reject = void 0);
}
u(ir, "defaultReaderClosedPromiseReject");
function Ao(n, o) {
fn(n, o);
}
u(Ao, "defaultReaderClosedPromiseResetToRejected");
function cn(n) {
n._closedPromise_resolve !== void 0 && (n._closedPromise_resolve(void 0), n._closedPromise_resolve = void 0, n._closedPromise_reject = void 0);
}
u(cn, "defaultReaderClosedPromiseResolve");
const dn = Number.isFinite || function(n) {
return typeof n == "number" && isFinite(n);
}, Bo = Math.trunc || function(n) {
return n < 0 ? Math.ceil(n) : Math.floor(n);
};
function qo(n) {
return typeof n == "object" || typeof n == "function";
}
u(qo, "isDictionary");
function ce(n, o) {
if (n !== void 0 && !qo(n)) throw new TypeError(`${o} is not an object.`);
}
u(ce, "assertDictionary");
function ee(n, o) {
if (typeof n != "function") throw new TypeError(`${o} is not a function.`);
}
u(ee, "assertFunction");
function ko(n) {
return typeof n == "object" && n !== null || typeof n == "function";
}
u(ko, "isObject");
function hn(n, o) {
if (!ko(n)) throw new TypeError(`${o} is not an object.`);
}
u(hn, "assertObject");
function Se(n, o, a) {
if (n === void 0) throw new TypeError(`Parameter ${o} is required in '${a}'.`);
}
u(Se, "assertRequiredArgument");
function sr(n, o, a) {
if (n === void 0) throw new TypeError(`${o} is required in '${a}'.`);
}
u(sr, "assertRequiredField");
function ar(n) {
return Number(n);
}
u(ar, "convertUnrestrictedDouble");
function pn(n) {
return n === 0 ? 0 : n;
}
u(pn, "censorNegativeZero");
function Wo(n) {
return pn(Bo(n));
}
u(Wo, "integerPart");
function ur(n, o) {
const p = Number.MAX_SAFE_INTEGER;
let y = Number(n);
if (y = pn(y), !dn(y)) throw new TypeError(`${o} is not a finite number`);
if (y = Wo(y), y < 0 || y > p) throw new TypeError(`${o} is outside the accepted range of 0 to ${p}, inclusive`);
return !dn(y) || y === 0 ? 0 : y;
}
u(ur, "convertUnsignedLongLongWithEnforceRange");
function lr(n, o) {
if (!qe(n)) throw new TypeError(`${o} is not a ReadableStream.`);
}
u(lr, "assertReadableStream");
function Ne(n) {
return new de(n);
}
u(Ne, "AcquireReadableStreamDefaultReader");
function bn(n, o) {
n._reader._readRequests.push(o);
}
u(bn, "ReadableStreamAddReadRequest");
function fr(n, o, a) {
const y = n._reader._readRequests.shift();
a ? y._closeSteps() : y._chunkSteps(o);
}
u(fr, "ReadableStreamFulfillReadRequest");
function Tt(n) {
return n._reader._readRequests.length;
}
u(Tt, "ReadableStreamGetNumReadRequests");
function mn(n) {
const o = n._reader;
return !(o === void 0 || !ve(o));
}
u(mn, "ReadableStreamHasDefaultReader");
const Mr = class Mr {
constructor(o) {
if (Se(o, 1, "ReadableStreamDefaultReader"), lr(o, "First parameter"), ke(o)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
ln(this, o), this._readRequests = new Q();
}
get closed() {
return ve(this) ? this._closedPromise : T(Ct("closed"));
}
cancel(o = void 0) {
return ve(this) ? this._ownerReadableStream === void 0 ? T(Rt("cancel")) : nr(this, o) : T(Ct("cancel"));
}
read() {
if (!ve(this)) return T(Ct("read"));
if (this._ownerReadableStream === void 0) return T(Rt("read from"));
let o, a;
const p = I((_, S) => {
o = _, a = S;
});
return ut(this, { _chunkSteps: u((_) => o({ value: _, done: false }), "_chunkSteps"), _closeSteps: u(() => o({ value: void 0, done: true }), "_closeSteps"), _errorSteps: u((_) => a(_), "_errorSteps") }), p;
}
releaseLock() {
if (!ve(this)) throw Ct("releaseLock");
this._ownerReadableStream !== void 0 && Oo(this);
}
};
u(Mr, "ReadableStreamDefaultReader");
let de = Mr;
Object.defineProperties(de.prototype, { cancel: { enumerable: true }, read: { enumerable: true }, releaseLock: { enumerable: true }, closed: { enumerable: true } }), w(de.prototype.cancel, "cancel"), w(de.prototype.read, "read"), w(de.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(de.prototype, Symbol.toStringTag, { value: "ReadableStreamDefaultReader", configurable: true });
function ve(n) {
return !b(n) || !Object.prototype.hasOwnProperty.call(n, "_readRequests") ? false : n instanceof de;
}
u(ve, "IsReadableStreamDefaultReader");
function ut(n, o) {
const a = n._ownerReadableStream;
a._disturbed = true, a._state === "closed" ? o._closeSteps() : a._state === "errored" ? o._errorSteps(a._storedError) : a._readableStreamController[tr](o);
}
u(ut, "ReadableStreamDefaultReaderRead");
function Oo(n) {
_e(n);
const o = new TypeError("Reader was released");
yn(n, o);
}
u(Oo, "ReadableStreamDefaultReaderRelease");
function yn(n, o) {
const a = n._readRequests;
n._readRequests = new Q(), a.forEach((p) => {
p._errorSteps(o);
});
}
u(yn, "ReadableStreamDefaultReaderErrorReadRequests");
function Ct(n) {
return new TypeError(`ReadableStreamDefaultReader.prototype.${n} can only be used on a ReadableStreamDefaultReader`);
}
u(Ct, "defaultReaderBrandCheckException");
const zo = Object.getPrototypeOf(Object.getPrototypeOf(async function* () {
}).prototype), xr = class xr {
constructor(o, a) {
this._ongoingPromise = void 0, this._isFinished = false, this._reader = o, this._preventCancel = a;
}
next() {
const o = u(() => this._nextSteps(), "nextSteps");
return this._ongoingPromise = this._ongoingPromise ? N(this._ongoingPromise, o, o) : o(), this._ongoingPromise;
}
return(o) {
const a = u(() => this._returnSteps(o), "returnSteps");
return this._ongoingPromise ? N(this._ongoingPromise, a, a) : a();
}
_nextSteps() {
if (this._isFinished) return Promise.resolve({ value: void 0, done: true });
const o = this._reader;
let a, p;
const y = I((S, C) => {
a = S, p = C;
});
return ut(o, { _chunkSteps: u((S) => {
this._ongoingPromise = void 0, ge(() => a({ value: S, done: false }));
}, "_chunkSteps"), _closeSteps: u(() => {
this._ongoingPromise = void 0, this._isFinished = true, _e(o), a({ value: void 0, done: true });
}, "_closeSteps"), _errorSteps: u((S) => {
this._ongoingPromise = void 0, this._isFinished = true, _e(o), p(S);
}, "_errorSteps") }), y;
}
_returnSteps(o) {
if (this._isFinished) return Promise.resolve({ value: o, done: true });
this._isFinished = true;
const a = this._reader;
if (!this._preventCancel) {
const p = nr(a, o);
return _e(a), N(p, () => ({ value: o, done: true }));
}
return _e(a), k({ value: o, done: true });
}
};
u(xr, "ReadableStreamAsyncIteratorImpl");
let Pt = xr;
const gn = { next() {
return _n(this) ? this._asyncIteratorImpl.next() : T(Sn("next"));
}, return(n) {
return _n(this) ? this._asyncIteratorImpl.return(n) : T(Sn("return"));
} };
Object.setPrototypeOf(gn, zo);
function Fo(n, o) {
const a = Ne(n), p = new Pt(a, o), y = Object.create(gn);
return y._asyncIteratorImpl = p, y;
}
u(Fo, "AcquireReadableStreamAsyncIterator");
function _n(n) {
if (!b(n) || !Object.prototype.hasOwnProperty.call(n, "_asyncIteratorImpl")) return false;
try {
return n._asyncIteratorImpl instanceof Pt;
} catch (e3) {
return false;
}
}
u(_n, "IsReadableStreamAsyncIterator");
function Sn(n) {
return new TypeError(`ReadableStreamAsyncIterator.${n} can only be used on a ReadableSteamAsyncIterator`);
}
u(Sn, "streamAsyncIteratorBrandCheckException");
const wn = Number.isNaN || function(n) {
return n !== n;
};
var cr, dr, hr;
function lt(n) {
return n.slice();
}
u(lt, "CreateArrayFromList");
function Rn(n, o, a, p, y) {
new Uint8Array(n).set(new Uint8Array(a, p, y), o);
}
u(Rn, "CopyDataBlockBytes");
let we = u((n) => (typeof n.transfer == "function" ? we = u((o) => o.transfer(), "TransferArrayBuffer") : typeof structuredClone == "function" ? we = u((o) => structuredClone(o, { transfer: [o] }), "TransferArrayBuffer") : we = u((o) => o, "TransferArrayBuffer"), we(n)), "TransferArrayBuffer"), Ee = u((n) => (typeof n.detached == "boolean" ? Ee = u((o) => o.detached, "IsDetachedBuffer") : Ee = u((o) => o.byteLength === 0, "IsDetachedBuffer"), Ee(n)), "IsDetachedBuffer");
function Tn(n, o, a) {
if (n.slice) return n.slice(o, a);
const p = a - o, y = new ArrayBuffer(p);
return Rn(y, 0, n, o, p), y;
}
u(Tn, "ArrayBufferSlice");
function vt(n, o) {
const a = n[o];
if (a != null) {
if (typeof a != "function") throw new TypeError(`${String(o)} is not a function`);
return a;
}
}
u(vt, "GetMethod");
function Io(n) {
const o = { [Symbol.iterator]: () => n.iterator }, a = async function* () {
return yield* o;
}(), p = a.next;
return { iterator: a, nextMethod: p, done: false };
}
u(Io, "CreateAsyncFromSyncIterator");
const pr = (hr = (cr = Symbol.asyncIterator) !== null && cr !== void 0 ? cr : (dr = Symbol.for) === null || dr === void 0 ? void 0 : dr.call(Symbol, "Symbol.asyncIterator")) !== null && hr !== void 0 ? hr : "@@asyncIterator";
function Cn(n, o = "sync", a) {
if (a === void 0) if (o === "async") {
if (a = vt(n, pr), a === void 0) {
const _ = vt(n, Symbol.iterator), S = Cn(n, "sync", _);
return Io(S);
}
} else a = vt(n, Symbol.iterator);
if (a === void 0) throw new TypeError("The object is not iterable");
const p = M(a, n, []);
if (!b(p)) throw new TypeError("The iterator method must return an object");
const y = p.next;
return { iterator: p, nextMethod: y, done: false };
}
u(Cn, "GetIterator");
function jo(n) {
const o = M(n.nextMethod, n.iterator, []);
if (!b(o)) throw new TypeError("The iterator.next() method must return an object");
return o;
}
u(jo, "IteratorNext");
function Lo(n) {
return !!n.done;
}
u(Lo, "IteratorComplete");
function $o(n) {
return n.value;
}
u($o, "IteratorValue");
function Do(n) {
return !(typeof n != "number" || wn(n) || n < 0);
}
u(Do, "IsNonNegativeNumber");
function Pn(n) {
const o = Tn(n.buffer, n.byteOffset, n.byteOffset + n.byteLength);
return new Uint8Array(o);
}
u(Pn, "CloneAsUint8Array");
function br(n) {
const o = n._queue.shift();
return n._queueTotalSize -= o.size, n._queueTotalSize < 0 && (n._queueTotalSize = 0), o.value;
}
u(br, "DequeueValue");
function mr(n, o, a) {
if (!Do(a) || a === 1 / 0) throw new RangeError("Size must be a finite, non-NaN, non-negative number.");
n._queue.push({ value: o, size: a }), n._queueTotalSize += a;
}
u(mr, "EnqueueValueWithSize");
function Mo(n) {
return n._queue.peek().value;
}
u(Mo, "PeekQueueValue");
function Ae(n) {
n._queue = new Q(), n._queueTotalSize = 0;
}
u(Ae, "ResetQueue");
function vn(n) {
return n === DataView;
}
u(vn, "isDataViewConstructor");
function xo(n) {
return vn(n.constructor);
}
u(xo, "isDataView");
function Uo(n) {
return vn(n) ? 1 : n.BYTES_PER_ELEMENT;
}
u(Uo, "arrayBufferViewElementSize");
const Ur = class Ur {
constructor() {
throw new TypeError("Illegal constructor");
}
get view() {
if (!yr(this)) throw Rr("view");
return this._view;
}
respond(o) {
if (!yr(this)) throw Rr("respond");
if (Se(o, 1, "respond"), o = ur(o, "First parameter"), this._associatedReadableByteStreamController === void 0) throw new TypeError("This BYOB request has been invalidated");
if (Ee(this._view.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");
qt(this._associatedReadableByteStreamController, o);
}
respondWithNewView(o) {
if (!yr(this)) throw Rr("respondWithNewView");
if (Se(o, 1, "respondWithNewView"), !ArrayBuffer.isView(o)) 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 (Ee(o.buffer)) throw new TypeError("The given view's buffer has been detached and so cannot be used as a response");
kt(this._associatedReadableByteStreamController, o);
}
};
u(Ur, "ReadableStreamBYOBRequest");
let Re = Ur;
Object.defineProperties(Re.prototype, { respond: { enumerable: true }, respondWithNewView: { enumerable: true }, view: { enumerable: true } }), w(Re.prototype.respond, "respond"), w(Re.prototype.respondWithNewView, "respondWithNewView"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Re.prototype, Symbol.toStringTag, { value: "ReadableStreamBYOBRequest", configurable: true });
const Nr = class Nr {
constructor() {
throw new TypeError("Illegal constructor");
}
get byobRequest() {
if (!ze(this)) throw ct("byobRequest");
return wr(this);
}
get desiredSize() {
if (!ze(this)) throw ct("desiredSize");
return In(this);
}
close() {
if (!ze(this)) throw ct("close");
if (this._closeRequested) throw new TypeError("The stream has already been closed; do not close it again!");
const o = this._controlledReadableByteStream._state;
if (o !== "readable") throw new TypeError(`The stream (in ${o} state) is not in the readable state and cannot be closed`);
ft(this);
}
enqueue(o) {
if (!ze(this)) throw ct("enqueue");
if (Se(o, 1, "enqueue"), !ArrayBuffer.isView(o)) throw new TypeError("chunk must be an array buffer view");
if (o.byteLength === 0) throw new TypeError("chunk must have non-zero byteLength");
if (o.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`);
Bt(this, o);
}
error(o = void 0) {
if (!ze(this)) throw ct("error");
te(this, o);
}
[er](o) {
En(this), Ae(this);
const a = this._cancelAlgorithm(o);
return At(this), a;
}
[tr](o) {
const a = this._controlledReadableByteStream;
if (this._queueTotalSize > 0) {
Fn(this, o);
return;
}
const p = this._autoAllocateChunkSize;
if (p !== void 0) {
let y;
try {
y = new ArrayBuffer(p);
} catch (S) {
o._errorSteps(S);
return;
}
const _ = { buffer: y, bufferByteLength: p, byteOffset: 0, byteLength: p, bytesFilled: 0, minimumFill: 1, elementSize: 1, viewConstructor: Uint8Array, readerType: "default" };
this._pendingPullIntos.push(_);
}
bn(a, o), Fe(this);
}
[rr]() {
if (this._pendingPullIntos.length > 0) {
const o = this._pendingPullIntos.peek();
o.readerType = "none", this._pendingPullIntos = new Q(), this._pendingPullIntos.push(o);
}
}
};
u(Nr, "ReadableByteStreamController");
let ie = Nr;
Object.defineProperties(ie.prototype, { close: { enumerable: true }, enqueue: { enumerable: true }, error: { enumerable: true }, byobRequest: { enumerable: true }, desiredSize: { enumerable: true } }), w(ie.prototype.close, "close"), w(ie.prototype.enqueue, "enqueue"), w(ie.prototype.error, "error"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ie.prototype, Symbol.toStringTag, { value: "ReadableByteStreamController", configurable: true });
function ze(n) {
return !b(n) || !Object.prototype.hasOwnProperty.call(n, "_controlledReadableByteStream") ? false : n instanceof ie;
}
u(ze, "IsReadableByteStreamController");
function yr(n) {
return !b(n) || !Object.prototype.hasOwnProperty.call(n, "_associatedReadableByteStreamController") ? false : n instanceof Re;
}
u(yr, "IsReadableStreamBYOBRequest");
function Fe(n) {
if (!Yo(n)) return;
if (n._pulling) {
n._pullAgain = true;
return;
}
n._pulling = true;
const a = n._pullAlgorithm();
v(a, () => (n._pulling = false, n._pullAgain && (n._pullAgain = false, Fe(n)), null), (p) => (te(n, p), null));
}
u(Fe, "ReadableByteStreamControllerCallPullIfNeeded");
function En(n) {
_r(n), n._pendingPullIntos = new Q();
}
u(En, "ReadableByteStreamControllerClearPendingPullIntos");
function gr(n, o) {
let a = false;
n._state === "closed" && (a = true);
const p = An(o);
o.readerType === "default" ? fr(n, p, a) : ei(n, p, a);
}
u(gr, "ReadableByteStreamControllerCommitPullIntoDescriptor");
function An(n) {
const o = n.bytesFilled, a = n.elementSize;
return new n.viewConstructor(n.buffer, n.byteOffset, o / a);
}
u(An, "ReadableByteStreamControllerConvertPullIntoDescriptor");
function Et(n, o, a, p) {
n._queue.push({ buffer: o, byteOffset: a, byteLength: p }), n._queueTotalSize += p;
}
u(Et, "ReadableByteStreamControllerEnqueueChunkToQueue");
function Bn(n, o, a, p) {
let y;
try {
y = Tn(o, a, a + p);
} catch (_) {
throw te(n, _), _;
}
Et(n, y, 0, p);
}
u(Bn, "ReadableByteStreamControllerEnqueueClonedChunkToQueue");
function qn(n, o) {
o.bytesFilled > 0 && Bn(n, o.buffer, o.byteOffset, o.bytesFilled), He(n);
}
u(qn, "ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue");
function kn(n, o) {
const a = Math.min(n._queueTotalSize, o.byteLength - o.bytesFilled), p = o.bytesFilled + a;
let y = a, _ = false;
const S = p % o.elementSize, C = p - S;
C >= o.minimumFill && (y = C - o.bytesFilled, _ = true);
const q = n._queue;
for (; y > 0; ) {
const P = q.peek(), W = Math.min(y, P.byteLength), O = o.byteOffset + o.bytesFilled;
Rn(o.buffer, O, P.buffer, P.byteOffset, W), P.byteLength === W ? q.shift() : (P.byteOffset += W, P.byteLength -= W), n._queueTotalSize -= W, Wn(n, W, o), y -= W;
}
return _;
}
u(kn, "ReadableByteStreamControllerFillPullIntoDescriptorFromQueue");
function Wn(n, o, a) {
a.bytesFilled += o;
}
u(Wn, "ReadableByteStreamControllerFillHeadPullIntoDescriptor");
function On(n) {
n._queueTotalSize === 0 && n._closeRequested ? (At(n), yt(n._controlledReadableByteStream)) : Fe(n);
}
u(On, "ReadableByteStreamControllerHandleQueueDrain");
function _r(n) {
n._byobRequest !== null && (n._byobRequest._associatedReadableByteStreamController = void 0, n._byobRequest._view = null, n._byobRequest = null);
}
u(_r, "ReadableByteStreamControllerInvalidateBYOBRequest");
function Sr(n) {
for (; n._pendingPullIntos.length > 0; ) {
if (n._queueTotalSize === 0) return;
const o = n._pendingPullIntos.peek();
kn(n, o) && (He(n), gr(n._controlledReadableByteStream, o));
}
}
u(Sr, "ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue");
function No(n) {
const o = n._controlledReadableByteStream._reader;
for (; o._readRequests.length > 0; ) {
if (n._queueTotalSize === 0) return;
const a = o._readRequests.shift();
Fn(n, a);
}
}
u(No, "ReadableByteStreamControllerProcessReadRequestsUsingQueue");
function Ho(n, o, a, p) {
const y = n._controlledReadableByteStream, _ = o.constructor, S = Uo(_), { byteOffset: C, byteLength: q } = o, P = a * S;
let W;
try {
W = we(o.buffer);
} catch (j) {
p._errorSteps(j);
return;
}
const O = { buffer: W, bufferByteLength: W.byteLength, byteOffset: C, byteLength: q, bytesFilled: 0, minimumFill: P, elementSize: S, viewConstructor: _, readerType: "byob" };
if (n._pendingPullIntos.length > 0) {
n._pendingPullIntos.push(O), $n(y, p);
return;
}
if (y._state === "closed") {
const j = new _(O.buffer, O.byteOffset, 0);
p._closeSteps(j);
return;
}
if (n._queueTotalSize > 0) {
if (kn(n, O)) {
const j = An(O);
On(n), p._chunkSteps(j);
return;
}
if (n._closeRequested) {
const j = new TypeError("Insufficient bytes to fill elements in the given buffer");
te(n, j), p._errorSteps(j);
return;
}
}
n._pendingPullIntos.push(O), $n(y, p), Fe(n);
}
u(Ho, "ReadableByteStreamControllerPullInto");
function Vo(n, o) {
o.readerType === "none" && He(n);
const a = n._controlledReadableByteStream;
if (Tr(a)) for (; Dn(a) > 0; ) {
const p = He(n);
gr(a, p);
}
}
u(Vo, "ReadableByteStreamControllerRespondInClosedState");
function Qo(n, o, a) {
if (Wn(n, o, a), a.readerType === "none") {
qn(n, a), Sr(n);
return;
}
if (a.bytesFilled < a.minimumFill) return;
He(n);
const p = a.bytesFilled % a.elementSize;
if (p > 0) {
const y = a.byteOffset + a.bytesFilled;
Bn(n, a.buffer, y - p, p);
}
a.bytesFilled -= p, gr(n._controlledReadableByteStream, a), Sr(n);
}
u(Qo, "ReadableByteStreamControllerRespondInReadableState");
function zn(n, o) {
const a = n._pendingPullIntos.peek();
_r(n), n._controlledReadableByteStream._state === "closed" ? Vo(n, a) : Qo(n, o, a), Fe(n);
}
u(zn, "ReadableByteStreamControllerRespondInternal");
function He(n) {
return n._pendingPullIntos.shift();
}
u(He, "ReadableByteStreamControllerShiftPendingPullInto");
function Yo(n) {
const o = n._controlledReadableByteStream;
return o._state !== "readable" || n._closeRequested || !n._started ? false : !!(mn(o) && Tt(o) > 0 || Tr(o) && Dn(o) > 0 || In(n) > 0);
}
u(Yo, "ReadableByteStreamControllerShouldCallPull");
function At(n) {
n._pullAlgorithm = void 0, n._cancelAlgorithm = void 0;
}
u(At, "ReadableByteStreamControllerClearAlgorithms");
function ft(n) {
const o = n._controlledReadableByteStream;
if (!(n._closeRequested || o._state !== "readable")) {
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 p = new TypeError("Insufficient bytes to fill elements in the given buffer");
throw te(n, p), p;
}
}
At(n), yt(o);
}
}
u(ft, "ReadableByteStreamControllerClose");
function Bt(n, o) {
const a = n._controlledReadableByteStream;
if (n._closeRequested || a._state !== "readable") return;
const { buffer: p, byteOffset: y, byteLength: _ } = o;
if (Ee(p)) throw new TypeError("chunk's buffer is detached and so cannot be enqueued");
const S = we(p);
if (n._pendingPullIntos.length > 0) {
const C = n._pendingPullIntos.peek();
if (Ee(C.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk");
_r(n), C.buffer = we(C.buffer), C.readerType === "none" && qn(n, C);
}
if (mn(a)) if (No(n), Tt(a) === 0) Et(n, S, y, _);
else {
n._pendingPullIntos.length > 0 && He(n);
const C = new Uint8Array(S, y, _);
fr(a, C, false);
}
else Tr(a) ? (Et(n, S, y, _), Sr(n)) : Et(n, S, y, _);
Fe(n);
}
u(Bt, "ReadableByteStreamControllerEnqueue");
function te(n, o) {
const a = n._controlledReadableByteStream;
a._state === "readable" && (En(n), Ae(n), At(n), fo(a, o));
}
u(te, "ReadableByteStreamControllerError");
function Fn(n, o) {
const a = n._queue.shift();
n._queueTotalSize -= a.byteLength, On(n);
const p = new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
o._chunkSteps(p);
}
u(Fn, "ReadableByteStreamControllerFillReadRequestFromQueue");
function wr(n) {
if (n._byobRequest === null && n._pendingPullIntos.length > 0) {
const o = n._pendingPullIntos.peek(), a = new Uint8Array(o.buffer, o.byteOffset + o.bytesFilled, o.byteLength - o.bytesFilled), p = Object.create(Re.prototype);
Zo(p, n, a), n._byobRequest = p;
}
return n._byobRequest;
}
u(wr, "ReadableByteStreamControllerGetBYOBRequest");
function In(n) {
const o = n._controlledReadableByteStream._state;
return o === "errored" ? null : o === "closed" ? 0 : n._strategyHWM - n._queueTotalSize;
}
u(In, "ReadableByteStreamControllerGetDesiredSize");
function qt(n, o) {
const a = n._pendingPullIntos.peek();
if (n._controlledReadableByteStream._state === "closed") {
if (o !== 0) throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");
} else {
if (o === 0) throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");
if (a.bytesFilled + o > a.byteLength) throw new RangeError("bytesWritten out of range");
}
a.buffer = we(a.buffer), zn(n, o);
}
u(qt, "ReadableByteStreamControllerRespond");
function kt(n, o) {
const a = n._pendingPullIntos.peek();
if (n._controlledReadableByteStream._state === "closed") {
if (o.byteLength !== 0) throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream");
} else if (o.byteLength === 0) throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");
if (a.byteOffset + a.bytesFilled !== o.byteOffset) throw new RangeError("The region specified by view does not match byobRequest");
if (a.bufferByteLength !== o.buffer.byteLength) throw new RangeError("The buffer of view has different capacity than byobRequest");
if (a.bytesFilled + o.byteLength > a.byteLength) throw new RangeError("The region specified by view is larger than byobRequest");
const y = o.byteLength;
a.buffer = we(o.buffer), zn(n, y);
}
u(kt, "ReadableByteStreamControllerRespondWithNewView");
function jn(n, o, a, p, y, _, S) {
o._controlledReadableByteStream = n, o._pullAgain = false, o._pulling = false, o._byobRequest = null, o._queue = o._queueTotalSize = void 0, Ae(o), o._closeRequested = false, o._started = false, o._strategyHWM = _, o._pullAlgorithm = p, o._cancelAlgorithm = y, o._autoAllocateChunkSize = S, o._pendingPullIntos = new Q(), n._readableStreamController = o;
const C = a();
v(k(C), () => (o._started = true, Fe(o), null), (q) => (te(o, q), null));
}
u(jn, "SetUpReadableByteStreamController");
function Go(n, o, a) {
const p = Object.create(ie.prototype);
let y, _, S;
o.start !== void 0 ? y = u(() => o.start(p), "startAlgorithm") : y = u(() => {
}, "startAlgorithm"), o.pull !== void 0 ? _ = u(() => o.pull(p), "pullAlgorithm") : _ = u(() => k(void 0), "pullAlgorithm"), o.cancel !== void 0 ? S = u((q) => o.cancel(q), "cancelAlgorithm") : S = u(() => k(void 0), "cancelAlgorithm");
const C = o.autoAllocateChunkSize;
if (C === 0) throw new TypeError("autoAllocateChunkSize must be greater than 0");
jn(n, p, y, _, S, a, C);
}
u(Go, "SetUpReadableByteStreamControllerFromUnderlyingSource");
function Zo(n, o, a) {
n._associatedReadableByteStreamController = o, n._view = a;
}
u(Zo, "SetUpReadableStreamBYOBRequest");
function Rr(n) {
return new TypeError(`ReadableStreamBYOBRequest.prototype.${n} can only be used on a ReadableStreamBYOBRequest`);
}
u(Rr, "byobRequestBrandCheckException");
function ct(n) {
return new TypeError(`ReadableByteStreamController.prototype.${n} can only be used on a ReadableByteStreamController`);
}
u(ct, "byteStreamControllerBrandCheckException");
function Ko(n, o) {
ce(n, o);
const a = _optionalChain([n, 'optionalAccess', _2 => _2.mode]);
return { mode: a === void 0 ? void 0 : Jo(a, `${o} has member 'mode' that`) };
}
u(Ko, "convertReaderOptions");
function Jo(n, o) {
if (n = `${n}`, n !== "byob") throw new TypeError(`${o} '${n}' is not a valid enumeration value for ReadableStreamReaderMode`);
return n;
}
u(Jo, "convertReadableStreamReaderMode");
function Xo(n, o) {
var a;
ce(n, o);
const p = (a = _optionalChain([n, 'optionalAccess', _3 => _3.min])) !== null && a !== void 0 ? a : 1;
return { min: ur(p, `${o} has member 'min' that`) };
}
u(Xo, "convertByobReadOptions");
function Ln(n) {
return new he(n);
}
u(Ln, "AcquireReadableStreamBYOBReader");
function $n(n, o) {
n._reader._readIntoRequests.push(o);
}
u($n, "ReadableStreamAddReadIntoRequest");
function ei(n, o, a) {
const y = n._reader._readIntoRequests.shift();
a ? y._closeSteps(o) : y._chunkSteps(o);
}
u(ei, "ReadableStreamFulfillReadIntoRequest");
function Dn(n) {
return n._reader._readIntoRequests.length;
}
u(Dn, "ReadableStreamGetNumReadIntoRequests");
function Tr(n) {
const o = n._reader;
return !(o === void 0 || !Ie(o));
}
u(Tr, "ReadableStreamHasBYOBReader");
const Hr = class Hr {
constructor(o) {
if (Se(o, 1, "ReadableStreamBYOBReader"), lr(o, "First parameter"), ke(o)) throw new TypeError("This stream has already been locked for exclusive reading by another reader");
if (!ze(o._readableStreamController)) throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");
ln(this, o), this._readIntoRequests = new Q();
}
get closed() {
return Ie(this) ? this._closedPromise : T(Wt("closed"));
}
cancel(o = void 0) {
return Ie(this) ? this._ownerReadableStream === void 0 ? T(Rt("cancel")) : nr(this, o) : T(Wt("cancel"));
}
read(o, a = {}) {
if (!Ie(this)) return T(Wt("read"));
if (!ArrayBuffer.isView(o)) return T(new TypeError("view must be an array buffer view"));
if (o.byteLength === 0) return T(new TypeError("view must have non-zero byteLength"));
if (o.buffer.byteLength === 0) return T(new TypeError("view's buffer must have non-zero byteLength"));
if (Ee(o.buffer)) return T(new TypeError("view's buffer has been detached"));
let p;
try {
p = Xo(a, "options");
} catch (P) {
return T(P);
}
const y = p.min;
if (y === 0) return T(new TypeError("options.min must be greater than 0"));
if (xo(o)) {
if (y > o.byteLength) return T(new RangeError("options.min must be less than or equal to view's byteLength"));
} else if (y > o.length) return T(new RangeError("options.min must be less than or equal to view's length"));
if (this._ownerReadableStream === void 0) return T(Rt("read from"));
let _, S;
const C = I((P, W) => {
_ = P, S = W;
});
return Mn(this, o, y, { _chunkSteps: u((P) => _({ value: P, done: false }), "_chunkSteps"), _closeSteps: u((P) => _({ value: P, done: true }), "_closeSteps"), _errorSteps: u((P) => S(P), "_errorSteps") }), C;
}
releaseLock() {
if (!Ie(this)) throw Wt("releaseLock");
this._ownerReadableStream !== void 0 && ti(this);
}
};
u(Hr, "ReadableStreamBYOBReader");
let he = Hr;
Object.defineProperties(he.prototype, { cancel: { enumerable: true }, read: { enumerable: true }, releaseLock: { enumerable: true }, closed: { enumerable: true } }), w(he.prototype.cancel, "cancel"), w(he.prototype.read, "read"), w(he.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(he.prototype, Symbol.toStringTag, { value: "ReadableStreamBYOBReader", configurable: true });
function Ie(n) {
return !b(n) || !Object.prototype.hasOwnProperty.call(n, "_readIntoRequests") ? false : n instanceof he;
}
u(Ie, "IsReadableStreamBYOBReader");
function Mn(n, o, a, p) {
const y = n._ownerReadableStream;
y._disturbed = true, y._state === "errored" ? p._errorSteps(y._storedError) : Ho(y._readableStreamController, o, a, p);
}
u(Mn, "ReadableStreamBYOBReaderRead");
function ti(n) {
_e(n);
const o = new TypeError("Reader was released");
xn(n, o);
}
u(ti, "ReadableStreamBYOBReaderRelease");
function xn(n, o) {
const a = n._readIntoRequests;
n._readIntoRequests = new Q(), a.forEach((p) => {
p._errorSteps(o);
});
}
u(xn, "ReadableStreamBYOBReaderErrorReadIntoRequests");
function Wt(n) {
return new TypeError(`ReadableStreamBYOBReader.prototype.${n} can on