rx-tiny-flux 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Readme.md CHANGED
@@ -295,3 +295,98 @@ Page(BasePage({
295
295
  }
296
296
  }));
297
297
  ```
298
+
299
+ #### Accessing Component Context in Effects
300
+
301
+ The `storePlugin` automatically injects the component instance (`this` from `BasePage` or `BaseApp` or `BaseSideService`) into every dispatched action under the `context` property. This powerful feature allows your effects to access other plugins or methods available on the component instance, such as a logger, a toast notification service, or the router.
302
+
303
+ This enables better separation of concerns, where effects can trigger UI-related side effects without being tightly coupled to specific UI components.
304
+
305
+ **Example: Showing a Toast Notification from an Effect**
306
+
307
+ Imagine you have a `toast` plugin registered on your `BasePage`. You can create an effect that listens for a success action and uses the injected context to show a notification.
308
+
309
+ ```javascript
310
+ // effects/toast.effect.js
311
+ import { createEffect, ofType } from 'rx-tiny-flux';
312
+ import { tap } from 'rx-tiny-flux/rxjs';
313
+ import { operationSuccess } from '../actions';
314
+
315
+ export const showSuccessToastEffect = createEffect(
316
+ (actions$) =>
317
+ actions$.pipe(
318
+ ofType(operationSuccess),
319
+ // The action now contains the 'context' of the Page that dispatched it
320
+ tap((action) => {
321
+ // Check if the context and the toast plugin exist before using it
322
+ if (action.context && action.context.toast) {
323
+ action.context.toast.show({ text: 'Operation successful!' });
324
+ }
325
+ })
326
+ ),
327
+ // This effect does not dispatch a new action, so we set dispatch: false
328
+ { dispatch: false }
329
+ );
330
+ ```
331
+
332
+ #### Environment-Specific Effects with `isApp` and `isSideService`
333
+
334
+ When building complex ZeppOS applications, you often need effects that run exclusively on the watch face (App/Page) or in the background service (Side Service). To simplify this, `rx-tiny-flux` provides two custom RxJS operators: `isApp` and `isSideService`.
335
+
336
+ These operators filter the action stream based on the execution environment, making your effects cleaner and more declarative.
337
+
338
+ * `isApp()`: Allows actions to pass through only when running on the App/Page.
339
+ * `isSideService()`: Allows actions to pass through only when running in the Side Service.
340
+
341
+ **Example: Handling a request between App and Side Service**
342
+
343
+ ```javascript
344
+ // Import the operators from the zeppos entry point
345
+ import { createEffect, ofType } from 'rx-tiny-flux';
346
+ import { isApp, isSideService } from 'rx-tiny-flux/zeppos';
347
+ import { fetchData, fetchDataSuccess, fetchDataError } from './actions';
348
+
349
+ // This effect runs on the App side and requests data from the service
350
+ const requestDataEffect = createEffect(actions$ => actions$.pipe(
351
+ ofType(fetchData),
352
+ isApp(),
353
+ // ... logic to send a message to the side service
354
+ ));
355
+
356
+ // This effect runs on the Side Service, handles the request, and calls a backend
357
+ const handleDataRequestEffect = createEffect(actions$ => actions$.pipe(
358
+ ofType(fetchData),
359
+ isSideService(),
360
+ // ... logic to call a backend API and return the result to the app
361
+ ));
362
+ ```
363
+
364
+ #### Accessing State within Effects using `withLatestFromStore`
365
+
366
+ A common requirement for effects is to access the current state to make decisions. For example, an effect might need the current user's ID to fetch data. The `withLatestFromStore` operator is designed for this purpose, especially in ZeppOS where the `store` instance isn't readily available when defining effects.
367
+
368
+ It works by safely using the `subscribe` method injected into the action's context by the `storePlugin`.
369
+
370
+ **Example: Fetching data using a value from the state**
371
+
372
+ ```javascript
373
+ import { createEffect, ofType } from 'rx-tiny-flux';
374
+ // Import the new operator from the zeppos entry point
375
+ import { withLatestFromStore } from 'rx-tiny-flux/zeppos';
376
+ import { switchMap, map, catchError } from 'rx-tiny-flux/rxjs';
377
+ import { fetchData, fetchDataSuccess, fetchDataError } from './actions';
378
+ import { selectCurrentUserId } from './selectors';
379
+
380
+ const fetchDataEffect = createEffect(actions$ => actions$.pipe(
381
+ ofType(fetchData),
382
+ // Combines the action with the latest value from the store using the selector
383
+ withLatestFromStore(selectCurrentUserId),
384
+ // The next operator receives an array: [action, userId]
385
+ switchMap(([action, userId]) =>
386
+ from(api.fetchDataForUser(userId)).pipe(
387
+ map(data => fetchDataSuccess(data)),
388
+ catchError(error => of(fetchDataError(error)))
389
+ ))
390
+ ));
391
+ ```
392
+ ```
@@ -1100,12 +1100,12 @@ function isScheduler(value) {
1100
1100
  function last(arr) {
1101
1101
  return arr[arr.length - 1];
1102
1102
  }
1103
+ function popResultSelector(args) {
1104
+ return isFunction(last(args)) ? args.pop() : undefined;
1105
+ }
1103
1106
  function popScheduler(args) {
1104
1107
  return isScheduler(last(args)) ? args.pop() : undefined;
1105
1108
  }
1106
- function popNumber(args, defaultValue) {
1107
- return typeof last(args) === 'number' ? args.pop() : defaultValue;
1108
- }
1109
1109
 
1110
1110
  var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
1111
1111
 
@@ -1526,7 +1526,6 @@ function mergeMap(project, resultSelector, concurrent) {
1526
1526
  }
1527
1527
 
1528
1528
  function mergeAll(concurrent) {
1529
- if (concurrent === void 0) { concurrent = Infinity; }
1530
1529
  return mergeMap(identity, concurrent);
1531
1530
  }
1532
1531
 
@@ -1580,24 +1579,6 @@ function timer(dueTime, intervalOrScheduler, scheduler) {
1580
1579
  });
1581
1580
  }
1582
1581
 
1583
- function merge() {
1584
- var args = [];
1585
- for (var _i = 0; _i < arguments.length; _i++) {
1586
- args[_i] = arguments[_i];
1587
- }
1588
- var scheduler = popScheduler(args);
1589
- var concurrent = popNumber(args, Infinity);
1590
- var sources = args;
1591
- return !sources.length
1592
- ?
1593
- EMPTY
1594
- : sources.length === 1
1595
- ?
1596
- innerFrom(sources[0])
1597
- :
1598
- mergeAll(concurrent)(from(sources, scheduler));
1599
- }
1600
-
1601
1582
  function filter(predicate, thisArg) {
1602
1583
  return operate(function (source, subscriber) {
1603
1584
  var index = 0;
@@ -1892,6 +1873,38 @@ function tap(observerOrNext, error, complete) {
1892
1873
  identity;
1893
1874
  }
1894
1875
 
1876
+ function withLatestFrom() {
1877
+ var inputs = [];
1878
+ for (var _i = 0; _i < arguments.length; _i++) {
1879
+ inputs[_i] = arguments[_i];
1880
+ }
1881
+ var project = popResultSelector(inputs);
1882
+ return operate(function (source, subscriber) {
1883
+ var len = inputs.length;
1884
+ var otherValues = new Array(len);
1885
+ var hasValue = inputs.map(function () { return false; });
1886
+ var ready = false;
1887
+ var _loop_1 = function (i) {
1888
+ innerFrom(inputs[i]).subscribe(createOperatorSubscriber(subscriber, function (value) {
1889
+ otherValues[i] = value;
1890
+ if (!ready && !hasValue[i]) {
1891
+ hasValue[i] = true;
1892
+ (ready = hasValue.every(identity)) && (hasValue = null);
1893
+ }
1894
+ }, noop));
1895
+ };
1896
+ for (var i = 0; i < len; i++) {
1897
+ _loop_1(i);
1898
+ }
1899
+ source.subscribe(createOperatorSubscriber(subscriber, function (value) {
1900
+ if (ready) {
1901
+ var values = __spreadArray([value], __read(otherValues));
1902
+ subscriber.next(project ? project.apply(void 0, __spreadArray([], __read(values))) : values);
1903
+ }
1904
+ }));
1905
+ });
1906
+ }
1907
+
1895
1908
  /**
1896
1909
  * @typedef {import('./actions').Action} Action
1897
1910
  */
@@ -1988,9 +2001,20 @@ class Store {
1988
2001
  * @param {...function(import('rxjs').Observable<Action>): import('rxjs').Observable<Action>} effects
1989
2002
  */
1990
2003
  registerEffects(...effects) {
1991
- const effectStreams = effects.map((effect) => effect(this._actions$));
1992
- // Merges all action streams returned by the effects and dispatches them back into the store.
1993
- merge(...effectStreams).subscribe((action) => this.dispatch(action));
2004
+ effects.forEach((effectFn) => {
2005
+ // Check for the metadata attached by createEffect
2006
+ const config = effectFn._rxEffect || { dispatch: true };
2007
+ const effect$ = effectFn(this._actions$);
2008
+
2009
+ if (config.dispatch) {
2010
+ // If dispatch is true (default), subscribe and dispatch the resulting actions.
2011
+ effect$.subscribe(this.dispatch.bind(this));
2012
+ } else {
2013
+ // If dispatch is false, just subscribe to trigger the side-effect.
2014
+ // The output is ignored.
2015
+ effect$.subscribe();
2016
+ }
2017
+ });
1994
2018
  }
1995
2019
 
1996
2020
  /**
@@ -2118,17 +2142,23 @@ function ofType(...actionCreators) {
2118
2142
  }
2119
2143
 
2120
2144
  /**
2121
- * Factory function to create an effect.
2122
- * An effect is a function that receives the stream of all actions
2123
- * and returns a new stream of actions to be dispatched.
2145
+ * Factory function to create an effect and attaches metadata to it.
2124
2146
  *
2125
- * @param {function(ActionStream): ActionStream} effectFn
2126
- * @returns {function(ActionStream): ActionStream} The effect function.
2147
+ * @param {function(ActionStream): ActionStream} effectFn A function that takes an actions stream and returns a new stream.
2148
+ * @param {object} [config] - An optional configuration object.
2149
+ * @param {boolean} [config.dispatch=true] - If false, the effect's output will not be dispatched as an action.
2150
+ * @returns {function(ActionStream): ActionStream} The effect function with a `_rxEffect` property for metadata.
2127
2151
  */
2128
- function createEffect(effectFn) {
2152
+ function createEffect(effectFn, config = { dispatch: true }) {
2129
2153
  if (typeof effectFn !== 'function') {
2130
2154
  throw new Error('Effect must be a function.');
2131
2155
  }
2156
+ // Attach metadata to the function object itself.
2157
+ // This allows the store to identify it as an effect and read its configuration.
2158
+ Object.defineProperty(effectFn, '_rxEffect', {
2159
+ value: { dispatch: config.dispatch !== false }, // Default to true
2160
+ enumerable: false,
2161
+ });
2132
2162
  return effectFn;
2133
2163
  }
2134
2164
 
@@ -2172,4 +2202,4 @@ function createSelector(...args) {
2172
2202
  }
2173
2203
  }
2174
2204
 
2175
- export { Store, anyAction, catchError, concatMap, createAction, createEffect, createFeatureSelector, createReducer, createSelector, defer, delay, exhaustMap, filter, from, map, mergeMap, of, ofType, on, switchMap, tap };
2205
+ export { Store, anyAction, catchError, concatMap, createAction, createEffect, createFeatureSelector, createReducer, createSelector, defer, delay, exhaustMap, filter, from, map, mergeMap, of, ofType, on, switchMap, tap, withLatestFrom };
@@ -1 +1 @@
1
- var t=function(n,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},t(n,r)};function n(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}function r(t,n,r,e){return new(r||(r=Promise))(function(o,i){function u(t){try{s(e.next(t))}catch(t){i(t)}}function c(t){try{s(e.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof r?n:new r(function(t){t(n)})).then(u,c)}s((e=e.apply(t,n||[])).next())})}function e(t,n){var r,e,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(r=1,e&&(o=2&c[0]?e.return:c[0]?e.throw||((o=e.return)&&o.call(e),0):e.next)&&!(o=o.call(e,c[1])).done)return o;switch(e=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,e=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],e=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function o(t){var n="function"==typeof Symbol&&Symbol.iterator,r=n&&t[n],e=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,o,i=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(e=i.next()).done;)u.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function u(t,n,r){if(r||2===arguments.length)for(var e,o=0,i=n.length;o<i;o++)!e&&o in n||(e||(e=Array.prototype.slice.call(n,0,o)),e[o]=n[o]);return t.concat(e||Array.prototype.slice.call(n))}function c(t){return this instanceof c?(this.v=t,this):new c(t)}function s(t,n,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,o=r.apply(t,n||[]),i=[];return e=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",function(t){return function(n){return Promise.resolve(n).then(t,a)}}),e[Symbol.asyncIterator]=function(){return this},e;function u(t,n){o[t]&&(e[t]=function(n){return new Promise(function(r,e){i.push([t,n,r,e])>1||s(t,n)})},n&&(e[t]=n(e[t])))}function s(t,n){try{(r=o[t](n)).value instanceof c?Promise.resolve(r.value.v).then(l,a):f(i[0][2],r)}catch(t){f(i[0][3],t)}var r}function l(t){s("next",t)}function a(t){s("throw",t)}function f(t,n){t(n),i.shift(),i.length&&s(i[0][0],i[0][1])}}function l(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,r=t[Symbol.asyncIterator];return r?r.call(t):(t=o(t),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(r){n[r]=t[r]&&function(n){return new Promise(function(e,o){(function(t,n,r,e){Promise.resolve(e).then(function(n){t({value:n,done:r})},n)})(e,o,(n=t[r](n)).done,n.value)})}}}function a(t){return"function"==typeof t}function f(t){var n=t(function(t){Error.call(t),t.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}"function"==typeof SuppressedError&&SuppressedError;var h=f(function(t){return function(n){t(this),this.message=n?n.length+" errors occurred during unsubscription:\n"+n.map(function(t,n){return n+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=n}});function p(t,n){if(t){var r=t.indexOf(n);0<=r&&t.splice(r,1)}}var d=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var n;return t.prototype.unsubscribe=function(){var t,n,r,e,c;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var l=o(s),f=l.next();!f.done;f=l.next()){f.value.remove(this)}}catch(n){t={error:n}}finally{try{f&&!f.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}else s.remove(this);var p=this.initialTeardown;if(a(p))try{p()}catch(t){c=t instanceof h?t.errors:[t]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var v=o(d),b=v.next();!b.done;b=v.next()){var w=b.value;try{y(w)}catch(t){c=null!=c?c:[],t instanceof h?c=u(u([],i(c)),i(t.errors)):c.push(t)}}}catch(t){r={error:t}}finally{try{b&&!b.done&&(e=v.return)&&e.call(v)}finally{if(r)throw r.error}}}if(c)throw new h(c)}},t.prototype.add=function(n){var r;if(n&&n!==this)if(this.closed)y(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(n)}},t.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},t.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},t.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&p(n,t)},t.prototype.remove=function(n){var r=this._finalizers;r&&p(r,n),n instanceof t&&n._removeParent(this)},t.EMPTY=((n=new t).closed=!0,n),t}(),v=d.EMPTY;function b(t){return t instanceof d||t&&"closed"in t&&a(t.remove)&&a(t.add)&&a(t.unsubscribe)}function y(t){a(t)?t():t.unsubscribe()}var w={Promise:void 0},m=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setTimeout.apply(void 0,u([t,n],i(r)))};function _(t){m(function(){throw t})}function x(){}function g(t){t()}var S=function(t){function r(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,b(n)&&n.add(r)):r.destination=A,r}return n(r,t),r.create=function(t,n,r){return new E(t,n,r)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(d),O=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(t){I(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){I(t)}else I(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){I(t)}},t}(),E=function(t){function r(n,r,e){var o,i=t.call(this)||this;return o=a(n)||!n?{next:null!=n?n:void 0,error:null!=r?r:void 0,complete:null!=e?e:void 0}:n,i.destination=new O(o),i}return n(r,t),r}(S);function I(t){_(t)}var A={closed:!0,next:x,error:function(t){throw t},complete:x},P="function"==typeof Symbol&&Symbol.observable||"@@observable";function T(t){return t}var C=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var r=new t;return r.source=this,r.operator=n,r},t.prototype.subscribe=function(t,n,r){var e,o=this,i=(e=t)&&e instanceof S||function(t){return t&&a(t.next)&&a(t.error)&&a(t.complete)}(e)&&b(e)?t:new E(t,n,r);return g(function(){var t=o,n=t.operator,r=t.source;i.add(n?n.call(i,r):r?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},t.prototype.forEach=function(t,n){var r=this;return new(n=j(n))(function(n,e){var o=new E({next:function(n){try{t(n)}catch(t){e(t),o.unsubscribe()}},error:e,complete:n});r.subscribe(o)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[P]=function(){return this},t.prototype.pipe=function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return(0===(t=n).length?T:1===t.length?t[0]:function(n){return t.reduce(function(t,n){return n(t)},n)})(this)},t.prototype.toPromise=function(t){var n=this;return new(t=j(t))(function(t,r){var e;n.subscribe(function(t){return e=t},function(t){return r(t)},function(){return t(e)})})},t.create=function(n){return new t(n)},t}();function j(t){var n;return null!==(n=null!=t?t:w.Promise)&&void 0!==n?n:Promise}function k(t){return function(n){if(function(t){return a(null==t?void 0:t.lift)}(n))return n.lift(function(n){try{return t(n,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}function z(t,n,r,e,o){return new F(t,n,r,e,o)}var F=function(t){function r(n,r,e,o,i,u){var c=t.call(this,n)||this;return c.onFinalize=i,c.shouldUnsubscribe=u,c._next=r?function(t){try{r(t)}catch(t){n.error(t)}}:t.prototype._next,c._error=o?function(t){try{o(t)}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=e?function(){try{e()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,c}return n(r,t),r.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},r}(S),$=f(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),N=function(t){function r(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return n(r,t),r.prototype.lift=function(t){var n=new R(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new $},r.prototype.next=function(t){var n=this;g(function(){var r,e;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var i=o(n.currentObservers),u=i.next();!u.done;u=i.next()){u.value.next(t)}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}}})},r.prototype.error=function(t){var n=this;g(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var r=n.observers;r.length;)r.shift().error(t)}})},r.prototype.complete=function(){var t=this;g(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,r=this,e=r.hasError,o=r.isStopped,i=r.observers;return e||o?v:(this.currentObservers=null,i.push(t),new d(function(){n.currentObservers=null,p(i,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,r=n.hasError,e=n.thrownError,o=n.isStopped;r?t.error(e):o&&t.complete()},r.prototype.asObservable=function(){var t=new C;return t.source=this,t},r.create=function(t,n){return new R(t,n)},r}(C),R=function(t){function r(n,r){var e=t.call(this)||this;return e.destination=n,e.source=r,e}return n(r,t),r.prototype.next=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===r||r.call(n,t)},r.prototype.error=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===r||r.call(n,t)},r.prototype.complete=function(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)},r.prototype._subscribe=function(t){var n,r;return null!==(r=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==r?r:v},r}(N),J=function(t){function r(n){var r=t.call(this)||this;return r._value=n,r}return n(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var r=t.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},r.prototype.getValue=function(){var t=this,n=t.hasError,r=t.thrownError,e=t._value;if(n)throw r;return this._throwIfClosed(),e},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(N),U={now:function(){return(U.delegate||Date).now()},delegate:void 0},W=function(t){function r(n,r,e){void 0===n&&(n=1/0),void 0===r&&(r=1/0),void 0===e&&(e=U);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=e,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return n(r,t),r.prototype.next=function(n){var r=this,e=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,u=r._timestampProvider,c=r._windowTime;e||(o.push(n),!i&&o.push(u.now()+c)),this._trimBuffer(),t.prototype.next.call(this,n)},r.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),r=this._infiniteTimeWindow,e=this._buffer.slice(),o=0;o<e.length&&!t.closed;o+=r?1:2)t.next(e[o]);return this._checkFinalizedStatuses(t),n},r.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,r=t._timestampProvider,e=t._buffer,o=t._infiniteTimeWindow,i=(o?1:2)*n;if(n<1/0&&i<e.length&&e.splice(0,e.length-i),!o){for(var u=r.now(),c=0,s=1;s<e.length&&e[s]<=u;s+=2)c=s;c&&e.splice(0,c+1)}},r}(N),M=function(t){function r(n,r){return t.call(this)||this}return n(r,t),r.prototype.schedule=function(t,n){return this},r}(d),Y=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setInterval.apply(void 0,u([t,n],i(r)))},B=function(t){return clearInterval(t)},D=function(t){function r(n,r){var e=t.call(this,n,r)||this;return e.scheduler=n,e.work=r,e.pending=!1,e}return n(r,t),r.prototype.schedule=function(t,n){var r;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var e=this.id,o=this.scheduler;return null!=e&&(this.id=this.recycleAsyncId(o,e,n)),this.pending=!0,this.delay=n,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,n),this},r.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),Y(t.flush.bind(t,this),r)},r.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return n;null!=n&&B(n)},r.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,n);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},r.prototype._execute=function(t,n){var r,e=!1;try{this.work(t)}catch(t){e=!0,r=t||new Error("Scheduled action threw falsy error")}if(e)return this.unsubscribe(),r},r.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,r=this.scheduler,e=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(e,this),null!=n&&(this.id=this.recycleAsyncId(r,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},r}(M),V=function(){function t(n,r){void 0===r&&(r=t.now),this.schedulerActionCtor=n,this.now=r}return t.prototype.schedule=function(t,n,r){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},t.now=U.now,t}(),q=new(function(t){function r(n,r){void 0===r&&(r=V.now);var e=t.call(this,n,r)||this;return e.actions=[],e._active=!1,e}return n(r,t),r.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,r){for(;t=n.shift();)t.unsubscribe();throw r}}},r}(V))(D),Z=q,G=new C(function(t){return t.complete()});function K(t){return t&&a(t.schedule)}function L(t){return t[t.length-1]}function H(t){return K(L(t))?t.pop():void 0}var Q=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function X(t){return a(null==t?void 0:t.then)}function tt(t){return a(t[P])}function nt(t){return Symbol.asyncIterator&&a(null==t?void 0:t[Symbol.asyncIterator])}function rt(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var et="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ot(t){return a(null==t?void 0:t[et])}function it(t){return s(this,arguments,function(){var n,r,o;return e(this,function(e){switch(e.label){case 0:n=t.getReader(),e.label=1;case 1:e.trys.push([1,,9,10]),e.label=2;case 2:return[4,c(n.read())];case 3:return r=e.sent(),o=r.value,r.done?[4,c(void 0)]:[3,5];case 4:return[2,e.sent()];case 5:return[4,c(o)];case 6:return[4,e.sent()];case 7:return e.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function ut(t){return a(null==t?void 0:t.getReader)}function ct(t){if(t instanceof C)return t;if(null!=t){if(tt(t))return i=t,new C(function(t){var n=i[P]();if(a(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(Q(t))return e=t,new C(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()});if(X(t))return r=t,new C(function(t){r.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,_)});if(nt(t))return st(t);if(ot(t))return n=t,new C(function(t){var r,e;try{for(var i=o(n),u=i.next();!u.done;u=i.next()){var c=u.value;if(t.next(c),t.closed)return}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}t.complete()});if(ut(t))return st(it(t))}var n,r,e,i;throw rt(t)}function st(t){return new C(function(n){(function(t,n){var o,i,u,c;return r(this,void 0,void 0,function(){var r,s;return e(this,function(e){switch(e.label){case 0:e.trys.push([0,5,6,11]),o=l(t),e.label=1;case 1:return[4,o.next()];case 2:if((i=e.sent()).done)return[3,4];if(r=i.value,n.next(r),n.closed)return[2];e.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=e.sent(),u={error:s},[3,11];case 6:return e.trys.push([6,,9,10]),i&&!i.done&&(c=o.return)?[4,c.call(o)]:[3,8];case 7:e.sent(),e.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})})(t,n).catch(function(t){return n.error(t)})})}function lt(t,n,r,e,o){void 0===e&&(e=0),void 0===o&&(o=!1);var i=n.schedule(function(){r(),o?t.add(this.schedule(null,e)):this.unsubscribe()},e);if(t.add(i),!o)return i}function at(t,n){return void 0===n&&(n=0),k(function(r,e){r.subscribe(z(e,function(r){return lt(e,t,function(){return e.next(r)},n)},function(){return lt(e,t,function(){return e.complete()},n)},function(r){return lt(e,t,function(){return e.error(r)},n)}))})}function ft(t,n){return void 0===n&&(n=0),k(function(r,e){e.add(t.schedule(function(){return r.subscribe(e)},n))})}function ht(t,n){if(!t)throw new Error("Iterable cannot be null");return new C(function(r){lt(r,n,function(){var e=t[Symbol.asyncIterator]();lt(r,n,function(){e.next().then(function(t){t.done?r.complete():r.next(t.value)})},0,!0)})})}function pt(t,n){if(null!=t){if(tt(t))return function(t,n){return ct(t).pipe(ft(n),at(n))}(t,n);if(Q(t))return function(t,n){return new C(function(r){var e=0;return n.schedule(function(){e===t.length?r.complete():(r.next(t[e++]),r.closed||this.schedule())})})}(t,n);if(X(t))return function(t,n){return ct(t).pipe(ft(n),at(n))}(t,n);if(nt(t))return ht(t,n);if(ot(t))return function(t,n){return new C(function(r){var e;return lt(r,n,function(){e=t[et](),lt(r,n,function(){var t,n,o;try{n=(t=e.next()).value,o=t.done}catch(t){return void r.error(t)}o?r.complete():r.next(n)},0,!0)}),function(){return a(null==e?void 0:e.return)&&e.return()}})}(t,n);if(ut(t))return function(t,n){return ht(it(t),n)}(t,n)}throw rt(t)}function dt(t,n){return n?pt(t,n):ct(t)}function vt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return dt(t,H(t))}function bt(t,n){return k(function(r,e){var o=0;r.subscribe(z(e,function(r){e.next(t.call(n,r,o++))}))})}function yt(t,n,r){return void 0===r&&(r=1/0),a(n)?yt(function(r,e){return bt(function(t,o){return n(r,t,e,o)})(ct(t(r,e)))},r):("number"==typeof n&&(r=n),k(function(n,e){return function(t,n,r,e,o,i,u){var c=[],s=0,l=0,a=!1,f=function(){!a||c.length||s||n.complete()},h=function(t){s++;var o=!1;ct(r(t,l++)).subscribe(z(n,function(t){n.next(t)},function(){o=!0},void 0,function(){if(o)try{s--;for(var t=function(){var t=c.shift();u||h(t)};c.length&&s<e;)t();f()}catch(t){n.error(t)}}))};return t.subscribe(z(n,function(t){return s<e?h(t):c.push(t)},function(){a=!0,f()})),function(){}}(n,e,t,r)}))}function wt(t){return void 0===t&&(t=1/0),yt(T,t)}function mt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return wt(1)(dt(t,H(t)))}function _t(t){return new C(function(n){ct(t()).subscribe(n)})}function xt(t,n,r){void 0===t&&(t=0),void 0===r&&(r=Z);var e=-1;return null!=n&&(K(n)?r=n:e=n),new C(function(n){var o,i=(o=t)instanceof Date&&!isNaN(o)?+t-r.now():t;i<0&&(i=0);var u=0;return r.schedule(function(){n.closed||(n.next(u++),0<=e?this.schedule(void 0,e):n.complete())},i)})}function gt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=H(t),e=function(t,n){return"number"==typeof L(t)?t.pop():n}(t,1/0),o=t;return o.length?1===o.length?ct(o[0]):wt(e)(dt(o,r)):G}function St(t,n){return k(function(r,e){var o=0;r.subscribe(z(e,function(r){return t.call(n,r,o++)&&e.next(r)}))})}function Ot(t){return k(function(n,r){var e,o=null,i=!1;o=n.subscribe(z(r,void 0,void 0,function(u){e=ct(t(u,Ot(t)(n))),o?(o.unsubscribe(),o=null,e.subscribe(r)):i=!0})),i&&(o.unsubscribe(),o=null,e.subscribe(r))})}function Et(t,n){return a(n)?yt(t,n,1):yt(t,1)}function It(t,n){return yt(function(n,r){return ct(t(n,r)).pipe((e=1)<=0?function(){return G}:k(function(t,n){var r=0;t.subscribe(z(n,function(t){++r<=e&&(n.next(t),e<=r&&n.complete())}))}),function(t){return bt(function(){return t})}(n));var e})}function At(t,n){void 0===n&&(n=q);var r=xt(t,n);return It(function(){return r})}function Pt(t,n){return t===n}function Tt(t,n){return n?function(r){return r.pipe(Tt(function(r,e){return ct(t(r,e)).pipe(bt(function(t,o){return n(r,t,e,o)}))}))}:k(function(n,r){var e=0,o=null,i=!1;n.subscribe(z(r,function(n){o||(o=z(r,void 0,function(){o=null,i&&r.complete()}),ct(t(n,e++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Ct(t,n){return k(function(t,n,r,e,o){return function(e,i){var u=r,c=n,s=0;e.subscribe(z(i,function(n){var r=s++;c=u?t(c,n,r):(u=!0,n),i.next(c)},o))}}(t,n,arguments.length>=2))}function jt(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];if(!0!==n){if(!1!==n){var o=new E({next:function(){o.unsubscribe(),t()}});return ct(n.apply(void 0,u([],i(r)))).subscribe(o)}}else t()}function kt(t,n,r){var e;return e=t,function(t){void 0===t&&(t={});var n=t.connector,r=void 0===n?function(){return new N}:n,e=t.resetOnError,o=void 0===e||e,i=t.resetOnComplete,u=void 0===i||i,c=t.resetOnRefCountZero,s=void 0===c||c;return function(t){var n,e,i,c=0,l=!1,a=!1,f=function(){null==e||e.unsubscribe(),e=void 0},h=function(){f(),n=i=void 0,l=a=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return k(function(t,d){c++,a||l||f();var v=i=null!=i?i:r();d.add(function(){0!==--c||a||l||(e=jt(p,s))}),v.subscribe(d),!n&&c>0&&(n=new E({next:function(t){return v.next(t)},error:function(t){a=!0,f(),e=jt(h,o,t),v.error(t)},complete:function(){l=!0,f(),e=jt(h,u),v.complete()}}),ct(t).subscribe(n))})(t)}}({connector:function(){return new W(e,n,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function zt(t,n){return k(function(r,e){var o=null,i=0,u=!1,c=function(){return u&&!o&&e.complete()};r.subscribe(z(e,function(r){null==o||o.unsubscribe();var u=0,s=i++;ct(t(r,s)).subscribe(o=z(e,function(t){return e.next(n?n(r,t,s,u++):t)},function(){o=null,c()}))},function(){u=!0,c()}))})}function Ft(t,n,r){var e=a(t)||n||r?{next:t,error:n,complete:r}:t;return e?k(function(t,n){var r;null===(r=e.subscribe)||void 0===r||r.call(e);var o=!0;t.subscribe(z(n,function(t){var r;null===(r=e.next)||void 0===r||r.call(e,t),n.next(t)},function(){var t;o=!1,null===(t=e.complete)||void 0===t||t.call(e),n.complete()},function(t){var r;o=!1,null===(r=e.error)||void 0===r||r.call(e,t),n.error(t)},function(){var t,n;o&&(null===(t=e.unsubscribe)||void 0===t||t.call(e)),null===(n=e.finalize)||void 0===n||n.call(e)}))}):T}class $t{_state$;_actions$=new N;_reducers=[];constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new J(n);const r=this._actions$.pipe(Ft(t=>console.log("Action Dispatched:",t))).pipe(Ct((t,n)=>{const r=JSON.parse(JSON.stringify(t));return this._reducers.forEach(({path:t,reducerFn:e})=>{const o=r[t],i=e(o,n);void 0!==i&&o!==i&&(r[t]=i)}),r},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=H(t);return k(function(n,e){(r?mt(t,n,r):mt(t,n)).subscribe(e)})}(t),kt(1));r.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n=this._state$.getValue(),r=JSON.parse(JSON.stringify(n));t.forEach(({path:t,initialState:n})=>{void 0===r[t]&&(r[t]=n)}),this._state$.next(r)}registerEffects(...t){gt(...t.map(t=>t(this._actions$))).subscribe(t=>this.dispatch(t))}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(bt(n=>t(n)),(void 0===r&&(r=T),n=null!=n?n:Pt,k(function(t,e){var o,i=!0;t.subscribe(z(e,function(t){var u=r(t);!i&&n(o,u)||(i=!1,o=u,e.next(t))}))})));var n,r}}function Nt(t){const n=n=>({type:t,payload:n});return n.type=t,n}function Rt(){}function Jt(...t){const n=t.pop(),r=t,e=r.includes(Rt);if(e&&r.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:r.map(t=>t.type),reducerFn:n,isCatchAll:e}}function Ut(t,n,...r){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const e=r.filter(t=>!t.isCatchAll),o=r.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,r)=>{for(const n of e)if(n.types.includes(r.type))return n.reducerFn(t,r);return o?o.reducerFn(t,r):t}}}function Wt(...t){const n=t.map(t=>t.type);return St(t=>n.includes(t.type))}function Mt(t){if("function"!=typeof t)throw new Error("Effect must be a function.");return t}function Yt(t,n){return r=>{const e=r[t];return n?n(e):e}}function Bt(...t){const n=t.pop(),r=t;if("function"!=typeof n)throw new Error("The last argument to createSelector must be a projection function.");return t=>{const e=r.map(n=>n(t));return n(...e)}}export{$t as Store,Rt as anyAction,Ot as catchError,Et as concatMap,Nt as createAction,Mt as createEffect,Yt as createFeatureSelector,Ut as createReducer,Bt as createSelector,_t as defer,At as delay,Tt as exhaustMap,St as filter,dt as from,bt as map,yt as mergeMap,vt as of,Wt as ofType,Jt as on,zt as switchMap,Ft as tap};
1
+ var t=function(n,r){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},t(n,r)};function n(n,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function e(){this.constructor=n}t(n,r),n.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}function r(t,n,r,e){return new(r||(r=Promise))(function(o,i){function u(t){try{s(e.next(t))}catch(t){i(t)}}function c(t){try{s(e.throw(t))}catch(t){i(t)}}function s(t){var n;t.done?o(t.value):(n=t.value,n instanceof r?n:new r(function(t){t(n)})).then(u,c)}s((e=e.apply(t,n||[])).next())})}function e(t,n){var r,e,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=c(0),u.throw=c(1),u.return=c(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,c[0]&&(i=0)),i;)try{if(r=1,e&&(o=2&c[0]?e.return:c[0]?e.throw||((o=e.return)&&o.call(e),0):e.next)&&!(o=o.call(e,c[1])).done)return o;switch(e=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return i.label++,{value:c[1],done:!1};case 5:i.label++,e=c[1],c=[0];continue;case 7:c=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){i=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){i.label=c[1];break}if(6===c[0]&&i.label<o[1]){i.label=o[1],o=c;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(c);break}o[2]&&i.ops.pop(),i.trys.pop();continue}c=n.call(t,i)}catch(t){c=[6,t],e=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function o(t){var n="function"==typeof Symbol&&Symbol.iterator,r=n&&t[n],e=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(n?"Object is not iterable.":"Symbol.iterator is not defined.")}function i(t,n){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var e,o,i=r.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(e=i.next()).done;)u.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u}function u(t,n,r){if(r||2===arguments.length)for(var e,o=0,i=n.length;o<i;o++)!e&&o in n||(e||(e=Array.prototype.slice.call(n,0,o)),e[o]=n[o]);return t.concat(e||Array.prototype.slice.call(n))}function c(t){return this instanceof c?(this.v=t,this):new c(t)}function s(t,n,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,o=r.apply(t,n||[]),i=[];return e=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",function(t){return function(n){return Promise.resolve(n).then(t,l)}}),e[Symbol.asyncIterator]=function(){return this},e;function u(t,n){o[t]&&(e[t]=function(n){return new Promise(function(r,e){i.push([t,n,r,e])>1||s(t,n)})},n&&(e[t]=n(e[t])))}function s(t,n){try{(r=o[t](n)).value instanceof c?Promise.resolve(r.value.v).then(a,l):f(i[0][2],r)}catch(t){f(i[0][3],t)}var r}function a(t){s("next",t)}function l(t){s("throw",t)}function f(t,n){t(n),i.shift(),i.length&&s(i[0][0],i[0][1])}}function a(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,r=t[Symbol.asyncIterator];return r?r.call(t):(t=o(t),n={},e("next"),e("throw"),e("return"),n[Symbol.asyncIterator]=function(){return this},n);function e(r){n[r]=t[r]&&function(n){return new Promise(function(e,o){(function(t,n,r,e){Promise.resolve(e).then(function(n){t({value:n,done:r})},n)})(e,o,(n=t[r](n)).done,n.value)})}}}function l(t){return"function"==typeof t}function f(t){var n=t(function(t){Error.call(t),t.stack=(new Error).stack});return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}"function"==typeof SuppressedError&&SuppressedError;var h=f(function(t){return function(n){t(this),this.message=n?n.length+" errors occurred during unsubscription:\n"+n.map(function(t,n){return n+1+") "+t.toString()}).join("\n "):"",this.name="UnsubscriptionError",this.errors=n}});function p(t,n){if(t){var r=t.indexOf(n);0<=r&&t.splice(r,1)}}var d=function(){function t(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}var n;return t.prototype.unsubscribe=function(){var t,n,r,e,c;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var a=o(s),f=a.next();!f.done;f=a.next()){f.value.remove(this)}}catch(n){t={error:n}}finally{try{f&&!f.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}else s.remove(this);var p=this.initialTeardown;if(l(p))try{p()}catch(t){c=t instanceof h?t.errors:[t]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var v=o(d),b=v.next();!b.done;b=v.next()){var w=b.value;try{y(w)}catch(t){c=null!=c?c:[],t instanceof h?c=u(u([],i(c)),i(t.errors)):c.push(t)}}}catch(t){r={error:t}}finally{try{b&&!b.done&&(e=v.return)&&e.call(v)}finally{if(r)throw r.error}}}if(c)throw new h(c)}},t.prototype.add=function(n){var r;if(n&&n!==this)if(this.closed)y(n);else{if(n instanceof t){if(n.closed||n._hasParent(this))return;n._addParent(this)}(this._finalizers=null!==(r=this._finalizers)&&void 0!==r?r:[]).push(n)}},t.prototype._hasParent=function(t){var n=this._parentage;return n===t||Array.isArray(n)&&n.includes(t)},t.prototype._addParent=function(t){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(t),n):n?[n,t]:t},t.prototype._removeParent=function(t){var n=this._parentage;n===t?this._parentage=null:Array.isArray(n)&&p(n,t)},t.prototype.remove=function(n){var r=this._finalizers;r&&p(r,n),n instanceof t&&n._removeParent(this)},t.EMPTY=((n=new t).closed=!0,n),t}(),v=d.EMPTY;function b(t){return t instanceof d||t&&"closed"in t&&l(t.remove)&&l(t.add)&&l(t.unsubscribe)}function y(t){l(t)?t():t.unsubscribe()}var w={Promise:void 0},m=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setTimeout.apply(void 0,u([t,n],i(r)))};function _(t){m(function(){throw t})}function x(){}function g(t){t()}var S=function(t){function r(n){var r=t.call(this)||this;return r.isStopped=!1,n?(r.destination=n,b(n)&&n.add(r)):r.destination=A,r}return n(r,t),r.create=function(t,n,r){return new O(t,n,r)},r.prototype.next=function(t){this.isStopped||this._next(t)},r.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(t){this.destination.next(t)},r.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(d),E=function(){function t(t){this.partialObserver=t}return t.prototype.next=function(t){var n=this.partialObserver;if(n.next)try{n.next(t)}catch(t){I(t)}},t.prototype.error=function(t){var n=this.partialObserver;if(n.error)try{n.error(t)}catch(t){I(t)}else I(t)},t.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(t){I(t)}},t}(),O=function(t){function r(n,r,e){var o,i=t.call(this)||this;return o=l(n)||!n?{next:null!=n?n:void 0,error:null!=r?r:void 0,complete:null!=e?e:void 0}:n,i.destination=new E(o),i}return n(r,t),r}(S);function I(t){_(t)}var A={closed:!0,next:x,error:function(t){throw t},complete:x},P="function"==typeof Symbol&&Symbol.observable||"@@observable";function T(t){return t}var C=function(){function t(t){t&&(this._subscribe=t)}return t.prototype.lift=function(n){var r=new t;return r.source=this,r.operator=n,r},t.prototype.subscribe=function(t,n,r){var e,o=this,i=(e=t)&&e instanceof S||function(t){return t&&l(t.next)&&l(t.error)&&l(t.complete)}(e)&&b(e)?t:new O(t,n,r);return g(function(){var t=o,n=t.operator,r=t.source;i.add(n?n.call(i,r):r?o._subscribe(i):o._trySubscribe(i))}),i},t.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(n){t.error(n)}},t.prototype.forEach=function(t,n){var r=this;return new(n=j(n))(function(n,e){var o=new O({next:function(n){try{t(n)}catch(t){e(t),o.unsubscribe()}},error:e,complete:n});r.subscribe(o)})},t.prototype._subscribe=function(t){var n;return null===(n=this.source)||void 0===n?void 0:n.subscribe(t)},t.prototype[P]=function(){return this},t.prototype.pipe=function(){for(var t,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return(0===(t=n).length?T:1===t.length?t[0]:function(n){return t.reduce(function(t,n){return n(t)},n)})(this)},t.prototype.toPromise=function(t){var n=this;return new(t=j(t))(function(t,r){var e;n.subscribe(function(t){return e=t},function(t){return r(t)},function(){return t(e)})})},t.create=function(n){return new t(n)},t}();function j(t){var n;return null!==(n=null!=t?t:w.Promise)&&void 0!==n?n:Promise}function k(t){return function(n){if(function(t){return l(null==t?void 0:t.lift)}(n))return n.lift(function(n){try{return t(n,this)}catch(t){this.error(t)}});throw new TypeError("Unable to lift unknown Observable type")}}function z(t,n,r,e,o){return new F(t,n,r,e,o)}var F=function(t){function r(n,r,e,o,i,u){var c=t.call(this,n)||this;return c.onFinalize=i,c.shouldUnsubscribe=u,c._next=r?function(t){try{r(t)}catch(t){n.error(t)}}:t.prototype._next,c._error=o?function(t){try{o(t)}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._error,c._complete=e?function(){try{e()}catch(t){n.error(t)}finally{this.unsubscribe()}}:t.prototype._complete,c}return n(r,t),r.prototype.unsubscribe=function(){var n;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var r=this.closed;t.prototype.unsubscribe.call(this),!r&&(null===(n=this.onFinalize)||void 0===n||n.call(this))}},r}(S),$=f(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),N=function(t){function r(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return n(r,t),r.prototype.lift=function(t){var n=new R(this,this);return n.operator=t,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new $},r.prototype.next=function(t){var n=this;g(function(){var r,e;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var i=o(n.currentObservers),u=i.next();!u.done;u=i.next()){u.value.next(t)}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}}})},r.prototype.error=function(t){var n=this;g(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=t;for(var r=n.observers;r.length;)r.shift().error(t)}})},r.prototype.complete=function(){var t=this;g(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var n=t.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},r.prototype._innerSubscribe=function(t){var n=this,r=this,e=r.hasError,o=r.isStopped,i=r.observers;return e||o?v:(this.currentObservers=null,i.push(t),new d(function(){n.currentObservers=null,p(i,t)}))},r.prototype._checkFinalizedStatuses=function(t){var n=this,r=n.hasError,e=n.thrownError,o=n.isStopped;r?t.error(e):o&&t.complete()},r.prototype.asObservable=function(){var t=new C;return t.source=this,t},r.create=function(t,n){return new R(t,n)},r}(C),R=function(t){function r(n,r){var e=t.call(this)||this;return e.destination=n,e.source=r,e}return n(r,t),r.prototype.next=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.next)||void 0===r||r.call(n,t)},r.prototype.error=function(t){var n,r;null===(r=null===(n=this.destination)||void 0===n?void 0:n.error)||void 0===r||r.call(n,t)},r.prototype.complete=function(){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.complete)||void 0===n||n.call(t)},r.prototype._subscribe=function(t){var n,r;return null!==(r=null===(n=this.source)||void 0===n?void 0:n.subscribe(t))&&void 0!==r?r:v},r}(N),J=function(t){function r(n){var r=t.call(this)||this;return r._value=n,r}return n(r,t),Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var r=t.prototype._subscribe.call(this,n);return!r.closed&&n.next(this._value),r},r.prototype.getValue=function(){var t=this,n=t.hasError,r=t.thrownError,e=t._value;if(n)throw r;return this._throwIfClosed(),e},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(N),U={now:function(){return(U.delegate||Date).now()},delegate:void 0},W=function(t){function r(n,r,e){void 0===n&&(n=1/0),void 0===r&&(r=1/0),void 0===e&&(e=U);var o=t.call(this)||this;return o._bufferSize=n,o._windowTime=r,o._timestampProvider=e,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=r===1/0,o._bufferSize=Math.max(1,n),o._windowTime=Math.max(1,r),o}return n(r,t),r.prototype.next=function(n){var r=this,e=r.isStopped,o=r._buffer,i=r._infiniteTimeWindow,u=r._timestampProvider,c=r._windowTime;e||(o.push(n),!i&&o.push(u.now()+c)),this._trimBuffer(),t.prototype.next.call(this,n)},r.prototype._subscribe=function(t){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(t),r=this._infiniteTimeWindow,e=this._buffer.slice(),o=0;o<e.length&&!t.closed;o+=r?1:2)t.next(e[o]);return this._checkFinalizedStatuses(t),n},r.prototype._trimBuffer=function(){var t=this,n=t._bufferSize,r=t._timestampProvider,e=t._buffer,o=t._infiniteTimeWindow,i=(o?1:2)*n;if(n<1/0&&i<e.length&&e.splice(0,e.length-i),!o){for(var u=r.now(),c=0,s=1;s<e.length&&e[s]<=u;s+=2)c=s;c&&e.splice(0,c+1)}},r}(N),M=function(t){function r(n,r){return t.call(this)||this}return n(r,t),r.prototype.schedule=function(t,n){return this},r}(d),Y=function(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];return setInterval.apply(void 0,u([t,n],i(r)))},B=function(t){return clearInterval(t)},D=function(t){function r(n,r){var e=t.call(this,n,r)||this;return e.scheduler=n,e.work=r,e.pending=!1,e}return n(r,t),r.prototype.schedule=function(t,n){var r;if(void 0===n&&(n=0),this.closed)return this;this.state=t;var e=this.id,o=this.scheduler;return null!=e&&(this.id=this.recycleAsyncId(o,e,n)),this.pending=!0,this.delay=n,this.id=null!==(r=this.id)&&void 0!==r?r:this.requestAsyncId(o,this.id,n),this},r.prototype.requestAsyncId=function(t,n,r){return void 0===r&&(r=0),Y(t.flush.bind(t,this),r)},r.prototype.recycleAsyncId=function(t,n,r){if(void 0===r&&(r=0),null!=r&&this.delay===r&&!1===this.pending)return n;null!=n&&B(n)},r.prototype.execute=function(t,n){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var r=this._execute(t,n);if(r)return r;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},r.prototype._execute=function(t,n){var r,e=!1;try{this.work(t)}catch(t){e=!0,r=t||new Error("Scheduled action threw falsy error")}if(e)return this.unsubscribe(),r},r.prototype.unsubscribe=function(){if(!this.closed){var n=this.id,r=this.scheduler,e=r.actions;this.work=this.state=this.scheduler=null,this.pending=!1,p(e,this),null!=n&&(this.id=this.recycleAsyncId(r,n,null)),this.delay=null,t.prototype.unsubscribe.call(this)}},r}(M),V=function(){function t(n,r){void 0===r&&(r=t.now),this.schedulerActionCtor=n,this.now=r}return t.prototype.schedule=function(t,n,r){return void 0===n&&(n=0),new this.schedulerActionCtor(this,t).schedule(r,n)},t.now=U.now,t}(),q=new(function(t){function r(n,r){void 0===r&&(r=V.now);var e=t.call(this,n,r)||this;return e.actions=[],e._active=!1,e}return n(r,t),r.prototype.flush=function(t){var n=this.actions;if(this._active)n.push(t);else{var r;this._active=!0;do{if(r=t.execute(t.state,t.delay))break}while(t=n.shift());if(this._active=!1,r){for(;t=n.shift();)t.unsubscribe();throw r}}},r}(V))(D),Z=q,G=new C(function(t){return t.complete()});function K(t){return t&&l(t.schedule)}function L(t){return t[t.length-1]}function H(t){return K(L(t))?t.pop():void 0}var Q=function(t){return t&&"number"==typeof t.length&&"function"!=typeof t};function X(t){return l(null==t?void 0:t.then)}function tt(t){return l(t[P])}function nt(t){return Symbol.asyncIterator&&l(null==t?void 0:t[Symbol.asyncIterator])}function rt(t){return new TypeError("You provided "+(null!==t&&"object"==typeof t?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var et="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function ot(t){return l(null==t?void 0:t[et])}function it(t){return s(this,arguments,function(){var n,r,o;return e(this,function(e){switch(e.label){case 0:n=t.getReader(),e.label=1;case 1:e.trys.push([1,,9,10]),e.label=2;case 2:return[4,c(n.read())];case 3:return r=e.sent(),o=r.value,r.done?[4,c(void 0)]:[3,5];case 4:return[2,e.sent()];case 5:return[4,c(o)];case 6:return[4,e.sent()];case 7:return e.sent(),[3,2];case 8:return[3,10];case 9:return n.releaseLock(),[7];case 10:return[2]}})})}function ut(t){return l(null==t?void 0:t.getReader)}function ct(t){if(t instanceof C)return t;if(null!=t){if(tt(t))return i=t,new C(function(t){var n=i[P]();if(l(n.subscribe))return n.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")});if(Q(t))return e=t,new C(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()});if(X(t))return r=t,new C(function(t){r.then(function(n){t.closed||(t.next(n),t.complete())},function(n){return t.error(n)}).then(null,_)});if(nt(t))return st(t);if(ot(t))return n=t,new C(function(t){var r,e;try{for(var i=o(n),u=i.next();!u.done;u=i.next()){var c=u.value;if(t.next(c),t.closed)return}}catch(t){r={error:t}}finally{try{u&&!u.done&&(e=i.return)&&e.call(i)}finally{if(r)throw r.error}}t.complete()});if(ut(t))return st(it(t))}var n,r,e,i;throw rt(t)}function st(t){return new C(function(n){(function(t,n){var o,i,u,c;return r(this,void 0,void 0,function(){var r,s;return e(this,function(e){switch(e.label){case 0:e.trys.push([0,5,6,11]),o=a(t),e.label=1;case 1:return[4,o.next()];case 2:if((i=e.sent()).done)return[3,4];if(r=i.value,n.next(r),n.closed)return[2];e.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=e.sent(),u={error:s},[3,11];case 6:return e.trys.push([6,,9,10]),i&&!i.done&&(c=o.return)?[4,c.call(o)]:[3,8];case 7:e.sent(),e.label=8;case 8:return[3,10];case 9:if(u)throw u.error;return[7];case 10:return[7];case 11:return n.complete(),[2]}})})})(t,n).catch(function(t){return n.error(t)})})}function at(t,n,r,e,o){void 0===e&&(e=0),void 0===o&&(o=!1);var i=n.schedule(function(){r(),o?t.add(this.schedule(null,e)):this.unsubscribe()},e);if(t.add(i),!o)return i}function lt(t,n){return void 0===n&&(n=0),k(function(r,e){r.subscribe(z(e,function(r){return at(e,t,function(){return e.next(r)},n)},function(){return at(e,t,function(){return e.complete()},n)},function(r){return at(e,t,function(){return e.error(r)},n)}))})}function ft(t,n){return void 0===n&&(n=0),k(function(r,e){e.add(t.schedule(function(){return r.subscribe(e)},n))})}function ht(t,n){if(!t)throw new Error("Iterable cannot be null");return new C(function(r){at(r,n,function(){var e=t[Symbol.asyncIterator]();at(r,n,function(){e.next().then(function(t){t.done?r.complete():r.next(t.value)})},0,!0)})})}function pt(t,n){if(null!=t){if(tt(t))return function(t,n){return ct(t).pipe(ft(n),lt(n))}(t,n);if(Q(t))return function(t,n){return new C(function(r){var e=0;return n.schedule(function(){e===t.length?r.complete():(r.next(t[e++]),r.closed||this.schedule())})})}(t,n);if(X(t))return function(t,n){return ct(t).pipe(ft(n),lt(n))}(t,n);if(nt(t))return ht(t,n);if(ot(t))return function(t,n){return new C(function(r){var e;return at(r,n,function(){e=t[et](),at(r,n,function(){var t,n,o;try{n=(t=e.next()).value,o=t.done}catch(t){return void r.error(t)}o?r.complete():r.next(n)},0,!0)}),function(){return l(null==e?void 0:e.return)&&e.return()}})}(t,n);if(ut(t))return function(t,n){return ht(it(t),n)}(t,n)}throw rt(t)}function dt(t,n){return n?pt(t,n):ct(t)}function vt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return dt(t,H(t))}function bt(t,n){return k(function(r,e){var o=0;r.subscribe(z(e,function(r){e.next(t.call(n,r,o++))}))})}function yt(t,n,r){return void 0===r&&(r=1/0),l(n)?yt(function(r,e){return bt(function(t,o){return n(r,t,e,o)})(ct(t(r,e)))},r):("number"==typeof n&&(r=n),k(function(n,e){return function(t,n,r,e,o,i,u){var c=[],s=0,a=0,l=!1,f=function(){!l||c.length||s||n.complete()},h=function(t){s++;var o=!1;ct(r(t,a++)).subscribe(z(n,function(t){n.next(t)},function(){o=!0},void 0,function(){if(o)try{s--;for(var t=function(){var t=c.shift();u||h(t)};c.length&&s<e;)t();f()}catch(t){n.error(t)}}))};return t.subscribe(z(n,function(t){return s<e?h(t):c.push(t)},function(){l=!0,f()})),function(){}}(n,e,t,r)}))}function wt(){return yt(T,1)}function mt(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return wt()(dt(t,H(t)))}function _t(t){return new C(function(n){ct(t()).subscribe(n)})}function xt(t,n,r){void 0===t&&(t=0),void 0===r&&(r=Z);var e=-1;return null!=n&&(K(n)?r=n:e=n),new C(function(n){var o,i=(o=t)instanceof Date&&!isNaN(o)?+t-r.now():t;i<0&&(i=0);var u=0;return r.schedule(function(){n.closed||(n.next(u++),0<=e?this.schedule(void 0,e):n.complete())},i)})}function gt(t,n){return k(function(r,e){var o=0;r.subscribe(z(e,function(r){return t.call(n,r,o++)&&e.next(r)}))})}function St(t){return k(function(n,r){var e,o=null,i=!1;o=n.subscribe(z(r,void 0,void 0,function(u){e=ct(t(u,St(t)(n))),o?(o.unsubscribe(),o=null,e.subscribe(r)):i=!0})),i&&(o.unsubscribe(),o=null,e.subscribe(r))})}function Et(t,n){return l(n)?yt(t,n,1):yt(t,1)}function Ot(t,n){return yt(function(n,r){return ct(t(n,r)).pipe((e=1)<=0?function(){return G}:k(function(t,n){var r=0;t.subscribe(z(n,function(t){++r<=e&&(n.next(t),e<=r&&n.complete())}))}),function(t){return bt(function(){return t})}(n));var e})}function It(t,n){void 0===n&&(n=q);var r=xt(t,n);return Ot(function(){return r})}function At(t,n){return t===n}function Pt(t,n){return n?function(r){return r.pipe(Pt(function(r,e){return ct(t(r,e)).pipe(bt(function(t,o){return n(r,t,e,o)}))}))}:k(function(n,r){var e=0,o=null,i=!1;n.subscribe(z(r,function(n){o||(o=z(r,void 0,function(){o=null,i&&r.complete()}),ct(t(n,e++)).subscribe(o))},function(){i=!0,!o&&r.complete()}))})}function Tt(t,n){return k(function(t,n,r,e,o){return function(e,i){var u=r,c=n,s=0;e.subscribe(z(i,function(n){var r=s++;c=u?t(c,n,r):(u=!0,n),i.next(c)},o))}}(t,n,arguments.length>=2))}function Ct(t,n){for(var r=[],e=2;e<arguments.length;e++)r[e-2]=arguments[e];if(!0!==n){if(!1!==n){var o=new O({next:function(){o.unsubscribe(),t()}});return ct(n.apply(void 0,u([],i(r)))).subscribe(o)}}else t()}function jt(t,n,r){var e;return e=t,function(t){void 0===t&&(t={});var n=t.connector,r=void 0===n?function(){return new N}:n,e=t.resetOnError,o=void 0===e||e,i=t.resetOnComplete,u=void 0===i||i,c=t.resetOnRefCountZero,s=void 0===c||c;return function(t){var n,e,i,c=0,a=!1,l=!1,f=function(){null==e||e.unsubscribe(),e=void 0},h=function(){f(),n=i=void 0,a=l=!1},p=function(){var t=n;h(),null==t||t.unsubscribe()};return k(function(t,d){c++,l||a||f();var v=i=null!=i?i:r();d.add(function(){0!==--c||l||a||(e=Ct(p,s))}),v.subscribe(d),!n&&c>0&&(n=new O({next:function(t){return v.next(t)},error:function(t){l=!0,f(),e=Ct(h,o,t),v.error(t)},complete:function(){a=!0,f(),e=Ct(h,u),v.complete()}}),ct(t).subscribe(n))})(t)}}({connector:function(){return new W(e,n,r)},resetOnError:!0,resetOnComplete:!1,resetOnRefCountZero:!1})}function kt(t,n){return k(function(r,e){var o=null,i=0,u=!1,c=function(){return u&&!o&&e.complete()};r.subscribe(z(e,function(r){null==o||o.unsubscribe();var u=0,s=i++;ct(t(r,s)).subscribe(o=z(e,function(t){return e.next(n?n(r,t,s,u++):t)},function(){o=null,c()}))},function(){u=!0,c()}))})}function zt(t,n,r){var e=l(t)||n||r?{next:t,error:n,complete:r}:t;return e?k(function(t,n){var r;null===(r=e.subscribe)||void 0===r||r.call(e);var o=!0;t.subscribe(z(n,function(t){var r;null===(r=e.next)||void 0===r||r.call(e,t),n.next(t)},function(){var t;o=!1,null===(t=e.complete)||void 0===t||t.call(e),n.complete()},function(t){var r;o=!1,null===(r=e.error)||void 0===r||r.call(e,t),n.error(t)},function(){var t,n;o&&(null===(t=e.unsubscribe)||void 0===t||t.call(e)),null===(n=e.finalize)||void 0===n||n.call(e)}))}):T}function Ft(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r,e=l(L(r=t))?r.pop():void 0;return k(function(n,r){for(var o=t.length,c=new Array(o),s=t.map(function(){return!1}),a=!1,l=function(n){ct(t[n]).subscribe(z(r,function(t){c[n]=t,a||s[n]||(s[n]=!0,(a=s.every(T))&&(s=null))},x))},f=0;f<o;f++)l(f);n.subscribe(z(r,function(t){if(a){var n=u([t],i(c));r.next(e?e.apply(void 0,u([],i(n))):n)}}))})}class $t{_state$;_actions$=new N;_reducers=[];constructor(t={}){const n="function"==typeof structuredClone?structuredClone(t):JSON.parse(JSON.stringify(t));this._state$=new J(n);const r=this._actions$.pipe(zt(t=>console.log("Action Dispatched:",t))).pipe(Tt((t,n)=>{const r=JSON.parse(JSON.stringify(t));return this._reducers.forEach(({path:t,reducerFn:e})=>{const o=r[t],i=e(o,n);void 0!==i&&o!==i&&(r[t]=i)}),r},n),function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=H(t);return k(function(n,e){(r?mt(t,n,r):mt(t,n)).subscribe(e)})}(t),jt(1));r.subscribe(this._state$)}registerReducers(...t){this._reducers.push(...t);const n=this._state$.getValue(),r=JSON.parse(JSON.stringify(n));t.forEach(({path:t,initialState:n})=>{void 0===r[t]&&(r[t]=n)}),this._state$.next(r)}registerEffects(...t){t.forEach(t=>{const n=t._rxEffect||{dispatch:!0},r=t(this._actions$);n.dispatch?r.subscribe(this.dispatch.bind(this)):r.subscribe()})}dispatch(t){this._actions$.next(t)}select(t){return this._state$.pipe(bt(n=>t(n)),(void 0===r&&(r=T),n=null!=n?n:At,k(function(t,e){var o,i=!0;t.subscribe(z(e,function(t){var u=r(t);!i&&n(o,u)||(i=!1,o=u,e.next(t))}))})));var n,r}}function Nt(t){const n=n=>({type:t,payload:n});return n.type=t,n}function Rt(){}function Jt(...t){const n=t.pop(),r=t,e=r.includes(Rt);if(e&&r.length>1)throw new Error("The `anyAction` token cannot be mixed with other action creators in a single `on` handler.");return{types:r.map(t=>t.type),reducerFn:n,isCatchAll:e}}function Ut(t,n,...r){if(!t||"string"!=typeof t)throw new Error("Reducer featureKey must be a non-empty string.");const e=r.filter(t=>!t.isCatchAll),o=r.find(t=>t.isCatchAll);return{path:t,initialState:n,reducerFn:(t=n,r)=>{for(const n of e)if(n.types.includes(r.type))return n.reducerFn(t,r);return o?o.reducerFn(t,r):t}}}function Wt(...t){const n=t.map(t=>t.type);return gt(t=>n.includes(t.type))}function Mt(t,n={dispatch:!0}){if("function"!=typeof t)throw new Error("Effect must be a function.");return Object.defineProperty(t,"_rxEffect",{value:{dispatch:!1!==n.dispatch},enumerable:!1}),t}function Yt(t,n){return r=>{const e=r[t];return n?n(e):e}}function Bt(...t){const n=t.pop(),r=t;if("function"!=typeof n)throw new Error("The last argument to createSelector must be a projection function.");return t=>{const e=r.map(n=>n(t));return n(...e)}}export{$t as Store,Rt as anyAction,St as catchError,Et as concatMap,Nt as createAction,Mt as createEffect,Yt as createFeatureSelector,Ut as createReducer,Bt as createSelector,_t as defer,It as delay,Pt as exhaustMap,gt as filter,dt as from,bt as map,yt as mergeMap,vt as of,Wt as ofType,Jt as on,kt as switchMap,zt as tap,Ft as withLatestFrom};