puppeteer-core
Version:
A high-level API to control headless Chrome over the DevTools Protocol
4 lines (3 loc) • 27.1 kB
JavaScript
var Sr=function(r,e){return Sr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,o){t.__proto__=o}||function(t,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])},Sr(r,e)};function T(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Sr(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Rr(r,e,t,o){function n(i){return i instanceof t?i:new t(function(f){f(i)})}return new(t||(t=Promise))(function(i,f){function c(m){try{a(o.next(m))}catch(h){f(h)}}function u(m){try{a(o.throw(m))}catch(h){f(h)}}function a(m){m.done?i(m.value):n(m.value).then(c,u)}a((o=o.apply(r,e||[])).next())})}function $(r,e){var t={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},o,n,i,f;return f={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function c(a){return function(m){return u([a,m])}}function u(a){if(o)throw new TypeError("Generator is already executing.");for(;f&&(f=0,a[0]&&(t=0)),t;)try{if(o=1,n&&(i=a[0]&2?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[a[0]&2,i.value]),a[0]){case 0:case 1:i=a;break;case 4:return t.label++,{value:a[1],done:!1};case 5:t.label++,n=a[1],a=[0];continue;case 7:a=t.ops.pop(),t.trys.pop();continue;default:if(i=t.trys,!(i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){t=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){t.label=a[1];break}if(a[0]===6&&t.label<i[1]){t.label=i[1],i=a;break}if(i&&t.label<i[2]){t.label=i[2],t.ops.push(a);break}i[2]&&t.ops.pop(),t.trys.pop();continue}a=e.call(r,t)}catch(m){a=[6,m],n=0}finally{o=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}function I(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],o=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&o>=r.length&&(r=void 0),{value:r&&r[o++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function w(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var o=t.call(r),n,i=[],f;try{for(;(e===void 0||e-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(c){f={error:c}}finally{try{n&&!n.done&&(t=o.return)&&t.call(o)}finally{if(f)throw f.error}}return i}function A(r,e,t){if(t||arguments.length===2)for(var o=0,n=e.length,i;o<n;o++)(i||!(o in e))&&(i||(i=Array.prototype.slice.call(e,0,o)),i[o]=e[o]);return r.concat(i||Array.prototype.slice.call(e))}function C(r){return this instanceof C?(this.v=r,this):new C(r)}function Lr(r,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o=t.apply(r,e||[]),n,i=[];return n={},f("next"),f("throw"),f("return"),n[Symbol.asyncIterator]=function(){return this},n;function f(l){o[l]&&(n[l]=function(y){return new Promise(function(g,x){i.push([l,y,g,x])>1||c(l,y)})})}function c(l,y){try{u(o[l](y))}catch(g){h(i[0][3],g)}}function u(l){l.value instanceof C?Promise.resolve(l.value.v).then(a,m):h(i[0][2],l)}function a(l){c("next",l)}function m(l){c("throw",l)}function h(l,y){l(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function Cr(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof I=="function"?I(r):r[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(i){t[i]=r[i]&&function(f){return new Promise(function(c,u){f=r[i](f),n(c,u,f.done,f.value)})}}function n(i,f,c,u){Promise.resolve(u).then(function(a){i({value:a,done:c})},f)}}function p(r){return typeof r=="function"}function B(r){var e=function(o){Error.call(o),o.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var rr=B(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
`+t.map(function(o,n){return n+1+") "+o.toString()}).join(`
`):"",this.name="UnsubscriptionError",this.errors=t}});function U(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var W=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,o,n,i;if(!this.closed){this.closed=!0;var f=this._parentage;if(f)if(this._parentage=null,Array.isArray(f))try{for(var c=I(f),u=c.next();!u.done;u=c.next()){var a=u.value;a.remove(this)}}catch(x){e={error:x}}finally{try{u&&!u.done&&(t=c.return)&&t.call(c)}finally{if(e)throw e.error}}else f.remove(this);var m=this.initialTeardown;if(p(m))try{m()}catch(x){i=x instanceof rr?x.errors:[x]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var l=I(h),y=l.next();!y.done;y=l.next()){var g=y.value;try{Ur(g)}catch(x){i=i??[],x instanceof rr?i=A(A([],w(i)),w(x.errors)):i.push(x)}}}catch(x){o={error:x}}finally{try{y&&!y.done&&(n=l.return)&&n.call(l)}finally{if(o)throw o.error}}}if(i)throw new rr(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)Ur(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&U(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&U(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}();var vt=W.EMPTY;function er(r){return r instanceof W||r&&"closed"in r&&p(r.remove)&&p(r.add)&&p(r.unsubscribe)}function Ur(r){p(r)?r():r.unsubscribe()}var P={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};var D={setTimeout:function(r,e){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];var n=D.delegate;return n!=null&&n.setTimeout?n.setTimeout.apply(n,A([r,e],w(t))):setTimeout.apply(void 0,A([r,e],w(t)))},clearTimeout:function(r){var e=D.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function tr(r){D.setTimeout(function(){var e=P.onUnhandledError;if(e)e(r);else throw r})}function F(){}var Vr=function(){return Er("C",void 0,void 0)}();function Wr(r){return Er("E",void 0,r)}function Dr(r){return Er("N",r,void 0)}function Er(r,e,t){return{kind:r,value:e,error:t}}var V=null;function Yr(r){if(P.useDeprecatedSynchronousErrorHandling){var e=!V;if(e&&(V={errorThrown:!1,error:null}),r(),e){var t=V,o=t.errorThrown,n=t.error;if(V=null,o)throw n}}else r()}function qr(r){P.useDeprecatedSynchronousErrorHandling&&V&&(V.errorThrown=!0,V.error=r)}var K=function(r){T(e,r);function e(t){var o=r.call(this)||this;return o.isStopped=!1,t?(o.destination=t,er(t)&&t.add(o)):o.destination=Me,o}return e.create=function(t,o,n){return new Y(t,o,n)},e.prototype.next=function(t){this.isStopped?Ar(Dr(t),this):this._next(t)},e.prototype.error=function(t){this.isStopped?Ar(Wr(t),this):(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped?Ar(Vr,this):(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(W);var Fe=Function.prototype.bind;function Or(r,e){return Fe.call(r,e)}var je=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(o){or(o)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(o){or(o)}else or(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){or(t)}},r}(),Y=function(r){T(e,r);function e(t,o,n){var i=r.call(this)||this,f;if(p(t)||!t)f={next:t??void 0,error:o??void 0,complete:n??void 0};else{var c;i&&P.useDeprecatedNextContext?(c=Object.create(t),c.unsubscribe=function(){return i.unsubscribe()},f={next:t.next&&Or(t.next,c),error:t.error&&Or(t.error,c),complete:t.complete&&Or(t.complete,c)}):f=t}return i.destination=new je(f),i}return e}(K);function or(r){P.useDeprecatedSynchronousErrorHandling?qr(r):tr(r)}function ke(r){throw r}function Ar(r,e){var t=P.onStoppedNotification;t&&D.setTimeout(function(){return t(r,e)})}var Me={closed:!0,next:F,error:ke,complete:F};var q=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function S(r){return r}function Nr(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return _r(r)}function _r(r){return r.length===0?S:r.length===1?r[0]:function(t){return r.reduce(function(o,n){return n(o)},t)}}var b=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,o){var n=this,i=Le(e)?e:new Y(e,t,o);return Yr(function(){var f=n,c=f.operator,u=f.source;i.add(c?c.call(i,u):u?n._subscribe(i):n._trySubscribe(i))}),i},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var o=this;return t=Gr(t),new t(function(n,i){var f=new Y({next:function(c){try{e(c)}catch(u){i(u),f.unsubscribe()}},error:i,complete:n});o.subscribe(f)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[q]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _r(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=Gr(e),new e(function(o,n){var i;t.subscribe(function(f){return i=f},function(f){return n(f)},function(){return o(i)})})},r.create=function(e){return new r(e)},r}();function Gr(r){var e;return(e=r??P.Promise)!==null&&e!==void 0?e:Promise}function Re(r){return r&&p(r.next)&&p(r.error)&&p(r.complete)}function Le(r){return r&&r instanceof K||Re(r)&&er(r)}function Ce(r){return p(r==null?void 0:r.lift)}function d(r){return function(e){if(Ce(e))return e.lift(function(t){try{return r(t,this)}catch(o){this.error(o)}});throw new TypeError("Unable to lift unknown Observable type")}}function s(r,e,t,o,n){return new Ue(r,e,t,o,n)}var Ue=function(r){T(e,r);function e(t,o,n,i,f,c){var u=r.call(this,t)||this;return u.onFinalize=f,u.shouldUnsubscribe=c,u._next=o?function(a){try{o(a)}catch(m){t.error(m)}}:r.prototype._next,u._error=i?function(a){try{i(a)}catch(m){t.error(m)}finally{this.unsubscribe()}}:r.prototype._error,u._complete=n?function(){try{n()}catch(a){t.error(a)}finally{this.unsubscribe()}}:r.prototype._complete,u}return e.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var o=this.closed;r.prototype.unsubscribe.call(this),!o&&((t=this.onFinalize)===null||t===void 0||t.call(this))}},e}(K);var Ir={now:function(){return(Ir.delegate||Date).now()},delegate:void 0};var Hr=function(r){T(e,r);function e(t,o){return r.call(this)||this}return e.prototype.schedule=function(t,o){return o===void 0&&(o=0),this},e}(W);var z={setInterval:function(r,e){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];var n=z.delegate;return n!=null&&n.setInterval?n.setInterval.apply(n,A([r,e],w(t))):setInterval.apply(void 0,A([r,e],w(t)))},clearInterval:function(r){var e=z.delegate;return((e==null?void 0:e.clearInterval)||clearInterval)(r)},delegate:void 0};var Jr=function(r){T(e,r);function e(t,o){var n=r.call(this,t,o)||this;return n.scheduler=t,n.work=o,n.pending=!1,n}return e.prototype.schedule=function(t,o){var n;if(o===void 0&&(o=0),this.closed)return this;this.state=t;var i=this.id,f=this.scheduler;return i!=null&&(this.id=this.recycleAsyncId(f,i,o)),this.pending=!0,this.delay=o,this.id=(n=this.id)!==null&&n!==void 0?n:this.requestAsyncId(f,this.id,o),this},e.prototype.requestAsyncId=function(t,o,n){return n===void 0&&(n=0),z.setInterval(t.flush.bind(t,this),n)},e.prototype.recycleAsyncId=function(t,o,n){if(n===void 0&&(n=0),n!=null&&this.delay===n&&this.pending===!1)return o;o!=null&&z.clearInterval(o)},e.prototype.execute=function(t,o){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(t,o);if(n)return n;this.pending===!1&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},e.prototype._execute=function(t,o){var n=!1,i;try{this.work(t)}catch(f){n=!0,i=f||new Error("Scheduled action threw falsy error")}if(n)return this.unsubscribe(),i},e.prototype.unsubscribe=function(){if(!this.closed){var t=this,o=t.id,n=t.scheduler,i=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,U(i,this),o!=null&&(this.id=this.recycleAsyncId(n,o,null)),this.delay=null,r.prototype.unsubscribe.call(this)}},e}(Hr);var Tr=function(){function r(e,t){t===void 0&&(t=r.now),this.schedulerActionCtor=e,this.now=t}return r.prototype.schedule=function(e,t,o){return t===void 0&&(t=0),new this.schedulerActionCtor(this,e).schedule(o,t)},r.now=Ir.now,r}();var Kr=function(r){T(e,r);function e(t,o){o===void 0&&(o=Tr.now);var n=r.call(this,t,o)||this;return n.actions=[],n._active=!1,n}return e.prototype.flush=function(t){var o=this.actions;if(this._active){o.push(t);return}var n;this._active=!0;do if(n=t.execute(t.state,t.delay))break;while(t=o.shift());if(this._active=!1,n){for(;t=o.shift();)t.unsubscribe();throw n}},e}(Tr);var Pr=new Kr(Jr),zr=Pr;var N=new b(function(r){return r.complete()});function nr(r){return r&&p(r.schedule)}function Fr(r){return r[r.length-1]}function Qr(r){return p(Fr(r))?r.pop():void 0}function R(r){return nr(Fr(r))?r.pop():void 0}function Xr(r,e){return typeof Fr(r)=="number"?r.pop():e}var G=function(r){return r&&typeof r.length=="number"&&typeof r!="function"};function ir(r){return p(r==null?void 0:r.then)}function fr(r){return p(r[q])}function ar(r){return Symbol.asyncIterator&&p(r==null?void 0:r[Symbol.asyncIterator])}function ur(r){return new TypeError("You provided "+(r!==null&&typeof r=="object"?"an invalid object":"'"+r+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ve(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var cr=Ve();function pr(r){return p(r==null?void 0:r[cr])}function mr(r){return Lr(this,arguments,function(){var t,o,n,i;return $(this,function(f){switch(f.label){case 0:t=r.getReader(),f.label=1;case 1:f.trys.push([1,,9,10]),f.label=2;case 2:return[4,C(t.read())];case 3:return o=f.sent(),n=o.value,i=o.done,i?[4,C(void 0)]:[3,5];case 4:return[2,f.sent()];case 5:return[4,C(n)];case 6:return[4,f.sent()];case 7:return f.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function sr(r){return p(r==null?void 0:r.getReader)}function v(r){if(r instanceof b)return r;if(r!=null){if(fr(r))return We(r);if(G(r))return De(r);if(ir(r))return Ye(r);if(ar(r))return Zr(r);if(pr(r))return qe(r);if(sr(r))return Ne(r)}throw ur(r)}function We(r){return new b(function(e){var t=r[q]();if(p(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function De(r){return new b(function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()})}function Ye(r){return new b(function(e){r.then(function(t){e.closed||(e.next(t),e.complete())},function(t){return e.error(t)}).then(null,tr)})}function qe(r){return new b(function(e){var t,o;try{for(var n=I(r),i=n.next();!i.done;i=n.next()){var f=i.value;if(e.next(f),e.closed)return}}catch(c){t={error:c}}finally{try{i&&!i.done&&(o=n.return)&&o.call(n)}finally{if(t)throw t.error}}e.complete()})}function Zr(r){return new b(function(e){Ge(r,e).catch(function(t){return e.error(t)})})}function Ne(r){return Zr(mr(r))}function Ge(r,e){var t,o,n,i;return Rr(this,void 0,void 0,function(){var f,c;return $(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),t=Cr(r),u.label=1;case 1:return[4,t.next()];case 2:if(o=u.sent(),!!o.done)return[3,4];if(f=o.value,e.next(f),e.closed)return[2];u.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=u.sent(),n={error:c},[3,11];case 6:return u.trys.push([6,,9,10]),o&&!o.done&&(i=t.return)?[4,i.call(t)]:[3,8];case 7:u.sent(),u.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return e.complete(),[2]}})})}function _(r,e,t,o,n){o===void 0&&(o=0),n===void 0&&(n=!1);var i=e.schedule(function(){t(),n?r.add(this.schedule(null,o)):this.unsubscribe()},o);if(r.add(i),!n)return i}function lr(r,e){return e===void 0&&(e=0),d(function(t,o){t.subscribe(s(o,function(n){return _(o,r,function(){return o.next(n)},e)},function(){return _(o,r,function(){return o.complete()},e)},function(n){return _(o,r,function(){return o.error(n)},e)}))})}function dr(r,e){return e===void 0&&(e=0),d(function(t,o){o.add(r.schedule(function(){return t.subscribe(o)},e))})}function $r(r,e){return v(r).pipe(dr(e),lr(e))}function Br(r,e){return v(r).pipe(dr(e),lr(e))}function re(r,e){return new b(function(t){var o=0;return e.schedule(function(){o===r.length?t.complete():(t.next(r[o++]),t.closed||this.schedule())})})}function ee(r,e){return new b(function(t){var o;return _(t,e,function(){o=r[cr](),_(t,e,function(){var n,i,f;try{n=o.next(),i=n.value,f=n.done}catch(c){t.error(c);return}f?t.complete():t.next(i)},0,!0)}),function(){return p(o==null?void 0:o.return)&&o.return()}})}function hr(r,e){if(!r)throw new Error("Iterable cannot be null");return new b(function(t){_(t,e,function(){var o=r[Symbol.asyncIterator]();_(t,e,function(){o.next().then(function(n){n.done?t.complete():t.next(n.value)})},0,!0)})})}function te(r,e){return hr(mr(r),e)}function oe(r,e){if(r!=null){if(fr(r))return $r(r,e);if(G(r))return re(r,e);if(ir(r))return Br(r,e);if(ar(r))return hr(r,e);if(pr(r))return ee(r,e);if(sr(r))return te(r,e)}throw ur(r)}function j(r,e){return e?oe(r,e):v(r)}function ne(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=R(r);return j(r,t)}var L=B(function(r){return function(){r(this),this.name="EmptyError",this.message="no elements in sequence"}});function ie(r,e){var t=typeof e=="object";return new Promise(function(o,n){var i=!1,f;r.subscribe({next:function(c){f=c,i=!0},error:n,complete:function(){i?o(f):t?o(e.defaultValue):n(new L)}})})}function fe(r,e){var t=typeof e=="object";return new Promise(function(o,n){var i=new Y({next:function(f){o(f),i.unsubscribe()},error:n,complete:function(){t?o(e.defaultValue):n(new L)}});r.subscribe(i)})}function ae(r){return r instanceof Date&&!isNaN(r)}function k(r,e){return d(function(t,o){var n=0;t.subscribe(s(o,function(i){o.next(r.call(e,i,n++))}))})}var He=Array.isArray;function Je(r,e){return He(e)?r.apply(void 0,A([],w(e))):r(e)}function vr(r){return k(function(e){return Je(r,e)})}var Ke=Array.isArray,ze=Object.getPrototypeOf,Qe=Object.prototype,Xe=Object.keys;function ue(r){if(r.length===1){var e=r[0];if(Ke(e))return{args:e,keys:null};if(Ze(e)){var t=Xe(e);return{args:t.map(function(o){return e[o]}),keys:t}}}return{args:r,keys:null}}function Ze(r){return r&&typeof r=="object"&&ze(r)===Qe}function ce(r,e){return r.reduce(function(t,o,n){return t[o]=e[n],t},{})}function pe(r,e,t,o,n,i,f,c){var u=[],a=0,m=0,h=!1,l=function(){h&&!u.length&&!a&&e.complete()},y=function(x){return a<o?g(x):u.push(x)},g=function(x){i&&e.next(x),a++;var O=!1;v(t(x,m++)).subscribe(s(e,function(M){n==null||n(M),i?y(M):e.next(M)},function(){O=!0},void 0,function(){if(O)try{a--;for(var M=function(){var Z=u.shift();f?_(e,f,function(){return g(Z)}):g(Z)};u.length&&a<o;)M();l()}catch(Z){e.error(Z)}}))};return r.subscribe(s(e,y,function(){h=!0,l()})),function(){c==null||c()}}function E(r,e,t){return t===void 0&&(t=1/0),p(e)?E(function(o,n){return k(function(i,f){return e(o,i,n,f)})(v(r(o,n)))},t):(typeof e=="number"&&(t=e),d(function(o,n){return pe(o,n,r,t)}))}function yr(r){return r===void 0&&(r=1/0),E(S,r)}function me(){return yr(1)}function Q(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return me()(j(r,R(r)))}function se(r){return new b(function(e){v(r()).subscribe(e)})}function le(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=Qr(r),o=ue(r),n=o.args,i=o.keys,f=new b(function(c){var u=n.length;if(!u){c.complete();return}for(var a=new Array(u),m=u,h=u,l=function(g){var x=!1;v(n[g]).subscribe(s(c,function(O){x||(x=!0,h--),a[g]=O},function(){return m--},void 0,function(){(!m||!x)&&(h||c.next(i?ce(i,a):a),c.complete())}))},y=0;y<u;y++)l(y)});return t?f.pipe(vr(t)):f}var $e=["addListener","removeListener"],Be=["addEventListener","removeEventListener"],rt=["on","off"];function xr(r,e,t,o){if(p(t)&&(o=t,t=void 0),o)return xr(r,e,t).pipe(vr(o));var n=w(ot(r)?Be.map(function(c){return function(u){return r[c](e,u,t)}}):et(r)?$e.map(de(r,e)):tt(r)?rt.map(de(r,e)):[],2),i=n[0],f=n[1];if(!i&&G(r))return E(function(c){return xr(c,e,t)})(v(r));if(!i)throw new TypeError("Invalid event target");return new b(function(c){var u=function(){for(var a=[],m=0;m<arguments.length;m++)a[m]=arguments[m];return c.next(1<a.length?a:a[0])};return i(u),function(){return f(u)}})}function de(r,e){return function(t){return function(o){return r[t](e,o)}}}function et(r){return p(r.addListener)&&p(r.removeListener)}function tt(r){return p(r.on)&&p(r.off)}function ot(r){return p(r.addEventListener)&&p(r.removeEventListener)}function H(r,e,t){r===void 0&&(r=0),t===void 0&&(t=zr);var o=-1;return e!=null&&(nr(e)?t=e:o=e),new b(function(n){var i=ae(r)?+r-t.now():r;i<0&&(i=0);var f=0;return t.schedule(function(){n.closed||(n.next(f++),0<=o?this.schedule(void 0,o):n.complete())},i)})}function he(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=R(r),o=Xr(r,1/0),n=r;return n.length?n.length===1?v(n[0]):yr(o)(j(n,t)):N}var ve=new b(F);var nt=Array.isArray;function ye(r){return r.length===1&&nt(r[0])?r[0]:r}function J(r,e){return d(function(t,o){var n=0;t.subscribe(s(o,function(i){return r.call(e,i,n++)&&o.next(i)}))})}function xe(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return r=ye(r),r.length===1?v(r[0]):new b(jr(r))}function jr(r){return function(e){for(var t=[],o=function(i){t.push(v(r[i]).subscribe(s(e,function(f){if(t){for(var c=0;c<t.length;c++)c!==i&&t[c].unsubscribe();t=null}e.next(f)})))},n=0;t&&!e.closed&&n<r.length;n++)o(n)}}function be(r,e){return e===void 0&&(e=null),e=e??r,d(function(t,o){var n=[],i=0;t.subscribe(s(o,function(f){var c,u,a,m,h=null;i++%e===0&&n.push([]);try{for(var l=I(n),y=l.next();!y.done;y=l.next()){var g=y.value;g.push(f),r<=g.length&&(h=h??[],h.push(g))}}catch(M){c={error:M}}finally{try{y&&!y.done&&(u=l.return)&&u.call(l)}finally{if(c)throw c.error}}if(h)try{for(var x=I(h),O=x.next();!O.done;O=x.next()){var g=O.value;U(n,g),o.next(g)}}catch(M){a={error:M}}finally{try{O&&!O.done&&(m=x.return)&&m.call(x)}finally{if(a)throw a.error}}},function(){var f,c;try{for(var u=I(n),a=u.next();!a.done;a=u.next()){var m=a.value;o.next(m)}}catch(h){f={error:h}}finally{try{a&&!a.done&&(c=u.return)&&c.call(u)}finally{if(f)throw f.error}}o.complete()},void 0,function(){n=null}))})}function kr(r){return d(function(e,t){var o=null,n=!1,i;o=e.subscribe(s(t,void 0,void 0,function(f){i=v(r(f,kr(r)(e))),o?(o.unsubscribe(),o=null,i.subscribe(t)):n=!0})),n&&(o.unsubscribe(),o=null,i.subscribe(t))})}function ge(r,e){return p(e)?E(r,e,1):E(r,1)}function br(r){return d(function(e,t){var o=!1;e.subscribe(s(t,function(n){o=!0,t.next(n)},function(){o||t.next(r),t.complete()}))})}function X(r){return r<=0?function(){return N}:d(function(e,t){var o=0;e.subscribe(s(t,function(n){++o<=r&&(t.next(n),r<=o&&t.complete())}))})}function gr(){return d(function(r,e){r.subscribe(s(e,F))})}function we(r){return k(function(){return r})}function Mr(r,e){return e?function(t){return Q(e.pipe(X(1),gr()),t.pipe(Mr(r)))}:E(function(t,o){return v(r(t,o)).pipe(X(1),we(t))})}function Se(r,e){e===void 0&&(e=Pr);var t=H(r,e);return Mr(function(){return t})}function wr(r){return r===void 0&&(r=it),d(function(e,t){var o=!1;e.subscribe(s(t,function(n){o=!0,t.next(n)},function(){return o?t.complete():t.error(r())}))})}function it(){return new L}function Ee(r,e){var t=arguments.length>=2;return function(o){return o.pipe(r?J(function(n,i){return r(n,i,o)}):S,X(1),t?br(e):wr(function(){return new L}))}}function Oe(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return r.length?d(function(t,o){jr(A([t],w(r)))(o)}):S}function Ae(r){r===void 0&&(r=1/0);var e;r&&typeof r=="object"?e=r:e={count:r};var t=e.count,o=t===void 0?1/0:t,n=e.delay,i=e.resetOnSuccess,f=i===void 0?!1:i;return o<=0?S:d(function(c,u){var a=0,m,h=function(){var l=!1;m=c.subscribe(s(u,function(y){f&&(a=0),u.next(y)},void 0,function(y){if(a++<o){var g=function(){m?(m.unsubscribe(),m=null,h()):l=!0};if(n!=null){var x=typeof n=="number"?H(n):v(n(y,a)),O=s(u,function(){O.unsubscribe(),g()},function(){u.complete()});x.subscribe(O)}else g()}else u.error(y)})),l&&(m.unsubscribe(),m=null,h())};h()})}function _e(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var t=R(r);return d(function(o,n){(t?Q(r,o,t):Q(r,o)).subscribe(n)})}function Ie(r,e){return d(function(t,o){var n=null,i=0,f=!1,c=function(){return f&&!n&&o.complete()};t.subscribe(s(o,function(u){n==null||n.unsubscribe();var a=0,m=i++;v(r(u,m)).subscribe(n=s(o,function(h){return o.next(e?e(u,h,m,a++):h)},function(){n=null,c()}))},function(){f=!0,c()}))})}function Te(r){return d(function(e,t){v(r).subscribe(s(t,function(){return t.complete()},F)),!t.closed&&e.subscribe(t)})}function Pe(r,e,t){var o=p(r)||e||t?{next:r,error:e,complete:t}:r;return o?d(function(n,i){var f;(f=o.subscribe)===null||f===void 0||f.call(o);var c=!0;n.subscribe(s(i,function(u){var a;(a=o.next)===null||a===void 0||a.call(o,u),i.next(u)},function(){var u;c=!1,(u=o.complete)===null||u===void 0||u.call(o),i.complete()},function(u){var a;c=!1,(a=o.error)===null||a===void 0||a.call(o,u),i.error(u)},function(){var u,a;c&&((u=o.unsubscribe)===null||u===void 0||u.call(o)),(a=o.finalize)===null||a===void 0||a.call(o)}))}):S}function Au(r){return E(e=>j(Promise.resolve(r(e))).pipe(J(t=>t),k(()=>e)))}export{N as EMPTY,ve as NEVER,be as bufferCount,kr as catchError,ge as concatMap,br as defaultIfEmpty,se as defer,Se as delay,J as filter,Au as filterAsync,Ee as first,fe as firstValueFrom,le as forkJoin,j as from,xr as fromEvent,S as identity,gr as ignoreElements,ie as lastValueFrom,k as map,he as merge,E as mergeMap,F as noop,ne as of,Nr as pipe,xe as race,Oe as raceWith,Ae as retry,_e as startWith,Ie as switchMap,Te as takeUntil,Pe as tap,wr as throwIfEmpty,H as timer};