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

@politie/sherlock

Package Overview
Dependencies
Maintainers
8
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@politie/sherlock - npm Package Compare versions

Comparing version 3.0.0-beta.1 to 3.0.0

36

package.json
{
"name": "@politie/sherlock",
"version": "3.0.0-beta.1",
"version": "3.0.0",
"private": false,

@@ -57,25 +57,25 @@ "description": "A reactive programming library for JavaScript applications, built with TypeScript.",

"devDependencies": {
"@types/jest": "^24.0.14",
"@types/node": "^12.0.8",
"coveralls": "^3.0.4",
"@types/jest": "^24.0.18",
"@types/node": "^12.7.5",
"coveralls": "^3.0.6",
"gzip-size": "^5.1.1",
"immutable": "^4.0.0-rc.12",
"jest": "^24.8.0",
"jest-extended": "^0.11.1",
"nodemon": "^1.19.1",
"jest": "^24.9.0",
"jest-extended": "^0.11.2",
"nodemon": "^1.19.2",
"npm-run-all": "^4.1.5",
"rimraf": "^2.6.3",
"rollup": "^1.15.4",
"rollup-plugin-commonjs": "^10.0.0",
"rollup-plugin-node-resolve": "^5.0.2",
"rimraf": "^3.0.0",
"rollup": "^1.21.4",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-visualizer": "^2.2.0",
"rxjs": "^6.5.2",
"rollup-plugin-visualizer": "^2.6.0",
"rxjs": "^6.5.3",
"shelljs": "^0.8.3",
"terser": "^4.0.0",
"ts-jest": "^24.0.2",
"ts-node": "^8.2.0",
"tslint": "^5.17.0",
"typescript": "^3.5.2"
"terser": "^4.3.2",
"ts-jest": "^24.1.0",
"ts-node": "^8.4.1",
"tslint": "^5.20.0",
"typescript": "^3.6.3"
}
}

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

Object.defineProperty(exports,"__esModule",{value:!0});var t,n=require("tslib"),i=Symbol("autoCacheMode"),r=Symbol("connect"),e=Symbol("dependencies"),o=Symbol("dependencyVersions"),u=Symbol("derivableAtom"),s=Symbol("disconnect"),c=Symbol("emptyCache"),f=Symbol("finalize"),h=Symbol("internalGetState"),a=Symbol("mark"),v=Symbol("observers"),l=Symbol("rollback"),b=Symbol("sherlockInstances"),d=Symbol("unresolved"),w=Object.freeze({autoCacheMode:i,connect:r,dependencies:e,dependencyVersions:o,derivableAtom:u,disconnect:s,emptyCache:c,finalize:f,internalGetState:h,mark:a,observers:v,rollback:l,sherlockInstances:b,unresolved:d});function p(){return!!t}function y(n){t?t.t[n.id]=n:n[f]()}function m(n,i,r){t&&E(t,n,i,r)}function O(n){if(t)j(n,t.i);else{var i=[];j(n,i),g(i)}}function j(t,n){for(var i=0,r=t[v];i<r.length;i++)r[i][a](n)}function g(t){for(var n=0,i=t;n<i.length;n++)i[n].o()}function x(n){var i;t={u:[],s:{},h:{},t:{},i:[],v:t};try{i=n()}catch(n){throw function(){var n=t;if(!n)throw Error();t=n.v,n.u.forEach(function(t){return t[l](n.s[t.id],n.h[t.id])})}(),n}return function(){var n,i=t;if(!i)throw Error();(t=i.v)?(i.u.forEach(function(n){return E(t,n,i.s[n.id],i.h[n.id])}),(n=t.i).push.apply(n,i.i),Object.assign(t.t,i.t)):(Object.values(i.t).forEach(function(t){return t[f]()}),g(i.i))}(),i}function S(t){return p()?t():x(t)}function k(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return S(function(){return t.apply(r,n)})}:function(t,n,i){i.value=i.value&&k(i.value)}}function E(t,n,i,r){var e=n.id;e in t.s||(t.u.push(n),t.s[e]=i,t.h[e]=r)}var _=Object.getOwnPropertyDescriptors||function(t){for(var n={},i=0,r=R(t);i<r.length;i++){var e=r[i];n[e]=Object.getOwnPropertyDescriptor(t,e)}return n},R="undefined"!=typeof Reflect?Reflect.ownKeys:function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))};function A(t){return Array.isArray(t)?function(t){try{return Object.defineProperties(new t.constructor,_(t))}catch(t){throw Object.assign(Error("could not clone Array: "+(t&&t.message)),{jse_cause:t})}}(t):Object.create(Object.getPrototypeOf(t),_(t))}var T={equals:function(t,n){return(i=t)&&"function"==typeof i.equals&&!!t.equals(n);var i},plucker:{get:function(t,n){return C(t)?t.get(n):t[n]},set:function(t,n,i){if(C(n)){if("function"==typeof n.set)return n.set(i,t);throw Error("object is readonly")}var r=A(n);return r[i]=t,r}},debugMode:!1};function C(t){return t&&"function"==typeof t.get}function D(t,n){return Object.is(t,n)||T.equals(t,n)}var F=function(){function t(t){this.error=t}return t.prototype.equals=function(n){return this===n||n instanceof t&&D(this.error,n.error)},t}(),I=function(){function t(t){this.value=t}return t.wrap=function(n){return n instanceof t?n:new t(n)},t.unwrap=function(n){return n instanceof t?n.value:n},t.map=function(n,i){return n instanceof t?t.wrap(i(n.value)):i(n)},t.prototype.equals=function(n){return this===n||n instanceof t&&D(this.value,n.value)},t}();function M(t,n){var i=n.creationStack;return i?Object.defineProperty(A(t),"stack",{value:t.stack+"\n"+i}):t}function V(t,n){if(t instanceof I){var i=V(t.value,n);if(i!==t.value)return I.wrap(i)}return n.creationStack&&t instanceof F?new F(M(t.error,n)):t}function q(t){if(T.debugMode){var n=Error().stack;return t.constructor.name+" created:\n"+(n&&n.substr(n.indexOf("\n")+1))}}var z,B,G,N,P=0;function U(){return P++}function L(t){for(var n=z;n;){if(n.l===t)throw M(Error("cyclic dependency between derivables detected"),t);n=n.p}z={l:t,m:0,p:z,t:{}}}function $(){var t=z;if(!t)throw Error("No active recording!");z=t.p;for(var n=t.m,i=t.l,r=t.t,u=i[e],s=i[o],c=n,f=u.length;c<f;c++)Y(u[c],i);u.length=n;for(var h=0,a=u;h<a.length;h++){var v=a[h];s[v.id]=v.version}Object.values(r).forEach(y)}function H(){return!!z}function J(){if(!z)return!1;for(var t=z.m,n=z.t,i=z.l[e],r=0;r<t;r++)if(!(i[r].id in n))return!1;return!0}function K(t){var n=z;z=void 0;try{return t()}finally{z=n}}function Q(t){z?z.t[t.id]=t:y(t)}function W(t,n){if(z&&!t.finalized){n&&(z.t[t.id]=t);var i=z.l,r=i[e];if(r[z.m]===t)z.m++;else{var o=r.indexOf(t);o<0?(X(t,i),z.m===r.length?r.push(t):(r.push(r[z.m]),r[z.m]=t),z.m++):o>z.m&&(r[o]=r[z.m],r[z.m]=t,z.m++)}}}function X(t,n){var i=t[v];i.push(n),1!==i.length||t.connected||t[r]()}function Y(t,n){var r=t[v],e=r.indexOf(n);if(e<0)throw Error("Inconsistent state!");r.splice(e,1),0===r.length&&t.connected&&(t[i]?Z(t):t[s]())}function Z(t){B?B.push(t):(B=[t],setTimeout(function(){var t=B;B=void 0,t.forEach(function(t){return t.connected&&0===t[v].length&&t[s]()})},0))}var tt=function(){function t(){this.id=U(),this.creationStack=q(this),this[G]=[],this[N]=!1,this.connected=!1,this.O=void 0,this.finalized=!1}return t.prototype.autoCache=function(){return this[i]=!0,this},t.prototype.getMaybeFinalState=function(){return this.connected||(this[i]?(this[r](),Z(this)):H()&&this[r]()),this[h]()},t.prototype.getState=function(){return I.unwrap(this.getMaybeFinalState())},t.prototype[(G=v,N=i,r)]=function(){this.finalized||nt(this,!0)},t.prototype[s]=function(){nt(this,!1)},t.prototype[f]=function(){this.finalized=!0,this.connected&&this[s]()},t}();function nt(t,n){t.connected=n,t.O&&K(function(){return t.O.set(n)})}var it,rt,et=function(t){function i(n){var i=t.call(this)||this;return i.version=0,i.j=V(n,i),i.g()&&i[f](),i}return n.__extends(i,t),Object.defineProperty(i.prototype,"settable",{get:function(){return!this.g()},enumerable:!0,configurable:!0}),i.prototype.g=function(){return this.j instanceof I},i.prototype[h]=function(){return W(this,this.g()),this.j},i.prototype.set=function(t){var n=this.j;if(!D(t,n)){if(this.g())throw M(Error("cannot set a final atom"),this);this.j=V(t,this),m(this,n,this.version++),O(this),this.g()&&Q(this)}},i.prototype[l]=function(t,n){this.j=t,this.version=n,j(this,[])},i}(tt),ot=function(t){function i(){var n=null!==t&&t.apply(this,arguments)||this;return n.S=c,n.version=0,n}return n.__extends(i,t),i.prototype.g=function(){return this.S instanceof I},i.prototype[h]=function(){return this.connected?(W(this,this.g()),this.S):this.g()?this.S:this.k()},i.prototype.set=function(t){if(!this.acceptNewValue)throw M(Error("DataSource is not settable"),this);this.acceptNewValue(t)},i.prototype.checkForChanges=function(){var t=this;if(this.connected){var n=K(function(){return t.k()}),i=this.S;D(n,i)||(this.S=n,m(this,i,this.version++),O(this))}},i.prototype.k=function(){try{return this.calculateCurrentValue()}catch(t){return new F(M(t,this))}},i.prototype[l]=function(t,n){this.version++,j(this,[])},i.prototype[r]=function(){t.prototype[r].call(this),this.connected&&this.checkForChanges()},i.prototype[s]=function(){t.prototype[s].call(this),this.finalized||(this.S=c)},Object.defineProperty(i.prototype,"settable",{get:function(){return!!this.acceptNewValue},enumerable:!0,configurable:!0}),i}(tt);function ut(t){return t instanceof tt?t.get():t}function st(t){return t instanceof tt?t.value:t}var ct=function(t){function i(){var n=null!==t&&t.apply(this,arguments)||this;return n._=!1,n.S=c,n.R=0,n}return n.__extends(i,t),Object.defineProperty(i.prototype,"version",{get:function(){return this.A(),this.R},enumerable:!0,configurable:!0}),i.prototype.g=function(){return this.S instanceof I},i.prototype[h]=function(){if(this.connected)return this.A(),W(this,this.g()),this.S;if(this.g())return this.S;var t=this.T();return t instanceof I&&(this.S=t,m(this,void 0,this.R++),Q(this)),t},i.prototype.A=function(){this.connected&&!this._&&(this.S!==c&&(this._=this.g()||this.C()),this._||this.D())},i.prototype.D=function(){var t=this.T();D(t,this.S)||(this.S=t,m(this,void 0,this.R++),this.g()&&Q(this)),this._=!0},i.prototype[a]=function(t){this._&&(this._=!1,j(this,t))},i.prototype[l]=function(t,n){this.S=c,this.R=n,this[a]([])},i.prototype[s]=function(){t.prototype[s].call(this),this._=!1,this.finalized||(this.S=c)},i}(tt),ft=0,ht=function(t){function i(n,i){var r=t.call(this)||this;return r.F=n,r.I=i,r[it]=[],r[rt]={},r}return n.__extends(i,t),i.prototype.D=function(){L(this);try{t.prototype.D.call(this)}finally{$()}},i.prototype.T=function(){++ft;try{var t=this.I?this.F.apply(this,this.I.map(ut)):this.F();return J()?I.wrap(t):t}catch(t){return t===d?d:new F(M(t,this))}finally{--ft}},i.prototype.C=function(){var t=this;return this[e].every(function(n){return t[o][n.id]===n.version})},i.prototype[(it=e,rt=o,s)]=function(){for(var n=0,i=this[e];n<i.length;n++)Y(i[n],this);this[e].length=0,t.prototype[s].call(this)},i.prototype[f]=function(){t.prototype[f].call(this),this.F=void 0,this.I=void 0},i}(ct),at=function(t){function i(n,i){var r=n.get,e=n.set,o=t.call(this,r,i)||this;return o.M=e,o}return n.__extends(i,t),i.prototype.set=function(t){this.I?this.M.apply(this,[t].concat(this.I.map(st))):this.M(t)},n.__decorate([k()],i.prototype,"set",null),i}(ht),vt=function(t){function i(n,i){var r=t.call(this)||this;return r.V=n,r.q=i,r.B=0,r}return n.__extends(i,t),i.prototype.D=function(){this.B=this.V.version,t.prototype.D.call(this)},i.prototype.T=function(){var t=this;try{return K(function(){var n=t.V.getMaybeFinalState();return I.map(n,function(n){return t.q(n)})})}catch(t){return new F(M(t,this))}},i.prototype.C=function(){return this.B===this.V.version},i.prototype[r]=function(){t.prototype[r].call(this),this.connected&&X(this.V,this)},i.prototype[s]=function(){Y(this.V,this),t.prototype[s].call(this)},i.prototype[f]=function(){t.prototype[f].call(this),this.V=void 0,this.q=void 0},i}(ct),lt=function(t){function i(n,i,r){var e=t.call(this,n,i)||this;return e.G=r,e}return n.__extends(i,t),i.prototype.set=function(t){var n=this;this.V.set(I.map(t,function(t){return n.G(t)}))},Object.defineProperty(i.prototype,"settable",{get:function(){return this.V.settable},enumerable:!0,configurable:!0}),i.prototype[f]=function(){t.prototype[f].call(this),this.G=void 0},i}(vt);function bt(t){return t.settable}function dt(t){return"function"==typeof t?t():ut(t)}function wt(){var t=this.getState();return t===d||t instanceof F?void 0:t}function pt(t){return this.set(t)}function yt(t){return t instanceof tt}var mt=I.wrap(d);function Ot(t){return new et(t)}function jt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new ht(t,n.length?n:void 0)}function gt(t){return Ot.final(t)}function xt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new at(t,n.length?n:void 0)}function St(t){var n=this,i=T.plucker,r=i.get,e=i.set,o=this;return yt(t)?xt({get:function(){return r.call(this,o.get(),t.get())},set:function(n){o.set(e.call(this,n,o.value,t.get()))}}):o.map(function(i){return r.call(n,i,t)},function(i){return e.call(n,i,o.value,t)})}function kt(){this.set(d)}function Et(t){this.set(new F(t))}function _t(t){this.set(I.wrap(t))}function Rt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.set(t.apply(void 0,[this.value].concat(n.map(st))))}!function(t){function n(t){return new et(I.wrap(t))}t.unresolved=function(){return new et(d)},t.error=function(t){return new et(new F(t))},t.final=n,function(t){t.unresolved=function(){return new et(mt)},t.error=function(t){return new et(I.wrap(new F(t)))}}(n=t.final||(t.final={}))}(Ot||(Ot={})),function(t){t.unresolved=function(){return Ot.final.unresolved()},t.error=function(t){return Ot.final.error(t)}}(gt||(gt={}));var At=new et(I.wrap(!0)),Tt=new et(I.wrap(!1)),Ct=Symbol("skipped"),Dt=I.wrap(Ct);function Ft(t,n,i,r){if(void 0!==t){var e=t?At:Tt;if(!(t===i||t instanceof et&&t.j instanceof I&&t.j.value===i)){if("function"==typeof t){var o=t;t=new ht(function(){return o(n)}).derive(ut)}return t instanceof tt?void 0!==r?t.mapState(function(t){return t===r?I.wrap(t):t}):t:e}}}function It(t){var n=I.unwrap(t);return n!==d&&!(n instanceof F)}Object.defineProperties(tt.prototype,{get:{value:function(){var t=this.getState();if(t instanceof F)throw t.error;if(t!==d)return t;if(ft>0)throw d;throw M(Error("Could not get value, derivable is unresolved"),this)}},getOr:{value:function(t){var n=this.getState();if(n instanceof F)throw n.error;return n===d?dt(t):n}},value:{get:wt},resolved:{get:function(){return this.getState()!==d}},settable:{value:!1},final:{get:function(){return this.getMaybeFinalState()instanceof I}},errored:{get:function(){return this.getState()instanceof F}},error:{get:function(){var t=this.getState();return t instanceof F?t.error:void 0}},connected$:{get:function(){return this.O||(this.O=new et(this.connected))}},derive:{value:function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new ht(t,[this].concat(n))}},map:{value:function(t,n){var i=function(n){return n===d||n instanceof F?n:t.call(this,n)};return n&&bt(this)?new lt(this,i,function(t){return t===d||t instanceof F?t:n.call(this,t,this.V.value)}):new vt(this,i)}},mapState:{value:function(t,n){return n&&bt(this)?new lt(this,t,function(t){return n.call(this,t,this.V.getState())}):new vt(this,t)}},pluck:{value:function(t){var n=this,i=T.plucker.get;return yt(t)?this.derive(i,t):this.map(function(r){return i.call(n,r,t)})}},fallbackTo:{value:function(t){var n=this;return yt(t)?jt(function(){return n.getOr(t)}):this.mapState(function(n){return n===d?dt(t):n})}},take:{value:function(t){var n=this,i=t.from,r=t.when,e=t.until,o=t.once,u=t.stopOnError,s=t.skipFirst,c=Ft(i,this,!0,!0),f=Ft(r,this,!0),h=Ft(e,this,!1,!0),a=s?new et(d):void 0;if(!(c||f||h||o||u||a))return this;var v=(h||f)&&new et(d);function l(t){return v&&v.set(t),t}return new ht(function(){if(c&&!c.get())return d;if(h&&h.get())return l(I.wrap(v.j));if(f&&!f.value)return v.j;var t=n.getMaybeFinalState();if(a&&!Dt.equals(a.j)){if(!It(t))return l(t);if(a.j===d||D(t,a.j))return a.set(t),l(d);a.set(Dt)}return l(o&&It(t)||u&&t instanceof F?I.wrap(t):t)})}},and:{value:function(t){return yt(t)?this.derive(function(n){return n&&t.get()}):this.map(function(n){return n&&t})}},or:{value:function(t){return yt(t)?this.derive(function(n){return n||t.get()}):this.map(function(n){return n||t})}},not:{value:function(){return this.map(function(t){return!t})}},is:{value:function(t){return yt(t)?this.derive(D,t):this.map(function(n){return D(n,t)})}}}),[et,ot,lt,at].forEach(function(t){return Object.defineProperties(t.prototype,{value:{get:wt,set:pt},swap:{value:Rt},pluck:{value:St}})}),[et,lt].forEach(function(t){return Object.defineProperties(t.prototype,{unset:{value:kt},setError:{value:Et},setFinal:{value:_t}})}),Object.defineProperties(at.prototype,{settable:{value:!0}}),tt.prototype.react=function(t,n){var i=this;return K(function(){return Vt.create(i,t,n)})},tt.prototype.toPromise=function(t){var i=this;return new Promise(function(r,e){return i.react(r,n.__assign({},t,{once:!0,onError:function(t,n){n(),e(t)}}))})};var Mt,Vt=function(){function t(t,n,i,r){this.N=t,this.P=n,this.U=i,this.ended=r,this.L=!1,this.id=U(),this.$=0,this.creationStack=q(this),this.H=c}return t.prototype.J=function(){X(this.N,this),this.L=!0,this.o()},t.prototype.o=function(){var t=this;if(this.L){var n=function(n){return function(){n===d||D(t.H,n)||(t.H=n,n instanceof F?t.P(n.error):t.K(n))}},i=this.N[h]();i instanceof I?this.W(n(i.value)):n(i)()}},t.prototype.K=function(t){var n=this;this.$++;try{if(this.$>100)throw Error("Too deeply nested synchronous cyclical reactions disallowed. Use setImmediate.");this.U(t,function(){return n.W()})}catch(t){this.P(M(t,this))}finally{this.$--}},t.prototype.W=function(t){this.L&&(this.L=!1,Y(this.N,this),t&&t(),this.ended&&this.ended())},t.prototype[a]=function(t){t.indexOf(this)<0&&t.push(this)},t.create=function(n,i,r,e){var o=new t(r?n.take(r):n,function(t){if(!r||!r.onError)throw u(),t;r.onError(t,u)},i,e);function u(){o.W()}return o.J(),u},t}(),qt=Object.freeze({symbols:w,Atom:et,BaseDerivable:tt,BaseDerivation:ct,Derivation:ht,Lens:at,resolveFallback:dt,safeUnwrap:st,Reactor:Vt,isRecordingObservations:H,addObserver:X,allDependenciesAreFinal:J,independentTracking:K,markFinal:Q,maybeDisconnectInNextTick:Z,recordObservation:W,removeObserver:Y,startRecordingObservations:L,stopRecordingObservations:$,processChangedState:O,augmentStack:M}),zt={clone:A,equals:D,isPlainObject:function(t){if("object"!=typeof t||null==t)return!1;var n=Object.getPrototypeOf(t);return n===Object.prototype||null===n||t.constructor===Object},resolveFallback:dt};(Mt="undefined"!=typeof window?window:global)[b]?(Mt[b]++,console.warn(Mt[b]+" instances of Sherlock detected. This could cause unexpected results.")):Mt[b]=1,exports.ErrorWrapper=F,exports.FinalWrapper=I,exports.PullDataSource=ot,exports._internal=qt,exports.atom=Ot,exports.atomic=k,exports.atomically=S,exports.config=T,exports.constant=gt,exports.derive=jt,exports.inTransaction=p,exports.isDerivable=yt,exports.isDerivableAtom=function t(n){return n instanceof et&&n.settable||n instanceof lt&&t(n.V)},exports.isSettableDerivable=function(t){return yt(t)&&t.settable},exports.lens=xt,exports.safeUnwrap=st,exports.transact=x,exports.transaction=function t(n){return n?function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var r=this;return x(function(){return n.apply(r,t)})}:function(n,i,r){r.value=r.value&&t(r.value)}},exports.unresolved=d,exports.unwrap=ut,exports.utils=zt;
Object.defineProperty(exports,"__esModule",{value:!0});var t,n=require("tslib"),i=Symbol("autoCacheMode"),r=Symbol("connect"),e=Symbol("dependencies"),o=Symbol("dependencyVersions"),u=Symbol("derivableAtom"),s=Symbol("disconnect"),c=Symbol("emptyCache"),f=Symbol("finalize"),h=Symbol("internalGetState"),a=Symbol("mark"),v=Symbol("observers"),l=Symbol("rollback"),b=Symbol("sherlockInstances"),d=Symbol("unresolved"),w=Object.freeze({autoCacheMode:i,connect:r,dependencies:e,dependencyVersions:o,derivableAtom:u,disconnect:s,emptyCache:c,finalize:f,internalGetState:h,mark:a,observers:v,rollback:l,sherlockInstances:b,unresolved:d});function p(){return!!t}function y(n){t?t.t[n.id]=n:n[f]()}function m(n,i,r){t&&E(t,n,i,r)}function O(n){if(t)j(n,t.i);else{var i=[];j(n,i),g(i)}}function j(t,n){for(var i=0,r=t[v];i<r.length;i++)r[i][a](n)}function g(t){for(var n=0,i=t;n<i.length;n++)i[n].o()}function x(n){var i;t={u:[],s:{},h:{},t:{},i:[],v:t};try{i=n()}catch(n){throw function(){var n=t;if(!n)throw Error();t=n.v,n.u.forEach((function(t){return t[l](n.s[t.id],n.h[t.id])}))}(),n}return function(){var n,i=t;if(!i)throw Error();(t=i.v)?(i.u.forEach((function(n){return E(t,n,i.s[n.id],i.h[n.id])})),(n=t.i).push.apply(n,i.i),Object.assign(t.t,i.t)):(Object.values(i.t).forEach((function(t){return t[f]()})),g(i.i))}(),i}function S(t){return p()?t():x(t)}function k(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return S((function(){return t.apply(r,n)}))}:function(t,n,i){i.value=i.value&&k(i.value)}}function E(t,n,i,r){var e=n.id;e in t.s||(t.u.push(n),t.s[e]=i,t.h[e]=r)}var _=Object.getOwnPropertyDescriptors||function(t){for(var n={},i=0,r=R(t);i<r.length;i++){var e=r[i];n[e]=Object.getOwnPropertyDescriptor(t,e)}return n},R="undefined"!=typeof Reflect?Reflect.ownKeys:function(t){return n.__spreadArrays(Object.getOwnPropertyNames(t),Object.getOwnPropertySymbols(t))};function A(t){return Array.isArray(t)?function(t){try{return Object.defineProperties(new t.constructor,_(t))}catch(t){throw Object.assign(Error("could not clone Array: "+(t&&t.message)),{jse_cause:t})}}(t):Object.create(Object.getPrototypeOf(t),_(t))}var T={equals:function(t,n){return(i=t)&&"function"==typeof i.equals&&!!t.equals(n);var i},plucker:{get:function(t,n){return C(t)?t.get(n):t[n]},set:function(t,n,i){if(C(n)){if("function"==typeof n.set)return n.set(i,t);throw Error("object is readonly")}var r=A(n);return r[i]=t,r}},debugMode:!1};function C(t){return t&&"function"==typeof t.get}function D(t,n){return Object.is(t,n)||T.equals(t,n)}var F=function(){function t(t){this.error=t}return t.prototype.equals=function(n){return this===n||n instanceof t&&D(this.error,n.error)},t}(),I=function(){function t(t){this.value=t}return t.wrap=function(n){return n instanceof t?n:new t(n)},t.unwrap=function(n){return n instanceof t?n.value:n},t.map=function(n,i){return n instanceof t?t.wrap(i(n.value)):i(n)},t.prototype.equals=function(n){return this===n||n instanceof t&&D(this.value,n.value)},t}();function M(t,n){var i=n.creationStack;return i?Object.defineProperty(A(t),"stack",{value:t.stack+"\n"+i}):t}function V(t,n){if(t instanceof I){var i=V(t.value,n);if(i!==t.value)return I.wrap(i)}return n.creationStack&&t instanceof F?new F(M(t.error,n)):t}function q(t){if(T.debugMode){var n=Error().stack;return t.constructor.name+" created:\n"+(n&&n.substr(n.indexOf("\n")+1))}}var z,B,G,N,P=0;function U(){return P++}function L(t){for(var n=z;n;){if(n.l===t)throw M(Error("cyclic dependency between derivables detected"),t);n=n.p}z={l:t,m:0,p:z,t:{}}}function $(){var t=z;if(!t)throw Error("No active recording!");z=t.p;for(var n=t.m,i=t.l,r=t.t,u=i[e],s=i[o],c=n,f=u.length;c<f;c++)Y(u[c],i);u.length=n;for(var h=0,a=u;h<a.length;h++){var v=a[h];s[v.id]=v.version}Object.values(r).forEach(y)}function H(){return!!z}function J(){if(!z)return!1;for(var t=z.m,n=z.t,i=z.l[e],r=0;r<t;r++)if(!(i[r].id in n))return!1;return!0}function K(t){var n=z;z=void 0;try{return t()}finally{z=n}}function Q(t){z?z.t[t.id]=t:y(t)}function W(t,n){if(z&&!t.finalized){n&&(z.t[t.id]=t);var i=z.l,r=i[e];if(r[z.m]===t)z.m++;else{var o=r.indexOf(t);o<0?(X(t,i),z.m===r.length?r.push(t):(r.push(r[z.m]),r[z.m]=t),z.m++):o>z.m&&(r[o]=r[z.m],r[z.m]=t,z.m++)}}}function X(t,n){var i=t[v];i.push(n),1!==i.length||t.connected||t[r]()}function Y(t,n){var r=t[v],e=r.indexOf(n);if(e<0)throw Error("Inconsistent state!");r.splice(e,1),0===r.length&&t.connected&&(t[i]?Z(t):t[s]())}function Z(t){B?B.push(t):(B=[t],setTimeout((function(){var t=B;B=void 0,t.forEach((function(t){return t.connected&&0===t[v].length&&t[s]()}))}),0))}var tt=function(){function t(){this.id=U(),this.creationStack=q(this),this[G]=[],this[N]=!1,this.connected=!1,this.O=void 0,this.finalized=!1}return t.prototype.autoCache=function(){return this[i]=!0,this},t.prototype.getMaybeFinalState=function(){return this.connected||(this[i]?(this[r](),Z(this)):H()&&this[r]()),this[h]()},t.prototype.getState=function(){return I.unwrap(this.getMaybeFinalState())},t.prototype[(G=v,N=i,r)]=function(){this.finalized||nt(this,!0)},t.prototype[s]=function(){nt(this,!1)},t.prototype[f]=function(){this.finalized=!0,this.connected&&this[s]()},t}();function nt(t,n){t.connected=n,t.O&&K((function(){return t.O.set(n)}))}var it,rt,et=function(t){function i(n){var i=t.call(this)||this;return i.version=0,i.j=V(n,i),i.g()&&i[f](),i}return n.__extends(i,t),Object.defineProperty(i.prototype,"settable",{get:function(){return!this.g()},enumerable:!0,configurable:!0}),i.prototype.g=function(){return this.j instanceof I},i.prototype[h]=function(){return W(this,this.g()),this.j},i.prototype.set=function(t){var n=this.j;if(!D(t,n)){if(this.g())throw M(Error("cannot set a final derivable"),this);this.j=V(t,this),m(this,n,this.version++),O(this),this.g()&&Q(this)}},i.prototype[l]=function(t,n){this.j=t,this.version=n,j(this,[])},i}(tt),ot=function(t){function i(){var n=null!==t&&t.apply(this,arguments)||this;return n.S=c,n.version=0,n}return n.__extends(i,t),i.prototype.g=function(){return this.S instanceof I},i.prototype[h]=function(){return this.connected?(W(this,this.g()),this.S):this.g()?this.S:this.k()},i.prototype.set=function(t){if(!this.acceptNewValue)throw M(Error("DataSource is not settable"),this);this.acceptNewValue(t)},i.prototype.checkForChanges=function(){var t=this;if(this.connected){var n=K((function(){return t.k()})),i=this.S;D(n,i)||(this.S=n,m(this,i,this.version++),O(this))}},i.prototype.k=function(){try{return this.calculateCurrentValue()}catch(t){return new F(M(t,this))}},i.prototype[l]=function(t,n){this.version++,j(this,[])},i.prototype[r]=function(){t.prototype[r].call(this),this.connected&&this.checkForChanges()},i.prototype[s]=function(){t.prototype[s].call(this),this.finalized||(this.S=c)},Object.defineProperty(i.prototype,"settable",{get:function(){return!!this.acceptNewValue},enumerable:!0,configurable:!0}),i}(tt);function ut(t){return t instanceof tt?t.get():t}function st(t){return t instanceof tt?t.value:t}var ct=function(t){function i(){var n=null!==t&&t.apply(this,arguments)||this;return n._=!1,n.S=c,n.R=0,n}return n.__extends(i,t),Object.defineProperty(i.prototype,"version",{get:function(){return this.A(),this.R},enumerable:!0,configurable:!0}),i.prototype.g=function(){return this.S instanceof I},i.prototype[h]=function(){if(this.connected)return this.A(),W(this,this.g()),this.S;if(this.g())return this.S;var t=this.T();return t instanceof I&&(this.S=t,m(this,void 0,this.R++),Q(this)),t},i.prototype.A=function(){this.connected&&!this._&&(this.S!==c&&(this._=this.g()||this.C()),this._||this.D())},i.prototype.D=function(){var t=this.T();D(t,this.S)||(this.S=t,m(this,void 0,this.R++),this.g()&&Q(this)),this._=!0},i.prototype[a]=function(t){this._&&(this._=!1,j(this,t))},i.prototype[l]=function(t,n){this.S=c,this.R=n,this[a]([])},i.prototype[s]=function(){t.prototype[s].call(this),this._=!1,this.finalized||(this.S=c)},i}(tt),ft=0,ht=function(t){function i(n,i){var r=t.call(this)||this;return r.F=n,r.I=i,r[it]=[],r[rt]={},r}return n.__extends(i,t),i.prototype.D=function(){L(this);try{t.prototype.D.call(this)}finally{$()}},i.prototype.T=function(){++ft;try{var t=this.I?this.F.apply(this,this.I.map(ut)):this.F();return J()?I.wrap(t):t}catch(t){return t===d?d:new F(M(t,this))}finally{--ft}},i.prototype.C=function(){var t=this;return this[e].every((function(n){return t[o][n.id]===n.version}))},i.prototype[(it=e,rt=o,s)]=function(){for(var n=0,i=this[e];n<i.length;n++)Y(i[n],this);this[e].length=0,t.prototype[s].call(this)},i.prototype[f]=function(){t.prototype[f].call(this),this.F=void 0,this.I=void 0},i}(ct),at=function(t){function i(n,i){var r=n.get,e=n.set,o=t.call(this,r,i)||this;return o.M=e,o}return n.__extends(i,t),i.prototype.set=function(t){if(this.finalized)throw M(Error("cannot set a final derivable"),this);this.I?this.M.apply(this,n.__spreadArrays([t],this.I.map(st))):this.M(t)},n.__decorate([k()],i.prototype,"set",null),i}(ht),vt=function(t){function i(n,i){var r=t.call(this)||this;return r.V=n,r.q=i,r.B=0,r}return n.__extends(i,t),i.prototype.D=function(){this.B=this.V.version,t.prototype.D.call(this)},i.prototype.T=function(){var t=this;try{return K((function(){var n=t.V.getMaybeFinalState();return I.map(n,(function(n){return t.q(n)}))}))}catch(t){return new F(M(t,this))}},i.prototype.C=function(){return this.B===this.V.version},i.prototype[r]=function(){t.prototype[r].call(this),this.connected&&X(this.V,this)},i.prototype[s]=function(){Y(this.V,this),t.prototype[s].call(this)},i.prototype[f]=function(){t.prototype[f].call(this),this.V=void 0,this.q=void 0},i}(ct),lt=function(t){function i(n,i,r){var e=t.call(this,n,i)||this;return e.G=r,e}return n.__extends(i,t),i.prototype.set=function(t){var n=this;if(this.finalized)throw M(Error("cannot set a final derivable"),this);this.V.set(I.map(t,(function(t){return n.G(t)})))},Object.defineProperty(i.prototype,"settable",{get:function(){return this.V.settable},enumerable:!0,configurable:!0}),i.prototype[f]=function(){t.prototype[f].call(this),this.G=void 0},i}(vt);function bt(t){return t.settable}function dt(t){return"function"==typeof t?t():ut(t)}function wt(){var t=this.getState();return t===d||t instanceof F?void 0:t}function pt(t){return this.set(t)}function yt(t){return t instanceof tt}var mt=I.wrap(d);function Ot(t){return new et(t)}function jt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new ht(t,n.length?n:void 0)}function gt(t){return Ot.final(t)}function xt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new at(t,n.length?n:void 0)}function St(t){var n=this,i=T.plucker,r=i.get,e=i.set,o=this;return yt(t)?xt({get:function(){return r.call(this,o.get(),t.get())},set:function(n){o.set(e.call(this,n,o.value,t.get()))}}):o.map((function(i){return r.call(n,i,t)}),(function(i){return e.call(n,i,o.value,t)}))}function kt(){this.set(d)}function Et(t){this.set(new F(t))}function _t(t){this.set(I.wrap(t))}function Rt(t){for(var i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];this.set(t.apply(void 0,n.__spreadArrays([this.value],i.map(st))))}!function(t){function n(t){return new et(I.wrap(t))}t.unresolved=function(){return new et(d)},t.error=function(t){return new et(new F(t))},t.final=n,function(t){t.unresolved=function(){return new et(mt)},t.error=function(t){return new et(I.wrap(new F(t)))}}(n=t.final||(t.final={}))}(Ot||(Ot={})),function(t){t.unresolved=function(){return Ot.final.unresolved()},t.error=function(t){return Ot.final.error(t)}}(gt||(gt={}));var At=new et(I.wrap(!0)),Tt=new et(I.wrap(!1)),Ct=Symbol("skipped"),Dt=I.wrap(Ct);function Ft(t,n,i,r){if(void 0!==t){var e=t?At:Tt;if(!(t===i||t instanceof et&&t.j instanceof I&&t.j.value===i)){if("function"==typeof t){var o=t;t=new ht((function(){return o(n)})).derive(ut)}return t instanceof tt?void 0!==r?t.mapState((function(t){return t===r?I.wrap(t):t})):t:e}}}function It(t){var n=I.unwrap(t);return n!==d&&!(n instanceof F)}Object.defineProperties(tt.prototype,{get:{value:function(){var t=this.getState();if(t instanceof F)throw t.error;if(t!==d)return t;if(ft>0)throw d;throw M(Error("Could not get value, derivable is unresolved"),this)}},getOr:{value:function(t){var n=this.getState();if(n instanceof F)throw n.error;return n===d?dt(t):n}},value:{get:wt},resolved:{get:function(){return this.getState()!==d}},settable:{value:!1},final:{get:function(){return this.getMaybeFinalState()instanceof I}},errored:{get:function(){return this.getState()instanceof F}},error:{get:function(){var t=this.getState();return t instanceof F?t.error:void 0}},connected$:{get:function(){return this.O||(this.O=new et(this.connected))}},derive:{value:function(t){for(var i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];return new ht(t,n.__spreadArrays([this],i))}},map:{value:function(t,n){var i=function(n){return n===d||n instanceof F?n:t.call(this,n)};return n&&bt(this)?new lt(this,i,(function(t){return t===d||t instanceof F?t:n.call(this,t,this.V.value)})):new vt(this,i)}},mapState:{value:function(t,n){return n&&bt(this)?new lt(this,t,(function(t){return n.call(this,t,this.V.getState())})):new vt(this,t)}},pluck:{value:function(t){var n=this,i=T.plucker.get;return yt(t)?this.derive(i,t):this.map((function(r){return i.call(n,r,t)}))}},fallbackTo:{value:function(t){var n=this;return yt(t)?jt((function(){return n.getOr(t)})):this.mapState((function(n){return n===d?dt(t):n}))}},take:{value:function(t){var n=this,i=t.from,r=t.when,e=t.until,o=t.once,u=t.stopOnError,s=t.skipFirst,c=Ft(i,this,!0,!0),f=Ft(r,this,!0),h=Ft(e,this,!1,!0),a=s?new et(d):void 0;if(!(c||f||h||o||u||a))return this;var v=(h||f)&&new et(d);function l(t){return v&&v.set(t),t}return new ht((function(){if(c&&!c.get())return d;if(h&&h.get())return l(I.wrap(v.j));if(f&&!f.value)return v.j;var t=n.getMaybeFinalState();if(a&&!Dt.equals(a.j)){if(!It(t))return l(t);if(a.j===d||D(t,a.j))return a.set(t),l(d);a.set(Dt)}return l(o&&It(t)||u&&t instanceof F?I.wrap(t):t)}))}},and:{value:function(t){return yt(t)?this.derive((function(n){return n&&t.get()})):this.map((function(n){return n&&t}))}},or:{value:function(t){return yt(t)?this.derive((function(n){return n||t.get()})):this.map((function(n){return n||t}))}},not:{value:function(){return this.map((function(t){return!t}))}},is:{value:function(t){return yt(t)?this.derive(D,t):this.map((function(n){return D(n,t)}))}}}),[et,ot,lt,at].forEach((function(t){return Object.defineProperties(t.prototype,{value:{get:wt,set:pt},swap:{value:Rt},pluck:{value:St}})})),[et,lt].forEach((function(t){return Object.defineProperties(t.prototype,{unset:{value:kt},setError:{value:Et},setFinal:{value:_t}})})),Object.defineProperties(at.prototype,{settable:{value:!0}}),tt.prototype.react=function(t,n){var i=this;return K((function(){return Vt.create(i,t,n)}))},tt.prototype.toPromise=function(t){var i=this;return new Promise((function(r,e){return i.react(r,n.__assign(n.__assign({},t),{once:!0,onError:function(t,n){n(),e(t)}}))}))};var Mt,Vt=function(){function t(t,n,i,r){this.N=t,this.P=n,this.U=i,this.ended=r,this.L=!1,this.id=U(),this.$=0,this.creationStack=q(this),this.H=c}return t.prototype.J=function(){X(this.N,this),this.L=!0,this.o()},t.prototype.o=function(){var t=this;if(this.L){var n=function(n){return function(){n===d||D(t.H,n)||(t.H=n,n instanceof F?t.P(n.error):t.K(n))}},i=this.N[h]();i instanceof I?this.W(n(i.value)):n(i)()}},t.prototype.K=function(t){var n=this;this.$++;try{if(this.$>100)throw Error("Too deeply nested synchronous cyclical reactions disallowed. Use setImmediate.");this.U(t,(function(){return n.W()}))}catch(t){this.P(M(t,this))}finally{this.$--}},t.prototype.W=function(t){this.L&&(this.L=!1,Y(this.N,this),t&&t(),this.ended&&this.ended())},t.prototype[a]=function(t){t.indexOf(this)<0&&t.push(this)},t.create=function(n,i,r,e){var o=new t(r?n.take(r):n,(function(t){if(!r||!r.onError)throw u(),t;r.onError(t,u)}),i,e);function u(){o.W()}return o.J(),u},t}(),qt=Object.freeze({symbols:w,Atom:et,BaseDerivable:tt,BaseDerivation:ct,Derivation:ht,Lens:at,resolveFallback:dt,safeUnwrap:st,Reactor:Vt,isRecordingObservations:H,addObserver:X,allDependenciesAreFinal:J,independentTracking:K,markFinal:Q,maybeDisconnectInNextTick:Z,recordObservation:W,removeObserver:Y,startRecordingObservations:L,stopRecordingObservations:$,processChangedState:O,augmentStack:M}),zt={clone:A,equals:D,isPlainObject:function(t){if("object"!=typeof t||null==t)return!1;var n=Object.getPrototypeOf(t);return n===Object.prototype||null===n||t.constructor===Object},resolveFallback:dt};(Mt="undefined"!=typeof window?window:global)[b]?(Mt[b]++,console.warn(Mt[b]+" instances of Sherlock detected. This could cause unexpected results.")):Mt[b]=1,exports.ErrorWrapper=F,exports.FinalWrapper=I,exports.PullDataSource=ot,exports._internal=qt,exports.atom=Ot,exports.atomic=k,exports.atomically=S,exports.config=T,exports.constant=gt,exports.derive=jt,exports.inTransaction=p,exports.isDerivable=yt,exports.isDerivableAtom=function t(n){return n instanceof et&&n.settable||n instanceof lt&&t(n.V)},exports.isSettableDerivable=function(t){return yt(t)&&t.settable},exports.lens=xt,exports.safeUnwrap=st,exports.transact=x,exports.transaction=function t(n){return n?function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var r=this;return x((function(){return n.apply(r,t)}))}:function(n,i,r){r.value=r.value&&t(r.value)}},exports.unresolved=d,exports.unwrap=ut,exports.utils=zt;
//# sourceMappingURL=sherlock.cjs.min.js.map

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

import{__extends as t,__decorate as n,__assign as i}from"tslib";var r,e=Symbol("autoCacheMode"),u=Symbol("connect"),o=Symbol("dependencies"),s=Symbol("dependencyVersions"),c=Symbol("derivableAtom"),f=Symbol("disconnect"),h=Symbol("emptyCache"),a=Symbol("finalize"),v=Symbol("internalGetState"),l=Symbol("mark"),b=Symbol("observers"),d=Symbol("rollback"),w=Symbol("sherlockInstances"),y=Symbol("unresolved"),m=Object.freeze({autoCacheMode:e,connect:u,dependencies:o,dependencyVersions:s,derivableAtom:c,disconnect:f,emptyCache:h,finalize:a,internalGetState:v,mark:l,observers:b,rollback:d,sherlockInstances:w,unresolved:y});function O(){return!!r}function p(t){r?r.t[t.id]=t:t[a]()}function g(t,n,i){r&&T(r,t,n,i)}function j(t){if(r)S(t,r.i);else{var n=[];S(t,n),k(n)}}function S(t,n){for(var i=0,r=t[b];i<r.length;i++)r[i][l](n)}function k(t){for(var n=0,i=t;n<i.length;n++)i[n].u()}function E(t){var n;r={o:[],s:{},h:{},t:{},i:[],v:r};try{n=t()}catch(t){throw function(){var t=r;if(!t)throw Error();r=t.v,t.o.forEach(function(n){return n[d](t.s[n.id],t.h[n.id])})}(),t}return function(){var t,n=r;if(!n)throw Error();(r=n.v)?(n.o.forEach(function(t){return T(r,t,n.s[t.id],n.h[t.id])}),(t=r.i).push.apply(t,n.i),Object.assign(r.t,n.t)):(Object.values(n.t).forEach(function(t){return t[a]()}),k(n.i))}(),n}function _(t){return O()?t():E(t)}function R(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return _(function(){return t.apply(r,n)})}:function(t,n,i){i.value=i.value&&R(i.value)}}function A(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return E(function(){return t.apply(r,n)})}:function(t,n,i){i.value=i.value&&A(i.value)}}function T(t,n,i,r){var e=n.id;e in t.s||(t.o.push(n),t.s[e]=i,t.h[e]=r)}var C=Object.getOwnPropertyDescriptors||function(t){for(var n={},i=0,r=D(t);i<r.length;i++){var e=r[i];n[e]=Object.getOwnPropertyDescriptor(t,e)}return n},D="undefined"!=typeof Reflect?Reflect.ownKeys:function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))};function F(t){return Array.isArray(t)?function(t){try{return Object.defineProperties(new t.constructor,C(t))}catch(t){throw Object.assign(Error("could not clone Array: "+(t&&t.message)),{jse_cause:t})}}(t):Object.create(Object.getPrototypeOf(t),C(t))}var I={equals:function(t,n){return(i=t)&&"function"==typeof i.equals&&!!t.equals(n);var i},plucker:{get:function(t,n){return V(t)?t.get(n):t[n]},set:function(t,n,i){if(V(n)){if("function"==typeof n.set)return n.set(i,t);throw Error("object is readonly")}var r=F(n);return r[i]=t,r}},debugMode:!1};function V(t){return t&&"function"==typeof t.get}function x(t,n){return Object.is(t,n)||I.equals(t,n)}var M=function(){function t(t){this.error=t}return t.prototype.equals=function(n){return this===n||n instanceof t&&x(this.error,n.error)},t}(),q=function(){function t(t){this.value=t}return t.wrap=function(n){return n instanceof t?n:new t(n)},t.unwrap=function(n){return n instanceof t?n.value:n},t.map=function(n,i){return n instanceof t?t.wrap(i(n.value)):i(n)},t.prototype.equals=function(n){return this===n||n instanceof t&&x(this.value,n.value)},t}();function z(t,n){var i=n.creationStack;return i?Object.defineProperty(F(t),"stack",{value:t.stack+"\n"+i}):t}function B(t,n){if(t instanceof q){var i=B(t.value,n);if(i!==t.value)return q.wrap(i)}return n.creationStack&&t instanceof M?new M(z(t.error,n)):t}function G(t){if(I.debugMode){var n=Error().stack;return t.constructor.name+" created:\n"+(n&&n.substr(n.indexOf("\n")+1))}}var N,P,U,L,$=0;function H(){return $++}function J(t){for(var n=N;n;){if(n.l===t)throw z(Error("cyclic dependency between derivables detected"),t);n=n.m}N={l:t,O:0,m:N,t:{}}}function K(){var t=N;if(!t)throw Error("No active recording!");N=t.m;for(var n=t.O,i=t.l,r=t.t,e=i[o],u=i[s],c=n,f=e.length;c<f;c++)nt(e[c],i);e.length=n;for(var h=0,a=e;h<a.length;h++){var v=a[h];u[v.id]=v.version}Object.values(r).forEach(p)}function Q(){return!!N}function W(){if(!N)return!1;for(var t=N.O,n=N.t,i=N.l[o],r=0;r<t;r++)if(!(i[r].id in n))return!1;return!0}function X(t){var n=N;N=void 0;try{return t()}finally{N=n}}function Y(t){N?N.t[t.id]=t:p(t)}function Z(t,n){if(N&&!t.finalized){n&&(N.t[t.id]=t);var i=N.l,r=i[o];if(r[N.O]===t)N.O++;else{var e=r.indexOf(t);e<0?(tt(t,i),N.O===r.length?r.push(t):(r.push(r[N.O]),r[N.O]=t),N.O++):e>N.O&&(r[e]=r[N.O],r[N.O]=t,N.O++)}}}function tt(t,n){var i=t[b];i.push(n),1!==i.length||t.connected||t[u]()}function nt(t,n){var i=t[b],r=i.indexOf(n);if(r<0)throw Error("Inconsistent state!");i.splice(r,1),0===i.length&&t.connected&&(t[e]?it(t):t[f]())}function it(t){P?P.push(t):(P=[t],setTimeout(function(){var t=P;P=void 0,t.forEach(function(t){return t.connected&&0===t[b].length&&t[f]()})},0))}var rt=function(){function t(){this.id=H(),this.creationStack=G(this),this[U]=[],this[L]=!1,this.connected=!1,this.p=void 0,this.finalized=!1}return t.prototype.autoCache=function(){return this[e]=!0,this},t.prototype.getMaybeFinalState=function(){return this.connected||(this[e]?(this[u](),it(this)):Q()&&this[u]()),this[v]()},t.prototype.getState=function(){return q.unwrap(this.getMaybeFinalState())},t.prototype[(U=b,L=e,u)]=function(){this.finalized||et(this,!0)},t.prototype[f]=function(){et(this,!1)},t.prototype[a]=function(){this.finalized=!0,this.connected&&this[f]()},t}();function et(t,n){t.connected=n,t.p&&X(function(){return t.p.set(n)})}var ut,ot,st=function(n){function i(t){var i=n.call(this)||this;return i.version=0,i.g=B(t,i),i.j()&&i[a](),i}return t(i,n),Object.defineProperty(i.prototype,"settable",{get:function(){return!this.j()},enumerable:!0,configurable:!0}),i.prototype.j=function(){return this.g instanceof q},i.prototype[v]=function(){return Z(this,this.j()),this.g},i.prototype.set=function(t){var n=this.g;if(!x(t,n)){if(this.j())throw z(Error("cannot set a final atom"),this);this.g=B(t,this),g(this,n,this.version++),j(this),this.j()&&Y(this)}},i.prototype[d]=function(t,n){this.g=t,this.version=n,S(this,[])},i}(rt),ct=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.S=h,t.version=0,t}return t(i,n),i.prototype.j=function(){return this.S instanceof q},i.prototype[v]=function(){return this.connected?(Z(this,this.j()),this.S):this.j()?this.S:this.k()},i.prototype.set=function(t){if(!this.acceptNewValue)throw z(Error("DataSource is not settable"),this);this.acceptNewValue(t)},i.prototype.checkForChanges=function(){var t=this;if(this.connected){var n=X(function(){return t.k()}),i=this.S;x(n,i)||(this.S=n,g(this,i,this.version++),j(this))}},i.prototype.k=function(){try{return this.calculateCurrentValue()}catch(t){return new M(z(t,this))}},i.prototype[d]=function(t,n){this.version++,S(this,[])},i.prototype[u]=function(){n.prototype[u].call(this),this.connected&&this.checkForChanges()},i.prototype[f]=function(){n.prototype[f].call(this),this.finalized||(this.S=h)},Object.defineProperty(i.prototype,"settable",{get:function(){return!!this.acceptNewValue},enumerable:!0,configurable:!0}),i}(rt);function ft(t){return t instanceof rt?t.get():t}function ht(t){return t instanceof rt?t.value:t}var at=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t._=!1,t.S=h,t.R=0,t}return t(i,n),Object.defineProperty(i.prototype,"version",{get:function(){return this.A(),this.R},enumerable:!0,configurable:!0}),i.prototype.j=function(){return this.S instanceof q},i.prototype[v]=function(){if(this.connected)return this.A(),Z(this,this.j()),this.S;if(this.j())return this.S;var t=this.T();return t instanceof q&&(this.S=t,g(this,void 0,this.R++),Y(this)),t},i.prototype.A=function(){this.connected&&!this._&&(this.S!==h&&(this._=this.j()||this.C()),this._||this.D())},i.prototype.D=function(){var t=this.T();x(t,this.S)||(this.S=t,g(this,void 0,this.R++),this.j()&&Y(this)),this._=!0},i.prototype[l]=function(t){this._&&(this._=!1,S(this,t))},i.prototype[d]=function(t,n){this.S=h,this.R=n,this[l]([])},i.prototype[f]=function(){n.prototype[f].call(this),this._=!1,this.finalized||(this.S=h)},i}(rt),vt=0,lt=function(n){function i(t,i){var r=n.call(this)||this;return r.F=t,r.I=i,r[ut]=[],r[ot]={},r}return t(i,n),i.prototype.D=function(){J(this);try{n.prototype.D.call(this)}finally{K()}},i.prototype.T=function(){++vt;try{var t=this.I?this.F.apply(this,this.I.map(ft)):this.F();return W()?q.wrap(t):t}catch(t){return t===y?y:new M(z(t,this))}finally{--vt}},i.prototype.C=function(){var t=this;return this[o].every(function(n){return t[s][n.id]===n.version})},i.prototype[(ut=o,ot=s,f)]=function(){for(var t=0,i=this[o];t<i.length;t++)nt(i[t],this);this[o].length=0,n.prototype[f].call(this)},i.prototype[a]=function(){n.prototype[a].call(this),this.F=void 0,this.I=void 0},i}(at),bt=function(i){function r(t,n){var r=t.get,e=t.set,u=i.call(this,r,n)||this;return u.V=e,u}return t(r,i),r.prototype.set=function(t){this.I?this.V.apply(this,[t].concat(this.I.map(ht))):this.V(t)},n([R()],r.prototype,"set",null),r}(lt),dt=function(n){function i(t,i){var r=n.call(this)||this;return r.M=t,r.q=i,r.B=0,r}return t(i,n),i.prototype.D=function(){this.B=this.M.version,n.prototype.D.call(this)},i.prototype.T=function(){var t=this;try{return X(function(){var n=t.M.getMaybeFinalState();return q.map(n,function(n){return t.q(n)})})}catch(t){return new M(z(t,this))}},i.prototype.C=function(){return this.B===this.M.version},i.prototype[u]=function(){n.prototype[u].call(this),this.connected&&tt(this.M,this)},i.prototype[f]=function(){nt(this.M,this),n.prototype[f].call(this)},i.prototype[a]=function(){n.prototype[a].call(this),this.M=void 0,this.q=void 0},i}(at),wt=function(n){function i(t,i,r){var e=n.call(this,t,i)||this;return e.G=r,e}return t(i,n),i.prototype.set=function(t){var n=this;this.M.set(q.map(t,function(t){return n.G(t)}))},Object.defineProperty(i.prototype,"settable",{get:function(){return this.M.settable},enumerable:!0,configurable:!0}),i.prototype[a]=function(){n.prototype[a].call(this),this.G=void 0},i}(dt);function yt(t){return t.settable}function mt(t){return"function"==typeof t?t():ft(t)}function Ot(){var t=this.getState();return t===y||t instanceof M?void 0:t}function pt(t){return this.set(t)}function gt(t){return t instanceof rt}function jt(t){return gt(t)&&t.settable}function St(t){return t instanceof st&&t.settable||t instanceof wt&&St(t.M)}var kt=q.wrap(y);function Et(t){return new st(t)}function _t(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new lt(t,n.length?n:void 0)}function Rt(t){return Et.final(t)}function At(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new bt(t,n.length?n:void 0)}function Tt(t){var n=this,i=I.plucker,r=i.get,e=i.set,u=this;return gt(t)?At({get:function(){return r.call(this,u.get(),t.get())},set:function(n){u.set(e.call(this,n,u.value,t.get()))}}):u.map(function(i){return r.call(n,i,t)},function(i){return e.call(n,i,u.value,t)})}function Ct(){this.set(y)}function Dt(t){this.set(new M(t))}function Ft(t){this.set(q.wrap(t))}function It(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.set(t.apply(void 0,[this.value].concat(n.map(ht))))}!function(t){function n(t){return new st(q.wrap(t))}t.unresolved=function(){return new st(y)},t.error=function(t){return new st(new M(t))},t.final=n,function(t){t.unresolved=function(){return new st(kt)},t.error=function(t){return new st(q.wrap(new M(t)))}}(n=t.final||(t.final={}))}(Et||(Et={})),function(t){t.unresolved=function(){return Et.final.unresolved()},t.error=function(t){return Et.final.error(t)}}(Rt||(Rt={}));var Vt=new st(q.wrap(!0)),xt=new st(q.wrap(!1)),Mt=Symbol("skipped"),qt=q.wrap(Mt);function zt(t,n,i,r){if(void 0!==t){var e=t?Vt:xt;if(!(t===i||t instanceof st&&t.g instanceof q&&t.g.value===i)){if("function"==typeof t){var u=t;t=new lt(function(){return u(n)}).derive(ft)}return t instanceof rt?void 0!==r?t.mapState(function(t){return t===r?q.wrap(t):t}):t:e}}}function Bt(t){var n=q.unwrap(t);return n!==y&&!(n instanceof M)}Object.defineProperties(rt.prototype,{get:{value:function(){var t=this.getState();if(t instanceof M)throw t.error;if(t!==y)return t;if(vt>0)throw y;throw z(Error("Could not get value, derivable is unresolved"),this)}},getOr:{value:function(t){var n=this.getState();if(n instanceof M)throw n.error;return n===y?mt(t):n}},value:{get:Ot},resolved:{get:function(){return this.getState()!==y}},settable:{value:!1},final:{get:function(){return this.getMaybeFinalState()instanceof q}},errored:{get:function(){return this.getState()instanceof M}},error:{get:function(){var t=this.getState();return t instanceof M?t.error:void 0}},connected$:{get:function(){return this.p||(this.p=new st(this.connected))}},derive:{value:function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new lt(t,[this].concat(n))}},map:{value:function(t,n){var i=function(n){return n===y||n instanceof M?n:t.call(this,n)};return n&&yt(this)?new wt(this,i,function(t){return t===y||t instanceof M?t:n.call(this,t,this.M.value)}):new dt(this,i)}},mapState:{value:function(t,n){return n&&yt(this)?new wt(this,t,function(t){return n.call(this,t,this.M.getState())}):new dt(this,t)}},pluck:{value:function(t){var n=this,i=I.plucker.get;return gt(t)?this.derive(i,t):this.map(function(r){return i.call(n,r,t)})}},fallbackTo:{value:function(t){var n=this;return gt(t)?_t(function(){return n.getOr(t)}):this.mapState(function(n){return n===y?mt(t):n})}},take:{value:function(t){var n=this,i=t.from,r=t.when,e=t.until,u=t.once,o=t.stopOnError,s=t.skipFirst,c=zt(i,this,!0,!0),f=zt(r,this,!0),h=zt(e,this,!1,!0),a=s?new st(y):void 0;if(!(c||f||h||u||o||a))return this;var v=(h||f)&&new st(y);function l(t){return v&&v.set(t),t}return new lt(function(){if(c&&!c.get())return y;if(h&&h.get())return l(q.wrap(v.g));if(f&&!f.value)return v.g;var t=n.getMaybeFinalState();if(a&&!qt.equals(a.g)){if(!Bt(t))return l(t);if(a.g===y||x(t,a.g))return a.set(t),l(y);a.set(qt)}return l(u&&Bt(t)||o&&t instanceof M?q.wrap(t):t)})}},and:{value:function(t){return gt(t)?this.derive(function(n){return n&&t.get()}):this.map(function(n){return n&&t})}},or:{value:function(t){return gt(t)?this.derive(function(n){return n||t.get()}):this.map(function(n){return n||t})}},not:{value:function(){return this.map(function(t){return!t})}},is:{value:function(t){return gt(t)?this.derive(x,t):this.map(function(n){return x(n,t)})}}}),[st,ct,wt,bt].forEach(function(t){return Object.defineProperties(t.prototype,{value:{get:Ot,set:pt},swap:{value:It},pluck:{value:Tt}})}),[st,wt].forEach(function(t){return Object.defineProperties(t.prototype,{unset:{value:Ct},setError:{value:Dt},setFinal:{value:Ft}})}),Object.defineProperties(bt.prototype,{settable:{value:!0}}),rt.prototype.react=function(t,n){var i=this;return X(function(){return Nt.create(i,t,n)})},rt.prototype.toPromise=function(t){var n=this;return new Promise(function(r,e){return n.react(r,i({},t,{once:!0,onError:function(t,n){n(),e(t)}}))})};var Gt,Nt=function(){function t(t,n,i,r){this.N=t,this.P=n,this.U=i,this.ended=r,this.L=!1,this.id=H(),this.$=0,this.creationStack=G(this),this.H=h}return t.prototype.J=function(){tt(this.N,this),this.L=!0,this.u()},t.prototype.u=function(){var t=this;if(this.L){var n=function(n){return function(){n===y||x(t.H,n)||(t.H=n,n instanceof M?t.P(n.error):t.K(n))}},i=this.N[v]();i instanceof q?this.W(n(i.value)):n(i)()}},t.prototype.K=function(t){var n=this;this.$++;try{if(this.$>100)throw Error("Too deeply nested synchronous cyclical reactions disallowed. Use setImmediate.");this.U(t,function(){return n.W()})}catch(t){this.P(z(t,this))}finally{this.$--}},t.prototype.W=function(t){this.L&&(this.L=!1,nt(this.N,this),t&&t(),this.ended&&this.ended())},t.prototype[l]=function(t){t.indexOf(this)<0&&t.push(this)},t.create=function(n,i,r,e){var u=new t(r?n.take(r):n,function(t){if(!r||!r.onError)throw o(),t;r.onError(t,o)},i,e);function o(){u.W()}return u.J(),o},t}(),Pt=Object.freeze({symbols:m,Atom:st,BaseDerivable:rt,BaseDerivation:at,Derivation:lt,Lens:bt,resolveFallback:mt,safeUnwrap:ht,Reactor:Nt,isRecordingObservations:Q,addObserver:tt,allDependenciesAreFinal:W,independentTracking:X,markFinal:Y,maybeDisconnectInNextTick:it,recordObservation:Z,removeObserver:nt,startRecordingObservations:J,stopRecordingObservations:K,processChangedState:j,augmentStack:z}),Ut={clone:F,equals:x,isPlainObject:function(t){if("object"!=typeof t||null==t)return!1;var n=Object.getPrototypeOf(t);return n===Object.prototype||null===n||t.constructor===Object},resolveFallback:mt};(Gt="undefined"!=typeof window?window:global)[w]?(Gt[w]++,console.warn(Gt[w]+" instances of Sherlock detected. This could cause unexpected results.")):Gt[w]=1;export{M as ErrorWrapper,q as FinalWrapper,ct as PullDataSource,Pt as _internal,Et as atom,R as atomic,_ as atomically,I as config,Rt as constant,_t as derive,O as inTransaction,gt as isDerivable,St as isDerivableAtom,jt as isSettableDerivable,At as lens,ht as safeUnwrap,E as transact,A as transaction,y as unresolved,ft as unwrap,Ut as utils};
import{__spreadArrays as t,__extends as n,__decorate as i,__assign as r}from"tslib";var e,u=Symbol("autoCacheMode"),o=Symbol("connect"),s=Symbol("dependencies"),c=Symbol("dependencyVersions"),f=Symbol("derivableAtom"),h=Symbol("disconnect"),a=Symbol("emptyCache"),v=Symbol("finalize"),l=Symbol("internalGetState"),b=Symbol("mark"),d=Symbol("observers"),w=Symbol("rollback"),y=Symbol("sherlockInstances"),m=Symbol("unresolved"),O=Object.freeze({autoCacheMode:u,connect:o,dependencies:s,dependencyVersions:c,derivableAtom:f,disconnect:h,emptyCache:a,finalize:v,internalGetState:l,mark:b,observers:d,rollback:w,sherlockInstances:y,unresolved:m});function p(){return!!e}function g(t){e?e.t[t.id]=t:t[v]()}function j(t,n,i){e&&C(e,t,n,i)}function S(t){if(e)k(t,e.i);else{var n=[];k(t,n),E(n)}}function k(t,n){for(var i=0,r=t[d];i<r.length;i++)r[i][b](n)}function E(t){for(var n=0,i=t;n<i.length;n++)i[n].u()}function _(t){var n;e={o:[],s:{},h:{},t:{},i:[],v:e};try{n=t()}catch(t){throw function(){var t=e;if(!t)throw Error();e=t.v,t.o.forEach((function(n){return n[w](t.s[n.id],t.h[n.id])}))}(),t}return function(){var t,n=e;if(!n)throw Error();(e=n.v)?(n.o.forEach((function(t){return C(e,t,n.s[t.id],n.h[t.id])})),(t=e.i).push.apply(t,n.i),Object.assign(e.t,n.t)):(Object.values(n.t).forEach((function(t){return t[v]()})),E(n.i))}(),n}function R(t){return p()?t():_(t)}function A(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return R((function(){return t.apply(r,n)}))}:function(t,n,i){i.value=i.value&&A(i.value)}}function T(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return _((function(){return t.apply(r,n)}))}:function(t,n,i){i.value=i.value&&T(i.value)}}function C(t,n,i,r){var e=n.id;e in t.s||(t.o.push(n),t.s[e]=i,t.h[e]=r)}var D=Object.getOwnPropertyDescriptors||function(t){for(var n={},i=0,r=F(t);i<r.length;i++){var e=r[i];n[e]=Object.getOwnPropertyDescriptor(t,e)}return n},F="undefined"!=typeof Reflect?Reflect.ownKeys:function(n){return t(Object.getOwnPropertyNames(n),Object.getOwnPropertySymbols(n))};function I(t){return Array.isArray(t)?function(t){try{return Object.defineProperties(new t.constructor,D(t))}catch(t){throw Object.assign(Error("could not clone Array: "+(t&&t.message)),{jse_cause:t})}}(t):Object.create(Object.getPrototypeOf(t),D(t))}var V={equals:function(t,n){return(i=t)&&"function"==typeof i.equals&&!!t.equals(n);var i},plucker:{get:function(t,n){return x(t)?t.get(n):t[n]},set:function(t,n,i){if(x(n)){if("function"==typeof n.set)return n.set(i,t);throw Error("object is readonly")}var r=I(n);return r[i]=t,r}},debugMode:!1};function x(t){return t&&"function"==typeof t.get}function M(t,n){return Object.is(t,n)||V.equals(t,n)}var q=function(){function t(t){this.error=t}return t.prototype.equals=function(n){return this===n||n instanceof t&&M(this.error,n.error)},t}(),z=function(){function t(t){this.value=t}return t.wrap=function(n){return n instanceof t?n:new t(n)},t.unwrap=function(n){return n instanceof t?n.value:n},t.map=function(n,i){return n instanceof t?t.wrap(i(n.value)):i(n)},t.prototype.equals=function(n){return this===n||n instanceof t&&M(this.value,n.value)},t}();function B(t,n){var i=n.creationStack;return i?Object.defineProperty(I(t),"stack",{value:t.stack+"\n"+i}):t}function G(t,n){if(t instanceof z){var i=G(t.value,n);if(i!==t.value)return z.wrap(i)}return n.creationStack&&t instanceof q?new q(B(t.error,n)):t}function N(t){if(V.debugMode){var n=Error().stack;return t.constructor.name+" created:\n"+(n&&n.substr(n.indexOf("\n")+1))}}var P,U,L,$,H=0;function J(){return H++}function K(t){for(var n=P;n;){if(n.l===t)throw B(Error("cyclic dependency between derivables detected"),t);n=n.m}P={l:t,O:0,m:P,t:{}}}function Q(){var t=P;if(!t)throw Error("No active recording!");P=t.m;for(var n=t.O,i=t.l,r=t.t,e=i[s],u=i[c],o=n,f=e.length;o<f;o++)it(e[o],i);e.length=n;for(var h=0,a=e;h<a.length;h++){var v=a[h];u[v.id]=v.version}Object.values(r).forEach(g)}function W(){return!!P}function X(){if(!P)return!1;for(var t=P.O,n=P.t,i=P.l[s],r=0;r<t;r++)if(!(i[r].id in n))return!1;return!0}function Y(t){var n=P;P=void 0;try{return t()}finally{P=n}}function Z(t){P?P.t[t.id]=t:g(t)}function tt(t,n){if(P&&!t.finalized){n&&(P.t[t.id]=t);var i=P.l,r=i[s];if(r[P.O]===t)P.O++;else{var e=r.indexOf(t);e<0?(nt(t,i),P.O===r.length?r.push(t):(r.push(r[P.O]),r[P.O]=t),P.O++):e>P.O&&(r[e]=r[P.O],r[P.O]=t,P.O++)}}}function nt(t,n){var i=t[d];i.push(n),1!==i.length||t.connected||t[o]()}function it(t,n){var i=t[d],r=i.indexOf(n);if(r<0)throw Error("Inconsistent state!");i.splice(r,1),0===i.length&&t.connected&&(t[u]?rt(t):t[h]())}function rt(t){U?U.push(t):(U=[t],setTimeout((function(){var t=U;U=void 0,t.forEach((function(t){return t.connected&&0===t[d].length&&t[h]()}))}),0))}var et=function(){function t(){this.id=J(),this.creationStack=N(this),this[L]=[],this[$]=!1,this.connected=!1,this.p=void 0,this.finalized=!1}return t.prototype.autoCache=function(){return this[u]=!0,this},t.prototype.getMaybeFinalState=function(){return this.connected||(this[u]?(this[o](),rt(this)):W()&&this[o]()),this[l]()},t.prototype.getState=function(){return z.unwrap(this.getMaybeFinalState())},t.prototype[(L=d,$=u,o)]=function(){this.finalized||ut(this,!0)},t.prototype[h]=function(){ut(this,!1)},t.prototype[v]=function(){this.finalized=!0,this.connected&&this[h]()},t}();function ut(t,n){t.connected=n,t.p&&Y((function(){return t.p.set(n)}))}var ot,st,ct=function(t){function i(n){var i=t.call(this)||this;return i.version=0,i.g=G(n,i),i.j()&&i[v](),i}return n(i,t),Object.defineProperty(i.prototype,"settable",{get:function(){return!this.j()},enumerable:!0,configurable:!0}),i.prototype.j=function(){return this.g instanceof z},i.prototype[l]=function(){return tt(this,this.j()),this.g},i.prototype.set=function(t){var n=this.g;if(!M(t,n)){if(this.j())throw B(Error("cannot set a final derivable"),this);this.g=G(t,this),j(this,n,this.version++),S(this),this.j()&&Z(this)}},i.prototype[w]=function(t,n){this.g=t,this.version=n,k(this,[])},i}(et),ft=function(t){function i(){var n=null!==t&&t.apply(this,arguments)||this;return n.S=a,n.version=0,n}return n(i,t),i.prototype.j=function(){return this.S instanceof z},i.prototype[l]=function(){return this.connected?(tt(this,this.j()),this.S):this.j()?this.S:this.k()},i.prototype.set=function(t){if(!this.acceptNewValue)throw B(Error("DataSource is not settable"),this);this.acceptNewValue(t)},i.prototype.checkForChanges=function(){var t=this;if(this.connected){var n=Y((function(){return t.k()})),i=this.S;M(n,i)||(this.S=n,j(this,i,this.version++),S(this))}},i.prototype.k=function(){try{return this.calculateCurrentValue()}catch(t){return new q(B(t,this))}},i.prototype[w]=function(t,n){this.version++,k(this,[])},i.prototype[o]=function(){t.prototype[o].call(this),this.connected&&this.checkForChanges()},i.prototype[h]=function(){t.prototype[h].call(this),this.finalized||(this.S=a)},Object.defineProperty(i.prototype,"settable",{get:function(){return!!this.acceptNewValue},enumerable:!0,configurable:!0}),i}(et);function ht(t){return t instanceof et?t.get():t}function at(t){return t instanceof et?t.value:t}var vt=function(t){function i(){var n=null!==t&&t.apply(this,arguments)||this;return n._=!1,n.S=a,n.R=0,n}return n(i,t),Object.defineProperty(i.prototype,"version",{get:function(){return this.A(),this.R},enumerable:!0,configurable:!0}),i.prototype.j=function(){return this.S instanceof z},i.prototype[l]=function(){if(this.connected)return this.A(),tt(this,this.j()),this.S;if(this.j())return this.S;var t=this.T();return t instanceof z&&(this.S=t,j(this,void 0,this.R++),Z(this)),t},i.prototype.A=function(){this.connected&&!this._&&(this.S!==a&&(this._=this.j()||this.C()),this._||this.D())},i.prototype.D=function(){var t=this.T();M(t,this.S)||(this.S=t,j(this,void 0,this.R++),this.j()&&Z(this)),this._=!0},i.prototype[b]=function(t){this._&&(this._=!1,k(this,t))},i.prototype[w]=function(t,n){this.S=a,this.R=n,this[b]([])},i.prototype[h]=function(){t.prototype[h].call(this),this._=!1,this.finalized||(this.S=a)},i}(et),lt=0,bt=function(t){function i(n,i){var r=t.call(this)||this;return r.F=n,r.I=i,r[ot]=[],r[st]={},r}return n(i,t),i.prototype.D=function(){K(this);try{t.prototype.D.call(this)}finally{Q()}},i.prototype.T=function(){++lt;try{var t=this.I?this.F.apply(this,this.I.map(ht)):this.F();return X()?z.wrap(t):t}catch(t){return t===m?m:new q(B(t,this))}finally{--lt}},i.prototype.C=function(){var t=this;return this[s].every((function(n){return t[c][n.id]===n.version}))},i.prototype[(ot=s,st=c,h)]=function(){for(var n=0,i=this[s];n<i.length;n++)it(i[n],this);this[s].length=0,t.prototype[h].call(this)},i.prototype[v]=function(){t.prototype[v].call(this),this.F=void 0,this.I=void 0},i}(vt),dt=function(r){function e(t,n){var i=t.get,e=t.set,u=r.call(this,i,n)||this;return u.V=e,u}return n(e,r),e.prototype.set=function(n){if(this.finalized)throw B(Error("cannot set a final derivable"),this);this.I?this.V.apply(this,t([n],this.I.map(at))):this.V(n)},i([A()],e.prototype,"set",null),e}(bt),wt=function(t){function i(n,i){var r=t.call(this)||this;return r.M=n,r.q=i,r.B=0,r}return n(i,t),i.prototype.D=function(){this.B=this.M.version,t.prototype.D.call(this)},i.prototype.T=function(){var t=this;try{return Y((function(){var n=t.M.getMaybeFinalState();return z.map(n,(function(n){return t.q(n)}))}))}catch(t){return new q(B(t,this))}},i.prototype.C=function(){return this.B===this.M.version},i.prototype[o]=function(){t.prototype[o].call(this),this.connected&&nt(this.M,this)},i.prototype[h]=function(){it(this.M,this),t.prototype[h].call(this)},i.prototype[v]=function(){t.prototype[v].call(this),this.M=void 0,this.q=void 0},i}(vt),yt=function(t){function i(n,i,r){var e=t.call(this,n,i)||this;return e.G=r,e}return n(i,t),i.prototype.set=function(t){var n=this;if(this.finalized)throw B(Error("cannot set a final derivable"),this);this.M.set(z.map(t,(function(t){return n.G(t)})))},Object.defineProperty(i.prototype,"settable",{get:function(){return this.M.settable},enumerable:!0,configurable:!0}),i.prototype[v]=function(){t.prototype[v].call(this),this.G=void 0},i}(wt);function mt(t){return t.settable}function Ot(t){return"function"==typeof t?t():ht(t)}function pt(){var t=this.getState();return t===m||t instanceof q?void 0:t}function gt(t){return this.set(t)}function jt(t){return t instanceof et}function St(t){return jt(t)&&t.settable}function kt(t){return t instanceof ct&&t.settable||t instanceof yt&&kt(t.M)}var Et=z.wrap(m);function _t(t){return new ct(t)}function Rt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new bt(t,n.length?n:void 0)}function At(t){return _t.final(t)}function Tt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new dt(t,n.length?n:void 0)}function Ct(t){var n=this,i=V.plucker,r=i.get,e=i.set,u=this;return jt(t)?Tt({get:function(){return r.call(this,u.get(),t.get())},set:function(n){u.set(e.call(this,n,u.value,t.get()))}}):u.map((function(i){return r.call(n,i,t)}),(function(i){return e.call(n,i,u.value,t)}))}function Dt(){this.set(m)}function Ft(t){this.set(new q(t))}function It(t){this.set(z.wrap(t))}function Vt(n){for(var i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];this.set(n.apply(void 0,t([this.value],i.map(at))))}!function(t){function n(t){return new ct(z.wrap(t))}t.unresolved=function(){return new ct(m)},t.error=function(t){return new ct(new q(t))},t.final=n,function(t){t.unresolved=function(){return new ct(Et)},t.error=function(t){return new ct(z.wrap(new q(t)))}}(n=t.final||(t.final={}))}(_t||(_t={})),function(t){t.unresolved=function(){return _t.final.unresolved()},t.error=function(t){return _t.final.error(t)}}(At||(At={}));var xt=new ct(z.wrap(!0)),Mt=new ct(z.wrap(!1)),qt=Symbol("skipped"),zt=z.wrap(qt);function Bt(t,n,i,r){if(void 0!==t){var e=t?xt:Mt;if(!(t===i||t instanceof ct&&t.g instanceof z&&t.g.value===i)){if("function"==typeof t){var u=t;t=new bt((function(){return u(n)})).derive(ht)}return t instanceof et?void 0!==r?t.mapState((function(t){return t===r?z.wrap(t):t})):t:e}}}function Gt(t){var n=z.unwrap(t);return n!==m&&!(n instanceof q)}Object.defineProperties(et.prototype,{get:{value:function(){var t=this.getState();if(t instanceof q)throw t.error;if(t!==m)return t;if(lt>0)throw m;throw B(Error("Could not get value, derivable is unresolved"),this)}},getOr:{value:function(t){var n=this.getState();if(n instanceof q)throw n.error;return n===m?Ot(t):n}},value:{get:pt},resolved:{get:function(){return this.getState()!==m}},settable:{value:!1},final:{get:function(){return this.getMaybeFinalState()instanceof z}},errored:{get:function(){return this.getState()instanceof q}},error:{get:function(){var t=this.getState();return t instanceof q?t.error:void 0}},connected$:{get:function(){return this.p||(this.p=new ct(this.connected))}},derive:{value:function(n){for(var i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];return new bt(n,t([this],i))}},map:{value:function(t,n){var i=function(n){return n===m||n instanceof q?n:t.call(this,n)};return n&&mt(this)?new yt(this,i,(function(t){return t===m||t instanceof q?t:n.call(this,t,this.M.value)})):new wt(this,i)}},mapState:{value:function(t,n){return n&&mt(this)?new yt(this,t,(function(t){return n.call(this,t,this.M.getState())})):new wt(this,t)}},pluck:{value:function(t){var n=this,i=V.plucker.get;return jt(t)?this.derive(i,t):this.map((function(r){return i.call(n,r,t)}))}},fallbackTo:{value:function(t){var n=this;return jt(t)?Rt((function(){return n.getOr(t)})):this.mapState((function(n){return n===m?Ot(t):n}))}},take:{value:function(t){var n=this,i=t.from,r=t.when,e=t.until,u=t.once,o=t.stopOnError,s=t.skipFirst,c=Bt(i,this,!0,!0),f=Bt(r,this,!0),h=Bt(e,this,!1,!0),a=s?new ct(m):void 0;if(!(c||f||h||u||o||a))return this;var v=(h||f)&&new ct(m);function l(t){return v&&v.set(t),t}return new bt((function(){if(c&&!c.get())return m;if(h&&h.get())return l(z.wrap(v.g));if(f&&!f.value)return v.g;var t=n.getMaybeFinalState();if(a&&!zt.equals(a.g)){if(!Gt(t))return l(t);if(a.g===m||M(t,a.g))return a.set(t),l(m);a.set(zt)}return l(u&&Gt(t)||o&&t instanceof q?z.wrap(t):t)}))}},and:{value:function(t){return jt(t)?this.derive((function(n){return n&&t.get()})):this.map((function(n){return n&&t}))}},or:{value:function(t){return jt(t)?this.derive((function(n){return n||t.get()})):this.map((function(n){return n||t}))}},not:{value:function(){return this.map((function(t){return!t}))}},is:{value:function(t){return jt(t)?this.derive(M,t):this.map((function(n){return M(n,t)}))}}}),[ct,ft,yt,dt].forEach((function(t){return Object.defineProperties(t.prototype,{value:{get:pt,set:gt},swap:{value:Vt},pluck:{value:Ct}})})),[ct,yt].forEach((function(t){return Object.defineProperties(t.prototype,{unset:{value:Dt},setError:{value:Ft},setFinal:{value:It}})})),Object.defineProperties(dt.prototype,{settable:{value:!0}}),et.prototype.react=function(t,n){var i=this;return Y((function(){return Pt.create(i,t,n)}))},et.prototype.toPromise=function(t){var n=this;return new Promise((function(i,e){return n.react(i,r(r({},t),{once:!0,onError:function(t,n){n(),e(t)}}))}))};var Nt,Pt=function(){function t(t,n,i,r){this.N=t,this.P=n,this.U=i,this.ended=r,this.L=!1,this.id=J(),this.$=0,this.creationStack=N(this),this.H=a}return t.prototype.J=function(){nt(this.N,this),this.L=!0,this.u()},t.prototype.u=function(){var t=this;if(this.L){var n=function(n){return function(){n===m||M(t.H,n)||(t.H=n,n instanceof q?t.P(n.error):t.K(n))}},i=this.N[l]();i instanceof z?this.W(n(i.value)):n(i)()}},t.prototype.K=function(t){var n=this;this.$++;try{if(this.$>100)throw Error("Too deeply nested synchronous cyclical reactions disallowed. Use setImmediate.");this.U(t,(function(){return n.W()}))}catch(t){this.P(B(t,this))}finally{this.$--}},t.prototype.W=function(t){this.L&&(this.L=!1,it(this.N,this),t&&t(),this.ended&&this.ended())},t.prototype[b]=function(t){t.indexOf(this)<0&&t.push(this)},t.create=function(n,i,r,e){var u=new t(r?n.take(r):n,(function(t){if(!r||!r.onError)throw o(),t;r.onError(t,o)}),i,e);function o(){u.W()}return u.J(),o},t}(),Ut=Object.freeze({symbols:O,Atom:ct,BaseDerivable:et,BaseDerivation:vt,Derivation:bt,Lens:dt,resolveFallback:Ot,safeUnwrap:at,Reactor:Pt,isRecordingObservations:W,addObserver:nt,allDependenciesAreFinal:X,independentTracking:Y,markFinal:Z,maybeDisconnectInNextTick:rt,recordObservation:tt,removeObserver:it,startRecordingObservations:K,stopRecordingObservations:Q,processChangedState:S,augmentStack:B}),Lt={clone:I,equals:M,isPlainObject:function(t){if("object"!=typeof t||null==t)return!1;var n=Object.getPrototypeOf(t);return n===Object.prototype||null===n||t.constructor===Object},resolveFallback:Ot};(Nt="undefined"!=typeof window?window:global)[y]?(Nt[y]++,console.warn(Nt[y]+" instances of Sherlock detected. This could cause unexpected results.")):Nt[y]=1;export{q as ErrorWrapper,z as FinalWrapper,ft as PullDataSource,Ut as _internal,_t as atom,A as atomic,R as atomically,V as config,At as constant,Rt as derive,p as inTransaction,jt as isDerivable,kt as isDerivableAtom,St as isSettableDerivable,Tt as lens,at as safeUnwrap,_ as transact,T as transaction,m as unresolved,ht as unwrap,Lt as utils};
//# sourceMappingURL=sherlock.esm.min.js.map

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

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).Sherlock={})}(this,function(t){"use strict";var n=function(t,i){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])})(t,i)};function i(t,i){function r(){this.constructor=t}n(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r,e=function(){return(e=Object.assign||function(t){for(var n,i=1,r=arguments.length;i<r;i++)for(var e in n=arguments[i])Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t}).apply(this,arguments)},u=Symbol("autoCacheMode"),o=Symbol("connect"),s=Symbol("dependencies"),c=Symbol("dependencyVersions"),f=Symbol("derivableAtom"),h=Symbol("disconnect"),a=Symbol("emptyCache"),v=Symbol("finalize"),l=Symbol("internalGetState"),b=Symbol("mark"),d=Symbol("observers"),w=Symbol("rollback"),y=Symbol("sherlockInstances"),O=Symbol("unresolved"),m=Object.freeze({autoCacheMode:u,connect:o,dependencies:s,dependencyVersions:c,derivableAtom:f,disconnect:h,emptyCache:a,finalize:v,internalGetState:l,mark:b,observers:d,rollback:w,sherlockInstances:y,unresolved:O});function p(){return!!r}function j(t){r?r.t[t.id]=t:t[v]()}function g(t,n,i){r&&T(r,t,n,i)}function S(t){if(r)k(t,r.i);else{var n=[];k(t,n),_(n)}}function k(t,n){for(var i=0,r=t[d];i<r.length;i++)r[i][b](n)}function _(t){for(var n=0,i=t;n<i.length;n++)i[n].u()}function E(t){var n;r={o:[],s:{},h:{},t:{},i:[],v:r};try{n=t()}catch(t){throw function(){var t=r;if(!t)throw Error();r=t.v,t.o.forEach(function(n){return n[w](t.s[n.id],t.h[n.id])})}(),t}return function(){var t,n=r;if(!n)throw Error();(r=n.v)?(n.o.forEach(function(t){return T(r,t,n.s[t.id],n.h[t.id])}),(t=r.i).push.apply(t,n.i),Object.assign(r.t,n.t)):(Object.values(n.t).forEach(function(t){return t[v]()}),_(n.i))}(),n}function R(t){return p()?t():E(t)}function A(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return R(function(){return t.apply(r,n)})}:function(t,n,i){i.value=i.value&&A(i.value)}}function T(t,n,i,r){var e=n.id;e in t.s||(t.o.push(n),t.s[e]=i,t.h[e]=r)}var C=Object.getOwnPropertyDescriptors||function(t){for(var n={},i=0,r=D(t);i<r.length;i++){var e=r[i];n[e]=Object.getOwnPropertyDescriptor(t,e)}return n},D="undefined"!=typeof Reflect?Reflect.ownKeys:function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))};function x(t){return Array.isArray(t)?function(t){try{return Object.defineProperties(new t.constructor,C(t))}catch(t){throw Object.assign(Error("could not clone Array: "+(t&&t.message)),{jse_cause:t})}}(t):Object.create(Object.getPrototypeOf(t),C(t))}var F={equals:function(t,n){return(i=t)&&"function"==typeof i.equals&&!!t.equals(n);var i},plucker:{get:function(t,n){return I(t)?t.get(n):t[n]},set:function(t,n,i){if(I(n)){if("function"==typeof n.set)return n.set(i,t);throw Error("object is readonly")}var r=x(n);return r[i]=t,r}},debugMode:!1};function I(t){return t&&"function"==typeof t.get}function M(t,n){return Object.is(t,n)||F.equals(t,n)}var V=function(){function t(t){this.error=t}return t.prototype.equals=function(n){return this===n||n instanceof t&&M(this.error,n.error)},t}(),q=function(){function t(t){this.value=t}return t.wrap=function(n){return n instanceof t?n:new t(n)},t.unwrap=function(n){return n instanceof t?n.value:n},t.map=function(n,i){return n instanceof t?t.wrap(i(n.value)):i(n)},t.prototype.equals=function(n){return this===n||n instanceof t&&M(this.value,n.value)},t}();function z(t,n){var i=n.creationStack;return i?Object.defineProperty(x(t),"stack",{value:t.stack+"\n"+i}):t}function B(t,n){if(t instanceof q){var i=B(t.value,n);if(i!==t.value)return q.wrap(i)}return n.creationStack&&t instanceof V?new V(z(t.error,n)):t}function G(t){if(F.debugMode){var n=Error().stack;return t.constructor.name+" created:\n"+(n&&n.substr(n.indexOf("\n")+1))}}var N,P,U,L,$=0;function H(){return $++}function J(t){for(var n=N;n;){if(n.l===t)throw z(Error("cyclic dependency between derivables detected"),t);n=n.O}N={l:t,m:0,O:N,t:{}}}function K(){var t=N;if(!t)throw Error("No active recording!");N=t.O;for(var n=t.m,i=t.l,r=t.t,e=i[s],u=i[c],o=n,f=e.length;o<f;o++)nt(e[o],i);e.length=n;for(var h=0,a=e;h<a.length;h++){var v=a[h];u[v.id]=v.version}Object.values(r).forEach(j)}function Q(){return!!N}function W(){if(!N)return!1;for(var t=N.m,n=N.t,i=N.l[s],r=0;r<t;r++)if(!(i[r].id in n))return!1;return!0}function X(t){var n=N;N=void 0;try{return t()}finally{N=n}}function Y(t){N?N.t[t.id]=t:j(t)}function Z(t,n){if(N&&!t.finalized){n&&(N.t[t.id]=t);var i=N.l,r=i[s];if(r[N.m]===t)N.m++;else{var e=r.indexOf(t);e<0?(tt(t,i),N.m===r.length?r.push(t):(r.push(r[N.m]),r[N.m]=t),N.m++):e>N.m&&(r[e]=r[N.m],r[N.m]=t,N.m++)}}}function tt(t,n){var i=t[d];i.push(n),1!==i.length||t.connected||t[o]()}function nt(t,n){var i=t[d],r=i.indexOf(n);if(r<0)throw Error("Inconsistent state!");i.splice(r,1),0===i.length&&t.connected&&(t[u]?it(t):t[h]())}function it(t){P?P.push(t):(P=[t],setTimeout(function(){var t=P;P=void 0,t.forEach(function(t){return t.connected&&0===t[d].length&&t[h]()})},0))}var rt=function(){function t(){this.id=H(),this.creationStack=G(this),this[U]=[],this[L]=!1,this.connected=!1,this.p=void 0,this.finalized=!1}return t.prototype.autoCache=function(){return this[u]=!0,this},t.prototype.getMaybeFinalState=function(){return this.connected||(this[u]?(this[o](),it(this)):Q()&&this[o]()),this[l]()},t.prototype.getState=function(){return q.unwrap(this.getMaybeFinalState())},t.prototype[(U=d,L=u,o)]=function(){this.finalized||et(this,!0)},t.prototype[h]=function(){et(this,!1)},t.prototype[v]=function(){this.finalized=!0,this.connected&&this[h]()},t}();function et(t,n){t.connected=n,t.p&&X(function(){return t.p.set(n)})}var ut,ot,st=function(t){function n(n){var i=t.call(this)||this;return i.version=0,i.j=B(n,i),i.g()&&i[v](),i}return i(n,t),Object.defineProperty(n.prototype,"settable",{get:function(){return!this.g()},enumerable:!0,configurable:!0}),n.prototype.g=function(){return this.j instanceof q},n.prototype[l]=function(){return Z(this,this.g()),this.j},n.prototype.set=function(t){var n=this.j;if(!M(t,n)){if(this.g())throw z(Error("cannot set a final atom"),this);this.j=B(t,this),g(this,n,this.version++),S(this),this.g()&&Y(this)}},n.prototype[w]=function(t,n){this.j=t,this.version=n,k(this,[])},n}(rt),ct=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.S=a,n.version=0,n}return i(n,t),n.prototype.g=function(){return this.S instanceof q},n.prototype[l]=function(){return this.connected?(Z(this,this.g()),this.S):this.g()?this.S:this.k()},n.prototype.set=function(t){if(!this.acceptNewValue)throw z(Error("DataSource is not settable"),this);this.acceptNewValue(t)},n.prototype.checkForChanges=function(){var t=this;if(this.connected){var n=X(function(){return t.k()}),i=this.S;M(n,i)||(this.S=n,g(this,i,this.version++),S(this))}},n.prototype.k=function(){try{return this.calculateCurrentValue()}catch(t){return new V(z(t,this))}},n.prototype[w]=function(t,n){this.version++,k(this,[])},n.prototype[o]=function(){t.prototype[o].call(this),this.connected&&this.checkForChanges()},n.prototype[h]=function(){t.prototype[h].call(this),this.finalized||(this.S=a)},Object.defineProperty(n.prototype,"settable",{get:function(){return!!this.acceptNewValue},enumerable:!0,configurable:!0}),n}(rt);function ft(t){return t instanceof rt?t.get():t}function ht(t){return t instanceof rt?t.value:t}var at=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n._=!1,n.S=a,n.R=0,n}return i(n,t),Object.defineProperty(n.prototype,"version",{get:function(){return this.A(),this.R},enumerable:!0,configurable:!0}),n.prototype.g=function(){return this.S instanceof q},n.prototype[l]=function(){if(this.connected)return this.A(),Z(this,this.g()),this.S;if(this.g())return this.S;var t=this.T();return t instanceof q&&(this.S=t,g(this,void 0,this.R++),Y(this)),t},n.prototype.A=function(){this.connected&&!this._&&(this.S!==a&&(this._=this.g()||this.C()),this._||this.D())},n.prototype.D=function(){var t=this.T();M(t,this.S)||(this.S=t,g(this,void 0,this.R++),this.g()&&Y(this)),this._=!0},n.prototype[b]=function(t){this._&&(this._=!1,k(this,t))},n.prototype[w]=function(t,n){this.S=a,this.R=n,this[b]([])},n.prototype[h]=function(){t.prototype[h].call(this),this._=!1,this.finalized||(this.S=a)},n}(rt),vt=0,lt=function(t){function n(n,i){var r=t.call(this)||this;return r.F=n,r.I=i,r[ut]=[],r[ot]={},r}return i(n,t),n.prototype.D=function(){J(this);try{t.prototype.D.call(this)}finally{K()}},n.prototype.T=function(){++vt;try{var t=this.I?this.F.apply(this,this.I.map(ft)):this.F();return W()?q.wrap(t):t}catch(t){return t===O?O:new V(z(t,this))}finally{--vt}},n.prototype.C=function(){var t=this;return this[s].every(function(n){return t[c][n.id]===n.version})},n.prototype[(ut=s,ot=c,h)]=function(){for(var n=0,i=this[s];n<i.length;n++)nt(i[n],this);this[s].length=0,t.prototype[h].call(this)},n.prototype[v]=function(){t.prototype[v].call(this),this.F=void 0,this.I=void 0},n}(at),bt=function(t){function n(n,i){var r=n.get,e=n.set,u=t.call(this,r,i)||this;return u.M=e,u}return i(n,t),n.prototype.set=function(t){this.I?this.M.apply(this,[t].concat(this.I.map(ht))):this.M(t)},function(t,n,i,r){var e,u=arguments.length,o=u<3?n:null===r?r=Object.getOwnPropertyDescriptor(n,"set"):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,n,"set",r);else for(var s=t.length-1;s>=0;s--)(e=t[s])&&(o=(u<3?e(o):u>3?e(n,"set",o):e(n,"set"))||o);u>3&&o&&Object.defineProperty(n,"set",o)}([A()],n.prototype,"set",null),n}(lt),dt=function(t){function n(n,i){var r=t.call(this)||this;return r.V=n,r.q=i,r.B=0,r}return i(n,t),n.prototype.D=function(){this.B=this.V.version,t.prototype.D.call(this)},n.prototype.T=function(){var t=this;try{return X(function(){var n=t.V.getMaybeFinalState();return q.map(n,function(n){return t.q(n)})})}catch(t){return new V(z(t,this))}},n.prototype.C=function(){return this.B===this.V.version},n.prototype[o]=function(){t.prototype[o].call(this),this.connected&&tt(this.V,this)},n.prototype[h]=function(){nt(this.V,this),t.prototype[h].call(this)},n.prototype[v]=function(){t.prototype[v].call(this),this.V=void 0,this.q=void 0},n}(at),wt=function(t){function n(n,i,r){var e=t.call(this,n,i)||this;return e.G=r,e}return i(n,t),n.prototype.set=function(t){var n=this;this.V.set(q.map(t,function(t){return n.G(t)}))},Object.defineProperty(n.prototype,"settable",{get:function(){return this.V.settable},enumerable:!0,configurable:!0}),n.prototype[v]=function(){t.prototype[v].call(this),this.G=void 0},n}(dt);function yt(t){return t.settable}function Ot(t){return"function"==typeof t?t():ft(t)}function mt(){var t=this.getState();return t===O||t instanceof V?void 0:t}function pt(t){return this.set(t)}function jt(t){return t instanceof rt}var gt=q.wrap(O);function St(t){return new st(t)}function kt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new lt(t,n.length?n:void 0)}function _t(t){return St.final(t)}function Et(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new bt(t,n.length?n:void 0)}function Rt(t){var n=this,i=F.plucker,r=i.get,e=i.set,u=this;return jt(t)?Et({get:function(){return r.call(this,u.get(),t.get())},set:function(n){u.set(e.call(this,n,u.value,t.get()))}}):u.map(function(i){return r.call(n,i,t)},function(i){return e.call(n,i,u.value,t)})}function At(){this.set(O)}function Tt(t){this.set(new V(t))}function Ct(t){this.set(q.wrap(t))}function Dt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.set(t.apply(void 0,[this.value].concat(n.map(ht))))}!function(t){function n(t){return new st(q.wrap(t))}t.unresolved=function(){return new st(O)},t.error=function(t){return new st(new V(t))},t.final=n,function(t){t.unresolved=function(){return new st(gt)},t.error=function(t){return new st(q.wrap(new V(t)))}}(n=t.final||(t.final={}))}(St||(St={})),function(t){t.unresolved=function(){return St.final.unresolved()},t.error=function(t){return St.final.error(t)}}(_t||(_t={}));var xt=new st(q.wrap(!0)),Ft=new st(q.wrap(!1)),It=Symbol("skipped"),Mt=q.wrap(It);function Vt(t,n,i,r){if(void 0!==t){var e=t?xt:Ft;if(!(t===i||t instanceof st&&t.j instanceof q&&t.j.value===i)){if("function"==typeof t){var u=t;t=new lt(function(){return u(n)}).derive(ft)}return t instanceof rt?void 0!==r?t.mapState(function(t){return t===r?q.wrap(t):t}):t:e}}}function qt(t){var n=q.unwrap(t);return n!==O&&!(n instanceof V)}Object.defineProperties(rt.prototype,{get:{value:function(){var t=this.getState();if(t instanceof V)throw t.error;if(t!==O)return t;if(vt>0)throw O;throw z(Error("Could not get value, derivable is unresolved"),this)}},getOr:{value:function(t){var n=this.getState();if(n instanceof V)throw n.error;return n===O?Ot(t):n}},value:{get:mt},resolved:{get:function(){return this.getState()!==O}},settable:{value:!1},final:{get:function(){return this.getMaybeFinalState()instanceof q}},errored:{get:function(){return this.getState()instanceof V}},error:{get:function(){var t=this.getState();return t instanceof V?t.error:void 0}},connected$:{get:function(){return this.p||(this.p=new st(this.connected))}},derive:{value:function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new lt(t,[this].concat(n))}},map:{value:function(t,n){var i=function(n){return n===O||n instanceof V?n:t.call(this,n)};return n&&yt(this)?new wt(this,i,function(t){return t===O||t instanceof V?t:n.call(this,t,this.V.value)}):new dt(this,i)}},mapState:{value:function(t,n){return n&&yt(this)?new wt(this,t,function(t){return n.call(this,t,this.V.getState())}):new dt(this,t)}},pluck:{value:function(t){var n=this,i=F.plucker.get;return jt(t)?this.derive(i,t):this.map(function(r){return i.call(n,r,t)})}},fallbackTo:{value:function(t){var n=this;return jt(t)?kt(function(){return n.getOr(t)}):this.mapState(function(n){return n===O?Ot(t):n})}},take:{value:function(t){var n=this,i=t.from,r=t.when,e=t.until,u=t.once,o=t.stopOnError,s=t.skipFirst,c=Vt(i,this,!0,!0),f=Vt(r,this,!0),h=Vt(e,this,!1,!0),a=s?new st(O):void 0;if(!(c||f||h||u||o||a))return this;var v=(h||f)&&new st(O);function l(t){return v&&v.set(t),t}return new lt(function(){if(c&&!c.get())return O;if(h&&h.get())return l(q.wrap(v.j));if(f&&!f.value)return v.j;var t=n.getMaybeFinalState();if(a&&!Mt.equals(a.j)){if(!qt(t))return l(t);if(a.j===O||M(t,a.j))return a.set(t),l(O);a.set(Mt)}return l(u&&qt(t)||o&&t instanceof V?q.wrap(t):t)})}},and:{value:function(t){return jt(t)?this.derive(function(n){return n&&t.get()}):this.map(function(n){return n&&t})}},or:{value:function(t){return jt(t)?this.derive(function(n){return n||t.get()}):this.map(function(n){return n||t})}},not:{value:function(){return this.map(function(t){return!t})}},is:{value:function(t){return jt(t)?this.derive(M,t):this.map(function(n){return M(n,t)})}}}),[st,ct,wt,bt].forEach(function(t){return Object.defineProperties(t.prototype,{value:{get:mt,set:pt},swap:{value:Dt},pluck:{value:Rt}})}),[st,wt].forEach(function(t){return Object.defineProperties(t.prototype,{unset:{value:At},setError:{value:Tt},setFinal:{value:Ct}})}),Object.defineProperties(bt.prototype,{settable:{value:!0}}),rt.prototype.react=function(t,n){var i=this;return X(function(){return Bt.create(i,t,n)})},rt.prototype.toPromise=function(t){var n=this;return new Promise(function(i,r){return n.react(i,e({},t,{once:!0,onError:function(t,n){n(),r(t)}}))})};var zt,Bt=function(){function t(t,n,i,r){this.N=t,this.P=n,this.U=i,this.ended=r,this.L=!1,this.id=H(),this.$=0,this.creationStack=G(this),this.H=a}return t.prototype.J=function(){tt(this.N,this),this.L=!0,this.u()},t.prototype.u=function(){var t=this;if(this.L){var n=function(n){return function(){n===O||M(t.H,n)||(t.H=n,n instanceof V?t.P(n.error):t.K(n))}},i=this.N[l]();i instanceof q?this.W(n(i.value)):n(i)()}},t.prototype.K=function(t){var n=this;this.$++;try{if(this.$>100)throw Error("Too deeply nested synchronous cyclical reactions disallowed. Use setImmediate.");this.U(t,function(){return n.W()})}catch(t){this.P(z(t,this))}finally{this.$--}},t.prototype.W=function(t){this.L&&(this.L=!1,nt(this.N,this),t&&t(),this.ended&&this.ended())},t.prototype[b]=function(t){t.indexOf(this)<0&&t.push(this)},t.create=function(n,i,r,e){var u=new t(r?n.take(r):n,function(t){if(!r||!r.onError)throw o(),t;r.onError(t,o)},i,e);function o(){u.W()}return u.J(),o},t}(),Gt=Object.freeze({symbols:m,Atom:st,BaseDerivable:rt,BaseDerivation:at,Derivation:lt,Lens:bt,resolveFallback:Ot,safeUnwrap:ht,Reactor:Bt,isRecordingObservations:Q,addObserver:tt,allDependenciesAreFinal:W,independentTracking:X,markFinal:Y,maybeDisconnectInNextTick:it,recordObservation:Z,removeObserver:nt,startRecordingObservations:J,stopRecordingObservations:K,processChangedState:S,augmentStack:z}),Nt={clone:x,equals:M,isPlainObject:function(t){if("object"!=typeof t||null==t)return!1;var n=Object.getPrototypeOf(t);return n===Object.prototype||null===n||t.constructor===Object},resolveFallback:Ot};(zt="undefined"!=typeof window?window:global)[y]?(zt[y]++,console.warn(zt[y]+" instances of Sherlock detected. This could cause unexpected results.")):zt[y]=1,t.ErrorWrapper=V,t.FinalWrapper=q,t.PullDataSource=ct,t._internal=Gt,t.atom=St,t.atomic=A,t.atomically=R,t.config=F,t.constant=_t,t.derive=kt,t.inTransaction=p,t.isDerivable=jt,t.isDerivableAtom=function t(n){return n instanceof st&&n.settable||n instanceof wt&&t(n.V)},t.isSettableDerivable=function(t){return jt(t)&&t.settable},t.lens=Et,t.safeUnwrap=ht,t.transact=E,t.transaction=function t(n){return n?function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var r=this;return E(function(){return n.apply(r,t)})}:function(n,i,r){r.value=r.value&&t(r.value)}},t.unresolved=O,t.unwrap=ft,t.utils=Nt,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).Sherlock={})}(this,(function(t){"use strict";var n=function(t,i){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)n.hasOwnProperty(i)&&(t[i]=n[i])})(t,i)};function i(t,i){function r(){this.constructor=t}n(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var n,i=1,r=arguments.length;i<r;i++)for(var e in n=arguments[i])Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e]);return t}).apply(this,arguments)};function e(){for(var t=0,n=0,i=arguments.length;n<i;n++)t+=arguments[n].length;var r=Array(t),e=0;for(n=0;n<i;n++)for(var o=arguments[n],u=0,s=o.length;u<s;u++,e++)r[e]=o[u];return r}var o,u=Symbol("autoCacheMode"),s=Symbol("connect"),c=Symbol("dependencies"),f=Symbol("dependencyVersions"),h=Symbol("derivableAtom"),a=Symbol("disconnect"),v=Symbol("emptyCache"),l=Symbol("finalize"),b=Symbol("internalGetState"),d=Symbol("mark"),w=Symbol("observers"),y=Symbol("rollback"),O=Symbol("sherlockInstances"),p=Symbol("unresolved"),m=Object.freeze({autoCacheMode:u,connect:s,dependencies:c,dependencyVersions:f,derivableAtom:h,disconnect:a,emptyCache:v,finalize:l,internalGetState:b,mark:d,observers:w,rollback:y,sherlockInstances:O,unresolved:p});function j(){return!!o}function g(t){o?o.t[t.id]=t:t[l]()}function S(t,n,i){o&&C(o,t,n,i)}function k(t){if(o)_(t,o.i);else{var n=[];_(t,n),E(n)}}function _(t,n){for(var i=0,r=t[w];i<r.length;i++)r[i][d](n)}function E(t){for(var n=0,i=t;n<i.length;n++)i[n].o()}function R(t){var n;o={u:[],s:{},h:{},t:{},i:[],v:o};try{n=t()}catch(t){throw function(){var t=o;if(!t)throw Error();o=t.v,t.u.forEach((function(n){return n[y](t.s[n.id],t.h[n.id])}))}(),t}return function(){var t,n=o;if(!n)throw Error();(o=n.v)?(n.u.forEach((function(t){return C(o,t,n.s[t.id],n.h[t.id])})),(t=o.i).push.apply(t,n.i),Object.assign(o.t,n.t)):(Object.values(n.t).forEach((function(t){return t[l]()})),E(n.i))}(),n}function A(t){return j()?t():R(t)}function T(t){return t?function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=this;return A((function(){return t.apply(r,n)}))}:function(t,n,i){i.value=i.value&&T(i.value)}}function C(t,n,i,r){var e=n.id;e in t.s||(t.u.push(n),t.s[e]=i,t.h[e]=r)}var D=Object.getOwnPropertyDescriptors||function(t){for(var n={},i=0,r=x(t);i<r.length;i++){var e=r[i];n[e]=Object.getOwnPropertyDescriptor(t,e)}return n},x="undefined"!=typeof Reflect?Reflect.ownKeys:function(t){return e(Object.getOwnPropertyNames(t),Object.getOwnPropertySymbols(t))};function F(t){return Array.isArray(t)?function(t){try{return Object.defineProperties(new t.constructor,D(t))}catch(t){throw Object.assign(Error("could not clone Array: "+(t&&t.message)),{jse_cause:t})}}(t):Object.create(Object.getPrototypeOf(t),D(t))}var I={equals:function(t,n){return(i=t)&&"function"==typeof i.equals&&!!t.equals(n);var i},plucker:{get:function(t,n){return M(t)?t.get(n):t[n]},set:function(t,n,i){if(M(n)){if("function"==typeof n.set)return n.set(i,t);throw Error("object is readonly")}var r=F(n);return r[i]=t,r}},debugMode:!1};function M(t){return t&&"function"==typeof t.get}function V(t,n){return Object.is(t,n)||I.equals(t,n)}var q=function(){function t(t){this.error=t}return t.prototype.equals=function(n){return this===n||n instanceof t&&V(this.error,n.error)},t}(),z=function(){function t(t){this.value=t}return t.wrap=function(n){return n instanceof t?n:new t(n)},t.unwrap=function(n){return n instanceof t?n.value:n},t.map=function(n,i){return n instanceof t?t.wrap(i(n.value)):i(n)},t.prototype.equals=function(n){return this===n||n instanceof t&&V(this.value,n.value)},t}();function B(t,n){var i=n.creationStack;return i?Object.defineProperty(F(t),"stack",{value:t.stack+"\n"+i}):t}function G(t,n){if(t instanceof z){var i=G(t.value,n);if(i!==t.value)return z.wrap(i)}return n.creationStack&&t instanceof q?new q(B(t.error,n)):t}function N(t){if(I.debugMode){var n=Error().stack;return t.constructor.name+" created:\n"+(n&&n.substr(n.indexOf("\n")+1))}}var P,U,L,$,H=0;function J(){return H++}function K(t){for(var n=P;n;){if(n.l===t)throw B(Error("cyclic dependency between derivables detected"),t);n=n.O}P={l:t,p:0,O:P,t:{}}}function Q(){var t=P;if(!t)throw Error("No active recording!");P=t.O;for(var n=t.p,i=t.l,r=t.t,e=i[c],o=i[f],u=n,s=e.length;u<s;u++)it(e[u],i);e.length=n;for(var h=0,a=e;h<a.length;h++){var v=a[h];o[v.id]=v.version}Object.values(r).forEach(g)}function W(){return!!P}function X(){if(!P)return!1;for(var t=P.p,n=P.t,i=P.l[c],r=0;r<t;r++)if(!(i[r].id in n))return!1;return!0}function Y(t){var n=P;P=void 0;try{return t()}finally{P=n}}function Z(t){P?P.t[t.id]=t:g(t)}function tt(t,n){if(P&&!t.finalized){n&&(P.t[t.id]=t);var i=P.l,r=i[c];if(r[P.p]===t)P.p++;else{var e=r.indexOf(t);e<0?(nt(t,i),P.p===r.length?r.push(t):(r.push(r[P.p]),r[P.p]=t),P.p++):e>P.p&&(r[e]=r[P.p],r[P.p]=t,P.p++)}}}function nt(t,n){var i=t[w];i.push(n),1!==i.length||t.connected||t[s]()}function it(t,n){var i=t[w],r=i.indexOf(n);if(r<0)throw Error("Inconsistent state!");i.splice(r,1),0===i.length&&t.connected&&(t[u]?rt(t):t[a]())}function rt(t){U?U.push(t):(U=[t],setTimeout((function(){var t=U;U=void 0,t.forEach((function(t){return t.connected&&0===t[w].length&&t[a]()}))}),0))}var et=function(){function t(){this.id=J(),this.creationStack=N(this),this[L]=[],this[$]=!1,this.connected=!1,this.m=void 0,this.finalized=!1}return t.prototype.autoCache=function(){return this[u]=!0,this},t.prototype.getMaybeFinalState=function(){return this.connected||(this[u]?(this[s](),rt(this)):W()&&this[s]()),this[b]()},t.prototype.getState=function(){return z.unwrap(this.getMaybeFinalState())},t.prototype[(L=w,$=u,s)]=function(){this.finalized||ot(this,!0)},t.prototype[a]=function(){ot(this,!1)},t.prototype[l]=function(){this.finalized=!0,this.connected&&this[a]()},t}();function ot(t,n){t.connected=n,t.m&&Y((function(){return t.m.set(n)}))}var ut,st,ct=function(t){function n(n){var i=t.call(this)||this;return i.version=0,i.j=G(n,i),i.g()&&i[l](),i}return i(n,t),Object.defineProperty(n.prototype,"settable",{get:function(){return!this.g()},enumerable:!0,configurable:!0}),n.prototype.g=function(){return this.j instanceof z},n.prototype[b]=function(){return tt(this,this.g()),this.j},n.prototype.set=function(t){var n=this.j;if(!V(t,n)){if(this.g())throw B(Error("cannot set a final derivable"),this);this.j=G(t,this),S(this,n,this.version++),k(this),this.g()&&Z(this)}},n.prototype[y]=function(t,n){this.j=t,this.version=n,_(this,[])},n}(et),ft=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n.S=v,n.version=0,n}return i(n,t),n.prototype.g=function(){return this.S instanceof z},n.prototype[b]=function(){return this.connected?(tt(this,this.g()),this.S):this.g()?this.S:this.k()},n.prototype.set=function(t){if(!this.acceptNewValue)throw B(Error("DataSource is not settable"),this);this.acceptNewValue(t)},n.prototype.checkForChanges=function(){var t=this;if(this.connected){var n=Y((function(){return t.k()})),i=this.S;V(n,i)||(this.S=n,S(this,i,this.version++),k(this))}},n.prototype.k=function(){try{return this.calculateCurrentValue()}catch(t){return new q(B(t,this))}},n.prototype[y]=function(t,n){this.version++,_(this,[])},n.prototype[s]=function(){t.prototype[s].call(this),this.connected&&this.checkForChanges()},n.prototype[a]=function(){t.prototype[a].call(this),this.finalized||(this.S=v)},Object.defineProperty(n.prototype,"settable",{get:function(){return!!this.acceptNewValue},enumerable:!0,configurable:!0}),n}(et);function ht(t){return t instanceof et?t.get():t}function at(t){return t instanceof et?t.value:t}var vt=function(t){function n(){var n=null!==t&&t.apply(this,arguments)||this;return n._=!1,n.S=v,n.R=0,n}return i(n,t),Object.defineProperty(n.prototype,"version",{get:function(){return this.A(),this.R},enumerable:!0,configurable:!0}),n.prototype.g=function(){return this.S instanceof z},n.prototype[b]=function(){if(this.connected)return this.A(),tt(this,this.g()),this.S;if(this.g())return this.S;var t=this.T();return t instanceof z&&(this.S=t,S(this,void 0,this.R++),Z(this)),t},n.prototype.A=function(){this.connected&&!this._&&(this.S!==v&&(this._=this.g()||this.C()),this._||this.D())},n.prototype.D=function(){var t=this.T();V(t,this.S)||(this.S=t,S(this,void 0,this.R++),this.g()&&Z(this)),this._=!0},n.prototype[d]=function(t){this._&&(this._=!1,_(this,t))},n.prototype[y]=function(t,n){this.S=v,this.R=n,this[d]([])},n.prototype[a]=function(){t.prototype[a].call(this),this._=!1,this.finalized||(this.S=v)},n}(et),lt=0,bt=function(t){function n(n,i){var r=t.call(this)||this;return r.F=n,r.I=i,r[ut]=[],r[st]={},r}return i(n,t),n.prototype.D=function(){K(this);try{t.prototype.D.call(this)}finally{Q()}},n.prototype.T=function(){++lt;try{var t=this.I?this.F.apply(this,this.I.map(ht)):this.F();return X()?z.wrap(t):t}catch(t){return t===p?p:new q(B(t,this))}finally{--lt}},n.prototype.C=function(){var t=this;return this[c].every((function(n){return t[f][n.id]===n.version}))},n.prototype[(ut=c,st=f,a)]=function(){for(var n=0,i=this[c];n<i.length;n++)it(i[n],this);this[c].length=0,t.prototype[a].call(this)},n.prototype[l]=function(){t.prototype[l].call(this),this.F=void 0,this.I=void 0},n}(vt),dt=function(t){function n(n,i){var r=n.get,e=n.set,o=t.call(this,r,i)||this;return o.M=e,o}return i(n,t),n.prototype.set=function(t){if(this.finalized)throw B(Error("cannot set a final derivable"),this);this.I?this.M.apply(this,e([t],this.I.map(at))):this.M(t)},function(t,n,i,r){var e,o=arguments.length,u=o<3?n:null===r?r=Object.getOwnPropertyDescriptor(n,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,n,i,r);else for(var s=t.length-1;s>=0;s--)(e=t[s])&&(u=(o<3?e(u):o>3?e(n,i,u):e(n,i))||u);o>3&&u&&Object.defineProperty(n,i,u)}([T()],n.prototype,"set",null),n}(bt),wt=function(t){function n(n,i){var r=t.call(this)||this;return r.V=n,r.q=i,r.B=0,r}return i(n,t),n.prototype.D=function(){this.B=this.V.version,t.prototype.D.call(this)},n.prototype.T=function(){var t=this;try{return Y((function(){var n=t.V.getMaybeFinalState();return z.map(n,(function(n){return t.q(n)}))}))}catch(t){return new q(B(t,this))}},n.prototype.C=function(){return this.B===this.V.version},n.prototype[s]=function(){t.prototype[s].call(this),this.connected&&nt(this.V,this)},n.prototype[a]=function(){it(this.V,this),t.prototype[a].call(this)},n.prototype[l]=function(){t.prototype[l].call(this),this.V=void 0,this.q=void 0},n}(vt),yt=function(t){function n(n,i,r){var e=t.call(this,n,i)||this;return e.G=r,e}return i(n,t),n.prototype.set=function(t){var n=this;if(this.finalized)throw B(Error("cannot set a final derivable"),this);this.V.set(z.map(t,(function(t){return n.G(t)})))},Object.defineProperty(n.prototype,"settable",{get:function(){return this.V.settable},enumerable:!0,configurable:!0}),n.prototype[l]=function(){t.prototype[l].call(this),this.G=void 0},n}(wt);function Ot(t){return t.settable}function pt(t){return"function"==typeof t?t():ht(t)}function mt(){var t=this.getState();return t===p||t instanceof q?void 0:t}function jt(t){return this.set(t)}function gt(t){return t instanceof et}var St=z.wrap(p);function kt(t){return new ct(t)}function _t(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new bt(t,n.length?n:void 0)}function Et(t){return kt.final(t)}function Rt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new dt(t,n.length?n:void 0)}function At(t){var n=this,i=I.plucker,r=i.get,e=i.set,o=this;return gt(t)?Rt({get:function(){return r.call(this,o.get(),t.get())},set:function(n){o.set(e.call(this,n,o.value,t.get()))}}):o.map((function(i){return r.call(n,i,t)}),(function(i){return e.call(n,i,o.value,t)}))}function Tt(){this.set(p)}function Ct(t){this.set(new q(t))}function Dt(t){this.set(z.wrap(t))}function xt(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.set(t.apply(void 0,e([this.value],n.map(at))))}!function(t){function n(t){return new ct(z.wrap(t))}t.unresolved=function(){return new ct(p)},t.error=function(t){return new ct(new q(t))},t.final=n,function(t){t.unresolved=function(){return new ct(St)},t.error=function(t){return new ct(z.wrap(new q(t)))}}(n=t.final||(t.final={}))}(kt||(kt={})),function(t){t.unresolved=function(){return kt.final.unresolved()},t.error=function(t){return kt.final.error(t)}}(Et||(Et={}));var Ft=new ct(z.wrap(!0)),It=new ct(z.wrap(!1)),Mt=Symbol("skipped"),Vt=z.wrap(Mt);function qt(t,n,i,r){if(void 0!==t){var e=t?Ft:It;if(!(t===i||t instanceof ct&&t.j instanceof z&&t.j.value===i)){if("function"==typeof t){var o=t;t=new bt((function(){return o(n)})).derive(ht)}return t instanceof et?void 0!==r?t.mapState((function(t){return t===r?z.wrap(t):t})):t:e}}}function zt(t){var n=z.unwrap(t);return n!==p&&!(n instanceof q)}Object.defineProperties(et.prototype,{get:{value:function(){var t=this.getState();if(t instanceof q)throw t.error;if(t!==p)return t;if(lt>0)throw p;throw B(Error("Could not get value, derivable is unresolved"),this)}},getOr:{value:function(t){var n=this.getState();if(n instanceof q)throw n.error;return n===p?pt(t):n}},value:{get:mt},resolved:{get:function(){return this.getState()!==p}},settable:{value:!1},final:{get:function(){return this.getMaybeFinalState()instanceof z}},errored:{get:function(){return this.getState()instanceof q}},error:{get:function(){var t=this.getState();return t instanceof q?t.error:void 0}},connected$:{get:function(){return this.m||(this.m=new ct(this.connected))}},derive:{value:function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];return new bt(t,e([this],n))}},map:{value:function(t,n){var i=function(n){return n===p||n instanceof q?n:t.call(this,n)};return n&&Ot(this)?new yt(this,i,(function(t){return t===p||t instanceof q?t:n.call(this,t,this.V.value)})):new wt(this,i)}},mapState:{value:function(t,n){return n&&Ot(this)?new yt(this,t,(function(t){return n.call(this,t,this.V.getState())})):new wt(this,t)}},pluck:{value:function(t){var n=this,i=I.plucker.get;return gt(t)?this.derive(i,t):this.map((function(r){return i.call(n,r,t)}))}},fallbackTo:{value:function(t){var n=this;return gt(t)?_t((function(){return n.getOr(t)})):this.mapState((function(n){return n===p?pt(t):n}))}},take:{value:function(t){var n=this,i=t.from,r=t.when,e=t.until,o=t.once,u=t.stopOnError,s=t.skipFirst,c=qt(i,this,!0,!0),f=qt(r,this,!0),h=qt(e,this,!1,!0),a=s?new ct(p):void 0;if(!(c||f||h||o||u||a))return this;var v=(h||f)&&new ct(p);function l(t){return v&&v.set(t),t}return new bt((function(){if(c&&!c.get())return p;if(h&&h.get())return l(z.wrap(v.j));if(f&&!f.value)return v.j;var t=n.getMaybeFinalState();if(a&&!Vt.equals(a.j)){if(!zt(t))return l(t);if(a.j===p||V(t,a.j))return a.set(t),l(p);a.set(Vt)}return l(o&&zt(t)||u&&t instanceof q?z.wrap(t):t)}))}},and:{value:function(t){return gt(t)?this.derive((function(n){return n&&t.get()})):this.map((function(n){return n&&t}))}},or:{value:function(t){return gt(t)?this.derive((function(n){return n||t.get()})):this.map((function(n){return n||t}))}},not:{value:function(){return this.map((function(t){return!t}))}},is:{value:function(t){return gt(t)?this.derive(V,t):this.map((function(n){return V(n,t)}))}}}),[ct,ft,yt,dt].forEach((function(t){return Object.defineProperties(t.prototype,{value:{get:mt,set:jt},swap:{value:xt},pluck:{value:At}})})),[ct,yt].forEach((function(t){return Object.defineProperties(t.prototype,{unset:{value:Tt},setError:{value:Ct},setFinal:{value:Dt}})})),Object.defineProperties(dt.prototype,{settable:{value:!0}}),et.prototype.react=function(t,n){var i=this;return Y((function(){return Gt.create(i,t,n)}))},et.prototype.toPromise=function(t){var n=this;return new Promise((function(i,e){return n.react(i,r(r({},t),{once:!0,onError:function(t,n){n(),e(t)}}))}))};var Bt,Gt=function(){function t(t,n,i,r){this.N=t,this.P=n,this.U=i,this.ended=r,this.L=!1,this.id=J(),this.$=0,this.creationStack=N(this),this.H=v}return t.prototype.J=function(){nt(this.N,this),this.L=!0,this.o()},t.prototype.o=function(){var t=this;if(this.L){var n=function(n){return function(){n===p||V(t.H,n)||(t.H=n,n instanceof q?t.P(n.error):t.K(n))}},i=this.N[b]();i instanceof z?this.W(n(i.value)):n(i)()}},t.prototype.K=function(t){var n=this;this.$++;try{if(this.$>100)throw Error("Too deeply nested synchronous cyclical reactions disallowed. Use setImmediate.");this.U(t,(function(){return n.W()}))}catch(t){this.P(B(t,this))}finally{this.$--}},t.prototype.W=function(t){this.L&&(this.L=!1,it(this.N,this),t&&t(),this.ended&&this.ended())},t.prototype[d]=function(t){t.indexOf(this)<0&&t.push(this)},t.create=function(n,i,r,e){var o=new t(r?n.take(r):n,(function(t){if(!r||!r.onError)throw u(),t;r.onError(t,u)}),i,e);function u(){o.W()}return o.J(),u},t}(),Nt=Object.freeze({symbols:m,Atom:ct,BaseDerivable:et,BaseDerivation:vt,Derivation:bt,Lens:dt,resolveFallback:pt,safeUnwrap:at,Reactor:Gt,isRecordingObservations:W,addObserver:nt,allDependenciesAreFinal:X,independentTracking:Y,markFinal:Z,maybeDisconnectInNextTick:rt,recordObservation:tt,removeObserver:it,startRecordingObservations:K,stopRecordingObservations:Q,processChangedState:k,augmentStack:B}),Pt={clone:F,equals:V,isPlainObject:function(t){if("object"!=typeof t||null==t)return!1;var n=Object.getPrototypeOf(t);return n===Object.prototype||null===n||t.constructor===Object},resolveFallback:pt};(Bt="undefined"!=typeof window?window:global)[O]?(Bt[O]++,console.warn(Bt[O]+" instances of Sherlock detected. This could cause unexpected results.")):Bt[O]=1,t.ErrorWrapper=q,t.FinalWrapper=z,t.PullDataSource=ft,t._internal=Nt,t.atom=kt,t.atomic=T,t.atomically=A,t.config=I,t.constant=Et,t.derive=_t,t.inTransaction=j,t.isDerivable=gt,t.isDerivableAtom=function t(n){return n instanceof ct&&n.settable||n instanceof yt&&t(n.V)},t.isSettableDerivable=function(t){return gt(t)&&t.settable},t.lens=Rt,t.safeUnwrap=at,t.transact=R,t.transaction=function t(n){return n?function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];var r=this;return R((function(){return n.apply(r,t)}))}:function(n,i,r){r.value=r.value&&t(r.value)}},t.unresolved=p,t.unwrap=ht,t.utils=Pt,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=sherlock.umd.min.js.map

@@ -8,3 +8,3 @@ export declare const getOwnPropertyDescriptors: {

declare global {
interface ObjectConstructor {
export interface ObjectConstructor {
getOwnPropertyDescriptors(obj: any): PropertyDescriptorMap;

@@ -11,0 +11,0 @@ }

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc