UNPKG

@activejs/core

Version:

Pragmatic, Reactive State Management for JavaScript Apps

16 lines (14 loc) 43.5 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@activejs/core",["exports","rxjs","rxjs/operators"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).activejs=t.activejs||{},t.activejs.core={}),t.rxjs,t.rxjs.operators)}(this,(function(t,e,i){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])})(t,e)};function r(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}Object.create;function o(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,r,o=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return s}function s(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t}Object.create;var u,a=function(t){this.value=t},c=function(t,e){this.value=t,this.options=e};(u=t.DispatchFailReason||(t.DispatchFailReason={})).FROZEN_UNIT="FROZEN_UNIT",u.INVALID_VALUE="INVALID_VALUE",u.CUSTOM_DISPATCH_CHECK="CUSTOM_DISPATCH_CHECK",u.DISTINCT_CHECK="DISTINCT_CHECK";var h=function(t,e,i){this.value=t,this.reason=e,this.options=i},l=function(){},p=function(){},f=function(){},d=function(t,e){this.steps=t,this.newCacheIndex=e},y=function(t){this.options=t},b=function(){},v=function(t){this.options=t},g=function(){},O=function(t){this.options=t},j=function(){},m=function(t,e){this.key=t,this.value=e},V=function(t,e){this.sources=t,this.newProps=e},S=function(t){this.deletedProps=t},U=function(t,e){this.index=t,this.item=e},N=function(t){this.item=t},E=function(t){this.items=t},I=function(t){this.item=t},w=function(t){this.items=t},_=function(t,e){this.indices=t,this.deletedItems=e},C=function(t,e){this.indices=t,this.removedItems=e},T=function(t,e,i,n){this.start=t,this.deleteCount=e,this.removedItems=i,this.addedItems=n},M=function(t,e,i){this.item=t,this.start=e,this.end=i},P=function(t,e,i){this.target=t,this.start=e,this.end=i},A=function(){},x=function(){},z=function(){},R="function"==typeof Symbol&&Symbol.iterator||"@@iterator";function D(t){return"string"==typeof t&&!!t.trim().length}function k(t){return"[object Object]"===Object.prototype.toString.call(t)}function F(t){return null!=t&&"object"==typeof t}function L(t){var e=[];return e[t]=1,!!e.length&&1===e[t]}function q(t,e){return t<0?t<-e?0:e+t:t}function B(t,e){var i,n=[];return t.forEach((function(t){(t=q(t,e))<e&&L(t)&&n.push(t)})),i=n,"function"==typeof Set?s(new Set(i)):i.filter((function(t,e){return i.indexOf(t)===e}))}function Q(t){return"number"==typeof t&&!isNaN(t)}function G(t){return"function"==typeof t}function Y(t){return null==t||"object"!=typeof t?t:Array.isArray(t)?t.map((function(t){return Y(t)})):k(t)?Object.keys(t).reduce((function(e,i){return e[i]=Y(t[i]),e}),{}):t}function K(t){if(!F(t))return t;Array.isArray(t)?t.forEach((function(t){return K(t)})):k(t)&&Object.keys(t).forEach((function(e){return K(t[e])}));try{return Object.freeze(t)}catch(e){return t}}function W(t){return null==t||"string"==typeof t||"boolean"==typeof t||"number"==typeof t?[!0]:Array.isArray(t)?(t.find((function(t){var i=W(t);if(!1===i[0])return e=i,!0})),e||[!0]):t.constructor===Object?(Object.keys(t).find((function(e){var n=W(t[e]);if(!1===n[0])return i=n,!0})),i||[!0]):[!1,t];var e,i}function J(t){null!=t&&"object"==typeof t&&Object.keys(t).forEach((function(e){Object.defineProperty(t,e,{enumerable:!1})}))}function H(t,e){for(var i=Array.isArray(e)?e.length:0,n=0;n<i;n++){if(null==t)return;t=Object.prototype.hasOwnProperty.call(t,e[n])?t[e[n]]:void 0}return t}function $(t){if(null==t||"object"!=typeof t)return"";t=t.constructor.name;var e=function(){try{throw new Error}catch(t){return t.stacktrace||t.stack}}(),i=e.match(new RegExp("new "+t+"\\b.+\\n(?:[\\s\\S]+new (?:AsyncSystem|Cluster)\\b.+\\n)?((?:.+\\n?){1,2})"));return function(t){var e=0,i="string"==typeof t?t.length:0;if(0===i)return String(e);for(var n=0;n<i;n++)e=(e<<5)-e+t.charCodeAt(n),e|=0;return e>>>=0,Number(e).toString(32).toUpperCase()}((null==i?void 0:i[1])||e)}var Z={},X=Object.freeze({}),tt=function(){function t(){}return Object.defineProperty(t,"storage",{get:function(){return t._storage||localStorage},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ENVIRONMENT",{get:function(){return this.isDevMode()?t._ENVIRONMENT:Object.freeze({})},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ACTION",{get:function(){return t._ACTION},enumerable:!1,configurable:!0}),Object.defineProperty(t,"CLUSTER",{get:function(){return t._CLUSTER},enumerable:!1,configurable:!0}),Object.defineProperty(t,"UNITS",{get:function(){return t._UNITS},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BOOL_UNIT",{get:function(){return t._BOOL_UNIT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"NUM_UNIT",{get:function(){return t._NUM_UNIT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"STRING_UNIT",{get:function(){return t._STRING_UNIT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LIST_UNIT",{get:function(){return t._LIST_UNIT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DICT_UNIT",{get:function(){return t._DICT_UNIT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"GENERIC_UNIT",{get:function(){return t._GENERIC_UNIT},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ASYNC_SYSTEM",{get:function(){return t._ASYNC_SYSTEM},enumerable:!1,configurable:!0}),t.set=function(e){var i=Object.assign({},e),n=i.storage,r=i.ENVIRONMENT,o=i.ACTION,s=i.UNITS,u=i.CLUSTER,a=i.BOOL_UNIT,c=i.NUM_UNIT,h=i.STRING_UNIT,l=i.LIST_UNIT,p=i.DICT_UNIT,f=i.GENERIC_UNIT,d=i.ASYNC_SYSTEM;t._storage=n,t._ENVIRONMENT=Object.freeze(Object.assign({},r)),t._ACTION=Object.freeze(Object.assign({},o)),t._CLUSTER=Object.freeze(Object.assign({},u)),t._UNITS=Object.freeze(Object.assign({},s)),t._BOOL_UNIT=Object.freeze(Object.assign({},a)),t._NUM_UNIT=Object.freeze(Object.assign({},c)),t._STRING_UNIT=Object.freeze(Object.assign({},h)),t._LIST_UNIT=Object.freeze(Object.assign({},l)),t._DICT_UNIT=Object.freeze(Object.assign({},p)),t._GENERIC_UNIT=Object.freeze(Object.assign({},f)),t._ASYNC_SYSTEM=Object.freeze(Object.assign(Object.assign({},d),{UNITS:Object.assign({},null==d?void 0:d.UNITS),QUERY_UNIT:Object.assign({},null==d?void 0:d.QUERY_UNIT),DATA_UNIT:Object.assign({},null==d?void 0:d.DATA_UNIT),ERROR_UNIT:Object.assign({},null==d?void 0:d.ERROR_UNIT),PENDING_UNIT:Object.assign({},null==d?void 0:d.PENDING_UNIT)})),!0===t.ENVIRONMENT.checkUniqueId&&Object.keys(Z).forEach((function(t){delete Z[t]}))},t.reset=function(){t.set(null)},t.enableProdMode=function(){this._isDevMode=!1},t.isDevMode=function(){return this._isDevMode},t}();tt._isDevMode=!0,tt._ENVIRONMENT=X,tt._ACTION=X,tt._CLUSTER=X,tt._UNITS=X,tt._BOOL_UNIT=X,tt._NUM_UNIT=X,tt._STRING_UNIT=X,tt._LIST_UNIT=X,tt._DICT_UNIT=X,tt._GENERIC_UNIT=X,tt._ASYNC_SYSTEM=X;var et=function(t){function i(i){var n=t.call(this)||this;if(n.futureSubject=new e.Subject,n.future$=n.futureSubject.asObservable(),n._emitCount=0,n.config=Object.assign({},i),void 0!==n.config.id){if(!D(n.config.id))throw new TypeError("Invalid id provided, expected a non-empty string, got "+String(n.config.id));if(!0===tt.ENVIRONMENT.checkUniqueId){var r=$(n);if(null!=Z[n.config.id]&&Z[n.config.id]!==r)throw new TypeError('Duplicate id "'+n.config.id+'" detected by "checkUniqueId" check, consider assigning a unique id.');Z[n.config.id]=r}}else if(!0===n.config.persistent)throw new TypeError("An id is required for persistence to work.");return!1===n.config.replay?(n.sourceSubject=n.futureSubject,n.source=n.future$):(n.sourceSubject=new e.BehaviorSubject(void 0),n.source=n.sourceSubject.asObservable()),n.setupEvents(),Object.freeze(n.config),n}return r(i,t),Object.defineProperty(i.prototype,"emitCount",{get:function(){return this._emitCount},enumerable:!1,configurable:!0}),i.prototype.rawValue=function(){return this.value()},i.prototype.asObservable=function(){var t=new e.Observable;return t.source=this.source,t},i.prototype.replay=function(){var t;this.emit(this.emittedValue),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&this.eventsSubject.next(new a(this.emittedValue))},i.prototype.toJsonString=function(){return JSON.stringify(this.rawValue())},i.prototype.valueOf=function(){return this.rawValue()},i.prototype.toJSON=function(){return this.rawValue()},i.prototype.emit=function(t){void 0===t&&(t=this.value()),++this._emitCount,this.emittedValue=t,this.sourceSubject!==this.futureSubject&&this.sourceSubject.next(t),this.futureSubject.next(t)},i.prototype.setupEvents=function(){Object.defineProperty(this,"events$",{get:function(){return this._events||(this.eventsSubject=new e.Subject,this._events=this.eventsSubject.asObservable(),Object.defineProperty(this,"eventsSubject",{enumerable:!1}),Object.defineProperty(this,"_events",{enumerable:!1})),this._events},enumerable:!1})},i}(e.Observable),it=s(Object.getOwnPropertyNames(e.Observable.prototype),Object.getOwnPropertyNames(et.prototype));Object.getOwnPropertyNames(Object.prototype).forEach((function(t){G(Object.prototype[t])&&!it.includes(t)&&Object.defineProperty(et.prototype,t,{value:function(){for(var e,i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];return(e=this.rawValue())[t].apply(e,s(i))}})}));var nt=function(){function t(t){if(this.observable=t,!(t instanceof e.Observable))throw new TypeError("Expected an Observable, got "+t);this.subscribe(),J(this)}return Object.defineProperty(t.prototype,"subscription",{get:function(){return this._subscription},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSubscribed",{get:function(){return!!this._subscription},enumerable:!1,configurable:!0}),t.prototype.subscribe=function(){var t=this;return this._subscription=this.observable.subscribe({error:function(){return t.unsubscribe()}}),this.subscription},t.prototype.unsubscribe=function(){this.subscription&&(this.subscription.unsubscribe(),delete this._subscription)},t.prototype.resubscribe=function(){return this.unsubscribe(),this.subscribe()},t}(),rt="_AJS_UNIT_";function ot(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=tt.ENVIRONMENT.logLevel;return Q(n)&&n>=1?(t=console.warn).bind.apply(t,s([console],e)):z}function st(t){var e=o(W(t),2),i=e[0],n=e[1];if(!1===i)throw new TypeError("Non-serializable value "+String(n)+" of type "+n.constructor.name+":"+typeof n+' detected by "checkSerializability" check. Consider a serializable alternative.')}var ut=function(e){function i(t){var i=e.call(this,Object.assign(Object.assign({},tt.UNITS),t))||this;i._isFrozen=!1,i._isMuted=!1,i._cachedValues=[],i._cacheIndex=0,i._initialValue=void 0;var n,r,o,s,u=i.config,a=u.cacheSize,c=u.initialValue,h=u.dispatchDebounce,l=u.dispatchDebounceMode,p=u.persistent;return i.cacheSize=Q(a)?Math.max(1,a):2,!0===p?i.restoreValueFromPersistentStorage(c):(i.checkSerializabilityMaybe(c),i.dispatchInitialValue(i.deepCopyMaybe(c))),(!0===h||Q(h))&&(i.dispatchMiddleware=(n=i.dispatchMiddleware.bind(i),o=l,Q(r=h)||(r=200),["START","END","BOTH"].includes(o)||(o="END"),function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=this,u=function(){if(s=null,"START"!==o)return n.apply(i,t)},a="END"!==o&&!s;if(clearTimeout(s),s=setTimeout(u,r),a)return n.apply(i,t)})),i}return r(i,e),Object.defineProperty(i.prototype,"isFrozen",{get:function(){return this._isFrozen},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isMuted",{get:function(){return this._isMuted},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"isEmpty",{get:function(){return this.rawValue()===this.defaultValue()},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cachedValuesCount",{get:function(){return this._cachedValues.length},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"cacheIndex",{get:function(){return this._cacheIndex},enumerable:!1,configurable:!0}),i.prototype.initialValue=function(){return this.deepCopyMaybe(this.initialValueRaw())},i.prototype.value=function(){return this.deepCopyMaybe(this.rawValue())},i.prototype.rawValue=function(){return this.applyFallbackValue(this._value)},i.prototype.cachedValues=function(){var t=this;return this._cachedValues.map((function(e){return t.deepCopyMaybe(e)}))},i.prototype.initialValueRaw=function(){return this.applyFallbackValue(this._initialValue)},i.prototype.defaultValue=function(){},i.prototype.createStream=function(t){var e=t(this);return new nt(e)},i.prototype.wouldDispatch=function(t,e){return void 0===e&&(e=!1),!this.isFrozen&&(!0===e||!("function"==typeof this.config.customDispatchCheck&&!this.config.customDispatchCheck(this.rawValue(),t))&&this.distinctCheck(t))},i.prototype.dispatch=function(t,e){return!0===(null==e?void 0:e.bypassDebounce)?this.dispatchActual(t,e):this.dispatchMiddleware(t,e)},i.prototype.replay=function(){return!this.isFrozen&&!this.isMuted&&(e.prototype.replay.call(this),!0)},i.prototype.goBack=function(){return this.jump(-1)},i.prototype.goForward=function(){return this.jump(1)},i.prototype.jumpToStart=function(){return this.jump(-this.cacheIndex)},i.prototype.jumpToEnd=function(){return this.jump(this.cachedValuesCount-1-this.cacheIndex)},i.prototype.jump=function(t){var e;if(this.isFrozen||!Q(t))return!1;var i=this.cacheIndex+t;return!(i<0||i===this.cacheIndex||i>this.cachedValuesCount-1)&&(this._cacheIndex=i,this.updateValueAndCache(this._cachedValues[this.cacheIndex],null,!0),(null===(e=this.eventsSubject)||void 0===e?void 0:e.observers.length)&&!this.isMuted&&this.eventsSubject.next(new d(t,i)),!0)},i.prototype.getCachedValue=function(t){return this._cachedValues.hasOwnProperty(t)?this.deepCopyMaybe(this._cachedValues[t]):void 0},i.prototype.clearCache=function(t){var e,i=!0===(null==t?void 0:t.leaveFirst),n=!0===(null==t?void 0:t.leaveLast);if(this.isFrozen||0===this.cachedValuesCount||1===this.cachedValuesCount&&(i||n)||2===this.cachedValuesCount&&i&&n)return!1;var r=i?1:0,o=this.cachedValuesCount-r-(n?1:0);return this._cachedValues.splice(r,o),this._cacheIndex=Math.max(0,this.cachedValuesCount-1),(null===(e=this.eventsSubject)||void 0===e?void 0:e.observers.length)&&!this.isMuted&&this.eventsSubject.next(new y(t)),!0},i.prototype.clearValue=function(){var t;return!this.isFrozen&&0!==this.emitCount&&!this.isEmpty&&(this.updateValueAndCache(this.defaultValue()),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new b),!0)},i.prototype.clear=function(t){var e;this.unfreeze(),this.clearValue(),this.clearCache(t),(null===(e=this.eventsSubject)||void 0===e?void 0:e.observers.length)&&!this.isMuted&&this.eventsSubject.next(new v(t))},i.prototype.resetValue=function(){var t;return!this.isFrozen&&this.rawValue()!==this.initialValueRaw()&&(this.updateValueAndCache(this.initialValueRaw()),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new g),!0)},i.prototype.reset=function(t){var e;void 0===t&&(t={leaveLast:!0}),this.unfreeze(),this.resetValue(),this.clearCache(t),(null===(e=this.eventsSubject)||void 0===e?void 0:e.observers.length)&&!this.isMuted&&this.eventsSubject.next(new O(t))},i.prototype.freeze=function(){var t;console.trace(),this.isFrozen||(this._isFrozen=!0,(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new p))},i.prototype.unfreeze=function(){var t;this.isFrozen&&(this._isFrozen=!1,(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new f))},i.prototype.mute=function(){this._isMuted=!0},i.prototype.unmute=function(){var t;this.isMuted&&(this._isMuted=!1,this.emitOnUnmute&&(this.emit(),this.emitOnUnmute=null),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&this.eventsSubject.next(new l))},i.prototype.clearPersistedValue=function(){var t,e,i;return!0===this.config.persistent&&(e=this.config.id,void 0===(i=this.config.storage)&&(i=tt.storage),i.removeItem(rt+e),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new j),!0)},i.prototype.deepCopyMaybe=function(t){return!0===this.config.immutable?Y(t):t},i.prototype.checkSerializabilityMaybe=function(t){!0===tt.ENVIRONMENT.checkSerializability&&st(t)},i.prototype.updateValueAndCache=function(t,e,i){void 0===i&&(i=!1);var n=(e||{}).cacheReplace;!0===tt.ENVIRONMENT.checkImmutability&&K(t),i||this.updateCache(t,n),this._value=t,this.isMuted?this.emitOnUnmute=!0:(this.emitOnUnmute=null,this.emit()),this.updateValueInPersistentStorage()},i.prototype.applyFallbackValue=function(t){return void 0===t?this.defaultValue():t},i.prototype.distinctCheck=function(t){return!0!==this.config.distinctDispatchCheck||t!==this.rawValue()},i.prototype.dispatchMiddleware=function(t,e){return this.dispatchActual(t,e)},i.prototype.dispatchActual=function(e,i){var n,r,o=(i||{}).force,s="function"==typeof e?e(this.value()):e;if(this.checkSerializabilityMaybe(s),this.wouldDispatch(s,o))return this.updateValueAndCache(this.deepCopyMaybe(s),i),(null===(n=this.eventsSubject)||void 0===n?void 0:n.observers.length)&&!this.isMuted&&this.eventsSubject.next(new c(s,i)),!0;if((null===(r=this.eventsSubject)||void 0===r?void 0:r.observers.length)&&!this.isMuted){var u=this.isFrozen&&t.DispatchFailReason.FROZEN_UNIT||this.isValidValue(s)&&(this.distinctCheck(s)?t.DispatchFailReason.CUSTOM_DISPATCH_CHECK:t.DispatchFailReason.DISTINCT_CHECK)||t.DispatchFailReason.INVALID_VALUE;this.eventsSubject.next(new h(s,u,i))}return!1},i.prototype.shouldDispatchInitialValue=function(t){return void 0!==t&&this.isValidValue(t)},i.prototype.updateCache=function(t,e){!0===e?this._cachedValues[this.cacheIndex]=t:0===this.cachedValuesCount||this.cacheIndex===this.cachedValuesCount-1?(this._cachedValues.push(t),this.cachedValuesCount>this.cacheSize&&this._cachedValues.shift(),this._cacheIndex=this.cachedValuesCount-1):(this._cachedValues.splice(this.cacheIndex+1,this.cachedValuesCount-1-this.cacheIndex,t),++this._cacheIndex)},i.prototype.dispatchInitialValue=function(t){this.shouldDispatchInitialValue(t)?(this._initialValue=t,this.updateValueAndCache(this.initialValueRaw())):this.updateValueAndCache(this.defaultValue())},i.prototype.updateValueInPersistentStorage=function(){!0===this.config.persistent&&function(t,e,i){var n;void 0===i&&(i=tt.storage);try{n=JSON.stringify({value:e})}catch(t){n=JSON.stringify({value:String(e)})}i.setItem(rt+t,n)}(this.config.id,this.rawValue(),this.config.storage)},i.prototype.restoreValueFromPersistentStorage=function(t){var e=function(t,e){void 0===e&&(e=tt.storage);var i=e.getItem(rt+t);try{return JSON.parse(i)}catch(t){return null}}(this.config.id,this.config.storage);e?this.dispatchInitialValue(e.value):(this.checkSerializabilityMaybe(t),this.dispatchInitialValue(this.deepCopyMaybe(t)))},i}(et),at=function(){function t(t,e){this.unit=t,this.path=e,function(t){if(!t.length)throw new TypeError("Expected at least one key");var e=t.findIndex((function(t){return"string"!=typeof t&&"number"!=typeof t}));if(e>-1){var i=t[e];throw new TypeError("Expected numbers and strings, but got "+i+" of type "+typeof i)}}(e)}return t.prototype.value=function(){var t=H(this.unit.rawValue(),this.path);return this.unit.deepCopyMaybe(t)},t.prototype.asObservable=function(){var t=this;return!0===this.unit.config.immutable?this.unit.pipe(i.map((function(){return H(t.unit.rawValue(),t.path)})),i.distinctUntilChanged(),i.map((function(){return H(t.unit.emittedValue,t.path)}))):this.unit.pipe(i.map((function(e){return H(e,t.path)})),i.distinctUntilChanged())},t}(),ct=function(t){function e(e){var i=t.call(this,e)||this;return J(i),i}return r(e,t),e.prototype.objectKeys=function(){return null==this.rawValue()?[]:Object.keys(this.rawValue())},e.prototype.objectEntries=function(){return null==this.rawValue()?[]:Object.entries(this.value())},e.prototype.objectValues=function(){return null==this.rawValue()?[]:Object.values(this.value())},e.prototype.select=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new at(this,t)},e}(ut),ht=function(t){function e(e){var i=t.call(this,Object.assign(Object.assign({},tt.GENERIC_UNIT),e))||this;return J(i),i}return r(e,t),e.prototype.goToNonNilValue=function(t){if(this.isFrozen)return!1;var e="BACK"===t?function(t,e,i){for(var n=L(i)?Math.max(0,Math.min(i,t.length-1)):t.length-1;n>-1;){if(e(t[n],n,t))return n;--n}return-1}(this._cachedValues,(function(t){return null!=t}),this.cacheIndex-1):function(t,e,i){for(var n=L(i)?Math.max(0,Math.min(i,t.length-1)):0;n<t.length;){if(e(t[n],n,t))return n;++n}return-1}(this._cachedValues,(function(t){return null!=t}),this.cacheIndex+1);return-1!==e&&this.jump(e-this.cacheIndex)},e.prototype.goBack=function(e){return void 0===e&&(e=!1),!0===e?this.goToNonNilValue("BACK"):t.prototype.goBack.call(this)},e.prototype.goForward=function(e){return void 0===e&&(e=!1),!0===e?this.goToNonNilValue("FORWARD"):t.prototype.goForward.call(this)},e.prototype.isValidValue=function(t){return!0},e}(ct),lt=function(t){function e(e){var i=t.call(this,Object.assign(Object.assign({},tt.BOOL_UNIT),e))||this;return J(i),i}return r(e,t),e.prototype.value=function(){return this.rawValue()},e.prototype.defaultValue=function(){return!1},e.prototype.wouldDispatch=function(e,i){return this.isValidValue(e)&&t.prototype.wouldDispatch.call(this,e,i)},e.prototype.isValidValue=function(t){return"boolean"==typeof t},e}(ut),pt=function(t){function e(e){var i=t.call(this,Object.assign(Object.assign({},tt.STRING_UNIT),e))||this;return J(i),i}return r(e,t),Object.defineProperty(e.prototype,"length",{get:function(){return this.rawValue().length},enumerable:!1,configurable:!0}),e.prototype.value=function(){return this.rawValue()},e.prototype.defaultValue=function(){return""},e.prototype.wouldDispatch=function(e,i){return this.isValidValue(e)&&t.prototype.wouldDispatch.call(this,e,i)},e.prototype.isValidValue=function(t){return"string"==typeof t},e.prototype[R]=function(){return String.prototype[R].call(this.value())},e}(ut),ft=s(Object.getOwnPropertyNames(e.Observable.prototype),Object.getOwnPropertyNames(et.prototype),Object.getOwnPropertyNames(ut.prototype),Object.getOwnPropertyNames(pt.prototype));Object.getOwnPropertyNames(String.prototype).forEach((function(t){G(String.prototype[t])&&!ft.includes(t)&&Object.defineProperty(pt.prototype,t,{value:function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return String.prototype[t].apply(this.value(),e)}})}));var dt=function(t){function e(e){var i=t.call(this,Object.assign(Object.assign({},tt.NUM_UNIT),e))||this;return J(i),i}return r(e,t),e.prototype.value=function(){return this.rawValue()},e.prototype.defaultValue=function(){return 0},e.prototype.wouldDispatch=function(e,i){return this.isValidValue(e)&&t.prototype.wouldDispatch.call(this,e,i)},e.prototype.isValidValue=function(t){return Q(t)},e}(ut),yt=s(Object.getOwnPropertyNames(e.Observable.prototype),Object.getOwnPropertyNames(et.prototype),Object.getOwnPropertyNames(ut.prototype),Object.getOwnPropertyNames(dt.prototype));Object.getOwnPropertyNames(Number.prototype).forEach((function(t){G(Number.prototype[t])&&!yt.includes(t)&&Object.defineProperty(dt.prototype,t,{value:function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return Number.prototype[t].apply(this.value(),e)}})}));var bt=function(t){function e(e){var i=t.call(this,Object.assign(Object.assign({},tt.LIST_UNIT),e))||this;return J(i),i}return r(e,t),Object.defineProperty(e.prototype,"length",{get:function(){return this.rawValue().length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.length},enumerable:!1,configurable:!0}),e.prototype.defaultValue=function(){return[]},e.prototype.wouldDispatch=function(e,i){return this.isValidValue(e)&&t.prototype.wouldDispatch.call(this,e,i)},e.prototype.set=function(t,e){var i;if(!this.isFrozen&&L(t)){this.checkSerializabilityMaybe(e);var n=s(this.rawValue());n[q(t,this.length)]=this.deepCopyMaybe(e),this.updateValueAndCache(n),(null===(i=this.eventsSubject)||void 0===i?void 0:i.observers.length)&&!this.isMuted&&this.eventsSubject.next(new U(t,e))}},e.prototype.insert=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];return this.isFrozen||!e.length||(this.checkSerializabilityMaybe(e),this.splice.apply(this,s([t,0],e))),this.length},e.prototype.remove=function(){for(var t,e=this,i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];var r=this.length;if(i=B(i,r).filter((function(t){return e.hasOwnProperty(t)})),this.isFrozen||!i.length||this.isEmpty)return[];i.sort().reverse();var o=[],u=s(this.rawValue());return i.forEach((function(t){o.push.apply(o,s(e.deepCopyMaybe(u.splice(t,1))))})),this.updateValueAndCache(u),o.reverse(),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new C(i,o)),o},e.prototype.removeIf=function(t){if(this.isFrozen||"function"!=typeof t||this.isEmpty)return[];var e=[];return this.value().forEach((function(i,n){t(i,n)&&e.push(n)})),this.remove.apply(this,s(e))},e.prototype.delete=function(){for(var t,e=this,i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(i=B(i,this.length).filter((function(t){return e.hasOwnProperty(t)})),this.isFrozen||0===i.length||this.isEmpty)return[];var r=[],o=s(this.rawValue());return i.forEach((function(t){r.push(e.deepCopyMaybe(o[t])),delete o[t]})),this.updateValueAndCache(o),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new _(i,r)),r},e.prototype.deleteIf=function(t){if(this.isFrozen||"function"!=typeof t||this.isEmpty)return[];var e=[];return this.value().forEach((function(i,n){t(i,n)&&e.push(n)})),this.delete.apply(this,s(e))},e.prototype.findByProp=function(t,e,i){var n=this;return void 0===i&&(i=!0),this.isEmpty?[]:this.rawValue().reduce((function(r,o,s){return F(o)&&(!1===i?o[t]==e:o[t]===e)&&r.push([s,n.deepCopyMaybe(o)]),r}),[])},e.prototype.get=function(t){return t=q(t,this.length),this.hasOwnProperty(t)?this.deepCopyMaybe(this.rawValue()[t]):void 0},e.prototype.first=function(){return this.get(0)},e.prototype.last=function(){return this.get(-1)},e.prototype.jsonJoin=function(t){return this.rawValue().map((function(t){return JSON.stringify(t)})).join(t)},e.prototype.push=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];if(this.isFrozen||!e.length)return this.length;this.checkSerializabilityMaybe(e);var n=s(this.rawValue()),r=n.push.apply(n,s(this.deepCopyMaybe(e)));return this.updateValueAndCache(n),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new E(e)),r},e.prototype.pop=function(){var t;if(!this.isFrozen&&!this.isEmpty){var e=s(this.rawValue()),i=this.deepCopyMaybe(e.pop());return this.updateValueAndCache(e),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new N(i)),i}},e.prototype.shift=function(){var t;if(!this.isFrozen&&!this.isEmpty){var e=s(this.rawValue()),i=this.deepCopyMaybe(e.shift());return this.updateValueAndCache(e),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new I(i)),i}},e.prototype.unshift=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];if(this.isFrozen||!e.length)return this.length;this.checkSerializabilityMaybe(e);var n=s(this.rawValue()),r=n.unshift.apply(n,s(this.deepCopyMaybe(e)));return this.updateValueAndCache(n),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new w(e)),r},e.prototype.splice=function(t,e){for(var i,n=this,r=[],o=2;o<arguments.length;o++)r[o-2]=arguments[o];if(this.isFrozen||(0==e||this.isEmpty)&&!r.length)return[];this.checkSerializabilityMaybe(r);var u=s(this.rawValue()),a=this.deepCopyMaybe(u.splice.apply(u,s([t,e],r.map((function(t){return n.deepCopyMaybe(t)})))));return this.updateValueAndCache(u),(null===(i=this.eventsSubject)||void 0===i?void 0:i.observers.length)&&!this.isMuted&&this.eventsSubject.next(new T(t,e,a,r)),a},e.prototype.fill=function(t,e,i){var n;if(!this.isFrozen&&!this.isEmpty){this.checkSerializabilityMaybe(t);var r=s(this.rawValue());r.fill(this.deepCopyMaybe(t),e,i),this.updateValueAndCache(r),(null===(n=this.eventsSubject)||void 0===n?void 0:n.observers.length)&&!this.isMuted&&this.eventsSubject.next(new M(t,e,i))}},e.prototype.copyWithin=function(t,e,i){var n;if(!this.isFrozen&&!this.isEmpty){var r=s(this.rawValue());r.copyWithin(t,e,i),this.updateValueAndCache(r),(null===(n=this.eventsSubject)||void 0===n?void 0:n.observers.length)&&!this.isMuted&&this.eventsSubject.next(new P(t,e,i))}},e.prototype.reverse=function(){var t;if(!this.isFrozen&&!this.isEmpty){var e=s(this.rawValue()).reverse();this.updateValueAndCache(e),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new A)}},e.prototype.sort=function(t){var e;if(!this.isFrozen&&!this.isEmpty){var i="function"==typeof t?s(this.value()).sort(t):s(this.rawValue()).sort();this.updateValueAndCache(i),(null===(e=this.eventsSubject)||void 0===e?void 0:e.observers.length)&&!this.isMuted&&this.eventsSubject.next(new x)}},e.prototype.slice=function(t,e){return this.deepCopyMaybe(this.rawValue().slice(t,e))},e.prototype.forEvery=function(t,e){Array.prototype.forEach.apply(this.value(),[t,e])},e.prototype[R]=function(){return Array.prototype[R].call(this.value())},e.prototype.isValidValue=function(t){return Array.isArray(t)},e}(ct),vt=["includes","indexOf","lastIndexOf","join","keys","toLocaleString"];vt.forEach((function(t){Object.defineProperty(bt.prototype,t,{value:function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return Array.prototype[t].apply(this.rawValue(),e)}})}));var gt=s(Object.getOwnPropertyNames(e.Observable.prototype),Object.getOwnPropertyNames(et.prototype),Object.getOwnPropertyNames(ut.prototype),Object.getOwnPropertyNames(bt.prototype),vt);Object.getOwnPropertyNames(Array.prototype).forEach((function(t){G(Array.prototype[t])&&!gt.includes(t)&&Object.defineProperty(bt.prototype,t,{value:function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return Array.prototype[t].apply(this.value(),e)}})}));var Ot=function(t){function e(e){var i=t.call(this,Object.assign(Object.assign({},tt.DICT_UNIT),e))||this;return J(i),i}return r(e,t),Object.defineProperty(e.prototype,"length",{get:function(){return this.objectKeys().length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEmpty",{get:function(){return 0===this.length},enumerable:!1,configurable:!0}),e.prototype.defaultValue=function(){return{}},e.prototype.wouldDispatch=function(e,i){return this.isValidValue(e)&&t.prototype.wouldDispatch.call(this,e,i)},e.prototype.set=function(t,e){var i;if(!this.isFrozen&&function(t){return"string"==typeof t||"number"==typeof t}(t)){this.checkSerializabilityMaybe(e);var n=Object.assign({},this.rawValue());n[t]=this.deepCopyMaybe(e),this.updateValueAndCache(n),(null===(i=this.eventsSubject)||void 0===i?void 0:i.observers.length)&&!this.isMuted&&this.eventsSubject.next(new m(t,e))}},e.prototype.delete=function(){for(var t,e=this,i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(i=i.filter((function(t){return e.has(t)})),this.isFrozen||this.isEmpty||!i.length)return{};var r=Object.assign({},this.rawValue()),o={};return i.forEach((function(t){o[t]=e.deepCopyMaybe(r[t]),delete r[t]})),this.updateValueAndCache(r),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new S(o)),o},e.prototype.deleteIf=function(t){var e,i=this;if(this.isFrozen||"function"!=typeof t||this.isEmpty)return{};var n=Object.assign({},this.rawValue()),r={};return Object.keys(n).forEach((function(e,o){t(i.deepCopyMaybe(n[e]),e,o)&&(r[e]=n[e],delete n[e])})),this.updateValueAndCache(n),(null===(e=this.eventsSubject)||void 0===e?void 0:e.observers.length)&&!this.isMuted&&this.eventsSubject.next(new S(r)),r},e.prototype.assign=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];if(e=e.filter(F),!this.isFrozen&&e.length){this.checkSerializabilityMaybe(e);var n=Object.assign({},this.rawValue()),r=Object.assign.apply(Object,s([{}],e));this.updateValueAndCache(Object.assign(n,this.deepCopyMaybe(r))),(null===(t=this.eventsSubject)||void 0===t?void 0:t.observers.length)&&!this.isMuted&&this.eventsSubject.next(new V(e,r))}},e.prototype.get=function(t){return this.hasOwnProperty(t)?this.deepCopyMaybe(this.rawValue()[t]):void 0},e.prototype.has=function(t){return this.hasOwnProperty(t)},e.prototype.findByProp=function(t,e,i){return void 0===i&&(i=!0),this.isEmpty?[]:this.deepCopyMaybe(Object.entries(this.rawValue()).filter((function(n){var r=o(n,2),s=(r[0],r[1]);return F(s)&&(!1===i?s[t]==e:s[t]===e)})))},e.prototype.forEvery=function(t,e){this.objectEntries().forEach((function(i,n,r){var s=o(i,2),u=s[0],a=s[1];return t.call(e,a,u,n,r)}))},e.prototype[R]=function(){var t=0,e=this.objectEntries(),i=e.length;return{next:function(){return{value:e[t++],done:t>i}}}},e.prototype.isValidValue=function(t){return k(t)},e}(ct);var jt=function(t){function e(e,i,n,r,o){var s=t.call(this,o)||this;return s.queryUnit=e,s.dataUnit=i,s.errorUnit=n,s.pendingUnit=r,s.relationshipsAutoPaused=!1,s.relationshipsManuallyPaused=!1,function(t){if(t){if(!0===t.clearDataOnError&&!0===t.clearDataOnQuery)return ot('When "clearDataOnQuery" is set to true,\n"clearDataOnError" stops working, as only one of them can work at a time\n\nConsider only setting one at a time.');if(!0===t.clearErrorOnData&&!0===t.clearErrorOnQuery)return ot('When "clearErrorOnQuery" is set to true,\n"clearErrorOnData" stops working, as only one of them can work at a time\n\nConsider only setting one at a time.')}return z}(o)(),s.emit(),s.createRelationshipsAmongMemberUnits(),J(s),s}return r(e,t),Object.defineProperty(e.prototype,"relationshipsWorking",{get:function(){return!this.relationshipsAutoPaused&&!this.relationshipsManuallyPaused},enumerable:!1,configurable:!0}),e.prototype.value=function(){var t={query:this.queryUnit.value(),data:this.dataUnit.value(),error:this.errorUnit.value(),pending:this.pendingUnit.value()};return!0===tt.ENVIRONMENT.checkImmutability&&Object.freeze(t),t},e.prototype.createStream=function(t){var e=t(this.queryUnit,this.dataUnit,this.errorUnit,this.pendingUnit);return new nt(e)},e.prototype.pauseRelationships=function(){!0!==this.relationshipsManuallyPaused&&(this.relationshipsManuallyPaused=!0,this.unitsEmitCountsBeforePausing=this.unitsEmitCounts())},e.prototype.resumeRelationships=function(){!1!==this.relationshipsManuallyPaused&&(this.relationshipsManuallyPaused=!1,this.unitsEmitCountsBeforePausing.join()!==this.unitsEmitCounts().join()&&this.emit())},e.prototype.unitsEmitCounts=function(){return[this.queryUnit.emitCount,this.dataUnit.emitCount,this.errorUnit.emitCount,this.pendingUnit.emitCount]},e.prototype.createRelationshipsAmongMemberUnits=function(){var t=this;this.queryUnit.future$.subscribe((function(){t.relationshipsWorking&&t.executeQueryUnitRelationship()})),this.dataUnit.future$.subscribe((function(){t.relationshipsWorking&&t.executeDataUnitRelationship()})),this.errorUnit.future$.subscribe((function(){t.relationshipsWorking&&t.executeErrorUnitRelationship()})),this.pendingUnit.future$.subscribe((function(e){t.relationshipsManuallyPaused||t.toggleQueryUnitFreezeMaybe(e),t.relationshipsWorking&&t.emit()}))},e.prototype.executeQueryUnitRelationship=function(){this.relationshipsAutoPaused=!0,this.autoUpdatePendingValue(!0),!0===this.config.clearDataOnQuery&&this.dataUnit.clearValue(),!0===this.config.clearErrorOnQuery&&this.errorUnit.clearValue(),this.relationshipsAutoPaused=!1,this.emit()},e.prototype.executeDataUnitRelationship=function(){this.relationshipsAutoPaused=!0,this.autoUpdatePendingValue(!1),!0!==this.config.clearErrorOnQuery&&!1!==this.config.clearErrorOnData&&this.errorUnit.clearValue(),!0===this.config.clearQueryOnData&&this.queryUnit.clearValue(),this.relationshipsAutoPaused=!1,this.emit()},e.prototype.executeErrorUnitRelationship=function(){this.relationshipsAutoPaused=!0,this.autoUpdatePendingValue(!1),!0!==this.config.clearDataOnQuery&&!0===this.config.clearDataOnError&&this.dataUnit.clearValue(),!0===this.config.clearQueryOnError&&this.queryUnit.clearValue(),this.relationshipsAutoPaused=!1,this.emit()},e.prototype.toggleQueryUnitFreezeMaybe=function(t){!0===this.config.freezeQueryWhilePending&&(t?this.queryUnit.freeze():this.queryUnit.unfreeze())},e.prototype.autoUpdatePendingValue=function(t){!1!==this.config.autoUpdatePendingValue&&this.pendingUnit.dispatch(t,{bypassDebounce:!0})},e.prototype.emit=function(e){void 0===e&&(e=this.combinedEmittedValues()),!0===tt.ENVIRONMENT.checkImmutability&&Object.freeze(e),t.prototype.emit.call(this,e)},e.prototype.combinedEmittedValues=function(){return{query:this.queryUnit.emittedValue,data:this.dataUnit.emittedValue,error:this.errorUnit.emittedValue,pending:this.pendingUnit.emittedValue}},e}(et),mt=function(t){function e(e){return t.apply(this,s((i=(e=Object.assign(Object.assign({},tt.ASYNC_SYSTEM),e)).id,n=e.initialValue,r=e.QUERY_UNIT,o=e.DATA_UNIT,u=e.ERROR_UNIT,a=e.PENDING_UNIT,c=e.UNITS,h=function(t,e,i,n,r){var o,s,u,a,c=Object.assign(Object.assign(Object.assign(Object.assign({},(null==e?void 0:e.hasOwnProperty("id"))&&{queryUnitId:e.id}),(null==i?void 0:i.hasOwnProperty("id"))&&{dataUnitId:i.id}),(null==n?void 0:n.hasOwnProperty("id"))&&{errorUnitId:n.id}),(null==r?void 0:r.hasOwnProperty("id"))&&{pendingUnitId:r.id});return D(t)&&(c.queryUnitId=null!==(o=c.queryUnitId)&&void 0!==o?o:t+"_QUERY",c.dataUnitId=null!==(s=c.dataUnitId)&&void 0!==s?s:t+"_DATA",c.errorUnitId=null!==(u=c.errorUnitId)&&void 0!==u?u:t+"_ERROR",c.pendingUnitId=null!==(a=c.pendingUnitId)&&void 0!==a?a:t+"_PENDING"),c}(i,r,o,u,a),l=h.queryUnitId,p=h.dataUnitId,f=h.errorUnitId,d=h.pendingUnitId,b=(y=n||{}).query,v=y.data,g=y.error,O=y.pending,[new ht(Object.assign(Object.assign(Object.assign({initialValue:b},c),r),{id:l})),new ht(Object.assign(Object.assign(Object.assign({initialValue:v},c),o),{id:p})),new ht(Object.assign(Object.assign(Object.assign({initialValue:g},c),u),{id:f})),new lt(Object.assign(Object.assign(Object.assign({initialValue:O},c),a),{id:d})),e])))||this;var i,n,r,o,u,a,c,h,l,p,f,d,y,b,v,g,O}return r(e,t),e}(jt),Vt=function(t){function i(e,i){var n=t.call(this,Object.assign(Object.assign({},tt.CLUSTER),i))||this;return n.items={},function(t){if(!k(t)||!Object.values(t).some((function(t){return t instanceof et})))throw new TypeError("No ActiveJS construct provided; expected at least one Unit, System, Action or Cluster; got "+String(t))}(e),n.extractItems(e),n.startListeningAndEmitting(),J(n),Object.freeze(n.items),n}return r(i,t),Object.defineProperty(i.prototype,"itemsCount",{get:function(){return this._itemsCount},enumerable:!1,configurable:!0}),i.prototype.value=function(){var t=this,e=this.itemsKeys.reduce((function(e,i){return e[i]=t.items[i].value(),e}),{});return!0===tt.ENVIRONMENT.checkImmutability&&Object.freeze(e),e},i.prototype.createStream=function(t){var e=t(this);return new nt(e)},i.prototype.select=function(t){return this.items[t]},i.prototype.forEvery=function(t,e){Object.entries(this.items).forEach((function(i,n,r){var s=o(i,2),u=s[0],a=s[1];return t.call(e,a,u,n,r)}))},i.prototype[R]=function(){var t=0,e=Object.entries(this.items),i=e.length;return{next:function(){return{value:e[t++],done:t>i}}}},i.prototype.extractItems=function(t){var e=this;this.itemsKeys=Object.keys(t).filter((function(e){return t[e]instanceof et})),this._itemsCount=this.itemsKeys.length,this.itemsKeys.forEach((function(i){e.items[i]=t[i]}))},i.prototype.startListeningAndEmitting=function(){var t=this;this.emit(),e.merge.apply(void 0,s(Object.values(this.items).map((function(t){return t.future$})))).subscribe((function(){return t.emit()}))},i.prototype.emit=function(e){void 0===e&&(e=this.combinedEmittedValues()),!0===tt.ENVIRONMENT.checkImmutability&&Object.freeze(e),t.prototype.emit.call(this,e)},i.prototype.combinedEmittedValues=function(){var t=this;return this.itemsKeys.reduce((function(e,i){return e[i]=t.items[i].emittedValue,e}),{})},i}(et),St=function(t){function e(e){var i=t.call(this,Object.assign(Object.assign({replay:!1},tt.ACTION),e))||this;return i.dispatch(i.config.initialValue),J(i),i}return r(e,t),e.prototype.value=function(){return this._value},e.prototype.createStream=function(t){var e=t(this);return new nt(e)},e.prototype.dispatch=function(t){this._value="function"==typeof t?t(this.value()):t,!0===tt.ENVIRONMENT.checkImmutability&&K(this._value),this.emit()},e}(et);t.Action=St,t.AsyncSystem=mt,t.AsyncSystemBase=jt,t.Base=et,t.BoolUnit=lt,t.Cluster=Vt,t.Configuration=tt,t.DictUnit=Ot,t.EventDictUnitAssign=V,t.EventDictUnitDelete=S,t.EventDictUnitSet=m,t.EventListUnitCopyWithin=P,t.EventListUnitDelete=_,t.EventListUnitFill=M,t.EventListUnitPop=N,t.EventListUnitPush=E,t.EventListUnitRemove=C,t.EventListUnitReverse=A,t.EventListUnitSet=U,t.EventListUnitShift=I,t.EventListUnitSort=x,t.EventListUnitSplice=T,t.EventListUnitUnshift=w,t.EventReplay=a,t.EventUnitClear=v,t.EventUnitClearCache=y,t.EventUnitClearPersistedValue=j,t.EventUnitClearValue=b,t.EventUnitDispatch=c,t.EventUnitDispatchFail=h,t.EventUnitFreeze=p,t.EventUnitJump=d,t.EventUnitReset=O,t.EventUnitResetValue=g,t.EventUnitUnfreeze=f,t.EventUnitUnmute=l,t.GenericUnit=ht,t.ListUnit=bt,t.NonPrimitiveUnitBase=ct,t.NumUnit=dt,t.Selection=at,t.Stream=nt,t.StringUnit=pt,t.UnitBase=ut,t.clearPersistentStorage=function(t){void 0===t&&(t=tt.storage),Object.keys(t).forEach((function(e){e.startsWith(rt)&&t.removeItem(e)}))},t.createUnit=function(t,e){var i=Object.assign(Object.assign({},e),{initialValue:t}),n=typeof t;switch(!0){case null==t:default:return new ht(i);case"boolean"===n:return new lt(i);case"number"===n:return new dt(i);case"string"===n:return new pt(i);case Array.isArray(t):return new bt(i);case k(t):return new Ot(i)}},t.deepCopy=Y,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=activejs-core.umd.min.js.map