Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mattiasbuelens/web-streams-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mattiasbuelens/web-streams-polyfill - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

dist/polyfill.es6.js

8

CHANGELOG.md

@@ -12,2 +12,10 @@ # Changelog

## v0.3.0 (2019-02-21)
* 💥 **Breaking change:** The type of `TransformStream<R, W>` is changed to `TransformStream<I, O>` and the meaning of the two type parameters is flipped, to align the polyfill with the built-in type definitions of TypeScript 3.2.
* 🚀 Add `polyfill/es6` variant
* 🐛 Fix memory leak when using streams in a microtask loop in Node.js ([#8](https://github.com/MattiasBuelens/web-streams-polyfill/pull/8))
* 🏠 Switch to TypeScript ([#7](https://github.com/MattiasBuelens/web-streams-polyfill/pull/7))
* 💅 Improve type definitions ([#7](https://github.com/MattiasBuelens/web-streams-polyfill/pull/7))
## v0.2.1 (2018-12-31)

@@ -14,0 +22,0 @@

2

dist/polyfill.es6.min.js

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).WebStreamsPolyfill={})}(this,function(e){"use strict";const r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`,t=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function o(){}const n="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;var a={default:o};const i=Number.isNaN||function(e){return e!=e};function s(e){return e&&e.default||e}s(a);var l=function(e,r){return e(r={exports:{}},r.exports),r.exports}(function(e,t){const o=r('is "detached" for our purposes');function n(e,r,t){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,r,t)}function a(e,r,t){try{return Promise.resolve(n(e,r,t))}catch(e){return Promise.reject(e)}}t.typeIsObject=(e=>"object"==typeof e&&null!==e||"function"==typeof e),t.createDataProperty=((e,r,t)=>{Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})}),t.createArrayFromList=(e=>e.slice()),t.ArrayBufferCopy=((e,r,t,o,n)=>{new Uint8Array(e).set(new Uint8Array(t,o,n),r)}),t.IsFiniteNonNegativeNumber=(e=>!1!==t.IsNonNegativeNumber(e)&&e!==1/0),t.IsNonNegativeNumber=(e=>"number"==typeof e&&(!i(e)&&!(e<0))),t.Call=n,t.CreateAlgorithmFromUnderlyingMethod=((e,r,t,o)=>{const n=e[r];if(void 0!==n){if("function"!=typeof n)throw new TypeError(`${n} is not a method`);switch(t){case 0:return()=>a(n,e,o);case 1:return r=>{const t=[r].concat(o);return a(n,e,t)}}}return()=>Promise.resolve()}),t.InvokeOrNoop=((e,r,t)=>{const o=e[r];if(void 0!==o)return n(o,e,t)}),t.PromiseCall=a,t.TransferArrayBuffer=(e=>{const r=e.slice();return Object.defineProperty(e,"byteLength",{get:()=>0}),e[o]=!0,r}),t.IsDetachedBuffer=(e=>o in e),t.ValidateAndNormalizeHighWaterMark=(e=>{if(e=Number(e),i(e)||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e}),t.MakeSizeAlgorithmFromSizeFunction=(e=>{if(void 0===e)return()=>1;if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return r=>e(r)}),t.PerformPromiseThen=((e,r,t)=>Promise.prototype.then.call(e,r,t)),t.WaitForAll=((e,r,o)=>{let n=!1;const a=e=>{!1===n&&(n=!0,o(e))};let i=0,s=0;const l=e.length,c=new Array(l);for(const o of e){const e=i,n=t=>{c[e]=t,++s===l&&r(c)};t.PerformPromiseThen(o,n,a),++i}}),t.WaitForAllPromise=((e,r,o)=>{let n,a;const i=new Promise((e,r)=>{n=e,a=r});void 0===o&&(o=(e=>{throw e}));return t.WaitForAll(e,e=>{try{const t=r(e);n(t)}catch(e){a(e)}},e=>{try{const r=o(e);n(r)}catch(e){a(e)}}),i})}),c=l.typeIsObject,u=l.createDataProperty,d=l.createArrayFromList,f=l.ArrayBufferCopy,m=l.IsFiniteNonNegativeNumber,h=l.IsNonNegativeNumber,_=l.Call,b=l.CreateAlgorithmFromUnderlyingMethod,y=l.InvokeOrNoop,p=l.PromiseCall;l.TransferArrayBuffer,l.IsDetachedBuffer;var w={TransferArrayBuffer:function(e){return e},IsDetachedBuffer:function(e){return!1},typeIsObject:c,createDataProperty:u,createArrayFromList:d,ArrayBufferCopy:f,IsFiniteNonNegativeNumber:m,IsNonNegativeNumber:h,Call:_,CreateAlgorithmFromUnderlyingMethod:b,InvokeOrNoop:y,PromiseCall:p,ValidateAndNormalizeHighWaterMark:l.ValidateAndNormalizeHighWaterMark,MakeSizeAlgorithmFromSizeFunction:l.MakeSizeAlgorithmFromSizeFunction,PerformPromiseThen:l.PerformPromiseThen,WaitForAll:l.WaitForAll,WaitForAllPromise:l.WaitForAllPromise};function S(){}S.AssertionError=o;var g=s({default:S}),v={rethrowAssertionErrorRejection:e=>{e&&e instanceof g.AssertionError&&setTimeout(()=>{throw e},0)}},P=s(w);const{IsFiniteNonNegativeNumber:R}=P;var T={DequeueValue:e=>{const r=e._queue.shift();return e._queueTotalSize-=r.size,e._queueTotalSize<0&&(e._queueTotalSize=0),r.value},EnqueueValueWithSize:(e,r,t)=>{if(t=Number(t),!R(t))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:r,size:t}),e._queueTotalSize+=t},PeekQueueValue:e=>{return e._queue[0].value},ResetQueue:e=>{e._queue=[],e._queueTotalSize=0}},C=s({default:o});C("streams:writable-stream:verbose");const{CreateAlgorithmFromUnderlyingMethod:q,InvokeOrNoop:j,ValidateAndNormalizeHighWaterMark:A,IsNonNegativeNumber:E,MakeSizeAlgorithmFromSizeFunction:W,typeIsObject:O}=P,{rethrowAssertionErrorRejection:B}=v,{DequeueValue:z,EnqueueValueWithSize:k,PeekQueueValue:F,ResetQueue:I}=T,D=r("[[AbortSteps]]"),N=r("[[ErrorSteps]]");class WritableStream{constructor(e={},r={}){V(this);const t=r.size;let o=r.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");const n=W(t);void 0===o&&(o=1),function(e,r,t,o){const n=Object.create(WritableStreamDefaultController.prototype);const a=q(r,"write",1,[n]),i=q(r,"close",0,[]),s=q(r,"abort",1,[]);ae(e,n,function(){return j(r,"start",[n])},a,i,s,t,o)}(this,e,o=A(o),n)}get locked(){if(!1===Y(this))throw fe("locked");return $(this)}abort(e){return!1===Y(this)?Promise.reject(fe("abort")):!0===$(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):H(this,e)}getWriter(){if(!1===Y(this))throw fe("getWriter");return M(this)}}var L={AcquireWritableStreamDefaultWriter:M,CreateWritableStream:function(e,r,t,o,n=1,a=(()=>1)){const i=Object.create(WritableStream.prototype);V(i);const s=Object.create(WritableStreamDefaultController.prototype);return ae(i,s,e,r,t,o,n,a),i},IsWritableStream:Y,IsWritableStreamLocked:$,WritableStream:WritableStream,WritableStreamAbort:H,WritableStreamDefaultControllerErrorIfNeeded:ce,WritableStreamDefaultWriterCloseWithErrorPropagation:function(e){const r=e._ownerWritableStream,t=r._state;if(!0===J(r)||"closed"===t)return Promise.resolve();if("errored"===t)return Promise.reject(r._storedError);return ee(e)},WritableStreamDefaultWriterRelease:oe,WritableStreamDefaultWriterWrite:ne,WritableStreamCloseQueuedOrInFlight:J};function M(e){return new WritableStreamDefaultWriter(e)}function V(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=[],e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function Y(e){return!!O(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function $(e){return void 0!==e._writer}function H(e,r){const t=e._state;if("closed"===t||"errored"===t)return Promise.resolve(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===t&&(o=!0,r=void 0);const n=new Promise((t,n)=>{e._pendingAbortRequest={_resolve:t,_reject:n,_reason:r,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&U(e,r),n}function Q(e,r){"writable"!==e._state?x(e):U(e,r)}function U(e,r){const t=e._writableStreamController;e._state="erroring",e._storedError=r;const o=e._writer;void 0!==o&&te(o,r),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===t._started&&x(e)}function x(e){e._state="errored",e._writableStreamController[N]();const r=e._storedError;for(const t of e._writeRequests)t._reject(r);if(e._writeRequests=[],void 0===e._pendingAbortRequest)return void K(e);const t=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===t._wasAlreadyErroring)return t._reject(r),void K(e);e._writableStreamController[D](t._reason).then(()=>{t._resolve(),K(e)},r=>{t._reject(r),K(e)})}function G(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const r=e._writer;void 0!==r&&function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(r)}function J(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function K(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const r=e._writer;void 0!==r&&(be(r,e._storedError),r._closedPromise.catch(()=>{}))}function X(e,r){const t=e._writer;void 0!==t&&r!==e._backpressure&&(!0===r?function(e){e._readyPromise=new Promise((r,t)=>{e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(t):we(t)),e._backpressure=r}class WritableStreamDefaultWriter{constructor(e){if(!1===Y(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===$(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("writable"===r)!1===J(e)&&!0===e._backpressure?function(e){e._readyPromise=new Promise((r,t)=>{e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(this):pe(this),_e(this);else if("erroring"===r)ye(this,e._storedError),this._readyPromise.catch(()=>{}),_e(this);else if("closed"===r)pe(this),function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(this);else{const r=e._storedError;ye(this,r),this._readyPromise.catch(()=>{}),function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}(this,r),this._closedPromise.catch(()=>{})}}get closed(){return!1===Z(this)?Promise.reject(me("closed")):this._closedPromise}get desiredSize(){if(!1===Z(this))throw me("desiredSize");if(void 0===this._ownerWritableStream)throw he("desiredSize");return function(e){const r=e._ownerWritableStream,t=r._state;if("errored"===t||"erroring"===t)return null;if("closed"===t)return 0;return se(r._writableStreamController)}(this)}get ready(){return!1===Z(this)?Promise.reject(me("ready")):this._readyPromise}abort(e){return!1===Z(this)?Promise.reject(me("abort")):void 0===this._ownerWritableStream?Promise.reject(he("abort")):function(e,r){return H(e._ownerWritableStream,r)}(this,e)}close(){if(!1===Z(this))return Promise.reject(me("close"));const e=this._ownerWritableStream;return void 0===e?Promise.reject(he("close")):!0===J(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):ee(this)}releaseLock(){if(!1===Z(this))throw me("releaseLock");void 0!==this._ownerWritableStream&&oe(this)}write(e){return!1===Z(this)?Promise.reject(me("write")):void 0===this._ownerWritableStream?Promise.reject(he("write to")):ne(this,e)}}function Z(e){return!!O(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function ee(e){const r=e._ownerWritableStream,t=r._state;if("closed"===t||"errored"===t)return Promise.reject(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const o=new Promise((e,t)=>{const o={_resolve:e,_reject:t};r._closeRequest=o});return!0===r._backpressure&&"writable"===t&&we(e),function(e){k(e,"close",0),le(e)}(r._writableStreamController),o}function re(e,r){"pending"===e._closedPromiseState?be(e,r):function(e,r){e._closedPromise=Promise.reject(r),e._closedPromiseState="rejected"}(e,r),e._closedPromise.catch(()=>{})}function te(e,r){"pending"===e._readyPromiseState?function(e,r){e._readyPromise_reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}(e,r):function(e,r){e._readyPromise=Promise.reject(r),e._readyPromiseState="rejected"}(e,r),e._readyPromise.catch(()=>{})}function oe(e){const r=e._ownerWritableStream,t=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");te(e,t),re(e,t),r._writer=void 0,e._ownerWritableStream=void 0}function ne(e,r){const t=e._ownerWritableStream,o=t._writableStreamController,n=function(e,r){try{return e._strategySizeAlgorithm(r)}catch(r){return ce(e,r),1}}(o,r);if(t!==e._ownerWritableStream)return Promise.reject(he("write to"));const a=t._state;if("errored"===a)return Promise.reject(t._storedError);if(!0===J(t)||"closed"===a)return Promise.reject(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===a)return Promise.reject(t._storedError);const i=function(e){return new Promise((r,t)=>{const o={_resolve:r,_reject:t};e._writeRequests.push(o)})}(t);return function(e,r,t){const o={chunk:r};try{k(e,o,t)}catch(r){return void ce(e,r)}const n=e._controlledWritableStream;if(!1===J(n)&&"writable"===n._state){const r=ue(e);X(n,r)}le(e)}(o,r,n),i}class WritableStreamDefaultController{constructor(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}error(e){if(!1===function(e){if(!O(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&de(this,e)}[D](e){const r=this._abortAlgorithm(e);return ie(this),r}[N](){I(this)}}function ae(e,r,t,o,n,a,i,s){r._controlledWritableStream=e,e._writableStreamController=r,r._queue=void 0,r._queueTotalSize=void 0,I(r),r._started=!1,r._strategySizeAlgorithm=s,r._strategyHWM=i,r._writeAlgorithm=o,r._closeAlgorithm=n,r._abortAlgorithm=a;const l=ue(r);X(e,l);const c=t();Promise.resolve(c).then(()=>{r._started=!0,le(r)},t=>{r._started=!0,Q(e,t)}).catch(B)}function ie(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function se(e){return e._strategyHWM-e._queueTotalSize}function le(e){const r=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==r._inFlightWriteRequest)return;const t=r._state;if("closed"===t||"errored"===t)return;if("erroring"===t)return void x(r);if(0===e._queue.length)return;const o=F(e);"close"===o?function(e){const r=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(r),z(e);const t=e._closeAlgorithm();ie(e),t.then(()=>{G(r)},e=>{!function(e,r){e._inFlightCloseRequest._reject(r),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(r),e._pendingAbortRequest=void 0),Q(e,r)}(r,e)}).catch(B)}(e):function(e,r){const t=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(t),e._writeAlgorithm(r).then(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(t);const r=t._state;if(z(e),!1===J(t)&&"writable"===r){const r=ue(e);X(t,r)}le(e)},r=>{"writable"===t._state&&ie(e),function(e,r){e._inFlightWriteRequest._reject(r),e._inFlightWriteRequest=void 0,Q(e,r)}(t,r)}).catch(B)}(e,o.chunk)}function ce(e,r){"writable"===e._controlledWritableStream._state&&de(e,r)}function ue(e){return se(e)<=0}function de(e,r){const t=e._controlledWritableStream;ie(e),U(t,r)}function fe(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function me(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function he(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function _e(e){e._closedPromise=new Promise((r,t)=>{e._closedPromise_resolve=r,e._closedPromise_reject=t,e._closedPromiseState="pending"})}function be(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function ye(e,r){e._readyPromise=Promise.reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function pe(e){e._readyPromise=Promise.resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}function we(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}var Se=L.WritableStream;const{ArrayBufferCopy:ge,CreateAlgorithmFromUnderlyingMethod:ve,IsFiniteNonNegativeNumber:Pe,InvokeOrNoop:Re,IsDetachedBuffer:Te,TransferArrayBuffer:Ce,ValidateAndNormalizeHighWaterMark:qe,IsNonNegativeNumber:je,MakeSizeAlgorithmFromSizeFunction:Ae,createArrayFromList:Ee,typeIsObject:We,WaitForAllPromise:Oe}=P,{rethrowAssertionErrorRejection:Be}=v,{DequeueValue:ze,EnqueueValueWithSize:ke,ResetQueue:Fe}=T,{AcquireWritableStreamDefaultWriter:Ie,IsWritableStream:De,IsWritableStreamLocked:Ne,WritableStreamAbort:Le,WritableStreamDefaultWriterCloseWithErrorPropagation:Me,WritableStreamDefaultWriterRelease:Ve,WritableStreamDefaultWriterWrite:Ye,WritableStreamCloseQueuedOrInFlight:$e}=L,He=r("[[CancelSteps]]"),Qe=r("[[PullSteps]]");class ReadableStream{constructor(e={},r={}){Je(this);const o=r.size;let n=r.highWaterMark;const a=e.type;if("bytes"===String(a)){if(void 0!==o)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===n&&(n=0),function(e,r,o){const n=Object.create(ReadableByteStreamController.prototype);const a=ve(r,"pull",0,[n]),i=ve(r,"cancel",1,[]);let s=r.autoAllocateChunkSize;if(void 0!==s&&(s=Number(s),!1===t(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");$r(e,n,function(){return Re(r,"start",[n])},a,i,o,s)}(this,e,n=qe(n))}else{if(void 0!==a)throw new RangeError("Invalid type is specified");{const r=Ae(o);void 0===n&&(n=1),function(e,r,t,o){const n=Object.create(ReadableStreamDefaultController.prototype);const a=ve(r,"pull",0,[n]),i=ve(r,"cancel",1,[]);Cr(e,n,function(){return Re(r,"start",[n])},a,i,t,o)}(this,e,n=qe(n),r)}}}get locked(){if(!1===Ke(this))throw Qr("locked");return Xe(this)}cancel(e){return!1===Ke(this)?Promise.reject(Qr("cancel")):!0===Xe(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):tr(this,e)}getReader({mode:e}={}){if(!1===Ke(this))throw Qr("getReader");if(void 0===e)return xe(this);if("byob"===(e=String(e)))return function(e){return new ReadableStreamBYOBReader(e)}(this);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:r},{preventClose:t,preventAbort:o,preventCancel:n,signal:a}={}){if(!1===Ke(this))throw Qr("pipeThrough");if(!1===De(e))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===Ke(r))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(t=Boolean(t),o=Boolean(o),n=Boolean(n),void 0!==a&&!Hr(a))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===Xe(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===Ne(e))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return Ze(this,e,t,o,n,a).catch(()=>{}),r}pipeTo(e,{preventClose:r,preventAbort:t,preventCancel:o,signal:n}={}){return!1===Ke(this)?Promise.reject(Qr("pipeTo")):!1===De(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream")):(r=Boolean(r),t=Boolean(t),o=Boolean(o),void 0===n||Hr(n)?!0===Xe(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===Ne(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Ze(this,e,r,t,o,n):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))}tee(){if(!1===Ke(this))throw Qr("tee");const e=function(e,r){const t=xe(e);let o,n,a,i,s,l=!1,c=!1,u=!1;const d=new Promise(e=>{s=e});function f(){return br(t).then(e=>{const r=e.value,t=e.done;if(!0===t&&!1===l&&(!1===c&&gr(a._readableStreamController),!1===u&&gr(i._readableStreamController),l=!0),!0===l)return;const o=r,n=r;!1===c&&vr(a._readableStreamController,o),!1===u&&vr(i._readableStreamController,n)})}function m(){}return a=Ge(m,f,function(r){if(c=!0,o=r,!0===u){const r=Ee([o,n]),t=tr(e,r);s(t)}return d}),i=Ge(m,f,function(r){if(u=!0,n=r,!0===c){const r=Ee([o,n]),t=tr(e,r);s(t)}return d}),t._closedPromise.catch(e=>{!0!==l&&(Pr(a._readableStreamController,e),Pr(i._readableStreamController,e),l=!0)}),[a,i]}(this);return Ee(e)}}var Ue={CreateReadableByteStream:function(e,r,t,o=0,n){const a=Object.create(ReadableStream.prototype);Je(a);const i=Object.create(ReadableByteStreamController.prototype);return $r(a,i,e,r,t,o,n),a},CreateReadableStream:Ge,ReadableStream:ReadableStream,IsReadableStreamDisturbed:function(e){return e._disturbed},ReadableStreamDefaultControllerClose:gr,ReadableStreamDefaultControllerEnqueue:vr,ReadableStreamDefaultControllerError:Pr,ReadableStreamDefaultControllerGetDesiredSize:Rr,ReadableStreamDefaultControllerHasBackpressure:function(e){if(!0===wr(e))return!1;return!0},ReadableStreamDefaultControllerCanCloseOrEnqueue:Tr};function xe(e){return new ReadableStreamDefaultReader(e)}function Ge(e,r,t,o=1,n=(()=>1)){const a=Object.create(ReadableStream.prototype);return Je(a),Cr(a,Object.create(ReadableStreamDefaultController.prototype),e,r,t,o,n),a}function Je(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Ke(e){return!!We(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function Xe(e){return void 0!==e._reader}function Ze(e,r,t,o,n,a){const i=xe(e),s=Ie(r);let l=!1,c=Promise.resolve();return new Promise((u,d)=>{let f;if(void 0!==a){if(f=(()=>{const t=new DOMException("Aborted","AbortError"),a=[];!1===o&&a.push(()=>"writable"===r._state?Le(r,t):Promise.resolve()),!1===n&&a.push(()=>"readable"===e._state?tr(e,t):Promise.resolve()),_(()=>Oe(a.map(e=>e()),e=>e),!0,t)}),!0===a.aborted)return void f();a.addEventListener("abort",f)}if(h(e,i._closedPromise,e=>{!1===o?_(()=>Le(r,e),!0,e):b(!0,e)}),h(r,s._closedPromise,r=>{!1===n?_(()=>tr(e,r),!0,r):b(!0,r)}),function(e,r,t){"closed"===e._state?t():r.then(t).catch(Be)}(e,i._closedPromise,()=>{!1===t?_(()=>Me(s)):b()}),!0===$e(r)||"closed"===r._state){const r=new TypeError("the destination writable stream closed before all data could be piped to it");!1===n?_(()=>tr(e,r),!0,r):b(!0,r)}function m(){const e=c;return c.then(()=>e!==c?m():void 0)}function h(e,r,t){"errored"===e._state?t(e._storedError):r.catch(t).catch(Be)}function _(e,t,o){function n(){e().then(()=>y(t,o),e=>y(!0,e)).catch(Be)}!0!==l&&(l=!0,"writable"===r._state&&!1===$e(r)?m().then(n):n())}function b(e,t){!0!==l&&(l=!0,"writable"===r._state&&!1===$e(r)?m().then(()=>y(e,t)).catch(Be):y(e,t))}function y(e,r){Ve(s),_r(i),void 0!==a&&a.removeEventListener("abort",f),e?d(r):u(void 0)}new Promise((e,r)=>{!function t(o){o?e():(!0===l?Promise.resolve(!0):s._readyPromise.then(()=>br(i).then(({value:e,done:r})=>!0===r||(c=Ye(s,e).catch(()=>{}),!1)))).then(t,r)}(!1)}).catch(e=>{c=Promise.resolve(),Be(e)})})}function er(e,r){return new Promise((t,o)=>{const n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readIntoRequests.push(n)})}function rr(e,r){return new Promise((t,o)=>{const n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readRequests.push(n)})}function tr(e,r){if(e._disturbed=!0,"closed"===e._state)return Promise.resolve(void 0);if("errored"===e._state)return Promise.reject(e._storedError);return or(e),e._readableStreamController[He](r).then(()=>void 0)}function or(e){e._state="closed";const r=e._reader;if(void 0!==r){if(!0===fr(r)){for(const{_resolve:e,_forAuthorCode:t}of r._readRequests)e(nr(void 0,!0,t));r._readRequests=[]}!function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(r)}}function nr(e,r,t){let o=null;!0===t&&(o=Object.prototype);const n=Object.create(o);return Object.defineProperty(n,"value",{value:e,enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(n,"done",{value:r,enumerable:!0,writable:!0,configurable:!0}),n}function ar(e,r){e._state="errored",e._storedError=r;const t=e._reader;if(void 0!==t){if(!0===fr(t)){for(const e of t._readRequests)e._reject(r);t._readRequests=[]}else{for(const e of t._readIntoRequests)e._reject(r);t._readIntoRequests=[]}Gr(t,r),t._closedPromise.catch(()=>{})}}function ir(e,r,t){const o=e._reader._readRequests.shift();o._resolve(nr(r,t,o._forAuthorCode))}function sr(e){return e._reader._readIntoRequests.length}function lr(e){return e._reader._readRequests.length}function cr(e){const r=e._reader;return void 0!==r&&!1!==dr(r)}function ur(e){const r=e._reader;return void 0!==r&&!1!==fr(r)}class ReadableStreamDefaultReader{constructor(e){if(!1===Ke(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===Xe(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");mr(this,e),this._readRequests=[]}get closed(){return!1===fr(this)?Promise.reject(xr("closed")):this._closedPromise}cancel(e){return!1===fr(this)?Promise.reject(xr("cancel")):void 0===this._ownerReadableStream?Promise.reject(Ur("cancel")):hr(this,e)}read(){return!1===fr(this)?Promise.reject(xr("read")):void 0===this._ownerReadableStream?Promise.reject(Ur("read from")):br(this,!0)}releaseLock(){if(!1===fr(this))throw xr("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");_r(this)}}}class ReadableStreamBYOBReader{constructor(e){if(!Ke(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===qr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(Xe(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");mr(this,e),this._readIntoRequests=[]}get closed(){return dr(this)?this._closedPromise:Promise.reject(Jr("closed"))}cancel(e){return dr(this)?void 0===this._ownerReadableStream?Promise.reject(Ur("cancel")):hr(this,e):Promise.reject(Jr("cancel"))}read(e){return dr(this)?void 0===this._ownerReadableStream?Promise.reject(Ur("read from")):ArrayBuffer.isView(e)?!0===Te(e.buffer)?Promise.reject(new TypeError("Cannot read into a view onto a detached ArrayBuffer")):0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,r,t=!1){const o=e._ownerReadableStream;if(o._disturbed=!0,"errored"===o._state)return Promise.reject(o._storedError);return function(e,r,t){const o=e._controlledReadableByteStream;let n=1;r.constructor!==DataView&&(n=r.constructor.BYTES_PER_ELEMENT);const a=r.constructor,i={buffer:Ce(r.buffer),byteOffset:r.byteOffset,byteLength:r.byteLength,bytesFilled:0,elementSize:n,ctor:a,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(i),er(o,t);if("closed"===o._state){const e=new r.constructor(i.buffer,i.byteOffset,0);return Promise.resolve(nr(e,!0,t))}if(e._queueTotalSize>0){if(!0===zr(e,i)){const r=Or(i);return Fr(e),Promise.resolve(nr(r,!1,t))}if(!0===e._closeRequested){const r=new TypeError("Insufficient bytes to fill elements in the given buffer");return Vr(e,r),Promise.reject(r)}}e._pendingPullIntos.push(i);const s=er(o,t);return Ar(e),s}(o._readableStreamController,r,t)}(this,e,!0):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(Jr("read"))}releaseLock(){if(!dr(this))throw Jr("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");_r(this)}}}function dr(e){return!!We(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function fr(e){return!!We(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function mr(e,r){e._ownerReadableStream=r,r._reader=e,"readable"===r._state?function(e){e._closedPromise=new Promise((r,t)=>{e._closedPromise_resolve=r,e._closedPromise_reject=t})}(e):"closed"===r._state?function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e):(!function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e,r._storedError),e._closedPromise.catch(()=>{}))}function hr(e,r){return tr(e._ownerReadableStream,r)}function _r(e){"readable"===e._ownerReadableStream._state?Gr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,r){e._closedPromise=Promise.reject(r)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._closedPromise.catch(()=>{}),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function br(e,r=!1){const t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?Promise.resolve(nr(void 0,!0,r)):"errored"===t._state?Promise.reject(t._storedError):t._readableStreamController[Qe](r)}class ReadableStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){if(!1===yr(this))throw Kr("desiredSize");return Rr(this)}close(){if(!1===yr(this))throw Kr("close");if(!1===Tr(this))throw new TypeError("The stream is not in a state that permits close");gr(this)}enqueue(e){if(!1===yr(this))throw Kr("enqueue");if(!1===Tr(this))throw new TypeError("The stream is not in a state that permits enqueue");return vr(this,e)}error(e){if(!1===yr(this))throw Kr("error");Pr(this,e)}[He](e){Fe(this);const r=this._cancelAlgorithm(e);return Sr(this),r}[Qe](e){const r=this._controlledReadableStream;if(this._queue.length>0){const t=ze(this);return!0===this._closeRequested&&0===this._queue.length?(Sr(this),or(r)):pr(this),Promise.resolve(nr(t,!1,e))}const t=rr(r,e);return pr(this),t}}function yr(e){return!!We(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function pr(e){!1!==wr(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{if(e._pulling=!1,!0===e._pullAgain)return e._pullAgain=!1,pr(e)},r=>{Pr(e,r)}).catch(Be)):e._pullAgain=!0)}function wr(e){const r=e._controlledReadableStream;return!1!==Tr(e)&&(!1!==e._started&&(!0===Xe(r)&&lr(r)>0||Rr(e)>0))}function Sr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function gr(e){const r=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Sr(e),or(r))}function vr(e,r){const t=e._controlledReadableStream;if(!0===Xe(t)&&lr(t)>0)ir(t,r,!1);else{let t;try{t=e._strategySizeAlgorithm(r)}catch(r){throw Pr(e,r),r}try{ke(e,r,t)}catch(r){throw Pr(e,r),r}}pr(e)}function Pr(e,r){const t=e._controlledReadableStream;"readable"===t._state&&(Fe(e),Sr(e),ar(t,r))}function Rr(e){const r=e._controlledReadableStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function Tr(e){const r=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===r}function Cr(e,r,t,o,n,a,i){r._controlledReadableStream=e,r._queue=void 0,r._queueTotalSize=void 0,Fe(r),r._started=!1,r._closeRequested=!1,r._pullAgain=!1,r._pulling=!1,r._strategySizeAlgorithm=i,r._strategyHWM=a,r._pullAlgorithm=o,r._cancelAlgorithm=n,e._readableStreamController=r;const s=t();Promise.resolve(s).then(()=>{r._started=!0,pr(r)},e=>{Pr(r,e)}).catch(Be)}class ReadableStreamBYOBRequest{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===jr(this))throw Xr("view");return this._view}respond(e){if(!1===jr(this))throw Xr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!0===Te(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");!function(e,r){if(r=Number(r),!1===Pe(r))throw new RangeError("bytesWritten must be a finite");Nr(e,r)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===jr(this))throw Xr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(!0===Te(e.buffer))throw new TypeError("The supplied view's buffer has been detached and so cannot be used as a response");!function(e,r){const t=e._pendingPullIntos[0];if(t.byteOffset+t.bytesFilled!==r.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(t.byteLength!==r.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");t.buffer=r.buffer,Nr(e,r.byteLength)}(this._associatedReadableByteStreamController,e)}}class ReadableByteStreamController{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===qr(this))throw Zr("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos[0],r=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),t=Object.create(ReadableStreamBYOBRequest.prototype);!function(e,r,t){e._associatedReadableByteStreamController=r,e._view=t}(t,this,r),this._byobRequest=t}return this._byobRequest}get desiredSize(){if(!1===qr(this))throw Zr("desiredSize");return Yr(this)}close(){if(!1===qr(this))throw Zr("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const r=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){const r=e._pendingPullIntos[0];if(r.bytesFilled>0){const r=new TypeError("Insufficient bytes to fill elements in the given buffer");throw Vr(e,r),r}}Mr(e),or(r)}(this)}enqueue(e){if(!1===qr(this))throw Zr("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");const r=this._controlledReadableByteStream._state;if("readable"!==r)throw new TypeError(`The stream (in ${r} state) is not in the readable state and cannot be enqueued to`);if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");if(!0===Te(e.buffer))throw new TypeError("Cannot enqueue a view onto a detached ArrayBuffer");!function(e,r){const t=e._controlledReadableByteStream,o=r.buffer,n=r.byteOffset,a=r.byteLength,i=Ce(o);if(!0===ur(t))if(0===lr(t))Br(e,i,n,a);else{const e=new Uint8Array(i,n,a);ir(t,e,!1)}else!0===cr(t)?(Br(e,i,n,a),Dr(e)):Br(e,i,n,a);Ar(e)}(this,e)}error(e){if(!1===qr(this))throw Zr("error");Vr(this,e)}[He](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos[0].bytesFilled=0}Fe(this);const r=this._cancelAlgorithm(e);return Mr(this),r}[Qe](e){const r=this._controlledReadableByteStream;if(this._queueTotalSize>0){const r=this._queue.shift();let t;this._queueTotalSize-=r.byteLength,Fr(this);try{t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(nr(t,!1,e))}const t=this._autoAllocateChunkSize;if(void 0!==t){let e;try{e=new ArrayBuffer(t)}catch(e){return Promise.reject(e)}const r={buffer:e,byteOffset:0,byteLength:t,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(r)}const o=rr(r,e);return Ar(this),o}}function qr(e){return!!We(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function jr(e){return!!We(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function Ar(e){!1!==function(e){const r=e._controlledReadableByteStream;if("readable"!==r._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===ur(r)&&lr(r)>0)return!0;if(!0===cr(r)&&sr(r)>0)return!0;if(Yr(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,Ar(e))},r=>{Vr(e,r)}).catch(Be)):e._pullAgain=!0)}function Er(e){Ir(e),e._pendingPullIntos=[]}function Wr(e,r){let t=!1;"closed"===e._state&&(t=!0);const o=Or(r);"default"===r.readerType?ir(e,o,t):function(e,r,t){const o=e._reader._readIntoRequests.shift();o._resolve(nr(r,t,o._forAuthorCode))}(e,o,t)}function Or(e){const r=e.bytesFilled,t=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,r/t)}function Br(e,r,t,o){e._queue.push({buffer:r,byteOffset:t,byteLength:o}),e._queueTotalSize+=o}function zr(e,r){const t=r.elementSize,o=r.bytesFilled-r.bytesFilled%t,n=Math.min(e._queueTotalSize,r.byteLength-r.bytesFilled),a=r.bytesFilled+n,i=a-a%t;let s=n,l=!1;i>o&&(s=i-r.bytesFilled,l=!0);const c=e._queue;for(;s>0;){const t=c[0],o=Math.min(s,t.byteLength),n=r.byteOffset+r.bytesFilled;ge(r.buffer,n,t.buffer,t.byteOffset,o),t.byteLength===o?c.shift():(t.byteOffset+=o,t.byteLength-=o),e._queueTotalSize-=o,kr(e,o,r),s-=o}return l}function kr(e,r,t){Ir(e),t.bytesFilled+=r}function Fr(e){0===e._queueTotalSize&&!0===e._closeRequested?(Mr(e),or(e._controlledReadableByteStream)):Ar(e)}function Ir(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function Dr(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const r=e._pendingPullIntos[0];!0===zr(e,r)&&(Lr(e),Wr(e._controlledReadableByteStream,r))}}function Nr(e,r){const t=e._pendingPullIntos[0];if("closed"===e._controlledReadableByteStream._state){if(0!==r)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,r){r.buffer=Ce(r.buffer);const t=e._controlledReadableByteStream;if(!0===cr(t))for(;sr(t)>0;)Wr(t,Lr(e))}(e,t)}else!function(e,r,t){if(t.bytesFilled+r>t.byteLength)throw new RangeError("bytesWritten out of range");if(kr(e,r,t),t.bytesFilled<t.elementSize)return;Lr(e);const o=t.bytesFilled%t.elementSize;if(o>0){const r=t.byteOffset+t.bytesFilled,n=t.buffer.slice(r-o,r);Br(e,n,0,n.byteLength)}t.buffer=Ce(t.buffer),t.bytesFilled-=o,Wr(e._controlledReadableByteStream,t),Dr(e)}(e,r,t);Ar(e)}function Lr(e){const r=e._pendingPullIntos.shift();return Ir(e),r}function Mr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function Vr(e,r){const t=e._controlledReadableByteStream;"readable"===t._state&&(Er(e),Fe(e),Mr(e),ar(t,r))}function Yr(e){const r=e._controlledReadableByteStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function $r(e,r,t,o,n,a,i){r._controlledReadableByteStream=e,r._pullAgain=!1,r._pulling=!1,Er(r),r._queue=r._queueTotalSize=void 0,Fe(r),r._closeRequested=!1,r._started=!1,r._strategyHWM=qe(a),r._pullAlgorithm=o,r._cancelAlgorithm=n,r._autoAllocateChunkSize=i,r._pendingPullIntos=[],e._readableStreamController=r;const s=t();Promise.resolve(s).then(()=>{r._started=!0,Ar(r)},e=>{Vr(r,e)}).catch(Be)}function Hr(e){if("object"!=typeof e||null===e)return!1;const r=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted").get;try{return r.call(e),!0}catch(e){return!1}}function Qr(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function Ur(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function xr(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}function Gr(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function Jr(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Kr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Xr(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Zr(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}var et=Ue.ReadableStream;const{createDataProperty:rt}=P;var tt=class ByteLengthQueuingStrategy{constructor({highWaterMark:e}){rt(this,"highWaterMark",e)}size(e){return e.byteLength}};const{createDataProperty:ot}=P;var nt=class CountQueuingStrategy{constructor({highWaterMark:e}){ot(this,"highWaterMark",e)}size(){return 1}};C("streams:transform-stream:verbose");const{InvokeOrNoop:at,CreateAlgorithmFromUnderlyingMethod:it,PromiseCall:st,typeIsObject:lt,ValidateAndNormalizeHighWaterMark:ct,IsNonNegativeNumber:ut,MakeSizeAlgorithmFromSizeFunction:dt}=P,{CreateReadableStream:ft,ReadableStreamDefaultControllerClose:mt,ReadableStreamDefaultControllerEnqueue:ht,ReadableStreamDefaultControllerError:_t,ReadableStreamDefaultControllerGetDesiredSize:bt,ReadableStreamDefaultControllerHasBackpressure:yt,ReadableStreamDefaultControllerCanCloseOrEnqueue:pt}=Ue,{CreateWritableStream:wt,WritableStreamDefaultControllerErrorIfNeeded:St}=L;class TransformStream{constructor(e={},r={},t={}){const o=r.size;let n=r.highWaterMark;const a=t.size;let i=t.highWaterMark;if(void 0!==e.writableType)throw new RangeError("Invalid writable type specified");const s=dt(o);if(void 0===n&&(n=1),n=ct(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");const l=dt(a);let c;void 0===i&&(i=0),i=ct(i),gt(this,new Promise(e=>{c=e}),n,s,i,l),function(e,r){const t=Object.create(TransformStreamDefaultController.prototype);let o=e=>{try{return At(t,e),Promise.resolve()}catch(e){return Promise.reject(e)}};const n=r.transform;if(void 0!==n){if("function"!=typeof n)throw new TypeError("transform is not a method");o=(e=>st(n,r,[e,t]))}const a=it(r,"flush",0,[t]);qt(e,t,o,a)}(this,e);const u=at(e,"start",[this._transformStreamController]);c(u)}get readable(){if(!1===vt(this))throw Ot("readable");return this._readable}get writable(){if(!1===vt(this))throw Ot("writable");return this._writable}}function gt(e,r,t,o,n,a){function i(){return r}e._writable=wt(i,function(r){return function(e,r){const t=e._transformStreamController;if(!0===e._backpressure){const o=e._backpressureChangePromise;return o.then(()=>{const o=e._writable,n=o._state;if("erroring"===n)throw o._storedError;return Et(t,r)})}return Et(t,r)}(e,r)},function(){return function(e){const r=e._readable,t=e._transformStreamController,o=t._flushAlgorithm();return jt(t),o.then(()=>{if("errored"===r._state)throw r._storedError;const e=r._readableStreamController;!0===pt(e)&&mt(e)}).catch(t=>{throw Pt(e,t),r._storedError})}(e)},function(r){return function(e,r){return Pt(e,r),Promise.resolve()}(e,r)},t,o),e._readable=ft(i,function(){return function(e){return Tt(e,!1),e._backpressureChangePromise}(e)},function(r){return Rt(e,r),Promise.resolve()},n,a),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Tt(e,!0),e._transformStreamController=void 0}function vt(e){return!!lt(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function Pt(e,r){_t(e._readable._readableStreamController,r),Rt(e,r)}function Rt(e,r){jt(e._transformStreamController),St(e._writable._writableStreamController,r),!0===e._backpressure&&Tt(e,!1)}function Tt(e,r){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(r=>{e._backpressureChangePromise_resolve=r}),e._backpressure=r}class TransformStreamDefaultController{constructor(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}get desiredSize(){if(!1===Ct(this))throw Wt("desiredSize");const e=this._controlledTransformStream._readable._readableStreamController;return bt(e)}enqueue(e){if(!1===Ct(this))throw Wt("enqueue");At(this,e)}error(e){if(!1===Ct(this))throw Wt("error");!function(e,r){Pt(e._controlledTransformStream,r)}(this,e)}terminate(){if(!1===Ct(this))throw Wt("terminate");!function(e){const r=e._controlledTransformStream,t=r._readable._readableStreamController;!0===pt(t)&&mt(t);const o=new TypeError("TransformStream terminated");Rt(r,o)}(this)}}function Ct(e){return!!lt(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function qt(e,r,t,o){r._controlledTransformStream=e,e._transformStreamController=r,r._transformAlgorithm=t,r._flushAlgorithm=o}function jt(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function At(e,r){const t=e._controlledTransformStream,o=t._readable._readableStreamController;if(!1===pt(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{ht(o,r)}catch(e){throw Rt(t,e),t._readable._storedError}yt(o)!==t._backpressure&&Tt(t,!0)}function Et(e,r){return e._transformAlgorithm(r).catch(r=>{throw Pt(e._controlledTransformStream,r),r})}function Wt(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function Ot(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}var Bt={CreateTransformStream:function(e,r,t,o=1,n=(()=>1),a=0,i=(()=>1)){const s=Object.create(TransformStream.prototype);let l;gt(s,new Promise(e=>{l=e}),o,n,a,i),qt(s,Object.create(TransformStreamDefaultController.prototype),r,t);const c=e();return l(c),s},TransformStream:TransformStream}.TransformStream;const zt={ReadableStream:et,WritableStream:Se,ByteLengthQueuingStrategy:tt,CountQueuingStrategy:nt,TransformStream:Bt};void 0!==n&&Object.assign(n,zt),e.ReadableStream=et,e.WritableStream=Se,e.ByteLengthQueuingStrategy=tt,e.CountQueuingStrategy=nt,e.TransformStream=Bt,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).WebStreamsPolyfill={})}(this,function(e){"use strict";const t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`;const r="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0,o=Number.isNaN||function(e){return e!=e};function n(e){return"object"==typeof e&&null!==e||"function"==typeof e}function i(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function a(e){return e.slice()}function s(e,t,r,o,n){new Uint8Array(e).set(new Uint8Array(r,o,n),t)}function l(e){return!1!==function(e){if("number"!=typeof e)return!1;if(o(e))return!1;if(e<0)return!1;return!0}(e)&&e!==1/0}function c(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function u(e,t,r,o){const n=e[t];if(void 0!==n){if("function"!=typeof n)throw new TypeError(`${n} is not a method`);switch(r){case 0:return()=>f(n,e,o);case 1:return t=>{const r=[t].concat(o);return f(n,e,r)}}}return()=>Promise.resolve()}function d(e,t,r){const o=e[t];if(void 0!==o)return c(o,e,r)}function f(e,t,r){try{return Promise.resolve(c(e,t,r))}catch(e){return Promise.reject(e)}}function _(e){return e}function h(e){if(e=Number(e),o(e)||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e}function b(e){if(void 0===e)return()=>1;if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return t=>e(t)}function m(e,t,r){return Promise.prototype.then.call(e,t,r)}function y(e,t,r){let o,n;const i=new Promise((e,t)=>{o=e,n=t});void 0===r&&(r=(e=>{throw e}));return function(e,t,r){let o=!1;const n=e=>{!1===o&&(o=!0,r(e))};let i=0,a=0;const s=e.length,l=new Array(s);for(const r of e){const e=i;m(r,r=>{l[e]=r,++a===s&&t(l)},n),++i}}(e,e=>{try{const r=t(e);o(r)}catch(e){n(e)}},e=>{try{const t=r(e);o(t)}catch(e){n(e)}}),i}function p(e){}function w(e){e&&e instanceof p.AssertionError&&setTimeout(()=>{throw e},0)}function g(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function S(e,t,r){if(!l(r=Number(r)))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function v(e){e._queue=[],e._queueTotalSize=0}p.AssertionError=function(){};const R=t("[[AbortSteps]]"),P=t("[[ErrorSteps]]");class WritableStream{constructor(e={},t={}){q(this);const r=t.size;let o=t.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");const n=b(r);void 0===o&&(o=1),function(e,t,r,o){const n=Object.create(WritableStreamDefaultController.prototype);const i=u(t,"write",1,[n]),a=u(t,"close",0,[]),s=u(t,"abort",1,[]);$(e,n,function(){return d(t,"start",[n])},i,a,s,r,o)}(this,e,o=h(o),n)}get locked(){if(!1===E(this))throw G("locked");return C(this)}abort(e){return!1===E(this)?Promise.reject(G("abort")):!0===C(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):j(this,e)}getWriter(){if(!1===E(this))throw G("getWriter");return T(this)}}function T(e){return new WritableStreamDefaultWriter(e)}function q(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=[],e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function E(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function C(e){return void 0!==e._writer}function j(e,t){const r=e._state;if("closed"===r||"errored"===r)return Promise.resolve(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===r&&(o=!0,t=void 0);const n=new Promise((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&W(e,t),n}function A(e,t){"writable"!==e._state?B(e):W(e,t)}function W(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const o=e._writer;void 0!==o&&D(o,t),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===r._started&&B(e)}function B(e){e._state="errored",e._writableStreamController[P]();const t=e._storedError;for(const r of e._writeRequests)r._reject(t);if(e._writeRequests=[],void 0===e._pendingAbortRequest)return void z(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===r._wasAlreadyErroring)return r._reject(t),void z(e);e._writableStreamController[R](r._reason).then(()=>{r._resolve(),z(e)},t=>{r._reject(t),z(e)})}function O(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function z(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&ee(t,e._storedError)}function k(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(!0===t?function(e){re(e)}(r):ae(r)),e._backpressure=t}class WritableStreamDefaultWriter{constructor(e){if(!1===E(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===C(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!1===O(e)&&!0===e._backpressure?re(this):ne(this),X(this);else if("erroring"===t)oe(this,e._storedError),X(this);else if("closed"===t)ne(this),function(e){X(e),te(e)}(this);else{const t=e._storedError;oe(this,t),Z(this,t)}}get closed(){return!1===F(this)?Promise.reject(J("closed")):this._closedPromise}get desiredSize(){if(!1===F(this))throw J("desiredSize");if(void 0===this._ownerWritableStream)throw K("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return Q(t._writableStreamController)}(this)}get ready(){return!1===F(this)?Promise.reject(J("ready")):this._readyPromise}abort(e){return!1===F(this)?Promise.reject(J("abort")):void 0===this._ownerWritableStream?Promise.reject(K("abort")):function(e,t){return j(e._ownerWritableStream,t)}(this,e)}close(){if(!1===F(this))return Promise.reject(J("close"));const e=this._ownerWritableStream;return void 0===e?Promise.reject(K("close")):!0===O(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):L(this)}releaseLock(){if(!1===F(this))throw J("releaseLock");void 0!==this._ownerWritableStream&&M(this)}write(e){return!1===F(this)?Promise.reject(J("write")):void 0===this._ownerWritableStream?Promise.reject(K("write to")):Y(this,e)}}function F(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function L(e){const t=e._ownerWritableStream,r=t._state;if("closed"===r||"errored"===r)return Promise.reject(new TypeError(`The stream (in ${r} state) is not in the writable state and cannot be closed`));const o=new Promise((e,r)=>{const o={_resolve:e,_reject:r};t._closeRequest=o});return!0===t._backpressure&&"writable"===r&&ae(e),function(e){S(e,"close",0),x(e)}(t._writableStreamController),o}function I(e,t){"pending"===e._closedPromiseState?ee(e,t):function(e,t){Z(e,t)}(e,t)}function D(e,t){"pending"===e._readyPromiseState?ie(e,t):function(e,t){oe(e,t)}(e,t)}function M(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");D(e,r),I(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Y(e,t){const r=e._ownerWritableStream,o=r._writableStreamController,n=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return H(e,t),1}}(o,t);if(r!==e._ownerWritableStream)return Promise.reject(K("write to"));const i=r._state;if("errored"===i)return Promise.reject(r._storedError);if(!0===O(r)||"closed"===i)return Promise.reject(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return Promise.reject(r._storedError);const a=function(e){return new Promise((t,r)=>{const o={_resolve:t,_reject:r};e._writeRequests.push(o)})}(r);return function(e,t,r){const o={chunk:t};try{S(e,o,r)}catch(t){return void H(e,t)}const n=e._controlledWritableStream;if(!1===O(n)&&"writable"===n._state){const t=U(e);k(n,t)}x(e)}(o,t,n),a}class WritableStreamDefaultController{constructor(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}error(e){if(!1===function(e){if(!n(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&V(this,e)}[R](e){const t=this._abortAlgorithm(e);return N(this),t}[P](){v(this)}}function $(e,t,r,o,n,i,a,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,v(t),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._writeAlgorithm=o,t._closeAlgorithm=n,t._abortAlgorithm=i;const l=U(t);k(e,l);const c=r();Promise.resolve(c).then(()=>{t._started=!0,x(t)},r=>{t._started=!0,A(e,r)}).catch(w)}function N(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Q(e){return e._strategyHWM-e._queueTotalSize}function x(e){const t=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==t._inFlightWriteRequest)return;const r=t._state;if("closed"===r||"errored"===r)return;if("erroring"===r)return void B(t);if(0===e._queue.length)return;const o=function(e){return e._queue[0].value}(e);"close"===o?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),g(e);const r=e._closeAlgorithm();N(e),r.then(()=>{!function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&te(t)}(t)},e=>{!function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),A(e,t)}(t,e)}).catch(w)}(e):function(e,t){const r=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(r),e._writeAlgorithm(t).then(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(g(e),!1===O(r)&&"writable"===t){const t=U(e);k(r,t)}x(e)},t=>{"writable"===r._state&&N(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,A(e,t)}(r,t)}).catch(w)}(e,o.chunk)}function H(e,t){"writable"===e._controlledWritableStream._state&&V(e,t)}function U(e){return Q(e)<=0}function V(e,t){const r=e._controlledWritableStream;N(e),W(r,t)}function G(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function J(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function K(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function X(e){e._closedPromise=new Promise((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function Z(e,t){X(e),ee(e,t)}function ee(e,t){e._closedPromise.catch(()=>{}),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function te(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}function re(e){e._readyPromise=new Promise((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function oe(e,t){re(e),ie(e,t)}function ne(e){re(e),ae(e)}function ie(e,t){e._readyPromise.catch(()=>{}),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function ae(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}const se=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},le=t("[[CancelSteps]]"),ce=t("[[PullSteps]]");class ReadableStream{constructor(e={},t={}){fe(this);const r=t.size;let o=t.highWaterMark;const n=e.type;if("bytes"===String(n)){if(void 0!==r)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===o&&(o=0),function(e,t,r){const o=Object.create(ReadableByteStreamController.prototype);const n=u(t,"pull",0,[o]),i=u(t,"cancel",1,[]);let a=t.autoAllocateChunkSize;if(void 0!==a&&(a=Number(a),!1===se(a)||a<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");!function(e,t,r,o,n,i,a){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,He(t),t._queue=t._queueTotalSize=void 0,v(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=h(i),t._pullAlgorithm=o,t._cancelAlgorithm=n,t._autoAllocateChunkSize=a,t._pendingPullIntos=[],e._readableStreamController=t;const s=r();Promise.resolve(s).then(()=>{t._started=!0,xe(t)},e=>{nt(t,e)}).catch(w)}(e,o,function(){return d(t,"start",[o])},n,i,r,a)}(this,e,o=h(o))}else{if(void 0!==n)throw new RangeError("Invalid type is specified");{const t=b(r);void 0===o&&(o=1),function(e,t,r,o){const n=Object.create(ReadableStreamDefaultController.prototype);const i=u(t,"pull",0,[n]),a=u(t,"cancel",1,[]);$e(e,n,function(){return d(t,"start",[n])},i,a,r,o)}(this,e,o=h(o),t)}}}get locked(){if(!1===_e(this))throw st("locked");return he(this)}cancel(e){return!1===_e(this)?Promise.reject(st("cancel")):!0===he(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):pe(this,e)}getReader({mode:e}={}){if(!1===_e(this))throw st("getReader");if(void 0===e)return ue(this);if("byob"===(e=String(e)))return function(e){return new ReadableStreamBYOBReader(e)}(this);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:t},{preventClose:r,preventAbort:o,preventCancel:n,signal:i}={}){if(!1===_e(this))throw st("pipeThrough");if(!1===E(e))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===_e(t))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(r=Boolean(r),o=Boolean(o),n=Boolean(n),void 0!==i&&!at(i))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===he(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===C(e))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return be(this,e,r,o,n,i).catch(()=>{}),t}pipeTo(e,{preventClose:t,preventAbort:r,preventCancel:o,signal:n}={}){return!1===_e(this)?Promise.reject(st("pipeTo")):!1===E(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream")):(t=Boolean(t),r=Boolean(r),o=Boolean(o),void 0===n||at(n)?!0===he(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===C(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):be(this,e,t,r,o,n):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))}tee(){if(!1===_e(this))throw st("tee");const e=function(e,t){const r=ue(e);let o,n,i,s,l,c=!1,u=!1,d=!1;const f=new Promise(e=>{l=e});function _(){return Be(r).then(e=>{const t=e.value,r=e.done;if(!0===r&&!1===c&&(!1===u&&Le(i._readableStreamController),!1===d&&Le(s._readableStreamController),c=!0),!0===c)return;const o=t,n=t;!1===u&&Ie(i._readableStreamController,o),!1===d&&Ie(s._readableStreamController,n)})}function h(){}return i=de(h,_,function(t){if(u=!0,o=t,!0===d){const t=a([o,n]),r=pe(e,t);l(r)}return f}),s=de(h,_,function(t){if(d=!0,n=t,!0===u){const t=a([o,n]),r=pe(e,t);l(r)}return f}),r._closedPromise.catch(e=>{!0!==c&&(De(i._readableStreamController,e),De(s._readableStreamController,e),c=!0)}),[i,s]}(this);return a(e)}}function ue(e){return new ReadableStreamDefaultReader(e)}function de(e,t,r,o=1,n=(()=>1)){const i=Object.create(ReadableStream.prototype);return fe(i),$e(i,Object.create(ReadableStreamDefaultController.prototype),e,t,r,o,n),i}function fe(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function _e(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function he(e){return void 0!==e._reader}function be(e,t,r,o,n,i){const a=ue(e),s=T(t);let l=!1,c=Promise.resolve();return new Promise((u,d)=>{let f;if(void 0!==i){if(f=(()=>{const r=new DOMException("Aborted","AbortError"),i=[];!1===o&&i.push(()=>"writable"===t._state?j(t,r):Promise.resolve()),!1===n&&i.push(()=>"readable"===e._state?pe(e,r):Promise.resolve()),b(()=>y(i.map(e=>e()),e=>e),!0,r)}),!0===i.aborted)return void f();i.addEventListener("abort",f)}if(h(e,a._closedPromise,e=>{!1===o?b(()=>j(t,e),!0,e):m(!0,e)}),h(t,s._closedPromise,t=>{!1===n?b(()=>pe(e,t),!0,t):m(!0,t)}),function(e,t,r){"closed"===e._state?r():t.then(r).catch(w)}(e,a._closedPromise,()=>{!1===r?b(()=>(function(e){const t=e._ownerWritableStream,r=t._state;return!0===O(t)||"closed"===r?Promise.resolve():"errored"===r?Promise.reject(t._storedError):L(e)})(s)):m()}),!0===O(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");!1===n?b(()=>pe(e,t),!0,t):m(!0,t)}function _(){const e=c;return c.then(()=>e!==c?_():void 0)}function h(e,t,r){"errored"===e._state?r(e._storedError):t.catch(r).catch(w)}function b(e,r,o){function n(){e().then(()=>p(r,o),e=>p(!0,e)).catch(w)}!0!==l&&(l=!0,"writable"===t._state&&!1===O(t)?_().then(n):n())}function m(e,r){!0!==l&&(l=!0,"writable"===t._state&&!1===O(t)?_().then(()=>p(e,r)).catch(w):p(e,r))}function p(e,t){M(s),We(a),void 0!==i&&i.removeEventListener("abort",f),e?d(t):u(void 0)}new Promise((e,t)=>{!function r(o){o?e():(!0===l?Promise.resolve(!0):s._readyPromise.then(()=>Be(a).then(({value:e,done:t})=>!0===t||(c=Y(s,e).catch(()=>{}),!1)))).then(r,t)}(!1)}).catch(e=>{c=Promise.resolve(),w(e)})})}function me(e,t){return new Promise((r,o)=>{const n={_resolve:r,_reject:o,_forAuthorCode:t};e._reader._readIntoRequests.push(n)})}function ye(e,t){return new Promise((r,o)=>{const n={_resolve:r,_reject:o,_forAuthorCode:t};e._reader._readRequests.push(n)})}function pe(e,t){if(e._disturbed=!0,"closed"===e._state)return Promise.resolve(void 0);if("errored"===e._state)return Promise.reject(e._storedError);return we(e),e._readableStreamController[le](t).then(()=>void 0)}function we(e){e._state="closed";const t=e._reader;if(void 0!==t){if(Ce(t)){for(const{_resolve:e,_forAuthorCode:r}of t._readRequests)e(ge(void 0,!0,r));t._readRequests=[]}_t(t)}}function ge(e,t,r){let o=null;!0===r&&(o=Object.prototype);const n=Object.create(o);return Object.defineProperty(n,"value",{value:e,enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(n,"done",{value:t,enumerable:!0,writable:!0,configurable:!0}),n}function Se(e,t){e._state="errored",e._storedError=t;const r=e._reader;if(void 0!==r){if(Ce(r)){for(const e of r._readRequests)e._reject(t);r._readRequests=[]}else{for(const e of r._readIntoRequests)e._reject(t);r._readIntoRequests=[]}ft(r,t)}}function ve(e,t,r){const o=e._reader._readRequests.shift();o._resolve(ge(t,r,o._forAuthorCode))}function Re(e){return e._reader._readIntoRequests.length}function Pe(e){return e._reader._readRequests.length}function Te(e){const t=e._reader;return void 0!==t&&!!Ee(t)}function qe(e){const t=e._reader;return void 0!==t&&!!Ce(t)}class ReadableStreamDefaultReader{constructor(e){if(!1===_e(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===he(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");je(this,e),this._readRequests=[]}get closed(){return Ce(this)?this._closedPromise:Promise.reject(ct("closed"))}cancel(e){return Ce(this)?void 0===this._ownerReadableStream?Promise.reject(lt("cancel")):Ae(this,e):Promise.reject(ct("cancel"))}read(){return Ce(this)?void 0===this._ownerReadableStream?Promise.reject(lt("read from")):Be(this,!0):Promise.reject(ct("read"))}releaseLock(){if(!Ce(this))throw ct("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");We(this)}}}class ReadableStreamBYOBReader{constructor(e){if(!_e(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===Ne(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(he(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");je(this,e),this._readIntoRequests=[]}get closed(){return Ee(this)?this._closedPromise:Promise.reject(ht("closed"))}cancel(e){return Ee(this)?void 0===this._ownerReadableStream?Promise.reject(lt("cancel")):Ae(this,e):Promise.reject(ht("cancel"))}read(e){return Ee(this)?void 0===this._ownerReadableStream?Promise.reject(lt("read from")):ArrayBuffer.isView(e)?(e.buffer,0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,t,r=!1){const o=e._ownerReadableStream;if(o._disturbed=!0,"errored"===o._state)return Promise.reject(o._storedError);return function(e,t,r){const o=e._controlledReadableByteStream;let n=1;t.constructor!==DataView&&(n=t.constructor.BYTES_PER_ELEMENT);const i=t.constructor,a={buffer:_(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:n,ctor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(a),me(o,r);if("closed"===o._state){const e=new i(a.buffer,a.byteOffset,0);return Promise.resolve(ge(e,!0,r))}if(e._queueTotalSize>0){if(!0===Je(e,a)){const t=Ve(a);return Xe(e),Promise.resolve(ge(t,!1,r))}if(!0===e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return nt(e,t),Promise.reject(t)}}e._pendingPullIntos.push(a);const s=me(o,r);return xe(e),s}(o._readableStreamController,t,r)}(this,e,!0)):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(ht("read"))}releaseLock(){if(!Ee(this))throw ht("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");We(this)}}}function Ee(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Ce(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function je(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?ut(e):"closed"===t._state?function(e){ut(e),_t(e)}(e):dt(e,t._storedError)}function Ae(e,t){return pe(e._ownerReadableStream,t)}function We(e){"readable"===e._ownerReadableStream._state?ft(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){dt(e,t)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function Be(e,t=!1){const r=e._ownerReadableStream;return r._disturbed=!0,"closed"===r._state?Promise.resolve(ge(void 0,!0,t)):"errored"===r._state?Promise.reject(r._storedError):r._readableStreamController[ce](t)}class ReadableStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){if(!1===Oe(this))throw bt("desiredSize");return Me(this)}close(){if(!1===Oe(this))throw bt("close");if(!1===Ye(this))throw new TypeError("The stream is not in a state that permits close");Le(this)}enqueue(e){if(!1===Oe(this))throw bt("enqueue");if(!1===Ye(this))throw new TypeError("The stream is not in a state that permits enqueue");return Ie(this,e)}error(e){if(!1===Oe(this))throw bt("error");De(this,e)}[le](e){v(this);const t=this._cancelAlgorithm(e);return Fe(this),t}[ce](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=g(this);return!0===this._closeRequested&&0===this._queue.length?(Fe(this),we(t)):ze(this),Promise.resolve(ge(r,!1,e))}const r=ye(t,e);return ze(this),r}}function Oe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function ze(e){!1!==ke(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{if(e._pulling=!1,!0===e._pullAgain)return e._pullAgain=!1,ze(e)},t=>{De(e,t)}).catch(w)):e._pullAgain=!0)}function ke(e){const t=e._controlledReadableStream;return!1!==Ye(e)&&(!1!==e._started&&(!0===he(t)&&Pe(t)>0||Me(e)>0))}function Fe(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Le(e){const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Fe(e),we(t))}function Ie(e,t){const r=e._controlledReadableStream;if(!0===he(r)&&Pe(r)>0)ve(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw De(e,t),t}try{S(e,t,r)}catch(t){throw De(e,t),t}}ze(e)}function De(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(v(e),Fe(e),Se(r,t))}function Me(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ye(e){const t=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===t}function $e(e,t,r,o,n,i,a){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,v(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=a,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=n,e._readableStreamController=t;const s=r();Promise.resolve(s).then(()=>{t._started=!0,ze(t)},e=>{De(t,e)}).catch(w)}class ReadableStreamBYOBRequest{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===Qe(this))throw mt("view");return this._view}respond(e){if(!1===Qe(this))throw mt("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,function(e,t){if(!1===l(t=Number(t)))throw new RangeError("bytesWritten must be a finite");tt(e,t)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===Qe(this))throw mt("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");e.buffer,function(e,t){const r=e._pendingPullIntos[0];if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.byteLength!==t.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");r.buffer=t.buffer,tt(e,t.byteLength)}(this._associatedReadableByteStreamController,e)}}class ReadableByteStreamController{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===Ne(this))throw yt("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos[0],t=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),r=Object.create(ReadableStreamBYOBRequest.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(r,this,t),this._byobRequest=r}return this._byobRequest}get desiredSize(){if(!1===Ne(this))throw yt("desiredSize");return it(this)}close(){if(!1===Ne(this))throw yt("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const t=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos[0];if(t.bytesFilled>0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw nt(e,t),t}}ot(e),we(t)}(this)}enqueue(e){if(!1===Ne(this))throw yt("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");e.buffer,function(e,t){const r=e._controlledReadableByteStream,o=t.buffer,n=t.byteOffset,i=t.byteLength,a=_(o);if(!0===qe(r))if(0===Pe(r))Ge(e,a,n,i);else{const e=new Uint8Array(a,n,i);ve(r,e,!1)}else!0===Te(r)?(Ge(e,a,n,i),et(e)):Ge(e,a,n,i);xe(e)}(this,e)}error(e){if(!1===Ne(this))throw yt("error");nt(this,e)}[le](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos[0].bytesFilled=0}v(this);const t=this._cancelAlgorithm(e);return ot(this),t}[ce](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0){const t=this._queue.shift();let r;this._queueTotalSize-=t.byteLength,Xe(this);try{r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(ge(r,!1,e))}const r=this._autoAllocateChunkSize;if(void 0!==r){let e;try{e=new ArrayBuffer(r)}catch(e){return Promise.reject(e)}const t={buffer:e,byteOffset:0,byteLength:r,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(t)}const o=ye(t,e);return xe(this),o}}function Ne(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function Qe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function xe(e){!1!==function(e){const t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===qe(t)&&Pe(t)>0)return!0;if(!0===Te(t)&&Re(t)>0)return!0;if(it(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,xe(e))},t=>{nt(e,t)}).catch(w)):e._pullAgain=!0)}function He(e){Ze(e),e._pendingPullIntos=[]}function Ue(e,t){let r=!1;"closed"===e._state&&(r=!0);const o=Ve(t);"default"===t.readerType?ve(e,o,r):function(e,t,r){const o=e._reader._readIntoRequests.shift();o._resolve(ge(t,r,o._forAuthorCode))}(e,o,r)}function Ve(e){const t=e.bytesFilled,r=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,t/r)}function Ge(e,t,r,o){e._queue.push({buffer:t,byteOffset:r,byteLength:o}),e._queueTotalSize+=o}function Je(e,t){const r=t.elementSize,o=t.bytesFilled-t.bytesFilled%r,n=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),i=t.bytesFilled+n,a=i-i%r;let l=n,c=!1;a>o&&(l=a-t.bytesFilled,c=!0);const u=e._queue;for(;l>0;){const r=u[0],o=Math.min(l,r.byteLength),n=t.byteOffset+t.bytesFilled;s(t.buffer,n,r.buffer,r.byteOffset,o),r.byteLength===o?u.shift():(r.byteOffset+=o,r.byteLength-=o),e._queueTotalSize-=o,Ke(e,o,t),l-=o}return c}function Ke(e,t,r){Ze(e),r.bytesFilled+=t}function Xe(e){0===e._queueTotalSize&&!0===e._closeRequested?(ot(e),we(e._controlledReadableByteStream)):xe(e)}function Ze(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function et(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos[0];!0===Je(e,t)&&(rt(e),Ue(e._controlledReadableByteStream,t))}}function tt(e,t){const r=e._pendingPullIntos[0];if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,t){t.buffer=_(t.buffer);const r=e._controlledReadableByteStream;if(!0===Te(r))for(;Re(r)>0;)Ue(r,rt(e))}(e,r)}else!function(e,t,r){if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range");if(Ke(e,t,r),r.bytesFilled<r.elementSize)return;rt(e);const o=r.bytesFilled%r.elementSize;if(o>0){const t=r.byteOffset+r.bytesFilled,n=r.buffer.slice(t-o,t);Ge(e,n,0,n.byteLength)}r.buffer=_(r.buffer),r.bytesFilled-=o,Ue(e._controlledReadableByteStream,r),et(e)}(e,t,r);xe(e)}function rt(e){const t=e._pendingPullIntos.shift();return Ze(e),t}function ot(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function nt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(He(e),v(e),ot(e),Se(r,t))}function it(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function at(e){if("object"!=typeof e||null===e)return!1;const t=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted").get;try{return t.call(e),!0}catch(e){return!1}}function st(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function lt(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function ct(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}function ut(e){e._closedPromise=new Promise((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function dt(e,t){ut(e),ft(e,t)}function ft(e,t){e._closedPromise.catch(()=>{}),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function _t(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function ht(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function bt(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function mt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function yt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}class ByteLengthQueuingStrategy{constructor({highWaterMark:e}){i(this,"highWaterMark",e)}size(e){return e.byteLength}}class CountQueuingStrategy{constructor({highWaterMark:e}){i(this,"highWaterMark",e)}size(){return 1}}class TransformStream{constructor(e={},t={},r={}){const o=t.size;let n=t.highWaterMark;const i=r.size;let a=r.highWaterMark;if(void 0!==e.writableType)throw new RangeError("Invalid writable type specified");const s=b(o);if(void 0===n&&(n=1),n=h(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");const l=b(i);let c;void 0===a&&(a=0),a=h(a),function(e,t,r,o,n,i){function a(){return t}e._writable=function(e,t,r,o,n=1,i=(()=>1)){const a=Object.create(WritableStream.prototype);return q(a),$(a,Object.create(WritableStreamDefaultController.prototype),e,t,r,o,n,i),a}(a,function(t){return function(e,t){const r=e._transformStreamController;if(!0===e._backpressure){const o=e._backpressureChangePromise;return o.then(()=>{const o=e._writable,n=o._state;if("erroring"===n)throw o._storedError;return Tt(r,t)})}return Tt(r,t)}(e,t)},function(){return function(e){const t=e._readable,r=e._transformStreamController,o=r._flushAlgorithm();return Rt(r),o.then(()=>{if("errored"===t._state)throw t._storedError;const e=t._readableStreamController;!0===Ye(e)&&Le(e)}).catch(r=>{throw wt(e,r),t._storedError})}(e)},function(t){return function(e,t){return wt(e,t),Promise.resolve()}(e,t)},r,o),e._readable=de(a,function(){return function(e){return St(e,!1),e._backpressureChangePromise}(e)},function(t){return gt(e,t),Promise.resolve()},n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,St(e,!0),e._transformStreamController=void 0}(this,new Promise(e=>{c=e}),n,s,a,l),function(e,t){const r=Object.create(TransformStreamDefaultController.prototype);let o=e=>{try{return Pt(r,e),Promise.resolve()}catch(e){return Promise.reject(e)}};const n=t.transform;if(void 0!==n){if("function"!=typeof n)throw new TypeError("transform is not a method");o=(e=>f(n,t,[e,r]))}const i=u(t,"flush",0,[r]);!function(e,t,r,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=o}(e,r,o,i)}(this,e);const _=d(e,"start",[this._transformStreamController]);c(_)}get readable(){if(!1===pt(this))throw Et("readable");return this._readable}get writable(){if(!1===pt(this))throw Et("writable");return this._writable}}function pt(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function wt(e,t){De(e._readable._readableStreamController,t),gt(e,t)}function gt(e,t){Rt(e._transformStreamController),H(e._writable._writableStreamController,t),!0===e._backpressure&&St(e,!1)}function St(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}class TransformStreamDefaultController{constructor(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}get desiredSize(){if(!1===vt(this))throw qt("desiredSize");return Me(this._controlledTransformStream._readable._readableStreamController)}enqueue(e){if(!1===vt(this))throw qt("enqueue");Pt(this,e)}error(e){if(!1===vt(this))throw qt("error");!function(e,t){wt(e._controlledTransformStream,t)}(this,e)}terminate(){if(!1===vt(this))throw qt("terminate");!function(e){const t=e._controlledTransformStream,r=t._readable._readableStreamController;!0===Ye(r)&&Le(r);const o=new TypeError("TransformStream terminated");gt(t,o)}(this)}}function vt(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function Rt(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Pt(e,t){const r=e._controlledTransformStream,o=r._readable._readableStreamController;if(!1===Ye(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{Ie(o,t)}catch(e){throw gt(r,e),r._readable._storedError}(function(e){return!0!==ke(e)})(o)!==r._backpressure&&St(r,!0)}function Tt(e,t){return e._transformAlgorithm(t).catch(t=>{throw wt(e._controlledTransformStream,t),t})}function qt(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function Et(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}const Ct={ReadableStream:ReadableStream,WritableStream:WritableStream,ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,CountQueuingStrategy:CountQueuingStrategy,TransformStream:TransformStream};void 0!==r&&Object.assign(r,Ct),e.ReadableStream=ReadableStream,e.WritableStream=WritableStream,e.ByteLengthQueuingStrategy=ByteLengthQueuingStrategy,e.CountQueuingStrategy=CountQueuingStrategy,e.TransformStream=TransformStream,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=polyfill.es6.min.js.map

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).WebStreamsPolyfill={})}(this,function(e){"use strict";function r(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function t(e,t,o){return t&&r(e.prototype,t),o&&r(e,o),e}function o(){return(o=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:function(e){return"Symbol("+e+")"},i=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function a(){}var s="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0,l={default:a},u=Number.isNaN||function(e){return e!=e};function c(e){return e&&e.default||e}c(l);var d=function(e,r){return e(r={exports:{}},r.exports),r.exports}(function(e,r){var t=n('is "detached" for our purposes');function o(e,r,t){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,r,t)}function i(e,r,t){try{return Promise.resolve(o(e,r,t))}catch(e){return Promise.reject(e)}}r.typeIsObject=function(e){return"object"==typeof e&&null!==e||"function"==typeof e},r.createDataProperty=function(e,r,t){Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})},r.createArrayFromList=function(e){return e.slice()},r.ArrayBufferCopy=function(e,r,t,o,n){new Uint8Array(e).set(new Uint8Array(t,o,n),r)},r.IsFiniteNonNegativeNumber=function(e){return!1!==r.IsNonNegativeNumber(e)&&e!==1/0},r.IsNonNegativeNumber=function(e){return"number"==typeof e&&(!u(e)&&!(e<0))},r.Call=o,r.CreateAlgorithmFromUnderlyingMethod=function(e,r,t,o){var n=e[r];if(void 0!==n){if("function"!=typeof n)throw new TypeError(n+" is not a method");switch(t){case 0:return function(){return i(n,e,o)};case 1:return function(r){var t=[r].concat(o);return i(n,e,t)}}}return function(){return Promise.resolve()}},r.InvokeOrNoop=function(e,r,t){var n=e[r];if(void 0!==n)return o(n,e,t)},r.PromiseCall=i,r.TransferArrayBuffer=function(e){var r=e.slice();return Object.defineProperty(e,"byteLength",{get:function(){return 0}}),e[t]=!0,r},r.IsDetachedBuffer=function(e){return t in e},r.ValidateAndNormalizeHighWaterMark=function(e){if(e=Number(e),u(e)||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e},r.MakeSizeAlgorithmFromSizeFunction=function(e){if(void 0===e)return function(){return 1};if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return function(r){return e(r)}},r.PerformPromiseThen=function(e,r,t){return Promise.prototype.then.call(e,r,t)},r.WaitForAll=function(e,t,o){for(var n=!1,i=function(e){!1===n&&(n=!0,o(e))},a=0,s=0,l=e.length,u=new Array(l),c=function(o){var n=e[o],c=a;r.PerformPromiseThen(n,function(e){u[c]=e,++s===l&&t(u)},i),++a},d=0;d<e.length;d++)c(d)},r.WaitForAllPromise=function(e,t,o){var n,i;void 0===o&&(o=void 0);var a=new Promise(function(e,r){n=e,i=r});void 0===o&&(o=function(e){throw e});return r.WaitForAll(e,function(e){try{var r=t(e);n(r)}catch(e){i(e)}},function(e){try{var r=o(e);n(r)}catch(e){i(e)}}),a}}),f=d.typeIsObject,m=d.createDataProperty,h=d.createArrayFromList,_=d.ArrayBufferCopy,b=d.IsFiniteNonNegativeNumber,v=d.IsNonNegativeNumber,y=d.Call,p=d.CreateAlgorithmFromUnderlyingMethod,w=d.InvokeOrNoop,g=d.PromiseCall;d.TransferArrayBuffer,d.IsDetachedBuffer;var S={TransferArrayBuffer:function(e){return e},IsDetachedBuffer:function(e){return!1},typeIsObject:f,createDataProperty:m,createArrayFromList:h,ArrayBufferCopy:_,IsFiniteNonNegativeNumber:b,IsNonNegativeNumber:v,Call:y,CreateAlgorithmFromUnderlyingMethod:p,InvokeOrNoop:w,PromiseCall:g,ValidateAndNormalizeHighWaterMark:d.ValidateAndNormalizeHighWaterMark,MakeSizeAlgorithmFromSizeFunction:d.MakeSizeAlgorithmFromSizeFunction,PerformPromiseThen:d.PerformPromiseThen,WaitForAll:d.WaitForAll,WaitForAllPromise:d.WaitForAllPromise};function P(){}P.AssertionError=a;var R=c({default:P}),T=function(e){e&&e instanceof R.AssertionError&&setTimeout(function(){throw e},0)},q=c(S),C=q.IsFiniteNonNegativeNumber,j=function(e){var r=e._queue.shift();return e._queueTotalSize-=r.size,e._queueTotalSize<0&&(e._queueTotalSize=0),r.value},A=function(e,r,t){if(t=Number(t),!C(t))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:r,size:t}),e._queueTotalSize+=t},E=function(e){return e._queue[0].value},W=function(e){e._queue=[],e._queueTotalSize=0},O=c({default:a}),k=(O("streams:writable-stream:verbose"),q.CreateAlgorithmFromUnderlyingMethod),z=q.InvokeOrNoop,B=q.ValidateAndNormalizeHighWaterMark,F=(q.IsNonNegativeNumber,q.MakeSizeAlgorithmFromSizeFunction),I=q.typeIsObject,N=T,D=j,M=A,L=E,H=W,Y=n("[[AbortSteps]]"),U=n("[[ErrorSteps]]"),x=function(){function e(e,r){void 0===e&&(e={}),void 0===r&&(r={}),G(this);var t=r.size,o=r.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");var n=F(t);void 0===o&&(o=1),function(e,r,t,o){var n=Object.create(fe.prototype);var i=k(r,"write",1,[n]),a=k(r,"close",0,[]),s=k(r,"abort",1,[]);me(e,n,function(){return z(r,"start",[n])},i,a,s,t,o)}(this,e,o=B(o),n)}var r=e.prototype;return r.abort=function(e){return!1===J(this)?Promise.reject(we("abort")):!0===K(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):X(this,e)},r.getWriter=function(){if(!1===J(this))throw we("getWriter");return Q(this)},t(e,[{key:"locked",get:function(){if(!1===J(this))throw we("locked");return K(this)}}]),e}(),V={AcquireWritableStreamDefaultWriter:Q,CreateWritableStream:function(e,r,t,o,n,i){void 0===n&&(n=1);void 0===i&&(i=function(){return 1});var a=Object.create(x.prototype);G(a);var s=Object.create(fe.prototype);return me(a,s,e,r,t,o,n,i),a},IsWritableStream:J,IsWritableStreamLocked:K,WritableStream:x,WritableStreamAbort:X,WritableStreamDefaultControllerErrorIfNeeded:ve,WritableStreamDefaultWriterCloseWithErrorPropagation:function(e){var r=e._ownerWritableStream,t=r._state;if(!0===te(r)||"closed"===t)return Promise.resolve();if("errored"===t)return Promise.reject(r._storedError);return se(e)},WritableStreamDefaultWriterRelease:ce,WritableStreamDefaultWriterWrite:de,WritableStreamCloseQueuedOrInFlight:te};function Q(e){return new ie(e)}function G(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=[],e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function J(e){return!!I(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function K(e){return void 0!==e._writer}function X(e,r){var t=e._state;if("closed"===t||"errored"===t)return Promise.resolve(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;var o=!1;"erroring"===t&&(o=!0,r=void 0);var n=new Promise(function(t,n){e._pendingAbortRequest={_resolve:t,_reject:n,_reason:r,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&$(e,r),n}function Z(e,r){"writable"!==e._state?ee(e):$(e,r)}function $(e,r){var t=e._writableStreamController;e._state="erroring",e._storedError=r;var o=e._writer;void 0!==o&&ue(o,r),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===t._started&&ee(e)}function ee(e){e._state="errored",e._writableStreamController[U]();for(var r=e._storedError,t=0,o=e._writeRequests;t<o.length;t++){o[t]._reject(r)}if(e._writeRequests=[],void 0!==e._pendingAbortRequest){var n=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===n._wasAlreadyErroring)return n._reject(r),void oe(e);e._writableStreamController[Y](n._reason).then(function(){n._resolve(),oe(e)},function(r){n._reject(r),oe(e)})}else oe(e)}function re(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";var r=e._writer;void 0!==r&&function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(r)}function te(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function oe(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);var r=e._writer;void 0!==r&&(Re(r,e._storedError),r._closedPromise.catch(function(){}))}function ne(e,r){var t=e._writer;void 0!==t&&r!==e._backpressure&&(!0===r?function(e){e._readyPromise=new Promise(function(r,t){e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(t):Ce(t)),e._backpressure=r}var ie=function(){function e(e){if(!1===J(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===K(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;var r=e._state;if("writable"===r)!1===te(e)&&!0===e._backpressure?function(e){e._readyPromise=new Promise(function(r,t){e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(this):qe(this),Pe(this);else if("erroring"===r)Te(this,e._storedError),this._readyPromise.catch(function(){}),Pe(this);else if("closed"===r)qe(this),function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(this);else{var t=e._storedError;Te(this,t),this._readyPromise.catch(function(){}),function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}(this,t),this._closedPromise.catch(function(){})}}var r=e.prototype;return r.abort=function(e){return!1===ae(this)?Promise.reject(ge("abort")):void 0===this._ownerWritableStream?Promise.reject(Se("abort")):function(e,r){return X(e._ownerWritableStream,r)}(this,e)},r.close=function(){if(!1===ae(this))return Promise.reject(ge("close"));var e=this._ownerWritableStream;return void 0===e?Promise.reject(Se("close")):!0===te(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):se(this)},r.releaseLock=function(){if(!1===ae(this))throw ge("releaseLock");void 0!==this._ownerWritableStream&&ce(this)},r.write=function(e){return!1===ae(this)?Promise.reject(ge("write")):void 0===this._ownerWritableStream?Promise.reject(Se("write to")):de(this,e)},t(e,[{key:"closed",get:function(){return!1===ae(this)?Promise.reject(ge("closed")):this._closedPromise}},{key:"desiredSize",get:function(){if(!1===ae(this))throw ge("desiredSize");if(void 0===this._ownerWritableStream)throw Se("desiredSize");return function(e){var r=e._ownerWritableStream,t=r._state;if("errored"===t||"erroring"===t)return null;if("closed"===t)return 0;return _e(r._writableStreamController)}(this)}},{key:"ready",get:function(){return!1===ae(this)?Promise.reject(ge("ready")):this._readyPromise}}]),e}();function ae(e){return!!I(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function se(e){var r=e._ownerWritableStream,t=r._state;if("closed"===t||"errored"===t)return Promise.reject(new TypeError("The stream (in "+t+" state) is not in the writable state and cannot be closed"));var o=new Promise(function(e,t){var o={_resolve:e,_reject:t};r._closeRequest=o});return!0===r._backpressure&&"writable"===t&&Ce(e),function(e){M(e,"close",0),be(e)}(r._writableStreamController),o}function le(e,r){"pending"===e._closedPromiseState?Re(e,r):function(e,r){e._closedPromise=Promise.reject(r),e._closedPromiseState="rejected"}(e,r),e._closedPromise.catch(function(){})}function ue(e,r){"pending"===e._readyPromiseState?function(e,r){e._readyPromise_reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}(e,r):function(e,r){e._readyPromise=Promise.reject(r),e._readyPromiseState="rejected"}(e,r),e._readyPromise.catch(function(){})}function ce(e){var r=e._ownerWritableStream,t=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");ue(e,t),le(e,t),r._writer=void 0,e._ownerWritableStream=void 0}function de(e,r){var t=e._ownerWritableStream,o=t._writableStreamController,n=function(e,r){try{return e._strategySizeAlgorithm(r)}catch(r){return ve(e,r),1}}(o,r);if(t!==e._ownerWritableStream)return Promise.reject(Se("write to"));var i=t._state;if("errored"===i)return Promise.reject(t._storedError);if(!0===te(t)||"closed"===i)return Promise.reject(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return Promise.reject(t._storedError);var a=function(e){return new Promise(function(r,t){var o={_resolve:r,_reject:t};e._writeRequests.push(o)})}(t);return function(e,r,t){var o={chunk:r};try{M(e,o,t)}catch(r){return void ve(e,r)}var n=e._controlledWritableStream;if(!1===te(n)&&"writable"===n._state){var i=ye(e);ne(n,i)}be(e)}(o,r,n),a}var fe=function(){function e(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}var r=e.prototype;return r.error=function(e){if(!1===function(e){if(!I(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&pe(this,e)},r[Y]=function(e){var r=this._abortAlgorithm(e);return he(this),r},r[U]=function(){H(this)},e}();function me(e,r,t,o,n,i,a,s){r._controlledWritableStream=e,e._writableStreamController=r,r._queue=void 0,r._queueTotalSize=void 0,H(r),r._started=!1,r._strategySizeAlgorithm=s,r._strategyHWM=a,r._writeAlgorithm=o,r._closeAlgorithm=n,r._abortAlgorithm=i;var l=ye(r);ne(e,l);var u=t();Promise.resolve(u).then(function(){r._started=!0,be(r)},function(t){r._started=!0,Z(e,t)}).catch(N)}function he(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function _e(e){return e._strategyHWM-e._queueTotalSize}function be(e){var r=e._controlledWritableStream;if(!1!==e._started&&void 0===r._inFlightWriteRequest){var t=r._state;if("closed"!==t&&"errored"!==t)if("erroring"!==t){if(0!==e._queue.length){var o=L(e);"close"===o?function(e){var r=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(r),D(e);var t=e._closeAlgorithm();he(e),t.then(function(){re(r)},function(e){!function(e,r){e._inFlightCloseRequest._reject(r),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(r),e._pendingAbortRequest=void 0),Z(e,r)}(r,e)}).catch(N)}(e):function(e,r){var t=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(t),e._writeAlgorithm(r).then(function(){!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(t);var r=t._state;if(D(e),!1===te(t)&&"writable"===r){var o=ye(e);ne(t,o)}be(e)},function(r){"writable"===t._state&&he(e),function(e,r){e._inFlightWriteRequest._reject(r),e._inFlightWriteRequest=void 0,Z(e,r)}(t,r)}).catch(N)}(e,o.chunk)}}else ee(r)}}function ve(e,r){"writable"===e._controlledWritableStream._state&&pe(e,r)}function ye(e){return _e(e)<=0}function pe(e,r){var t=e._controlledWritableStream;he(e),$(t,r)}function we(e){return new TypeError("WritableStream.prototype."+e+" can only be used on a WritableStream")}function ge(e){return new TypeError("WritableStreamDefaultWriter.prototype."+e+" can only be used on a WritableStreamDefaultWriter")}function Se(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Pe(e){e._closedPromise=new Promise(function(r,t){e._closedPromise_resolve=r,e._closedPromise_reject=t,e._closedPromiseState="pending"})}function Re(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function Te(e,r){e._readyPromise=Promise.reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function qe(e){e._readyPromise=Promise.resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}function Ce(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}var je=V.WritableStream,Ae=q.ArrayBufferCopy,Ee=q.CreateAlgorithmFromUnderlyingMethod,We=q.IsFiniteNonNegativeNumber,Oe=q.InvokeOrNoop,ke=q.IsDetachedBuffer,ze=q.TransferArrayBuffer,Be=q.ValidateAndNormalizeHighWaterMark,Fe=(q.IsNonNegativeNumber,q.MakeSizeAlgorithmFromSizeFunction),Ie=q.createArrayFromList,Ne=q.typeIsObject,De=q.WaitForAllPromise,Me=T,Le=j,He=A,Ye=W,Ue=V.AcquireWritableStreamDefaultWriter,xe=V.IsWritableStream,Ve=V.IsWritableStreamLocked,Qe=V.WritableStreamAbort,Ge=V.WritableStreamDefaultWriterCloseWithErrorPropagation,Je=V.WritableStreamDefaultWriterRelease,Ke=V.WritableStreamDefaultWriterWrite,Xe=V.WritableStreamCloseQueuedOrInFlight,Ze=n("[[CancelSteps]]"),$e=n("[[PullSteps]]"),er=function(){function e(e,r){void 0===e&&(e={}),void 0===r&&(r={}),nr(this);var t=r.size,o=r.highWaterMark,n=e.type;if("bytes"===String(n)){if(void 0!==t)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===o&&(o=0),function(e,r,t){var o=Object.create(Dr.prototype);var n=Ee(r,"pull",0,[o]),a=Ee(r,"cancel",1,[]),s=r.autoAllocateChunkSize;if(void 0!==s&&(s=Number(s),!1===i(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");ot(e,o,function(){return Oe(r,"start",[o])},n,a,t,s)}(this,e,o=Be(o))}else{if(void 0!==n)throw new RangeError("Invalid type is specified");var a=Fe(t);void 0===o&&(o=1),function(e,r,t,o){var n=Object.create(Cr.prototype);var i=Ee(r,"pull",0,[n]),a=Ee(r,"cancel",1,[]);Ir(e,n,function(){return Oe(r,"start",[n])},i,a,t,o)}(this,e,o=Be(o),a)}}var r=e.prototype;return r.cancel=function(e){return!1===ir(this)?Promise.reject(it("cancel")):!0===ar(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):cr(this,e)},r.getReader=function(e){var r=(void 0===e?{}:e).mode;if(!1===ir(this))throw it("getReader");if(void 0===r)return tr(this);if("byob"===(r=String(r)))return function(e){return new wr(e)}(this);throw new RangeError("Invalid mode is specified")},r.pipeThrough=function(e,r){var t=e.writable,o=e.readable,n=void 0===r?{}:r,i=n.preventClose,a=n.preventAbort,s=n.preventCancel,l=n.signal;if(!1===ir(this))throw it("pipeThrough");if(!1===xe(t))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===ir(o))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(i=Boolean(i),a=Boolean(a),s=Boolean(s),void 0!==l&&!nt(l))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===ar(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===Ve(t))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return sr(this,t,i,a,s,l).catch(function(){}),o},r.pipeTo=function(e,r){var t=void 0===r?{}:r,o=t.preventClose,n=t.preventAbort,i=t.preventCancel,a=t.signal;return!1===ir(this)?Promise.reject(it("pipeTo")):!1===xe(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream")):(o=Boolean(o),n=Boolean(n),i=Boolean(i),void 0===a||nt(a)?!0===ar(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===Ve(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):sr(this,e,o,n,i,a):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))},r.tee=function(){if(!1===ir(this))throw it("tee");var e=function(e,r){var t,o,n,i,a,s=tr(e),l=!1,u=!1,c=!1,d=new Promise(function(e){a=e});function f(){return qr(s).then(function(e){var r=e.value,t=e.done;if(!0===t&&!1===l&&(!1===u&&Or(n._readableStreamController),!1===c&&Or(i._readableStreamController),l=!0),!0!==l){var o=r,a=r;!1===u&&kr(n._readableStreamController,o),!1===c&&kr(i._readableStreamController,a)}})}function m(){}return n=or(m,f,function(r){if(u=!0,t=r,!0===c){var n=Ie([t,o]),i=cr(e,n);a(i)}return d}),i=or(m,f,function(r){if(c=!0,o=r,!0===u){var n=Ie([t,o]),i=cr(e,n);a(i)}return d}),s._closedPromise.catch(function(e){!0!==l&&(zr(n._readableStreamController,e),zr(i._readableStreamController,e),l=!0)}),[n,i]}(this);return Ie(e)},t(e,[{key:"locked",get:function(){if(!1===ir(this))throw it("locked");return ar(this)}}]),e}(),rr={CreateReadableByteStream:function(e,r,t,o,n){void 0===o&&(o=0);void 0===n&&(n=void 0);var i=Object.create(er.prototype);nr(i);var a=Object.create(Dr.prototype);return ot(i,a,e,r,t,o,n),i},CreateReadableStream:or,ReadableStream:er,IsReadableStreamDisturbed:function(e){return e._disturbed},ReadableStreamDefaultControllerClose:Or,ReadableStreamDefaultControllerEnqueue:kr,ReadableStreamDefaultControllerError:zr,ReadableStreamDefaultControllerGetDesiredSize:Br,ReadableStreamDefaultControllerHasBackpressure:function(e){if(!0===Er(e))return!1;return!0},ReadableStreamDefaultControllerCanCloseOrEnqueue:Fr};function tr(e){return new pr(e)}function or(e,r,t,o,n){void 0===o&&(o=1),void 0===n&&(n=function(){return 1});var i=Object.create(er.prototype);return nr(i),Ir(i,Object.create(Cr.prototype),e,r,t,o,n),i}function nr(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function ir(e){return!!Ne(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function ar(e){return void 0!==e._reader}function sr(e,r,t,o,n,i){var a=tr(e),s=Ue(r),l=!1,u=Promise.resolve();return new Promise(function(c,d){var f;if(void 0!==i){if(f=function(){var t=new DOMException("Aborted","AbortError"),i=[];!1===o&&i.push(function(){return"writable"===r._state?Qe(r,t):Promise.resolve()}),!1===n&&i.push(function(){return"readable"===e._state?cr(e,t):Promise.resolve()}),b(function(){return De(i.map(function(e){return e()}),function(e){return e})},!0,t)},!0===i.aborted)return void f();i.addEventListener("abort",f)}if(_(e,a._closedPromise,function(e){!1===o?b(function(){return Qe(r,e)},!0,e):v(!0,e)}),_(r,s._closedPromise,function(r){!1===n?b(function(){return cr(e,r)},!0,r):v(!0,r)}),function(e,r,t){"closed"===e._state?t():r.then(t).catch(Me)}(e,a._closedPromise,function(){!1===t?b(function(){return Ge(s)}):v()}),!0===Xe(r)||"closed"===r._state){var m=new TypeError("the destination writable stream closed before all data could be piped to it");!1===n?b(function(){return cr(e,m)},!0,m):v(!0,m)}function h(){var e=u;return u.then(function(){return e!==u?h():void 0})}function _(e,r,t){"errored"===e._state?t(e._storedError):r.catch(t).catch(Me)}function b(e,t,o){function n(){e().then(function(){return y(t,o)},function(e){return y(!0,e)}).catch(Me)}!0!==l&&(l=!0,"writable"===r._state&&!1===Xe(r)?h().then(n):n())}function v(e,t){!0!==l&&(l=!0,"writable"===r._state&&!1===Xe(r)?h().then(function(){return y(e,t)}).catch(Me):y(e,t))}function y(e,r){Je(s),Tr(a),void 0!==i&&i.removeEventListener("abort",f),e?d(r):c(void 0)}new Promise(function(e,r){!function t(o){o?e():(!0===l?Promise.resolve(!0):s._readyPromise.then(function(){return qr(a).then(function(e){var r=e.value,t=e.done;return!0===t||(u=Ke(s,r).catch(function(){}),!1)})})).then(t,r)}(!1)}).catch(function(e){u=Promise.resolve(),Me(e)})})}function lr(e,r){return new Promise(function(t,o){var n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readIntoRequests.push(n)})}function ur(e,r){return new Promise(function(t,o){var n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readRequests.push(n)})}function cr(e,r){return e._disturbed=!0,"closed"===e._state?Promise.resolve(void 0):"errored"===e._state?Promise.reject(e._storedError):(dr(e),e._readableStreamController[Ze](r).then(function(){}))}function dr(e){e._state="closed";var r=e._reader;if(void 0!==r){if(!0===Sr(r)){for(var t=0,o=r._readRequests;t<o.length;t++){var n=o[t];(0,n._resolve)(fr(void 0,!0,n._forAuthorCode))}r._readRequests=[]}!function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(r)}}function fr(e,r,t){var o=null;!0===t&&(o=Object.prototype);var n=Object.create(o);return Object.defineProperty(n,"value",{value:e,enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(n,"done",{value:r,enumerable:!0,writable:!0,configurable:!0}),n}function mr(e,r){e._state="errored",e._storedError=r;var t=e._reader;if(void 0!==t){if(!0===Sr(t)){for(var o=0,n=t._readRequests;o<n.length;o++){n[o]._reject(r)}t._readRequests=[]}else{for(var i=0,a=t._readIntoRequests;i<a.length;i++){a[i]._reject(r)}t._readIntoRequests=[]}lt(t,r),t._closedPromise.catch(function(){})}}function hr(e,r,t){var o=e._reader._readRequests.shift();o._resolve(fr(r,t,o._forAuthorCode))}function _r(e){return e._reader._readIntoRequests.length}function br(e){return e._reader._readRequests.length}function vr(e){var r=e._reader;return void 0!==r&&!1!==gr(r)}function yr(e){var r=e._reader;return void 0!==r&&!1!==Sr(r)}var pr=function(){function e(e){if(!1===ir(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===ar(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Pr(this,e),this._readRequests=[]}var r=e.prototype;return r.cancel=function(e){return!1===Sr(this)?Promise.reject(st("cancel")):void 0===this._ownerReadableStream?Promise.reject(at("cancel")):Rr(this,e)},r.read=function(){return!1===Sr(this)?Promise.reject(st("read")):void 0===this._ownerReadableStream?Promise.reject(at("read from")):qr(this,!0)},r.releaseLock=function(){if(!1===Sr(this))throw st("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");Tr(this)}},t(e,[{key:"closed",get:function(){return!1===Sr(this)?Promise.reject(st("closed")):this._closedPromise}}]),e}(),wr=function(){function e(e){if(!ir(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===Mr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(ar(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Pr(this,e),this._readIntoRequests=[]}var r=e.prototype;return r.cancel=function(e){return gr(this)?void 0===this._ownerReadableStream?Promise.reject(at("cancel")):Rr(this,e):Promise.reject(ut("cancel"))},r.read=function(e){return gr(this)?void 0===this._ownerReadableStream?Promise.reject(at("read from")):ArrayBuffer.isView(e)?!0===ke(e.buffer)?Promise.reject(new TypeError("Cannot read into a view onto a detached ArrayBuffer")):0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,r,t){void 0===t&&(t=!1);var o=e._ownerReadableStream;if(o._disturbed=!0,"errored"===o._state)return Promise.reject(o._storedError);return function(e,r,t){var o=e._controlledReadableByteStream,n=1;r.constructor!==DataView&&(n=r.constructor.BYTES_PER_ELEMENT);var i=r.constructor,a={buffer:ze(r.buffer),byteOffset:r.byteOffset,byteLength:r.byteLength,bytesFilled:0,elementSize:n,ctor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(a),lr(o,t);if("closed"===o._state){var s=new r.constructor(a.buffer,a.byteOffset,0);return Promise.resolve(fr(s,!0,t))}if(e._queueTotalSize>0){if(!0===Qr(e,a)){var l=xr(a);return Jr(e),Promise.resolve(fr(l,!1,t))}if(!0===e._closeRequested){var u=new TypeError("Insufficient bytes to fill elements in the given buffer");return rt(e,u),Promise.reject(u)}}e._pendingPullIntos.push(a);var c=lr(o,t);return Hr(e),c}(o._readableStreamController,r,t)}(this,e,!0):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(ut("read"))},r.releaseLock=function(){if(!gr(this))throw ut("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");Tr(this)}},t(e,[{key:"closed",get:function(){return gr(this)?this._closedPromise:Promise.reject(ut("closed"))}}]),e}();function gr(e){return!!Ne(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Sr(e){return!!Ne(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function Pr(e,r){e._ownerReadableStream=r,r._reader=e,"readable"===r._state?function(e){e._closedPromise=new Promise(function(r,t){e._closedPromise_resolve=r,e._closedPromise_reject=t})}(e):"closed"===r._state?function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e):(!function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e,r._storedError),e._closedPromise.catch(function(){}))}function Rr(e,r){return cr(e._ownerReadableStream,r)}function Tr(e){"readable"===e._ownerReadableStream._state?lt(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,r){e._closedPromise=Promise.reject(r)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._closedPromise.catch(function(){}),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function qr(e,r){void 0===r&&(r=!1);var t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?Promise.resolve(fr(void 0,!0,r)):"errored"===t._state?Promise.reject(t._storedError):t._readableStreamController[$e](r)}var Cr=function(){function e(){throw new TypeError}var r=e.prototype;return r.close=function(){if(!1===jr(this))throw ct("close");if(!1===Fr(this))throw new TypeError("The stream is not in a state that permits close");Or(this)},r.enqueue=function(e){if(!1===jr(this))throw ct("enqueue");if(!1===Fr(this))throw new TypeError("The stream is not in a state that permits enqueue");return kr(this,e)},r.error=function(e){if(!1===jr(this))throw ct("error");zr(this,e)},r[Ze]=function(e){Ye(this);var r=this._cancelAlgorithm(e);return Wr(this),r},r[$e]=function(e){var r=this._controlledReadableStream;if(this._queue.length>0){var t=Le(this);return!0===this._closeRequested&&0===this._queue.length?(Wr(this),dr(r)):Ar(this),Promise.resolve(fr(t,!1,e))}var o=ur(r,e);return Ar(this),o},t(e,[{key:"desiredSize",get:function(){if(!1===jr(this))throw ct("desiredSize");return Br(this)}}]),e}();function jr(e){return!!Ne(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function Ar(e){!1!==Er(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(function(){if(e._pulling=!1,!0===e._pullAgain)return e._pullAgain=!1,Ar(e)},function(r){zr(e,r)}).catch(Me)):e._pullAgain=!0)}function Er(e){var r=e._controlledReadableStream;return!1!==Fr(e)&&(!1!==e._started&&(!0===ar(r)&&br(r)>0||Br(e)>0))}function Wr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Or(e){var r=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Wr(e),dr(r))}function kr(e,r){var t=e._controlledReadableStream;if(!0===ar(t)&&br(t)>0)hr(t,r,!1);else{var o;try{o=e._strategySizeAlgorithm(r)}catch(r){throw zr(e,r),r}try{He(e,r,o)}catch(r){throw zr(e,r),r}}Ar(e)}function zr(e,r){var t=e._controlledReadableStream;"readable"===t._state&&(Ye(e),Wr(e),mr(t,r))}function Br(e){var r=e._controlledReadableStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function Fr(e){var r=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===r}function Ir(e,r,t,o,n,i,a){r._controlledReadableStream=e,r._queue=void 0,r._queueTotalSize=void 0,Ye(r),r._started=!1,r._closeRequested=!1,r._pullAgain=!1,r._pulling=!1,r._strategySizeAlgorithm=a,r._strategyHWM=i,r._pullAlgorithm=o,r._cancelAlgorithm=n,e._readableStreamController=r;var s=t();Promise.resolve(s).then(function(){r._started=!0,Ar(r)},function(e){zr(r,e)}).catch(Me)}var Nr=function(){function e(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}var r=e.prototype;return r.respond=function(e){if(!1===Lr(this))throw dt("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!0===ke(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");!function(e,r){if(r=Number(r),!1===We(r))throw new RangeError("bytesWritten must be a finite");Zr(e,r)}(this._associatedReadableByteStreamController,e)},r.respondWithNewView=function(e){if(!1===Lr(this))throw dt("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(!0===ke(e.buffer))throw new TypeError("The supplied view's buffer has been detached and so cannot be used as a response");!function(e,r){var t=e._pendingPullIntos[0];if(t.byteOffset+t.bytesFilled!==r.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(t.byteLength!==r.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");t.buffer=r.buffer,Zr(e,r.byteLength)}(this._associatedReadableByteStreamController,e)},t(e,[{key:"view",get:function(){if(!1===Lr(this))throw dt("view");return this._view}}]),e}(),Dr=function(){function e(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}var r=e.prototype;return r.close=function(){if(!1===Mr(this))throw ft("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");var e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError("The stream (in "+e+" state) is not in the readable state and cannot be closed");!function(e){var r=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){var t=e._pendingPullIntos[0];if(t.bytesFilled>0){var o=new TypeError("Insufficient bytes to fill elements in the given buffer");throw rt(e,o),o}}et(e),dr(r)}(this)},r.enqueue=function(e){if(!1===Mr(this))throw ft("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");var r=this._controlledReadableByteStream._state;if("readable"!==r)throw new TypeError("The stream (in "+r+" state) is not in the readable state and cannot be enqueued to");if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");if(!0===ke(e.buffer))throw new TypeError("Cannot enqueue a view onto a detached ArrayBuffer");!function(e,r){var t=e._controlledReadableByteStream,o=r.buffer,n=r.byteOffset,i=r.byteLength,a=ze(o);if(!0===yr(t))if(0===br(t))Vr(e,a,n,i);else{var s=new Uint8Array(a,n,i);hr(t,s,!1)}else!0===vr(t)?(Vr(e,a,n,i),Xr(e)):Vr(e,a,n,i);Hr(e)}(this,e)},r.error=function(e){if(!1===Mr(this))throw ft("error");rt(this,e)},r[Ze]=function(e){this._pendingPullIntos.length>0&&(this._pendingPullIntos[0].bytesFilled=0);Ye(this);var r=this._cancelAlgorithm(e);return et(this),r},r[$e]=function(e){var r=this._controlledReadableByteStream;if(this._queueTotalSize>0){var t,o=this._queue.shift();this._queueTotalSize-=o.byteLength,Jr(this);try{t=new Uint8Array(o.buffer,o.byteOffset,o.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(fr(t,!1,e))}var n=this._autoAllocateChunkSize;if(void 0!==n){var i;try{i=new ArrayBuffer(n)}catch(e){return Promise.reject(e)}var a={buffer:i,byteOffset:0,byteLength:n,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(a)}var s=ur(r,e);return Hr(this),s},t(e,[{key:"byobRequest",get:function(){if(!1===Mr(this))throw ft("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){var e=this._pendingPullIntos[0],r=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),t=Object.create(Nr.prototype);!function(e,r,t){e._associatedReadableByteStreamController=r,e._view=t}(t,this,r),this._byobRequest=t}return this._byobRequest}},{key:"desiredSize",get:function(){if(!1===Mr(this))throw ft("desiredSize");return tt(this)}}]),e}();function Mr(e){return!!Ne(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function Lr(e){return!!Ne(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function Hr(e){!1!==function(e){var r=e._controlledReadableByteStream;if("readable"!==r._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===yr(r)&&br(r)>0)return!0;if(!0===vr(r)&&_r(r)>0)return!0;if(tt(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(function(){e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,Hr(e))},function(r){rt(e,r)}).catch(Me)):e._pullAgain=!0)}function Yr(e){Kr(e),e._pendingPullIntos=[]}function Ur(e,r){var t=!1;"closed"===e._state&&(t=!0);var o=xr(r);"default"===r.readerType?hr(e,o,t):function(e,r,t){var o=e._reader._readIntoRequests.shift();o._resolve(fr(r,t,o._forAuthorCode))}(e,o,t)}function xr(e){var r=e.bytesFilled,t=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,r/t)}function Vr(e,r,t,o){e._queue.push({buffer:r,byteOffset:t,byteLength:o}),e._queueTotalSize+=o}function Qr(e,r){var t=r.elementSize,o=r.bytesFilled-r.bytesFilled%t,n=Math.min(e._queueTotalSize,r.byteLength-r.bytesFilled),i=r.bytesFilled+n,a=i-i%t,s=n,l=!1;a>o&&(s=a-r.bytesFilled,l=!0);for(var u=e._queue;s>0;){var c=u[0],d=Math.min(s,c.byteLength),f=r.byteOffset+r.bytesFilled;Ae(r.buffer,f,c.buffer,c.byteOffset,d),c.byteLength===d?u.shift():(c.byteOffset+=d,c.byteLength-=d),e._queueTotalSize-=d,Gr(e,d,r),s-=d}return l}function Gr(e,r,t){Kr(e),t.bytesFilled+=r}function Jr(e){0===e._queueTotalSize&&!0===e._closeRequested?(et(e),dr(e._controlledReadableByteStream)):Hr(e)}function Kr(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function Xr(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;var r=e._pendingPullIntos[0];!0===Qr(e,r)&&($r(e),Ur(e._controlledReadableByteStream,r))}}function Zr(e,r){var t=e._pendingPullIntos[0];if("closed"===e._controlledReadableByteStream._state){if(0!==r)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,r){r.buffer=ze(r.buffer);var t=e._controlledReadableByteStream;if(!0===vr(t))for(;_r(t)>0;)Ur(t,$r(e))}(e,t)}else!function(e,r,t){if(t.bytesFilled+r>t.byteLength)throw new RangeError("bytesWritten out of range");if(Gr(e,r,t),!(t.bytesFilled<t.elementSize)){$r(e);var o=t.bytesFilled%t.elementSize;if(o>0){var n=t.byteOffset+t.bytesFilled,i=t.buffer.slice(n-o,n);Vr(e,i,0,i.byteLength)}t.buffer=ze(t.buffer),t.bytesFilled-=o,Ur(e._controlledReadableByteStream,t),Xr(e)}}(e,r,t);Hr(e)}function $r(e){var r=e._pendingPullIntos.shift();return Kr(e),r}function et(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function rt(e,r){var t=e._controlledReadableByteStream;"readable"===t._state&&(Yr(e),Ye(e),et(e),mr(t,r))}function tt(e){var r=e._controlledReadableByteStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function ot(e,r,t,o,n,i,a){r._controlledReadableByteStream=e,r._pullAgain=!1,r._pulling=!1,Yr(r),r._queue=r._queueTotalSize=void 0,Ye(r),r._closeRequested=!1,r._started=!1,r._strategyHWM=Be(i),r._pullAlgorithm=o,r._cancelAlgorithm=n,r._autoAllocateChunkSize=a,r._pendingPullIntos=[],e._readableStreamController=r;var s=t();Promise.resolve(s).then(function(){r._started=!0,Hr(r)},function(e){rt(r,e)}).catch(Me)}function nt(e){if("object"!=typeof e||null===e)return!1;var r=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted").get;try{return r.call(e),!0}catch(e){return!1}}function it(e){return new TypeError("ReadableStream.prototype."+e+" can only be used on a ReadableStream")}function at(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function st(e){return new TypeError("ReadableStreamDefaultReader.prototype."+e+" can only be used on a ReadableStreamDefaultReader")}function lt(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function ut(e){return new TypeError("ReadableStreamBYOBReader.prototype."+e+" can only be used on a ReadableStreamBYOBReader")}function ct(e){return new TypeError("ReadableStreamDefaultController.prototype."+e+" can only be used on a ReadableStreamDefaultController")}function dt(e){return new TypeError("ReadableStreamBYOBRequest.prototype."+e+" can only be used on a ReadableStreamBYOBRequest")}function ft(e){return new TypeError("ReadableByteStreamController.prototype."+e+" can only be used on a ReadableByteStreamController")}var mt=rr.ReadableStream,ht=q.createDataProperty,_t=function(){function e(e){var r=e.highWaterMark;ht(this,"highWaterMark",r)}return e.prototype.size=function(e){return e.byteLength},e}(),bt=q.createDataProperty,vt=function(){function e(e){var r=e.highWaterMark;bt(this,"highWaterMark",r)}return e.prototype.size=function(){return 1},e}(),yt=(O("streams:transform-stream:verbose"),q.InvokeOrNoop),pt=q.CreateAlgorithmFromUnderlyingMethod,wt=q.PromiseCall,gt=q.typeIsObject,St=q.ValidateAndNormalizeHighWaterMark,Pt=(q.IsNonNegativeNumber,q.MakeSizeAlgorithmFromSizeFunction),Rt=rr.CreateReadableStream,Tt=rr.ReadableStreamDefaultControllerClose,qt=rr.ReadableStreamDefaultControllerEnqueue,Ct=rr.ReadableStreamDefaultControllerError,jt=rr.ReadableStreamDefaultControllerGetDesiredSize,At=rr.ReadableStreamDefaultControllerHasBackpressure,Et=rr.ReadableStreamDefaultControllerCanCloseOrEnqueue,Wt=V.CreateWritableStream,Ot=V.WritableStreamDefaultControllerErrorIfNeeded,kt=function(){function e(e,r,t){void 0===e&&(e={}),void 0===r&&(r={}),void 0===t&&(t={});var o=r.size,n=r.highWaterMark,i=t.size,a=t.highWaterMark;if(void 0!==e.writableType)throw new RangeError("Invalid writable type specified");var s=Pt(o);if(void 0===n&&(n=1),n=St(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");var l,u=Pt(i);void 0===a&&(a=0),a=St(a),zt(this,new Promise(function(e){l=e}),n,s,a,u),function(e,r){var t=Object.create(Dt.prototype),o=function(e){try{return Yt(t,e),Promise.resolve()}catch(e){return Promise.reject(e)}},n=r.transform;if(void 0!==n){if("function"!=typeof n)throw new TypeError("transform is not a method");o=function(e){return wt(n,r,[e,t])}}var i=pt(r,"flush",0,[t]);Lt(e,t,o,i)}(this,e);var c=yt(e,"start",[this._transformStreamController]);l(c)}return t(e,[{key:"readable",get:function(){if(!1===Bt(this))throw Vt("readable");return this._readable}},{key:"writable",get:function(){if(!1===Bt(this))throw Vt("writable");return this._writable}}]),e}();function zt(e,r,t,o,n,i){function a(){return r}e._writable=Wt(a,function(r){return function(e,r){var t=e._transformStreamController;if(!0===e._backpressure){var o=e._backpressureChangePromise;return o.then(function(){var o=e._writable,n=o._state;if("erroring"===n)throw o._storedError;return Ut(t,r)})}return Ut(t,r)}(e,r)},function(){return function(e){var r=e._readable,t=e._transformStreamController,o=t._flushAlgorithm();return Ht(t),o.then(function(){if("errored"===r._state)throw r._storedError;var e=r._readableStreamController;!0===Et(e)&&Tt(e)}).catch(function(t){throw Ft(e,t),r._storedError})}(e)},function(r){return function(e,r){return Ft(e,r),Promise.resolve()}(e,r)},t,o),e._readable=Rt(a,function(){return function(e){return Nt(e,!1),e._backpressureChangePromise}(e)},function(r){return It(e,r),Promise.resolve()},n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Nt(e,!0),e._transformStreamController=void 0}function Bt(e){return!!gt(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function Ft(e,r){Ct(e._readable._readableStreamController,r),It(e,r)}function It(e,r){Ht(e._transformStreamController),Ot(e._writable._writableStreamController,r),!0===e._backpressure&&Nt(e,!1)}function Nt(e,r){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(function(r){e._backpressureChangePromise_resolve=r}),e._backpressure=r}var Dt=function(){function e(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}var r=e.prototype;return r.enqueue=function(e){if(!1===Mt(this))throw xt("enqueue");Yt(this,e)},r.error=function(e){if(!1===Mt(this))throw xt("error");!function(e,r){Ft(e._controlledTransformStream,r)}(this,e)},r.terminate=function(){if(!1===Mt(this))throw xt("terminate");!function(e){var r=e._controlledTransformStream,t=r._readable._readableStreamController;!0===Et(t)&&Tt(t);var o=new TypeError("TransformStream terminated");It(r,o)}(this)},t(e,[{key:"desiredSize",get:function(){if(!1===Mt(this))throw xt("desiredSize");var e=this._controlledTransformStream._readable._readableStreamController;return jt(e)}}]),e}();function Mt(e){return!!gt(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function Lt(e,r,t,o){r._controlledTransformStream=e,e._transformStreamController=r,r._transformAlgorithm=t,r._flushAlgorithm=o}function Ht(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Yt(e,r){var t=e._controlledTransformStream,o=t._readable._readableStreamController;if(!1===Et(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{qt(o,r)}catch(e){throw It(t,e),t._readable._storedError}At(o)!==t._backpressure&&Nt(t,!0)}function Ut(e,r){return e._transformAlgorithm(r).catch(function(r){throw Ft(e._controlledTransformStream,r),r})}function xt(e){return new TypeError("TransformStreamDefaultController.prototype."+e+" can only be used on a TransformStreamDefaultController")}function Vt(e){return new TypeError("TransformStream.prototype."+e+" can only be used on a TransformStream")}var Qt={CreateTransformStream:function(e,r,t,o,n,i,a){void 0===o&&(o=1),void 0===n&&(n=function(){return 1}),void 0===i&&(i=0),void 0===a&&(a=function(){return 1});var s,l=Object.create(kt.prototype);zt(l,new Promise(function(e){s=e}),o,n,i,a),Lt(l,Object.create(Dt.prototype),r,t);var u=e();return s(u),l},TransformStream:kt}.TransformStream;void 0!==s&&o(s,{ReadableStream:mt,WritableStream:je,ByteLengthQueuingStrategy:_t,CountQueuingStrategy:vt,TransformStream:Qt}),e.ReadableStream=mt,e.WritableStream=je,e.ByteLengthQueuingStrategy=_t,e.CountQueuingStrategy=vt,e.TransformStream=Qt,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).WebStreamsPolyfill={})}(this,function(e){"use strict";const t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`;const r="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0,o=Number.isNaN||function(e){return e!=e};function n(e){return"object"==typeof e&&null!==e||"function"==typeof e}function i(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function a(e){return e.slice()}function s(e,t,r,o,n){new Uint8Array(e).set(new Uint8Array(r,o,n),t)}function l(e){return!1!==function(e){if("number"!=typeof e)return!1;if(o(e))return!1;if(e<0)return!1;return!0}(e)&&e!==1/0}function c(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function u(e,t,r,o){const n=e[t];if(void 0!==n){if("function"!=typeof n)throw new TypeError(`${n} is not a method`);switch(r){case 0:return()=>f(n,e,o);case 1:return t=>{const r=[t].concat(o);return f(n,e,r)}}}return()=>Promise.resolve()}function d(e,t,r){const o=e[t];if(void 0!==o)return c(o,e,r)}function f(e,t,r){try{return Promise.resolve(c(e,t,r))}catch(e){return Promise.reject(e)}}function _(e){return e}function h(e){if(e=Number(e),o(e)||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e}function b(e){if(void 0===e)return()=>1;if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return t=>e(t)}function m(e,t,r){return Promise.prototype.then.call(e,t,r)}function y(e,t,r){let o,n;const i=new Promise((e,t)=>{o=e,n=t});void 0===r&&(r=(e=>{throw e}));return function(e,t,r){let o=!1;const n=e=>{!1===o&&(o=!0,r(e))};let i=0,a=0;const s=e.length,l=new Array(s);for(const r of e){const e=i;m(r,r=>{l[e]=r,++a===s&&t(l)},n),++i}}(e,e=>{try{const r=t(e);o(r)}catch(e){n(e)}},e=>{try{const t=r(e);o(t)}catch(e){n(e)}}),i}function p(e){}function w(e){e&&e instanceof p.AssertionError&&setTimeout(()=>{throw e},0)}function g(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function S(e,t,r){if(!l(r=Number(r)))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function v(e){e._queue=[],e._queueTotalSize=0}p.AssertionError=function(){};const R=t("[[AbortSteps]]"),P=t("[[ErrorSteps]]");class WritableStream{constructor(e={},t={}){q(this);const r=t.size;let o=t.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");const n=b(r);void 0===o&&(o=1),function(e,t,r,o){const n=Object.create(WritableStreamDefaultController.prototype);const i=u(t,"write",1,[n]),a=u(t,"close",0,[]),s=u(t,"abort",1,[]);$(e,n,function(){return d(t,"start",[n])},i,a,s,r,o)}(this,e,o=h(o),n)}get locked(){if(!1===E(this))throw G("locked");return C(this)}abort(e){return!1===E(this)?Promise.reject(G("abort")):!0===C(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):j(this,e)}getWriter(){if(!1===E(this))throw G("getWriter");return T(this)}}function T(e){return new WritableStreamDefaultWriter(e)}function q(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=[],e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function E(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function C(e){return void 0!==e._writer}function j(e,t){const r=e._state;if("closed"===r||"errored"===r)return Promise.resolve(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===r&&(o=!0,t=void 0);const n=new Promise((r,n)=>{e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&W(e,t),n}function A(e,t){"writable"!==e._state?B(e):W(e,t)}function W(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const o=e._writer;void 0!==o&&D(o,t),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===r._started&&B(e)}function B(e){e._state="errored",e._writableStreamController[P]();const t=e._storedError;for(const r of e._writeRequests)r._reject(t);if(e._writeRequests=[],void 0===e._pendingAbortRequest)return void z(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===r._wasAlreadyErroring)return r._reject(t),void z(e);e._writableStreamController[R](r._reason).then(()=>{r._resolve(),z(e)},t=>{r._reject(t),z(e)})}function O(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function z(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&ee(t,e._storedError)}function k(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(!0===t?function(e){re(e)}(r):ae(r)),e._backpressure=t}class WritableStreamDefaultWriter{constructor(e){if(!1===E(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===C(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;const t=e._state;if("writable"===t)!1===O(e)&&!0===e._backpressure?re(this):ne(this),X(this);else if("erroring"===t)oe(this,e._storedError),X(this);else if("closed"===t)ne(this),function(e){X(e),te(e)}(this);else{const t=e._storedError;oe(this,t),Z(this,t)}}get closed(){return!1===F(this)?Promise.reject(J("closed")):this._closedPromise}get desiredSize(){if(!1===F(this))throw J("desiredSize");if(void 0===this._ownerWritableStream)throw K("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return Q(t._writableStreamController)}(this)}get ready(){return!1===F(this)?Promise.reject(J("ready")):this._readyPromise}abort(e){return!1===F(this)?Promise.reject(J("abort")):void 0===this._ownerWritableStream?Promise.reject(K("abort")):function(e,t){return j(e._ownerWritableStream,t)}(this,e)}close(){if(!1===F(this))return Promise.reject(J("close"));const e=this._ownerWritableStream;return void 0===e?Promise.reject(K("close")):!0===O(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):L(this)}releaseLock(){if(!1===F(this))throw J("releaseLock");void 0!==this._ownerWritableStream&&M(this)}write(e){return!1===F(this)?Promise.reject(J("write")):void 0===this._ownerWritableStream?Promise.reject(K("write to")):Y(this,e)}}function F(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function L(e){const t=e._ownerWritableStream,r=t._state;if("closed"===r||"errored"===r)return Promise.reject(new TypeError(`The stream (in ${r} state) is not in the writable state and cannot be closed`));const o=new Promise((e,r)=>{const o={_resolve:e,_reject:r};t._closeRequest=o});return!0===t._backpressure&&"writable"===r&&ae(e),function(e){S(e,"close",0),x(e)}(t._writableStreamController),o}function I(e,t){"pending"===e._closedPromiseState?ee(e,t):function(e,t){Z(e,t)}(e,t)}function D(e,t){"pending"===e._readyPromiseState?ie(e,t):function(e,t){oe(e,t)}(e,t)}function M(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");D(e,r),I(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function Y(e,t){const r=e._ownerWritableStream,o=r._writableStreamController,n=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return H(e,t),1}}(o,t);if(r!==e._ownerWritableStream)return Promise.reject(K("write to"));const i=r._state;if("errored"===i)return Promise.reject(r._storedError);if(!0===O(r)||"closed"===i)return Promise.reject(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return Promise.reject(r._storedError);const a=function(e){return new Promise((t,r)=>{const o={_resolve:t,_reject:r};e._writeRequests.push(o)})}(r);return function(e,t,r){const o={chunk:t};try{S(e,o,r)}catch(t){return void H(e,t)}const n=e._controlledWritableStream;if(!1===O(n)&&"writable"===n._state){const t=U(e);k(n,t)}x(e)}(o,t,n),a}class WritableStreamDefaultController{constructor(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}error(e){if(!1===function(e){if(!n(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&V(this,e)}[R](e){const t=this._abortAlgorithm(e);return N(this),t}[P](){v(this)}}function $(e,t,r,o,n,i,a,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,v(t),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._writeAlgorithm=o,t._closeAlgorithm=n,t._abortAlgorithm=i;const l=U(t);k(e,l);const c=r();Promise.resolve(c).then(()=>{t._started=!0,x(t)},r=>{t._started=!0,A(e,r)}).catch(w)}function N(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Q(e){return e._strategyHWM-e._queueTotalSize}function x(e){const t=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==t._inFlightWriteRequest)return;const r=t._state;if("closed"===r||"errored"===r)return;if("erroring"===r)return void B(t);if(0===e._queue.length)return;const o=function(e){return e._queue[0].value}(e);"close"===o?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),g(e);const r=e._closeAlgorithm();N(e),r.then(()=>{!function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const t=e._writer;void 0!==t&&te(t)}(t)},e=>{!function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),A(e,t)}(t,e)}).catch(w)}(e):function(e,t){const r=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(r),e._writeAlgorithm(t).then(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);const t=r._state;if(g(e),!1===O(r)&&"writable"===t){const t=U(e);k(r,t)}x(e)},t=>{"writable"===r._state&&N(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,A(e,t)}(r,t)}).catch(w)}(e,o.chunk)}function H(e,t){"writable"===e._controlledWritableStream._state&&V(e,t)}function U(e){return Q(e)<=0}function V(e,t){const r=e._controlledWritableStream;N(e),W(r,t)}function G(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function J(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function K(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function X(e){e._closedPromise=new Promise((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function Z(e,t){X(e),ee(e,t)}function ee(e,t){e._closedPromise.catch(()=>{}),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function te(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}function re(e){e._readyPromise=new Promise((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function oe(e,t){re(e),ie(e,t)}function ne(e){re(e),ae(e)}function ie(e,t){e._readyPromise.catch(()=>{}),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function ae(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}const se=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},le=t("[[CancelSteps]]"),ce=t("[[PullSteps]]");class ReadableStream{constructor(e={},t={}){fe(this);const r=t.size;let o=t.highWaterMark;const n=e.type;if("bytes"===String(n)){if(void 0!==r)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===o&&(o=0),function(e,t,r){const o=Object.create(ReadableByteStreamController.prototype);const n=u(t,"pull",0,[o]),i=u(t,"cancel",1,[]);let a=t.autoAllocateChunkSize;if(void 0!==a&&(a=Number(a),!1===se(a)||a<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");!function(e,t,r,o,n,i,a){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,He(t),t._queue=t._queueTotalSize=void 0,v(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=h(i),t._pullAlgorithm=o,t._cancelAlgorithm=n,t._autoAllocateChunkSize=a,t._pendingPullIntos=[],e._readableStreamController=t;const s=r();Promise.resolve(s).then(()=>{t._started=!0,xe(t)},e=>{nt(t,e)}).catch(w)}(e,o,function(){return d(t,"start",[o])},n,i,r,a)}(this,e,o=h(o))}else{if(void 0!==n)throw new RangeError("Invalid type is specified");{const t=b(r);void 0===o&&(o=1),function(e,t,r,o){const n=Object.create(ReadableStreamDefaultController.prototype);const i=u(t,"pull",0,[n]),a=u(t,"cancel",1,[]);$e(e,n,function(){return d(t,"start",[n])},i,a,r,o)}(this,e,o=h(o),t)}}}get locked(){if(!1===_e(this))throw st("locked");return he(this)}cancel(e){return!1===_e(this)?Promise.reject(st("cancel")):!0===he(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):pe(this,e)}getReader({mode:e}={}){if(!1===_e(this))throw st("getReader");if(void 0===e)return ue(this);if("byob"===(e=String(e)))return function(e){return new ReadableStreamBYOBReader(e)}(this);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:t},{preventClose:r,preventAbort:o,preventCancel:n,signal:i}={}){if(!1===_e(this))throw st("pipeThrough");if(!1===E(e))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===_e(t))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(r=Boolean(r),o=Boolean(o),n=Boolean(n),void 0!==i&&!at(i))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===he(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===C(e))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return be(this,e,r,o,n,i).catch(()=>{}),t}pipeTo(e,{preventClose:t,preventAbort:r,preventCancel:o,signal:n}={}){return!1===_e(this)?Promise.reject(st("pipeTo")):!1===E(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream")):(t=Boolean(t),r=Boolean(r),o=Boolean(o),void 0===n||at(n)?!0===he(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===C(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):be(this,e,t,r,o,n):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))}tee(){if(!1===_e(this))throw st("tee");const e=function(e,t){const r=ue(e);let o,n,i,s,l,c=!1,u=!1,d=!1;const f=new Promise(e=>{l=e});function _(){return Be(r).then(e=>{const t=e.value,r=e.done;if(!0===r&&!1===c&&(!1===u&&Le(i._readableStreamController),!1===d&&Le(s._readableStreamController),c=!0),!0===c)return;const o=t,n=t;!1===u&&Ie(i._readableStreamController,o),!1===d&&Ie(s._readableStreamController,n)})}function h(){}return i=de(h,_,function(t){if(u=!0,o=t,!0===d){const t=a([o,n]),r=pe(e,t);l(r)}return f}),s=de(h,_,function(t){if(d=!0,n=t,!0===u){const t=a([o,n]),r=pe(e,t);l(r)}return f}),r._closedPromise.catch(e=>{!0!==c&&(De(i._readableStreamController,e),De(s._readableStreamController,e),c=!0)}),[i,s]}(this);return a(e)}}function ue(e){return new ReadableStreamDefaultReader(e)}function de(e,t,r,o=1,n=(()=>1)){const i=Object.create(ReadableStream.prototype);return fe(i),$e(i,Object.create(ReadableStreamDefaultController.prototype),e,t,r,o,n),i}function fe(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function _e(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function he(e){return void 0!==e._reader}function be(e,t,r,o,n,i){const a=ue(e),s=T(t);let l=!1,c=Promise.resolve();return new Promise((u,d)=>{let f;if(void 0!==i){if(f=(()=>{const r=new DOMException("Aborted","AbortError"),i=[];!1===o&&i.push(()=>"writable"===t._state?j(t,r):Promise.resolve()),!1===n&&i.push(()=>"readable"===e._state?pe(e,r):Promise.resolve()),b(()=>y(i.map(e=>e()),e=>e),!0,r)}),!0===i.aborted)return void f();i.addEventListener("abort",f)}if(h(e,a._closedPromise,e=>{!1===o?b(()=>j(t,e),!0,e):m(!0,e)}),h(t,s._closedPromise,t=>{!1===n?b(()=>pe(e,t),!0,t):m(!0,t)}),function(e,t,r){"closed"===e._state?r():t.then(r).catch(w)}(e,a._closedPromise,()=>{!1===r?b(()=>(function(e){const t=e._ownerWritableStream,r=t._state;return!0===O(t)||"closed"===r?Promise.resolve():"errored"===r?Promise.reject(t._storedError):L(e)})(s)):m()}),!0===O(t)||"closed"===t._state){const t=new TypeError("the destination writable stream closed before all data could be piped to it");!1===n?b(()=>pe(e,t),!0,t):m(!0,t)}function _(){const e=c;return c.then(()=>e!==c?_():void 0)}function h(e,t,r){"errored"===e._state?r(e._storedError):t.catch(r).catch(w)}function b(e,r,o){function n(){e().then(()=>p(r,o),e=>p(!0,e)).catch(w)}!0!==l&&(l=!0,"writable"===t._state&&!1===O(t)?_().then(n):n())}function m(e,r){!0!==l&&(l=!0,"writable"===t._state&&!1===O(t)?_().then(()=>p(e,r)).catch(w):p(e,r))}function p(e,t){M(s),We(a),void 0!==i&&i.removeEventListener("abort",f),e?d(t):u(void 0)}new Promise((e,t)=>{!function r(o){o?e():(!0===l?Promise.resolve(!0):s._readyPromise.then(()=>Be(a).then(({value:e,done:t})=>!0===t||(c=Y(s,e).catch(()=>{}),!1)))).then(r,t)}(!1)}).catch(e=>{c=Promise.resolve(),w(e)})})}function me(e,t){return new Promise((r,o)=>{const n={_resolve:r,_reject:o,_forAuthorCode:t};e._reader._readIntoRequests.push(n)})}function ye(e,t){return new Promise((r,o)=>{const n={_resolve:r,_reject:o,_forAuthorCode:t};e._reader._readRequests.push(n)})}function pe(e,t){if(e._disturbed=!0,"closed"===e._state)return Promise.resolve(void 0);if("errored"===e._state)return Promise.reject(e._storedError);return we(e),e._readableStreamController[le](t).then(()=>void 0)}function we(e){e._state="closed";const t=e._reader;if(void 0!==t){if(Ce(t)){for(const{_resolve:e,_forAuthorCode:r}of t._readRequests)e(ge(void 0,!0,r));t._readRequests=[]}_t(t)}}function ge(e,t,r){let o=null;!0===r&&(o=Object.prototype);const n=Object.create(o);return Object.defineProperty(n,"value",{value:e,enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(n,"done",{value:t,enumerable:!0,writable:!0,configurable:!0}),n}function Se(e,t){e._state="errored",e._storedError=t;const r=e._reader;if(void 0!==r){if(Ce(r)){for(const e of r._readRequests)e._reject(t);r._readRequests=[]}else{for(const e of r._readIntoRequests)e._reject(t);r._readIntoRequests=[]}ft(r,t)}}function ve(e,t,r){const o=e._reader._readRequests.shift();o._resolve(ge(t,r,o._forAuthorCode))}function Re(e){return e._reader._readIntoRequests.length}function Pe(e){return e._reader._readRequests.length}function Te(e){const t=e._reader;return void 0!==t&&!!Ee(t)}function qe(e){const t=e._reader;return void 0!==t&&!!Ce(t)}class ReadableStreamDefaultReader{constructor(e){if(!1===_e(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===he(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");je(this,e),this._readRequests=[]}get closed(){return Ce(this)?this._closedPromise:Promise.reject(ct("closed"))}cancel(e){return Ce(this)?void 0===this._ownerReadableStream?Promise.reject(lt("cancel")):Ae(this,e):Promise.reject(ct("cancel"))}read(){return Ce(this)?void 0===this._ownerReadableStream?Promise.reject(lt("read from")):Be(this,!0):Promise.reject(ct("read"))}releaseLock(){if(!Ce(this))throw ct("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");We(this)}}}class ReadableStreamBYOBReader{constructor(e){if(!_e(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===Ne(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(he(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");je(this,e),this._readIntoRequests=[]}get closed(){return Ee(this)?this._closedPromise:Promise.reject(ht("closed"))}cancel(e){return Ee(this)?void 0===this._ownerReadableStream?Promise.reject(lt("cancel")):Ae(this,e):Promise.reject(ht("cancel"))}read(e){return Ee(this)?void 0===this._ownerReadableStream?Promise.reject(lt("read from")):ArrayBuffer.isView(e)?(e.buffer,0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,t,r=!1){const o=e._ownerReadableStream;if(o._disturbed=!0,"errored"===o._state)return Promise.reject(o._storedError);return function(e,t,r){const o=e._controlledReadableByteStream;let n=1;t.constructor!==DataView&&(n=t.constructor.BYTES_PER_ELEMENT);const i=t.constructor,a={buffer:_(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:n,ctor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(a),me(o,r);if("closed"===o._state){const e=new i(a.buffer,a.byteOffset,0);return Promise.resolve(ge(e,!0,r))}if(e._queueTotalSize>0){if(!0===Je(e,a)){const t=Ve(a);return Xe(e),Promise.resolve(ge(t,!1,r))}if(!0===e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return nt(e,t),Promise.reject(t)}}e._pendingPullIntos.push(a);const s=me(o,r);return xe(e),s}(o._readableStreamController,t,r)}(this,e,!0)):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(ht("read"))}releaseLock(){if(!Ee(this))throw ht("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");We(this)}}}function Ee(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Ce(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function je(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?ut(e):"closed"===t._state?function(e){ut(e),_t(e)}(e):dt(e,t._storedError)}function Ae(e,t){return pe(e._ownerReadableStream,t)}function We(e){"readable"===e._ownerReadableStream._state?ft(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){dt(e,t)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function Be(e,t=!1){const r=e._ownerReadableStream;return r._disturbed=!0,"closed"===r._state?Promise.resolve(ge(void 0,!0,t)):"errored"===r._state?Promise.reject(r._storedError):r._readableStreamController[ce](t)}class ReadableStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){if(!1===Oe(this))throw bt("desiredSize");return Me(this)}close(){if(!1===Oe(this))throw bt("close");if(!1===Ye(this))throw new TypeError("The stream is not in a state that permits close");Le(this)}enqueue(e){if(!1===Oe(this))throw bt("enqueue");if(!1===Ye(this))throw new TypeError("The stream is not in a state that permits enqueue");return Ie(this,e)}error(e){if(!1===Oe(this))throw bt("error");De(this,e)}[le](e){v(this);const t=this._cancelAlgorithm(e);return Fe(this),t}[ce](e){const t=this._controlledReadableStream;if(this._queue.length>0){const r=g(this);return!0===this._closeRequested&&0===this._queue.length?(Fe(this),we(t)):ze(this),Promise.resolve(ge(r,!1,e))}const r=ye(t,e);return ze(this),r}}function Oe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function ze(e){!1!==ke(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{if(e._pulling=!1,!0===e._pullAgain)return e._pullAgain=!1,ze(e)},t=>{De(e,t)}).catch(w)):e._pullAgain=!0)}function ke(e){const t=e._controlledReadableStream;return!1!==Ye(e)&&(!1!==e._started&&(!0===he(t)&&Pe(t)>0||Me(e)>0))}function Fe(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Le(e){const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Fe(e),we(t))}function Ie(e,t){const r=e._controlledReadableStream;if(!0===he(r)&&Pe(r)>0)ve(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw De(e,t),t}try{S(e,t,r)}catch(t){throw De(e,t),t}}ze(e)}function De(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(v(e),Fe(e),Se(r,t))}function Me(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ye(e){const t=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===t}function $e(e,t,r,o,n,i,a){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,v(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=a,t._strategyHWM=i,t._pullAlgorithm=o,t._cancelAlgorithm=n,e._readableStreamController=t;const s=r();Promise.resolve(s).then(()=>{t._started=!0,ze(t)},e=>{De(t,e)}).catch(w)}class ReadableStreamBYOBRequest{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===Qe(this))throw mt("view");return this._view}respond(e){if(!1===Qe(this))throw mt("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,function(e,t){if(!1===l(t=Number(t)))throw new RangeError("bytesWritten must be a finite");tt(e,t)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===Qe(this))throw mt("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");e.buffer,function(e,t){const r=e._pendingPullIntos[0];if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.byteLength!==t.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");r.buffer=t.buffer,tt(e,t.byteLength)}(this._associatedReadableByteStreamController,e)}}class ReadableByteStreamController{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===Ne(this))throw yt("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos[0],t=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),r=Object.create(ReadableStreamBYOBRequest.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(r,this,t),this._byobRequest=r}return this._byobRequest}get desiredSize(){if(!1===Ne(this))throw yt("desiredSize");return it(this)}close(){if(!1===Ne(this))throw yt("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const t=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){const t=e._pendingPullIntos[0];if(t.bytesFilled>0){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");throw nt(e,t),t}}ot(e),we(t)}(this)}enqueue(e){if(!1===Ne(this))throw yt("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");const t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError(`The stream (in ${t} state) is not in the readable state and cannot be enqueued to`);if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");e.buffer,function(e,t){const r=e._controlledReadableByteStream,o=t.buffer,n=t.byteOffset,i=t.byteLength,a=_(o);if(!0===qe(r))if(0===Pe(r))Ge(e,a,n,i);else{const e=new Uint8Array(a,n,i);ve(r,e,!1)}else!0===Te(r)?(Ge(e,a,n,i),et(e)):Ge(e,a,n,i);xe(e)}(this,e)}error(e){if(!1===Ne(this))throw yt("error");nt(this,e)}[le](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos[0].bytesFilled=0}v(this);const t=this._cancelAlgorithm(e);return ot(this),t}[ce](e){const t=this._controlledReadableByteStream;if(this._queueTotalSize>0){const t=this._queue.shift();let r;this._queueTotalSize-=t.byteLength,Xe(this);try{r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(ge(r,!1,e))}const r=this._autoAllocateChunkSize;if(void 0!==r){let e;try{e=new ArrayBuffer(r)}catch(e){return Promise.reject(e)}const t={buffer:e,byteOffset:0,byteLength:r,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(t)}const o=ye(t,e);return xe(this),o}}function Ne(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function Qe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function xe(e){!1!==function(e){const t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===qe(t)&&Pe(t)>0)return!0;if(!0===Te(t)&&Re(t)>0)return!0;if(it(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,xe(e))},t=>{nt(e,t)}).catch(w)):e._pullAgain=!0)}function He(e){Ze(e),e._pendingPullIntos=[]}function Ue(e,t){let r=!1;"closed"===e._state&&(r=!0);const o=Ve(t);"default"===t.readerType?ve(e,o,r):function(e,t,r){const o=e._reader._readIntoRequests.shift();o._resolve(ge(t,r,o._forAuthorCode))}(e,o,r)}function Ve(e){const t=e.bytesFilled,r=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,t/r)}function Ge(e,t,r,o){e._queue.push({buffer:t,byteOffset:r,byteLength:o}),e._queueTotalSize+=o}function Je(e,t){const r=t.elementSize,o=t.bytesFilled-t.bytesFilled%r,n=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),i=t.bytesFilled+n,a=i-i%r;let l=n,c=!1;a>o&&(l=a-t.bytesFilled,c=!0);const u=e._queue;for(;l>0;){const r=u[0],o=Math.min(l,r.byteLength),n=t.byteOffset+t.bytesFilled;s(t.buffer,n,r.buffer,r.byteOffset,o),r.byteLength===o?u.shift():(r.byteOffset+=o,r.byteLength-=o),e._queueTotalSize-=o,Ke(e,o,t),l-=o}return c}function Ke(e,t,r){Ze(e),r.bytesFilled+=t}function Xe(e){0===e._queueTotalSize&&!0===e._closeRequested?(ot(e),we(e._controlledReadableByteStream)):xe(e)}function Ze(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function et(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos[0];!0===Je(e,t)&&(rt(e),Ue(e._controlledReadableByteStream,t))}}function tt(e,t){const r=e._pendingPullIntos[0];if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,t){t.buffer=_(t.buffer);const r=e._controlledReadableByteStream;if(!0===Te(r))for(;Re(r)>0;)Ue(r,rt(e))}(e,r)}else!function(e,t,r){if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range");if(Ke(e,t,r),r.bytesFilled<r.elementSize)return;rt(e);const o=r.bytesFilled%r.elementSize;if(o>0){const t=r.byteOffset+r.bytesFilled,n=r.buffer.slice(t-o,t);Ge(e,n,0,n.byteLength)}r.buffer=_(r.buffer),r.bytesFilled-=o,Ue(e._controlledReadableByteStream,r),et(e)}(e,t,r);xe(e)}function rt(e){const t=e._pendingPullIntos.shift();return Ze(e),t}function ot(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function nt(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(He(e),v(e),ot(e),Se(r,t))}function it(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function at(e){if("object"!=typeof e||null===e)return!1;const t=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted").get;try{return t.call(e),!0}catch(e){return!1}}function st(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function lt(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function ct(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}function ut(e){e._closedPromise=new Promise((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function dt(e,t){ut(e),ft(e,t)}function ft(e,t){e._closedPromise.catch(()=>{}),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function _t(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function ht(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function bt(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function mt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function yt(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}class ByteLengthQueuingStrategy{constructor({highWaterMark:e}){i(this,"highWaterMark",e)}size(e){return e.byteLength}}class CountQueuingStrategy{constructor({highWaterMark:e}){i(this,"highWaterMark",e)}size(){return 1}}class TransformStream{constructor(e={},t={},r={}){const o=t.size;let n=t.highWaterMark;const i=r.size;let a=r.highWaterMark;if(void 0!==e.writableType)throw new RangeError("Invalid writable type specified");const s=b(o);if(void 0===n&&(n=1),n=h(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");const l=b(i);let c;void 0===a&&(a=0),a=h(a),function(e,t,r,o,n,i){function a(){return t}e._writable=function(e,t,r,o,n=1,i=(()=>1)){const a=Object.create(WritableStream.prototype);return q(a),$(a,Object.create(WritableStreamDefaultController.prototype),e,t,r,o,n,i),a}(a,function(t){return function(e,t){const r=e._transformStreamController;if(!0===e._backpressure){const o=e._backpressureChangePromise;return o.then(()=>{const o=e._writable,n=o._state;if("erroring"===n)throw o._storedError;return Tt(r,t)})}return Tt(r,t)}(e,t)},function(){return function(e){const t=e._readable,r=e._transformStreamController,o=r._flushAlgorithm();return Rt(r),o.then(()=>{if("errored"===t._state)throw t._storedError;const e=t._readableStreamController;!0===Ye(e)&&Le(e)}).catch(r=>{throw wt(e,r),t._storedError})}(e)},function(t){return function(e,t){return wt(e,t),Promise.resolve()}(e,t)},r,o),e._readable=de(a,function(){return function(e){return St(e,!1),e._backpressureChangePromise}(e)},function(t){return gt(e,t),Promise.resolve()},n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,St(e,!0),e._transformStreamController=void 0}(this,new Promise(e=>{c=e}),n,s,a,l),function(e,t){const r=Object.create(TransformStreamDefaultController.prototype);let o=e=>{try{return Pt(r,e),Promise.resolve()}catch(e){return Promise.reject(e)}};const n=t.transform;if(void 0!==n){if("function"!=typeof n)throw new TypeError("transform is not a method");o=(e=>f(n,t,[e,r]))}const i=u(t,"flush",0,[r]);!function(e,t,r,o){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=o}(e,r,o,i)}(this,e);const _=d(e,"start",[this._transformStreamController]);c(_)}get readable(){if(!1===pt(this))throw Et("readable");return this._readable}get writable(){if(!1===pt(this))throw Et("writable");return this._writable}}function pt(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function wt(e,t){De(e._readable._readableStreamController,t),gt(e,t)}function gt(e,t){Rt(e._transformStreamController),H(e._writable._writableStreamController,t),!0===e._backpressure&&St(e,!1)}function St(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(t=>{e._backpressureChangePromise_resolve=t}),e._backpressure=t}class TransformStreamDefaultController{constructor(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}get desiredSize(){if(!1===vt(this))throw qt("desiredSize");return Me(this._controlledTransformStream._readable._readableStreamController)}enqueue(e){if(!1===vt(this))throw qt("enqueue");Pt(this,e)}error(e){if(!1===vt(this))throw qt("error");!function(e,t){wt(e._controlledTransformStream,t)}(this,e)}terminate(){if(!1===vt(this))throw qt("terminate");!function(e){const t=e._controlledTransformStream,r=t._readable._readableStreamController;!0===Ye(r)&&Le(r);const o=new TypeError("TransformStream terminated");gt(t,o)}(this)}}function vt(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function Rt(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Pt(e,t){const r=e._controlledTransformStream,o=r._readable._readableStreamController;if(!1===Ye(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{Ie(o,t)}catch(e){throw gt(r,e),r._readable._storedError}(function(e){return!0!==ke(e)})(o)!==r._backpressure&&St(r,!0)}function Tt(e,t){return e._transformAlgorithm(t).catch(t=>{throw wt(e._controlledTransformStream,t),t})}function qt(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function Et(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}const Ct={ReadableStream:ReadableStream,WritableStream:WritableStream,ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,CountQueuingStrategy:CountQueuingStrategy,TransformStream:TransformStream};void 0!==r&&Object.assign(r,Ct),e.ReadableStream=ReadableStream,e.WritableStream=WritableStream,e.ByteLengthQueuingStrategy=ByteLengthQueuingStrategy,e.CountQueuingStrategy=CountQueuingStrategy,e.TransformStream=TransformStream,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=polyfill.min.js.map

@@ -1,2 +0,2 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e=e||self).WebStreamsPolyfill={})}(this,function(e){"use strict";const r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`,t=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function o(){}var n={default:o};const a=Number.isNaN||function(e){return e!=e};function i(e){return e&&e.default||e}i(n);var s=function(e,r){return e(r={exports:{}},r.exports),r.exports}(function(e,t){const o=r('is "detached" for our purposes');function n(e,r,t){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,r,t)}function i(e,r,t){try{return Promise.resolve(n(e,r,t))}catch(e){return Promise.reject(e)}}t.typeIsObject=(e=>"object"==typeof e&&null!==e||"function"==typeof e),t.createDataProperty=((e,r,t)=>{Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})}),t.createArrayFromList=(e=>e.slice()),t.ArrayBufferCopy=((e,r,t,o,n)=>{new Uint8Array(e).set(new Uint8Array(t,o,n),r)}),t.IsFiniteNonNegativeNumber=(e=>!1!==t.IsNonNegativeNumber(e)&&e!==1/0),t.IsNonNegativeNumber=(e=>"number"==typeof e&&(!a(e)&&!(e<0))),t.Call=n,t.CreateAlgorithmFromUnderlyingMethod=((e,r,t,o)=>{const n=e[r];if(void 0!==n){if("function"!=typeof n)throw new TypeError(`${n} is not a method`);switch(t){case 0:return()=>i(n,e,o);case 1:return r=>{const t=[r].concat(o);return i(n,e,t)}}}return()=>Promise.resolve()}),t.InvokeOrNoop=((e,r,t)=>{const o=e[r];if(void 0!==o)return n(o,e,t)}),t.PromiseCall=i,t.TransferArrayBuffer=(e=>{const r=e.slice();return Object.defineProperty(e,"byteLength",{get:()=>0}),e[o]=!0,r}),t.IsDetachedBuffer=(e=>o in e),t.ValidateAndNormalizeHighWaterMark=(e=>{if(e=Number(e),a(e)||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e}),t.MakeSizeAlgorithmFromSizeFunction=(e=>{if(void 0===e)return()=>1;if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return r=>e(r)}),t.PerformPromiseThen=((e,r,t)=>Promise.prototype.then.call(e,r,t)),t.WaitForAll=((e,r,o)=>{let n=!1;const a=e=>{!1===n&&(n=!0,o(e))};let i=0,s=0;const l=e.length,c=new Array(l);for(const o of e){const e=i,n=t=>{c[e]=t,++s===l&&r(c)};t.PerformPromiseThen(o,n,a),++i}}),t.WaitForAllPromise=((e,r,o)=>{let n,a;const i=new Promise((e,r)=>{n=e,a=r});void 0===o&&(o=(e=>{throw e}));return t.WaitForAll(e,e=>{try{const t=r(e);n(t)}catch(e){a(e)}},e=>{try{const r=o(e);n(r)}catch(e){a(e)}}),i})}),l=s.typeIsObject,c=s.createDataProperty,u=s.createArrayFromList,d=s.ArrayBufferCopy,f=s.IsFiniteNonNegativeNumber,m=s.IsNonNegativeNumber,h=s.Call,_=s.CreateAlgorithmFromUnderlyingMethod,b=s.InvokeOrNoop,y=s.PromiseCall;s.TransferArrayBuffer,s.IsDetachedBuffer;var p={TransferArrayBuffer:function(e){return e},IsDetachedBuffer:function(e){return!1},typeIsObject:l,createDataProperty:c,createArrayFromList:u,ArrayBufferCopy:d,IsFiniteNonNegativeNumber:f,IsNonNegativeNumber:m,Call:h,CreateAlgorithmFromUnderlyingMethod:_,InvokeOrNoop:b,PromiseCall:y,ValidateAndNormalizeHighWaterMark:s.ValidateAndNormalizeHighWaterMark,MakeSizeAlgorithmFromSizeFunction:s.MakeSizeAlgorithmFromSizeFunction,PerformPromiseThen:s.PerformPromiseThen,WaitForAll:s.WaitForAll,WaitForAllPromise:s.WaitForAllPromise};function w(){}w.AssertionError=o;var S=i({default:w}),g={rethrowAssertionErrorRejection:e=>{e&&e instanceof S.AssertionError&&setTimeout(()=>{throw e},0)}},v=i(p);const{IsFiniteNonNegativeNumber:P}=v;var R={DequeueValue:e=>{const r=e._queue.shift();return e._queueTotalSize-=r.size,e._queueTotalSize<0&&(e._queueTotalSize=0),r.value},EnqueueValueWithSize:(e,r,t)=>{if(t=Number(t),!P(t))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:r,size:t}),e._queueTotalSize+=t},PeekQueueValue:e=>{return e._queue[0].value},ResetQueue:e=>{e._queue=[],e._queueTotalSize=0}},T=i({default:o});T("streams:writable-stream:verbose");const{CreateAlgorithmFromUnderlyingMethod:C,InvokeOrNoop:q,ValidateAndNormalizeHighWaterMark:A,IsNonNegativeNumber:E,MakeSizeAlgorithmFromSizeFunction:j,typeIsObject:W}=v,{rethrowAssertionErrorRejection:O}=g,{DequeueValue:B,EnqueueValueWithSize:z,PeekQueueValue:k,ResetQueue:F}=R,I=r("[[AbortSteps]]"),D=r("[[ErrorSteps]]");class WritableStream{constructor(e={},r={}){L(this);const t=r.size;let o=r.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");const n=j(t);void 0===o&&(o=1),function(e,r,t,o){const n=Object.create(WritableStreamDefaultController.prototype);const a=C(r,"write",1,[n]),i=C(r,"close",0,[]),s=C(r,"abort",1,[]);ne(e,n,function(){return q(r,"start",[n])},a,i,s,t,o)}(this,e,o=A(o),n)}get locked(){if(!1===V(this))throw de("locked");return Y(this)}abort(e){return!1===V(this)?Promise.reject(de("abort")):!0===Y(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):$(this,e)}getWriter(){if(!1===V(this))throw de("getWriter");return M(this)}}var N={AcquireWritableStreamDefaultWriter:M,CreateWritableStream:function(e,r,t,o,n=1,a=(()=>1)){const i=Object.create(WritableStream.prototype);L(i);const s=Object.create(WritableStreamDefaultController.prototype);return ne(i,s,e,r,t,o,n,a),i},IsWritableStream:V,IsWritableStreamLocked:Y,WritableStream:WritableStream,WritableStreamAbort:$,WritableStreamDefaultControllerErrorIfNeeded:le,WritableStreamDefaultWriterCloseWithErrorPropagation:function(e){const r=e._ownerWritableStream,t=r._state;if(!0===G(r)||"closed"===t)return Promise.resolve();if("errored"===t)return Promise.reject(r._storedError);return Z(e)},WritableStreamDefaultWriterRelease:te,WritableStreamDefaultWriterWrite:oe,WritableStreamCloseQueuedOrInFlight:G};function M(e){return new WritableStreamDefaultWriter(e)}function L(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=[],e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function V(e){return!!W(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function Y(e){return void 0!==e._writer}function $(e,r){const t=e._state;if("closed"===t||"errored"===t)return Promise.resolve(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===t&&(o=!0,r=void 0);const n=new Promise((t,n)=>{e._pendingAbortRequest={_resolve:t,_reject:n,_reason:r,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&U(e,r),n}function H(e,r){"writable"!==e._state?x(e):U(e,r)}function U(e,r){const t=e._writableStreamController;e._state="erroring",e._storedError=r;const o=e._writer;void 0!==o&&re(o,r),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===t._started&&x(e)}function x(e){e._state="errored",e._writableStreamController[D]();const r=e._storedError;for(const t of e._writeRequests)t._reject(r);if(e._writeRequests=[],void 0===e._pendingAbortRequest)return void J(e);const t=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===t._wasAlreadyErroring)return t._reject(r),void J(e);e._writableStreamController[I](t._reason).then(()=>{t._resolve(),J(e)},r=>{t._reject(r),J(e)})}function Q(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const r=e._writer;void 0!==r&&function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(r)}function G(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function J(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const r=e._writer;void 0!==r&&(_e(r,e._storedError),r._closedPromise.catch(()=>{}))}function K(e,r){const t=e._writer;void 0!==t&&r!==e._backpressure&&(!0===r?function(e){e._readyPromise=new Promise((r,t)=>{e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(t):pe(t)),e._backpressure=r}class WritableStreamDefaultWriter{constructor(e){if(!1===V(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===Y(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("writable"===r)!1===G(e)&&!0===e._backpressure?function(e){e._readyPromise=new Promise((r,t)=>{e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(this):ye(this),he(this);else if("erroring"===r)be(this,e._storedError),this._readyPromise.catch(()=>{}),he(this);else if("closed"===r)ye(this),function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(this);else{const r=e._storedError;be(this,r),this._readyPromise.catch(()=>{}),function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}(this,r),this._closedPromise.catch(()=>{})}}get closed(){return!1===X(this)?Promise.reject(fe("closed")):this._closedPromise}get desiredSize(){if(!1===X(this))throw fe("desiredSize");if(void 0===this._ownerWritableStream)throw me("desiredSize");return function(e){const r=e._ownerWritableStream,t=r._state;if("errored"===t||"erroring"===t)return null;if("closed"===t)return 0;return ie(r._writableStreamController)}(this)}get ready(){return!1===X(this)?Promise.reject(fe("ready")):this._readyPromise}abort(e){return!1===X(this)?Promise.reject(fe("abort")):void 0===this._ownerWritableStream?Promise.reject(me("abort")):function(e,r){return $(e._ownerWritableStream,r)}(this,e)}close(){if(!1===X(this))return Promise.reject(fe("close"));const e=this._ownerWritableStream;return void 0===e?Promise.reject(me("close")):!0===G(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):Z(this)}releaseLock(){if(!1===X(this))throw fe("releaseLock");void 0!==this._ownerWritableStream&&te(this)}write(e){return!1===X(this)?Promise.reject(fe("write")):void 0===this._ownerWritableStream?Promise.reject(me("write to")):oe(this,e)}}function X(e){return!!W(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function Z(e){const r=e._ownerWritableStream,t=r._state;if("closed"===t||"errored"===t)return Promise.reject(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const o=new Promise((e,t)=>{const o={_resolve:e,_reject:t};r._closeRequest=o});return!0===r._backpressure&&"writable"===t&&pe(e),function(e){z(e,"close",0),se(e)}(r._writableStreamController),o}function ee(e,r){"pending"===e._closedPromiseState?_e(e,r):function(e,r){e._closedPromise=Promise.reject(r),e._closedPromiseState="rejected"}(e,r),e._closedPromise.catch(()=>{})}function re(e,r){"pending"===e._readyPromiseState?function(e,r){e._readyPromise_reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}(e,r):function(e,r){e._readyPromise=Promise.reject(r),e._readyPromiseState="rejected"}(e,r),e._readyPromise.catch(()=>{})}function te(e){const r=e._ownerWritableStream,t=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");re(e,t),ee(e,t),r._writer=void 0,e._ownerWritableStream=void 0}function oe(e,r){const t=e._ownerWritableStream,o=t._writableStreamController,n=function(e,r){try{return e._strategySizeAlgorithm(r)}catch(r){return le(e,r),1}}(o,r);if(t!==e._ownerWritableStream)return Promise.reject(me("write to"));const a=t._state;if("errored"===a)return Promise.reject(t._storedError);if(!0===G(t)||"closed"===a)return Promise.reject(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===a)return Promise.reject(t._storedError);const i=function(e){return new Promise((r,t)=>{const o={_resolve:r,_reject:t};e._writeRequests.push(o)})}(t);return function(e,r,t){const o={chunk:r};try{z(e,o,t)}catch(r){return void le(e,r)}const n=e._controlledWritableStream;if(!1===G(n)&&"writable"===n._state){const r=ce(e);K(n,r)}se(e)}(o,r,n),i}class WritableStreamDefaultController{constructor(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}error(e){if(!1===function(e){if(!W(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&ue(this,e)}[I](e){const r=this._abortAlgorithm(e);return ae(this),r}[D](){F(this)}}function ne(e,r,t,o,n,a,i,s){r._controlledWritableStream=e,e._writableStreamController=r,r._queue=void 0,r._queueTotalSize=void 0,F(r),r._started=!1,r._strategySizeAlgorithm=s,r._strategyHWM=i,r._writeAlgorithm=o,r._closeAlgorithm=n,r._abortAlgorithm=a;const l=ce(r);K(e,l);const c=t();Promise.resolve(c).then(()=>{r._started=!0,se(r)},t=>{r._started=!0,H(e,t)}).catch(O)}function ae(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function ie(e){return e._strategyHWM-e._queueTotalSize}function se(e){const r=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==r._inFlightWriteRequest)return;const t=r._state;if("closed"===t||"errored"===t)return;if("erroring"===t)return void x(r);if(0===e._queue.length)return;const o=k(e);"close"===o?function(e){const r=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(r),B(e);const t=e._closeAlgorithm();ae(e),t.then(()=>{Q(r)},e=>{!function(e,r){e._inFlightCloseRequest._reject(r),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(r),e._pendingAbortRequest=void 0),H(e,r)}(r,e)}).catch(O)}(e):function(e,r){const t=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(t),e._writeAlgorithm(r).then(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(t);const r=t._state;if(B(e),!1===G(t)&&"writable"===r){const r=ce(e);K(t,r)}se(e)},r=>{"writable"===t._state&&ae(e),function(e,r){e._inFlightWriteRequest._reject(r),e._inFlightWriteRequest=void 0,H(e,r)}(t,r)}).catch(O)}(e,o.chunk)}function le(e,r){"writable"===e._controlledWritableStream._state&&ue(e,r)}function ce(e){return ie(e)<=0}function ue(e,r){const t=e._controlledWritableStream;ae(e),U(t,r)}function de(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function fe(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function me(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function he(e){e._closedPromise=new Promise((r,t)=>{e._closedPromise_resolve=r,e._closedPromise_reject=t,e._closedPromiseState="pending"})}function _e(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function be(e,r){e._readyPromise=Promise.reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function ye(e){e._readyPromise=Promise.resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}function pe(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}var we=N.WritableStream;const{ArrayBufferCopy:Se,CreateAlgorithmFromUnderlyingMethod:ge,IsFiniteNonNegativeNumber:ve,InvokeOrNoop:Pe,IsDetachedBuffer:Re,TransferArrayBuffer:Te,ValidateAndNormalizeHighWaterMark:Ce,IsNonNegativeNumber:qe,MakeSizeAlgorithmFromSizeFunction:Ae,createArrayFromList:Ee,typeIsObject:je,WaitForAllPromise:We}=v,{rethrowAssertionErrorRejection:Oe}=g,{DequeueValue:Be,EnqueueValueWithSize:ze,ResetQueue:ke}=R,{AcquireWritableStreamDefaultWriter:Fe,IsWritableStream:Ie,IsWritableStreamLocked:De,WritableStreamAbort:Ne,WritableStreamDefaultWriterCloseWithErrorPropagation:Me,WritableStreamDefaultWriterRelease:Le,WritableStreamDefaultWriterWrite:Ve,WritableStreamCloseQueuedOrInFlight:Ye}=N,$e=r("[[CancelSteps]]"),He=r("[[PullSteps]]");class ReadableStream{constructor(e={},r={}){Ge(this);const o=r.size;let n=r.highWaterMark;const a=e.type;if("bytes"===String(a)){if(void 0!==o)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===n&&(n=0),function(e,r,o){const n=Object.create(ReadableByteStreamController.prototype);const a=ge(r,"pull",0,[n]),i=ge(r,"cancel",1,[]);let s=r.autoAllocateChunkSize;if(void 0!==s&&(s=Number(s),!1===t(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");Yr(e,n,function(){return Pe(r,"start",[n])},a,i,o,s)}(this,e,n=Ce(n))}else{if(void 0!==a)throw new RangeError("Invalid type is specified");{const r=Ae(o);void 0===n&&(n=1),function(e,r,t,o){const n=Object.create(ReadableStreamDefaultController.prototype);const a=ge(r,"pull",0,[n]),i=ge(r,"cancel",1,[]);Tr(e,n,function(){return Pe(r,"start",[n])},a,i,t,o)}(this,e,n=Ce(n),r)}}}get locked(){if(!1===Je(this))throw Hr("locked");return Ke(this)}cancel(e){return!1===Je(this)?Promise.reject(Hr("cancel")):!0===Ke(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):rr(this,e)}getReader({mode:e}={}){if(!1===Je(this))throw Hr("getReader");if(void 0===e)return xe(this);if("byob"===(e=String(e)))return function(e){return new ReadableStreamBYOBReader(e)}(this);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:r},{preventClose:t,preventAbort:o,preventCancel:n,signal:a}={}){if(!1===Je(this))throw Hr("pipeThrough");if(!1===Ie(e))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===Je(r))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(t=Boolean(t),o=Boolean(o),n=Boolean(n),void 0!==a&&!$r(a))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===Ke(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===De(e))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return Xe(this,e,t,o,n,a).catch(()=>{}),r}pipeTo(e,{preventClose:r,preventAbort:t,preventCancel:o,signal:n}={}){return!1===Je(this)?Promise.reject(Hr("pipeTo")):!1===Ie(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream")):(r=Boolean(r),t=Boolean(t),o=Boolean(o),void 0===n||$r(n)?!0===Ke(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===De(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Xe(this,e,r,t,o,n):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))}tee(){if(!1===Je(this))throw Hr("tee");const e=function(e,r){const t=xe(e);let o,n,a,i,s,l=!1,c=!1,u=!1;const d=new Promise(e=>{s=e});function f(){return _r(t).then(e=>{const r=e.value,t=e.done;if(!0===t&&!1===l&&(!1===c&&Sr(a._readableStreamController),!1===u&&Sr(i._readableStreamController),l=!0),!0===l)return;const o=r,n=r;!1===c&&gr(a._readableStreamController,o),!1===u&&gr(i._readableStreamController,n)})}function m(){}return a=Qe(m,f,function(r){if(c=!0,o=r,!0===u){const r=Ee([o,n]),t=rr(e,r);s(t)}return d}),i=Qe(m,f,function(r){if(u=!0,n=r,!0===c){const r=Ee([o,n]),t=rr(e,r);s(t)}return d}),t._closedPromise.catch(e=>{!0!==l&&(vr(a._readableStreamController,e),vr(i._readableStreamController,e),l=!0)}),[a,i]}(this);return Ee(e)}}var Ue={CreateReadableByteStream:function(e,r,t,o=0,n){const a=Object.create(ReadableStream.prototype);Ge(a);const i=Object.create(ReadableByteStreamController.prototype);return Yr(a,i,e,r,t,o,n),a},CreateReadableStream:Qe,ReadableStream:ReadableStream,IsReadableStreamDisturbed:function(e){return e._disturbed},ReadableStreamDefaultControllerClose:Sr,ReadableStreamDefaultControllerEnqueue:gr,ReadableStreamDefaultControllerError:vr,ReadableStreamDefaultControllerGetDesiredSize:Pr,ReadableStreamDefaultControllerHasBackpressure:function(e){if(!0===pr(e))return!1;return!0},ReadableStreamDefaultControllerCanCloseOrEnqueue:Rr};function xe(e){return new ReadableStreamDefaultReader(e)}function Qe(e,r,t,o=1,n=(()=>1)){const a=Object.create(ReadableStream.prototype);return Ge(a),Tr(a,Object.create(ReadableStreamDefaultController.prototype),e,r,t,o,n),a}function Ge(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Je(e){return!!je(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function Ke(e){return void 0!==e._reader}function Xe(e,r,t,o,n,a){const i=xe(e),s=Fe(r);let l=!1,c=Promise.resolve();return new Promise((u,d)=>{let f;if(void 0!==a){if(f=(()=>{const t=new DOMException("Aborted","AbortError"),a=[];!1===o&&a.push(()=>"writable"===r._state?Ne(r,t):Promise.resolve()),!1===n&&a.push(()=>"readable"===e._state?rr(e,t):Promise.resolve()),_(()=>We(a.map(e=>e()),e=>e),!0,t)}),!0===a.aborted)return void f();a.addEventListener("abort",f)}if(h(e,i._closedPromise,e=>{!1===o?_(()=>Ne(r,e),!0,e):b(!0,e)}),h(r,s._closedPromise,r=>{!1===n?_(()=>rr(e,r),!0,r):b(!0,r)}),function(e,r,t){"closed"===e._state?t():r.then(t).catch(Oe)}(e,i._closedPromise,()=>{!1===t?_(()=>Me(s)):b()}),!0===Ye(r)||"closed"===r._state){const r=new TypeError("the destination writable stream closed before all data could be piped to it");!1===n?_(()=>rr(e,r),!0,r):b(!0,r)}function m(){const e=c;return c.then(()=>e!==c?m():void 0)}function h(e,r,t){"errored"===e._state?t(e._storedError):r.catch(t).catch(Oe)}function _(e,t,o){function n(){e().then(()=>y(t,o),e=>y(!0,e)).catch(Oe)}!0!==l&&(l=!0,"writable"===r._state&&!1===Ye(r)?m().then(n):n())}function b(e,t){!0!==l&&(l=!0,"writable"===r._state&&!1===Ye(r)?m().then(()=>y(e,t)).catch(Oe):y(e,t))}function y(e,r){Le(s),hr(i),void 0!==a&&a.removeEventListener("abort",f),e?d(r):u(void 0)}new Promise((e,r)=>{!function t(o){o?e():(!0===l?Promise.resolve(!0):s._readyPromise.then(()=>_r(i).then(({value:e,done:r})=>!0===r||(c=Ve(s,e).catch(()=>{}),!1)))).then(t,r)}(!1)}).catch(e=>{c=Promise.resolve(),Oe(e)})})}function Ze(e,r){return new Promise((t,o)=>{const n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readIntoRequests.push(n)})}function er(e,r){return new Promise((t,o)=>{const n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readRequests.push(n)})}function rr(e,r){if(e._disturbed=!0,"closed"===e._state)return Promise.resolve(void 0);if("errored"===e._state)return Promise.reject(e._storedError);return tr(e),e._readableStreamController[$e](r).then(()=>void 0)}function tr(e){e._state="closed";const r=e._reader;if(void 0!==r){if(!0===dr(r)){for(const{_resolve:e,_forAuthorCode:t}of r._readRequests)e(or(void 0,!0,t));r._readRequests=[]}!function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(r)}}function or(e,r,t){let o=null;!0===t&&(o=Object.prototype);const n=Object.create(o);return Object.defineProperty(n,"value",{value:e,enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(n,"done",{value:r,enumerable:!0,writable:!0,configurable:!0}),n}function nr(e,r){e._state="errored",e._storedError=r;const t=e._reader;if(void 0!==t){if(!0===dr(t)){for(const e of t._readRequests)e._reject(r);t._readRequests=[]}else{for(const e of t._readIntoRequests)e._reject(r);t._readIntoRequests=[]}Qr(t,r),t._closedPromise.catch(()=>{})}}function ar(e,r,t){const o=e._reader._readRequests.shift();o._resolve(or(r,t,o._forAuthorCode))}function ir(e){return e._reader._readIntoRequests.length}function sr(e){return e._reader._readRequests.length}function lr(e){const r=e._reader;return void 0!==r&&!1!==ur(r)}function cr(e){const r=e._reader;return void 0!==r&&!1!==dr(r)}class ReadableStreamDefaultReader{constructor(e){if(!1===Je(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===Ke(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");fr(this,e),this._readRequests=[]}get closed(){return!1===dr(this)?Promise.reject(xr("closed")):this._closedPromise}cancel(e){return!1===dr(this)?Promise.reject(xr("cancel")):void 0===this._ownerReadableStream?Promise.reject(Ur("cancel")):mr(this,e)}read(){return!1===dr(this)?Promise.reject(xr("read")):void 0===this._ownerReadableStream?Promise.reject(Ur("read from")):_r(this,!0)}releaseLock(){if(!1===dr(this))throw xr("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");hr(this)}}}class ReadableStreamBYOBReader{constructor(e){if(!Je(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===Cr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(Ke(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");fr(this,e),this._readIntoRequests=[]}get closed(){return ur(this)?this._closedPromise:Promise.reject(Gr("closed"))}cancel(e){return ur(this)?void 0===this._ownerReadableStream?Promise.reject(Ur("cancel")):mr(this,e):Promise.reject(Gr("cancel"))}read(e){return ur(this)?void 0===this._ownerReadableStream?Promise.reject(Ur("read from")):ArrayBuffer.isView(e)?!0===Re(e.buffer)?Promise.reject(new TypeError("Cannot read into a view onto a detached ArrayBuffer")):0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,r,t=!1){const o=e._ownerReadableStream;if(o._disturbed=!0,"errored"===o._state)return Promise.reject(o._storedError);return function(e,r,t){const o=e._controlledReadableByteStream;let n=1;r.constructor!==DataView&&(n=r.constructor.BYTES_PER_ELEMENT);const a=r.constructor,i={buffer:Te(r.buffer),byteOffset:r.byteOffset,byteLength:r.byteLength,bytesFilled:0,elementSize:n,ctor:a,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(i),Ze(o,t);if("closed"===o._state){const e=new r.constructor(i.buffer,i.byteOffset,0);return Promise.resolve(or(e,!0,t))}if(e._queueTotalSize>0){if(!0===Br(e,i)){const r=Wr(i);return kr(e),Promise.resolve(or(r,!1,t))}if(!0===e._closeRequested){const r=new TypeError("Insufficient bytes to fill elements in the given buffer");return Lr(e,r),Promise.reject(r)}}e._pendingPullIntos.push(i);const s=Ze(o,t);return Ar(e),s}(o._readableStreamController,r,t)}(this,e,!0):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(Gr("read"))}releaseLock(){if(!ur(this))throw Gr("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");hr(this)}}}function ur(e){return!!je(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function dr(e){return!!je(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function fr(e,r){e._ownerReadableStream=r,r._reader=e,"readable"===r._state?function(e){e._closedPromise=new Promise((r,t)=>{e._closedPromise_resolve=r,e._closedPromise_reject=t})}(e):"closed"===r._state?function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e):(!function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e,r._storedError),e._closedPromise.catch(()=>{}))}function mr(e,r){return rr(e._ownerReadableStream,r)}function hr(e){"readable"===e._ownerReadableStream._state?Qr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,r){e._closedPromise=Promise.reject(r)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._closedPromise.catch(()=>{}),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function _r(e,r=!1){const t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?Promise.resolve(or(void 0,!0,r)):"errored"===t._state?Promise.reject(t._storedError):t._readableStreamController[He](r)}class ReadableStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){if(!1===br(this))throw Jr("desiredSize");return Pr(this)}close(){if(!1===br(this))throw Jr("close");if(!1===Rr(this))throw new TypeError("The stream is not in a state that permits close");Sr(this)}enqueue(e){if(!1===br(this))throw Jr("enqueue");if(!1===Rr(this))throw new TypeError("The stream is not in a state that permits enqueue");return gr(this,e)}error(e){if(!1===br(this))throw Jr("error");vr(this,e)}[$e](e){ke(this);const r=this._cancelAlgorithm(e);return wr(this),r}[He](e){const r=this._controlledReadableStream;if(this._queue.length>0){const t=Be(this);return!0===this._closeRequested&&0===this._queue.length?(wr(this),tr(r)):yr(this),Promise.resolve(or(t,!1,e))}const t=er(r,e);return yr(this),t}}function br(e){return!!je(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function yr(e){!1!==pr(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{if(e._pulling=!1,!0===e._pullAgain)return e._pullAgain=!1,yr(e)},r=>{vr(e,r)}).catch(Oe)):e._pullAgain=!0)}function pr(e){const r=e._controlledReadableStream;return!1!==Rr(e)&&(!1!==e._started&&(!0===Ke(r)&&sr(r)>0||Pr(e)>0))}function wr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Sr(e){const r=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(wr(e),tr(r))}function gr(e,r){const t=e._controlledReadableStream;if(!0===Ke(t)&&sr(t)>0)ar(t,r,!1);else{let t;try{t=e._strategySizeAlgorithm(r)}catch(r){throw vr(e,r),r}try{ze(e,r,t)}catch(r){throw vr(e,r),r}}yr(e)}function vr(e,r){const t=e._controlledReadableStream;"readable"===t._state&&(ke(e),wr(e),nr(t,r))}function Pr(e){const r=e._controlledReadableStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function Rr(e){const r=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===r}function Tr(e,r,t,o,n,a,i){r._controlledReadableStream=e,r._queue=void 0,r._queueTotalSize=void 0,ke(r),r._started=!1,r._closeRequested=!1,r._pullAgain=!1,r._pulling=!1,r._strategySizeAlgorithm=i,r._strategyHWM=a,r._pullAlgorithm=o,r._cancelAlgorithm=n,e._readableStreamController=r;const s=t();Promise.resolve(s).then(()=>{r._started=!0,yr(r)},e=>{vr(r,e)}).catch(Oe)}class ReadableStreamBYOBRequest{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===qr(this))throw Kr("view");return this._view}respond(e){if(!1===qr(this))throw Kr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!0===Re(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");!function(e,r){if(r=Number(r),!1===ve(r))throw new RangeError("bytesWritten must be a finite");Dr(e,r)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===qr(this))throw Kr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(!0===Re(e.buffer))throw new TypeError("The supplied view's buffer has been detached and so cannot be used as a response");!function(e,r){const t=e._pendingPullIntos[0];if(t.byteOffset+t.bytesFilled!==r.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(t.byteLength!==r.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");t.buffer=r.buffer,Dr(e,r.byteLength)}(this._associatedReadableByteStreamController,e)}}class ReadableByteStreamController{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===Cr(this))throw Xr("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos[0],r=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),t=Object.create(ReadableStreamBYOBRequest.prototype);!function(e,r,t){e._associatedReadableByteStreamController=r,e._view=t}(t,this,r),this._byobRequest=t}return this._byobRequest}get desiredSize(){if(!1===Cr(this))throw Xr("desiredSize");return Vr(this)}close(){if(!1===Cr(this))throw Xr("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const r=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){const r=e._pendingPullIntos[0];if(r.bytesFilled>0){const r=new TypeError("Insufficient bytes to fill elements in the given buffer");throw Lr(e,r),r}}Mr(e),tr(r)}(this)}enqueue(e){if(!1===Cr(this))throw Xr("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");const r=this._controlledReadableByteStream._state;if("readable"!==r)throw new TypeError(`The stream (in ${r} state) is not in the readable state and cannot be enqueued to`);if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");if(!0===Re(e.buffer))throw new TypeError("Cannot enqueue a view onto a detached ArrayBuffer");!function(e,r){const t=e._controlledReadableByteStream,o=r.buffer,n=r.byteOffset,a=r.byteLength,i=Te(o);if(!0===cr(t))if(0===sr(t))Or(e,i,n,a);else{const e=new Uint8Array(i,n,a);ar(t,e,!1)}else!0===lr(t)?(Or(e,i,n,a),Ir(e)):Or(e,i,n,a);Ar(e)}(this,e)}error(e){if(!1===Cr(this))throw Xr("error");Lr(this,e)}[$e](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos[0].bytesFilled=0}ke(this);const r=this._cancelAlgorithm(e);return Mr(this),r}[He](e){const r=this._controlledReadableByteStream;if(this._queueTotalSize>0){const r=this._queue.shift();let t;this._queueTotalSize-=r.byteLength,kr(this);try{t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(or(t,!1,e))}const t=this._autoAllocateChunkSize;if(void 0!==t){let e;try{e=new ArrayBuffer(t)}catch(e){return Promise.reject(e)}const r={buffer:e,byteOffset:0,byteLength:t,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(r)}const o=er(r,e);return Ar(this),o}}function Cr(e){return!!je(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function qr(e){return!!je(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function Ar(e){!1!==function(e){const r=e._controlledReadableByteStream;if("readable"!==r._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===cr(r)&&sr(r)>0)return!0;if(!0===lr(r)&&ir(r)>0)return!0;if(Vr(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,Ar(e))},r=>{Lr(e,r)}).catch(Oe)):e._pullAgain=!0)}function Er(e){Fr(e),e._pendingPullIntos=[]}function jr(e,r){let t=!1;"closed"===e._state&&(t=!0);const o=Wr(r);"default"===r.readerType?ar(e,o,t):function(e,r,t){const o=e._reader._readIntoRequests.shift();o._resolve(or(r,t,o._forAuthorCode))}(e,o,t)}function Wr(e){const r=e.bytesFilled,t=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,r/t)}function Or(e,r,t,o){e._queue.push({buffer:r,byteOffset:t,byteLength:o}),e._queueTotalSize+=o}function Br(e,r){const t=r.elementSize,o=r.bytesFilled-r.bytesFilled%t,n=Math.min(e._queueTotalSize,r.byteLength-r.bytesFilled),a=r.bytesFilled+n,i=a-a%t;let s=n,l=!1;i>o&&(s=i-r.bytesFilled,l=!0);const c=e._queue;for(;s>0;){const t=c[0],o=Math.min(s,t.byteLength),n=r.byteOffset+r.bytesFilled;Se(r.buffer,n,t.buffer,t.byteOffset,o),t.byteLength===o?c.shift():(t.byteOffset+=o,t.byteLength-=o),e._queueTotalSize-=o,zr(e,o,r),s-=o}return l}function zr(e,r,t){Fr(e),t.bytesFilled+=r}function kr(e){0===e._queueTotalSize&&!0===e._closeRequested?(Mr(e),tr(e._controlledReadableByteStream)):Ar(e)}function Fr(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function Ir(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const r=e._pendingPullIntos[0];!0===Br(e,r)&&(Nr(e),jr(e._controlledReadableByteStream,r))}}function Dr(e,r){const t=e._pendingPullIntos[0];if("closed"===e._controlledReadableByteStream._state){if(0!==r)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,r){r.buffer=Te(r.buffer);const t=e._controlledReadableByteStream;if(!0===lr(t))for(;ir(t)>0;)jr(t,Nr(e))}(e,t)}else!function(e,r,t){if(t.bytesFilled+r>t.byteLength)throw new RangeError("bytesWritten out of range");if(zr(e,r,t),t.bytesFilled<t.elementSize)return;Nr(e);const o=t.bytesFilled%t.elementSize;if(o>0){const r=t.byteOffset+t.bytesFilled,n=t.buffer.slice(r-o,r);Or(e,n,0,n.byteLength)}t.buffer=Te(t.buffer),t.bytesFilled-=o,jr(e._controlledReadableByteStream,t),Ir(e)}(e,r,t);Ar(e)}function Nr(e){const r=e._pendingPullIntos.shift();return Fr(e),r}function Mr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function Lr(e,r){const t=e._controlledReadableByteStream;"readable"===t._state&&(Er(e),ke(e),Mr(e),nr(t,r))}function Vr(e){const r=e._controlledReadableByteStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function Yr(e,r,t,o,n,a,i){r._controlledReadableByteStream=e,r._pullAgain=!1,r._pulling=!1,Er(r),r._queue=r._queueTotalSize=void 0,ke(r),r._closeRequested=!1,r._started=!1,r._strategyHWM=Ce(a),r._pullAlgorithm=o,r._cancelAlgorithm=n,r._autoAllocateChunkSize=i,r._pendingPullIntos=[],e._readableStreamController=r;const s=t();Promise.resolve(s).then(()=>{r._started=!0,Ar(r)},e=>{Lr(r,e)}).catch(Oe)}function $r(e){if("object"!=typeof e||null===e)return!1;const r=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted").get;try{return r.call(e),!0}catch(e){return!1}}function Hr(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function Ur(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function xr(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}function Qr(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function Gr(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Jr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Kr(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Xr(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}var Zr=Ue.ReadableStream;const{createDataProperty:et}=v;const{createDataProperty:rt}=v;T("streams:transform-stream:verbose");const{InvokeOrNoop:tt,CreateAlgorithmFromUnderlyingMethod:ot,PromiseCall:nt,typeIsObject:at,ValidateAndNormalizeHighWaterMark:it,IsNonNegativeNumber:st,MakeSizeAlgorithmFromSizeFunction:lt}=v,{CreateReadableStream:ct,ReadableStreamDefaultControllerClose:ut,ReadableStreamDefaultControllerEnqueue:dt,ReadableStreamDefaultControllerError:ft,ReadableStreamDefaultControllerGetDesiredSize:mt,ReadableStreamDefaultControllerHasBackpressure:ht,ReadableStreamDefaultControllerCanCloseOrEnqueue:_t}=Ue,{CreateWritableStream:bt,WritableStreamDefaultControllerErrorIfNeeded:yt}=N;class TransformStream{constructor(e={},r={},t={}){const o=r.size;let n=r.highWaterMark;const a=t.size;let i=t.highWaterMark;if(void 0!==e.writableType)throw new RangeError("Invalid writable type specified");const s=lt(o);if(void 0===n&&(n=1),n=it(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");const l=lt(a);let c;void 0===i&&(i=0),i=it(i),pt(this,new Promise(e=>{c=e}),n,s,i,l),function(e,r){const t=Object.create(TransformStreamDefaultController.prototype);let o=e=>{try{return Ct(t,e),Promise.resolve()}catch(e){return Promise.reject(e)}};const n=r.transform;if(void 0!==n){if("function"!=typeof n)throw new TypeError("transform is not a method");o=(e=>nt(n,r,[e,t]))}const a=ot(r,"flush",0,[t]);Rt(e,t,o,a)}(this,e);const u=tt(e,"start",[this._transformStreamController]);c(u)}get readable(){if(!1===wt(this))throw Et("readable");return this._readable}get writable(){if(!1===wt(this))throw Et("writable");return this._writable}}function pt(e,r,t,o,n,a){function i(){return r}e._writable=bt(i,function(r){return function(e,r){const t=e._transformStreamController;if(!0===e._backpressure){const o=e._backpressureChangePromise;return o.then(()=>{const o=e._writable,n=o._state;if("erroring"===n)throw o._storedError;return qt(t,r)})}return qt(t,r)}(e,r)},function(){return function(e){const r=e._readable,t=e._transformStreamController,o=t._flushAlgorithm();return Tt(t),o.then(()=>{if("errored"===r._state)throw r._storedError;const e=r._readableStreamController;!0===_t(e)&&ut(e)}).catch(t=>{throw St(e,t),r._storedError})}(e)},function(r){return function(e,r){return St(e,r),Promise.resolve()}(e,r)},t,o),e._readable=ct(i,function(){return function(e){return vt(e,!1),e._backpressureChangePromise}(e)},function(r){return gt(e,r),Promise.resolve()},n,a),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,vt(e,!0),e._transformStreamController=void 0}function wt(e){return!!at(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function St(e,r){ft(e._readable._readableStreamController,r),gt(e,r)}function gt(e,r){Tt(e._transformStreamController),yt(e._writable._writableStreamController,r),!0===e._backpressure&&vt(e,!1)}function vt(e,r){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(r=>{e._backpressureChangePromise_resolve=r}),e._backpressure=r}class TransformStreamDefaultController{constructor(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}get desiredSize(){if(!1===Pt(this))throw At("desiredSize");const e=this._controlledTransformStream._readable._readableStreamController;return mt(e)}enqueue(e){if(!1===Pt(this))throw At("enqueue");Ct(this,e)}error(e){if(!1===Pt(this))throw At("error");!function(e,r){St(e._controlledTransformStream,r)}(this,e)}terminate(){if(!1===Pt(this))throw At("terminate");!function(e){const r=e._controlledTransformStream,t=r._readable._readableStreamController;!0===_t(t)&&ut(t);const o=new TypeError("TransformStream terminated");gt(r,o)}(this)}}function Pt(e){return!!at(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function Rt(e,r,t,o){r._controlledTransformStream=e,e._transformStreamController=r,r._transformAlgorithm=t,r._flushAlgorithm=o}function Tt(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Ct(e,r){const t=e._controlledTransformStream,o=t._readable._readableStreamController;if(!1===_t(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{dt(o,r)}catch(e){throw gt(t,e),t._readable._storedError}ht(o)!==t._backpressure&&vt(t,!0)}function qt(e,r){return e._transformAlgorithm(r).catch(r=>{throw St(e._controlledTransformStream,r),r})}function At(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function Et(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}var jt={CreateTransformStream:function(e,r,t,o=1,n=(()=>1),a=0,i=(()=>1)){const s=Object.create(TransformStream.prototype);let l;pt(s,new Promise(e=>{l=e}),o,n,a,i),Rt(s,Object.create(TransformStreamDefaultController.prototype),r,t);const c=e();return l(c),s},TransformStream:TransformStream}.TransformStream;e.ReadableStream=Zr,e.WritableStream=we,e.ByteLengthQueuingStrategy=class ByteLengthQueuingStrategy{constructor({highWaterMark:e}){et(this,"highWaterMark",e)}size(e){return e.byteLength}},e.CountQueuingStrategy=class CountQueuingStrategy{constructor({highWaterMark:e}){rt(this,"highWaterMark",e)}size(){return 1}},e.TransformStream=jt,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.WebStreamsPolyfill={})}(this,function(e){"use strict";const r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:e=>`Symbol(${e})`,t=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};function o(){}var n={default:o};const i=Number.isNaN||function(e){return e!=e};function a(e){return e&&e.default||e}a(n);var s=function(e,r){return e(r={exports:{}},r.exports),r.exports}(function(e,t){const o=r('is "detached" for our purposes');function n(e,r,t){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,r,t)}function a(e,r,t){try{return Promise.resolve(n(e,r,t))}catch(e){return Promise.reject(e)}}t.typeIsObject=(e=>"object"==typeof e&&null!==e||"function"==typeof e),t.createDataProperty=((e,r,t)=>{Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})}),t.createArrayFromList=(e=>e.slice()),t.ArrayBufferCopy=((e,r,t,o,n)=>{new Uint8Array(e).set(new Uint8Array(t,o,n),r)}),t.IsFiniteNonNegativeNumber=(e=>!1!==t.IsNonNegativeNumber(e)&&e!==1/0),t.IsNonNegativeNumber=(e=>"number"==typeof e&&(!i(e)&&!(e<0))),t.Call=n,t.CreateAlgorithmFromUnderlyingMethod=((e,r,t,o)=>{const n=e[r];if(void 0!==n){if("function"!=typeof n)throw new TypeError(`${n} is not a method`);switch(t){case 0:return()=>a(n,e,o);case 1:return r=>{const t=[r].concat(o);return a(n,e,t)}}}return()=>Promise.resolve()}),t.InvokeOrNoop=((e,r,t)=>{const o=e[r];if(void 0!==o)return n(o,e,t)}),t.PromiseCall=a,t.TransferArrayBuffer=(e=>{const r=e.slice();return Object.defineProperty(e,"byteLength",{get:()=>0}),e[o]=!0,r}),t.IsDetachedBuffer=(e=>o in e),t.ValidateAndNormalizeHighWaterMark=(e=>{if(e=Number(e),i(e)||e<0)throw new RangeError("highWaterMark property of a queuing strategy must be non-negative and non-NaN");return e}),t.MakeSizeAlgorithmFromSizeFunction=(e=>{if(void 0===e)return()=>1;if("function"!=typeof e)throw new TypeError("size property of a queuing strategy must be a function");return r=>e(r)}),t.PerformPromiseThen=((e,r,t)=>Promise.prototype.then.call(e,r,t)),t.WaitForAll=((e,r,o)=>{let n=!1;const i=e=>{!1===n&&(n=!0,o(e))};let a=0,s=0;const l=e.length,c=new Array(l);for(const o of e){const e=a,n=t=>{c[e]=t,++s===l&&r(c)};t.PerformPromiseThen(o,n,i),++a}}),t.WaitForAllPromise=((e,r,o)=>{let n,i;const a=new Promise((e,r)=>{n=e,i=r});void 0===o&&(o=(e=>{throw e}));return t.WaitForAll(e,e=>{try{const t=r(e);n(t)}catch(e){i(e)}},e=>{try{const r=o(e);n(r)}catch(e){i(e)}}),a})});s.typeIsObject,s.createDataProperty,s.createArrayFromList,s.ArrayBufferCopy,s.IsFiniteNonNegativeNumber,s.IsNonNegativeNumber,s.Call,s.CreateAlgorithmFromUnderlyingMethod,s.InvokeOrNoop,s.PromiseCall,s.TransferArrayBuffer,s.IsDetachedBuffer,s.ValidateAndNormalizeHighWaterMark,s.MakeSizeAlgorithmFromSizeFunction,s.PerformPromiseThen,s.WaitForAll,s.WaitForAllPromise;function l(){}l.AssertionError=o;var c=a({default:l}),u={rethrowAssertionErrorRejection:e=>{e&&e instanceof c.AssertionError&&setTimeout(()=>{throw e},0)}};const{IsFiniteNonNegativeNumber:d}=s;var f={DequeueValue:e=>{const r=e._queue.shift();return e._queueTotalSize-=r.size,e._queueTotalSize<0&&(e._queueTotalSize=0),r.value},EnqueueValueWithSize:(e,r,t)=>{if(t=Number(t),!d(t))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:r,size:t}),e._queueTotalSize+=t},PeekQueueValue:e=>{return e._queue[0].value},ResetQueue:e=>{e._queue=[],e._queueTotalSize=0}},m=a({default:o});m("streams:writable-stream:verbose");const{CreateAlgorithmFromUnderlyingMethod:_,InvokeOrNoop:h,ValidateAndNormalizeHighWaterMark:b,IsNonNegativeNumber:y,MakeSizeAlgorithmFromSizeFunction:p,typeIsObject:w}=s,{rethrowAssertionErrorRejection:S}=u,{DequeueValue:g,EnqueueValueWithSize:v,PeekQueueValue:P,ResetQueue:R}=f,q=r("[[AbortSteps]]"),T=r("[[ErrorSteps]]");class WritableStream{constructor(e={},r={}){E(this);const t=r.size;let o=r.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");const n=p(t);void 0===o&&(o=1),function(e,r,t,o){const n=Object.create(WritableStreamDefaultController.prototype);const i=_(r,"write",1,[n]),a=_(r,"close",0,[]),s=_(r,"abort",1,[]);x(e,n,function(){return h(r,"start",[n])},i,a,s,t,o)}(this,e,o=b(o),n)}get locked(){if(!1===W(this))throw Z("locked");return A(this)}abort(e){return!1===W(this)?Promise.reject(Z("abort")):!0===A(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):O(this,e)}getWriter(){if(!1===W(this))throw Z("getWriter");return j(this)}}var C={AcquireWritableStreamDefaultWriter:j,CreateWritableStream:function(e,r,t,o,n=1,i=(()=>1)){const a=Object.create(WritableStream.prototype);E(a);const s=Object.create(WritableStreamDefaultController.prototype);return x(a,s,e,r,t,o,n,i),a},IsWritableStream:W,IsWritableStreamLocked:A,WritableStream:WritableStream,WritableStreamAbort:O,WritableStreamDefaultControllerErrorIfNeeded:J,WritableStreamDefaultWriterCloseWithErrorPropagation:function(e){const r=e._ownerWritableStream,t=r._state;if(!0===D(r)||"closed"===t)return Promise.resolve();if("errored"===t)return Promise.reject(r._storedError);return M(e)},WritableStreamDefaultWriterRelease:$,WritableStreamDefaultWriterWrite:H,WritableStreamCloseQueuedOrInFlight:D};function j(e){return new WritableStreamDefaultWriter(e)}function E(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=[],e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function W(e){return!!w(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function A(e){return void 0!==e._writer}function O(e,r){const t=e._state;if("closed"===t||"errored"===t)return Promise.resolve(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;let o=!1;"erroring"===t&&(o=!0,r=void 0);const n=new Promise((t,n)=>{e._pendingAbortRequest={_resolve:t,_reject:n,_reason:r,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&z(e,r),n}function B(e,r){"writable"!==e._state?k(e):z(e,r)}function z(e,r){const t=e._writableStreamController;e._state="erroring",e._storedError=r;const o=e._writer;void 0!==o&&Y(o,r),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===t._started&&k(e)}function k(e){e._state="errored",e._writableStreamController[T]();const r=e._storedError;for(const t of e._writeRequests)t._reject(r);if(e._writeRequests=[],void 0===e._pendingAbortRequest)return void I(e);const t=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===t._wasAlreadyErroring)return t._reject(r),void I(e);e._writableStreamController[q](t._reason).then(()=>{t._resolve(),I(e)},r=>{t._reject(r),I(e)})}function F(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";const r=e._writer;void 0!==r&&function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(r)}function D(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function I(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const r=e._writer;void 0!==r&&(oe(r,e._storedError),r._closedPromise.catch(()=>{}))}function N(e,r){const t=e._writer;void 0!==t&&r!==e._backpressure&&(!0===r?function(e){e._readyPromise=new Promise((r,t)=>{e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(t):ae(t)),e._backpressure=r}class WritableStreamDefaultWriter{constructor(e){if(!1===W(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===A(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("writable"===r)!1===D(e)&&!0===e._backpressure?function(e){e._readyPromise=new Promise((r,t)=>{e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}(this):ie(this),te(this);else if("erroring"===r)ne(this,e._storedError),this._readyPromise.catch(()=>{}),te(this);else if("closed"===r)ie(this),function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}(this);else{const r=e._storedError;ne(this,r),this._readyPromise.catch(()=>{}),function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}(this,r),this._closedPromise.catch(()=>{})}}get closed(){return!1===L(this)?Promise.reject(ee("closed")):this._closedPromise}get desiredSize(){if(!1===L(this))throw ee("desiredSize");if(void 0===this._ownerWritableStream)throw re("desiredSize");return function(e){const r=e._ownerWritableStream,t=r._state;if("errored"===t||"erroring"===t)return null;if("closed"===t)return 0;return U(r._writableStreamController)}(this)}get ready(){return!1===L(this)?Promise.reject(ee("ready")):this._readyPromise}abort(e){return!1===L(this)?Promise.reject(ee("abort")):void 0===this._ownerWritableStream?Promise.reject(re("abort")):function(e,r){return O(e._ownerWritableStream,r)}(this,e)}close(){if(!1===L(this))return Promise.reject(ee("close"));const e=this._ownerWritableStream;return void 0===e?Promise.reject(re("close")):!0===D(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):M(this)}releaseLock(){if(!1===L(this))throw ee("releaseLock");void 0!==this._ownerWritableStream&&$(this)}write(e){return!1===L(this)?Promise.reject(ee("write")):void 0===this._ownerWritableStream?Promise.reject(re("write to")):H(this,e)}}function L(e){return!!w(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function M(e){const r=e._ownerWritableStream,t=r._state;if("closed"===t||"errored"===t)return Promise.reject(new TypeError(`The stream (in ${t} state) is not in the writable state and cannot be closed`));const o=new Promise((e,t)=>{const o={_resolve:e,_reject:t};r._closeRequest=o});return!0===r._backpressure&&"writable"===t&&ae(e),function(e){v(e,"close",0),G(e)}(r._writableStreamController),o}function V(e,r){"pending"===e._closedPromiseState?oe(e,r):function(e,r){e._closedPromise=Promise.reject(r),e._closedPromiseState="rejected"}(e,r),e._closedPromise.catch(()=>{})}function Y(e,r){"pending"===e._readyPromiseState?function(e,r){e._readyPromise_reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}(e,r):function(e,r){e._readyPromise=Promise.reject(r),e._readyPromiseState="rejected"}(e,r),e._readyPromise.catch(()=>{})}function $(e){const r=e._ownerWritableStream,t=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");Y(e,t),V(e,t),r._writer=void 0,e._ownerWritableStream=void 0}function H(e,r){const t=e._ownerWritableStream,o=t._writableStreamController,n=function(e,r){try{return e._strategySizeAlgorithm(r)}catch(r){return J(e,r),1}}(o,r);if(t!==e._ownerWritableStream)return Promise.reject(re("write to"));const i=t._state;if("errored"===i)return Promise.reject(t._storedError);if(!0===D(t)||"closed"===i)return Promise.reject(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===i)return Promise.reject(t._storedError);const a=function(e){return new Promise((r,t)=>{const o={_resolve:r,_reject:t};e._writeRequests.push(o)})}(t);return function(e,r,t){const o={chunk:r};try{v(e,o,t)}catch(r){return void J(e,r)}const n=e._controlledWritableStream;if(!1===D(n)&&"writable"===n._state){const r=K(e);N(n,r)}G(e)}(o,r,n),a}class WritableStreamDefaultController{constructor(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}error(e){if(!1===function(e){if(!w(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream"))return!1;return!0}(this))throw new TypeError("WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController");"writable"===this._controlledWritableStream._state&&X(this,e)}[q](e){const r=this._abortAlgorithm(e);return Q(this),r}[T](){R(this)}}function x(e,r,t,o,n,i,a,s){r._controlledWritableStream=e,e._writableStreamController=r,r._queue=void 0,r._queueTotalSize=void 0,R(r),r._started=!1,r._strategySizeAlgorithm=s,r._strategyHWM=a,r._writeAlgorithm=o,r._closeAlgorithm=n,r._abortAlgorithm=i;const l=K(r);N(e,l);const c=t();Promise.resolve(c).then(()=>{r._started=!0,G(r)},t=>{r._started=!0,B(e,t)}).catch(S)}function Q(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function U(e){return e._strategyHWM-e._queueTotalSize}function G(e){const r=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==r._inFlightWriteRequest)return;const t=r._state;if("closed"===t||"errored"===t)return;if("erroring"===t)return void k(r);if(0===e._queue.length)return;const o=P(e);"close"===o?function(e){const r=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(r),g(e);const t=e._closeAlgorithm();Q(e),t.then(()=>{F(r)},e=>{!function(e,r){e._inFlightCloseRequest._reject(r),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(r),e._pendingAbortRequest=void 0),B(e,r)}(r,e)}).catch(S)}(e):function(e,r){const t=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(t),e._writeAlgorithm(r).then(()=>{!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(t);const r=t._state;if(g(e),!1===D(t)&&"writable"===r){const r=K(e);N(t,r)}G(e)},r=>{"writable"===t._state&&Q(e),function(e,r){e._inFlightWriteRequest._reject(r),e._inFlightWriteRequest=void 0,B(e,r)}(t,r)}).catch(S)}(e,o.chunk)}function J(e,r){"writable"===e._controlledWritableStream._state&&X(e,r)}function K(e){return U(e)<=0}function X(e,r){const t=e._controlledWritableStream;Q(e),z(t,r)}function Z(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function ee(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function re(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function te(e){e._closedPromise=new Promise((r,t)=>{e._closedPromise_resolve=r,e._closedPromise_reject=t,e._closedPromiseState="pending"})}function oe(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function ne(e,r){e._readyPromise=Promise.reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function ie(e){e._readyPromise=Promise.resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}function ae(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}var se=C.WritableStream;const{ArrayBufferCopy:le,CreateAlgorithmFromUnderlyingMethod:ce,IsFiniteNonNegativeNumber:ue,InvokeOrNoop:de,IsDetachedBuffer:fe,TransferArrayBuffer:me,ValidateAndNormalizeHighWaterMark:_e,IsNonNegativeNumber:he,MakeSizeAlgorithmFromSizeFunction:be,createArrayFromList:ye,typeIsObject:pe,WaitForAllPromise:we}=s,{rethrowAssertionErrorRejection:Se}=u,{DequeueValue:ge,EnqueueValueWithSize:ve,ResetQueue:Pe}=f,{AcquireWritableStreamDefaultWriter:Re,IsWritableStream:qe,IsWritableStreamLocked:Te,WritableStreamAbort:Ce,WritableStreamDefaultWriterCloseWithErrorPropagation:je,WritableStreamDefaultWriterRelease:Ee,WritableStreamDefaultWriterWrite:We,WritableStreamCloseQueuedOrInFlight:Ae}=C,Oe=r("[[CancelSteps]]"),Be=r("[[PullSteps]]");class ReadableStream{constructor(e={},r={}){De(this);const o=r.size;let n=r.highWaterMark;const i=e.type;if("bytes"===String(i)){if(void 0!==o)throw new RangeError("The strategy for a byte stream cannot have a size function");void 0===n&&(n=0),function(e,r,o){const n=Object.create(ReadableByteStreamController.prototype);const i=ce(r,"pull",0,[n]),a=ce(r,"cancel",1,[]);let s=r.autoAllocateChunkSize;if(void 0!==s&&(s=Number(s),!1===t(s)||s<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");Wr(e,n,function(){return de(r,"start",[n])},i,a,o,s)}(this,e,n=_e(n))}else{if(void 0!==i)throw new RangeError("Invalid type is specified");{const r=be(o);void 0===n&&(n=1),function(e,r,t,o){const n=Object.create(ReadableStreamDefaultController.prototype);const i=ce(r,"pull",0,[n]),a=ce(r,"cancel",1,[]);fr(e,n,function(){return de(r,"start",[n])},i,a,t,o)}(this,e,n=_e(n),r)}}}get locked(){if(!1===Ie(this))throw Ar("locked");return Ne(this)}cancel(e){return!1===Ie(this)?Promise.reject(Ar("cancel")):!0===Ne(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):Ve(this,e)}getReader({mode:e}={}){if(!1===Ie(this))throw Ar("getReader");if(void 0===e)return ke(this);if("byob"===(e=String(e)))return function(e){return new ReadableStreamBYOBReader(e)}(this);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:r},t){if(void 0===e||void 0===r)throw new TypeError("readable and writable arguments must be defined");return function(e){try{Promise.prototype.then.call(e,void 0,()=>{})}catch(e){}}(this.pipeTo(e,t)),r}pipeTo(e,{preventClose:r,preventAbort:t,preventCancel:o,signal:n}={}){if(!1===Ie(this))return Promise.reject(Ar("pipeTo"));if(!1===qe(e))return Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));if(r=Boolean(r),t=Boolean(t),o=Boolean(o),void 0!==n&&!function(e){if("object"!=typeof e||null===e)return!1;const r=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted").get;try{return r.call(e),!0}catch(e){return!1}}(n))return Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal"));if(!0===Ne(this))return Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream"));if(!0===Te(e))return Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream"));const i=ke(this),a=Re(e);let s=!1,l=Promise.resolve();return new Promise((c,u)=>{let d;if(void 0!==n){if(d=(()=>{const r=new DOMException("Aborted","AbortError"),n=[];!1===t&&n.push(()=>"writable"===e._state?Ce(e,r):Promise.resolve()),!1===o&&n.push(()=>"readable"===this._state?Ve(this,r):Promise.resolve()),_(()=>we(n.map(e=>e()),e=>e),!0,r)}),!0===n.aborted)return void d();n.addEventListener("abort",d)}if(m(this,i._closedPromise,r=>{!1===t?_(()=>Ce(e,r),!0,r):h(!0,r)}),m(e,a._closedPromise,e=>{!1===o?_(()=>Ve(this,e),!0,e):h(!0,e)}),function(e,r,t){"closed"===e._state?t():r.then(t).catch(Se)}(this,i._closedPromise,()=>{!1===r?_(()=>je(a)):h()}),!0===Ae(e)||"closed"===e._state){const e=new TypeError("the destination writable stream closed before all data could be piped to it");!1===o?_(()=>Ve(this,e),!0,e):h(!0,e)}function f(){const e=l;return l.then(()=>e!==l?f():void 0)}function m(e,r,t){"errored"===e._state?t(e._storedError):r.catch(t).catch(Se)}function _(r,t,o){function n(){r().then(()=>b(t,o),e=>b(!0,e)).catch(Se)}!0!==s&&(s=!0,"writable"===e._state&&!1===Ae(e)?f().then(n):n())}function h(r,t){!0!==s&&(s=!0,"writable"===e._state&&!1===Ae(e)?f().then(()=>b(r,t)).catch(Se):b(r,t))}function b(e,r){Ee(a),rr(i),void 0!==n&&n.removeEventListener("abort",d),e?u(r):c(void 0)}new Promise((e,r)=>{!function t(o){o?e():(!0===s?Promise.resolve(!0):a._readyPromise.then(()=>tr(i).then(({value:e,done:r})=>!0===r||(l=We(a,e).catch(()=>{}),!1)))).then(t,r)}(!1)}).catch(e=>{l=Promise.resolve(),Se(e)})})}tee(){if(!1===Ie(this))throw Ar("tee");const e=function(e,r){const t=ke(e);let o,n,i,a,s,l=!1,c=!1,u=!1;const d=new Promise(e=>{s=e});function f(){return tr(t).then(e=>{const r=e.value,t=e.done;if(!0===t&&!1===l&&(!1===c&&sr(i._readableStreamController),!1===u&&sr(a._readableStreamController),l=!0),!0===l)return;const o=r,n=r;!1===c&&lr(i._readableStreamController,o),!1===u&&lr(a._readableStreamController,n)})}function m(){}return i=Fe(m,f,function(r){if(c=!0,o=r,!0===u){const r=ye([o,n]),t=Ve(e,r);s(t)}return d}),a=Fe(m,f,function(r){if(u=!0,n=r,!0===c){const r=ye([o,n]),t=Ve(e,r);s(t)}return d}),t._closedPromise.catch(e=>{!0!==l&&(cr(i._readableStreamController,e),cr(a._readableStreamController,e),l=!0)}),[i,a]}(this);return ye(e)}}var ze={CreateReadableByteStream:function(e,r,t,o=0,n){const i=Object.create(ReadableStream.prototype);De(i);const a=Object.create(ReadableByteStreamController.prototype);return Wr(i,a,e,r,t,o,n),i},CreateReadableStream:Fe,ReadableStream:ReadableStream,IsReadableStreamDisturbed:function(e){return e._disturbed},ReadableStreamDefaultControllerClose:sr,ReadableStreamDefaultControllerEnqueue:lr,ReadableStreamDefaultControllerError:cr,ReadableStreamDefaultControllerGetDesiredSize:ur,ReadableStreamDefaultControllerHasBackpressure:function(e){if(!0===ir(e))return!1;return!0},ReadableStreamDefaultControllerCanCloseOrEnqueue:dr};function ke(e){return new ReadableStreamDefaultReader(e)}function Fe(e,r,t,o=1,n=(()=>1)){const i=Object.create(ReadableStream.prototype);return De(i),fr(i,Object.create(ReadableStreamDefaultController.prototype),e,r,t,o,n),i}function De(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function Ie(e){return!!pe(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function Ne(e){return void 0!==e._reader}function Le(e,r){return new Promise((t,o)=>{const n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readIntoRequests.push(n)})}function Me(e,r){return new Promise((t,o)=>{const n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readRequests.push(n)})}function Ve(e,r){if(e._disturbed=!0,"closed"===e._state)return Promise.resolve(void 0);if("errored"===e._state)return Promise.reject(e._storedError);return Ye(e),e._readableStreamController[Oe](r).then(()=>void 0)}function Ye(e){e._state="closed";const r=e._reader;if(void 0!==r){if(!0===Xe(r)){for(const{_resolve:e,_forAuthorCode:t}of r._readRequests)e($e(void 0,!0,t));r._readRequests=[]}!function(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(r)}}function $e(e,r,t){let o=null;!0===t&&(o=Object.prototype);const n=Object.create(o);return Object.defineProperty(n,"value",{value:e,enumerable:!0,writable:!0,configurable:!0}),Object.defineProperty(n,"done",{value:r,enumerable:!0,writable:!0,configurable:!0}),n}function He(e,r){e._state="errored",e._storedError=r;const t=e._reader;if(void 0!==t){if(!0===Xe(t)){for(const e of t._readRequests)e._reject(r);t._readRequests=[]}else{for(const e of t._readIntoRequests)e._reject(r);t._readIntoRequests=[]}zr(t,r),t._closedPromise.catch(()=>{})}}function xe(e,r,t){const o=e._reader._readRequests.shift();o._resolve($e(r,t,o._forAuthorCode))}function Qe(e){return e._reader._readIntoRequests.length}function Ue(e){return e._reader._readRequests.length}function Ge(e){const r=e._reader;return void 0!==r&&!1!==Ke(r)}function Je(e){const r=e._reader;return void 0!==r&&!1!==Xe(r)}class ReadableStreamDefaultReader{constructor(e){if(!1===Ie(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===Ne(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Ze(this,e),this._readRequests=[]}get closed(){return!1===Xe(this)?Promise.reject(Br("closed")):this._closedPromise}cancel(e){return!1===Xe(this)?Promise.reject(Br("cancel")):void 0===this._ownerReadableStream?Promise.reject(Or("cancel")):er(this,e)}read(){return!1===Xe(this)?Promise.reject(Br("read")):void 0===this._ownerReadableStream?Promise.reject(Or("read from")):tr(this,!0)}releaseLock(){if(!1===Xe(this))throw Br("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");rr(this)}}}class ReadableStreamBYOBReader{constructor(e){if(!Ie(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===mr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(Ne(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Ze(this,e),this._readIntoRequests=[]}get closed(){return Ke(this)?this._closedPromise:Promise.reject(kr("closed"))}cancel(e){return Ke(this)?void 0===this._ownerReadableStream?Promise.reject(Or("cancel")):er(this,e):Promise.reject(kr("cancel"))}read(e){return Ke(this)?void 0===this._ownerReadableStream?Promise.reject(Or("read from")):ArrayBuffer.isView(e)?!0===fe(e.buffer)?Promise.reject(new TypeError("Cannot read into a view onto a detached ArrayBuffer")):0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,r,t=!1){const o=e._ownerReadableStream;if(o._disturbed=!0,"errored"===o._state)return Promise.reject(o._storedError);return function(e,r,t){const o=e._controlledReadableByteStream;let n=1;r.constructor!==DataView&&(n=r.constructor.BYTES_PER_ELEMENT);const i=r.constructor,a={buffer:me(r.buffer),byteOffset:r.byteOffset,byteLength:r.byteLength,bytesFilled:0,elementSize:n,ctor:i,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(a),Le(o,t);if("closed"===o._state){const e=new r.constructor(a.buffer,a.byteOffset,0);return Promise.resolve($e(e,!0,t))}if(e._queueTotalSize>0){if(!0===Sr(e,a)){const r=pr(a);return vr(e),Promise.resolve($e(r,!1,t))}if(!0===e._closeRequested){const r=new TypeError("Insufficient bytes to fill elements in the given buffer");return jr(e,r),Promise.reject(r)}}e._pendingPullIntos.push(a);const s=Le(o,t);return hr(e),s}(o._readableStreamController,r,t)}(this,e,!0):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(kr("read"))}releaseLock(){if(!Ke(this))throw kr("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");rr(this)}}}function Ke(e){return!!pe(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Xe(e){return!!pe(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function Ze(e,r){e._ownerReadableStream=r,r._reader=e,"readable"===r._state?function(e){e._closedPromise=new Promise((r,t)=>{e._closedPromise_resolve=r,e._closedPromise_reject=t})}(e):"closed"===r._state?function(e){e._closedPromise=Promise.resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e):(!function(e,r){e._closedPromise=Promise.reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}(e,r._storedError),e._closedPromise.catch(()=>{}))}function er(e,r){return Ve(e._ownerReadableStream,r)}function rr(e){"readable"===e._ownerReadableStream._state?zr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,r){e._closedPromise=Promise.reject(r)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._closedPromise.catch(()=>{}),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function tr(e,r=!1){const t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?Promise.resolve($e(void 0,!0,r)):"errored"===t._state?Promise.reject(t._storedError):t._readableStreamController[Be](r)}class ReadableStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){if(!1===or(this))throw Fr("desiredSize");return ur(this)}close(){if(!1===or(this))throw Fr("close");if(!1===dr(this))throw new TypeError("The stream is not in a state that permits close");sr(this)}enqueue(e){if(!1===or(this))throw Fr("enqueue");if(!1===dr(this))throw new TypeError("The stream is not in a state that permits enqueue");return lr(this,e)}error(e){if(!1===or(this))throw Fr("error");cr(this,e)}[Oe](e){Pe(this);const r=this._cancelAlgorithm(e);return ar(this),r}[Be](e){const r=this._controlledReadableStream;if(this._queue.length>0){const t=ge(this);return!0===this._closeRequested&&0===this._queue.length?(ar(this),Ye(r)):nr(this),Promise.resolve($e(t,!1,e))}const t=Me(r,e);return nr(this),t}}function or(e){return!!pe(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function nr(e){!1!==ir(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{if(e._pulling=!1,!0===e._pullAgain)return e._pullAgain=!1,nr(e)},r=>{cr(e,r)}).catch(Se)):e._pullAgain=!0)}function ir(e){const r=e._controlledReadableStream;return!1!==dr(e)&&(!1!==e._started&&(!0===Ne(r)&&Ue(r)>0||ur(e)>0))}function ar(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function sr(e){const r=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(ar(e),Ye(r))}function lr(e,r){const t=e._controlledReadableStream;if(!0===Ne(t)&&Ue(t)>0)xe(t,r,!1);else{let t;try{t=e._strategySizeAlgorithm(r)}catch(r){throw cr(e,r),r}try{ve(e,r,t)}catch(r){throw cr(e,r),r}}nr(e)}function cr(e,r){const t=e._controlledReadableStream;"readable"===t._state&&(Pe(e),ar(e),He(t,r))}function ur(e){const r=e._controlledReadableStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function dr(e){const r=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===r}function fr(e,r,t,o,n,i,a){r._controlledReadableStream=e,r._queue=void 0,r._queueTotalSize=void 0,Pe(r),r._started=!1,r._closeRequested=!1,r._pullAgain=!1,r._pulling=!1,r._strategySizeAlgorithm=a,r._strategyHWM=i,r._pullAlgorithm=o,r._cancelAlgorithm=n,e._readableStreamController=r;const s=t();Promise.resolve(s).then(()=>{r._started=!0,nr(r)},e=>{cr(r,e)}).catch(Se)}class ReadableStreamBYOBRequest{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===_r(this))throw Dr("view");return this._view}respond(e){if(!1===_r(this))throw Dr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!0===fe(this._view.buffer))throw new TypeError("The BYOB request's buffer has been detached and so cannot be used as a response");!function(e,r){if(r=Number(r),!1===ue(r))throw new RangeError("bytesWritten must be a finite");qr(e,r)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===_r(this))throw Dr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");if(!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(!0===fe(e.buffer))throw new TypeError("The supplied view's buffer has been detached and so cannot be used as a response");!function(e,r){const t=e._pendingPullIntos[0];if(t.byteOffset+t.bytesFilled!==r.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(t.byteLength!==r.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");t.buffer=r.buffer,qr(e,r.byteLength)}(this._associatedReadableByteStreamController,e)}}class ReadableByteStreamController{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===mr(this))throw Ir("byobRequest");if(void 0===this._byobRequest&&this._pendingPullIntos.length>0){const e=this._pendingPullIntos[0],r=new Uint8Array(e.buffer,e.byteOffset+e.bytesFilled,e.byteLength-e.bytesFilled),t=Object.create(ReadableStreamBYOBRequest.prototype);!function(e,r,t){e._associatedReadableByteStreamController=r,e._view=t}(t,this,r),this._byobRequest=t}return this._byobRequest}get desiredSize(){if(!1===mr(this))throw Ir("desiredSize");return Er(this)}close(){if(!1===mr(this))throw Ir("close");if(!0===this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");const e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError(`The stream (in ${e} state) is not in the readable state and cannot be closed`);!function(e){const r=e._controlledReadableByteStream;if(e._queueTotalSize>0)return void(e._closeRequested=!0);if(e._pendingPullIntos.length>0){const r=e._pendingPullIntos[0];if(r.bytesFilled>0){const r=new TypeError("Insufficient bytes to fill elements in the given buffer");throw jr(e,r),r}}Cr(e),Ye(r)}(this)}enqueue(e){if(!1===mr(this))throw Ir("enqueue");if(!0===this._closeRequested)throw new TypeError("stream is closed or draining");const r=this._controlledReadableByteStream._state;if("readable"!==r)throw new TypeError(`The stream (in ${r} state) is not in the readable state and cannot be enqueued to`);if(!ArrayBuffer.isView(e))throw new TypeError("You can only enqueue array buffer views when using a ReadableByteStreamController");if(!0===fe(e.buffer))throw new TypeError("Cannot enqueue a view onto a detached ArrayBuffer");!function(e,r){const t=e._controlledReadableByteStream,o=r.buffer,n=r.byteOffset,i=r.byteLength,a=me(o);if(!0===Je(t))if(0===Ue(t))wr(e,a,n,i);else{const e=new Uint8Array(a,n,i);xe(t,e,!1)}else!0===Ge(t)?(wr(e,a,n,i),Rr(e)):wr(e,a,n,i);hr(e)}(this,e)}error(e){if(!1===mr(this))throw Ir("error");jr(this,e)}[Oe](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos[0].bytesFilled=0}Pe(this);const r=this._cancelAlgorithm(e);return Cr(this),r}[Be](e){const r=this._controlledReadableByteStream;if(this._queueTotalSize>0){const r=this._queue.shift();let t;this._queueTotalSize-=r.byteLength,vr(this);try{t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve($e(t,!1,e))}const t=this._autoAllocateChunkSize;if(void 0!==t){let e;try{e=new ArrayBuffer(t)}catch(e){return Promise.reject(e)}const r={buffer:e,byteOffset:0,byteLength:t,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(r)}const o=Me(r,e);return hr(this),o}}function mr(e){return!!pe(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function _r(e){return!!pe(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function hr(e){!1!==function(e){const r=e._controlledReadableByteStream;if("readable"!==r._state)return!1;if(!0===e._closeRequested)return!1;if(!1===e._started)return!1;if(!0===Je(r)&&Ue(r)>0)return!0;if(!0===Ge(r)&&Qe(r)>0)return!0;if(Er(e)>0)return!0;return!1}(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,hr(e))},r=>{jr(e,r)}).catch(Se)):e._pullAgain=!0)}function br(e){Pr(e),e._pendingPullIntos=[]}function yr(e,r){let t=!1;"closed"===e._state&&(t=!0);const o=pr(r);"default"===r.readerType?xe(e,o,t):function(e,r,t){const o=e._reader._readIntoRequests.shift();o._resolve($e(r,t,o._forAuthorCode))}(e,o,t)}function pr(e){const r=e.bytesFilled,t=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,r/t)}function wr(e,r,t,o){e._queue.push({buffer:r,byteOffset:t,byteLength:o}),e._queueTotalSize+=o}function Sr(e,r){const t=r.elementSize,o=r.bytesFilled-r.bytesFilled%t,n=Math.min(e._queueTotalSize,r.byteLength-r.bytesFilled),i=r.bytesFilled+n,a=i-i%t;let s=n,l=!1;a>o&&(s=a-r.bytesFilled,l=!0);const c=e._queue;for(;s>0;){const t=c[0],o=Math.min(s,t.byteLength),n=r.byteOffset+r.bytesFilled;le(r.buffer,n,t.buffer,t.byteOffset,o),t.byteLength===o?c.shift():(t.byteOffset+=o,t.byteLength-=o),e._queueTotalSize-=o,gr(e,o,r),s-=o}return l}function gr(e,r,t){Pr(e),t.bytesFilled+=r}function vr(e){0===e._queueTotalSize&&!0===e._closeRequested?(Cr(e),Ye(e._controlledReadableByteStream)):hr(e)}function Pr(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function Rr(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const r=e._pendingPullIntos[0];!0===Sr(e,r)&&(Tr(e),yr(e._controlledReadableByteStream,r))}}function qr(e,r){const t=e._pendingPullIntos[0];if("closed"===e._controlledReadableByteStream._state){if(0!==r)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream");!function(e,r){r.buffer=me(r.buffer);const t=e._controlledReadableByteStream;if(!0===Ge(t))for(;Qe(t)>0;)yr(t,Tr(e))}(e,t)}else!function(e,r,t){if(t.bytesFilled+r>t.byteLength)throw new RangeError("bytesWritten out of range");if(gr(e,r,t),t.bytesFilled<t.elementSize)return;Tr(e);const o=t.bytesFilled%t.elementSize;if(o>0){const r=t.byteOffset+t.bytesFilled,n=t.buffer.slice(r-o,r);wr(e,n,0,n.byteLength)}t.buffer=me(t.buffer),t.bytesFilled-=o,yr(e._controlledReadableByteStream,t),Rr(e)}(e,r,t);hr(e)}function Tr(e){const r=e._pendingPullIntos.shift();return Pr(e),r}function Cr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function jr(e,r){const t=e._controlledReadableByteStream;"readable"===t._state&&(br(e),Pe(e),Cr(e),He(t,r))}function Er(e){const r=e._controlledReadableByteStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function Wr(e,r,t,o,n,i,a){r._controlledReadableByteStream=e,r._pullAgain=!1,r._pulling=!1,br(r),r._queue=r._queueTotalSize=void 0,Pe(r),r._closeRequested=!1,r._started=!1,r._strategyHWM=_e(i),r._pullAlgorithm=o,r._cancelAlgorithm=n,r._autoAllocateChunkSize=a,r._pendingPullIntos=[],e._readableStreamController=r;const s=t();Promise.resolve(s).then(()=>{r._started=!0,hr(r)},e=>{jr(r,e)}).catch(Se)}function Ar(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function Or(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function Br(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}function zr(e,r){e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function kr(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function Fr(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function Dr(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function Ir(e){return new TypeError(`ReadableByteStreamController.prototype.${e} can only be used on a ReadableByteStreamController`)}var Nr=ze.ReadableStream;const{createDataProperty:Lr}=s;const{createDataProperty:Mr}=s;m("streams:transform-stream:verbose");const{InvokeOrNoop:Vr,CreateAlgorithmFromUnderlyingMethod:Yr,PromiseCall:$r,typeIsObject:Hr,ValidateAndNormalizeHighWaterMark:xr,IsNonNegativeNumber:Qr,MakeSizeAlgorithmFromSizeFunction:Ur}=s,{CreateReadableStream:Gr,ReadableStreamDefaultControllerClose:Jr,ReadableStreamDefaultControllerEnqueue:Kr,ReadableStreamDefaultControllerError:Xr,ReadableStreamDefaultControllerGetDesiredSize:Zr,ReadableStreamDefaultControllerHasBackpressure:et,ReadableStreamDefaultControllerCanCloseOrEnqueue:rt}=ze,{CreateWritableStream:tt,WritableStreamDefaultControllerErrorIfNeeded:ot}=C;class TransformStream{constructor(e={},r={},t={}){const o=r.size;let n=r.highWaterMark;const i=t.size;let a=t.highWaterMark;if(void 0!==e.writableType)throw new RangeError("Invalid writable type specified");const s=Ur(o);if(void 0===n&&(n=1),n=xr(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");const l=Ur(i);let c;void 0===a&&(a=0),a=xr(a),nt(this,new Promise(e=>{c=e}),n,s,a,l),function(e,r){const t=Object.create(TransformStreamDefaultController.prototype);let o=e=>{try{return ft(t,e),Promise.resolve()}catch(e){return Promise.reject(e)}};const n=r.transform;if(void 0!==n){if("function"!=typeof n)throw new TypeError("transform is not a method");o=(e=>$r(n,r,[e,t]))}const i=Yr(r,"flush",0,[t]);ut(e,t,o,i)}(this,e);const u=Vr(e,"start",[this._transformStreamController]);c(u)}get readable(){if(!1===it(this))throw ht("readable");return this._readable}get writable(){if(!1===it(this))throw ht("writable");return this._writable}}function nt(e,r,t,o,n,i){function a(){return r}e._writable=tt(a,function(r){return function(e,r){const t=e._transformStreamController;if(!0===e._backpressure){const o=e._backpressureChangePromise;return o.then(()=>{const o=e._writable,n=o._state;if("erroring"===n)throw o._storedError;return mt(t,r)})}return mt(t,r)}(e,r)},function(){return function(e){const r=e._readable,t=e._transformStreamController,o=t._flushAlgorithm();return dt(t),o.then(()=>{if("errored"===r._state)throw r._storedError;const e=r._readableStreamController;!0===rt(e)&&Jr(e)}).catch(t=>{throw at(e,t),r._storedError})}(e)},function(r){return function(e,r){return at(e,r),Promise.resolve()}(e,r)},t,o),e._readable=Gr(a,function(){return function(e){return lt(e,!1),e._backpressureChangePromise}(e)},function(r){return st(e,r),Promise.resolve()},n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,lt(e,!0),e._transformStreamController=void 0}function it(e){return!!Hr(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function at(e,r){Xr(e._readable._readableStreamController,r),st(e,r)}function st(e,r){dt(e._transformStreamController),ot(e._writable._writableStreamController,r),!0===e._backpressure&&lt(e,!1)}function lt(e,r){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(r=>{e._backpressureChangePromise_resolve=r}),e._backpressure=r}class TransformStreamDefaultController{constructor(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}get desiredSize(){if(!1===ct(this))throw _t("desiredSize");const e=this._controlledTransformStream._readable._readableStreamController;return Zr(e)}enqueue(e){if(!1===ct(this))throw _t("enqueue");ft(this,e)}error(e){if(!1===ct(this))throw _t("error");!function(e,r){at(e._controlledTransformStream,r)}(this,e)}terminate(){if(!1===ct(this))throw _t("terminate");!function(e){const r=e._controlledTransformStream,t=r._readable._readableStreamController;!0===rt(t)&&Jr(t);const o=new TypeError("TransformStream terminated");st(r,o)}(this)}}function ct(e){return!!Hr(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function ut(e,r,t,o){r._controlledTransformStream=e,e._transformStreamController=r,r._transformAlgorithm=t,r._flushAlgorithm=o}function dt(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function ft(e,r){const t=e._controlledTransformStream,o=t._readable._readableStreamController;if(!1===rt(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{Kr(o,r)}catch(e){throw st(t,e),t._readable._storedError}et(o)!==t._backpressure&&lt(t,!0)}function mt(e,r){return e._transformAlgorithm(r).catch(r=>{throw at(e._controlledTransformStream,r),r})}function _t(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function ht(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}var bt={CreateTransformStream:function(e,r,t,o=1,n=(()=>1),i=0,a=(()=>1)){const s=Object.create(TransformStream.prototype);let l;nt(s,new Promise(e=>{l=e}),o,n,i,a),ut(s,Object.create(TransformStreamDefaultController.prototype),r,t);const c=e();return l(c),s},TransformStream:TransformStream}.TransformStream;e.ReadableStream=Nr,e.WritableStream=se,e.ByteLengthQueuingStrategy=class ByteLengthQueuingStrategy{constructor({highWaterMark:e}){Lr(this,"highWaterMark",e)}size(e){return e.byteLength}},e.CountQueuingStrategy=class CountQueuingStrategy{constructor({highWaterMark:e}){Mr(this,"highWaterMark",e)}size(){return 1}},e.TransformStream=bt,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ponyfill.es6.min.js.map
{
"name": "@mattiasbuelens/web-streams-polyfill",
"version": "0.2.1",
"version": "0.3.0",
"description": "Web Streams, based on the WHATWG spec reference implementation",

@@ -8,8 +8,12 @@ "main": "dist/polyfill",

"module": "dist/polyfill.mjs",
"types": "types/polyfill.d.ts",
"types": "dist/types/polyfill.d.ts",
"scripts": {
"test": "node --expose_gc run-web-platform-tests.js",
"lint": "eslint \"*.js\" \"build/**/*.js\" \"src/**/*.js\"",
"build": "rollup -c",
"prebuild": "git submodule update --init --recursive",
"test": "npm run test:types && npm run test:wpt",
"test:wpt": "node --expose_gc run-web-platform-tests.js",
"pretest:wpt": "git submodule update --init --recursive",
"test:types": "tsc -p ./test/types/tsconfig.json",
"lint": "eslint \"src/**/*.ts\"",
"build": "npm run build:types && npm run build:bundle",
"build:bundle": "rollup -c",
"build:types": "rollup -c rollup-types.config.js",
"prepare": "npm run build"

@@ -19,3 +23,3 @@ },

"dist",
"types",
"es6",
"ponyfill"

@@ -44,23 +48,14 @@ ],

"homepage": "https://github.com/MattiasBuelens/web-streams-polyfill#readme",
"dependencies": {
"@types/whatwg-streams": "^0.0.7"
},
"devDependencies": {
"@babel/core": "^7.2.0",
"@babel/plugin-transform-for-of": "^7.2.0",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/preset-env": "^7.2.0",
"eslint": "^5.11.1",
"@typescript-eslint/eslint-plugin": "^1.3.0",
"eslint": "^5.14.1",
"micromatch": "^3.1.10",
"rollup": "^1.0.0",
"rollup-plugin-alias": "^1.5.1",
"rollup-plugin-babel": "^4.2.0",
"rollup-plugin-commonjs": "^9.2.0",
"rollup": "^1.2.1",
"rollup-plugin-dts": "^0.12.0",
"rollup-plugin-inject": "^2.2.0",
"rollup-plugin-strip": "^1.2.0",
"rollup-plugin-terser": "^3.0.0",
"rollup-pluginutils": "^2.3.3",
"typescript": "^3.2.2",
"rollup-plugin-strip": "^1.2.1",
"rollup-plugin-terser": "^4.0.4",
"typescript": "^3.3.3",
"wpt-runner": "^2.7.0"
}
}

@@ -5,3 +5,3 @@ {

"module": "../../dist/ponyfill.es6.mjs",
"types": "../../types/polyfill.d.ts"
"types": "../../dist/types/polyfill.d.ts"
}

@@ -5,3 +5,3 @@ {

"module": "../dist/ponyfill.mjs",
"types": "../types/polyfill.d.ts"
"types": "../dist/types/polyfill.d.ts"
}
# web-streams-polyfill
Web Streams, based on the WHATWG spec reference implementation.
[![Join the chat at https://gitter.im/web-streams-polyfill/Lobby](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/web-streams-polyfill/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![build status](https://api.travis-ci.com/MattiasBuelens/web-streams-polyfill.svg?branch=master)](https://travis-ci.com/MattiasBuelens/web-streams-polyfill)
[![npm version](https://img.shields.io/npm/v/@mattiasbuelens/web-streams-polyfill.svg)](https://www.npmjs.com/package/@mattiasbuelens/web-streams-polyfill)
[![license](https://img.shields.io/npm/l/@mattiasbuelens/web-streams-polyfill.svg)](https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/LICENSE)
[![Join the chat at https://gitter.im/web-streams-polyfill/Lobby](https://badges.gitter.im/web-streams-polyfill/Lobby.svg)](https://gitter.im/web-streams-polyfill/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Links
- [Official spec](https://streams.spec.whatwg.org/)
- [Reference implementation](https://github.com/whatwg/streams)
- [Official spec][spec]
- [Reference implementation][ref-impl]
## Usage
This project comes in three variants:
This library comes in four variants:
* `@mattiasbuelens/web-streams-polyfill`: a polyfill that replaces the native stream implementations.
Recommended for use in web apps through a `<script>` tag.
* `@mattiasbuelens/web-streams-polyfill/es6`: a polyfill targeting ES2015+ environments.
Recommended for use in web apps targeting modern browsers through a `<script>` tag.
* `@mattiasbuelens/web-streams-polyfill/ponyfill`: a [ponyfill] that provides

@@ -18,8 +26,12 @@ the stream implementations without replacing any globals.

* `@mattiasbuelens/web-streams-polyfill/ponyfill/es6`: a ponyfill targeting ES2015+ environments.
Recommended for use in modern Node applications, or in web apps targeting modern browsers.
Recommended for use in modern Node applications, or in web libraries targeting modern browsers.
Each variant also includes the [type definitions for WHATWG streams from DefinitelyTyped][types-streams].
Each variant also includes TypeScript type definitions, compatible with the DOM type definitions for streams included in TypeScript.
Usage as a polyfill:
```html
<!-- unpkg cdn -->
<script src="https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"></script>
<!-- self hosted -->
<script src="/path/to/web-streams-polyfill/dist/polyfill.min.js"></script>

@@ -30,3 +42,3 @@ <script>

```
Usage as a Node library:
Usage as a Node module:
```js

@@ -49,4 +61,10 @@ var streams = require("@mattiasbuelens/web-streams-polyfill/ponyfill");

The `ponyfill/es6` variant works in any ES2015-compatible environment.
The `polyfill/es6` and `ponyfill/es6` variants work in any ES2015-compatible environment.
### Compliance
The polyfill implements [version `1116de06e9` (29 Nov 2018)](https://streams.spec.whatwg.org/commit-snapshots/1116de06e94bf4406c60b1e766111dfd8bc7bfcd/) of the streams specification.
The type definitions are compatible with the built-in stream types of TypeScript 3.3.
### Contributors

@@ -59,7 +77,7 @@

[spec]: https://streams.spec.whatwg.org
[ref-impl]: https://github.com/whatwg/streams
[ponyfill]: https://github.com/sindresorhus/ponyfill
[types-streams]: https://www.npmjs.com/package/@types/whatwg-streams
[promise-support]: https://kangax.github.io/compat-table/es6/#test-Promise
[promise-polyfill]: https://www.npmjs.com/package/promise-polyfill
[creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc