UNPKG

node-fetch-native

Version:

better fetch for Node.js. Works on any JavaScript runtime!

1 lines 109 kB
"use strict";var Li=Object.defineProperty;var u=(c,l)=>Li(c,"name",{value:l,configurable:!0});var co=(c,l,d)=>{if(!l.has(c))throw TypeError("Cannot "+d)};var L=(c,l,d)=>(co(c,l,"read from private field"),d?d.call(c):l.get(c)),ue=(c,l,d)=>{if(l.has(c))throw TypeError("Cannot add the same private member more than once");l instanceof WeakSet?l.add(c):l.set(c,d)},J=(c,l,d,b)=>(co(c,l,"write to private field"),b?b.call(c,d):l.set(c,d),d);var be,ct,et,Qt,Me,dt,ht,pt,X,bt,$e,De,mt;Object.defineProperty(exports,"__esModule",{value:!0});const http=require("node:http"),https=require("node:https"),zlib=require("node:zlib"),Stream=require("node:stream"),node_buffer=require("node:buffer"),require$$1=require("node:util"),_commonjsHelpers=require("./shared/node-fetch-native.61758d11.cjs"),node_url=require("node:url"),node_net=require("node:net"),node_fs=require("node:fs"),node_path=require("node:path");function _interopDefaultCompat(c){return c&&typeof c=="object"&&"default"in c?c.default:c}u(_interopDefaultCompat,"_interopDefaultCompat");const http__default=_interopDefaultCompat(http),https__default=_interopDefaultCompat(https),zlib__default=_interopDefaultCompat(zlib),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 b="",y=!1;const S=d[0]||"text/plain";let R=S;for(let N=1;N<d.length;N++)d[N]==="base64"?y=!0:d[N]&&(R+=`;${d[N]}`,d[N].indexOf("charset=")===0&&(b=d[N].substring(8)));!d[0]&&!b.length&&(R+=";charset=US-ASCII",b="US-ASCII");const C=y?"base64":"ascii",O=unescape(c.substring(l+1)),A=Buffer.from(O,C);return A.type=S,A.typeFull=R,A.charset=b,A}u(dataUriToBuffer,"dataUriToBuffer");var ponyfill_es2018={exports:{}},hasRequiredPonyfill_es2018;function requirePonyfill_es2018(){return hasRequiredPonyfill_es2018||(hasRequiredPonyfill_es2018=1,function(c,l){(function(d,b){b(l)})(_commonjsHelpers.commonjsGlobal,function(d){const b=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Symbol:n=>`Symbol(${n})`;function y(){}u(y,"noop");function S(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof _commonjsHelpers.commonjsGlobal<"u")return _commonjsHelpers.commonjsGlobal}u(S,"getGlobals");const R=S();function C(n){return typeof n=="object"&&n!==null||typeof n=="function"}u(C,"typeIsObject");const O=y,A=Promise,N=Promise.prototype.then,oe=Promise.resolve.bind(A),H=Promise.reject.bind(A);function F(n){return new A(n)}u(F,"newPromise");function T(n){return oe(n)}u(T,"promiseResolvedWith");function v(n){return H(n)}u(v,"promiseRejectedWith");function j(n,o,a){return N.call(n,o,a)}u(j,"PerformPromiseThen");function D(n,o,a){j(j(n,o,a),void 0,O)}u(D,"uponPromise");function ie(n,o){D(n,o)}u(ie,"uponFulfillment");function tt(n,o){D(n,void 0,o)}u(tt,"uponRejection");function $(n,o,a){return j(n,o,a)}u($,"transformPromiseWith");function V(n){j(n,void 0,O)}u(V,"setPromiseIsHandledToTrue");const U=(()=>{const n=R&&R.queueMicrotask;if(typeof n=="function")return n;const o=T(void 0);return a=>j(o,a)})();function Pe(n,o,a){if(typeof n!="function")throw new TypeError("Argument is not a function");return Function.prototype.apply.call(n,o,a)}u(Pe,"reflectCall");function le(n,o,a){try{return T(Pe(n,o,a))}catch(p){return v(p)}}u(le,"promiseCall");const Yr=16384,Ar=class Ar{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===Yr-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 g=p+1;const _=o._elements,w=_[p];return g===Yr&&(a=o._next,g=0),--this._size,this._cursor=g,o!==a&&(this._front=a),_[p]=void 0,w}forEach(o){let a=this._cursor,p=this._front,g=p._elements;for(;(a!==g.length||p._next!==void 0)&&!(a===g.length&&(p=p._next,g=p._elements,a=0,g.length===0));)o(g[a]),++a}peek(){const o=this._front,a=this._cursor;return o._elements[a]}};u(Ar,"SimpleQueue");let Y=Ar;function Zr(n,o){n._ownerReadableStream=o,o._reader=n,o._state==="readable"?Jt(n):o._state==="closed"?ho(n):Kr(n,o._storedError)}u(Zr,"ReadableStreamReaderGenericInitialize");function Kt(n,o){const a=n._ownerReadableStream;return re(a,o)}u(Kt,"ReadableStreamReaderGenericCancel");function fe(n){n._ownerReadableStream._state==="readable"?Xt(n,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):po(n,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),n._ownerReadableStream._reader=void 0,n._ownerReadableStream=void 0}u(fe,"ReadableStreamReaderGenericRelease");function Ue(n){return new TypeError("Cannot "+n+" a stream using a released reader")}u(Ue,"readerLockException");function Jt(n){n._closedPromise=F((o,a)=>{n._closedPromise_resolve=o,n._closedPromise_reject=a})}u(Jt,"defaultReaderClosedPromiseInitialize");function Kr(n,o){Jt(n),Xt(n,o)}u(Kr,"defaultReaderClosedPromiseInitializeAsRejected");function ho(n){Jt(n),Jr(n)}u(ho,"defaultReaderClosedPromiseInitializeAsResolved");function Xt(n,o){n._closedPromise_reject!==void 0&&(V(n._closedPromise),n._closedPromise_reject(o),n._closedPromise_resolve=void 0,n._closedPromise_reject=void 0)}u(Xt,"defaultReaderClosedPromiseReject");function po(n,o){Kr(n,o)}u(po,"defaultReaderClosedPromiseResetToRejected");function Jr(n){n._closedPromise_resolve!==void 0&&(n._closedPromise_resolve(void 0),n._closedPromise_resolve=void 0,n._closedPromise_reject=void 0)}u(Jr,"defaultReaderClosedPromiseResolve");const Xr=b("[[AbortSteps]]"),en=b("[[ErrorSteps]]"),er=b("[[CancelSteps]]"),tr=b("[[PullSteps]]"),tn=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 mo(n){return typeof n=="object"||typeof n=="function"}u(mo,"isDictionary");function ce(n,o){if(n!==void 0&&!mo(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 yo(n){return typeof n=="object"&&n!==null||typeof n=="function"}u(yo,"isObject");function rn(n,o){if(!yo(n))throw new TypeError(`${o} is not an object.`)}u(rn,"assertObject");function de(n,o,a){if(n===void 0)throw new TypeError(`Parameter ${o} is required in '${a}'.`)}u(de,"assertRequiredArgument");function rr(n,o,a){if(n===void 0)throw new TypeError(`${o} is required in '${a}'.`)}u(rr,"assertRequiredField");function nr(n){return Number(n)}u(nr,"convertUnrestrictedDouble");function nn(n){return n===0?0:n}u(nn,"censorNegativeZero");function go(n){return nn(bo(n))}u(go,"integerPart");function on(n,o){const p=Number.MAX_SAFE_INTEGER;let g=Number(n);if(g=nn(g),!tn(g))throw new TypeError(`${o} is not a finite number`);if(g=go(g),g<0||g>p)throw new TypeError(`${o} is outside the accepted range of 0 to ${p}, inclusive`);return!tn(g)||g===0?0:g}u(on,"convertUnsignedLongLongWithEnforceRange");function or(n,o){if(!Re(n))throw new TypeError(`${o} is not a ReadableStream.`)}u(or,"assertReadableStream");function xe(n){return new ve(n)}u(xe,"AcquireReadableStreamDefaultReader");function sn(n,o){n._reader._readRequests.push(o)}u(sn,"ReadableStreamAddReadRequest");function ir(n,o,a){const g=n._reader._readRequests.shift();a?g._closeSteps():g._chunkSteps(o)}u(ir,"ReadableStreamFulfillReadRequest");function yt(n){return n._reader._readRequests.length}u(yt,"ReadableStreamGetNumReadRequests");function an(n){const o=n._reader;return!(o===void 0||!me(o))}u(an,"ReadableStreamHasDefaultReader");const Br=class Br{constructor(o){if(de(o,1,"ReadableStreamDefaultReader"),or(o,"First parameter"),Te(o))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Zr(this,o),this._readRequests=new Y}get closed(){return me(this)?this._closedPromise:v(gt("closed"))}cancel(o=void 0){return me(this)?this._ownerReadableStream===void 0?v(Ue("cancel")):Kt(this,o):v(gt("cancel"))}read(){if(!me(this))return v(gt("read"));if(this._ownerReadableStream===void 0)return v(Ue("read from"));let o,a;const p=F((_,w)=>{o=_,a=w});return rt(this,{_chunkSteps:_=>o({value:_,done:!1}),_closeSteps:()=>o({value:void 0,done:!0}),_errorSteps:_=>a(_)}),p}releaseLock(){if(!me(this))throw gt("releaseLock");if(this._ownerReadableStream!==void 0){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");fe(this)}}};u(Br,"ReadableStreamDefaultReader");let ve=Br;Object.defineProperties(ve.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(ve.prototype,b.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0});function me(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_readRequests")?!1:n instanceof ve}u(me,"IsReadableStreamDefaultReader");function rt(n,o){const a=n._ownerReadableStream;a._disturbed=!0,a._state==="closed"?o._closeSteps():a._state==="errored"?o._errorSteps(a._storedError):a._readableStreamController[tr](o)}u(rt,"ReadableStreamDefaultReaderRead");function gt(n){return new TypeError(`ReadableStreamDefaultReader.prototype.${n} can only be used on a ReadableStreamDefaultReader`)}u(gt,"defaultReaderBrandCheckException");const un=Object.getPrototypeOf(Object.getPrototypeOf(async function*(){}).prototype),Wr=class Wr{constructor(o,a){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=o,this._preventCancel=a}next(){const o=u(()=>this._nextSteps(),"nextSteps");return this._ongoingPromise=this._ongoingPromise?$(this._ongoingPromise,o,o):o(),this._ongoingPromise}return(o){const a=u(()=>this._returnSteps(o),"returnSteps");return this._ongoingPromise?$(this._ongoingPromise,a,a):a()}_nextSteps(){if(this._isFinished)return Promise.resolve({value:void 0,done:!0});const o=this._reader;if(o._ownerReadableStream===void 0)return v(Ue("iterate"));let a,p;const g=F((w,P)=>{a=w,p=P});return rt(o,{_chunkSteps:w=>{this._ongoingPromise=void 0,U(()=>a({value:w,done:!1}))},_closeSteps:()=>{this._ongoingPromise=void 0,this._isFinished=!0,fe(o),a({value:void 0,done:!0})},_errorSteps:w=>{this._ongoingPromise=void 0,this._isFinished=!0,fe(o),p(w)}}),g}_returnSteps(o){if(this._isFinished)return Promise.resolve({value:o,done:!0});this._isFinished=!0;const a=this._reader;if(a._ownerReadableStream===void 0)return v(Ue("finish iterating"));if(!this._preventCancel){const p=Kt(a,o);return fe(a),$(p,()=>({value:o,done:!0}))}return fe(a),T({value:o,done:!0})}};u(Wr,"ReadableStreamAsyncIteratorImpl");let _t=Wr;const ln={next(){return fn(this)?this._asyncIteratorImpl.next():v(cn("next"))},return(n){return fn(this)?this._asyncIteratorImpl.return(n):v(cn("return"))}};un!==void 0&&Object.setPrototypeOf(ln,un);function _o(n,o){const a=xe(n),p=new _t(a,o),g=Object.create(ln);return g._asyncIteratorImpl=p,g}u(_o,"AcquireReadableStreamAsyncIterator");function fn(n){if(!C(n)||!Object.prototype.hasOwnProperty.call(n,"_asyncIteratorImpl"))return!1;try{return n._asyncIteratorImpl instanceof _t}catch{return!1}}u(fn,"IsReadableStreamAsyncIterator");function cn(n){return new TypeError(`ReadableStreamAsyncIterator.${n} can only be used on a ReadableSteamAsyncIterator`)}u(cn,"streamAsyncIteratorBrandCheckException");const dn=Number.isNaN||function(n){return n!==n};function nt(n){return n.slice()}u(nt,"CreateArrayFromList");function hn(n,o,a,p,g){new Uint8Array(n).set(new Uint8Array(a,p,g),o)}u(hn,"CopyDataBlockBytes");function $i(n){return n}u($i,"TransferArrayBuffer");function St(n){return!1}u(St,"IsDetachedBuffer");function pn(n,o,a){if(n.slice)return n.slice(o,a);const p=a-o,g=new ArrayBuffer(p);return hn(g,0,n,o,p),g}u(pn,"ArrayBufferSlice");function So(n){return!(typeof n!="number"||dn(n)||n<0)}u(So,"IsNonNegativeNumber");function bn(n){const o=pn(n.buffer,n.byteOffset,n.byteOffset+n.byteLength);return new Uint8Array(o)}u(bn,"CloneAsUint8Array");function sr(n){const o=n._queue.shift();return n._queueTotalSize-=o.size,n._queueTotalSize<0&&(n._queueTotalSize=0),o.value}u(sr,"DequeueValue");function ar(n,o,a){if(!So(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(ar,"EnqueueValueWithSize");function wo(n){return n._queue.peek().value}u(wo,"PeekQueueValue");function ye(n){n._queue=new Y,n._queueTotalSize=0}u(ye,"ResetQueue");const kr=class kr{constructor(){throw new TypeError("Illegal constructor")}get view(){if(!ur(this))throw dr("view");return this._view}respond(o){if(!ur(this))throw dr("respond");if(de(o,1,"respond"),o=on(o,"First parameter"),this._associatedReadableByteStreamController===void 0)throw new TypeError("This BYOB request has been invalidated");St(this._view.buffer),Pt(this._associatedReadableByteStreamController,o)}respondWithNewView(o){if(!ur(this))throw dr("respondWithNewView");if(de(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");St(o.buffer),vt(this._associatedReadableByteStreamController,o)}};u(kr,"ReadableStreamBYOBRequest");let Ee=kr;Object.defineProperties(Ee.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(Ee.prototype,b.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});const Or=class Or{constructor(){throw new TypeError("Illegal constructor")}get byobRequest(){if(!Ae(this))throw it("byobRequest");return cr(this)}get desiredSize(){if(!Ae(this))throw it("desiredSize");return Tn(this)}close(){if(!Ae(this))throw it("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`);ot(this)}enqueue(o){if(!Ae(this))throw it("enqueue");if(de(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`);Ct(this,o)}error(o=void 0){if(!Ae(this))throw it("error");te(this,o)}[er](o){mn(this),ye(this);const a=this._cancelAlgorithm(o);return Tt(this),a}[tr](o){const a=this._controlledReadableByteStream;if(this._queueTotalSize>0){const g=this._queue.shift();this._queueTotalSize-=g.byteLength,Sn(this);const _=new Uint8Array(g.buffer,g.byteOffset,g.byteLength);o._chunkSteps(_);return}const p=this._autoAllocateChunkSize;if(p!==void 0){let g;try{g=new ArrayBuffer(p)}catch(w){o._errorSteps(w);return}const _={buffer:g,bufferByteLength:p,byteOffset:0,byteLength:p,bytesFilled:0,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(_)}sn(a,o),Be(this)}};u(Or,"ReadableByteStreamController");let ge=Or;Object.defineProperties(ge.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(ge.prototype,b.toStringTag,{value:"ReadableByteStreamController",configurable:!0});function Ae(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_controlledReadableByteStream")?!1:n instanceof ge}u(Ae,"IsReadableByteStreamController");function ur(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_associatedReadableByteStreamController")?!1:n instanceof Ee}u(ur,"IsReadableStreamBYOBRequest");function Be(n){if(!Po(n))return;if(n._pulling){n._pullAgain=!0;return}n._pulling=!0;const a=n._pullAlgorithm();D(a,()=>{n._pulling=!1,n._pullAgain&&(n._pullAgain=!1,Be(n))},p=>{te(n,p)})}u(Be,"ReadableByteStreamControllerCallPullIfNeeded");function mn(n){fr(n),n._pendingPullIntos=new Y}u(mn,"ReadableByteStreamControllerClearPendingPullIntos");function lr(n,o){let a=!1;n._state==="closed"&&(a=!0);const p=yn(o);o.readerType==="default"?ir(n,p,a):Ao(n,p,a)}u(lr,"ReadableByteStreamControllerCommitPullIntoDescriptor");function yn(n){const o=n.bytesFilled,a=n.elementSize;return new n.viewConstructor(n.buffer,n.byteOffset,o/a)}u(yn,"ReadableByteStreamControllerConvertPullIntoDescriptor");function wt(n,o,a,p){n._queue.push({buffer:o,byteOffset:a,byteLength:p}),n._queueTotalSize+=p}u(wt,"ReadableByteStreamControllerEnqueueChunkToQueue");function gn(n,o){const a=o.elementSize,p=o.bytesFilled-o.bytesFilled%a,g=Math.min(n._queueTotalSize,o.byteLength-o.bytesFilled),_=o.bytesFilled+g,w=_-_%a;let P=g,B=!1;w>p&&(P=w-o.bytesFilled,B=!0);const k=n._queue;for(;P>0;){const q=k.peek(),z=Math.min(P,q.byteLength),M=o.byteOffset+o.bytesFilled;hn(o.buffer,M,q.buffer,q.byteOffset,z),q.byteLength===z?k.shift():(q.byteOffset+=z,q.byteLength-=z),n._queueTotalSize-=z,_n(n,z,o),P-=z}return B}u(gn,"ReadableByteStreamControllerFillPullIntoDescriptorFromQueue");function _n(n,o,a){a.bytesFilled+=o}u(_n,"ReadableByteStreamControllerFillHeadPullIntoDescriptor");function Sn(n){n._queueTotalSize===0&&n._closeRequested?(Tt(n),ft(n._controlledReadableByteStream)):Be(n)}u(Sn,"ReadableByteStreamControllerHandleQueueDrain");function fr(n){n._byobRequest!==null&&(n._byobRequest._associatedReadableByteStreamController=void 0,n._byobRequest._view=null,n._byobRequest=null)}u(fr,"ReadableByteStreamControllerInvalidateBYOBRequest");function wn(n){for(;n._pendingPullIntos.length>0;){if(n._queueTotalSize===0)return;const o=n._pendingPullIntos.peek();gn(n,o)&&(Rt(n),lr(n._controlledReadableByteStream,o))}}u(wn,"ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue");function Ro(n,o,a){const p=n._controlledReadableByteStream;let g=1;o.constructor!==DataView&&(g=o.constructor.BYTES_PER_ELEMENT);const _=o.constructor,w=o.buffer,P={buffer:w,bufferByteLength:w.byteLength,byteOffset:o.byteOffset,byteLength:o.byteLength,bytesFilled:0,elementSize:g,viewConstructor:_,readerType:"byob"};if(n._pendingPullIntos.length>0){n._pendingPullIntos.push(P),vn(p,a);return}if(p._state==="closed"){const B=new _(P.buffer,P.byteOffset,0);a._closeSteps(B);return}if(n._queueTotalSize>0){if(gn(n,P)){const B=yn(P);Sn(n),a._chunkSteps(B);return}if(n._closeRequested){const B=new TypeError("Insufficient bytes to fill elements in the given buffer");te(n,B),a._errorSteps(B);return}}n._pendingPullIntos.push(P),vn(p,a),Be(n)}u(Ro,"ReadableByteStreamControllerPullInto");function To(n,o){const a=n._controlledReadableByteStream;if(hr(a))for(;En(a)>0;){const p=Rt(n);lr(a,p)}}u(To,"ReadableByteStreamControllerRespondInClosedState");function Co(n,o,a){if(_n(n,o,a),a.bytesFilled<a.elementSize)return;Rt(n);const p=a.bytesFilled%a.elementSize;if(p>0){const g=a.byteOffset+a.bytesFilled,_=pn(a.buffer,g-p,g);wt(n,_,0,_.byteLength)}a.bytesFilled-=p,lr(n._controlledReadableByteStream,a),wn(n)}u(Co,"ReadableByteStreamControllerRespondInReadableState");function Rn(n,o){const a=n._pendingPullIntos.peek();fr(n),n._controlledReadableByteStream._state==="closed"?To(n):Co(n,o,a),Be(n)}u(Rn,"ReadableByteStreamControllerRespondInternal");function Rt(n){return n._pendingPullIntos.shift()}u(Rt,"ReadableByteStreamControllerShiftPendingPullInto");function Po(n){const o=n._controlledReadableByteStream;return o._state!=="readable"||n._closeRequested||!n._started?!1:!!(an(o)&&yt(o)>0||hr(o)&&En(o)>0||Tn(n)>0)}u(Po,"ReadableByteStreamControllerShouldCallPull");function Tt(n){n._pullAlgorithm=void 0,n._cancelAlgorithm=void 0}u(Tt,"ReadableByteStreamControllerClearAlgorithms");function ot(n){const o=n._controlledReadableByteStream;if(!(n._closeRequested||o._state!=="readable")){if(n._queueTotalSize>0){n._closeRequested=!0;return}if(n._pendingPullIntos.length>0&&n._pendingPullIntos.peek().bytesFilled>0){const p=new TypeError("Insufficient bytes to fill elements in the given buffer");throw te(n,p),p}Tt(n),ft(o)}}u(ot,"ReadableByteStreamControllerClose");function Ct(n,o){const a=n._controlledReadableByteStream;if(n._closeRequested||a._state!=="readable")return;const p=o.buffer,g=o.byteOffset,_=o.byteLength,w=p;if(n._pendingPullIntos.length>0){const P=n._pendingPullIntos.peek();St(P.buffer),P.buffer=P.buffer}if(fr(n),an(a))if(yt(a)===0)wt(n,w,g,_);else{n._pendingPullIntos.length>0&&Rt(n);const P=new Uint8Array(w,g,_);ir(a,P,!1)}else hr(a)?(wt(n,w,g,_),wn(n)):wt(n,w,g,_);Be(n)}u(Ct,"ReadableByteStreamControllerEnqueue");function te(n,o){const a=n._controlledReadableByteStream;a._state==="readable"&&(mn(n),ye(n),Tt(n),Kn(a,o))}u(te,"ReadableByteStreamControllerError");function cr(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(Ee.prototype);Eo(p,n,a),n._byobRequest=p}return n._byobRequest}u(cr,"ReadableByteStreamControllerGetBYOBRequest");function Tn(n){const o=n._controlledReadableByteStream._state;return o==="errored"?null:o==="closed"?0:n._strategyHWM-n._queueTotalSize}u(Tn,"ReadableByteStreamControllerGetDesiredSize");function Pt(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=a.buffer,Rn(n,o)}u(Pt,"ReadableByteStreamControllerRespond");function vt(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 g=o.byteLength;a.buffer=o.buffer,Rn(n,g)}u(vt,"ReadableByteStreamControllerRespondWithNewView");function Cn(n,o,a,p,g,_,w){o._controlledReadableByteStream=n,o._pullAgain=!1,o._pulling=!1,o._byobRequest=null,o._queue=o._queueTotalSize=void 0,ye(o),o._closeRequested=!1,o._started=!1,o._strategyHWM=_,o._pullAlgorithm=p,o._cancelAlgorithm=g,o._autoAllocateChunkSize=w,o._pendingPullIntos=new Y,n._readableStreamController=o;const P=a();D(T(P),()=>{o._started=!0,Be(o)},B=>{te(o,B)})}u(Cn,"SetUpReadableByteStreamController");function vo(n,o,a){const p=Object.create(ge.prototype);let g=u(()=>{},"startAlgorithm"),_=u(()=>T(void 0),"pullAlgorithm"),w=u(()=>T(void 0),"cancelAlgorithm");o.start!==void 0&&(g=u(()=>o.start(p),"startAlgorithm")),o.pull!==void 0&&(_=u(()=>o.pull(p),"pullAlgorithm")),o.cancel!==void 0&&(w=u(B=>o.cancel(B),"cancelAlgorithm"));const P=o.autoAllocateChunkSize;if(P===0)throw new TypeError("autoAllocateChunkSize must be greater than 0");Cn(n,p,g,_,w,a,P)}u(vo,"SetUpReadableByteStreamControllerFromUnderlyingSource");function Eo(n,o,a){n._associatedReadableByteStreamController=o,n._view=a}u(Eo,"SetUpReadableStreamBYOBRequest");function dr(n){return new TypeError(`ReadableStreamBYOBRequest.prototype.${n} can only be used on a ReadableStreamBYOBRequest`)}u(dr,"byobRequestBrandCheckException");function it(n){return new TypeError(`ReadableByteStreamController.prototype.${n} can only be used on a ReadableByteStreamController`)}u(it,"byteStreamControllerBrandCheckException");function Pn(n){return new We(n)}u(Pn,"AcquireReadableStreamBYOBReader");function vn(n,o){n._reader._readIntoRequests.push(o)}u(vn,"ReadableStreamAddReadIntoRequest");function Ao(n,o,a){const g=n._reader._readIntoRequests.shift();a?g._closeSteps(o):g._chunkSteps(o)}u(Ao,"ReadableStreamFulfillReadIntoRequest");function En(n){return n._reader._readIntoRequests.length}u(En,"ReadableStreamGetNumReadIntoRequests");function hr(n){const o=n._reader;return!(o===void 0||!ke(o))}u(hr,"ReadableStreamHasBYOBReader");const qr=class qr{constructor(o){if(de(o,1,"ReadableStreamBYOBReader"),or(o,"First parameter"),Te(o))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!Ae(o._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");Zr(this,o),this._readIntoRequests=new Y}get closed(){return ke(this)?this._closedPromise:v(Et("closed"))}cancel(o=void 0){return ke(this)?this._ownerReadableStream===void 0?v(Ue("cancel")):Kt(this,o):v(Et("cancel"))}read(o){if(!ke(this))return v(Et("read"));if(!ArrayBuffer.isView(o))return v(new TypeError("view must be an array buffer view"));if(o.byteLength===0)return v(new TypeError("view must have non-zero byteLength"));if(o.buffer.byteLength===0)return v(new TypeError("view's buffer must have non-zero byteLength"));if(St(o.buffer),this._ownerReadableStream===void 0)return v(Ue("read from"));let a,p;const g=F((w,P)=>{a=w,p=P});return An(this,o,{_chunkSteps:w=>a({value:w,done:!1}),_closeSteps:w=>a({value:w,done:!0}),_errorSteps:w=>p(w)}),g}releaseLock(){if(!ke(this))throw Et("releaseLock");if(this._ownerReadableStream!==void 0){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");fe(this)}}};u(qr,"ReadableStreamBYOBReader");let We=qr;Object.defineProperties(We.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(We.prototype,b.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});function ke(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_readIntoRequests")?!1:n instanceof We}u(ke,"IsReadableStreamBYOBReader");function An(n,o,a){const p=n._ownerReadableStream;p._disturbed=!0,p._state==="errored"?a._errorSteps(p._storedError):Ro(p._readableStreamController,o,a)}u(An,"ReadableStreamBYOBReaderRead");function Et(n){return new TypeError(`ReadableStreamBYOBReader.prototype.${n} can only be used on a ReadableStreamBYOBReader`)}u(Et,"byobReaderBrandCheckException");function st(n,o){const{highWaterMark:a}=n;if(a===void 0)return o;if(dn(a)||a<0)throw new RangeError("Invalid highWaterMark");return a}u(st,"ExtractHighWaterMark");function At(n){const{size:o}=n;return o||(()=>1)}u(At,"ExtractSizeAlgorithm");function Bt(n,o){ce(n,o);const a=n?.highWaterMark,p=n?.size;return{highWaterMark:a===void 0?void 0:nr(a),size:p===void 0?void 0:Bo(p,`${o} has member 'size' that`)}}u(Bt,"convertQueuingStrategy");function Bo(n,o){return ee(n,o),a=>nr(n(a))}u(Bo,"convertQueuingStrategySize");function Wo(n,o){ce(n,o);const a=n?.abort,p=n?.close,g=n?.start,_=n?.type,w=n?.write;return{abort:a===void 0?void 0:ko(a,n,`${o} has member 'abort' that`),close:p===void 0?void 0:Oo(p,n,`${o} has member 'close' that`),start:g===void 0?void 0:qo(g,n,`${o} has member 'start' that`),write:w===void 0?void 0:zo(w,n,`${o} has member 'write' that`),type:_}}u(Wo,"convertUnderlyingSink");function ko(n,o,a){return ee(n,a),p=>le(n,o,[p])}u(ko,"convertUnderlyingSinkAbortCallback");function Oo(n,o,a){return ee(n,a),()=>le(n,o,[])}u(Oo,"convertUnderlyingSinkCloseCallback");function qo(n,o,a){return ee(n,a),p=>Pe(n,o,[p])}u(qo,"convertUnderlyingSinkStartCallback");function zo(n,o,a){return ee(n,a),(p,g)=>le(n,o,[p,g])}u(zo,"convertUnderlyingSinkWriteCallback");function Bn(n,o){if(!Ne(n))throw new TypeError(`${o} is not a WritableStream.`)}u(Bn,"assertWritableStream");function Fo(n){if(typeof n!="object"||n===null)return!1;try{return typeof n.aborted=="boolean"}catch{return!1}}u(Fo,"isAbortSignal");const jo=typeof AbortController=="function";function Io(){if(jo)return new AbortController}u(Io,"createAbortController");const zr=class zr{constructor(o={},a={}){o===void 0?o=null:rn(o,"First parameter");const p=Bt(a,"Second parameter"),g=Wo(o,"First parameter");if(kn(this),g.type!==void 0)throw new RangeError("Invalid type is specified");const w=At(p),P=st(p,1);Ko(this,g,P,w)}get locked(){if(!Ne(this))throw zt("locked");return He(this)}abort(o=void 0){return Ne(this)?He(this)?v(new TypeError("Cannot abort a stream that already has a writer")):Wt(this,o):v(zt("abort"))}close(){return Ne(this)?He(this)?v(new TypeError("Cannot close a stream that already has a writer")):se(this)?v(new TypeError("Cannot close an already-closing stream")):On(this):v(zt("close"))}getWriter(){if(!Ne(this))throw zt("getWriter");return Wn(this)}};u(zr,"WritableStream");let Oe=zr;Object.defineProperties(Oe.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(Oe.prototype,b.toStringTag,{value:"WritableStream",configurable:!0});function Wn(n){return new qe(n)}u(Wn,"AcquireWritableStreamDefaultWriter");function Lo(n,o,a,p,g=1,_=()=>1){const w=Object.create(Oe.prototype);kn(w);const P=Object.create(_e.prototype);return Ln(w,P,n,o,a,p,g,_),w}u(Lo,"CreateWritableStream");function kn(n){n._state="writable",n._storedError=void 0,n._writer=void 0,n._writableStreamController=void 0,n._writeRequests=new Y,n._inFlightWriteRequest=void 0,n._closeRequest=void 0,n._inFlightCloseRequest=void 0,n._pendingAbortRequest=void 0,n._backpressure=!1}u(kn,"InitializeWritableStream");function Ne(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_writableStreamController")?!1:n instanceof Oe}u(Ne,"IsWritableStream");function He(n){return n._writer!==void 0}u(He,"IsWritableStreamLocked");function Wt(n,o){var a;if(n._state==="closed"||n._state==="errored")return T(void 0);n._writableStreamController._abortReason=o,(a=n._writableStreamController._abortController)===null||a===void 0||a.abort();const p=n._state;if(p==="closed"||p==="errored")return T(void 0);if(n._pendingAbortRequest!==void 0)return n._pendingAbortRequest._promise;let g=!1;p==="erroring"&&(g=!0,o=void 0);const _=F((w,P)=>{n._pendingAbortRequest={_promise:void 0,_resolve:w,_reject:P,_reason:o,_wasAlreadyErroring:g}});return n._pendingAbortRequest._promise=_,g||br(n,o),_}u(Wt,"WritableStreamAbort");function On(n){const o=n._state;if(o==="closed"||o==="errored")return v(new TypeError(`The stream (in ${o} state) is not in the writable state and cannot be closed`));const a=F((g,_)=>{const w={_resolve:g,_reject:_};n._closeRequest=w}),p=n._writer;return p!==void 0&&n._backpressure&&o==="writable"&&Cr(p),Jo(n._writableStreamController),a}u(On,"WritableStreamClose");function $o(n){return F((a,p)=>{const g={_resolve:a,_reject:p};n._writeRequests.push(g)})}u($o,"WritableStreamAddWriteRequest");function pr(n,o){if(n._state==="writable"){br(n,o);return}mr(n)}u(pr,"WritableStreamDealWithRejection");function br(n,o){const a=n._writableStreamController;n._state="erroring",n._storedError=o;const p=n._writer;p!==void 0&&zn(p,o),!No(n)&&a._started&&mr(n)}u(br,"WritableStreamStartErroring");function mr(n){n._state="errored",n._writableStreamController[en]();const o=n._storedError;if(n._writeRequests.forEach(g=>{g._reject(o)}),n._writeRequests=new Y,n._pendingAbortRequest===void 0){kt(n);return}const a=n._pendingAbortRequest;if(n._pendingAbortRequest=void 0,a._wasAlreadyErroring){a._reject(o),kt(n);return}const p=n._writableStreamController[Xr](a._reason);D(p,()=>{a._resolve(),kt(n)},g=>{a._reject(g),kt(n)})}u(mr,"WritableStreamFinishErroring");function Do(n){n._inFlightWriteRequest._resolve(void 0),n._inFlightWriteRequest=void 0}u(Do,"WritableStreamFinishInFlightWrite");function Mo(n,o){n._inFlightWriteRequest._reject(o),n._inFlightWriteRequest=void 0,pr(n,o)}u(Mo,"WritableStreamFinishInFlightWriteWithError");function Uo(n){n._inFlightCloseRequest._resolve(void 0),n._inFlightCloseRequest=void 0,n._state==="erroring"&&(n._storedError=void 0,n._pendingAbortRequest!==void 0&&(n._pendingAbortRequest._resolve(),n._pendingAbortRequest=void 0)),n._state="closed";const a=n._writer;a!==void 0&&Un(a)}u(Uo,"WritableStreamFinishInFlightClose");function xo(n,o){n._inFlightCloseRequest._reject(o),n._inFlightCloseRequest=void 0,n._pendingAbortRequest!==void 0&&(n._pendingAbortRequest._reject(o),n._pendingAbortRequest=void 0),pr(n,o)}u(xo,"WritableStreamFinishInFlightCloseWithError");function se(n){return!(n._closeRequest===void 0&&n._inFlightCloseRequest===void 0)}u(se,"WritableStreamCloseQueuedOrInFlight");function No(n){return!(n._inFlightWriteRequest===void 0&&n._inFlightCloseRequest===void 0)}u(No,"WritableStreamHasOperationMarkedInFlight");function Ho(n){n._inFlightCloseRequest=n._closeRequest,n._closeRequest=void 0}u(Ho,"WritableStreamMarkCloseRequestInFlight");function Vo(n){n._inFlightWriteRequest=n._writeRequests.shift()}u(Vo,"WritableStreamMarkFirstWriteRequestInFlight");function kt(n){n._closeRequest!==void 0&&(n._closeRequest._reject(n._storedError),n._closeRequest=void 0);const o=n._writer;o!==void 0&&Rr(o,n._storedError)}u(kt,"WritableStreamRejectCloseAndClosedPromiseIfNeeded");function yr(n,o){const a=n._writer;a!==void 0&&o!==n._backpressure&&(o?ii(a):Cr(a)),n._backpressure=o}u(yr,"WritableStreamUpdateBackpressure");const Fr=class Fr{constructor(o){if(de(o,1,"WritableStreamDefaultWriter"),Bn(o,"First parameter"),He(o))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=o,o._writer=this;const a=o._state;if(a==="writable")!se(o)&&o._backpressure?jt(this):xn(this),Ft(this);else if(a==="erroring")Tr(this,o._storedError),Ft(this);else if(a==="closed")xn(this),ni(this);else{const p=o._storedError;Tr(this,p),Mn(this,p)}}get closed(){return ze(this)?this._closedPromise:v(Fe("closed"))}get desiredSize(){if(!ze(this))throw Fe("desiredSize");if(this._ownerWritableStream===void 0)throw at("desiredSize");return Zo(this)}get ready(){return ze(this)?this._readyPromise:v(Fe("ready"))}abort(o=void 0){return ze(this)?this._ownerWritableStream===void 0?v(at("abort")):Qo(this,o):v(Fe("abort"))}close(){if(!ze(this))return v(Fe("close"));const o=this._ownerWritableStream;return o===void 0?v(at("close")):se(o)?v(new TypeError("Cannot close an already-closing stream")):qn(this)}releaseLock(){if(!ze(this))throw Fe("releaseLock");this._ownerWritableStream!==void 0&&Fn(this)}write(o=void 0){return ze(this)?this._ownerWritableStream===void 0?v(at("write to")):jn(this,o):v(Fe("write"))}};u(Fr,"WritableStreamDefaultWriter");let qe=Fr;Object.defineProperties(qe.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(qe.prototype,b.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});function ze(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_ownerWritableStream")?!1:n instanceof qe}u(ze,"IsWritableStreamDefaultWriter");function Qo(n,o){const a=n._ownerWritableStream;return Wt(a,o)}u(Qo,"WritableStreamDefaultWriterAbort");function qn(n){const o=n._ownerWritableStream;return On(o)}u(qn,"WritableStreamDefaultWriterClose");function Go(n){const o=n._ownerWritableStream,a=o._state;return se(o)||a==="closed"?T(void 0):a==="errored"?v(o._storedError):qn(n)}u(Go,"WritableStreamDefaultWriterCloseWithErrorPropagation");function Yo(n,o){n._closedPromiseState==="pending"?Rr(n,o):oi(n,o)}u(Yo,"WritableStreamDefaultWriterEnsureClosedPromiseRejected");function zn(n,o){n._readyPromiseState==="pending"?Nn(n,o):si(n,o)}u(zn,"WritableStreamDefaultWriterEnsureReadyPromiseRejected");function Zo(n){const o=n._ownerWritableStream,a=o._state;return a==="errored"||a==="erroring"?null:a==="closed"?0:$n(o._writableStreamController)}u(Zo,"WritableStreamDefaultWriterGetDesiredSize");function Fn(n){const o=n._ownerWritableStream,a=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");zn(n,a),Yo(n,a),o._writer=void 0,n._ownerWritableStream=void 0}u(Fn,"WritableStreamDefaultWriterRelease");function jn(n,o){const a=n._ownerWritableStream,p=a._writableStreamController,g=Xo(p,o);if(a!==n._ownerWritableStream)return v(at("write to"));const _=a._state;if(_==="errored")return v(a._storedError);if(se(a)||_==="closed")return v(new TypeError("The stream is closing or closed and cannot be written to"));if(_==="erroring")return v(a._storedError);const w=$o(a);return ei(p,o,g),w}u(jn,"WritableStreamDefaultWriterWrite");const In={},jr=class jr{constructor(){throw new TypeError("Illegal constructor")}get abortReason(){if(!gr(this))throw wr("abortReason");return this._abortReason}get signal(){if(!gr(this))throw wr("signal");if(this._abortController===void 0)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal}error(o=void 0){if(!gr(this))throw wr("error");this._controlledWritableStream._state==="writable"&&Dn(this,o)}[Xr](o){const a=this._abortAlgorithm(o);return Ot(this),a}[en](){ye(this)}};u(jr,"WritableStreamDefaultController");let _e=jr;Object.defineProperties(_e.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(_e.prototype,b.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});function gr(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_controlledWritableStream")?!1:n instanceof _e}u(gr,"IsWritableStreamDefaultController");function Ln(n,o,a,p,g,_,w,P){o._controlledWritableStream=n,n._writableStreamController=o,o._queue=void 0,o._queueTotalSize=void 0,ye(o),o._abortReason=void 0,o._abortController=Io(),o._started=!1,o._strategySizeAlgorithm=P,o._strategyHWM=w,o._writeAlgorithm=p,o._closeAlgorithm=g,o._abortAlgorithm=_;const B=Sr(o);yr(n,B);const k=a(),q=T(k);D(q,()=>{o._started=!0,qt(o)},z=>{o._started=!0,pr(n,z)})}u(Ln,"SetUpWritableStreamDefaultController");function Ko(n,o,a,p){const g=Object.create(_e.prototype);let _=u(()=>{},"startAlgorithm"),w=u(()=>T(void 0),"writeAlgorithm"),P=u(()=>T(void 0),"closeAlgorithm"),B=u(()=>T(void 0),"abortAlgorithm");o.start!==void 0&&(_=u(()=>o.start(g),"startAlgorithm")),o.write!==void 0&&(w=u(k=>o.write(k,g),"writeAlgorithm")),o.close!==void 0&&(P=u(()=>o.close(),"closeAlgorithm")),o.abort!==void 0&&(B=u(k=>o.abort(k),"abortAlgorithm")),Ln(n,g,_,w,P,B,a,p)}u(Ko,"SetUpWritableStreamDefaultControllerFromUnderlyingSink");function Ot(n){n._writeAlgorithm=void 0,n._closeAlgorithm=void 0,n._abortAlgorithm=void 0,n._strategySizeAlgorithm=void 0}u(Ot,"WritableStreamDefaultControllerClearAlgorithms");function Jo(n){ar(n,In,0),qt(n)}u(Jo,"WritableStreamDefaultControllerClose");function Xo(n,o){try{return n._strategySizeAlgorithm(o)}catch(a){return _r(n,a),1}}u(Xo,"WritableStreamDefaultControllerGetChunkSize");function $n(n){return n._strategyHWM-n._queueTotalSize}u($n,"WritableStreamDefaultControllerGetDesiredSize");function ei(n,o,a){try{ar(n,o,a)}catch(g){_r(n,g);return}const p=n._controlledWritableStream;if(!se(p)&&p._state==="writable"){const g=Sr(n);yr(p,g)}qt(n)}u(ei,"WritableStreamDefaultControllerWrite");function qt(n){const o=n._controlledWritableStream;if(!n._started||o._inFlightWriteRequest!==void 0)return;if(o._state==="erroring"){mr(o);return}if(n._queue.length===0)return;const p=wo(n);p===In?ti(n):ri(n,p)}u(qt,"WritableStreamDefaultControllerAdvanceQueueIfNeeded");function _r(n,o){n._controlledWritableStream._state==="writable"&&Dn(n,o)}u(_r,"WritableStreamDefaultControllerErrorIfNeeded");function ti(n){const o=n._controlledWritableStream;Ho(o),sr(n);const a=n._closeAlgorithm();Ot(n),D(a,()=>{Uo(o)},p=>{xo(o,p)})}u(ti,"WritableStreamDefaultControllerProcessClose");function ri(n,o){const a=n._controlledWritableStream;Vo(a);const p=n._writeAlgorithm(o);D(p,()=>{Do(a);const g=a._state;if(sr(n),!se(a)&&g==="writable"){const _=Sr(n);yr(a,_)}qt(n)},g=>{a._state==="writable"&&Ot(n),Mo(a,g)})}u(ri,"WritableStreamDefaultControllerProcessWrite");function Sr(n){return $n(n)<=0}u(Sr,"WritableStreamDefaultControllerGetBackpressure");function Dn(n,o){const a=n._controlledWritableStream;Ot(n),br(a,o)}u(Dn,"WritableStreamDefaultControllerError");function zt(n){return new TypeError(`WritableStream.prototype.${n} can only be used on a WritableStream`)}u(zt,"streamBrandCheckException$2");function wr(n){return new TypeError(`WritableStreamDefaultController.prototype.${n} can only be used on a WritableStreamDefaultController`)}u(wr,"defaultControllerBrandCheckException$2");function Fe(n){return new TypeError(`WritableStreamDefaultWriter.prototype.${n} can only be used on a WritableStreamDefaultWriter`)}u(Fe,"defaultWriterBrandCheckException");function at(n){return new TypeError("Cannot "+n+" a stream using a released writer")}u(at,"defaultWriterLockException");function Ft(n){n._closedPromise=F((o,a)=>{n._closedPromise_resolve=o,n._closedPromise_reject=a,n._closedPromiseState="pending"})}u(Ft,"defaultWriterClosedPromiseInitialize");function Mn(n,o){Ft(n),Rr(n,o)}u(Mn,"defaultWriterClosedPromiseInitializeAsRejected");function ni(n){Ft(n),Un(n)}u(ni,"defaultWriterClosedPromiseInitializeAsResolved");function Rr(n,o){n._closedPromise_reject!==void 0&&(V(n._closedPromise),n._closedPromise_reject(o),n._closedPromise_resolve=void 0,n._closedPromise_reject=void 0,n._closedPromiseState="rejected")}u(Rr,"defaultWriterClosedPromiseReject");function oi(n,o){Mn(n,o)}u(oi,"defaultWriterClosedPromiseResetToRejected");function Un(n){n._closedPromise_resolve!==void 0&&(n._closedPromise_resolve(void 0),n._closedPromise_resolve=void 0,n._closedPromise_reject=void 0,n._closedPromiseState="resolved")}u(Un,"defaultWriterClosedPromiseResolve");function jt(n){n._readyPromise=F((o,a)=>{n._readyPromise_resolve=o,n._readyPromise_reject=a}),n._readyPromiseState="pending"}u(jt,"defaultWriterReadyPromiseInitialize");function Tr(n,o){jt(n),Nn(n,o)}u(Tr,"defaultWriterReadyPromiseInitializeAsRejected");function xn(n){jt(n),Cr(n)}u(xn,"defaultWriterReadyPromiseInitializeAsResolved");function Nn(n,o){n._readyPromise_reject!==void 0&&(V(n._readyPromise),n._readyPromise_reject(o),n._readyPromise_resolve=void 0,n._readyPromise_reject=void 0,n._readyPromiseState="rejected")}u(Nn,"defaultWriterReadyPromiseReject");function ii(n){jt(n)}u(ii,"defaultWriterReadyPromiseReset");function si(n,o){Tr(n,o)}u(si,"defaultWriterReadyPromiseResetToRejected");function Cr(n){n._readyPromise_resolve!==void 0&&(n._readyPromise_resolve(void 0),n._readyPromise_resolve=void 0,n._readyPromise_reject=void 0,n._readyPromiseState="fulfilled")}u(Cr,"defaultWriterReadyPromiseResolve");const Hn=typeof DOMException<"u"?DOMException:void 0;function ai(n){if(!(typeof n=="function"||typeof n=="object"))return!1;try{return new n,!0}catch{return!1}}u(ai,"isDOMExceptionConstructor");function ui(){const n=u(function(a,p){this.message=a||"",this.name=p||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)},"DOMException");return n.prototype=Object.create(Error.prototype),Object.defineProperty(n.prototype,"constructor",{value:n,writable:!0,configurable:!0}),n}u(ui,"createDOMExceptionPolyfill");const li=ai(Hn)?Hn:ui();function Vn(n,o,a,p,g,_){const w=xe(n),P=Wn(o);n._disturbed=!0;let B=!1,k=T(void 0);return F((q,z)=>{let M;if(_!==void 0){if(M=u(()=>{const E=new li("Aborted","AbortError"),W=[];p||W.push(()=>o._state==="writable"?Wt(o,E):T(void 0)),g||W.push(()=>n._state==="readable"?re(n,E):T(void 0)),G(()=>Promise.all(W.map(I=>I())),!0,E)},"abortAlgorithm"),_.aborted){M();return}_.addEventListener("abort",M)}function ne(){return F((E,W)=>{function I(Z){Z?E():j(Ze(),I,W)}u(I,"next"),I(!1)})}u(ne,"pipeLoop");function Ze(){return B?T(!0):j(P._readyPromise,()=>F((E,W)=>{rt(w,{_chunkSteps:I=>{k=j(jn(P,I),void 0,y),E(!1)},_closeSteps:()=>E(!0),_errorSteps:W})}))}if(u(Ze,"pipeStep"),he(n,w._closedPromise,E=>{p?K(!0,E):G(()=>Wt(o,E),!0,E)}),he(o,P._closedPromise,E=>{g?K(!0,E):G(()=>re(n,E),!0,E)}),Q(n,w._closedPromise,()=>{a?K():G(()=>Go(P))}),se(o)||o._state==="closed"){const E=new TypeError("the destination writable stream closed before all data could be piped to it");g?K(!0,E):G(()=>re(n,E),!0,E)}V(ne());function Ce(){const E=k;return j(k,()=>E!==k?Ce():void 0)}u(Ce,"waitForWritesToFinish");function he(E,W,I){E._state==="errored"?I(E._storedError):tt(W,I)}u(he,"isOrBecomesErrored");function Q(E,W,I){E._state==="closed"?I():ie(W,I)}u(Q,"isOrBecomesClosed");function G(E,W,I){if(B)return;B=!0,o._state==="writable"&&!se(o)?ie(Ce(),Z):Z();function Z(){D(E(),()=>pe(W,I),Ke=>pe(!0,Ke))}u(Z,"doTheRest")}u(G,"shutdownWithAction");function K(E,W){B||(B=!0,o._state==="writable"&&!se(o)?ie(Ce(),()=>pe(E,W)):pe(E,W))}u(K,"shutdown");function pe(E,W){Fn(P),fe(w),_!==void 0&&_.removeEventListener("abort",M),E?z(W):q(void 0)}u(pe,"finalize")})}u(Vn,"ReadableStreamPipeTo");const Ir=class Ir{constructor(){throw new TypeError("Illegal constructor")}get desiredSize(){if(!It(this))throw Dt("desiredSize");return Pr(this)}close(){if(!It(this))throw Dt("close");if(!Ve(this))throw new TypeError("The stream is not in a state that permits close");lt(this)}enqueue(o=void 0){if(!It(this))throw Dt("enqueue");if(!Ve(this))throw new TypeError("The stream is not in a state that permits enqueue");return $t(this,o)}error(o=void 0){if(!It(this))throw Dt("error");we(this,o)}[er](o){ye(this);const a=this._cancelAlgorithm(o);return Lt(this),a}[tr](o){const a=this._controlledReadableStream;if(this._queue.length>0){const p=sr(this);this._closeRequested&&this._queue.length===0?(Lt(this),ft(a)):ut(this),o._chunkSteps(p)}else sn(a,o),ut(this)}};u(Ir,"ReadableStreamDefaultController");let Se=Ir;Object.defineProperties(Se.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),typeof b.toStringTag=="symbol"&&Object.defineProperty(Se.prototype,b.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});function It(n){return!C(n)||!Object.prototype.hasOwnProperty.call(n,"_controlledReadableStream")?!1:n instanceof Se}u(It,"IsReadableStreamDefaultController");function ut(n){if(!Qn(n))return;if(n._pulling){n._pullAgain=!0;return}n._pulling=!0;const a=n._pullAlgorithm();D(a,()=>{n._pulling=!1,n._pullAgain&&(n._pullAgain=!1,ut(n))},p=>{we(n,p)})}u(ut,"ReadableStreamDefaultControllerCallPullIfNeeded");function Qn(n){const o=n._controlledReadableStream;return!Ve(n)||!n._started?!1:!!(Te(o)&&yt(o)>0||Pr(n)>0)}u(Qn,"ReadableStreamDefaultControllerShouldCallPull");function Lt(n){n._pullAlgorithm=void 0,n._cancelAlgorithm=void 0,n._strategySizeAlgorithm=void 0}u(Lt,"ReadableStreamDefaultControllerClearAlgorithms");function lt(n){if(!Ve(n))return;const o=n._controlledReadableStream;n._closeRequested=!0,n._queue.length===0&&(Lt(n),ft(o))}u(lt,"ReadableStreamDefaultControllerClose");function $t(n,o){if(!Ve(n))return;const a=n._controlledReadableStream;if(Te(a)&&yt(a)>0)ir(a,o,!1);else{let p;try{p=n._strategySizeAlgorithm(o)}catch(g){throw we(n,g),g}try{ar(n,o,p)}catch(g){throw we(n,g),g}}ut(n)}u($t,"ReadableStreamDefaultControllerEnqueue");function we(n,o){const a=n._controlledReadableStream;a._state==="readable"&&(ye(n),Lt(n),Kn(a,o))}u(we,"ReadableStreamDefaultControllerError");function Pr(n){const o=n._controlledReadableStream._state;return o==="errored"?null:o==="closed"?0:n._strategyHWM-n._queueTotalSize}u(Pr,"ReadableStreamDefaultControllerGetDesiredSize");function fi(n){return!Qn(n)}u(fi,"ReadableStreamDefaultControllerHasBackpressure");function Ve(n){const o=n._controlledReadableStream._state;return!n._closeRequested&&o==="readable"}u(Ve,"ReadableStreamDefaultControllerCanCloseOrEnqueue");function Gn(n,o,a,p,g,_,w){o._controlledReadableStream=n,o._queue=void 0,o._queueTotalSize=void 0,ye(o),o._started=!1,o._closeRequested=!1,o._pullAgain=!1,o._pulling=!1,o._strategySizeAlgorithm=w,o._strategyHWM=_,o._pullAlgorithm=p,o._cancelAlgorithm=g,n._readableStreamController=o;const P=a();D(T(P),()=>{o._started=!0,ut(o)},B=>{we(o,B)})}u(Gn,"SetUpReadableStreamDefaultController");function ci(n,o,a,p){const g=Object.create(Se.prototype);let _=u(()=>{},"startAlgorithm"),w=u(()=>T(void 0),"pullAlgorithm"),P=u(()=>T(void 0),"cancelAlgorithm");o.start!==void 0&&(_=u(()=>o.start(g),"startAlgorithm")),o.pull!==void 0&&(w=u(()=>o.pull(g),"pullAlgorithm")),o.cancel!==void 0&&(P=u(B=>o.cancel(B),"cancelAlgorithm")),Gn(n,g,_,w,P,a,p)}u(ci,"SetUpReadableStreamDefaultControllerFromUnderlyingSource");function Dt(n){return new TypeError(`ReadableStreamDefaultController.prototype.${n} can only be used on a ReadableStreamDefaultController`)}u(Dt,"defaultControllerBrandCheckException$1");function di(n,o){return Ae(n._readableStreamController)?pi(n):hi(n)}u(di,"ReadableStreamTee");function hi(n,o){const a=xe(n);let p=!1,g=!1,_=!1,w=!1,P,B,k,q,z;const M=F(Q=>{z=Q});function ne(){return p?(g=!0,T(void 0)):(p=!0,rt(a,{_chunkSteps:G=>{U(()=>{g=!1;const K=G,pe=G;_||$t(k._readableStreamController,K),w||$t(q._readableStreamController,pe),p=!1,g&&ne()})},_closeSteps:()=>{p=!1,_||lt(k._readableStreamController),w||lt(q._readableStreamCon