UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

1,293 lines 223 kB
var yi = Object.defineProperty; var Bi = (t, e, r) => e in t ? yi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r; var dt = (t, e, r) => Bi(t, typeof e != "symbol" ? e + "" : e, r); import { c as Ei } from "./crc32-CxoSWZf_.js"; import { R as Qi, Q as Si } from "./remoteFile-H_6BTCFF.js"; import { a as Xr, b as Ri, g as vi } from "./index-CoM8QAjP.js"; import { L as xi } from "./browser-BpRiKmO-.js"; import { a as Di } from "./index-Be2G1OpM.js"; import { B as ki } from "./index-CpJXUZUB.js"; import { bV as Sr, a1 as Zr, $ as qi, a0 as Fi, u as pe, O as Ti, bW as Ni, bX as Pi } from "./JBrowsePanel-BNE3gNW1.js"; import { Q as Mi } from "./QuickLRU-BaqKky94.js"; import { r as Li } from "./rxjs-L4bS73F7.js"; const M = { CRAM_FLAG_PRESERVE_QUAL_SCORES: 1, CRAM_FLAG_DETACHED: 2, CRAM_FLAG_MATE_DOWNSTREAM: 4, CRAM_FLAG_NO_SEQ: 8, // the read is paired in sequencing, no matter whether it is mapped in a pair BAM_FPAIRED: 1, // the read is mapped in a proper pair BAM_FPROPER_PAIR: 2, // the read itself is unmapped; conflictive with BAM_FPROPER_PAIR BAM_FUNMAP: 4, // the mate is unmapped BAM_FMUNMAP: 8, // the read is mapped to the reverse strand BAM_FREVERSE: 16, // the mate is mapped to the reverse strand BAM_FMREVERSE: 32, // this is read1 BAM_FREAD1: 64, // this is read2 BAM_FREAD2: 128, // not primary alignment BAM_FSECONDARY: 256, // QC failure BAM_FQCFAIL: 512, // optical or PCR duplicate BAM_FDUP: 1024, // supplementary alignment BAM_FSUPPLEMENTARY: 2048 }; function Oi(t, e) { if (!t.lengthOnRef && !t.readLength || t.isUnknownBases()) return null; const r = t.alignmentStart - e.start; if (!t.readFeatures) return e.seq.slice(r, r + (t.lengthOnRef || 0)).toUpperCase(); let n = "", o = r, s = 0; for (; n.length < t.readLength; ) if (s < t.readFeatures.length) { const a = t.readFeatures[s]; if (a.code === "Q" || a.code === "q") s += 1; else if (a.pos === n.length + 1) if (s += 1, a.code === "b") { const i = a.data; n += i, o += i.length; } else a.code === "B" ? (n += a.data[0], o += 1) : a.code === "X" ? (n += a.sub, o += 1) : a.code === "I" ? n += a.data : a.code === "D" ? o += a.data : a.code === "i" ? n += a.data : a.code === "N" ? o += a.data : a.code === "S" ? n += a.data : a.code === "P" || a.code; else if (s < t.readFeatures.length) { const i = e.seq.slice(o, o + a.pos - n.length - 1); n += i, o += i.length; } } else { const a = e.seq.slice(o, o + t.readLength - n.length); n += a, o += a.length; } return n.toUpperCase(); } const Hi = { a: 0, A: 0, c: 1, C: 1, g: 2, G: 2, t: 3, T: 3, n: 4, N: 4 }; function Ui(t, e, r, n) { const o = n.refPos - e.start, s = e.seq.charAt(o); s && (n.ref = s); let a = Hi[s]; a === void 0 && (a = 4); const l = r.substitutionMatrix[a][n.data]; l && (n.sub = l); } const Yi = [ [1, "Paired"], [2, "ProperlyPaired"], [4, "SegmentUnmapped"], [8, "MateUnmapped"], [16, "ReverseComplemented"], // the mate is mapped to the reverse strand [32, "MateReverseComplemented"], // this is read1 [64, "Read1"], // this is read2 [128, "Read2"], // not primary alignment [256, "Secondary"], // QC failure [512, "FailedQc"], // optical or PCR duplicate [1024, "Duplicate"], // supplementary alignment [2048, "Supplementary"] ], Gi = [ [1, "PreservingQualityScores"], [2, "Detached"], [4, "WithMateDownstream"], [8, "DecodeSequenceAsStar"] ], zi = [ [1, "OnNegativeStrand"], [2, "Unmapped"] ]; function Rr(t) { const e = {}; for (const [r, n] of t) e[`is${n}`] = (o) => !!(o & r), e[`set${n}`] = (o) => o | r; return e; } const Xt = Rr(Yi), Je = Rr(Gi), en = Rr(zi); class Ji { constructor({ flags: e, cramFlags: r, readLength: n, mappingQuality: o, lengthOnRef: s, qualityScores: a, mateRecordNumber: i, readBases: l, readFeatures: c, mateToUse: A, readGroupId: u, readName: d, sequenceId: g, uniqueId: f, templateSize: I, alignmentStart: h, tags: C }) { this.flags = e, this.cramFlags = r, this.readLength = n, this.mappingQuality = o, this.lengthOnRef = s, this.qualityScores = a, l && (this.readBases = l), this.readGroupId = u, this.readName = d, this.sequenceId = g, this.uniqueId = f, this.templateSize = I, this.alignmentStart = h, this.tags = C, c && (this.readFeatures = c), A && (this.mate = { flags: A.mateFlags, readName: A.mateReadName, sequenceId: A.mateSequenceId, alignmentStart: A.mateAlignmentStart }), i && (this.mateRecordNumber = i); } /** * @returns {boolean} true if the read is paired, regardless of whether both segments are mapped */ isPaired() { return !!(this.flags & M.BAM_FPAIRED); } /** @returns {boolean} true if the read is paired, and both segments are mapped */ isProperlyPaired() { return !!(this.flags & M.BAM_FPROPER_PAIR); } /** @returns {boolean} true if the read itself is unmapped; conflictive with isProperlyPaired */ isSegmentUnmapped() { return !!(this.flags & M.BAM_FUNMAP); } /** @returns {boolean} true if the read itself is unmapped; conflictive with isProperlyPaired */ isMateUnmapped() { return !!(this.flags & M.BAM_FMUNMAP); } /** @returns {boolean} true if the read is mapped to the reverse strand */ isReverseComplemented() { return !!(this.flags & M.BAM_FREVERSE); } /** @returns {boolean} true if the mate is mapped to the reverse strand */ isMateReverseComplemented() { return !!(this.flags & M.BAM_FMREVERSE); } /** @returns {boolean} true if this is read number 1 in a pair */ isRead1() { return !!(this.flags & M.BAM_FREAD1); } /** @returns {boolean} true if this is read number 2 in a pair */ isRead2() { return !!(this.flags & M.BAM_FREAD2); } /** @returns {boolean} true if this is a secondary alignment */ isSecondary() { return !!(this.flags & M.BAM_FSECONDARY); } /** @returns {boolean} true if this read has failed QC checks */ isFailedQc() { return !!(this.flags & M.BAM_FQCFAIL); } /** @returns {boolean} true if the read is an optical or PCR duplicate */ isDuplicate() { return !!(this.flags & M.BAM_FDUP); } /** @returns {boolean} true if this is a supplementary alignment */ isSupplementary() { return !!(this.flags & M.BAM_FSUPPLEMENTARY); } /** * @returns {boolean} true if the read is detached */ isDetached() { return !!(this.cramFlags & M.CRAM_FLAG_DETACHED); } /** @returns {boolean} true if the read has a mate in this same CRAM segment */ hasMateDownStream() { return !!(this.cramFlags & M.CRAM_FLAG_MATE_DOWNSTREAM); } /** @returns {boolean} true if the read contains qual scores */ isPreservingQualityScores() { return !!(this.cramFlags & M.CRAM_FLAG_PRESERVE_QUAL_SCORES); } /** @returns {boolean} true if the read has no sequence bases */ isUnknownBases() { return !!(this.cramFlags & M.CRAM_FLAG_NO_SEQ); } /** * Get the original sequence of this read. * @returns {String} sequence basepairs */ getReadBases() { if (!this.readBases && this._refRegion) { const e = Oi(this, this._refRegion); e && (this.readBases = e); } return this.readBases; } /** * Get the pair orientation of a paired read. Adapted from igv.js * @returns {String} of paired orientatin */ getPairOrientation() { if (!this.isSegmentUnmapped() && this.isPaired() && !this.isMateUnmapped() && this.mate && this.sequenceId === this.mate.sequenceId) { const e = this.isReverseComplemented() ? "R" : "F", r = this.isMateReverseComplemented() ? "R" : "F"; let n = " ", o = " "; this.isRead1() ? (n = "1", o = "2") : this.isRead2() && (n = "2", o = "1"); const s = []; let a = this.templateLength || this.templateSize; if (a === void 0) throw new Error("One of templateSize and templateLength must be set"); return this.alignmentStart > this.mate.alignmentStart && a > 0 && (a = -a), a > 0 ? (s[0] = e, s[1] = n, s[2] = r, s[3] = o) : (s[2] = e, s[3] = n, s[0] = r, s[1] = o), s.join(""); } return null; } /** * Annotates this feature with the given reference sequence basepair * information. This will add a `sub` and a `ref` item to base * substitution read features given the actual substituted and reference * base pairs, and will make the `getReadSequence()` method work. * * @param {object} refRegion * @param {number} refRegion.start * @param {number} refRegion.end * @param {string} refRegion.seq * @param {CramContainerCompressionScheme} compressionScheme * @returns {undefined} nothing */ addReferenceSequence(e, r) { this.readFeatures && this.readFeatures.forEach((n) => { n.code === "X" && Ui(this, e, r, n); }), !this.readBases && e.start <= this.alignmentStart && e.end >= this.alignmentStart + (this.lengthOnRef || this.readLength) - 1 && (this._refRegion = e); } toJSON() { const e = {}; return Object.keys(this).forEach((r) => { r.startsWith("_") || (e[r] = this[r]); }), e.readBases = this.getReadBases(), e; } } var bt = { exports: {} }; /** * @license * web-streams-polyfill v4.2.0 * Copyright 2025 Mattias Buelens, Diwank Singh Tomer and other contributors. * This code is released under the MIT license. * SPDX-License-Identifier: MIT */ function tt() { } function O(t) { return typeof t == "object" && t !== null || typeof t == "function"; } const $n = tt; function q(t, e) { try { Object.defineProperty(t, "name", { value: e, configurable: !0 }); } catch { } } const vr = Promise, Ki = Promise.resolve.bind(vr), Wi = Promise.prototype.then, ji = Promise.reject.bind(vr), $i = Ki; function H(t) { return new vr(t); } function F(t) { return H((e) => e(t)); } function b(t) { return ji(t); } function X(t, e, r) { return Wi.call(t, e, r); } function G(t, e, r) { X(X(t, e, r), void 0, $n); } function Zt(t, e) { G(t, e); } function gr(t, e) { G(t, void 0, e); } function ie(t, e, r) { return X(t, e, r); } function ze(t) { X(t, void 0, $n); } let Se = (t) => { if (typeof queueMicrotask == "function") Se = queueMicrotask; else { const e = F(void 0); Se = (r) => X(e, r); } return Se(t); }; function xe(t, e, r) { if (typeof t != "function") throw new TypeError("Argument is not a function"); return Function.prototype.apply.call(t, e, r); } function ae(t, e, r) { try { return F(xe(t, e, r)); } catch (n) { return b(n); } } class K { 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(e) { const r = this._back; let n = r; r._elements.length === 16383 && (n = { _elements: [], _next: void 0 }), r._elements.push(e), n !== r && (this._back = n, r._next = n), ++this._size; } shift() { const e = this._front; let r = e; const n = this._cursor; let o = n + 1; const s = e._elements, a = s[n]; return o === 16384 && (r = e._next, o = 0), --this._size, this._cursor = o, e !== r && (this._front = r), s[n] = void 0, a; } forEach(e) { let r = this._cursor, n = this._front, o = n._elements; for (; !(r === o.length && n._next === void 0 || r === o.length && (n = n._next, o = n._elements, r = 0, o.length === 0)); ) e(o[r]), ++r; } peek() { const e = this._front, r = this._cursor; return e._elements[r]; } } const Vn = Symbol("[[AbortSteps]]"), Xn = Symbol("[[ErrorSteps]]"), xr = Symbol("[[CancelSteps]]"), Dr = Symbol("[[PullSteps]]"), kr = Symbol("[[ReleaseSteps]]"); function Zn(t, e) { t._ownerReadableStream = e, e._reader = t, e._state === "readable" ? fr(t) : e._state === "closed" ? (function(r) { fr(r), to(r); })(t) : eo(t, e._storedError); } function qr(t, e) { return j(t._ownerReadableStream, e); } function oe(t) { const e = t._ownerReadableStream; e._state === "readable" ? Fr(t, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")) : (function(r, n) { eo(r, n); })(t, new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")), e._readableStreamController[kr](), e._reader = void 0, t._ownerReadableStream = void 0; } function Dt(t) { return new TypeError("Cannot " + t + " a stream using a released reader"); } function fr(t) { t._closedPromise = H((e, r) => { t._closedPromise_resolve = e, t._closedPromise_reject = r; }); } function eo(t, e) { fr(t), Fr(t, e); } function Fr(t, e) { t._closedPromise_reject !== void 0 && (ze(t._closedPromise), t._closedPromise_reject(e), t._closedPromise_resolve = void 0, t._closedPromise_reject = void 0); } function to(t) { t._closedPromise_resolve !== void 0 && (t._closedPromise_resolve(void 0), t._closedPromise_resolve = void 0, t._closedPromise_reject = void 0); } const tn = Number.isFinite || function(t) { return typeof t == "number" && isFinite(t); }, Vi = Math.trunc || function(t) { return t < 0 ? Math.ceil(t) : Math.floor(t); }; function Z(t, e) { if (t !== void 0 && typeof (r = t) != "object" && typeof r != "function") throw new TypeError(`${e} is not an object.`); var r; } function W(t, e) { if (typeof t != "function") throw new TypeError(`${e} is not a function.`); } function ro(t, e) { if (!/* @__PURE__ */ (function(r) { return typeof r == "object" && r !== null || typeof r == "function"; })(t)) throw new TypeError(`${e} is not an object.`); } function se(t, e, r) { if (t === void 0) throw new TypeError(`Parameter ${e} is required in '${r}'.`); } function hr(t, e, r) { if (t === void 0) throw new TypeError(`${e} is required in '${r}'.`); } function Tr(t) { return Number(t); } function rn(t) { return t === 0 ? 0 : t; } function Nr(t, e) { const r = Number.MAX_SAFE_INTEGER; let n = Number(t); if (n = rn(n), !tn(n)) throw new TypeError(`${e} is not a finite number`); if (n = (function(o) { return rn(Vi(o)); })(n), n < 0 || n > r) throw new TypeError(`${e} is outside the accepted range of 0 to ${r}, inclusive`); return tn(n) && n !== 0 ? n : 0; } function Pr(t, e) { if (!Ae(t)) throw new TypeError(`${e} is not a ReadableStream.`); } function Le(t) { return new ce(t); } function no(t, e) { t._reader._readRequests.push(e); } function Mr(t, e, r) { const n = t._reader._readRequests.shift(); r ? n._closeSteps() : n._chunkSteps(e); } function zt(t) { return t._reader._readRequests.length; } function oo(t) { const e = t._reader; return e !== void 0 && !!ge(e); } class ce { constructor(e) { if (se(e, 1, "ReadableStreamDefaultReader"), Pr(e, "First parameter"), fe(e)) throw new TypeError("This stream has already been locked for exclusive reading by another reader"); Zn(this, e), this._readRequests = new K(); } get closed() { return ge(this) ? this._closedPromise : b(ut("closed")); } cancel(e = void 0) { return ge(this) ? this._ownerReadableStream === void 0 ? b(Dt("cancel")) : qr(this, e) : b(ut("cancel")); } read() { if (!ge(this)) return b(ut("read")); if (this._ownerReadableStream === void 0) return b(Dt("read from")); let e, r; const n = H((o, s) => { e = o, r = s; }); return rt(this, { _chunkSteps: (o) => e({ value: o, done: !1 }), _closeSteps: () => e({ value: void 0, done: !0 }), _errorSteps: (o) => r(o) }), n; } releaseLock() { if (!ge(this)) throw ut("releaseLock"); this._ownerReadableStream !== void 0 && (function(e) { oe(e); const r = new TypeError("Reader was released"); io(e, r); })(this); } } function ge(t) { return !!O(t) && !!Object.prototype.hasOwnProperty.call(t, "_readRequests") && t instanceof ce; } function rt(t, e) { const r = t._ownerReadableStream; r._disturbed = !0, r._state === "closed" ? e._closeSteps() : r._state === "errored" ? e._errorSteps(r._storedError) : r._readableStreamController[Dr](e); } function io(t, e) { const r = t._readRequests; t._readRequests = new K(), r.forEach((n) => { n._errorSteps(e); }); } function ut(t) { return new TypeError(`ReadableStreamDefaultReader.prototype.${t} can only be used on a ReadableStreamDefaultReader`); } var er, tr, rr; function We(t) { return t.slice(); } function so(t, e, r, n, o) { new Uint8Array(t).set(new Uint8Array(r, n, o), e); } Object.defineProperties(ce.prototype, { cancel: { enumerable: !0 }, read: { enumerable: !0 }, releaseLock: { enumerable: !0 }, closed: { enumerable: !0 } }), q(ce.prototype.cancel, "cancel"), q(ce.prototype.read, "read"), q(ce.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(ce.prototype, Symbol.toStringTag, { value: "ReadableStreamDefaultReader", configurable: !0 }); let De = (t) => (De = typeof t.transfer == "function" ? (e) => e.transfer() : typeof structuredClone == "function" ? (e) => structuredClone(e, { transfer: [e] }) : (e) => e, De(t)), ke = (t) => (ke = typeof t.detached == "boolean" ? (e) => e.detached : (e) => e.byteLength === 0, ke(t)); function ao(t, e, r) { if (t.slice) return t.slice(e, r); const n = r - e, o = new ArrayBuffer(n); return so(o, 0, t, e, n), o; } function je(t, e) { const r = t[e]; if (r != null) { if (typeof r != "function") throw new TypeError(`${String(e)} is not a function`); return r; } } function nn(t) { try { const e = t.done, r = t.value; return X($i(r), (n) => ({ done: e, value: n })); } catch (e) { return b(e); } } const At = (rr = (er = Symbol.asyncIterator) !== null && er !== void 0 ? er : (tr = Symbol.for) === null || tr === void 0 ? void 0 : tr.call(Symbol, "Symbol.asyncIterator")) !== null && rr !== void 0 ? rr : "@@asyncIterator"; function Ao(t, e = "sync", r) { if (r === void 0) if (e === "async") { if ((r = je(t, At)) === void 0) return (function(o) { const s = { next() { let a; try { a = co(o); } catch (i) { return b(i); } return nn(a); }, return(a) { let i; try { const l = je(o.iterator, "return"); if (l === void 0) return F({ done: !0, value: a }); i = xe(l, o.iterator, [a]); } catch (l) { return b(l); } return O(i) ? nn(i) : b(new TypeError("The iterator.return() method must return an object")); } }; return { iterator: s, nextMethod: s.next, done: !1 }; })(Ao(t, "sync", je(t, Symbol.iterator))); } else r = je(t, Symbol.iterator); if (r === void 0) throw new TypeError("The object is not iterable"); const n = xe(r, t, []); if (!O(n)) throw new TypeError("The iterator method must return an object"); return { iterator: n, nextMethod: n.next, done: !1 }; } function co(t) { const e = xe(t.nextMethod, t.iterator, []); if (!O(e)) throw new TypeError("The iterator.next() method must return an object"); return e; } class lo { constructor(e, r) { this._ongoingPromise = void 0, this._isFinished = !1, this._reader = e, this._preventCancel = r; } next() { const e = () => this._nextSteps(); return this._ongoingPromise = this._ongoingPromise ? ie(this._ongoingPromise, e, e) : e(), this._ongoingPromise; } return(e) { const r = () => this._returnSteps(e); return this._ongoingPromise = this._ongoingPromise ? ie(this._ongoingPromise, r, r) : r(), this._ongoingPromise; } _nextSteps() { if (this._isFinished) return Promise.resolve({ value: void 0, done: !0 }); const e = this._reader; let r, n; const o = H((s, a) => { r = s, n = a; }); return rt(e, { _chunkSteps: (s) => { this._ongoingPromise = void 0, Se(() => r({ value: s, done: !1 })); }, _closeSteps: () => { this._ongoingPromise = void 0, this._isFinished = !0, oe(e), r({ value: void 0, done: !0 }); }, _errorSteps: (s) => { this._ongoingPromise = void 0, this._isFinished = !0, oe(e), n(s); } }), o; } _returnSteps(e) { if (this._isFinished) return Promise.resolve({ value: e, done: !0 }); this._isFinished = !0; const r = this._reader; if (!this._preventCancel) { const n = qr(r, e); return oe(r), ie(n, () => ({ value: e, done: !0 })); } return oe(r), F({ value: e, done: !0 }); } } const uo = { next() { return on(this) ? this._asyncIteratorImpl.next() : b(sn("next")); }, return(t) { return on(this) ? this._asyncIteratorImpl.return(t) : b(sn("return")); }, [At]() { return this; } }; function on(t) { if (!O(t) || !Object.prototype.hasOwnProperty.call(t, "_asyncIteratorImpl")) return !1; try { return t._asyncIteratorImpl instanceof lo; } catch { return !1; } } function sn(t) { return new TypeError(`ReadableStreamAsyncIterator.${t} can only be used on a ReadableSteamAsyncIterator`); } Object.defineProperty(uo, At, { enumerable: !1 }); const go = Number.isNaN || function(t) { return t != t; }; function an(t) { const e = ao(t.buffer, t.byteOffset, t.byteOffset + t.byteLength); return new Uint8Array(e); } function Cr(t) { const e = t._queue.shift(); return t._queueTotalSize -= e.size, t._queueTotalSize < 0 && (t._queueTotalSize = 0), e.value; } function Lr(t, e, r) { if (typeof (n = r) != "number" || go(n) || n < 0 || r === 1 / 0) throw new RangeError("Size must be a finite, non-NaN, non-negative number."); var n; t._queue.push({ value: e, size: r }), t._queueTotalSize += r; } function Ce(t) { t._queue = new K(), t._queueTotalSize = 0; } function fo(t) { return t === DataView; } class Be { constructor() { throw new TypeError("Illegal constructor"); } get view() { if (!nr(this)) throw or("view"); return this._view; } respond(e) { if (!nr(this)) throw or("respond"); if (se(e, 1, "respond"), e = Nr(e, "First parameter"), this._associatedReadableByteStreamController === void 0) throw new TypeError("This BYOB request has been invalidated"); if (ke(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, e); } respondWithNewView(e) { if (!nr(this)) throw or("respondWithNewView"); if (se(e, 1, "respondWithNewView"), !ArrayBuffer.isView(e)) 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 (ke(e.buffer)) throw new TypeError("The given view's buffer has been detached and so cannot be used as a response"); St(this._associatedReadableByteStreamController, e); } } Object.defineProperties(Be.prototype, { respond: { enumerable: !0 }, respondWithNewView: { enumerable: !0 }, view: { enumerable: !0 } }), q(Be.prototype.respond, "respond"), q(Be.prototype.respondWithNewView, "respondWithNewView"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(Be.prototype, Symbol.toStringTag, { value: "ReadableStreamBYOBRequest", configurable: !0 }); class re { constructor() { throw new TypeError("Illegal constructor"); } get byobRequest() { if (!ye(this)) throw Ke("byobRequest"); return mr(this); } get desiredSize() { if (!ye(this)) throw Ke("desiredSize"); return Eo(this); } close() { if (!ye(this)) throw Ke("close"); if (this._closeRequested) throw new TypeError("The stream has already been closed; do not close it again!"); const e = this._controlledReadableByteStream._state; if (e !== "readable") throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`); $e(this); } enqueue(e) { if (!ye(this)) throw Ke("enqueue"); if (se(e, 1, "enqueue"), !ArrayBuffer.isView(e)) throw new TypeError("chunk must be an array buffer view"); if (e.byteLength === 0) throw new TypeError("chunk must have non-zero byteLength"); if (e.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 r = this._controlledReadableByteStream._state; if (r !== "readable") throw new TypeError(`The stream (in ${r} state) is not in the readable state and cannot be enqueued to`); Et(this, e); } error(e = void 0) { if (!ye(this)) throw Ke("error"); J(this, e); } [xr](e) { ho(this), Ce(this); const r = this._cancelAlgorithm(e); return Jt(this), r; } [Dr](e) { const r = this._controlledReadableByteStream; if (this._queueTotalSize > 0) return void Bo(this, e); const n = this._autoAllocateChunkSize; if (n !== void 0) { let o; try { o = new ArrayBuffer(n); } catch (a) { return void e._errorSteps(a); } const s = { buffer: o, bufferByteLength: n, byteOffset: 0, byteLength: n, bytesFilled: 0, minimumFill: 1, elementSize: 1, viewConstructor: Uint8Array, readerType: "default" }; this._pendingPullIntos.push(s); } no(r, e), Fe(this); } [kr]() { if (this._pendingPullIntos.length > 0) { const e = this._pendingPullIntos.peek(); e.readerType = "none", this._pendingPullIntos = new K(), this._pendingPullIntos.push(e); } } } function ye(t) { return !!O(t) && !!Object.prototype.hasOwnProperty.call(t, "_controlledReadableByteStream") && t instanceof re; } function nr(t) { return !!O(t) && !!Object.prototype.hasOwnProperty.call(t, "_associatedReadableByteStreamController") && t instanceof Be; } function Fe(t) { if ((function(r) { const n = r._controlledReadableByteStream; return n._state !== "readable" || r._closeRequested || !r._started ? !1 : !!(oo(n) && zt(n) > 0 || Hr(n) && Ro(n) > 0 || Eo(r) > 0); })(t)) { if (t._pulling) return void (t._pullAgain = !0); t._pulling = !0, G(t._pullAlgorithm(), () => (t._pulling = !1, t._pullAgain && (t._pullAgain = !1, Fe(t)), null), (r) => (J(t, r), null)); } } function ho(t) { Or(t), t._pendingPullIntos = new K(); } function Co(t, e) { let r = !1; t._state === "closed" && (r = !0); const n = Io(e); e.readerType === "default" ? Mr(t, n, r) : (function(o, s, a) { const i = o._reader, l = i._readIntoRequests.shift(); a ? l._closeSteps(s) : l._chunkSteps(s); })(t, n, r); } function yt(t, e) { for (let r = 0; r < e.length; ++r) Co(t, e[r]); } function Io(t) { const e = t.bytesFilled, r = t.elementSize; return new t.viewConstructor(t.buffer, t.byteOffset, e / r); } function Bt(t, e, r, n) { t._queue.push({ buffer: e, byteOffset: r, byteLength: n }), t._queueTotalSize += n; } function mo(t, e, r, n) { let o; try { o = ao(e, r, r + n); } catch (s) { throw J(t, s), s; } Bt(t, o, 0, n); } function po(t, e) { e.bytesFilled > 0 && mo(t, e.buffer, e.byteOffset, e.bytesFilled), Oe(t); } function wo(t, e) { const r = Math.min(t._queueTotalSize, e.byteLength - e.bytesFilled), n = e.bytesFilled + r; let o = r, s = !1; const a = n - n % e.elementSize; a >= e.minimumFill && (o = a - e.bytesFilled, s = !0); const i = t._queue; for (; o > 0; ) { const l = i.peek(), c = Math.min(o, l.byteLength), A = e.byteOffset + e.bytesFilled; so(e.buffer, A, l.buffer, l.byteOffset, c), l.byteLength === c ? i.shift() : (l.byteOffset += c, l.byteLength -= c), t._queueTotalSize -= c, _o(t, c, e), o -= c; } return s; } function _o(t, e, r) { r.bytesFilled += e; } function bo(t) { t._queueTotalSize === 0 && t._closeRequested ? (Jt(t), ct(t._controlledReadableByteStream)) : Fe(t); } function Or(t) { t._byobRequest !== null && (t._byobRequest._associatedReadableByteStreamController = void 0, t._byobRequest._view = null, t._byobRequest = null); } function Ir(t) { const e = []; for (; t._pendingPullIntos.length > 0 && t._queueTotalSize !== 0; ) { const r = t._pendingPullIntos.peek(); wo(t, r) && (Oe(t), e.push(r)); } return e; } function Xi(t, e, r, n) { const o = t._controlledReadableByteStream, s = e.constructor, a = (function(d) { return fo(d) ? 1 : d.BYTES_PER_ELEMENT; })(s), { byteOffset: i, byteLength: l } = e, c = r * a; let A; try { A = De(e.buffer); } catch (d) { return void n._errorSteps(d); } const u = { buffer: A, bufferByteLength: A.byteLength, byteOffset: i, byteLength: l, bytesFilled: 0, minimumFill: c, elementSize: a, viewConstructor: s, readerType: "byob" }; if (t._pendingPullIntos.length > 0) return t._pendingPullIntos.push(u), void An(o, n); if (o._state === "closed") { const d = new s(u.buffer, u.byteOffset, 0); return void n._closeSteps(d); } if (t._queueTotalSize > 0) { if (wo(t, u)) { const d = Io(u); return bo(t), void n._chunkSteps(d); } if (t._closeRequested) { const d = new TypeError("Insufficient bytes to fill elements in the given buffer"); return J(t, d), void n._errorSteps(d); } } t._pendingPullIntos.push(u), An(o, n), Fe(t); } function yo(t, e) { const r = t._pendingPullIntos.peek(); Or(t), t._controlledReadableByteStream._state === "closed" ? (function(n, o) { o.readerType === "none" && Oe(n); const s = n._controlledReadableByteStream; if (Hr(s)) { const a = []; for (; a.length < Ro(s); ) a.push(Oe(n)); yt(s, a); } })(t, r) : (function(n, o, s) { if (_o(0, o, s), s.readerType === "none") { po(n, s); const l = Ir(n); return void yt(n._controlledReadableByteStream, l); } if (s.bytesFilled < s.minimumFill) return; Oe(n); const a = s.bytesFilled % s.elementSize; if (a > 0) { const l = s.byteOffset + s.bytesFilled; mo(n, s.buffer, l - a, a); } s.bytesFilled -= a; const i = Ir(n); Co(n._controlledReadableByteStream, s), yt(n._controlledReadableByteStream, i); })(t, e, r), Fe(t); } function Oe(t) { return t._pendingPullIntos.shift(); } function Jt(t) { t._pullAlgorithm = void 0, t._cancelAlgorithm = void 0; } function $e(t) { const e = t._controlledReadableByteStream; if (!t._closeRequested && e._state === "readable") if (t._queueTotalSize > 0) t._closeRequested = !0; else { if (t._pendingPullIntos.length > 0) { const r = t._pendingPullIntos.peek(); if (r.bytesFilled % r.elementSize !== 0) { const n = new TypeError("Insufficient bytes to fill elements in the given buffer"); throw J(t, n), n; } } Jt(t), ct(e); } } function Et(t, e) { const r = t._controlledReadableByteStream; if (t._closeRequested || r._state !== "readable") return; const { buffer: n, byteOffset: o, byteLength: s } = e; if (ke(n)) throw new TypeError("chunk's buffer is detached and so cannot be enqueued"); const a = De(n); if (t._pendingPullIntos.length > 0) { const i = t._pendingPullIntos.peek(); if (ke(i.buffer)) throw new TypeError("The BYOB request's buffer has been detached and so cannot be filled with an enqueued chunk"); Or(t), i.buffer = De(i.buffer), i.readerType === "none" && po(t, i); } oo(r) ? ((function(i) { const l = i._controlledReadableByteStream._reader; for (; l._readRequests.length > 0; ) { if (i._queueTotalSize === 0) return; Bo(i, l._readRequests.shift()); } })(t), zt(r) === 0 ? Bt(t, a, o, s) : (t._pendingPullIntos.length > 0 && Oe(t), Mr(r, new Uint8Array(a, o, s), !1))) : Hr(r) ? (Bt(t, a, o, s), yt(r, Ir(t))) : Bt(t, a, o, s), Fe(t); } function J(t, e) { const r = t._controlledReadableByteStream; r._state === "readable" && (ho(t), Ce(t), Jt(t), Wo(r, e)); } function Bo(t, e) { const r = t._queue.shift(); t._queueTotalSize -= r.byteLength, bo(t); const n = new Uint8Array(r.buffer, r.byteOffset, r.byteLength); e._chunkSteps(n); } function mr(t) { if (t._byobRequest === null && t._pendingPullIntos.length > 0) { const e = t._pendingPullIntos.peek(), r = new Uint8Array(e.buffer, e.byteOffset + e.bytesFilled, e.byteLength - e.bytesFilled), n = Object.create(Be.prototype); (function(o, s, a) { o._associatedReadableByteStreamController = s, o._view = a; })(n, t, r), t._byobRequest = n; } return t._byobRequest; } function Eo(t) { const e = t._controlledReadableByteStream._state; return e === "errored" ? null : e === "closed" ? 0 : t._strategyHWM - t._queueTotalSize; } function Qt(t, e) { const r = t._pendingPullIntos.peek(); if (t._controlledReadableByteStream._state === "closed") { if (e !== 0) throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream"); } else { if (e === 0) throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream"); if (r.bytesFilled + e > r.byteLength) throw new RangeError("bytesWritten out of range"); } r.buffer = De(r.buffer), yo(t, e); } function St(t, e) { const r = t._pendingPullIntos.peek(); if (t._controlledReadableByteStream._state === "closed") { if (e.byteLength !== 0) throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream"); } else if (e.byteLength === 0) throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream"); if (r.byteOffset + r.bytesFilled !== e.byteOffset) throw new RangeError("The region specified by view does not match byobRequest"); if (r.bufferByteLength !== e.buffer.byteLength) throw new RangeError("The buffer of view has different capacity than byobRequest"); if (r.bytesFilled + e.byteLength > r.byteLength) throw new RangeError("The region specified by view is larger than byobRequest"); const n = e.byteLength; r.buffer = De(e.buffer), yo(t, n); } function Qo(t, e, r, n, o, s, a) { e._controlledReadableByteStream = t, e._pullAgain = !1, e._pulling = !1, e._byobRequest = null, e._queue = e._queueTotalSize = void 0, Ce(e), e._closeRequested = !1, e._started = !1, e._strategyHWM = s, e._pullAlgorithm = n, e._cancelAlgorithm = o, e._autoAllocateChunkSize = a, e._pendingPullIntos = new K(), t._readableStreamController = e, G(F(r()), () => (e._started = !0, Fe(e), null), (i) => (J(e, i), null)); } function or(t) { return new TypeError(`ReadableStreamBYOBRequest.prototype.${t} can only be used on a ReadableStreamBYOBRequest`); } function Ke(t) { return new TypeError(`ReadableByteStreamController.prototype.${t} can only be used on a ReadableByteStreamController`); } function Zi(t, e) { if ((t = `${t}`) != "byob") throw new TypeError(`${e} '${t}' is not a valid enumeration value for ReadableStreamReaderMode`); return t; } function So(t) { return new le(t); } function An(t, e) { t._reader._readIntoRequests.push(e); } function Ro(t) { return t._reader._readIntoRequests.length; } function Hr(t) { const e = t._reader; return e !== void 0 && !!Ee(e); } Object.defineProperties(re.prototype, { close: { enumerable: !0 }, enqueue: { enumerable: !0 }, error: { enumerable: !0 }, byobRequest: { enumerable: !0 }, desiredSize: { enumerable: !0 } }), q(re.prototype.close, "close"), q(re.prototype.enqueue, "enqueue"), q(re.prototype.error, "error"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(re.prototype, Symbol.toStringTag, { value: "ReadableByteStreamController", configurable: !0 }); class le { constructor(e) { if (se(e, 1, "ReadableStreamBYOBReader"), Pr(e, "First parameter"), fe(e)) throw new TypeError("This stream has already been locked for exclusive reading by another reader"); if (!ye(e._readableStreamController)) throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source"); Zn(this, e), this._readIntoRequests = new K(); } get closed() { return Ee(this) ? this._closedPromise : b(gt("closed")); } cancel(e = void 0) { return Ee(this) ? this._ownerReadableStream === void 0 ? b(Dt("cancel")) : qr(this, e) : b(gt("cancel")); } read(e, r = {}) { if (!Ee(this)) return b(gt("read")); if (!ArrayBuffer.isView(e)) return b(new TypeError("view must be an array buffer view")); if (e.byteLength === 0) return b(new TypeError("view must have non-zero byteLength")); if (e.buffer.byteLength === 0) return b(new TypeError("view's buffer must have non-zero byteLength")); if (ke(e.buffer)) return b(new TypeError("view's buffer has been detached")); let n; try { n = (function(l, c) { var A; return Z(l, c), { min: Nr((A = l == null ? void 0 : l.min) !== null && A !== void 0 ? A : 1, `${c} has member 'min' that`) }; })(r, "options"); } catch (l) { return b(l); } const o = n.min; if (o === 0) return b(new TypeError("options.min must be greater than 0")); if ((function(l) { return fo(l.constructor); })(e)) { if (o > e.byteLength) return b(new RangeError("options.min must be less than or equal to view's byteLength")); } else if (o > e.length) return b(new RangeError("options.min must be less than or equal to view's length")); if (this._ownerReadableStream === void 0) return b(Dt("read from")); let s, a; const i = H((l, c) => { s = l, a = c; }); return vo(this, e, o, { _chunkSteps: (l) => s({ value: l, done: !1 }), _closeSteps: (l) => s({ value: l, done: !0 }), _errorSteps: (l) => a(l) }), i; } releaseLock() { if (!Ee(this)) throw gt("releaseLock"); this._ownerReadableStream !== void 0 && (function(e) { oe(e); const r = new TypeError("Reader was released"); xo(e, r); })(this); } } function Ee(t) { return !!O(t) && !!Object.prototype.hasOwnProperty.call(t, "_readIntoRequests") && t instanceof le; } function vo(t, e, r, n) { const o = t._ownerReadableStream; o._disturbed = !0, o._state === "errored" ? n._errorSteps(o._storedError) : Xi(o._readableStreamController, e, r, n); } function xo(t, e) { const r = t._readIntoRequests; t._readIntoRequests = new K(), r.forEach((n) => { n._errorSteps(e); }); } function gt(t) { return new TypeError(`ReadableStreamBYOBReader.prototype.${t} can only be used on a ReadableStreamBYOBReader`); } function nt(t, e) { const { highWaterMark: r } = t; if (r === void 0) return e; if (go(r) || r < 0) throw new RangeError("Invalid highWaterMark"); return r; } function kt(t) { const { size: e } = t; return e || (() => 1); } function qt(t, e) { Z(t, e); const r = t == null ? void 0 : t.highWaterMark, n = t == null ? void 0 : t.size; return { highWaterMark: r === void 0 ? void 0 : Tr(r), size: n === void 0 ? void 0 : es(n, `${e} has member 'size' that`) }; } function es(t, e) { return W(t, e), (r) => Tr(t(r)); } function ts(t, e, r) { return W(t, r), (n) => ae(t, e, [n]); } function rs(t, e, r) { return W(t, r), () => ae(t, e, []); } function ns(t, e, r) { return W(t, r), (n) => xe(t, e, [n]); } function os(t, e, r) { return W(t, r), (n, o) => ae(t, e, [n, o]); } function Do(t, e) { if (!Me(t)) throw new TypeError(`${e} is not a WritableStream.`); } Object.defineProperties(le.prototype, { cancel: { enumerable: !0 }, read: { enumerable: !0 }, releaseLock: { enumerable: !0 }, closed: { enumerable: !0 } }), q(le.prototype.cancel, "cancel"), q(le.prototype.read, "read"), q(le.prototype.releaseLock, "releaseLock"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(le.prototype, Symbol.toStringTag, { value: "ReadableStreamBYOBReader", configurable: !0 }); class de { constructor(e = {}, r = {}) { e === void 0 ? e = null : ro(e, "First parameter"); const n = qt(r, "Second parameter"), o = (function(a, i) { Z(a, i); const l = a == null ? void 0 : a.abort, c = a == null ? void 0 : a.close, A = a == null ? void 0 : a.start, u = a == null ? void 0 : a.type, d = a == null ? void 0 : a.write; return { abort: l === void 0 ? void 0 : ts(l, a, `${i} has member 'abort' that`), close: c === void 0 ? void 0 : rs(c, a, `${i} has member 'close' that`), start: A === void 0 ? void 0 : ns(A, a, `${i} has member 'start' that`), write: d === void 0 ? void 0 : os(d, a, `${i} has member 'write' that`), type: u }; })(e, "First parameter"); if (qo(this), o.type !== void 0) throw new RangeError("Invalid type is specified"); const s = kt(n); (function(a, i, l, c) { const A = Object.create(Ue.prototype); let u, d, g, f; u = i.start !== void 0 ? () => i.start(A) : () => { }, d = i.write !== void 0 ? (I) => i.write(I, A) : () => F(void 0), g = i.close !== void 0 ? () => i.close() : () => F(void 0), f = i.abort !== void 0 ? (I) => i.abort(I) : () => F(void 0), Oo(a, A, u, d, g, f, l, c); })(this, o, nt(n, 1), s); } get locked() { if (!Me(this)) throw ht("locked"); return He(this); } abort(e = void 0) { return Me(this) ? He(this) ? b(new TypeError("Cannot abort a stream that already has a writer")) : Ft(this, e) : b(ht("abort")); } close() { return Me(this) ? He(this) ? b(new TypeError("Cannot close a stream that already has a writer")) : ee(this) ? b(new TypeError("Cannot close an already-closing stream")) : Fo(this) : b(ht("close")); } getWriter() { if (!Me(this)) throw ht("getWriter"); return ko(this); } } function ko(t) { return new te(t); } function qo(t) { t._state = "writable", t._storedError = void 0, t._writer = void 0, t._writableStreamController = void 0, t._writeRequests = new K(), t._inFlightWriteRequest = void 0, t._closeRequest = void 0, t._inFlightCloseRequest = void 0, t._pendingAbortRequest = void 0, t._backpressure = !1; } function Me(t) { return !!O(t) && !!Object.prototype.hasOwnProperty.call(t, "_writableStreamController") && t instanceof de; } function He(t) { return t._writer !== void 0; } function Ft(t, e) { var r; if (t._state === "closed" || t._state === "errored") return F(void 0); t._writableStreamController._abortReason = e, (r = t._writableStreamController._abortController) === null || r === void 0 || r.abort(e); const n = t._state; if (n === "closed" || n === "errored") return F(void 0); if (t._pendingAbortRequest !== void 0) return t._pendingAbortRequest._promise; let o = !1; n === "erroring" && (o = !0, e = void 0); const s = H((a, i) => { t._pendingAbortRequest = { _promise: void 0, _resolve: a, _reject: i, _reason: e, _wasAlreadyErroring: o }; }); return t._pendingAbortRequest._promise = s, o || Ur(t, e), s; } function Fo(t) { const e = t._state; if (e === "closed" || e === "errored") return b(new TypeError(`The stream (in ${e} state) is not in the writable state and cannot be closed`)); const r = H((s, a) => { const i = { _resolve: s, _reject: a }; t._closeRequest = i; }), n = t._writer; var o; return n !== void 0 && t._backpressure && e === "writable" && Kr(n), Lr(o = t._writableStreamController, Lo, 0), Kt(o), r; } function pr(t, e) { t._state !== "writable" ? Yr(t) : Ur(t, e); } function Ur(t, e) { const r = t._writableStreamController; t._state = "erroring", t._storedError = e; const n = t._writer; n !== void 0 && No(n, e), !(function(o) { return !(o._inFlightWriteRequest === void 0 && o._inFlightCloseRequest === void 0); })(t) && r._started && Yr(t); } function Yr(t) { t._state = "errored", t._writableStreamController[Xn](); const e = t._storedError; if (t._writeRequests.forEach((n) => { n._reject(e); }), t._writeRequests = new K(), t._pendingAbortRequest === void 0) return void ft(t); const r = t._pendingAbortRequest; if (t._pendingAbortRequest = void 0, r._wasAlreadyErroring) return r._reject(e), void ft(t); G(t._writableStreamController[Vn](r._reason), () => (r._resolve(), ft(t), null), (n) => (r._reject(n), ft(t), null)); } function ee(t) { return t._closeRequest !== void 0 || t._inFlightCloseRequest !== void 0; } function ft(t) { t._closeRequest !== void 0 && (t._closeRequest._reject(t._storedError), t._closeRequest = void 0); const e = t._writer; e !== void 0 && Jr(e, t._storedError); } function Gr(t, e) { const r = t._writer; r !== void 0 && e !== t._backpressure && (e ? (function(n) { Wt(n); })(r) : Kr(r)), t._backpressure = e; } Object.defineProperties(de.prototype, { abort: { enumerable: !0 }, close: { enumerable: !0 }, getWriter: { enumerable: !0 }, locked: { enumerable: !0 } }), q(de.prototype.abort, "abort"), q(de.prototype.close, "close"), q(de.prototype.getWriter, "getWriter"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(de.prototype, Symbol.toStringTag, { value: "WritableStream", configurable: !0 }); class te { constructor(e) { if (se(e, 1, "WritableStreamDefaultWriter"), Do(e, "First parameter"), He(e)) throw new TypeError("This stream has already been locked for exclusive writing by another writer"); this._ownerWritableStream = e, e._writer = this; const r = e._state; if (r === "writable") !ee(e) && e._backpressure ? Wt(this) : cn(this), Rt(this); else if (r === "erroring") wr(this, e._storedError), Rt(this); else if (r === "closed") cn(this), Rt(n = this), Go(n); else { const o = e._storedError; wr(this, o), Yo(this, o); } var n; } get closed() { return we(this) ? this._closedPromise : b(_e("closed")); } get desiredSize() { if (!we(this)) throw _e("desiredSize"); if (this._ownerWritableStream === void 0) throw Ve("desiredSize"); return (function(e) { const r = e._ownerWritableStream, n = r._state; return n === "errored" || n === "erroring" ? null : n === "closed" ? 0 : Ho(r._writableStreamController); })(this); } get ready() { return we(this) ? this._readyPromise : b(_e("ready")); } abort(e = void 0) { return we(this) ? this._ownerWritableStream === void 0 ? b(Ve("abort")) : (function(r, n) { return Ft(r._ownerWritableStream, n); })(this, e) : b(_e("abort")); } close() { if (!we(this)) return b(_e("close")); const e = this._ownerWritableStream; return e === void 0 ? b(Ve("close")) : ee(e) ? b(new TypeError("Cannot close an already-closing stream")) : To(this); } releaseLock() { if (!we(this)) throw _e("releaseLock"); this._ownerWritableStream !== void 0 && Po(this); } write(e = void 0) { return we(this) ? this._ownerWritableStream === void 0 ? b(Ve("write to")) : Mo(this, e) : b(_e("write")); } } function we(t) { return !!O(t) && !!Object.prototype.hasOwnProperty.call(t, "_ownerWritableStream") && t instanceof te; } function To(t) { return Fo(t._ownerWritableStream); } function is(t, e) { t._closedPromiseState === "pending" ? Jr(t, e) : (function(r, n) { Yo(r, n); })(t, e); } function No(t, e) { t._readyPromiseState === "pending" ? zo(t, e) : (function(r, n) { wr(r, n); })(t, e); } function Po(t) { const e = t._ownerWritableStream, r = new TypeError("Writer was released and can no longer be used to monitor the stream's closedness"); No(t, r), is(t, r), e._writer = void 0, t._ownerWritableStream = void 0; } function Mo(t, e) { const r = t._ownerWritableStream, n = r._writableStreamController, o = (function(i, l) { if (i._strategySizeAlgorithm === void 0) return 1; try { return i._strategySizeAlgorithm(l); } catch (c) { return ot(i, c), 1; } })(n, e); if (r !== t._ownerWritableStream) return b(Ve("write to")); const s = r._state; if (s === "errored") return b(r._storedError); if (ee(r) || s === "closed") return b(new TypeError("The stream is closing or closed and cannot be written to")); if (s === "erroring") return b(r._storedError); const a = (function(i) { return H((l, c) => { const A = { _resolve: l, _reject: c }; i._writeRequests.push(A); }); })(r); return (function(i, l, c) { try { Lr(i, l, c); } catch (u) { return void ot(i, u); } const A = i._controlledWritableStream; !ee(A) && A._state === "writable" && Gr(A, zr(i)), Kt(i); })(n, e, o), a; } Object.defineProperties(te.prototype, { abort: { enumerable: !0 }, close: { enumerable: !0 }, releaseLock: { enumerable: !0 }, write: { enumerable: !0 }, closed: { enumerable: !0 }, desiredSize: { enumerable: !0 }, ready: { enumerable: !0 } }), q(te.prototype.abort, "abort"), q(te.prototype.close, "close"), q(te.prototype.releaseLock, "releaseLock"), q(te.prototype.write, "write"), typeof Symbol.toStringTag == "symbol" && Object.defineProperty(te.prototype, Symbol.toStringTag, { value: "WritableStreamDefaultWriter", configurable: !0 }); const Lo = {}; class Ue { constructor() { throw new TypeError("Illegal constructor"); } get abortReason() { if (!ir(this)) throw sr("abortReason"); return this._abortReason; } get signal() { if (!ir(this)) throw sr("signal"); if (this._abortController === void 0) throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported"); return this._abortController.signal; } error(e = void 0) { if (!ir(this)) throw sr("error"); this._controlledWritableStream._state === "writable" && Uo(this, e); } [Vn](e) { const r = this._abortAlgorithm(e); return Tt(this), r; } [Xn]() { Ce(this); } } function ir(t) { return !!O(t) && !!Object.prototype.hasOwnProperty.call(t, "_controlledWritableStream") && t instanceof Ue; } function Oo(t, e, r, n, o, s, a, i) { e._controlledWritableStream = t, t._writableStreamController = e, e._queue = void 0, e._queueTotalSize = void 0, Ce(e), e._abortReason = void 0, e._abortController = (function() { if (typeof AbortController == "function") return new AbortController(); })(), e._started = !1, e._strategySizeAlgorithm = i, e._strategyHWM = a, e._writeAlgorithm = n, e._closeAlgorithm = o, e._abortAlg