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 to 3.0.1

2

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

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

@@ -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 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;
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(!function(t,n){return t===n||t instanceof et&&t.j instanceof I&&t.j.value===n}(t,i)){if("function"==typeof t){var o=t;t=new ht((function(){return o(n)})).derive(ut)}return yt(t)?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.getOr(!1))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{__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};
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(!function(t,n){return t===n||t instanceof ct&&t.g instanceof z&&t.g.value===n}(t,i)){if("function"==typeof t){var u=t;t=new bt((function(){return u(n)})).derive(ht)}return jt(t)?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.getOr(!1))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=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})}));
!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(!function(t,n){return t===n||t instanceof ct&&t.j instanceof z&&t.j.value===n}(t,i)){if("function"==typeof t){var o=t;t=new bt((function(){return o(n)})).derive(ht)}return gt(t)?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.getOr(!1))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

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