@mattiasbuelens/web-streams-polyfill
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -5,3 +5,3 @@ # Changelog | ||
> - 💥 Breaking Change | ||
> - 👓 Spec Compliancy | ||
> - 👓 Spec Compliance | ||
> - 🚀 New Feature | ||
@@ -13,2 +13,9 @@ > - 🐛 Bug Fix | ||
## v0.3.2 (2019-03-10) | ||
* 🚀 Add `@@asyncIterator` to `ReadableStream` ([#11](https://github.com/MattiasBuelens/web-streams-polyfill/pull/11)) | ||
* 🚀 Add `polyfill/es2018` and `ponyfill/es2018` variants ([#11](https://github.com/MattiasBuelens/web-streams-polyfill/pull/11)) | ||
* 🐛 Fix using unsupported `Object.assign` on Internet Explorer | ||
* 👓 Align with [spec version `2c8f35e`](https://github.com/whatwg/streams/tree/2c8f35ed23451ffc9b32ec37b56def4a5349abb1/) ([#11](https://github.com/MattiasBuelens/web-streams-polyfill/pull/11), [#12](https://github.com/MattiasBuelens/web-streams-polyfill/pull/12)) | ||
## v0.3.1 (2019-02-25) | ||
@@ -29,3 +36,3 @@ | ||
* 🐛 Do not copy `ArrayBuffer` when transferring chunk to readable byte stream ([#3](https://github.com/MattiasBuelens/web-streams-polyfill/issues/3), [#4](https://github.com/MattiasBuelens/web-streams-polyfill/pull/4)) | ||
* 👓 Align with [spec version `1116de06e9`](https://github.com/whatwg/streams/tree/1116de06e94bf4406c60b1e766111dfd8bc7bfcd/) | ||
* 👓 Align with [spec version `1116de0`](https://github.com/whatwg/streams/tree/1116de06e94bf4406c60b1e766111dfd8bc7bfcd/) | ||
@@ -35,3 +42,3 @@ ## v0.2.0 (2018-11-15) | ||
* 🐛 Avoid long promise chains in `ReadableStream.pipeTo()` ([whatwg/streams#968](https://github.com/whatwg/streams/pull/968)) | ||
* 👓 Align with [spec version `46c3b89dd3`](https://github.com/whatwg/streams/tree/46c3b89dd3aff28b2fc381dd1d397c12b4fb8a16/) | ||
* 👓 Align with [spec version `46c3b89`](https://github.com/whatwg/streams/tree/46c3b89dd3aff28b2fc381dd1d397c12b4fb8a16/) | ||
@@ -41,2 +48,2 @@ ## v0.1.0 (2018-08-15) | ||
* 🚀 Initial release | ||
* 👓 Align with [spec version `78cfd1e22b`](https://github.com/whatwg/streams/tree/78cfd1e22b717ce7e6d3aae4e36de0ef9101356e/) | ||
* 👓 Align with [spec version `78cfd1e`](https://github.com/whatwg/streams/tree/78cfd1e22b717ce7e6d3aae4e36de0ef9101356e/) |
@@ -1,2 +0,2 @@ | ||
!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})}); | ||
!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}const p=function(){};function w(e){const t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function g(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 S(e){e._queue=[],e._queueTotalSize=0}const v=t("[[AbortSteps]]"),R=t("[[ErrorSteps]]");class WritableStream{constructor(e={},t={}){T(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,[]);Y(e,n,function(){return d(t,"start",[n])},i,a,s,r,o)}(this,e,o=h(o),n)}get locked(){if(!1===q(this))throw V("locked");return j(this)}abort(e){return!1===q(this)?Promise.reject(V("abort")):!0===j(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):E(this,e)}getWriter(){if(!1===q(this))throw V("getWriter");return P(this)}}function P(e){return new WritableStreamDefaultWriter(e)}function T(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 q(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function j(e){return void 0!==e._writer}function E(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&&A(e,t),n}function C(e,t){"writable"!==e._state?W(e):A(e,t)}function A(e,t){const r=e._writableStreamController;e._state="erroring",e._storedError=t;const o=e._writer;void 0!==o&&L(o,t),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===r._started&&W(e)}function W(e){e._state="errored",e._writableStreamController[R]();const t=e._storedError;for(const r of e._writeRequests)r._reject(t);if(e._writeRequests=[],void 0===e._pendingAbortRequest)return void B(e);const r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,!0===r._wasAlreadyErroring)return r._reject(t),void B(e);e._writableStreamController[v](r._reason).then(()=>{r._resolve(),B(e)},t=>{r._reject(t),B(e)})}function O(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function B(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);const t=e._writer;void 0!==t&&Z(t,e._storedError)}function z(e,t){const r=e._writer;void 0!==r&&t!==e._backpressure&&(!0===t?function(e){te(e)}(r):ie(r)),e._backpressure=t}class WritableStreamDefaultWriter{constructor(e){if(!1===q(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===j(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?te(this):oe(this),K(this);else if("erroring"===t)re(this,e._storedError),K(this);else if("closed"===t)oe(this),function(e){K(e),ee(e)}(this);else{const t=e._storedError;re(this,t),X(this,t)}}get closed(){return!1===k(this)?Promise.reject(G("closed")):this._closedPromise}get desiredSize(){if(!1===k(this))throw G("desiredSize");if(void 0===this._ownerWritableStream)throw J("desiredSize");return function(e){const t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return N(t._writableStreamController)}(this)}get ready(){return!1===k(this)?Promise.reject(G("ready")):this._readyPromise}abort(e){return!1===k(this)?Promise.reject(G("abort")):void 0===this._ownerWritableStream?Promise.reject(J("abort")):function(e,t){return E(e._ownerWritableStream,t)}(this,e)}close(){if(!1===k(this))return Promise.reject(G("close"));const e=this._ownerWritableStream;return void 0===e?Promise.reject(J("close")):!0===O(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):I(this)}releaseLock(){if(!1===k(this))throw G("releaseLock");void 0!==this._ownerWritableStream&&D(this)}write(e){return!1===k(this)?Promise.reject(G("write")):void 0===this._ownerWritableStream?Promise.reject(J("write to")):M(this,e)}}function k(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function I(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&&ie(e),function(e){g(e,"close",0),x(e)}(t._writableStreamController),o}function F(e,t){"pending"===e._closedPromiseState?Z(e,t):function(e,t){X(e,t)}(e,t)}function L(e,t){"pending"===e._readyPromiseState?ne(e,t):function(e,t){re(e,t)}(e,t)}function D(e){const t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");L(e,r),F(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function M(e,t){const r=e._ownerWritableStream,o=r._writableStreamController,n=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return Q(e,t),1}}(o,t);if(r!==e._ownerWritableStream)return Promise.reject(J("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{g(e,o,r)}catch(t){return void Q(e,t)}const n=e._controlledWritableStream;if(!1===O(n)&&"writable"===n._state){const t=H(e);z(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&&U(this,e)}[v](e){const t=this._abortAlgorithm(e);return $(this),t}[R](){S(this)}}function Y(e,t,r,o,n,i,a,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,S(t),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=a,t._writeAlgorithm=o,t._closeAlgorithm=n,t._abortAlgorithm=i;const l=H(t);z(e,l);const c=r();Promise.resolve(c).then(()=>{t._started=!0,x(t)},r=>{t._started=!0,C(e,r)}).catch(p)}function $(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function N(e){return e._strategyHWM-e._queueTotalSize}function x(e){const t=e._controlledWritableStream;if(!1===e._started)return;if(void 0!==t._inFlightWriteRequest)return;if("erroring"===t._state)return void W(t);if(0===e._queue.length)return;const r=function(e){return e._queue[0].value}(e);"close"===r?function(e){const t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),w(e);const r=e._closeAlgorithm();$(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&&ee(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),C(e,t)}(t,e)}).catch(p)}(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(w(e),!1===O(r)&&"writable"===t){const t=H(e);z(r,t)}x(e)},t=>{"writable"===r._state&&$(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,C(e,t)}(r,t)}).catch(p)}(e,r.chunk)}function Q(e,t){"writable"===e._controlledWritableStream._state&&U(e,t)}function H(e){return N(e)<=0}function U(e,t){const r=e._controlledWritableStream;$(e),A(r,t)}function V(e){return new TypeError(`WritableStream.prototype.${e} can only be used on a WritableStream`)}function G(e){return new TypeError(`WritableStreamDefaultWriter.prototype.${e} can only be used on a WritableStreamDefaultWriter`)}function J(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function K(e){e._closedPromise=new Promise((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"})}function X(e,t){K(e),Z(e,t)}function Z(e,t){e._closedPromise.catch(()=>{}),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function ee(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}function te(e){e._readyPromise=new Promise((t,r)=>{e._readyPromise_resolve=t,e._readyPromise_reject=r}),e._readyPromiseState="pending"}function re(e,t){te(e),ne(e,t)}function oe(e){te(e),ie(e)}function ne(e,t){e._readyPromise.catch(()=>{}),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function ie(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}const ae=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};let se;"symbol"==typeof t.asyncIterator&&(se={[t.asyncIterator](){return this}},Object.defineProperty(se,t.asyncIterator,{enumerable:!1}));const le=t("[[CancelSteps]]"),ce=t("[[PullSteps]]");class ReadableStream{constructor(e={},t={}){_e(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===ae(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,t._byobRequest=void 0,t._queue=t._queueTotalSize=void 0,S(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,Ue(t)},e=>{it(t,e)}).catch(p)}(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,[]);xe(e,n,function(){return d(t,"start",[n])},i,a,r,o)}(this,e,o=h(o),t)}}}get locked(){if(!1===he(this))throw lt("locked");return be(this)}cancel(e){return!1===he(this)?Promise.reject(lt("cancel")):!0===be(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):ge(this,e)}getReader({mode:e}={}){if(!1===he(this))throw lt("getReader");if(void 0===e)return de(this,!0);if("byob"===(e=String(e)))return function(e,t=!1){const r=new ReadableStreamBYOBReader(e);return r._forAuthorCode=t,r}(this,!0);throw new RangeError("Invalid mode is specified")}pipeThrough({writable:e,readable:t},{preventClose:r,preventAbort:o,preventCancel:n,signal:i}={}){if(!1===he(this))throw lt("pipeThrough");if(!1===q(e))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===he(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&&!st(i))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===be(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===j(e))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return ye(this,e,r,o,n,i).catch(()=>{}),t}pipeTo(e,{preventClose:t,preventAbort:r,preventCancel:o,signal:n}={}){return!1===he(this)?Promise.reject(lt("pipeTo")):!1===q(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||st(n)?!0===be(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===j(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):ye(this,e,t,r,o,n):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))}tee(){if(!1===he(this))throw lt("tee");const e=function(e,t){const r=de(e);let o,n,i,s,l,c=!1,u=!1,d=!1;const f=new Promise(e=>{l=e});function _(){return ze(r).then(e=>{if(!0===c)return;const t=e.done;if(!0===t)return!1===u&&De(i._readableStreamController),!1===d&&De(s._readableStreamController),void(c=!0);const r=e.value,o=r,n=r;!1===u&&Me(i._readableStreamController,o),!1===d&&Me(s._readableStreamController,n)})}function h(){}return i=fe(h,_,function(t){if(u=!0,o=t,!0===d){const t=a([o,n]),r=ge(e,t);l(r)}return f}),s=fe(h,_,function(t){if(d=!0,n=t,!0===u){const t=a([o,n]),r=ge(e,t);l(r)}return f}),r._closedPromise.catch(e=>{Ye(i._readableStreamController,e),Ye(s._readableStreamController,e)}),[i,s]}(this);return a(e)}getIterator({preventCancel:e}={}){if(!1===he(this))throw lt("getIterator");const t=de(this),r=Object.create(ue);return r._asyncIteratorReader=t,r._preventCancel=Boolean(e),r}}const ue={next(){if(!1===me(this))return Promise.reject(ct("next"));const e=this._asyncIteratorReader;return void 0===e._ownerReadableStream?Promise.reject(ut("iterate")):ze(e).then(t=>{const r=t.done;return r&&Be(e),ve(t.value,r,!0)})},return(e){if(!1===me(this))return Promise.reject(ct("next"));const t=this._asyncIteratorReader;if(void 0===t._ownerReadableStream)return Promise.reject(ut("finish iterating"));if(t._readRequests.length>0)return Promise.reject(new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled"));if(!1===this._preventCancel){const r=Oe(t,e);return Be(t),r.then(()=>ve(e,!0,!0))}return Be(t),Promise.resolve(ve(e,!0,!0))}};function de(e,t=!1){const r=new ReadableStreamDefaultReader(e);return r._forAuthorCode=t,r}function fe(e,t,r,o=1,n=(()=>1)){const i=Object.create(ReadableStream.prototype);return _e(i),xe(i,Object.create(ReadableStreamDefaultController.prototype),e,t,r,o,n),i}function _e(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function he(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function be(e){return void 0!==e._reader}function me(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorReader")}function ye(e,t,r,o,n,i){const a=de(e),s=P(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?E(t,r):Promise.resolve()),!1===n&&i.push(()=>"readable"===e._state?ge(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(()=>E(t,e),!0,e):m(!0,e)}),h(t,s._closedPromise,t=>{!1===n?b(()=>ge(e,t),!0,t):m(!0,t)}),function(e,t,r){"closed"===e._state?r():t.then(r).catch(p)}(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):I(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(()=>ge(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(p)}function b(e,r,o){function n(){e().then(()=>w(r,o),e=>w(!0,e)).catch(p)}!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(()=>w(e,r)).catch(p):w(e,r))}function w(e,t){D(s),Be(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(()=>ze(a).then(({value:e,done:t})=>!0===t||(c=M(s,e).catch(()=>{}),!1)))).then(r,t)}(!1)}).catch(p)})}function pe(e){return new Promise((t,r)=>{const o={_resolve:t,_reject:r};e._reader._readIntoRequests.push(o)})}function we(e){return new Promise((t,r)=>{const o={_resolve:t,_reject:r};e._reader._readRequests.push(o)})}function ge(e,t){if(e._disturbed=!0,"closed"===e._state)return Promise.resolve(void 0);if("errored"===e._state)return Promise.reject(e._storedError);return Se(e),e._readableStreamController[le](t).then(()=>void 0)}function Se(e){e._state="closed";const t=e._reader;if(void 0!==t){if(Ae(t)){for(const{_resolve:e}of t._readRequests)e(ve(void 0,!0,t._forAuthorCode));t._readRequests=[]}bt(t)}}function ve(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 Re(e,t){e._state="errored",e._storedError=t;const r=e._reader;if(void 0!==r){if(Ae(r)){for(const e of r._readRequests)e._reject(t);r._readRequests=[]}else{for(const e of r._readIntoRequests)e._reject(t);r._readIntoRequests=[]}ht(r,t)}}function Pe(e,t,r){const o=e._reader;o._readRequests.shift()._resolve(ve(t,r,o._forAuthorCode))}function Te(e){return e._reader._readIntoRequests.length}function qe(e){return e._reader._readRequests.length}function je(e){const t=e._reader;return void 0!==t&&!!Ce(t)}function Ee(e){const t=e._reader;return void 0!==t&&!!Ae(t)}void 0!==se&&Object.setPrototypeOf(ue,se),Object.defineProperty(ue,"next",{enumerable:!1}),Object.defineProperty(ue,"return",{enumerable:!1}),"symbol"==typeof t.asyncIterator&&Object.defineProperty(ReadableStream.prototype,t.asyncIterator,{value:ReadableStream.prototype.getIterator,enumerable:!1,writable:!0,configurable:!0});class ReadableStreamDefaultReader{constructor(e){if(!1===he(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===be(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");We(this,e),this._readRequests=[]}get closed(){return Ae(this)?this._closedPromise:Promise.reject(dt("closed"))}cancel(e){return Ae(this)?void 0===this._ownerReadableStream?Promise.reject(ut("cancel")):Oe(this,e):Promise.reject(dt("cancel"))}read(){return Ae(this)?void 0===this._ownerReadableStream?Promise.reject(ut("read from")):ze(this):Promise.reject(dt("read"))}releaseLock(){if(!Ae(this))throw dt("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");Be(this)}}}class ReadableStreamBYOBReader{constructor(e){if(!he(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===Qe(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(be(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");We(this,e),this._readIntoRequests=[]}get closed(){return Ce(this)?this._closedPromise:Promise.reject(mt("closed"))}cancel(e){return Ce(this)?void 0===this._ownerReadableStream?Promise.reject(ut("cancel")):Oe(this,e):Promise.reject(mt("cancel"))}read(e){return Ce(this)?void 0===this._ownerReadableStream?Promise.reject(ut("read from")):ArrayBuffer.isView(e)?(e.buffer,0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,t){const r=e._ownerReadableStream;if(r._disturbed=!0,"errored"===r._state)return Promise.reject(r._storedError);return function(e,t){const r=e._controlledReadableByteStream;let o=1;t.constructor!==DataView&&(o=t.constructor.BYTES_PER_ELEMENT);const n=t.constructor,i={buffer:_(t.buffer),byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:o,ctor:n,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(i),pe(r);if("closed"===r._state){const e=new n(i.buffer,i.byteOffset,0);return Promise.resolve(ve(e,!0,r._reader._forAuthorCode))}if(e._queueTotalSize>0){if(!0===Ke(e,i)){const t=Ge(i);return Ze(e),Promise.resolve(ve(t,!1,r._reader._forAuthorCode))}if(!0===e._closeRequested){const t=new TypeError("Insufficient bytes to fill elements in the given buffer");return it(e,t),Promise.reject(t)}}e._pendingPullIntos.push(i);const a=pe(r);return Ue(e),a}(r._readableStreamController,t)}(this,e)):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(mt("read"))}releaseLock(){if(!Ce(this))throw mt("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");Be(this)}}}function Ce(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Ae(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function We(e,t){e._forAuthorCode=!0,e._ownerReadableStream=t,t._reader=e,"readable"===t._state?ft(e):"closed"===t._state?function(e){ft(e),bt(e)}(e):_t(e,t._storedError)}function Oe(e,t){return ge(e._ownerReadableStream,t)}function Be(e){"readable"===e._ownerReadableStream._state?ht(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){_t(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 ze(e){const t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?Promise.resolve(ve(void 0,!0,e._forAuthorCode)):"errored"===t._state?Promise.reject(t._storedError):t._readableStreamController[ce]()}class ReadableStreamDefaultController{constructor(){throw new TypeError}get desiredSize(){if(!1===ke(this))throw yt("desiredSize");return $e(this)}close(){if(!1===ke(this))throw yt("close");if(!1===Ne(this))throw new TypeError("The stream is not in a state that permits close");De(this)}enqueue(e){if(!1===ke(this))throw yt("enqueue");if(!1===Ne(this))throw new TypeError("The stream is not in a state that permits enqueue");return Me(this,e)}error(e){if(!1===ke(this))throw yt("error");Ye(this,e)}[le](e){S(this);const t=this._cancelAlgorithm(e);return Le(this),t}[ce](){const e=this._controlledReadableStream;if(this._queue.length>0){const t=w(this);return!0===this._closeRequested&&0===this._queue.length?(Le(this),Se(e)):Ie(this),Promise.resolve(ve(t,!1,e._reader._forAuthorCode))}const t=we(e);return Ie(this),t}}function ke(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function Ie(e){!1!==Fe(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(()=>{e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,Ie(e))},t=>{Ye(e,t)}).catch(p)):e._pullAgain=!0)}function Fe(e){const t=e._controlledReadableStream;return!1!==Ne(e)&&(!1!==e._started&&(!0===be(t)&&qe(t)>0||$e(e)>0))}function Le(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function De(e){const t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Le(e),Se(t))}function Me(e,t){const r=e._controlledReadableStream;if(!0===be(r)&&qe(r)>0)Pe(r,t,!1);else{let r;try{r=e._strategySizeAlgorithm(t)}catch(t){throw Ye(e,t),t}try{g(e,t,r)}catch(t){throw Ye(e,t),t}}Ie(e)}function Ye(e,t){const r=e._controlledReadableStream;"readable"===r._state&&(S(e),Le(e),Re(r,t))}function $e(e){const t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Ne(e){const t=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===t}function xe(e,t,r,o,n,i,a){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,S(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,Ie(t)},e=>{Ye(t,e)}).catch(p)}class ReadableStreamBYOBRequest{constructor(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}get view(){if(!1===He(this))throw pt("view");return this._view}respond(e){if(!1===He(this))throw pt("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");rt(e,t)}(this._associatedReadableByteStreamController,e)}respondWithNewView(e){if(!1===He(this))throw pt("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,rt(e,t.byteLength)}(this._associatedReadableByteStreamController,e)}}class ReadableByteStreamController{constructor(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}get byobRequest(){if(!1===Qe(this))throw wt("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===Qe(this))throw wt("desiredSize");return at(this)}close(){if(!1===Qe(this))throw wt("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 it(e,t),t}}nt(e),Se(t)}(this)}enqueue(e){if(!1===Qe(this))throw wt("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===Ee(r))if(0===qe(r))Je(e,a,n,i);else{const e=new Uint8Array(a,n,i);Pe(r,e,!1)}else!0===je(r)?(Je(e,a,n,i),tt(e)):Je(e,a,n,i);Ue(e)}(this,e)}error(e){if(!1===Qe(this))throw wt("error");it(this,e)}[le](e){if(this._pendingPullIntos.length>0){this._pendingPullIntos[0].bytesFilled=0}S(this);const t=this._cancelAlgorithm(e);return nt(this),t}[ce](){const e=this._controlledReadableByteStream;if(this._queueTotalSize>0){const t=this._queue.shift();let r;this._queueTotalSize-=t.byteLength,Ze(this);try{r=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(ve(r,!1,e._reader._forAuthorCode))}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 r=we(e);return Ue(this),r}}function Qe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function He(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function Ue(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===Ee(t)&&qe(t)>0)return!0;if(!0===je(t)&&Te(t)>0)return!0;if(at(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,Ue(e))},t=>{it(e,t)}).catch(p)):e._pullAgain=!0)}function Ve(e,t){let r=!1;"closed"===e._state&&(r=!0);const o=Ge(t);"default"===t.readerType?Pe(e,o,r):function(e,t,r){const o=e._reader;o._readIntoRequests.shift()._resolve(ve(t,r,o._forAuthorCode))}(e,o,r)}function Ge(e){const t=e.bytesFilled,r=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,t/r)}function Je(e,t,r,o){e._queue.push({buffer:t,byteOffset:r,byteLength:o}),e._queueTotalSize+=o}function Ke(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,Xe(e,o,t),l-=o}return c}function Xe(e,t,r){et(e),r.bytesFilled+=t}function Ze(e){0===e._queueTotalSize&&!0===e._closeRequested?(nt(e),Se(e._controlledReadableByteStream)):Ue(e)}function et(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function tt(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;const t=e._pendingPullIntos[0];!0===Ke(e,t)&&(ot(e),Ve(e._controlledReadableByteStream,t))}}function rt(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===je(r))for(;Te(r)>0;)Ve(r,ot(e))}(e,r)}else!function(e,t,r){if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range");if(Xe(e,t,r),r.bytesFilled<r.elementSize)return;ot(e);const o=r.bytesFilled%r.elementSize;if(o>0){const t=r.byteOffset+r.bytesFilled,n=r.buffer.slice(t-o,t);Je(e,n,0,n.byteLength)}r.buffer=_(r.buffer),r.bytesFilled-=o,Ve(e._controlledReadableByteStream,r),tt(e)}(e,t,r);Ue(e)}function ot(e){const t=e._pendingPullIntos.shift();return et(e),t}function nt(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function it(e,t){const r=e._controlledReadableByteStream;"readable"===r._state&&(!function(e){et(e),e._pendingPullIntos=[]}(e),S(e),nt(e),Re(r,t))}function at(e){const t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function st(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 lt(e){return new TypeError(`ReadableStream.prototype.${e} can only be used on a ReadableStream`)}function ct(e){return new TypeError(`ReadableStreamAsyncIterator.${e} can only be used on a ReadableSteamAsyncIterator`)}function ut(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function dt(e){return new TypeError(`ReadableStreamDefaultReader.prototype.${e} can only be used on a ReadableStreamDefaultReader`)}function ft(e){e._closedPromise=new Promise((t,r)=>{e._closedPromise_resolve=t,e._closedPromise_reject=r})}function _t(e,t){ft(e),ht(e,t)}function ht(e,t){e._closedPromise.catch(()=>{}),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function bt(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function mt(e){return new TypeError(`ReadableStreamBYOBReader.prototype.${e} can only be used on a ReadableStreamBYOBReader`)}function yt(e){return new TypeError(`ReadableStreamDefaultController.prototype.${e} can only be used on a ReadableStreamDefaultController`)}function pt(e){return new TypeError(`ReadableStreamBYOBRequest.prototype.${e} can only be used on a ReadableStreamBYOBRequest`)}function wt(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 T(a),Y(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 jt(r,t)})}return jt(r,t)}(e,t)},function(){return function(e){const t=e._readable,r=e._transformStreamController,o=r._flushAlgorithm();return Tt(r),o.then(()=>{if("errored"===t._state)throw t._storedError;const e=t._readableStreamController;!0===Ne(e)&&De(e)}).catch(r=>{throw St(e,r),t._storedError})}(e)},function(t){return function(e,t){return St(e,t),Promise.resolve()}(e,t)},r,o),e._readable=fe(a,function(){return function(e){return Rt(e,!1),e._backpressureChangePromise}(e)},function(t){return vt(e,t),Promise.resolve()},n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Rt(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 qt(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===gt(this))throw Ct("readable");return this._readable}get writable(){if(!1===gt(this))throw Ct("writable");return this._writable}}function gt(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function St(e,t){Ye(e._readable._readableStreamController,t),vt(e,t)}function vt(e,t){Tt(e._transformStreamController),Q(e._writable._writableStreamController,t),!0===e._backpressure&&Rt(e,!1)}function Rt(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===Pt(this))throw Et("desiredSize");return $e(this._controlledTransformStream._readable._readableStreamController)}enqueue(e){if(!1===Pt(this))throw Et("enqueue");qt(this,e)}error(e){if(!1===Pt(this))throw Et("error");!function(e,t){St(e._controlledTransformStream,t)}(this,e)}terminate(){if(!1===Pt(this))throw Et("terminate");!function(e){const t=e._controlledTransformStream,r=t._readable._readableStreamController;!0===Ne(r)&&De(r);const o=new TypeError("TransformStream terminated");vt(t,o)}(this)}}function Pt(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function Tt(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function qt(e,t){const r=e._controlledTransformStream,o=r._readable._readableStreamController;if(!1===Ne(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{Me(o,t)}catch(e){throw vt(r,e),r._readable._storedError}(function(e){return!0!==Fe(e)})(o)!==r._backpressure&&Rt(r,!0)}function jt(e,t){return e._transformAlgorithm(t).catch(t=>{throw St(e._controlledTransformStream,t),t})}function Et(e){return new TypeError(`TransformStreamDefaultController.prototype.${e} can only be used on a TransformStreamDefaultController`)}function Ct(e){return new TypeError(`TransformStream.prototype.${e} can only be used on a TransformStream`)}const At=Object.assign||function(e,...t){const r=Object(e);for(const e of t)for(const t in e)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=e[t]);return r};void 0!==r&&At(r,{ReadableStream:ReadableStream,WritableStream:WritableStream,ByteLengthQueuingStrategy:ByteLengthQueuingStrategy,CountQueuingStrategy:CountQueuingStrategy,TransformStream:TransformStream}),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";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:function(e){return"Symbol("+e+")"};var t="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,r,t){Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})}function a(e){return e.slice()}function s(e,r,t,o,n){new Uint8Array(e).set(new Uint8Array(t,o,n),r)}function u(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 l(e,r,t){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,r,t)}function c(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 d(n,e,o)};case 1:return function(r){var t=[r].concat(o);return d(n,e,t)}}}return function(){return Promise.resolve()}}function f(e,r,t){var o=e[r];if(void 0!==o)return l(o,e,t)}function d(e,r,t){try{return Promise.resolve(l(e,r,t))}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 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)}}function p(e,r,t){for(var o=!1,n=function(e){!1===o&&(o=!0,t(e))},i=0,a=0,s=e.length,u=new Array(s),l=function(e){var t=i;!function(e,r,t){Promise.prototype.then.call(e,r,t)}(e,function(e){u[t]=e,++a===s&&r(u)},n),++i},c=0,f=e;c<f.length;c++){l(f[c])}}function m(e){}function y(e){e&&e instanceof m.AssertionError&&setTimeout(function(){throw e},0)}function v(e){var r=e._queue.shift();return e._queueTotalSize-=r.size,e._queueTotalSize<0&&(e._queueTotalSize=0),r.value}function w(e,r,t){if(!u(t=Number(t)))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:r,size:t}),e._queueTotalSize+=t}function g(e){e._queue=[],e._queueTotalSize=0}m.AssertionError=function(){};var S=r("[[AbortSteps]]"),R=r("[[ErrorSteps]]"),P=function(){function e(e,r){void 0===e&&(e={}),void 0===r&&(r={}),q(this);var t=r.size,o=r.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");var n=b(t);void 0===o&&(o=1),function(e,r,t,o){var n=Object.create(x.prototype);var i=c(r,"write",1,[n]),a=c(r,"close",0,[]),s=c(r,"abort",1,[]);H(e,n,function(){return f(r,"start",[n])},i,a,s,t,o)}(this,e,o=h(o),n)}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!1===j(this))throw X("locked");return E(this)},enumerable:!0,configurable:!0}),e.prototype.abort=function(e){return!1===j(this)?Promise.reject(X("abort")):!0===E(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):C(this,e)},e.prototype.getWriter=function(){if(!1===j(this))throw X("getWriter");return T(this)},e}();function T(e){return new F(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 j(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function E(e){return void 0!==e._writer}function C(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={_promise:void 0,_resolve:t,_reject:n,_reason:r,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&O(e,r),n}function A(e,r){"writable"!==e._state?W(e):O(e,r)}function O(e,r){var t=e._writableStreamController;e._state="erroring",e._storedError=r;var o=e._writer;void 0!==o&&D(o,r),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===t._started&&W(e)}function W(e){e._state="errored",e._writableStreamController[R]();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 z(e);e._writableStreamController[S](n._reason).then(function(){n._resolve(),z(e)},function(r){n._reject(r),z(e)})}else z(e)}function B(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);var r=e._writer;void 0!==r&&te(r,e._storedError)}function k(e,r){var t=e._writer;void 0!==t&&r!==e._backpressure&&(!0===r?function(e){ne(e)}(t):ue(t)),e._backpressure=r}var F=function(){function e(e){if(!1===j(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===E(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===B(e)&&!0===e._backpressure?ne(this):ae(this),ee(this);else if("erroring"===r)ie(this,e._storedError),ee(this);else if("closed"===r)ae(this),function(e){ee(e),oe(e)}(this);else{var t=e._storedError;ie(this,t),re(this,t)}}return Object.defineProperty(e.prototype,"closed",{get:function(){return!1===I(this)?Promise.reject(Z("closed")):this._closedPromise},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===I(this))throw Z("desiredSize");if(void 0===this._ownerWritableStream)throw $("desiredSize");return function(e){var r=e._ownerWritableStream,t=r._state;if("errored"===t||"erroring"===t)return null;if("closed"===t)return 0;return V(r._writableStreamController)}(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get:function(){return!1===I(this)?Promise.reject(Z("ready")):this._readyPromise},enumerable:!0,configurable:!0}),e.prototype.abort=function(e){return!1===I(this)?Promise.reject(Z("abort")):void 0===this._ownerWritableStream?Promise.reject($("abort")):function(e,r){return C(e._ownerWritableStream,r)}(this,e)},e.prototype.close=function(){if(!1===I(this))return Promise.reject(Z("close"));var e=this._ownerWritableStream;return void 0===e?Promise.reject($("close")):!0===B(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):L(this)},e.prototype.releaseLock=function(){if(!1===I(this))throw Z("releaseLock");void 0!==this._ownerWritableStream&&N(this)},e.prototype.write=function(e){return!1===I(this)?Promise.reject(Z("write")):void 0===this._ownerWritableStream?Promise.reject($("write to")):Y(this,e)},e}();function I(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function L(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&&ue(e),function(e){w(e,"close",0),Q(e)}(r._writableStreamController),o}function M(e,r){"pending"===e._closedPromiseState?te(e,r):function(e,r){re(e,r)}(e,r)}function D(e,r){"pending"===e._readyPromiseState?se(e,r):function(e,r){ie(e,r)}(e,r)}function N(e){var r=e._ownerWritableStream,t=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");D(e,t),M(e,t),r._writer=void 0,e._ownerWritableStream=void 0}function Y(e,r){var t=e._ownerWritableStream,o=t._writableStreamController,n=function(e,r){try{return e._strategySizeAlgorithm(r)}catch(r){return G(e,r),1}}(o,r);if(t!==e._ownerWritableStream)return Promise.reject($("write to"));var i=t._state;if("errored"===i)return Promise.reject(t._storedError);if(!0===B(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{w(e,o,t)}catch(r){return void G(e,r)}var n=e._controlledWritableStream;if(!1===B(n)&&"writable"===n._state){var i=J(e);k(n,i)}Q(e)}(o,r,n),a}var x=function(){function e(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}return e.prototype.error=function(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&&K(this,e)},e.prototype[S]=function(e){var r=this._abortAlgorithm(e);return U(this),r},e.prototype[R]=function(){g(this)},e}();function H(e,r,t,o,n,i,a,s){r._controlledWritableStream=e,e._writableStreamController=r,r._queue=void 0,r._queueTotalSize=void 0,g(r),r._started=!1,r._strategySizeAlgorithm=s,r._strategyHWM=a,r._writeAlgorithm=o,r._closeAlgorithm=n,r._abortAlgorithm=i;var u=J(r);k(e,u);var l=t();Promise.resolve(l).then(function(){r._started=!0,Q(r)},function(t){r._started=!0,A(e,t)}).catch(y)}function U(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function V(e){return e._strategyHWM-e._queueTotalSize}function Q(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=function(e){return e._queue[0].value}(e);"close"===o?function(e){var r=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(r),v(e);var t=e._closeAlgorithm();U(e),t.then(function(){!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";var r=e._writer;void 0!==r&&oe(r)}(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),A(e,r)}(r,e)}).catch(y)}(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(v(e),!1===B(t)&&"writable"===r){var o=J(e);k(t,o)}Q(e)},function(r){"writable"===t._state&&U(e),function(e,r){e._inFlightWriteRequest._reject(r),e._inFlightWriteRequest=void 0,A(e,r)}(t,r)}).catch(y)}(e,o.chunk)}}else W(r)}}function G(e,r){"writable"===e._controlledWritableStream._state&&K(e,r)}function J(e){return V(e)<=0}function K(e,r){var t=e._controlledWritableStream;U(e),O(t,r)}function X(e){return new TypeError("WritableStream.prototype."+e+" can only be used on a WritableStream")}function Z(e){return new TypeError("WritableStreamDefaultWriter.prototype."+e+" can only be used on a WritableStreamDefaultWriter")}function $(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function ee(e){e._closedPromise=new Promise(function(r,t){e._closedPromise_resolve=r,e._closedPromise_reject=t,e._closedPromiseState="pending"})}function re(e,r){ee(e),te(e,r)}function te(e,r){e._closedPromise.catch(function(){}),e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected"}function oe(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved"}function ne(e){e._readyPromise=new Promise(function(r,t){e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}function ie(e,r){ne(e),se(e,r)}function ae(e){ne(e),ue(e)}function se(e,r){e._readyPromise.catch(function(){}),e._readyPromise_reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function ue(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}var le=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},ce=r("[[CancelSteps]]"),fe=r("[[PullSteps]]"),de=function(){function e(e,r){void 0===e&&(e={}),void 0===r&&(r={}),be(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(Ke.prototype);var n=c(r,"pull",0,[o]),i=c(r,"cancel",1,[]),a=r.autoAllocateChunkSize;if(void 0!==a&&(a=Number(a),!1===le(a)||a<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");!function(e,r,t,o,n,i,a){r._controlledReadableByteStream=e,r._pullAgain=!1,r._pulling=!1,er(r),r._queue=r._queueTotalSize=void 0,g(r),r._closeRequested=!1,r._started=!1,r._strategyHWM=h(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,$e(r)},function(e){dr(r,e)}).catch(y)}(e,o,function(){return f(r,"start",[o])},n,i,t,a)}(this,e,o=h(o))}else{if(void 0!==n)throw new RangeError("Invalid type is specified");var i=b(t);void 0===o&&(o=1),function(e,r,t,o){var n=Object.create(Le.prototype);var i=c(r,"pull",0,[n]),a=c(r,"cancel",1,[]);Ge(e,n,function(){return f(r,"start",[n])},i,a,t,o)}(this,e,o=h(o),i)}}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!1===pe(this))throw br("locked");return me(this)},enumerable:!0,configurable:!0}),e.prototype.cancel=function(e){return!1===pe(this)?Promise.reject(br("cancel")):!0===me(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):ge(this,e)},e.prototype.getReader=function(e){var r=(void 0===e?{}:e).mode;if(!1===pe(this))throw br("getReader");if(void 0===r)return _e(this);if("byob"===(r=String(r)))return function(e){return new Oe(e)}(this);throw new RangeError("Invalid mode is specified")},e.prototype.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,u=n.signal;if(!1===pe(this))throw br("pipeThrough");if(!1===j(t))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===pe(o))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(i=Boolean(i),a=Boolean(a),s=Boolean(s),void 0!==u&&!hr(u))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===me(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===E(t))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return ye(this,t,i,a,s,u).catch(function(){}),o},e.prototype.pipeTo=function(e,r){var t=void 0===r?{}:r,o=t.preventClose,n=t.preventAbort,i=t.preventCancel,a=t.signal;return!1===pe(this)?Promise.reject(br("pipeTo")):!1===j(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||hr(a)?!0===me(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===E(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):ye(this,e,o,n,i,a):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))},e.prototype.tee=function(){if(!1===pe(this))throw br("tee");var e=function(e,r){var t,o,n,i,s,u=_e(e),l=!1,c=!1,f=!1,d=new Promise(function(e){s=e});function _(){return Ie(u).then(function(e){var r=e.value,t=e.done;if(!0===t&&!1===l&&(!1===c&&xe(n._readableStreamController),!1===f&&xe(i._readableStreamController),l=!0),!0!==l){var o=r,a=r;!1===c&&He(n._readableStreamController,o),!1===f&&He(i._readableStreamController,a)}})}function h(){}return n=he(h,_,function(r){if(c=!0,t=r,!0===f){var n=a([t,o]),i=ge(e,n);s(i)}return d}),i=he(h,_,function(r){if(f=!0,o=r,!0===c){var n=a([t,o]),i=ge(e,n);s(i)}return d}),u._closedPromise.catch(function(e){!0!==l&&(Ue(n._readableStreamController,e),Ue(i._readableStreamController,e),l=!0)}),[n,i]}(this);return a(e)},e}();function _e(e){return new Ae(e)}function he(e,r,t,o,n){void 0===o&&(o=1),void 0===n&&(n=function(){return 1});var i=Object.create(de.prototype);return be(i),Ge(i,Object.create(Le.prototype),e,r,t,o,n),i}function be(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function pe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function me(e){return void 0!==e._reader}function ye(e,r,t,o,n,i){var a=_e(e),s=T(r),u=!1,l=Promise.resolve();return new Promise(function(c,f){var d;if(void 0!==i){if(d=function(){var t=new DOMException("Aborted","AbortError"),i=[];!1===o&&i.push(function(){return"writable"===r._state?C(r,t):Promise.resolve()}),!1===n&&i.push(function(){return"readable"===e._state?ge(e,t):Promise.resolve()}),m(function(){return function(e,r,t){var o,n;void 0===t&&(t=void 0);var i=new Promise(function(e,r){o=e,n=r});return void 0===t&&(t=function(e){throw e}),p(e,function(e){try{var t=r(e);o(t)}catch(e){n(e)}},function(e){try{var r=t(e);o(r)}catch(e){n(e)}}),i}(i.map(function(e){return e()}),function(e){return e})},!0,t)},!0===i.aborted)return void d();i.addEventListener("abort",d)}if(b(e,a._closedPromise,function(e){!1===o?m(function(){return C(r,e)},!0,e):v(!0,e)}),b(r,s._closedPromise,function(r){!1===n?m(function(){return ge(e,r)},!0,r):v(!0,r)}),function(e,r,t){"closed"===e._state?t():r.then(t).catch(y)}(e,a._closedPromise,function(){!1===t?m(function(){return function(e){var r=e._ownerWritableStream,t=r._state;return!0===B(r)||"closed"===t?Promise.resolve():"errored"===t?Promise.reject(r._storedError):L(e)}(s)}):v()}),!0===B(r)||"closed"===r._state){var _=new TypeError("the destination writable stream closed before all data could be piped to it");!1===n?m(function(){return ge(e,_)},!0,_):v(!0,_)}function h(){var e=l;return l.then(function(){return e!==l?h():void 0})}function b(e,r,t){"errored"===e._state?t(e._storedError):r.catch(t).catch(y)}function m(e,t,o){function n(){e().then(function(){return w(t,o)},function(e){return w(!0,e)}).catch(y)}!0!==u&&(u=!0,"writable"===r._state&&!1===B(r)?h().then(n):n())}function v(e,t){!0!==u&&(u=!0,"writable"===r._state&&!1===B(r)?h().then(function(){return w(e,t)}).catch(y):w(e,t))}function w(e,r){N(s),Fe(a),void 0!==i&&i.removeEventListener("abort",d),e?f(r):c(void 0)}new Promise(function(e,r){!function t(o){o?e():(!0===u?Promise.resolve(!0):s._readyPromise.then(function(){return Ie(a).then(function(e){var r=e.value,t=e.done;return!0===t||(l=Y(s,r).catch(function(){}),!1)})})).then(t,r)}(!1)}).catch(function(e){l=Promise.resolve(),y(e)})})}function ve(e,r){return new Promise(function(t,o){var n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readIntoRequests.push(n)})}function we(e,r){return new Promise(function(t,o){var n={_resolve:t,_reject:o,_forAuthorCode:r};e._reader._readRequests.push(n)})}function ge(e,r){return e._disturbed=!0,"closed"===e._state?Promise.resolve(void 0):"errored"===e._state?Promise.reject(e._storedError):(Se(e),e._readableStreamController[ce](r).then(function(){}))}function Se(e){e._state="closed";var r=e._reader;if(void 0!==r){if(Be(r)){for(var t=0,o=r._readRequests;t<o.length;t++){var n=o[t];(0,n._resolve)(Re(void 0,!0,n._forAuthorCode))}r._readRequests=[]}gr(r)}}function Re(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 Pe(e,r){e._state="errored",e._storedError=r;var t=e._reader;if(void 0!==t){if(Be(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=[]}wr(t,r)}}function Te(e,r,t){var o=e._reader._readRequests.shift();o._resolve(Re(r,t,o._forAuthorCode))}function qe(e){return e._reader._readIntoRequests.length}function je(e){return e._reader._readRequests.length}function Ee(e){var r=e._reader;return void 0!==r&&!!We(r)}function Ce(e){var r=e._reader;return void 0!==r&&!!Be(r)}var Ae=function(){function e(e){if(!1===pe(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===me(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");ze(this,e),this._readRequests=[]}return Object.defineProperty(e.prototype,"closed",{get:function(){return Be(this)?this._closedPromise:Promise.reject(mr("closed"))},enumerable:!0,configurable:!0}),e.prototype.cancel=function(e){return Be(this)?void 0===this._ownerReadableStream?Promise.reject(pr("cancel")):ke(this,e):Promise.reject(mr("cancel"))},e.prototype.read=function(){return Be(this)?void 0===this._ownerReadableStream?Promise.reject(pr("read from")):Ie(this,!0):Promise.reject(mr("read"))},e.prototype.releaseLock=function(){if(!Be(this))throw mr("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");Fe(this)}},e}(),Oe=function(){function e(e){if(!pe(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===Xe(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(me(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");ze(this,e),this._readIntoRequests=[]}return Object.defineProperty(e.prototype,"closed",{get:function(){return We(this)?this._closedPromise:Promise.reject(Sr("closed"))},enumerable:!0,configurable:!0}),e.prototype.cancel=function(e){return We(this)?void 0===this._ownerReadableStream?Promise.reject(pr("cancel")):ke(this,e):Promise.reject(Sr("cancel"))},e.prototype.read=function(e){return We(this)?void 0===this._ownerReadableStream?Promise.reject(pr("read from")):ArrayBuffer.isView(e)?(e.buffer,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:_(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),ve(o,t);if("closed"===o._state){var s=new i(a.buffer,a.byteOffset,0);return Promise.resolve(Re(s,!0,t))}if(e._queueTotalSize>0){if(!0===nr(e,a)){var u=tr(a);return ar(e),Promise.resolve(Re(u,!1,t))}if(!0===e._closeRequested){var l=new TypeError("Insufficient bytes to fill elements in the given buffer");return dr(e,l),Promise.reject(l)}}e._pendingPullIntos.push(a);var c=ve(o,t);return $e(e),c}(o._readableStreamController,r,t)}(this,e,!0)):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(Sr("read"))},e.prototype.releaseLock=function(){if(!We(this))throw Sr("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");Fe(this)}},e}();function We(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Be(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function ze(e,r){e._ownerReadableStream=r,r._reader=e,"readable"===r._state?yr(e):"closed"===r._state?function(e){yr(e),gr(e)}(e):vr(e,r._storedError)}function ke(e,r){return ge(e._ownerReadableStream,r)}function Fe(e){"readable"===e._ownerReadableStream._state?wr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,r){vr(e,r)}(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 Ie(e,r){void 0===r&&(r=!1);var t=e._ownerReadableStream;return t._disturbed=!0,"closed"===t._state?Promise.resolve(Re(void 0,!0,r)):"errored"===t._state?Promise.reject(t._storedError):t._readableStreamController[fe](r)}var Le=function(){function e(){throw new TypeError}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===Me(this))throw Rr("desiredSize");return Ve(this)},enumerable:!0,configurable:!0}),e.prototype.close=function(){if(!1===Me(this))throw Rr("close");if(!1===Qe(this))throw new TypeError("The stream is not in a state that permits close");xe(this)},e.prototype.enqueue=function(e){if(!1===Me(this))throw Rr("enqueue");if(!1===Qe(this))throw new TypeError("The stream is not in a state that permits enqueue");return He(this,e)},e.prototype.error=function(e){if(!1===Me(this))throw Rr("error");Ue(this,e)},e.prototype[ce]=function(e){g(this);var r=this._cancelAlgorithm(e);return Ye(this),r},e.prototype[fe]=function(e){var r=this._controlledReadableStream;if(this._queue.length>0){var t=v(this);return!0===this._closeRequested&&0===this._queue.length?(Ye(this),Se(r)):De(this),Promise.resolve(Re(t,!1,e))}var o=we(r,e);return De(this),o},e}();function Me(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function De(e){!1!==Ne(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(function(){if(e._pulling=!1,!0===e._pullAgain)return e._pullAgain=!1,De(e)},function(r){Ue(e,r)}).catch(y)):e._pullAgain=!0)}function Ne(e){var r=e._controlledReadableStream;return!1!==Qe(e)&&(!1!==e._started&&(!0===me(r)&&je(r)>0||Ve(e)>0))}function Ye(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function xe(e){var r=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Ye(e),Se(r))}function He(e,r){var t=e._controlledReadableStream;if(!0===me(t)&&je(t)>0)Te(t,r,!1);else{var o=void 0;try{o=e._strategySizeAlgorithm(r)}catch(r){throw Ue(e,r),r}try{w(e,r,o)}catch(r){throw Ue(e,r),r}}De(e)}function Ue(e,r){var t=e._controlledReadableStream;"readable"===t._state&&(g(e),Ye(e),Pe(t,r))}function Ve(e){var r=e._controlledReadableStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function Qe(e){var r=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===r}function Ge(e,r,t,o,n,i,a){r._controlledReadableStream=e,r._queue=void 0,r._queueTotalSize=void 0,g(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,De(r)},function(e){Ue(r,e)}).catch(y)}var Je=function(){function e(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}return Object.defineProperty(e.prototype,"view",{get:function(){if(!1===Ze(this))throw Pr("view");return this._view},enumerable:!0,configurable:!0}),e.prototype.respond=function(e){if(!1===Ze(this))throw Pr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,function(e,r){if(!1===u(r=Number(r)))throw new RangeError("bytesWritten must be a finite");lr(e,r)}(this._associatedReadableByteStreamController,e)},e.prototype.respondWithNewView=function(e){if(!1===Ze(this))throw Pr("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,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,lr(e,r.byteLength)}(this._associatedReadableByteStreamController,e)},e}(),Ke=function(){function e(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}return Object.defineProperty(e.prototype,"byobRequest",{get:function(){if(!1===Xe(this))throw Tr("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(Je.prototype);!function(e,r,t){e._associatedReadableByteStreamController=r,e._view=t}(t,this,r),this._byobRequest=t}return this._byobRequest},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===Xe(this))throw Tr("desiredSize");return _r(this)},enumerable:!0,configurable:!0}),e.prototype.close=function(){if(!1===Xe(this))throw Tr("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 dr(e,o),o}}fr(e),Se(r)}(this)},e.prototype.enqueue=function(e){if(!1===Xe(this))throw Tr("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");e.buffer,function(e,r){var t=e._controlledReadableByteStream,o=r.buffer,n=r.byteOffset,i=r.byteLength,a=_(o);if(!0===Ce(t))if(0===je(t))or(e,a,n,i);else{var s=new Uint8Array(a,n,i);Te(t,s,!1)}else!0===Ee(t)?(or(e,a,n,i),ur(e)):or(e,a,n,i);$e(e)}(this,e)},e.prototype.error=function(e){if(!1===Xe(this))throw Tr("error");dr(this,e)},e.prototype[ce]=function(e){this._pendingPullIntos.length>0&&(this._pendingPullIntos[0].bytesFilled=0);g(this);var r=this._cancelAlgorithm(e);return fr(this),r},e.prototype[fe]=function(e){var r=this._controlledReadableByteStream;if(this._queueTotalSize>0){var t=this._queue.shift();this._queueTotalSize-=t.byteLength,ar(this);var o=void 0;try{o=new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(Re(o,!1,e))}var n=this._autoAllocateChunkSize;if(void 0!==n){var i=void 0;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=we(r,e);return $e(this),s},e}();function Xe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function Ze(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function $e(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===Ce(r)&&je(r)>0)return!0;if(!0===Ee(r)&&qe(r)>0)return!0;if(_r(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,$e(e))},function(r){dr(e,r)}).catch(y)):e._pullAgain=!0)}function er(e){sr(e),e._pendingPullIntos=[]}function rr(e,r){var t=!1;"closed"===e._state&&(t=!0);var o=tr(r);"default"===r.readerType?Te(e,o,t):function(e,r,t){var o=e._reader._readIntoRequests.shift();o._resolve(Re(r,t,o._forAuthorCode))}(e,o,t)}function tr(e){var 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 nr(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,u=n,l=!1;a>o&&(u=a-r.bytesFilled,l=!0);for(var c=e._queue;u>0;){var f=c[0],d=Math.min(u,f.byteLength),_=r.byteOffset+r.bytesFilled;s(r.buffer,_,f.buffer,f.byteOffset,d),f.byteLength===d?c.shift():(f.byteOffset+=d,f.byteLength-=d),e._queueTotalSize-=d,ir(e,d,r),u-=d}return l}function ir(e,r,t){sr(e),t.bytesFilled+=r}function ar(e){0===e._queueTotalSize&&!0===e._closeRequested?(fr(e),Se(e._controlledReadableByteStream)):$e(e)}function sr(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function ur(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;var r=e._pendingPullIntos[0];!0===nr(e,r)&&(cr(e),rr(e._controlledReadableByteStream,r))}}function lr(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=_(r.buffer);var t=e._controlledReadableByteStream;if(!0===Ee(t))for(;qe(t)>0;)rr(t,cr(e))}(e,t)}else!function(e,r,t){if(t.bytesFilled+r>t.byteLength)throw new RangeError("bytesWritten out of range");if(ir(e,r,t),!(t.bytesFilled<t.elementSize)){cr(e);var o=t.bytesFilled%t.elementSize;if(o>0){var n=t.byteOffset+t.bytesFilled,i=t.buffer.slice(n-o,n);or(e,i,0,i.byteLength)}t.buffer=_(t.buffer),t.bytesFilled-=o,rr(e._controlledReadableByteStream,t),ur(e)}}(e,r,t);$e(e)}function cr(e){var r=e._pendingPullIntos.shift();return sr(e),r}function fr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function dr(e,r){var t=e._controlledReadableByteStream;"readable"===t._state&&(er(e),g(e),fr(e),Pe(t,r))}function _r(e){var r=e._controlledReadableByteStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function hr(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 br(e){return new TypeError("ReadableStream.prototype."+e+" can only be used on a ReadableStream")}function pr(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function mr(e){return new TypeError("ReadableStreamDefaultReader.prototype."+e+" can only be used on a ReadableStreamDefaultReader")}function yr(e){e._closedPromise=new Promise(function(r,t){e._closedPromise_resolve=r,e._closedPromise_reject=t})}function vr(e,r){yr(e),wr(e,r)}function wr(e,r){e._closedPromise.catch(function(){}),e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function gr(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function Sr(e){return new TypeError("ReadableStreamBYOBReader.prototype."+e+" can only be used on a ReadableStreamBYOBReader")}function Rr(e){return new TypeError("ReadableStreamDefaultController.prototype."+e+" can only be used on a ReadableStreamDefaultController")}function Pr(e){return new TypeError("ReadableStreamBYOBRequest.prototype."+e+" can only be used on a ReadableStreamBYOBRequest")}function Tr(e){return new TypeError("ReadableByteStreamController.prototype."+e+" can only be used on a ReadableByteStreamController")}var qr=function(){function e(e){i(this,"highWaterMark",e.highWaterMark)}return e.prototype.size=function(e){return e.byteLength},e}(),jr=function(){function e(e){i(this,"highWaterMark",e.highWaterMark)}return e.prototype.size=function(){return 1},e}(),Er=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=b(o);if(void 0===n&&(n=1),n=h(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");var u,l=b(i);void 0===a&&(a=0),a=h(a),function(e,r,t,o,n,i){function a(){return r}e._writable=function(e,r,t,o,n,i){void 0===n&&(n=1),void 0===i&&(i=function(){return 1});var a=Object.create(P.prototype);return q(a),H(a,Object.create(x.prototype),e,r,t,o,n,i),a}(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 Ir(t,r)})}return Ir(t,r)}(e,r)},function(){return function(e){var r=e._readable,t=e._transformStreamController,o=t._flushAlgorithm();return kr(t),o.then(function(){if("errored"===r._state)throw r._storedError;var e=r._readableStreamController;!0===Qe(e)&&xe(e)}).catch(function(t){throw Ar(e,t),r._storedError})}(e)},function(r){return function(e,r){return Ar(e,r),Promise.resolve()}(e,r)},t,o),e._readable=he(a,function(){return function(e){return Wr(e,!1),e._backpressureChangePromise}(e)},function(r){return Or(e,r),Promise.resolve()},n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Wr(e,!0),e._transformStreamController=void 0}(this,new Promise(function(e){u=e}),n,s,a,l),function(e,r){var t=Object.create(Br.prototype),o=function(e){try{return Fr(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 d(n,r,[e,t])}}var i=c(r,"flush",0,[t]);!function(e,r,t,o){r._controlledTransformStream=e,e._transformStreamController=r,r._transformAlgorithm=t,r._flushAlgorithm=o}(e,t,o,i)}(this,e);var _=f(e,"start",[this._transformStreamController]);u(_)}return Object.defineProperty(e.prototype,"readable",{get:function(){if(!1===Cr(this))throw Mr("readable");return this._readable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){if(!1===Cr(this))throw Mr("writable");return this._writable},enumerable:!0,configurable:!0}),e}();function Cr(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function Ar(e,r){Ue(e._readable._readableStreamController,r),Or(e,r)}function Or(e,r){kr(e._transformStreamController),G(e._writable._writableStreamController,r),!0===e._backpressure&&Wr(e,!1)}function Wr(e,r){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(function(r){e._backpressureChangePromise_resolve=r}),e._backpressure=r}var Br=function(){function e(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===zr(this))throw Lr("desiredSize");return Ve(this._controlledTransformStream._readable._readableStreamController)},enumerable:!0,configurable:!0}),e.prototype.enqueue=function(e){if(!1===zr(this))throw Lr("enqueue");Fr(this,e)},e.prototype.error=function(e){if(!1===zr(this))throw Lr("error");!function(e,r){Ar(e._controlledTransformStream,r)}(this,e)},e.prototype.terminate=function(){if(!1===zr(this))throw Lr("terminate");!function(e){var r=e._controlledTransformStream,t=r._readable._readableStreamController;!0===Qe(t)&&xe(t);var o=new TypeError("TransformStream terminated");Or(r,o)}(this)},e}();function zr(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function kr(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Fr(e,r){var t=e._controlledTransformStream,o=t._readable._readableStreamController;if(!1===Qe(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{He(o,r)}catch(e){throw Or(t,e),t._readable._storedError}(function(e){return!0!==Ne(e)})(o)!==t._backpressure&&Wr(t,!0)}function Ir(e,r){return e._transformAlgorithm(r).catch(function(r){throw Ar(e._controlledTransformStream,r),r})}function Lr(e){return new TypeError("TransformStreamDefaultController.prototype."+e+" can only be used on a TransformStreamDefaultController")}function Mr(e){return new TypeError("TransformStream.prototype."+e+" can only be used on a TransformStream")}var Dr={ReadableStream:de,WritableStream:P,ByteLengthQueuingStrategy:qr,CountQueuingStrategy:jr,TransformStream:Er};void 0!==t&&Object.assign(t,Dr),e.ReadableStream=de,e.WritableStream=P,e.ByteLengthQueuingStrategy=qr,e.CountQueuingStrategy=jr,e.TransformStream=Er,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=e||self).WebStreamsPolyfill={})}(this,function(e){"use strict";var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:function(e){return"Symbol("+e+")"};var t="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,r,t){Object.defineProperty(e,r,{value:t,writable:!0,enumerable:!0,configurable:!0})}function a(e){return e.slice()}function s(e,r,t,o,n){new Uint8Array(e).set(new Uint8Array(t,o,n),r)}function u(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 l(e,r,t){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,r,t)}function c(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 d(n,e,o)};case 1:return function(r){var t=[r].concat(o);return d(n,e,t)}}}return function(){return Promise.resolve()}}function f(e,r,t){var o=e[r];if(void 0!==o)return l(o,e,t)}function d(e,r,t){try{return Promise.resolve(l(e,r,t))}catch(e){return Promise.reject(e)}}function h(e){return e}function _(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 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)}}function p(e,r,t){for(var o=!1,n=function(e){!1===o&&(o=!0,t(e))},i=0,a=0,s=e.length,u=new Array(s),l=function(e){var t=i;!function(e,r,t){Promise.prototype.then.call(e,r,t)}(e,function(e){u[t]=e,++a===s&&r(u)},n),++i},c=0,f=e;c<f.length;c++){l(f[c])}}var m=function(){};function y(e){var r=e._queue.shift();return e._queueTotalSize-=r.size,e._queueTotalSize<0&&(e._queueTotalSize=0),r.value}function v(e,r,t){if(!u(t=Number(t)))throw new RangeError("Size must be a finite, non-NaN, non-negative number.");e._queue.push({value:r,size:t}),e._queueTotalSize+=t}function w(e){e._queue=[],e._queueTotalSize=0}var g=r("[[AbortSteps]]"),S=r("[[ErrorSteps]]"),R=function(){function e(e,r){void 0===e&&(e={}),void 0===r&&(r={}),T(this);var t=r.size,o=r.highWaterMark;if(void 0!==e.type)throw new RangeError("Invalid type is specified");var n=b(t);void 0===o&&(o=1),function(e,r,t,o){var n=Object.create(x.prototype);var i=c(r,"write",1,[n]),a=c(r,"close",0,[]),s=c(r,"abort",1,[]);Y(e,n,function(){return f(r,"start",[n])},i,a,s,t,o)}(this,e,o=_(o),n)}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!1===q(this))throw K("locked");return j(this)},enumerable:!0,configurable:!0}),e.prototype.abort=function(e){return!1===q(this)?Promise.reject(K("abort")):!0===j(this)?Promise.reject(new TypeError("Cannot abort a stream that already has a writer")):E(this,e)},e.prototype.getWriter=function(){if(!1===q(this))throw K("getWriter");return P(this)},e}();function P(e){return new k(e)}function T(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 q(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")}function j(e){return void 0!==e._writer}function E(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={_promise:void 0,_resolve:t,_reject:n,_reason:r,_wasAlreadyErroring:o}});return e._pendingAbortRequest._promise=n,!1===o&&A(e,r),n}function C(e,r){"writable"!==e._state?O(e):A(e,r)}function A(e,r){var t=e._writableStreamController;e._state="erroring",e._storedError=r;var o=e._writer;void 0!==o&&M(o,r),!1===function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&!0===t._started&&O(e)}function O(e){e._state="errored",e._writableStreamController[S]();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 B(e);e._writableStreamController[g](n._reason).then(function(){n._resolve(),B(e)},function(r){n._reject(r),B(e)})}else B(e)}function W(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function B(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)}function z(e,r){var t=e._writer;void 0!==t&&r!==e._backpressure&&(!0===r?function(e){oe(e)}(t):se(t)),e._backpressure=r}var k=function(){function e(e){if(!1===q(e))throw new TypeError("WritableStreamDefaultWriter can only be constructed with a WritableStream instance");if(!0===j(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===W(e)&&!0===e._backpressure?oe(this):ie(this),$(this);else if("erroring"===r)ne(this,e._storedError),$(this);else if("closed"===r)ie(this),function(e){$(e),te(e)}(this);else{var t=e._storedError;ne(this,t),ee(this,t)}}return Object.defineProperty(e.prototype,"closed",{get:function(){return!1===I(this)?Promise.reject(X("closed")):this._closedPromise},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===I(this))throw X("desiredSize");if(void 0===this._ownerWritableStream)throw Z("desiredSize");return function(e){var r=e._ownerWritableStream,t=r._state;if("errored"===t||"erroring"===t)return null;if("closed"===t)return 0;return U(r._writableStreamController)}(this)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get:function(){return!1===I(this)?Promise.reject(X("ready")):this._readyPromise},enumerable:!0,configurable:!0}),e.prototype.abort=function(e){return!1===I(this)?Promise.reject(X("abort")):void 0===this._ownerWritableStream?Promise.reject(Z("abort")):function(e,r){return E(e._ownerWritableStream,r)}(this,e)},e.prototype.close=function(){if(!1===I(this))return Promise.reject(X("close"));var e=this._ownerWritableStream;return void 0===e?Promise.reject(Z("close")):!0===W(e)?Promise.reject(new TypeError("cannot close an already-closing stream")):F(this)},e.prototype.releaseLock=function(){if(!1===I(this))throw X("releaseLock");void 0!==this._ownerWritableStream&&D(this)},e.prototype.write=function(e){return!1===I(this)?Promise.reject(X("write")):void 0===this._ownerWritableStream?Promise.reject(Z("write to")):N(this,e)},e}();function I(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")}function F(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&&se(e),function(e){v(e,"close",0),V(e)}(r._writableStreamController),o}function L(e,r){"pending"===e._closedPromiseState?re(e,r):function(e,r){ee(e,r)}(e,r)}function M(e,r){"pending"===e._readyPromiseState?ae(e,r):function(e,r){ne(e,r)}(e,r)}function D(e){var r=e._ownerWritableStream,t=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");M(e,t),L(e,t),r._writer=void 0,e._ownerWritableStream=void 0}function N(e,r){var t=e._ownerWritableStream,o=t._writableStreamController,n=function(e,r){try{return e._strategySizeAlgorithm(r)}catch(r){return Q(e,r),1}}(o,r);if(t!==e._ownerWritableStream)return Promise.reject(Z("write to"));var i=t._state;if("errored"===i)return Promise.reject(t._storedError);if(!0===W(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{v(e,o,t)}catch(r){return void Q(e,r)}var n=e._controlledWritableStream;if(!1===W(n)&&"writable"===n._state){var i=G(e);z(n,i)}V(e)}(o,r,n),a}var x=function(){function e(){throw new TypeError("WritableStreamDefaultController cannot be constructed explicitly")}return e.prototype.error=function(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&&J(this,e)},e.prototype[g]=function(e){var r=this._abortAlgorithm(e);return H(this),r},e.prototype[S]=function(){w(this)},e}();function Y(e,r,t,o,n,i,a,s){r._controlledWritableStream=e,e._writableStreamController=r,r._queue=void 0,r._queueTotalSize=void 0,w(r),r._started=!1,r._strategySizeAlgorithm=s,r._strategyHWM=a,r._writeAlgorithm=o,r._closeAlgorithm=n,r._abortAlgorithm=i;var u=G(r);z(e,u);var l=t();Promise.resolve(l).then(function(){r._started=!0,V(r)},function(t){r._started=!0,C(e,t)}).catch(m)}function H(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 V(e){var r=e._controlledWritableStream;if(!1!==e._started&&void 0===r._inFlightWriteRequest)if("erroring"!==r._state){if(0!==e._queue.length){var t=function(e){return e._queue[0].value}(e);"close"===t?function(e){var r=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(r),y(e);var t=e._closeAlgorithm();H(e),t.then(function(){!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";var r=e._writer;void 0!==r&&te(r)}(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),C(e,r)}(r,e)}).catch(m)}(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(y(e),!1===W(t)&&"writable"===r){var o=G(e);z(t,o)}V(e)},function(r){"writable"===t._state&&H(e),function(e,r){e._inFlightWriteRequest._reject(r),e._inFlightWriteRequest=void 0,C(e,r)}(t,r)}).catch(m)}(e,t.chunk)}}else O(r)}function Q(e,r){"writable"===e._controlledWritableStream._state&&J(e,r)}function G(e){return U(e)<=0}function J(e,r){var t=e._controlledWritableStream;H(e),A(t,r)}function K(e){return new TypeError("WritableStream.prototype."+e+" can only be used on a WritableStream")}function X(e){return new TypeError("WritableStreamDefaultWriter.prototype."+e+" can only be used on a WritableStreamDefaultWriter")}function Z(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function $(e){e._closedPromise=new Promise(function(r,t){e._closedPromise_resolve=r,e._closedPromise_reject=t,e._closedPromiseState="pending"})}function ee(e,r){$(e),re(e,r)}function re(e,r){e._closedPromise.catch(function(){}),e._closedPromise_reject(r),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 oe(e){e._readyPromise=new Promise(function(r,t){e._readyPromise_resolve=r,e._readyPromise_reject=t}),e._readyPromiseState="pending"}function ne(e,r){oe(e),ae(e,r)}function ie(e){oe(e),se(e)}function ae(e,r){e._readyPromise.catch(function(){}),e._readyPromise_reject(r),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected"}function se(e){e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled"}var ue,le,ce=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e};"symbol"==typeof r.asyncIterator&&((ue={})[r.asyncIterator]=function(){return this},le=ue,Object.defineProperty(le,r.asyncIterator,{enumerable:!1}));var fe=r("[[CancelSteps]]"),de=r("[[PullSteps]]"),he=function(){function e(e,r){void 0===e&&(e={}),void 0===r&&(r={}),me(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($e.prototype);var n=c(r,"pull",0,[o]),i=c(r,"cancel",1,[]),a=r.autoAllocateChunkSize;if(void 0!==a&&(a=Number(a),!1===ce(a)||a<=0))throw new RangeError("autoAllocateChunkSize must be a positive integer");!function(e,r,t,o,n,i,a){r._controlledReadableByteStream=e,r._pullAgain=!1,r._pulling=!1,r._byobRequest=void 0,r._queue=r._queueTotalSize=void 0,w(r),r._closeRequested=!1,r._started=!1,r._strategyHWM=_(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,tr(r)},function(e){_r(r,e)}).catch(m)}(e,o,function(){return f(r,"start",[o])},n,i,t,a)}(this,e,o=_(o))}else{if(void 0!==n)throw new RangeError("Invalid type is specified");var i=b(t);void 0===o&&(o=1),function(e,r,t,o){var n=Object.create(Ne.prototype);var i=c(r,"pull",0,[n]),a=c(r,"cancel",1,[]);Xe(e,n,function(){return f(r,"start",[n])},i,a,t,o)}(this,e,o=_(o),i)}}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!1===ye(this))throw mr("locked");return ve(this)},enumerable:!0,configurable:!0}),e.prototype.cancel=function(e){return!1===ye(this)?Promise.reject(mr("cancel")):!0===ve(this)?Promise.reject(new TypeError("Cannot cancel a stream that already has a reader")):Pe(this,e)},e.prototype.getReader=function(e){var r=(void 0===e?{}:e).mode;if(!1===ye(this))throw mr("getReader");if(void 0===r)return be(this,!0);if("byob"===(r=String(r)))return function(e,r){void 0===r&&(r=!1);var t=new ze(e);return t._forAuthorCode=r,t}(this,!0);throw new RangeError("Invalid mode is specified")},e.prototype.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,u=n.signal;if(!1===ye(this))throw mr("pipeThrough");if(!1===q(t))throw new TypeError("writable argument to pipeThrough must be a WritableStream");if(!1===ye(o))throw new TypeError("readable argument to pipeThrough must be a ReadableStream");if(i=Boolean(i),a=Boolean(a),s=Boolean(s),void 0!==u&&!pr(u))throw new TypeError("ReadableStream.prototype.pipeThrough's signal option must be an AbortSignal");if(!0===ve(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(!0===j(t))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return ge(this,t,i,a,s,u).catch(function(){}),o},e.prototype.pipeTo=function(e,r){var t=void 0===r?{}:r,o=t.preventClose,n=t.preventAbort,i=t.preventCancel,a=t.signal;return!1===ye(this)?Promise.reject(mr("pipeTo")):!1===q(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||pr(a)?!0===ve(this)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):!0===j(e)?Promise.reject(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):ge(this,e,o,n,i,a):Promise.reject(new TypeError("ReadableStream.prototype.pipeTo's signal option must be an AbortSignal")))},e.prototype.tee=function(){if(!1===ye(this))throw mr("tee");var e=function(e,r){var t,o,n,i,s,u=be(e),l=!1,c=!1,f=!1,d=new Promise(function(e){s=e});function h(){return De(u).then(function(e){if(!0!==l){var r=e.done;if(!0===r)return!1===c&&Ve(n._readableStreamController),!1===f&&Ve(i._readableStreamController),void(l=!0);var t=e.value,o=t,a=t;!1===c&&Qe(n._readableStreamController,o),!1===f&&Qe(i._readableStreamController,a)}})}function _(){}return n=pe(_,h,function(r){if(c=!0,t=r,!0===f){var n=a([t,o]),i=Pe(e,n);s(i)}return d}),i=pe(_,h,function(r){if(f=!0,o=r,!0===c){var n=a([t,o]),i=Pe(e,n);s(i)}return d}),u._closedPromise.catch(function(e){Ge(n._readableStreamController,e),Ge(i._readableStreamController,e)}),[n,i]}(this);return a(e)},e.prototype.getIterator=function(e){var r=(void 0===e?{}:e).preventCancel;if(!1===ye(this))throw mr("getIterator");var t=be(this),o=Object.create(_e);return o._asyncIteratorReader=t,o._preventCancel=Boolean(r),o},e}(),_e={next:function(){if(!1===we(this))return Promise.reject(yr("next"));var e=this._asyncIteratorReader;return void 0===e._ownerReadableStream?Promise.reject(vr("iterate")):De(e).then(function(r){var t=r.done;return t&&Me(e),qe(r.value,t,!0)})},return:function(e){if(!1===we(this))return Promise.reject(yr("next"));var r=this._asyncIteratorReader;if(void 0===r._ownerReadableStream)return Promise.reject(vr("finish iterating"));if(r._readRequests.length>0)return Promise.reject(new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled"));if(!1===this._preventCancel){var t=Le(r,e);return Me(r),t.then(function(){return qe(e,!0,!0)})}return Me(r),Promise.resolve(qe(e,!0,!0))}};function be(e,r){void 0===r&&(r=!1);var t=new Be(e);return t._forAuthorCode=r,t}function pe(e,r,t,o,n){void 0===o&&(o=1),void 0===n&&(n=function(){return 1});var i=Object.create(he.prototype);return me(i),Xe(i,Object.create(Ne.prototype),e,r,t,o,n),i}function me(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function ye(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")}function ve(e){return void 0!==e._reader}function we(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorReader")}function ge(e,r,t,o,n,i){var a=be(e),s=P(r),u=!1,l=Promise.resolve();return new Promise(function(c,f){var d;if(void 0!==i){if(d=function(){var t=new DOMException("Aborted","AbortError"),i=[];!1===o&&i.push(function(){return"writable"===r._state?E(r,t):Promise.resolve()}),!1===n&&i.push(function(){return"readable"===e._state?Pe(e,t):Promise.resolve()}),y(function(){return function(e,r,t){var o,n;void 0===t&&(t=void 0);var i=new Promise(function(e,r){o=e,n=r});return void 0===t&&(t=function(e){throw e}),p(e,function(e){try{var t=r(e);o(t)}catch(e){n(e)}},function(e){try{var r=t(e);o(r)}catch(e){n(e)}}),i}(i.map(function(e){return e()}),function(e){return e})},!0,t)},!0===i.aborted)return void d();i.addEventListener("abort",d)}if(b(e,a._closedPromise,function(e){!1===o?y(function(){return E(r,e)},!0,e):v(!0,e)}),b(r,s._closedPromise,function(r){!1===n?y(function(){return Pe(e,r)},!0,r):v(!0,r)}),function(e,r,t){"closed"===e._state?t():r.then(t).catch(m)}(e,a._closedPromise,function(){!1===t?y(function(){return function(e){var r=e._ownerWritableStream,t=r._state;return!0===W(r)||"closed"===t?Promise.resolve():"errored"===t?Promise.reject(r._storedError):F(e)}(s)}):v()}),!0===W(r)||"closed"===r._state){var h=new TypeError("the destination writable stream closed before all data could be piped to it");!1===n?y(function(){return Pe(e,h)},!0,h):v(!0,h)}function _(){var e=l;return l.then(function(){return e!==l?_():void 0})}function b(e,r,t){"errored"===e._state?t(e._storedError):r.catch(t).catch(m)}function y(e,t,o){function n(){e().then(function(){return w(t,o)},function(e){return w(!0,e)}).catch(m)}!0!==u&&(u=!0,"writable"===r._state&&!1===W(r)?_().then(n):n())}function v(e,t){!0!==u&&(u=!0,"writable"===r._state&&!1===W(r)?_().then(function(){return w(e,t)}).catch(m):w(e,t))}function w(e,r){D(s),Me(a),void 0!==i&&i.removeEventListener("abort",d),e?f(r):c(void 0)}new Promise(function(e,r){!function t(o){o?e():(!0===u?Promise.resolve(!0):s._readyPromise.then(function(){return De(a).then(function(e){var r=e.value,t=e.done;return!0===t||(l=N(s,r).catch(function(){}),!1)})})).then(t,r)}(!1)}).catch(m)})}function Se(e){return new Promise(function(r,t){var o={_resolve:r,_reject:t};e._reader._readIntoRequests.push(o)})}function Re(e){return new Promise(function(r,t){var o={_resolve:r,_reject:t};e._reader._readRequests.push(o)})}function Pe(e,r){return e._disturbed=!0,"closed"===e._state?Promise.resolve(void 0):"errored"===e._state?Promise.reject(e._storedError):(Te(e),e._readableStreamController[fe](r).then(function(){}))}function Te(e){e._state="closed";var r=e._reader;if(void 0!==r){if(Ie(r)){for(var t=0,o=r._readRequests;t<o.length;t++){(0,o[t]._resolve)(qe(void 0,!0,r._forAuthorCode))}r._readRequests=[]}Pr(r)}}function qe(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 je(e,r){e._state="errored",e._storedError=r;var t=e._reader;if(void 0!==t){if(Ie(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=[]}Rr(t,r)}}function Ee(e,r,t){var o=e._reader;o._readRequests.shift()._resolve(qe(r,t,o._forAuthorCode))}function Ce(e){return e._reader._readIntoRequests.length}function Ae(e){return e._reader._readRequests.length}function Oe(e){var r=e._reader;return void 0!==r&&!!ke(r)}function We(e){var r=e._reader;return void 0!==r&&!!Ie(r)}void 0!==le&&Object.setPrototypeOf(_e,le),Object.defineProperty(_e,"next",{enumerable:!1}),Object.defineProperty(_e,"return",{enumerable:!1}),"symbol"==typeof r.asyncIterator&&Object.defineProperty(he.prototype,r.asyncIterator,{value:he.prototype.getIterator,enumerable:!1,writable:!0,configurable:!0});var Be=function(){function e(e){if(!1===ye(e))throw new TypeError("ReadableStreamDefaultReader can only be constructed with a ReadableStream instance");if(!0===ve(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Fe(this,e),this._readRequests=[]}return Object.defineProperty(e.prototype,"closed",{get:function(){return Ie(this)?this._closedPromise:Promise.reject(wr("closed"))},enumerable:!0,configurable:!0}),e.prototype.cancel=function(e){return Ie(this)?void 0===this._ownerReadableStream?Promise.reject(vr("cancel")):Le(this,e):Promise.reject(wr("cancel"))},e.prototype.read=function(){return Ie(this)?void 0===this._ownerReadableStream?Promise.reject(vr("read from")):De(this):Promise.reject(wr("read"))},e.prototype.releaseLock=function(){if(!Ie(this))throw wr("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");Me(this)}},e}(),ze=function(){function e(e){if(!ye(e))throw new TypeError("ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a byte source");if(!1===er(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");if(ve(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");Fe(this,e),this._readIntoRequests=[]}return Object.defineProperty(e.prototype,"closed",{get:function(){return ke(this)?this._closedPromise:Promise.reject(Tr("closed"))},enumerable:!0,configurable:!0}),e.prototype.cancel=function(e){return ke(this)?void 0===this._ownerReadableStream?Promise.reject(vr("cancel")):Le(this,e):Promise.reject(Tr("cancel"))},e.prototype.read=function(e){return ke(this)?void 0===this._ownerReadableStream?Promise.reject(vr("read from")):ArrayBuffer.isView(e)?(e.buffer,0===e.byteLength?Promise.reject(new TypeError("view must have non-zero byteLength")):function(e,r){var t=e._ownerReadableStream;if(t._disturbed=!0,"errored"===t._state)return Promise.reject(t._storedError);return function(e,r){var t=e._controlledReadableByteStream,o=1;r.constructor!==DataView&&(o=r.constructor.BYTES_PER_ELEMENT);var n=r.constructor,i={buffer:h(r.buffer),byteOffset:r.byteOffset,byteLength:r.byteLength,bytesFilled:0,elementSize:o,ctor:n,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(i),Se(t);if("closed"===t._state){var a=new n(i.buffer,i.byteOffset,0);return Promise.resolve(qe(a,!0,t._reader._forAuthorCode))}if(e._queueTotalSize>0){if(!0===ar(e,i)){var s=nr(i);return ur(e),Promise.resolve(qe(s,!1,t._reader._forAuthorCode))}if(!0===e._closeRequested){var u=new TypeError("Insufficient bytes to fill elements in the given buffer");return _r(e,u),Promise.reject(u)}}e._pendingPullIntos.push(i);var l=Se(t);return tr(e),l}(t._readableStreamController,r)}(this,e)):Promise.reject(new TypeError("view must be an array buffer view")):Promise.reject(Tr("read"))},e.prototype.releaseLock=function(){if(!ke(this))throw Tr("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");Me(this)}},e}();function ke(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")}function Ie(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_readRequests")}function Fe(e,r){e._forAuthorCode=!0,e._ownerReadableStream=r,r._reader=e,"readable"===r._state?gr(e):"closed"===r._state?function(e){gr(e),Pr(e)}(e):Sr(e,r._storedError)}function Le(e,r){return Pe(e._ownerReadableStream,r)}function Me(e){"readable"===e._ownerReadableStream._state?Rr(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,r){Sr(e,r)}(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 De(e){var r=e._ownerReadableStream;return r._disturbed=!0,"closed"===r._state?Promise.resolve(qe(void 0,!0,e._forAuthorCode)):"errored"===r._state?Promise.reject(r._storedError):r._readableStreamController[de]()}var Ne=function(){function e(){throw new TypeError}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===xe(this))throw qr("desiredSize");return Je(this)},enumerable:!0,configurable:!0}),e.prototype.close=function(){if(!1===xe(this))throw qr("close");if(!1===Ke(this))throw new TypeError("The stream is not in a state that permits close");Ve(this)},e.prototype.enqueue=function(e){if(!1===xe(this))throw qr("enqueue");if(!1===Ke(this))throw new TypeError("The stream is not in a state that permits enqueue");return Qe(this,e)},e.prototype.error=function(e){if(!1===xe(this))throw qr("error");Ge(this,e)},e.prototype[fe]=function(e){w(this);var r=this._cancelAlgorithm(e);return Ue(this),r},e.prototype[de]=function(){var e=this._controlledReadableStream;if(this._queue.length>0){var r=y(this);return!0===this._closeRequested&&0===this._queue.length?(Ue(this),Te(e)):Ye(this),Promise.resolve(qe(r,!1,e._reader._forAuthorCode))}var t=Re(e);return Ye(this),t},e}();function xe(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")}function Ye(e){!1!==He(e)&&(!0!==e._pulling?(e._pulling=!0,e._pullAlgorithm().then(function(){e._pulling=!1,!0===e._pullAgain&&(e._pullAgain=!1,Ye(e))},function(r){Ge(e,r)}).catch(m)):e._pullAgain=!0)}function He(e){var r=e._controlledReadableStream;return!1!==Ke(e)&&(!1!==e._started&&(!0===ve(r)&&Ae(r)>0||Je(e)>0))}function Ue(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Ve(e){var r=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(Ue(e),Te(r))}function Qe(e,r){var t=e._controlledReadableStream;if(!0===ve(t)&&Ae(t)>0)Ee(t,r,!1);else{var o=void 0;try{o=e._strategySizeAlgorithm(r)}catch(r){throw Ge(e,r),r}try{v(e,r,o)}catch(r){throw Ge(e,r),r}}Ye(e)}function Ge(e,r){var t=e._controlledReadableStream;"readable"===t._state&&(w(e),Ue(e),je(t,r))}function Je(e){var r=e._controlledReadableStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function Ke(e){var r=e._controlledReadableStream._state;return!1===e._closeRequested&&"readable"===r}function Xe(e,r,t,o,n,i,a){r._controlledReadableStream=e,r._queue=void 0,r._queueTotalSize=void 0,w(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,Ye(r)},function(e){Ge(r,e)}).catch(m)}var Ze=function(){function e(){throw new TypeError("ReadableStreamBYOBRequest cannot be used directly")}return Object.defineProperty(e.prototype,"view",{get:function(){if(!1===rr(this))throw jr("view");return this._view},enumerable:!0,configurable:!0}),e.prototype.respond=function(e){if(!1===rr(this))throw jr("respond");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,function(e,r){if(!1===u(r=Number(r)))throw new RangeError("bytesWritten must be a finite");fr(e,r)}(this._associatedReadableByteStreamController,e)},e.prototype.respondWithNewView=function(e){if(!1===rr(this))throw jr("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,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,fr(e,r.byteLength)}(this._associatedReadableByteStreamController,e)},e}(),$e=function(){function e(){throw new TypeError("ReadableByteStreamController constructor cannot be used directly")}return Object.defineProperty(e.prototype,"byobRequest",{get:function(){if(!1===er(this))throw Er("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(Ze.prototype);!function(e,r,t){e._associatedReadableByteStreamController=r,e._view=t}(t,this,r),this._byobRequest=t}return this._byobRequest},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===er(this))throw Er("desiredSize");return br(this)},enumerable:!0,configurable:!0}),e.prototype.close=function(){if(!1===er(this))throw Er("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 _r(e,o),o}}hr(e),Te(r)}(this)},e.prototype.enqueue=function(e){if(!1===er(this))throw Er("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");e.buffer,function(e,r){var t=e._controlledReadableByteStream,o=r.buffer,n=r.byteOffset,i=r.byteLength,a=h(o);if(!0===We(t))if(0===Ae(t))ir(e,a,n,i);else{var s=new Uint8Array(a,n,i);Ee(t,s,!1)}else!0===Oe(t)?(ir(e,a,n,i),cr(e)):ir(e,a,n,i);tr(e)}(this,e)},e.prototype.error=function(e){if(!1===er(this))throw Er("error");_r(this,e)},e.prototype[fe]=function(e){this._pendingPullIntos.length>0&&(this._pendingPullIntos[0].bytesFilled=0);w(this);var r=this._cancelAlgorithm(e);return hr(this),r},e.prototype[de]=function(){var e=this._controlledReadableByteStream;if(this._queueTotalSize>0){var r=this._queue.shift();this._queueTotalSize-=r.byteLength,ur(this);var t=void 0;try{t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}catch(e){return Promise.reject(e)}return Promise.resolve(qe(t,!1,e._reader._forAuthorCode))}var o=this._autoAllocateChunkSize;if(void 0!==o){var n=void 0;try{n=new ArrayBuffer(o)}catch(e){return Promise.reject(e)}var i={buffer:n,byteOffset:0,byteLength:o,bytesFilled:0,elementSize:1,ctor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(i)}var a=Re(e);return tr(this),a},e}();function er(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")}function rr(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")}function tr(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===We(r)&&Ae(r)>0)return!0;if(!0===Oe(r)&&Ce(r)>0)return!0;if(br(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,tr(e))},function(r){_r(e,r)}).catch(m)):e._pullAgain=!0)}function or(e,r){var t=!1;"closed"===e._state&&(t=!0);var o=nr(r);"default"===r.readerType?Ee(e,o,t):function(e,r,t){var o=e._reader;o._readIntoRequests.shift()._resolve(qe(r,t,o._forAuthorCode))}(e,o,t)}function nr(e){var r=e.bytesFilled,t=e.elementSize;return new e.ctor(e.buffer,e.byteOffset,r/t)}function ir(e,r,t,o){e._queue.push({buffer:r,byteOffset:t,byteLength:o}),e._queueTotalSize+=o}function ar(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,u=n,l=!1;a>o&&(u=a-r.bytesFilled,l=!0);for(var c=e._queue;u>0;){var f=c[0],d=Math.min(u,f.byteLength),h=r.byteOffset+r.bytesFilled;s(r.buffer,h,f.buffer,f.byteOffset,d),f.byteLength===d?c.shift():(f.byteOffset+=d,f.byteLength-=d),e._queueTotalSize-=d,sr(e,d,r),u-=d}return l}function sr(e,r,t){lr(e),t.bytesFilled+=r}function ur(e){0===e._queueTotalSize&&!0===e._closeRequested?(hr(e),Te(e._controlledReadableByteStream)):tr(e)}function lr(e){void 0!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=void 0,e._byobRequest=void 0)}function cr(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;var r=e._pendingPullIntos[0];!0===ar(e,r)&&(dr(e),or(e._controlledReadableByteStream,r))}}function fr(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=h(r.buffer);var t=e._controlledReadableByteStream;if(!0===Oe(t))for(;Ce(t)>0;)or(t,dr(e))}(e,t)}else!function(e,r,t){if(t.bytesFilled+r>t.byteLength)throw new RangeError("bytesWritten out of range");if(sr(e,r,t),!(t.bytesFilled<t.elementSize)){dr(e);var o=t.bytesFilled%t.elementSize;if(o>0){var n=t.byteOffset+t.bytesFilled,i=t.buffer.slice(n-o,n);ir(e,i,0,i.byteLength)}t.buffer=h(t.buffer),t.bytesFilled-=o,or(e._controlledReadableByteStream,t),cr(e)}}(e,r,t);tr(e)}function dr(e){var r=e._pendingPullIntos.shift();return lr(e),r}function hr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function _r(e,r){var t=e._controlledReadableByteStream;"readable"===t._state&&(!function(e){lr(e),e._pendingPullIntos=[]}(e),w(e),hr(e),je(t,r))}function br(e){var r=e._controlledReadableByteStream._state;return"errored"===r?null:"closed"===r?0:e._strategyHWM-e._queueTotalSize}function pr(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 mr(e){return new TypeError("ReadableStream.prototype."+e+" can only be used on a ReadableStream")}function yr(e){return new TypeError("ReadableStreamAsyncIterator."+e+" can only be used on a ReadableSteamAsyncIterator")}function vr(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function wr(e){return new TypeError("ReadableStreamDefaultReader.prototype."+e+" can only be used on a ReadableStreamDefaultReader")}function gr(e){e._closedPromise=new Promise(function(r,t){e._closedPromise_resolve=r,e._closedPromise_reject=t})}function Sr(e,r){gr(e),Rr(e,r)}function Rr(e,r){e._closedPromise.catch(function(){}),e._closedPromise_reject(r),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function Pr(e){e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0}function Tr(e){return new TypeError("ReadableStreamBYOBReader.prototype."+e+" can only be used on a ReadableStreamBYOBReader")}function qr(e){return new TypeError("ReadableStreamDefaultController.prototype."+e+" can only be used on a ReadableStreamDefaultController")}function jr(e){return new TypeError("ReadableStreamBYOBRequest.prototype."+e+" can only be used on a ReadableStreamBYOBRequest")}function Er(e){return new TypeError("ReadableByteStreamController.prototype."+e+" can only be used on a ReadableByteStreamController")}var Cr=function(){function e(e){i(this,"highWaterMark",e.highWaterMark)}return e.prototype.size=function(e){return e.byteLength},e}(),Ar=function(){function e(e){i(this,"highWaterMark",e.highWaterMark)}return e.prototype.size=function(){return 1},e}(),Or=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=b(o);if(void 0===n&&(n=1),n=_(n),void 0!==e.readableType)throw new RangeError("Invalid readable type specified");var u,l=b(i);void 0===a&&(a=0),a=_(a),function(e,r,t,o,n,i){function a(){return r}e._writable=function(e,r,t,o,n,i){void 0===n&&(n=1),void 0===i&&(i=function(){return 1});var a=Object.create(R.prototype);return T(a),Y(a,Object.create(x.prototype),e,r,t,o,n,i),a}(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 Dr(t,r)})}return Dr(t,r)}(e,r)},function(){return function(e){var r=e._readable,t=e._transformStreamController,o=t._flushAlgorithm();return Lr(t),o.then(function(){if("errored"===r._state)throw r._storedError;var e=r._readableStreamController;!0===Ke(e)&&Ve(e)}).catch(function(t){throw Br(e,t),r._storedError})}(e)},function(r){return function(e,r){return Br(e,r),Promise.resolve()}(e,r)},t,o),e._readable=pe(a,function(){return function(e){return kr(e,!1),e._backpressureChangePromise}(e)},function(r){return zr(e,r),Promise.resolve()},n,i),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,kr(e,!0),e._transformStreamController=void 0}(this,new Promise(function(e){u=e}),n,s,a,l),function(e,r){var t=Object.create(Ir.prototype),o=function(e){try{return Mr(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 d(n,r,[e,t])}}var i=c(r,"flush",0,[t]);!function(e,r,t,o){r._controlledTransformStream=e,e._transformStreamController=r,r._transformAlgorithm=t,r._flushAlgorithm=o}(e,t,o,i)}(this,e);var h=f(e,"start",[this._transformStreamController]);u(h)}return Object.defineProperty(e.prototype,"readable",{get:function(){if(!1===Wr(this))throw xr("readable");return this._readable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){if(!1===Wr(this))throw xr("writable");return this._writable},enumerable:!0,configurable:!0}),e}();function Wr(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")}function Br(e,r){Ge(e._readable._readableStreamController,r),zr(e,r)}function zr(e,r){Lr(e._transformStreamController),Q(e._writable._writableStreamController,r),!0===e._backpressure&&kr(e,!1)}function kr(e,r){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=new Promise(function(r){e._backpressureChangePromise_resolve=r}),e._backpressure=r}var Ir=function(){function e(){throw new TypeError("TransformStreamDefaultController instances cannot be created directly")}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!1===Fr(this))throw Nr("desiredSize");return Je(this._controlledTransformStream._readable._readableStreamController)},enumerable:!0,configurable:!0}),e.prototype.enqueue=function(e){if(!1===Fr(this))throw Nr("enqueue");Mr(this,e)},e.prototype.error=function(e){if(!1===Fr(this))throw Nr("error");!function(e,r){Br(e._controlledTransformStream,r)}(this,e)},e.prototype.terminate=function(){if(!1===Fr(this))throw Nr("terminate");!function(e){var r=e._controlledTransformStream,t=r._readable._readableStreamController;!0===Ke(t)&&Ve(t);var o=new TypeError("TransformStream terminated");zr(r,o)}(this)},e}();function Fr(e){return!!n(e)&&!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")}function Lr(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Mr(e,r){var t=e._controlledTransformStream,o=t._readable._readableStreamController;if(!1===Ke(o))throw new TypeError("Readable side is not in a state that permits enqueue");try{Qe(o,r)}catch(e){throw zr(t,e),t._readable._storedError}(function(e){return!0!==He(e)})(o)!==t._backpressure&&kr(t,!0)}function Dr(e,r){return e._transformAlgorithm(r).catch(function(r){throw Br(e._controlledTransformStream,r),r})}function Nr(e){return new TypeError("TransformStreamDefaultController.prototype."+e+" can only be used on a TransformStreamDefaultController")}function xr(e){return new TypeError("TransformStream.prototype."+e+" can only be used on a TransformStream")}var Yr=Object.assign||function(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var o=Object(e),n=0,i=r;n<i.length;n++){var a=i[n];for(var s in a)Object.prototype.hasOwnProperty.call(a,s)&&(o[s]=a[s])}return o};void 0!==t&&Yr(t,{ReadableStream:he,WritableStream:R,ByteLengthQueuingStrategy:Cr,CountQueuingStrategy:Ar,TransformStream:Or}),e.ReadableStream=he,e.WritableStream=R,e.ByteLengthQueuingStrategy=Cr,e.CountQueuingStrategy=Ar,e.TransformStream=Or,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=polyfill.min.js.map |
/** | ||
* Type definitions for @mattiasbuelens/web-streams-polyfill v0.3.1 | ||
* Type definitions for @mattiasbuelens/web-streams-polyfill v0.3.2 | ||
*/ | ||
// FILE GENERATED BY `rollup-plugin-dts@0.12.0` | ||
// FILE GENERATED BY `rollup-plugin-dts@0.13.0` | ||
// https://github.com/Swatinem/rollup-plugin-dts | ||
@@ -91,3 +91,13 @@ | ||
tee(): [ReadableStream<R>, ReadableStream<R>]; | ||
getIterator({ preventCancel }?: { | ||
preventCancel?: boolean; | ||
}): ReadableStreamAsyncIterator<R>; | ||
[Symbol.asyncIterator]: (options?: { | ||
preventCancel?: boolean; | ||
}) => ReadableStreamAsyncIterator<R>; | ||
} | ||
interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R> { | ||
next(): Promise<IteratorResult<R>>; | ||
return(value?: any): Promise<IteratorResult<any>>; | ||
} | ||
declare type ReadableStreamDefaultReaderType<R> = ReadableStreamDefaultReader<R>; | ||
@@ -169,2 +179,2 @@ declare class ReadableStreamDefaultReader<R> { | ||
export { ReadableStream, UnderlyingSource, UnderlyingByteSource, PipeOptions, ReadResult, ReadableStreamDefaultControllerType as ReadableStreamDefaultController, ReadableByteStreamControllerType as ReadableByteStreamController, ReadableStreamBYOBRequestType as ReadableStreamBYOBRequest, ReadableStreamDefaultReaderType as ReadableStreamDefaultReader, ReadableStreamBYOBReaderType as ReadableStreamBYOBReader, WritableStream, UnderlyingSink, WritableStreamDefaultWriterType as WritableStreamDefaultWriter, WritableStreamDefaultControllerType as WritableStreamDefaultController, QueuingStrategy, ByteLengthQueuingStrategy, CountQueuingStrategy, TransformStream, Transformer, TransformStreamDefaultControllerType as TransformStreamDefaultController }; | ||
export { ReadableStream, UnderlyingSource, UnderlyingByteSource, PipeOptions, ReadResult, ReadableStreamDefaultControllerType as ReadableStreamDefaultController, ReadableByteStreamControllerType as ReadableByteStreamController, ReadableStreamBYOBRequestType as ReadableStreamBYOBRequest, ReadableStreamDefaultReaderType as ReadableStreamDefaultReader, ReadableStreamBYOBReaderType as ReadableStreamBYOBReader, ReadableStreamAsyncIterator, WritableStream, UnderlyingSink, WritableStreamDefaultWriterType as WritableStreamDefaultWriter, WritableStreamDefaultControllerType as WritableStreamDefaultController, QueuingStrategy, ByteLengthQueuingStrategy, CountQueuingStrategy, TransformStream, Transformer, TransformStreamDefaultControllerType as TransformStreamDefaultController }; |
{ | ||
"name": "@mattiasbuelens/web-streams-polyfill", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "Web Streams, based on the WHATWG spec reference implementation", | ||
@@ -11,3 +11,3 @@ "main": "dist/polyfill", | ||
"test": "npm run test:types && npm run test:wpt", | ||
"test:wpt": "node --expose_gc run-web-platform-tests.js", | ||
"test:wpt": "node --expose_gc ./test/run-web-platform-tests.js", | ||
"pretest:wpt": "git submodule update --init --recursive", | ||
@@ -24,2 +24,3 @@ "test:types": "tsc -p ./test/types/tsconfig.json", | ||
"es6", | ||
"es2018", | ||
"ponyfill" | ||
@@ -49,7 +50,7 @@ ], | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^1.3.0", | ||
"eslint": "^5.14.1", | ||
"@typescript-eslint/eslint-plugin": "^1.4.2", | ||
"eslint": "^5.15.1", | ||
"micromatch": "^3.1.10", | ||
"rollup": "^1.2.1", | ||
"rollup-plugin-dts": "^0.12.0", | ||
"rollup": "^1.6.0", | ||
"rollup-plugin-dts": "^0.13.0", | ||
"rollup-plugin-inject": "^2.2.0", | ||
@@ -59,4 +60,4 @@ "rollup-plugin-strip": "^1.2.1", | ||
"typescript": "^3.3.3", | ||
"wpt-runner": "^2.7.0" | ||
"wpt-runner": "^2.7.1" | ||
} | ||
} |
@@ -17,12 +17,16 @@ # web-streams-polyfill | ||
This library comes in four variants: | ||
This library comes in multiple variants: | ||
* `@mattiasbuelens/web-streams-polyfill`: a polyfill that replaces the native stream implementations. | ||
Recommended for use in web apps through a `<script>` tag. | ||
Recommended for use in web apps supporting older browsers 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. | ||
Recommended for use in web apps supporting modern browsers through a `<script>` tag. | ||
* `@mattiasbuelens/web-streams-polyfill/es2018`: a polyfill targeting ES2018+ environments. | ||
Required for [`ReadableStream` async iterable support][rs-asynciterator]. | ||
* `@mattiasbuelens/web-streams-polyfill/ponyfill`: a [ponyfill] that provides | ||
the stream implementations without replacing any globals. | ||
Recommended for use in Node applications or web libraries. | ||
Recommended for use in legacy Node applications, or in web libraries supporting older browsers. | ||
* `@mattiasbuelens/web-streams-polyfill/ponyfill/es6`: a ponyfill targeting ES2015+ environments. | ||
Recommended for use in modern Node applications, or in web libraries targeting modern browsers. | ||
Recommended for use in Node 6+ applications, or in web libraries supporting modern browsers. | ||
* `@mattiasbuelens/web-streams-polyfill/ponyfill/es2018`: a ponyfill targeting ES2018+ environments. | ||
Recommended for use in Node 10+ applications. | ||
@@ -33,6 +37,5 @@ Each variant also includes TypeScript type definitions, compatible with the DOM type definitions for streams included in TypeScript. | ||
```html | ||
<!-- unpkg cdn --> | ||
<!-- option 1: hosted by unpkg CDN --> | ||
<script src="https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js"></script> | ||
<!-- self hosted --> | ||
<!-- option 2: self hosted --> | ||
<script src="/path/to/web-streams-polyfill/dist/polyfill.min.js"></script> | ||
@@ -63,5 +66,7 @@ <script> | ||
The `polyfill/es2018` and `ponyfill/es2018` variants work in any ES2018-compatible environment. | ||
### Compliance | ||
The polyfill implements [version `1116de06e9` (29 Nov 2018)](https://streams.spec.whatwg.org/commit-snapshots/1116de06e94bf4406c60b1e766111dfd8bc7bfcd/) of the streams specification. | ||
The polyfill implements [version `2c8f35e` (21 Feb 2019)](https://streams.spec.whatwg.org/commit-snapshots/2c8f35ed23451ffc9b32ec37b56def4a5349abb1/) of the streams specification. | ||
@@ -80,4 +85,5 @@ The type definitions are compatible with the built-in stream types of TypeScript 3.3. | ||
[ponyfill]: https://github.com/sindresorhus/ponyfill | ||
[rs-asynciterator]: https://streams.spec.whatwg.org/#rs-asynciterator | ||
[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 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 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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2859659
40
34988
86