Socket
Socket
Sign inDemoInstall

jotai

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jotai - npm Package Compare versions

Comparing version 2.8.1 to 2.8.2

55

experimental.js

@@ -30,29 +30,20 @@ 'use strict';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -62,2 +53,9 @@ }

}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -222,2 +220,3 @@ var isSelfAtom = function isSelfAtom(atom, a) {

pendingPromise[CONTINUE_PROMISE](valueOrPromise, abortPromise);
++atomState.n;
}

@@ -393,4 +392,3 @@ } else {

var aState = getAtomState(a);
var hasPrevValue = ('v' in aState);
var prevValue = aState.v;
var prevEpochNumber = aState.n;
var hasChangedDeps = false;

@@ -407,3 +405,3 @@ for (var _iterator4 = _createForOfIteratorHelperLoose(aState.d.keys()), _step4; !(_step4 = _iterator4()).done;) {

mountDependencies(pending, a, aState);
if (!hasPrevValue || !Object.is(prevValue, aState.v)) {
if (prevEpochNumber !== aState.n) {
addPendingAtom(pending, a, aState);

@@ -556,5 +554,2 @@ changedAtoms.add(a);

},
dev4_override_method: function dev4_override_method(key, fn) {
store[key] = fn;
},
dev4_restore_atoms: function dev4_restore_atoms(values) {

@@ -561,0 +556,0 @@ var pending = createPending();

@@ -6,3 +6,3 @@ {

"type": "commonjs",
"version": "2.8.1",
"version": "2.8.2",
"main": "./index.js",

@@ -86,6 +86,2 @@ "types": "./index.d.ts",

"packageManager": "pnpm@8.15.0",
"resolutions": {
"@types/react": "18.2.56",
"@typescript-eslint/utils": "7.2.0"
},
"peerDependencies": {

@@ -92,0 +88,0 @@ "@types/react": ">=17.0.0",

@@ -44,29 +44,20 @@ 'use client';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -76,2 +67,9 @@ }

}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -78,0 +76,0 @@ var hydratedMap = new WeakMap();

@@ -167,2 +167,3 @@ System.register([], (function (exports) {

pendingPromise[CONTINUE_PROMISE](valueOrPromise, abortPromise);
++atomState.n;
}

@@ -344,4 +345,3 @@ } else {

const aState = getAtomState(a);
const hasPrevValue = "v" in aState;
const prevValue = aState.v;
const prevEpochNumber = aState.n;
let hasChangedDeps = false;

@@ -357,3 +357,3 @@ for (const dep of aState.d.keys()) {

mountDependencies(pending, a, aState);
if (!hasPrevValue || !Object.is(prevValue, aState.v)) {
if (prevEpochNumber !== aState.n) {
addPendingAtom(pending, a, aState);

@@ -486,5 +486,2 @@ changedAtoms.add(a);

dev4_get_internal_weak_map: () => atomStateMap,
dev4_override_method: (key, fn) => {
store[key] = fn;
},
dev4_restore_atoms: (values) => {

@@ -491,0 +488,0 @@ const pending = createPending();

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

System.register([],function(W){"use strict";return{execute:function(){W("atom",N);let L=0;function N(t,s){const a=`atom${++L}`,m={toString:()=>a};return typeof t=="function"?m.read=t:(m.init=t,m.read=R,m.write=T),s&&(m.write=s),m}function R(t){return t(this)}function T(t,s,a){return s(this,typeof a=="function"?a(t(this)):a)}const q=(t,s)=>t.unstable_is?t.unstable_is(s):s===t,B=t=>"init"in t,F=t=>!!t.write,A=Symbol(""),_="pending",U="fulfilled",$="rejected",x=t=>typeof t=="object"&&t!==null&&A in t,O=new WeakMap,Q=(t,s,a)=>{if(!O.has(t)){let m;const w=new Promise((E,V)=>{let g=t;const j=v=>p=>{g===v&&(w.status=U,w.value=p,E(p),a())},b=v=>p=>{g===v&&(w.status=$,w.reason=p,V(p),a())};t.then(j(t),b(t)),m=(v,p)=>{v&&(O.set(v,w),g=v,v.then(j(v),b(v))),s(),s=p}});w.status=_,w[A]=m,O.set(t,w)}return O.get(t)},X=t=>typeof(t==null?void 0:t.then)=="function",G=t=>"v"in t||"e"in t,P=t=>{if("e"in t)throw t.e;return t.v},D=t=>{const s=t.v;return x(s)&&s.status===_?s:null},H=(t,s,a)=>{a.p.has(t)||(a.p.add(t),s.then(()=>{a.p.delete(t)},()=>{a.p.delete(t)}))},M=()=>[new Map,new Map,new Set],I=(t,s,a)=>{t[0].has(s)||t[0].set(s,new Set),t[1].set(s,a)},Y=(t,s,a)=>{const m=t[0].get(s);m&&m.add(a)},Z=(t,s)=>t[0].get(s),J=(t,s)=>{t[2].add(s)},y=t=>{for(;t[1].size||t[2].size;){t[0].clear();const s=new Set(t[1].values());t[1].clear();const a=new Set(t[2]);t[2].clear(),s.forEach(m=>{var w;return(w=m.m)==null?void 0:w.l.forEach(E=>E())}),a.forEach(m=>m())}},tt=W("createStore",()=>{const t=new WeakMap,s=r=>{let e=t.get(r);return e||(e={d:new Map,p:new Set,n:0},t.set(r,e)),e},a=(r,e,n,o=()=>{},u=()=>{})=>{const c="v"in e,d=e.v,h=D(e);if(X(n))if(h)h!==n&&h[A](n,o);else{const i=Q(n,o,u);if(i.status===_)for(const l of e.d.keys()){const f=s(l);H(r,i,f)}e.v=i,delete e.e}else h&&h[A](Promise.resolve(n),o),e.v=n,delete e.e;(!c||!Object.is(d,e.v))&&++e.n},m=(r,e,n,o)=>{var u;const c=s(e);c.d.set(n,o.n);const d=D(c);d&&H(e,d,o),(u=o.m)==null||u.t.add(e),r&&Y(r,n,e)},w=(r,e,n)=>{const o=s(e);if(!(n!=null&&n(e))&&G(o)&&(o.m||Array.from(o.d).every(([l,f])=>w(r,l,n).n===f)))return o;o.d.clear();let u=!0;const c=l=>{if(q(e,l)){const S=s(l);if(!G(S))if(B(l))a(l,S,l.init);else throw new Error("no atom init");return P(S)}const f=w(r,l,n);if(u)m(r,e,l,f);else{const S=M();m(S,e,l,f),b(S,e,o),y(S)}return P(f)};let d,h;const i={get signal(){return d||(d=new AbortController),d.signal},get setSelf(){return!h&&F(e)&&(h=(...l)=>{if(!u)return j(e,...l)}),h}};try{const l=e.read(c,i);return a(e,o,l,()=>d==null?void 0:d.abort(),()=>{if(o.m){const f=M();b(f,e,o),y(f)}}),o}catch(l){return delete o.v,o.e=l,++o.n,o}finally{u=!1}},E=r=>P(w(void 0,r)),V=(r,e)=>{const n=i=>{var l,f;const S=s(i),z=new Set((l=S.m)==null?void 0:l.t);for(const k of S.p)z.add(k);return(f=Z(r,i))==null||f.forEach(k=>{z.add(k)}),z},o=[],u=new Set,c=i=>{if(!u.has(i)){u.add(i);for(const l of n(i))i!==l&&c(l);o.push(i)}};c(e);const d=new Set([e]),h=i=>u.has(i);for(let i=o.length-1;i>=0;--i){const l=o[i],f=s(l),S="v"in f,z=f.v;let k=!1;for(const K of f.d.keys())if(K!==l&&d.has(K)){k=!0;break}k&&(w(r,l,h),b(r,l,f),(!S||!Object.is(z,f.v))&&(I(r,l,f),d.add(l))),u.delete(l)}},g=(r,e,...n)=>{const o=c=>P(w(r,c)),u=(c,...d)=>{let h;if(q(e,c)){if(!B(c))throw new Error("atom not writable");const i=s(c),l="v"in i,f=i.v,S=d[0];a(c,i,S),b(r,c,i),(!l||!Object.is(f,i.v))&&(I(r,c,i),V(r,c))}else h=g(r,c,...d);return y(r),h};return e.write(o,u,...n)},j=(r,...e)=>{const n=M(),o=g(n,r,...e);return y(n),o},b=(r,e,n)=>{if(n.m&&!D(n)){for(const o of n.d.keys())n.m.d.has(o)||(v(r,o).t.add(e),n.m.d.add(o));for(const o of n.m.d||[])if(!n.d.has(o)){const u=p(r,o);u==null||u.t.delete(e),n.m.d.delete(o)}}},v=(r,e)=>{const n=s(e);if(!n.m){w(r,e);for(const o of n.d.keys())v(r,o).t.add(e);if(n.m={l:new Set,d:new Set(n.d.keys()),t:new Set},F(e)&&e.onMount){const o=n.m,{onMount:u}=e;J(r,()=>{const c=u((...d)=>g(r,e,...d));c&&(o.u=c)})}}return n.m},p=(r,e)=>{const n=s(e);if(n.m&&!n.m.l.size&&!Array.from(n.m.t).some(o=>s(o).m)){const o=n.m.u;o&&J(r,o),delete n.m;for(const c of n.d.keys()){const d=p(r,c);d==null||d.t.delete(e)}const u=D(n);u&&u[A](void 0,()=>{});return}return n.m};return{get:E,set:j,sub:(r,e)=>{const n=M(),o=v(n,r);y(n);const u=o.l;return u.add(e),()=>{u.delete(e);const c=M();p(c,r),y(c)}}}});let C;const et=W("getDefaultStore",()=>(C||(C=tt()),C))}}});
System.register([],function(_){"use strict";return{execute:function(){_("atom",P);let N=0;function P(t,s){const d=`atom${++N}`,m={toString:()=>d};return typeof t=="function"?m.read=t:(m.init=t,m.read=R,m.write=T),s&&(m.write=s),m}function R(t){return t(this)}function T(t,s,d){return s(this,typeof d=="function"?d(t(this)):d)}const B=(t,s)=>t.unstable_is?t.unstable_is(s):s===t,F=t=>"init"in t,G=t=>!!t.write,M=Symbol(""),C="pending",U="fulfilled",$="rejected",x=t=>typeof t=="object"&&t!==null&&M in t,D=new WeakMap,K=(t,s,d)=>{if(!D.has(t)){let m;const w=new Promise((j,q)=>{let g=t;const z=v=>p=>{g===v&&(w.status=U,w.value=p,j(p),d())},b=v=>p=>{g===v&&(w.status=$,w.reason=p,q(p),d())};t.then(z(t),b(t)),m=(v,p)=>{v&&(D.set(v,w),g=v,v.then(z(v),b(v))),s(),s=p}});w.status=C,w[M]=m,D.set(t,w)}return D.get(t)},Q=t=>typeof(t==null?void 0:t.then)=="function",H=t=>"v"in t||"e"in t,O=t=>{if("e"in t)throw t.e;return t.v},W=t=>{const s=t.v;return x(s)&&s.status===C?s:null},I=(t,s,d)=>{d.p.has(t)||(d.p.add(t),s.then(()=>{d.p.delete(t)},()=>{d.p.delete(t)}))},E=()=>[new Map,new Map,new Set],J=(t,s,d)=>{t[0].has(s)||t[0].set(s,new Set),t[1].set(s,d)},X=(t,s,d)=>{const m=t[0].get(s);m&&m.add(d)},Y=(t,s)=>t[0].get(s),L=(t,s)=>{t[2].add(s)},y=t=>{for(;t[1].size||t[2].size;){t[0].clear();const s=new Set(t[1].values());t[1].clear();const d=new Set(t[2]);t[2].clear(),s.forEach(m=>{var w;return(w=m.m)==null?void 0:w.l.forEach(j=>j())}),d.forEach(m=>m())}},Z=_("createStore",()=>{const t=new WeakMap,s=r=>{let e=t.get(r);return e||(e={d:new Map,p:new Set,n:0},t.set(r,e)),e},d=(r,e,n,o=()=>{},u=()=>{})=>{const l="v"in e,a=e.v,h=W(e);if(Q(n))if(h)h!==n&&(h[M](n,o),++e.n);else{const i=K(n,o,u);if(i.status===C)for(const c of e.d.keys()){const f=s(c);I(r,i,f)}e.v=i,delete e.e}else h&&h[M](Promise.resolve(n),o),e.v=n,delete e.e;(!l||!Object.is(a,e.v))&&++e.n},m=(r,e,n,o)=>{var u;const l=s(e);l.d.set(n,o.n);const a=W(l);a&&I(e,a,o),(u=o.m)==null||u.t.add(e),r&&X(r,n,e)},w=(r,e,n)=>{const o=s(e);if(!(n!=null&&n(e))&&H(o)&&(o.m||Array.from(o.d).every(([c,f])=>w(r,c,n).n===f)))return o;o.d.clear();let u=!0;const l=c=>{if(B(e,c)){const S=s(c);if(!H(S))if(F(c))d(c,S,c.init);else throw new Error("no atom init");return O(S)}const f=w(r,c,n);if(u)m(r,e,c,f);else{const S=E();m(S,e,c,f),b(S,e,o),y(S)}return O(f)};let a,h;const i={get signal(){return a||(a=new AbortController),a.signal},get setSelf(){return!h&&G(e)&&(h=(...c)=>{if(!u)return z(e,...c)}),h}};try{const c=e.read(l,i);return d(e,o,c,()=>a==null?void 0:a.abort(),()=>{if(o.m){const f=E();b(f,e,o),y(f)}}),o}catch(c){return delete o.v,o.e=c,++o.n,o}finally{u=!1}},j=r=>O(w(void 0,r)),q=(r,e)=>{const n=i=>{var c,f;const S=s(i),k=new Set((c=S.m)==null?void 0:c.t);for(const A of S.p)k.add(A);return(f=Y(r,i))==null||f.forEach(A=>{k.add(A)}),k},o=[],u=new Set,l=i=>{if(!u.has(i)){u.add(i);for(const c of n(i))i!==c&&l(c);o.push(i)}};l(e);const a=new Set([e]),h=i=>u.has(i);for(let i=o.length-1;i>=0;--i){const c=o[i],f=s(c),S=f.n;let k=!1;for(const A of f.d.keys())if(A!==c&&a.has(A)){k=!0;break}k&&(w(r,c,h),b(r,c,f),S!==f.n&&(J(r,c,f),a.add(c))),u.delete(c)}},g=(r,e,...n)=>{const o=l=>O(w(r,l)),u=(l,...a)=>{let h;if(B(e,l)){if(!F(l))throw new Error("atom not writable");const i=s(l),c="v"in i,f=i.v,S=a[0];d(l,i,S),b(r,l,i),(!c||!Object.is(f,i.v))&&(J(r,l,i),q(r,l))}else h=g(r,l,...a);return y(r),h};return e.write(o,u,...n)},z=(r,...e)=>{const n=E(),o=g(n,r,...e);return y(n),o},b=(r,e,n)=>{if(n.m&&!W(n)){for(const o of n.d.keys())n.m.d.has(o)||(v(r,o).t.add(e),n.m.d.add(o));for(const o of n.m.d||[])if(!n.d.has(o)){const u=p(r,o);u==null||u.t.delete(e),n.m.d.delete(o)}}},v=(r,e)=>{const n=s(e);if(!n.m){w(r,e);for(const o of n.d.keys())v(r,o).t.add(e);if(n.m={l:new Set,d:new Set(n.d.keys()),t:new Set},G(e)&&e.onMount){const o=n.m,{onMount:u}=e;L(r,()=>{const l=u((...a)=>g(r,e,...a));l&&(o.u=l)})}}return n.m},p=(r,e)=>{const n=s(e);if(n.m&&!n.m.l.size&&!Array.from(n.m.t).some(o=>s(o).m)){const o=n.m.u;o&&L(r,o),delete n.m;for(const l of n.d.keys()){const a=p(r,l);a==null||a.t.delete(e)}const u=W(n);u&&u[M](void 0,()=>{});return}return n.m};return{get:j,set:z,sub:(r,e)=>{const n=E(),o=v(n,r);y(n);const u=o.l;return u.add(e),()=>{u.delete(e);const l=E();p(l,r),y(l)}}}});let V;const tt=_("getDefaultStore",()=>(V||(V=Z()),V))}}});

@@ -85,6 +85,4 @@ System.register([], (function (exports) {

atomState.d.forEach((_, a) => {
var _a;
if (!pendingMap.has(a)) {
const aState = getAtomState(a);
(_a = pendingStack[pendingStack.length - 1]) == null ? void 0 : _a.add(a);
pendingMap.set(a, [aState, /* @__PURE__ */ new Set()]);

@@ -105,4 +103,4 @@ if (aState) {

atomStateMap.set(atom, atomState);
(_a = pendingStack[pendingStack.length - 1]) == null ? void 0 : _a.add(atom);
if (!pendingMap.has(atom)) {
(_a = pendingStack[pendingStack.length - 1]) == null ? void 0 : _a.add(atom);
pendingMap.set(atom, [prevAtomState, /* @__PURE__ */ new Set()]);

@@ -109,0 +107,0 @@ addPendingDependent(atom, atomState);

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

System.register([],function($){"use strict";return{execute:function(){$("atom",N);let L=0;function N(o,a){const h=`atom${++L}`,g={toString:()=>h};return typeof o=="function"?g.read=o:(g.init=o,g.read=R,g.write=T),a&&(g.write=a),g}function R(o){return o(this)}function T(o,a,h){return a(this,typeof h=="function"?h(o(this)):h)}const M=(o,a)=>o.unstable_is?o.unstable_is(a):a===o,A=o=>"init"in o,O=o=>!!o.write,m=new WeakMap,U=(o,a)=>{m.set(o,a),o.catch(()=>{}).finally(()=>m.delete(o))},_=(o,a)=>{const h=m.get(o);h&&(m.delete(o),h(a))},C=(o,a)=>{o.status="fulfilled",o.value=a},q=(o,a)=>{o.status="rejected",o.reason=a},V=o=>typeof(o==null?void 0:o.then)=="function",E=(o,a)=>!!o&&"v"in o&&"v"in a&&Object.is(o.v,a.v),x=(o,a)=>!!o&&"e"in o&&"e"in a&&Object.is(o.e,a.e),S=o=>!!o&&"v"in o&&o.v instanceof Promise,K=(o,a)=>"v"in o&&"v"in a&&o.v.orig&&o.v.orig===a.v.orig,y=o=>{if("e"in o)throw o.e;return o.v},B=()=>{const o=new WeakMap,a=new WeakMap,h=[],g=new WeakMap,w=t=>o.get(t),k=(t,r)=>{r.d.forEach((c,e)=>{var n;if(!g.has(e)){const i=w(e);(n=h[h.length-1])==null||n.add(e),g.set(e,[i,new Set]),i&&k(e,i)}g.get(e)[1].add(t)})},F=(t,r)=>{var c;const e=w(t);if(o.set(t,r),g.has(t)||((c=h[h.length-1])==null||c.add(t),g.set(t,[e,new Set]),k(t,r)),S(e)){const n="v"in r?r.v instanceof Promise?r.v:Promise.resolve(r.v):Promise.reject(r.e);e.v!==n&&_(e.v,n)}},G=(t,r,c,e)=>{const n=new Map(e?r.d:null);let i=!1;c.forEach((s,l)=>{!s&&M(t,l)&&(s=r),s&&(n.set(l,s),r.d.get(l)!==s&&(i=!0))}),(i||r.d.size!==n.size)&&(r.d=n)},z=(t,r,c,e)=>{const n=w(t),i={d:(n==null?void 0:n.d)||new Map,v:r};if(c&&G(t,i,c,e),E(n,i)&&n.d===i.d)return n;if(S(n)&&S(i)&&K(n,i)){if(n.d===i.d)return n;i.v=n.v}return F(t,i),i},H=(t,r,c,e)=>{if(V(r)){let n;const i=()=>{const l=w(t);if(!S(l)||l.v!==s)return;const f=z(t,s,c);a.has(t)&&l.d!==f.d&&J(t,f,l.d)},s=new Promise((l,f)=>{let u=!1;r.then(d=>{u||(u=!0,C(s,d),l(d),i())},d=>{u||(u=!0,q(s,d),f(d),i())}),n=d=>{u||(u=!0,d.then(v=>C(s,v),v=>q(s,v)),l(d))}});return s.orig=r,s.status="pending",U(s,l=>{l&&n(l),e==null||e()}),z(t,s,c,!0)}return z(t,r,c)},Q=(t,r,c)=>{const e=w(t),n={d:(e==null?void 0:e.d)||new Map,e:r};return c&&G(t,n,c),x(e,n)&&e.d===n.d?e:(F(t,n),n)},p=(t,r)=>{const c=w(t);if(!(r!=null&&r(t))&&c&&(a.has(t)||Array.from(c.d).every(([u,d])=>{if(u===t)return!0;const v=p(u,r);return v===d||E(v,d)})))return c;const e=new Map;let n=!0;const i=u=>{if(M(t,u)){const v=w(u);if(v)return e.set(u,v),y(v);if(A(u))return e.set(u,void 0),u.init;throw new Error("no atom init")}const d=p(u,r);return e.set(u,d),y(d)};let s,l;const f={get signal(){return s||(s=new AbortController),s.signal},get setSelf(){return!l&&O(t)&&(l=(...u)=>{if(!n)return D(t,...u)}),l}};try{const u=t.read(i,f);return H(t,u,e,()=>s==null?void 0:s.abort())}catch(u){return Q(t,u,e)}finally{n=!1}},X=t=>y(p(t)),Y=t=>{const r=l=>{var f,u;const d=new Set((f=a.get(l))==null?void 0:f.t);return(u=g.get(l))==null||u[1].forEach(v=>{d.add(v)}),d},c=new Array,e=new Set,n=l=>{if(!e.has(l)){e.add(l);for(const f of r(l))l!==f&&n(f);c.push(l)}};n(t);const i=new Set([t]),s=l=>e.has(l);for(let l=c.length-1;l>=0;--l){const f=c[l],u=w(f);if(!u)continue;let d=!1;for(const v of u.d.keys())if(v!==f&&i.has(v)){d=!0;break}if(d){const v=p(f,s);k(f,v),E(u,v)||i.add(f)}e.delete(f)}},I=(t,...r)=>{const c=n=>y(p(n)),e=(n,...i)=>{const s=h.length>0;s||h.push(new Set([n]));let l;if(M(t,n)){if(!A(n))throw new Error("atom not writable");const f=w(n),u=H(n,i[0]);E(f,u)||Y(n)}else l=I(n,...i);return s||W(h.pop()),l};return t.write(c,e,...r)},D=(t,...r)=>{h.push(new Set([t]));const c=I(t,...r);return W(h.pop()),c},P=(t,r,c)=>{var e;const n=a.get(t);if(n)return r&&n.t.add(r),n;const i=c||[];(e=w(t))==null||e.d.forEach((l,f)=>{f!==t&&P(f,t,i)}),p(t);const s={t:new Set(r&&[r]),l:new Set};if(a.set(t,s),O(t)&&t.onMount){const{onMount:l}=t;i.push(()=>{const f=l((...u)=>D(t,...u));f&&(s.u=f)})}return c||i.forEach(l=>l()),s},Z=(t,r)=>!r.l.size&&(!r.t.size||r.t.size===1&&r.t.has(t)),j=(t,r)=>{if(!Z(t,r))return;const c=r.u;c&&c(),a.delete(t);const e=w(t);e&&(S(e)&&_(e.v),e.d.forEach((n,i)=>{if(i!==t){const s=a.get(i);s&&(s.t.delete(t),j(i,s))}}))},J=(t,r,c)=>{const e=new Set(r.d.keys()),n=new Set;c==null||c.forEach((i,s)=>{if(e.has(s)){e.delete(s);return}n.add(s);const l=a.get(s);l&&l.t.delete(t)}),e.forEach(i=>{P(i,t)}),n.forEach(i=>{const s=a.get(i);s&&j(i,s)})},W=t=>{const r=[],c=e=>{var n;if(!g.has(e))return;const[i,s]=g.get(e);g.delete(e),r.push([e,i]),s.forEach(c),(n=w(e))==null||n.d.forEach((l,f)=>c(f))};t.forEach(c),r.forEach(([e,n])=>{const i=w(e);if(i&&i!==n){const s=a.get(e);s&&i.d!==(n==null?void 0:n.d)&&J(e,i,n==null?void 0:n.d),s&&!(!S(n)&&(E(n,i)||x(n,i)))&&s.l.forEach(l=>l())}})};return{get:X,set:D,sub:(t,r)=>{const c=P(t);W([t]);const e=c.l;return e.add(r),()=>{e.delete(r),j(t,c)}}}};let b;$({createStore:B,getDefaultStore:()=>(b||(b=B()),b)})}}});
System.register([],function($){"use strict";return{execute:function(){$("atom",N);let L=0;function N(s,a){const v=`atom${++L}`,g={toString:()=>v};return typeof s=="function"?g.read=s:(g.init=s,g.read=R,g.write=T),a&&(g.write=a),g}function R(s){return s(this)}function T(s,a,v){return a(this,typeof v=="function"?v(s(this)):v)}const M=(s,a)=>s.unstable_is?s.unstable_is(a):a===s,A=s=>"init"in s,O=s=>!!s.write,m=new WeakMap,U=(s,a)=>{m.set(s,a),s.catch(()=>{}).finally(()=>m.delete(s))},_=(s,a)=>{const v=m.get(s);v&&(m.delete(s),v(a))},C=(s,a)=>{s.status="fulfilled",s.value=a},q=(s,a)=>{s.status="rejected",s.reason=a},V=s=>typeof(s==null?void 0:s.then)=="function",E=(s,a)=>!!s&&"v"in s&&"v"in a&&Object.is(s.v,a.v),x=(s,a)=>!!s&&"e"in s&&"e"in a&&Object.is(s.e,a.e),S=s=>!!s&&"v"in s&&s.v instanceof Promise,K=(s,a)=>"v"in s&&"v"in a&&s.v.orig&&s.v.orig===a.v.orig,y=s=>{if("e"in s)throw s.e;return s.v},B=()=>{const s=new WeakMap,a=new WeakMap,v=[],g=new WeakMap,w=t=>s.get(t),k=(t,r)=>{r.d.forEach((l,n)=>{if(!g.has(n)){const e=w(n);g.set(n,[e,new Set]),e&&k(n,e)}g.get(n)[1].add(t)})},F=(t,r)=>{var l;const n=w(t);if(s.set(t,r),(l=v[v.length-1])==null||l.add(t),g.has(t)||(g.set(t,[n,new Set]),k(t,r)),S(n)){const e="v"in r?r.v instanceof Promise?r.v:Promise.resolve(r.v):Promise.reject(r.e);n.v!==e&&_(n.v,e)}},G=(t,r,l,n)=>{const e=new Map(n?r.d:null);let c=!1;l.forEach((o,i)=>{!o&&M(t,i)&&(o=r),o&&(e.set(i,o),r.d.get(i)!==o&&(c=!0))}),(c||r.d.size!==e.size)&&(r.d=e)},z=(t,r,l,n)=>{const e=w(t),c={d:(e==null?void 0:e.d)||new Map,v:r};if(l&&G(t,c,l,n),E(e,c)&&e.d===c.d)return e;if(S(e)&&S(c)&&K(e,c)){if(e.d===c.d)return e;c.v=e.v}return F(t,c),c},H=(t,r,l,n)=>{if(V(r)){let e;const c=()=>{const i=w(t);if(!S(i)||i.v!==o)return;const f=z(t,o,l);a.has(t)&&i.d!==f.d&&J(t,f,i.d)},o=new Promise((i,f)=>{let u=!1;r.then(d=>{u||(u=!0,C(o,d),i(d),c())},d=>{u||(u=!0,q(o,d),f(d),c())}),e=d=>{u||(u=!0,d.then(h=>C(o,h),h=>q(o,h)),i(d))}});return o.orig=r,o.status="pending",U(o,i=>{i&&e(i),n==null||n()}),z(t,o,l,!0)}return z(t,r,l)},Q=(t,r,l)=>{const n=w(t),e={d:(n==null?void 0:n.d)||new Map,e:r};return l&&G(t,e,l),x(n,e)&&n.d===e.d?n:(F(t,e),e)},p=(t,r)=>{const l=w(t);if(!(r!=null&&r(t))&&l&&(a.has(t)||Array.from(l.d).every(([u,d])=>{if(u===t)return!0;const h=p(u,r);return h===d||E(h,d)})))return l;const n=new Map;let e=!0;const c=u=>{if(M(t,u)){const h=w(u);if(h)return n.set(u,h),y(h);if(A(u))return n.set(u,void 0),u.init;throw new Error("no atom init")}const d=p(u,r);return n.set(u,d),y(d)};let o,i;const f={get signal(){return o||(o=new AbortController),o.signal},get setSelf(){return!i&&O(t)&&(i=(...u)=>{if(!e)return D(t,...u)}),i}};try{const u=t.read(c,f);return H(t,u,n,()=>o==null?void 0:o.abort())}catch(u){return Q(t,u,n)}finally{e=!1}},X=t=>y(p(t)),Y=t=>{const r=i=>{var f,u;const d=new Set((f=a.get(i))==null?void 0:f.t);return(u=g.get(i))==null||u[1].forEach(h=>{d.add(h)}),d},l=new Array,n=new Set,e=i=>{if(!n.has(i)){n.add(i);for(const f of r(i))i!==f&&e(f);l.push(i)}};e(t);const c=new Set([t]),o=i=>n.has(i);for(let i=l.length-1;i>=0;--i){const f=l[i],u=w(f);if(!u)continue;let d=!1;for(const h of u.d.keys())if(h!==f&&c.has(h)){d=!0;break}if(d){const h=p(f,o);k(f,h),E(u,h)||c.add(f)}n.delete(f)}},I=(t,...r)=>{const l=e=>y(p(e)),n=(e,...c)=>{const o=v.length>0;o||v.push(new Set([e]));let i;if(M(t,e)){if(!A(e))throw new Error("atom not writable");const f=w(e),u=H(e,c[0]);E(f,u)||Y(e)}else i=I(e,...c);return o||W(v.pop()),i};return t.write(l,n,...r)},D=(t,...r)=>{v.push(new Set([t]));const l=I(t,...r);return W(v.pop()),l},P=(t,r,l)=>{var n;const e=a.get(t);if(e)return r&&e.t.add(r),e;const c=l||[];(n=w(t))==null||n.d.forEach((i,f)=>{f!==t&&P(f,t,c)}),p(t);const o={t:new Set(r&&[r]),l:new Set};if(a.set(t,o),O(t)&&t.onMount){const{onMount:i}=t;c.push(()=>{const f=i((...u)=>D(t,...u));f&&(o.u=f)})}return l||c.forEach(i=>i()),o},Z=(t,r)=>!r.l.size&&(!r.t.size||r.t.size===1&&r.t.has(t)),j=(t,r)=>{if(!Z(t,r))return;const l=r.u;l&&l(),a.delete(t);const n=w(t);n&&(S(n)&&_(n.v),n.d.forEach((e,c)=>{if(c!==t){const o=a.get(c);o&&(o.t.delete(t),j(c,o))}}))},J=(t,r,l)=>{const n=new Set(r.d.keys()),e=new Set;l==null||l.forEach((c,o)=>{if(n.has(o)){n.delete(o);return}e.add(o);const i=a.get(o);i&&i.t.delete(t)}),n.forEach(c=>{P(c,t)}),e.forEach(c=>{const o=a.get(c);o&&j(c,o)})},W=t=>{const r=[],l=n=>{var e;if(!g.has(n))return;const[c,o]=g.get(n);g.delete(n),r.push([n,c]),o.forEach(l),(e=w(n))==null||e.d.forEach((i,f)=>l(f))};t.forEach(l),r.forEach(([n,e])=>{const c=w(n);if(c&&c!==e){const o=a.get(n);o&&c.d!==(e==null?void 0:e.d)&&J(n,c,e==null?void 0:e.d),o&&!(!S(e)&&(E(e,c)||x(e,c)))&&o.l.forEach(i=>i())}})};return{get:X,set:D,sub:(t,r)=>{const l=P(t);W([t]);const n=l.l;return n.add(r),()=>{n.delete(r),j(t,l)}}}};let b;$({createStore:B,getDefaultStore:()=>(b||(b=B()),b)})}}});

@@ -381,2 +381,3 @@ System.register(['jotai/vanilla'], (function (exports) {

}, options) {
var _a;
let lastStr;

@@ -386,3 +387,3 @@ let lastValue;

getItem: (key, initialValue) => {
var _a, _b;
var _a2, _b;
const parse = (str2) => {

@@ -400,3 +401,3 @@ str2 = str2 || "";

};
const str = (_b = (_a = getStringStorage()) == null ? void 0 : _a.getItem(key)) != null ? _b : null;
const str = (_b = (_a2 = getStringStorage()) == null ? void 0 : _a2.getItem(key)) != null ? _b : null;
if (isPromiseLike(str)) {

@@ -408,4 +409,4 @@ return str.then(parse);

setItem: (key, newValue) => {
var _a;
return (_a = getStringStorage()) == null ? void 0 : _a.setItem(
var _a2;
return (_a2 = getStringStorage()) == null ? void 0 : _a2.setItem(
key,

@@ -416,21 +417,21 @@ JSON.stringify(newValue, options == null ? void 0 : options.replacer)

removeItem: (key) => {
var _a;
return (_a = getStringStorage()) == null ? void 0 : _a.removeItem(key);
var _a2;
return (_a2 = getStringStorage()) == null ? void 0 : _a2.removeItem(key);
}
};
if (typeof window !== "undefined" && typeof window.addEventListener === "function" && window.Storage) {
storage.subscribe = (key, callback, initialValue) => {
if (!(getStringStorage() instanceof window.Storage)) {
return () => {
};
}
const createHandleSubscribe = (subscriber2) => (key, callback, initialValue) => subscriber2(key, (v) => {
let newValue;
try {
newValue = JSON.parse(v || "");
} catch (e) {
newValue = initialValue;
}
callback(newValue);
});
let subscriber = (_a = getStringStorage()) == null ? void 0 : _a.subscribe;
if (!subscriber && typeof window !== "undefined" && typeof window.addEventListener === "function" && window.Storage && getStringStorage() instanceof window.Storage) {
subscriber = (key, callback) => {
const storageEventCallback = (e) => {
if (e.storageArea === getStringStorage() && e.key === key) {
let newValue;
try {
newValue = JSON.parse(e.newValue || "");
} catch (e2) {
newValue = initialValue;
}
callback(newValue);
callback(e.newValue);
}

@@ -444,2 +445,5 @@ };

}
if (subscriber) {
storage.subscribe = createHandleSubscribe(subscriber);
}
return storage;

@@ -446,0 +450,0 @@ }

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

System.register(["jotai/vanilla"],function(x){"use strict";var d;return{setters:[function(S){d=S.atom}],execute:function(){x({atomFamily:_,atomWithDefault:X,atomWithLazy:ft,atomWithObservable:et,atomWithReducer:$,atomWithRefresh:lt,atomWithReset:J,atomWithStorage:tt,createJSONStorage:z,freezeAtom:V,freezeAtomCreator:q,loadable:ot,selectAtom:K,splitAtom:U,unstable_withStorageValidator:Y,unwrap:ct});const S=x("RESET",Symbol(""));function J(e){const n=d(e,(r,u,a)=>{const o=typeof a=="function"?a(r(n)):a;u(n,o===S?e:o)});return n}function $(e,n){return d(e,function(r,u,a){u(this,n(r(this),a))})}function _(e,n){let r=null;const u=new Map,a=o=>{let t;if(n===void 0)t=u.get(o);else for(const[c,i]of u)if(n(c,o)){t=i;break}if(t!==void 0)if(r!=null&&r(t[1],o))a.remove(o);else return t[0];const s=e(o);return u.set(o,[s,Date.now()]),s};return a.remove=o=>{if(n===void 0)u.delete(o);else for(const[t]of u)if(n(t,o)){u.delete(t);break}},a.setShouldRemove=o=>{if(r=o,!!r)for(const[t,s]of u)r(s[1],t)&&u.delete(t)},a}const I=(e,n,r)=>(n.has(r)?n:n.set(r,e())).get(r),C=new WeakMap,F=(e,n,r,u)=>{const a=I(()=>new WeakMap,C,n),o=I(()=>new WeakMap,a,r);return I(e,o,u)};function K(e,n,r=Object.is){return F(()=>{const u=Symbol(),a=([t,s])=>{if(s===u)return n(t);const c=n(t,s);return r(s,c)?s:c},o=d(t=>{const s=t(o),c=t(e);return a([c,s])});return o.init=u,o},e,n,r)}const j=new WeakSet,M=e=>{if(typeof e!="object"||e===null)return;Object.freeze(e);const n=Object.getOwnPropertyNames(e);for(const r of n){const u=e[r];M(u)}return e};function V(e){if(j.has(e))return e;j.add(e);const n=e.read;if(e.read=function(r,u){return M(n.call(this,r,u))},"write"in e){const r=e.write;e.write=function(u,a,...o){return r.call(this,u,(...t)=>(t[0]===e&&(t[1]=M(t[1])),a(...t)),...o)}}return e}function q(e){return(...n)=>V(e(...n))}const A=(e,n,r)=>(n.has(r)?n:n.set(r,e())).get(r),B=new WeakMap,G=(e,n,r)=>{const u=A(()=>new WeakMap,B,n);return A(e,u,r)},H={},R=e=>!!e.write,Q=e=>typeof e=="function";function U(e,n){return G(()=>{const r=new WeakMap,u=(t,s)=>{let c=r.get(t);if(c)return c;const i=s&&r.get(s),l=[],f=[];return t.forEach((v,b)=>{const h=n?n(v):b;f[b]=h;const y=i&&i.atomList[i.keyList.indexOf(h)];if(y){l[b]=y;return}const O=g=>{const m=g(a),p=g(e),W=u(p,m==null?void 0:m.arr).keyList.indexOf(h);if(W<0||W>=p.length){const w=t[u(t).keyList.indexOf(h)];if(w)return w;throw new Error("splitAtom: index out of bounds for read")}return p[W]},L=(g,m,p)=>{const W=g(a),w=g(e),k=u(w,W==null?void 0:W.arr).keyList.indexOf(h);if(k<0||k>=w.length)throw new Error("splitAtom: index out of bounds for write");const T=Q(p)?p(w[k]):p;Object.is(w[k],T)||m(e,[...w.slice(0,k),T,...w.slice(k+1)])};l[b]=R(e)?d(O,L):d(O)}),i&&i.keyList.length===f.length&&i.keyList.every((v,b)=>v===f[b])?c=i:c={arr:t,atomList:l,keyList:f},r.set(t,c),c},a=d(t=>{const s=t(a),c=t(e);return u(c,s==null?void 0:s.arr)});a.init=void 0;const o=R(e)?d(t=>t(a).atomList,(t,s,c)=>{switch(c.type){case"remove":{const i=t(o).indexOf(c.atom);if(i>=0){const l=t(e);s(e,[...l.slice(0,i),...l.slice(i+1)])}break}case"insert":{const i=c.before?t(o).indexOf(c.before):t(o).length;if(i>=0){const l=t(e);s(e,[...l.slice(0,i),c.value,...l.slice(i)])}break}case"move":{const i=t(o).indexOf(c.atom),l=c.before?t(o).indexOf(c.before):t(o).length;if(i>=0&&l>=0){const f=t(e);i<l?s(e,[...f.slice(0,i),...f.slice(i+1,l),f[i],...f.slice(l)]):s(e,[...f.slice(0,l),f[i],...f.slice(l,i),...f.slice(i+1)])}break}}}):d(t=>t(a).atomList);return o},e,n||H)}function X(e){const n=Symbol(),r=d(n),u=d((a,o)=>{const t=a(r);return t!==n?t:e(a,o)},(a,o,t)=>{if(t===S)o(r,n);else if(typeof t=="function"){const s=a(u);o(r,t(s))}else o(r,t)});return u}const P=e=>typeof(e==null?void 0:e.then)=="function";function Y(e){return n=>({...n,getItem:(r,u)=>{const a=t=>e(t)?t:u,o=n.getItem(r,u);return P(o)?o.then(a):a(o)}})}function z(e=()=>{try{return window.localStorage}catch(r){return}},n){let r,u;const a={getItem:(o,t)=>{var s,c;const i=f=>{if(f=f||"",r!==f){try{u=JSON.parse(f,n==null?void 0:n.reviver)}catch(v){return t}r=f}return u},l=(c=(s=e())==null?void 0:s.getItem(o))!=null?c:null;return P(l)?l.then(i):i(l)},setItem:(o,t)=>{var s;return(s=e())==null?void 0:s.setItem(o,JSON.stringify(t,n==null?void 0:n.replacer))},removeItem:o=>{var t;return(t=e())==null?void 0:t.removeItem(o)}};return typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&(a.subscribe=(o,t,s)=>{if(!(e()instanceof window.Storage))return()=>{};const c=i=>{if(i.storageArea===e()&&i.key===o){let l;try{l=JSON.parse(i.newValue||"")}catch(f){l=s}t(l)}};return window.addEventListener("storage",c),()=>{window.removeEventListener("storage",c)}}),a}const Z=z();function tt(e,n,r=Z,u){const a=u==null?void 0:u.getOnInit,o=d(a?r.getItem(e,n):n);return o.onMount=t=>{t(r.getItem(e,n));let s;return r.subscribe&&(s=r.subscribe(e,t,n)),s},d(t=>t(o),(t,s,c)=>{const i=typeof c=="function"?c(t(o)):c;return i===S?(s(o,n),r.removeItem(e)):i instanceof Promise?i.then(l=>(s(o,l),r.setItem(e,l))):(s(o,i),r.setItem(e,i))})}function et(e,n){const r=a=>{if("e"in a)throw a.e;return a.d},u=d(a=>{var o;let t=e(a);const s=(o=t[Symbol.observable])==null?void 0:o.call(t);s&&(t=s);let c;const i=()=>new Promise(m=>{c=m}),l=n&&"initialValue"in n?{d:typeof n.initialValue=="function"?n.initialValue():n.initialValue}:i();let f,v;const b=m=>{v=m,c==null||c(m),f==null||f(m)};let h,y;const O=()=>!f,L=()=>{h&&(clearTimeout(y),h.unsubscribe()),h=t.subscribe({next:m=>b({d:m}),error:m=>b({e:m}),complete:()=>{}}),O()&&n!=null&&n.unstable_timeout&&(y=setTimeout(()=>{h&&(h.unsubscribe(),h=void 0)},n.unstable_timeout))};L();const g=d(v||l);return g.onMount=m=>(f=m,v&&m(v),h?clearTimeout(y):L(),()=>{f=void 0,h&&(h.unsubscribe(),h=void 0)}),[g,t,i,L,O]});return d(a=>{const[o]=a(u),t=a(o);return t instanceof Promise?t.then(r):r(t)},(a,o,t)=>{const[s,c,i,l,f]=a(u);if("next"in c)f()&&(o(s,i()),l()),c.next(t);else throw new Error("observable is not subject")})}const E=new WeakMap,nt=(e,n)=>(E.has(n)?E:E.set(n,e())).get(n),rt=e=>e instanceof Promise,D={state:"loading"};function ot(e){return nt(()=>{const n=new WeakMap,r=d(0),u=d((a,{setSelf:o})=>{a(r);let t;try{t=a(e)}catch(l){return{state:"hasError",error:l}}if(!rt(t))return{state:"hasData",data:t};const s=t,c=n.get(s);return c||(s.status==="fulfilled"?n.set(s,{state:"hasData",data:s.value}):s.status==="rejected"?n.set(s,{state:"hasError",error:s.reason}):s.then(l=>{n.set(s,{state:"hasData",data:l})},l=>{n.set(s,{state:"hasError",error:l})}).finally(o),n.get(s)||(n.set(s,D),D))},(a,o)=>{o(r,t=>t+1)});return d(a=>a(u))},e)}const N=(e,n,r)=>(n.has(r)?n:n.set(r,e())).get(r),st=new WeakMap,it=(e,n,r)=>{const u=N(()=>new WeakMap,st,n);return N(e,u,r)},at=e=>e instanceof Promise,ut=()=>{};function ct(e,n=ut){return it(()=>{const r=new WeakMap,u=new WeakMap,a=d(0),o=d((t,{setSelf:s})=>{t(a);const c=t(o),i=t(e);if(!at(i))return{v:i};if(i!==(c==null?void 0:c.p)&&(i.status==="fulfilled"?u.set(i,i.value):i.status==="rejected"?r.set(i,i.reason):i.then(l=>u.set(i,l),l=>r.set(i,l)).finally(s)),r.has(i))throw r.get(i);return u.has(i)?{p:i,v:u.get(i)}:c&&"v"in c?{p:i,f:n(c.v),v:c.v}:{p:i,f:n()}},(t,s)=>{s(a,c=>c+1)});return o.init=void 0,d(t=>{const s=t(o);return"f"in s?s.f:s.v},(t,s,...c)=>s(e,...c))},e,n)}function lt(e,n){const r=d(0);return d((u,a)=>(u(r),e(u,a)),(u,a,...o)=>{if(o.length===0)a(r,t=>t+1);else if(n)return n(u,a,...o)})}function ft(e){const n=d(void 0);return delete n.init,Object.defineProperty(n,"init",{get(){return e()}}),n}}}});
System.register(["jotai/vanilla"],function(x){"use strict";var d;return{setters:[function(k){d=k.atom}],execute:function(){x({atomFamily:_,atomWithDefault:X,atomWithLazy:ft,atomWithObservable:et,atomWithReducer:$,atomWithRefresh:lt,atomWithReset:J,atomWithStorage:tt,createJSONStorage:D,freezeAtom:A,freezeAtomCreator:q,loadable:ot,selectAtom:K,splitAtom:U,unstable_withStorageValidator:Y,unwrap:ct});const k=x("RESET",Symbol(""));function J(t){const n=d(t,(r,u,a)=>{const s=typeof a=="function"?a(r(n)):a;u(n,s===k?t:s)});return n}function $(t,n){return d(t,function(r,u,a){u(this,n(r(this),a))})}function _(t,n){let r=null;const u=new Map,a=s=>{let e;if(n===void 0)e=u.get(s);else for(const[c,o]of u)if(n(c,s)){e=o;break}if(e!==void 0)if(r!=null&&r(e[1],s))a.remove(s);else return e[0];const i=t(s);return u.set(s,[i,Date.now()]),i};return a.remove=s=>{if(n===void 0)u.delete(s);else for(const[e]of u)if(n(e,s)){u.delete(e);break}},a.setShouldRemove=s=>{if(r=s,!!r)for(const[e,i]of u)r(i[1],e)&&u.delete(e)},a}const I=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),C=new WeakMap,F=(t,n,r,u)=>{const a=I(()=>new WeakMap,C,n),s=I(()=>new WeakMap,a,r);return I(t,s,u)};function K(t,n,r=Object.is){return F(()=>{const u=Symbol(),a=([e,i])=>{if(i===u)return n(e);const c=n(e,i);return r(i,c)?i:c},s=d(e=>{const i=e(s),c=e(t);return a([c,i])});return s.init=u,s},t,n,r)}const j=new WeakSet,M=t=>{if(typeof t!="object"||t===null)return;Object.freeze(t);const n=Object.getOwnPropertyNames(t);for(const r of n){const u=t[r];M(u)}return t};function A(t){if(j.has(t))return t;j.add(t);const n=t.read;if(t.read=function(r,u){return M(n.call(this,r,u))},"write"in t){const r=t.write;t.write=function(u,a,...s){return r.call(this,u,(...e)=>(e[0]===t&&(e[1]=M(e[1])),a(...e)),...s)}}return t}function q(t){return(...n)=>A(t(...n))}const R=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),B=new WeakMap,G=(t,n,r)=>{const u=R(()=>new WeakMap,B,n);return R(t,u,r)},H={},P=t=>!!t.write,Q=t=>typeof t=="function";function U(t,n){return G(()=>{const r=new WeakMap,u=(e,i)=>{let c=r.get(e);if(c)return c;const o=i&&r.get(i),l=[],f=[];return e.forEach((b,h)=>{const m=n?n(b):h;f[h]=m;const p=o&&o.atomList[o.keyList.indexOf(m)];if(p){l[h]=p;return}const O=g=>{const v=g(a),y=g(t),S=u(y,v==null?void 0:v.arr).keyList.indexOf(m);if(S<0||S>=y.length){const w=e[u(e).keyList.indexOf(m)];if(w)return w;throw new Error("splitAtom: index out of bounds for read")}return y[S]},L=(g,v,y)=>{const S=g(a),w=g(t),W=u(w,S==null?void 0:S.arr).keyList.indexOf(m);if(W<0||W>=w.length)throw new Error("splitAtom: index out of bounds for write");const V=Q(y)?y(w[W]):y;Object.is(w[W],V)||v(t,[...w.slice(0,W),V,...w.slice(W+1)])};l[h]=P(t)?d(O,L):d(O)}),o&&o.keyList.length===f.length&&o.keyList.every((b,h)=>b===f[h])?c=o:c={arr:e,atomList:l,keyList:f},r.set(e,c),c},a=d(e=>{const i=e(a),c=e(t);return u(c,i==null?void 0:i.arr)});a.init=void 0;const s=P(t)?d(e=>e(a).atomList,(e,i,c)=>{switch(c.type){case"remove":{const o=e(s).indexOf(c.atom);if(o>=0){const l=e(t);i(t,[...l.slice(0,o),...l.slice(o+1)])}break}case"insert":{const o=c.before?e(s).indexOf(c.before):e(s).length;if(o>=0){const l=e(t);i(t,[...l.slice(0,o),c.value,...l.slice(o)])}break}case"move":{const o=e(s).indexOf(c.atom),l=c.before?e(s).indexOf(c.before):e(s).length;if(o>=0&&l>=0){const f=e(t);o<l?i(t,[...f.slice(0,o),...f.slice(o+1,l),f[o],...f.slice(l)]):i(t,[...f.slice(0,l),f[o],...f.slice(l,o),...f.slice(o+1)])}break}}}):d(e=>e(a).atomList);return s},t,n||H)}function X(t){const n=Symbol(),r=d(n),u=d((a,s)=>{const e=a(r);return e!==n?e:t(a,s)},(a,s,e)=>{if(e===k)s(r,n);else if(typeof e=="function"){const i=a(u);s(r,e(i))}else s(r,e)});return u}const z=t=>typeof(t==null?void 0:t.then)=="function";function Y(t){return n=>({...n,getItem:(r,u)=>{const a=e=>t(e)?e:u,s=n.getItem(r,u);return z(s)?s.then(a):a(s)}})}function D(t=()=>{try{return window.localStorage}catch(r){return}},n){var r;let u,a;const s={getItem:(c,o)=>{var l,f;const b=m=>{if(m=m||"",u!==m){try{a=JSON.parse(m,n==null?void 0:n.reviver)}catch(p){return o}u=m}return a},h=(f=(l=t())==null?void 0:l.getItem(c))!=null?f:null;return z(h)?h.then(b):b(h)},setItem:(c,o)=>{var l;return(l=t())==null?void 0:l.setItem(c,JSON.stringify(o,n==null?void 0:n.replacer))},removeItem:c=>{var o;return(o=t())==null?void 0:o.removeItem(c)}},e=c=>(o,l,f)=>c(o,b=>{let h;try{h=JSON.parse(b||"")}catch(m){h=f}l(h)});let i=(r=t())==null?void 0:r.subscribe;return!i&&typeof window!="undefined"&&typeof window.addEventListener=="function"&&window.Storage&&t()instanceof window.Storage&&(i=(c,o)=>{const l=f=>{f.storageArea===t()&&f.key===c&&o(f.newValue)};return window.addEventListener("storage",l),()=>{window.removeEventListener("storage",l)}}),i&&(s.subscribe=e(i)),s}const Z=D();function tt(t,n,r=Z,u){const a=u==null?void 0:u.getOnInit,s=d(a?r.getItem(t,n):n);return s.onMount=e=>{e(r.getItem(t,n));let i;return r.subscribe&&(i=r.subscribe(t,e,n)),i},d(e=>e(s),(e,i,c)=>{const o=typeof c=="function"?c(e(s)):c;return o===k?(i(s,n),r.removeItem(t)):o instanceof Promise?o.then(l=>(i(s,l),r.setItem(t,l))):(i(s,o),r.setItem(t,o))})}function et(t,n){const r=a=>{if("e"in a)throw a.e;return a.d},u=d(a=>{var s;let e=t(a);const i=(s=e[Symbol.observable])==null?void 0:s.call(e);i&&(e=i);let c;const o=()=>new Promise(v=>{c=v}),l=n&&"initialValue"in n?{d:typeof n.initialValue=="function"?n.initialValue():n.initialValue}:o();let f,b;const h=v=>{b=v,c==null||c(v),f==null||f(v)};let m,p;const O=()=>!f,L=()=>{m&&(clearTimeout(p),m.unsubscribe()),m=e.subscribe({next:v=>h({d:v}),error:v=>h({e:v}),complete:()=>{}}),O()&&n!=null&&n.unstable_timeout&&(p=setTimeout(()=>{m&&(m.unsubscribe(),m=void 0)},n.unstable_timeout))};L();const g=d(b||l);return g.onMount=v=>(f=v,b&&v(b),m?clearTimeout(p):L(),()=>{f=void 0,m&&(m.unsubscribe(),m=void 0)}),[g,e,o,L,O]});return d(a=>{const[s]=a(u),e=a(s);return e instanceof Promise?e.then(r):r(e)},(a,s,e)=>{const[i,c,o,l,f]=a(u);if("next"in c)f()&&(s(i,o()),l()),c.next(e);else throw new Error("observable is not subject")})}const E=new WeakMap,nt=(t,n)=>(E.has(n)?E:E.set(n,t())).get(n),rt=t=>t instanceof Promise,N={state:"loading"};function ot(t){return nt(()=>{const n=new WeakMap,r=d(0),u=d((a,{setSelf:s})=>{a(r);let e;try{e=a(t)}catch(l){return{state:"hasError",error:l}}if(!rt(e))return{state:"hasData",data:e};const i=e,c=n.get(i);return c||(i.status==="fulfilled"?n.set(i,{state:"hasData",data:i.value}):i.status==="rejected"?n.set(i,{state:"hasError",error:i.reason}):i.then(l=>{n.set(i,{state:"hasData",data:l})},l=>{n.set(i,{state:"hasError",error:l})}).finally(s),n.get(i)||(n.set(i,N),N))},(a,s)=>{s(r,e=>e+1)});return d(a=>a(u))},t)}const T=(t,n,r)=>(n.has(r)?n:n.set(r,t())).get(r),st=new WeakMap,it=(t,n,r)=>{const u=T(()=>new WeakMap,st,n);return T(t,u,r)},at=t=>t instanceof Promise,ut=()=>{};function ct(t,n=ut){return it(()=>{const r=new WeakMap,u=new WeakMap,a=d(0),s=d((e,{setSelf:i})=>{e(a);const c=e(s),o=e(t);if(!at(o))return{v:o};if(o!==(c==null?void 0:c.p)&&(o.status==="fulfilled"?u.set(o,o.value):o.status==="rejected"?r.set(o,o.reason):o.then(l=>u.set(o,l),l=>r.set(o,l)).finally(i)),r.has(o))throw r.get(o);return u.has(o)?{p:o,v:u.get(o)}:c&&"v"in c?{p:o,f:n(c.v),v:c.v}:{p:o,f:n()}},(e,i)=>{i(a,c=>c+1)});return s.init=void 0,d(e=>{const i=e(s);return"f"in i?i.f:i.v},(e,i,...c)=>i(t,...c))},t,n)}function lt(t,n){const r=d(0);return d((u,a)=>(u(r),t(u,a)),(u,a,...s)=>{if(s.length===0)a(r,e=>e+1);else if(n)return n(u,a,...s)})}function ft(t){const n=d(void 0);return delete n.init,Object.defineProperty(n,"init",{get(){return t()}}),n}}}});

@@ -50,3 +50,2 @@ import type { Atom, WritableAtom } from './atom';

dev4_get_internal_weak_map: () => WeakMap<AnyAtom, AtomState>;
dev4_override_method: <K extends keyof PrdStore>(key: K, fn: PrdStore[K]) => void;
dev4_restore_atoms: (values: Iterable<readonly [

@@ -53,0 +52,0 @@ AnyAtom,

import type { WritableAtom } from 'jotai/vanilla';
import { RESET } from './constants';
type Unsubscribe = () => void;
type Subscribe<Value> = (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
type StringSubscribe = (key: string, callback: (value: string | null) => void) => Unsubscribe;
type SetStateActionWithReset<Value> = Value | typeof RESET | ((prev: Value) => Value | typeof RESET);

@@ -9,3 +11,3 @@ export interface AsyncStorage<Value> {

removeItem: (key: string) => PromiseLike<void>;
subscribe?: (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
subscribe?: Subscribe<Value>;
}

@@ -16,3 +18,3 @@ export interface SyncStorage<Value> {

removeItem: (key: string) => void;
subscribe?: (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
subscribe?: Subscribe<Value>;
}

@@ -23,2 +25,3 @@ export interface AsyncStringStorage {

removeItem: (key: string) => PromiseLike<void>;
subscribe?: StringSubscribe;
}

@@ -29,2 +32,3 @@ export interface SyncStringStorage {

removeItem: (key: string) => void;
subscribe?: StringSubscribe;
}

@@ -31,0 +35,0 @@ export declare function withStorageValidator<Value>(validator: (value: unknown) => value is Value): {

@@ -50,3 +50,2 @@ import type { Atom, WritableAtom } from './atom';

dev4_get_internal_weak_map: () => WeakMap<AnyAtom, AtomState>;
dev4_override_method: <K extends keyof PrdStore>(key: K, fn: PrdStore[K]) => void;
dev4_restore_atoms: (values: Iterable<readonly [

@@ -53,0 +52,0 @@ AnyAtom,

import type { WritableAtom } from 'jotai/vanilla';
import { RESET } from './constants';
type Unsubscribe = () => void;
type Subscribe<Value> = (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
type StringSubscribe = (key: string, callback: (value: string | null) => void) => Unsubscribe;
type SetStateActionWithReset<Value> = Value | typeof RESET | ((prev: Value) => Value | typeof RESET);

@@ -9,3 +11,3 @@ export interface AsyncStorage<Value> {

removeItem: (key: string) => PromiseLike<void>;
subscribe?: (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
subscribe?: Subscribe<Value>;
}

@@ -16,3 +18,3 @@ export interface SyncStorage<Value> {

removeItem: (key: string) => void;
subscribe?: (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
subscribe?: Subscribe<Value>;
}

@@ -23,2 +25,3 @@ export interface AsyncStringStorage {

removeItem: (key: string) => PromiseLike<void>;
subscribe?: StringSubscribe;
}

@@ -29,2 +32,3 @@ export interface SyncStringStorage {

removeItem: (key: string) => void;
subscribe?: StringSubscribe;
}

@@ -31,0 +35,0 @@ export declare function withStorageValidator<Value>(validator: (value: unknown) => value is Value): {

@@ -34,29 +34,20 @@ (function (global, factory) {

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -66,2 +57,9 @@ }

}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -226,2 +224,3 @@ var isSelfAtom = function isSelfAtom(atom, a) {

pendingPromise[CONTINUE_PROMISE](valueOrPromise, abortPromise);
++atomState.n;
}

@@ -397,4 +396,3 @@ } else {

var aState = getAtomState(a);
var hasPrevValue = ('v' in aState);
var prevValue = aState.v;
var prevEpochNumber = aState.n;
var hasChangedDeps = false;

@@ -411,3 +409,3 @@ for (var _iterator4 = _createForOfIteratorHelperLoose(aState.d.keys()), _step4; !(_step4 = _iterator4()).done;) {

mountDependencies(pending, a, aState);
if (!hasPrevValue || !Object.is(prevValue, aState.v)) {
if (prevEpochNumber !== aState.n) {
addPendingAtom(pending, a, aState);

@@ -560,5 +558,2 @@ changedAtoms.add(a);

},
dev4_override_method: function dev4_override_method(key, fn) {
store[key] = fn;
},
dev4_restore_atoms: function dev4_restore_atoms(values) {

@@ -565,0 +560,0 @@ var pending = createPending();

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

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).jotaiExperimental={})}(this,(function(n){"use strict";var e=0;function t(n){return n(this)}function r(n,e,t){return e(this,"function"==typeof t?t(n(this)):t)}function o(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=n[t];return r}function a(n,e){var t="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=function(n,e){if(n){if("string"==typeof n)return o(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(n,e):void 0}}(n))||e){t&&(n=t);var r=0;return function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=function(n,e){return n.unstable_is?n.unstable_is(e):e===n},f=function(n){return"init"in n},c=function(n){return!!n.write},v=Symbol(""),l="pending",d=new WeakMap,s=function(n){return"v"in n||"e"in n},m=function(n){if("e"in n)throw n.e;return n.v},p=function(n){var e,t=n.v;return"object"==typeof(e=t)&&null!==e&&v in e&&t.status===l?t:null},y=function(n,e,t){t.p.has(n)||(t.p.add(n),e.then((function(){t.p.delete(n)}),(function(){t.p.delete(n)})))},h=function(){return[new Map,new Map,new Set]},w=function(n,e,t){n[0].has(e)||n[0].set(e,new Set),n[1].set(e,t)},g=function(n,e){n[2].add(e)},b=function(n){for(;n[1].size||n[2].size;){n[0].clear();var e=new Set(n[1].values());n[1].clear();var t=new Set(n[2]);n[2].clear(),e.forEach((function(n){var e;return null==(e=n.m)?void 0:e.l.forEach((function(n){return n()}))})),t.forEach((function(n){return n()}))}},S=function(){var n=new WeakMap,e=function(e){var t=n.get(e);return t||(t={d:new Map,p:new Set,n:0},n.set(e,t)),t},t=function(n,t,r,o,i){void 0===o&&(o=function(){}),void 0===i&&(i=function(){});var u,f="v"in t,c=t.v,s=p(t);if("function"==typeof(null==(u=r)?void 0:u.then))if(s)s!==r&&s[v](r,o);else{var m=function(n,e,t){if(!d.has(n)){var r,o=new Promise((function(a,i){var u=n,f=function(n){return function(e){u===n&&(o.status="fulfilled",o.value=e,a(e),t())}},c=function(n){return function(e){u===n&&(o.status="rejected",o.reason=e,i(e),t())}};n.then(f(n),c(n)),r=function(n,t){n&&(d.set(n,o),u=n,n.then(f(n),c(n))),e(),e=t}}));o.status=l,o[v]=r,d.set(n,o)}return d.get(n)}(r,o,i);if(m.status===l)for(var h,w=a(t.d.keys());!(h=w()).done;){var g=h.value,b=e(g);y(n,m,b)}t.v=m,delete t.e}else s&&s[v](Promise.resolve(r),o),t.v=r,delete t.e;f&&Object.is(c,t.v)||++t.n},r=function(n,t,r,o){var a,i=e(t);i.d.set(r,o.n);var u=p(i);u&&y(t,u,o),null==(a=o.m)||a.t.add(t),n&&function(n,e,t){var r=n[0].get(e);r&&r.add(t)}(n,r,t)},o=function n(o,a,i){var v=e(a);if((null==i||!i(a))&&s(v)){if(v.m)return v;if(Array.from(v.d).every((function(e){var t=e[0],r=e[1];return n(o,t,i).n===r})))return v}v.d.clear();var l,d,p=!0,y={get signal(){return l||(l=new AbortController),l.signal},get setSelf(){return!d&&c(a)&&(d=function(){if(!p){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return A.apply(void 0,[a].concat(e))}}),d}};try{var w=a.read((function(c){if(u(a,c)){var l=e(c);if(!s(l)){if(!f(c))throw new Error("no atom init");t(c,l,c.init)}return m(l)}var d=n(o,c,i);if(p)r(o,a,c,d);else{var y=h();r(y,a,c,d),j(y,a,v),b(y)}return m(d)}),y);return t(a,v,w,(function(){var n;return null==(n=l)?void 0:n.abort()}),(function(){if(v.m){var n=h();j(n,a,v),b(n)}})),v}catch(n){return delete v.v,v.e=n,++v.n,v}finally{p=!1}},i=function(n,t){var r=[],i=new Set;!function t(o){if(!i.has(o)){i.add(o);for(var u,f=a(function(t){for(var r,o,i,u=e(t),f=new Set(null==(r=u.m)?void 0:r.t),c=a(u.p);!(i=c()).done;){var v=i.value;f.add(v)}return null==(o=function(n,e){return n[0].get(e)}(n,t))||o.forEach((function(n){f.add(n)})),f}(o));!(u=f()).done;){var c=u.value;o!==c&&t(c)}r.push(o)}}(t);for(var u=new Set([t]),f=function(n){return i.has(n)},c=r.length-1;c>=0;--c){for(var v,l=r[c],d=e(l),s=("v"in d),m=d.v,p=!1,y=a(d.d.keys());!(v=y()).done;){var h=v.value;if(h!==l&&u.has(h)){p=!0;break}}p&&(o(n,l,f),j(n,l,d),s&&Object.is(m,d.v)||(w(n,l,d),u.add(l))),i.delete(l)}},S=function n(r,a){for(var c=arguments.length,v=new Array(c>2?c-2:0),l=2;l<c;l++)v[l-2]=arguments[l];var d=a.write.apply(a,[function(n){return m(o(r,n))},function(o){for(var c,v=arguments.length,l=new Array(v>1?v-1:0),d=1;d<v;d++)l[d-1]=arguments[d];if(u(a,o)){if(!f(o))throw new Error("atom not writable");var s=e(o),m="v"in s,p=s.v,y=l[0];t(o,s,y),j(r,o,s),m&&Object.is(p,s.v)||(w(r,o,s),i(r,o))}else c=n.apply(void 0,[r,o].concat(l));return b(r),c}].concat(v));return d},A=function(n){for(var e=h(),t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];var a=S.apply(void 0,[e,n].concat(r));return b(e),a},j=function(n,e,t){if(t.m&&!p(t)){for(var r,o=a(t.d.keys());!(r=o()).done;){var i=r.value;if(!t.m.d.has(i))k(n,i).t.add(e),t.m.d.add(i)}for(var u,f=a(t.m.d||[]);!(u=f()).done;){var c=u.value;if(!t.d.has(c)){var v=E(n,c);null==v||v.t.delete(e),t.m.d.delete(c)}}}},k=function n(t,r){var i=e(r);if(!i.m){o(t,r);for(var u,f=a(i.d.keys());!(u=f()).done;){var v=u.value;n(t,v).t.add(r)}if(i.m={l:new Set,d:new Set(i.d.keys()),t:new Set},c(r)&&r.onMount){var l=i.m,d=r.onMount;g(t,(function(){var n=d((function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];return S.apply(void 0,[t,r].concat(e))}));n&&(l.u=n)}))}}return i.m},E=function n(t,r){var o=e(r);if(!o.m||o.m.l.size||Array.from(o.m.t).some((function(n){return e(n).m})))return o.m;var i=o.m.u;i&&g(t,i),delete o.m;for(var u,f=a(o.d.keys());!(u=f()).done;){var c=n(t,u.value);null==c||c.t.delete(r)}var l=p(o);l&&l[v](void 0,(function(){}))};return{get:function(n){return m(o(void 0,n))},set:A,sub:function(n,e){var t=h(),r=k(t,n);b(t);var o=r.l;return o.add(e),function(){o.delete(e);var t=h();E(t,n),b(t)}}}};n.atom=function(n,o){var a="atom"+ ++e,i={toString:function(){return a}};return"function"==typeof n?i.read=n:(i.init=n,i.read=t,i.write=r),o&&(i.write=o),i},n.createStore=S,n.getDefaultStore=function(){return i||(i=S()),i}}));
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).jotaiExperimental={})}(this,(function(n){"use strict";var e=0;function t(n){return n(this)}function r(n,e,t){return e(this,"function"==typeof t?t(n(this)):t)}function o(n,e){(null==e||e>n.length)&&(e=n.length);for(var t=0,r=Array(e);t<e;t++)r[t]=n[t];return r}function a(n,e){var t="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(t)return(t=t.call(n)).next.bind(t);if(Array.isArray(n)||(t=function(n,e){if(n){if("string"==typeof n)return o(n,e);var t={}.toString.call(n).slice(8,-1);return"Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t?Array.from(n):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(n,e):void 0}}(n))||e){t&&(n=t);var r=0;return function(){return r>=n.length?{done:!0}:{done:!1,value:n[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=function(n,e){return n.unstable_is?n.unstable_is(e):e===n},f=function(n){return"init"in n},c=function(n){return!!n.write},l=Symbol(""),v="pending",d=new WeakMap,s=function(n){return"v"in n||"e"in n},m=function(n){if("e"in n)throw n.e;return n.v},y=function(n){var e,t=n.v;return"object"==typeof(e=t)&&null!==e&&l in e&&t.status===v?t:null},p=function(n,e,t){t.p.has(n)||(t.p.add(n),e.then((function(){t.p.delete(n)}),(function(){t.p.delete(n)})))},h=function(){return[new Map,new Map,new Set]},w=function(n,e,t){n[0].has(e)||n[0].set(e,new Set),n[1].set(e,t)},g=function(n,e){n[2].add(e)},b=function(n){for(;n[1].size||n[2].size;){n[0].clear();var e=new Set(n[1].values());n[1].clear();var t=new Set(n[2]);n[2].clear(),e.forEach((function(n){var e;return null==(e=n.m)?void 0:e.l.forEach((function(n){return n()}))})),t.forEach((function(n){return n()}))}},S=function(){var n=new WeakMap,e=function(e){var t=n.get(e);return t||(t={d:new Map,p:new Set,n:0},n.set(e,t)),t},t=function(n,t,r,o,i){void 0===o&&(o=function(){}),void 0===i&&(i=function(){});var u,f="v"in t,c=t.v,s=y(t);if("function"==typeof(null==(u=r)?void 0:u.then))if(s)s!==r&&(s[l](r,o),++t.n);else{var m=function(n,e,t){if(!d.has(n)){var r,o=new Promise((function(a,i){var u=n,f=function(n){return function(e){u===n&&(o.status="fulfilled",o.value=e,a(e),t())}},c=function(n){return function(e){u===n&&(o.status="rejected",o.reason=e,i(e),t())}};n.then(f(n),c(n)),r=function(n,t){n&&(d.set(n,o),u=n,n.then(f(n),c(n))),e(),e=t}}));o.status=v,o[l]=r,d.set(n,o)}return d.get(n)}(r,o,i);if(m.status===v)for(var h,w=a(t.d.keys());!(h=w()).done;){var g=h.value,b=e(g);p(n,m,b)}t.v=m,delete t.e}else s&&s[l](Promise.resolve(r),o),t.v=r,delete t.e;f&&Object.is(c,t.v)||++t.n},r=function(n,t,r,o){var a,i=e(t);i.d.set(r,o.n);var u=y(i);u&&p(t,u,o),null==(a=o.m)||a.t.add(t),n&&function(n,e,t){var r=n[0].get(e);r&&r.add(t)}(n,r,t)},o=function n(o,a,i){var l=e(a);if((null==i||!i(a))&&s(l)){if(l.m)return l;if(Array.from(l.d).every((function(e){var t=e[0],r=e[1];return n(o,t,i).n===r})))return l}l.d.clear();var v,d,y=!0,p={get signal(){return v||(v=new AbortController),v.signal},get setSelf(){return!d&&c(a)&&(d=function(){if(!y){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return A.apply(void 0,[a].concat(e))}}),d}};try{var w=a.read((function(c){if(u(a,c)){var v=e(c);if(!s(v)){if(!f(c))throw new Error("no atom init");t(c,v,c.init)}return m(v)}var d=n(o,c,i);if(y)r(o,a,c,d);else{var p=h();r(p,a,c,d),k(p,a,l),b(p)}return m(d)}),p);return t(a,l,w,(function(){var n;return null==(n=v)?void 0:n.abort()}),(function(){if(l.m){var n=h();k(n,a,l),b(n)}})),l}catch(n){return delete l.v,l.e=n,++l.n,l}finally{y=!1}},i=function(n,t){var r=[],i=new Set;!function t(o){if(!i.has(o)){i.add(o);for(var u,f=a(function(t){for(var r,o,i,u=e(t),f=new Set(null==(r=u.m)?void 0:r.t),c=a(u.p);!(i=c()).done;){var l=i.value;f.add(l)}return null==(o=function(n,e){return n[0].get(e)}(n,t))||o.forEach((function(n){f.add(n)})),f}(o));!(u=f()).done;){var c=u.value;o!==c&&t(c)}r.push(o)}}(t);for(var u=new Set([t]),f=function(n){return i.has(n)},c=r.length-1;c>=0;--c){for(var l,v=r[c],d=e(v),s=d.n,m=!1,y=a(d.d.keys());!(l=y()).done;){var p=l.value;if(p!==v&&u.has(p)){m=!0;break}}m&&(o(n,v,f),k(n,v,d),s!==d.n&&(w(n,v,d),u.add(v))),i.delete(v)}},S=function n(r,a){for(var c=arguments.length,l=new Array(c>2?c-2:0),v=2;v<c;v++)l[v-2]=arguments[v];var d=a.write.apply(a,[function(n){return m(o(r,n))},function(o){for(var c,l=arguments.length,v=new Array(l>1?l-1:0),d=1;d<l;d++)v[d-1]=arguments[d];if(u(a,o)){if(!f(o))throw new Error("atom not writable");var s=e(o),m="v"in s,y=s.v,p=v[0];t(o,s,p),k(r,o,s),m&&Object.is(y,s.v)||(w(r,o,s),i(r,o))}else c=n.apply(void 0,[r,o].concat(v));return b(r),c}].concat(l));return d},A=function(n){for(var e=h(),t=arguments.length,r=new Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];var a=S.apply(void 0,[e,n].concat(r));return b(e),a},k=function(n,e,t){if(t.m&&!y(t)){for(var r,o=a(t.d.keys());!(r=o()).done;){var i=r.value;if(!t.m.d.has(i))j(n,i).t.add(e),t.m.d.add(i)}for(var u,f=a(t.m.d||[]);!(u=f()).done;){var c=u.value;if(!t.d.has(c)){var l=E(n,c);null==l||l.t.delete(e),t.m.d.delete(c)}}}},j=function n(t,r){var i=e(r);if(!i.m){o(t,r);for(var u,f=a(i.d.keys());!(u=f()).done;){var l=u.value;n(t,l).t.add(r)}if(i.m={l:new Set,d:new Set(i.d.keys()),t:new Set},c(r)&&r.onMount){var v=i.m,d=r.onMount;g(t,(function(){var n=d((function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];return S.apply(void 0,[t,r].concat(e))}));n&&(v.u=n)}))}}return i.m},E=function n(t,r){var o=e(r);if(!o.m||o.m.l.size||Array.from(o.m.t).some((function(n){return e(n).m})))return o.m;var i=o.m.u;i&&g(t,i),delete o.m;for(var u,f=a(o.d.keys());!(u=f()).done;){var c=n(t,u.value);null==c||c.t.delete(r)}var v=y(o);v&&v[l](void 0,(function(){}))};return{get:function(n){return m(o(void 0,n))},set:A,sub:function(n,e){var t=h(),r=j(t,n);b(t);var o=r.l;return o.add(e),function(){o.delete(e);var t=h();E(t,n),b(t)}}}};n.atom=function(n,o){var a="atom"+ ++e,i={toString:function(){return a}};return"function"==typeof n?i.read=n:(i.init=n,i.read=t,i.write=r),o&&(i.write=o),i},n.createStore=S,n.getDefaultStore=function(){return i||(i=S()),i}}));

@@ -43,29 +43,20 @@ 'use client';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -75,2 +66,9 @@ }

}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -77,0 +75,0 @@ var hydratedMap = new WeakMap();

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("jotai/react"),require("jotai/vanilla/utils"),require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","react","jotai/react","jotai/vanilla/utils","jotai/vanilla"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiReactUtils={},t.React,t.jotaiReact,t.jotaiVanillaUtils,t.jotaiVanilla)}(this,(function(t,e,r,n,a){"use strict";function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t))||e){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=new WeakMap;var l=function(t){var e=u.get(t);return e||(e=new WeakSet,u.set(t,e)),e};t.useAtomCallback=function(t,n){var o=e.useMemo((function(){return a.atom(null,(function(e,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),o=2;o<n;o++)a[o-2]=arguments[o];return t.apply(void 0,[e,r].concat(a))}))}),[t]);return r.useSetAtom(o,n)},t.useHydrateAtoms=function(t,e){for(var n,a=r.useStore(e),o=l(a),u=i(t);!(n=u()).done;){var c=n.value,s=c[0],f=c[1];(!o.has(s)||null!=e&&e.dangerouslyForceHydrate)&&(o.add(s),a.set(s,f))}},t.useReducerAtom=function(t,n,a){var o=r.useAtom(t,a),i=o[0],u=o[1];return[i,e.useCallback((function(t){u((function(e){return n(e,t)}))}),[u,n])]},t.useResetAtom=function(t,a){var o=r.useSetAtom(t,a);return e.useCallback((function(){return o(n.RESET)}),[o])}}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("jotai/react"),require("jotai/vanilla/utils"),require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","react","jotai/react","jotai/vanilla/utils","jotai/vanilla"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiReactUtils={},t.React,t.jotaiReact,t.jotaiVanillaUtils,t.jotaiVanilla)}(this,(function(t,e,r,n,a){"use strict";function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(r)return(r=r.call(t)).next.bind(r);if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t))||e){r&&(t=r);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u=new WeakMap;var l=function(t){var e=u.get(t);return e||(e=new WeakSet,u.set(t,e)),e};t.useAtomCallback=function(t,n){var o=e.useMemo((function(){return a.atom(null,(function(e,r){for(var n=arguments.length,a=new Array(n>2?n-2:0),o=2;o<n;o++)a[o-2]=arguments[o];return t.apply(void 0,[e,r].concat(a))}))}),[t]);return r.useSetAtom(o,n)},t.useHydrateAtoms=function(t,e){for(var n,a=r.useStore(e),o=l(a),u=i(t);!(n=u()).done;){var c=n.value,s=c[0],f=c[1];(!o.has(s)||null!=e&&e.dangerouslyForceHydrate)&&(o.add(s),a.set(s,f))}},t.useReducerAtom=function(t,n,a){var o=r.useAtom(t,a),i=o[0],u=o[1];return[i,e.useCallback((function(t){u((function(e){return n(e,t)}))}),[u,n])]},t.useResetAtom=function(t,a){var o=r.useSetAtom(t,a);return e.useCallback((function(){return o(n.RESET)}),[o])}}));

@@ -34,29 +34,20 @@ (function (global, factory) {

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -66,2 +57,9 @@ }

}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -137,5 +135,3 @@ var isSelfAtom = function isSelfAtom(atom, a) {

if (!pendingMap.has(a)) {
var _pendingStack;
var aState = getAtomState(a);
(_pendingStack = pendingStack[pendingStack.length - 1]) == null || _pendingStack.add(a);
pendingMap.set(a, [aState, new Set()]);

@@ -150,2 +146,3 @@ if (aState) {

var setAtomState = function setAtomState(atom, atomState) {
var _pendingStack;
{

@@ -156,5 +153,4 @@ Object.freeze(atomState);

atomStateMap.set(atom, atomState);
(_pendingStack = pendingStack[pendingStack.length - 1]) == null || _pendingStack.add(atom);
if (!pendingMap.has(atom)) {
var _pendingStack2;
(_pendingStack2 = pendingStack[pendingStack.length - 1]) == null || _pendingStack2.add(atom);
pendingMap.set(atom, [prevAtomState, new Set()]);

@@ -161,0 +157,0 @@ addPendingDependent(atom, atomState);

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).jotaiVanilla={})}(this,(function(n){"use strict";var t=0;function r(n){return n(this)}function e(n,t,r){return t(this,"function"==typeof r?r(n(this)):r)}function i(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function o(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(r)return(r=r.call(n)).next.bind(r);if(Array.isArray(n)||(r=function(n,t){if(n){if("string"==typeof n)return i(n,t);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(n,t):void 0}}(n))||t){r&&(n=r);var e=0;return function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=function(n,t){return n.unstable_is?n.unstable_is(t):t===n},f=function(n){return"init"in n},c=function(n){return!!n.write},v=new WeakMap,l=function(n,t){var r=v.get(n);r&&(v.delete(n),r(t))},d=function(n,t){n.status="fulfilled",n.value=t},s=function(n,t){n.status="rejected",n.reason=t},h=function(n,t){return!!n&&"v"in n&&"v"in t&&Object.is(n.v,t.v)},p=function(n,t){return!!n&&"e"in n&&"e"in t&&Object.is(n.e,t.e)},g=function(n){return!!n&&"v"in n&&n.v instanceof Promise},w=function(n){if("e"in n)throw n.e;return n.v},y=function(){var n=new WeakMap,t=new WeakMap,r=[],e=new WeakMap,i=function(t){return n.get(t)},a=function n(t,o){o.d.forEach((function(o,a){if(!e.has(a)){var u,f=i(a);null==(u=r[r.length-1])||u.add(a),e.set(a,[f,new Set]),f&&n(a,f)}e.get(a)[1].add(t)}))},y=function(t,o){var u,f=i(t);(n.set(t,o),e.has(t))||(null==(u=r[r.length-1])||u.add(t),e.set(t,[f,new Set]),a(t,o));if(g(f)){var c="v"in o?o.v instanceof Promise?o.v:Promise.resolve(o.v):Promise.reject(o.e);f.v!==c&&l(f.v,c)}},b=function(n,t,r,e){var i=new Map(e?t.d:null),o=!1;r.forEach((function(r,e){!r&&u(n,e)&&(r=t),r&&(i.set(e,r),t.d.get(e)!==r&&(o=!0))})),(o||t.d.size!==i.size)&&(t.d=i)},m=function(n,t,r,e){var o,a,u=i(n),f={d:(null==u?void 0:u.d)||new Map,v:t};if(r&&b(n,f,r,e),h(u,f)&&u.d===f.d)return u;if(g(u)&&g(f)&&(a=f,"v"in(o=u)&&"v"in a&&o.v.orig&&o.v.orig===a.v.orig)){if(u.d===f.d)return u;f.v=u.v}return y(n,f),f},S=function(n,r,e,o){if("function"==typeof(null==(c=r)?void 0:c.then)){var a,u=function(){var r=i(n);if(g(r)&&r.v===f){var o=m(n,f,e);t.has(n)&&r.d!==o.d&&P(n,o,r.d)}},f=new Promise((function(n,t){var e=!1;r.then((function(t){e||(e=!0,d(f,t),n(t),u())}),(function(n){e||(e=!0,s(f,n),t(n),u())})),a=function(t){e||(e=!0,t.then((function(n){return d(f,n)}),(function(n){return s(f,n)})),n(t))}}));return f.orig=r,f.status="pending",function(n,t){v.set(n,t),n.catch((function(){})).finally((function(){return v.delete(n)}))}(f,(function(n){n&&a(n),null==o||o()})),m(n,f,e,!0)}var c;return m(n,r,e)},E=function n(r,e){var o=i(r);if((null==e||!e(r))&&o){if(t.has(r))return o;if(Array.from(o.d).every((function(t){var i=t[0],o=t[1];if(i===r)return!0;var a=n(i,e);return a===o||h(a,o)})))return o}var a,v,l=new Map,d=!0,s={get signal(){return a||(a=new AbortController),a.signal},get setSelf(){return!v&&c(r)&&(v=function(){if(!d){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}}),v}};try{var g=r.read((function(t){if(u(r,t)){var o=i(t);if(o)return l.set(t,o),w(o);if(f(t))return l.set(t,void 0),t.init;throw new Error("no atom init")}var a=n(t,e);return l.set(t,a),w(a)}),s);return S(r,g,l,(function(){var n;return null==(n=a)?void 0:n.abort()}))}catch(n){return function(n,t,r){var e=i(n),o={d:(null==e?void 0:e.d)||new Map,e:t};return r&&b(n,o,r),p(e,o)&&e.d===o.d?e:(y(n,o),o)}(r,n,l)}finally{d=!1}},A=function(n){var r=new Array,u=new Set;!function n(i){if(!u.has(i)){u.add(i);for(var a,f=o(function(n){var r,i,o=new Set(null==(r=t.get(n))?void 0:r.t);return null==(i=e.get(n))||i[1].forEach((function(n){o.add(n)})),o}(i));!(a=f()).done;){var c=a.value;i!==c&&n(c)}r.push(i)}}(n);for(var f=new Set([n]),c=function(n){return u.has(n)},v=r.length-1;v>=0;--v){var l=r[v],d=i(l);if(d){for(var s,p=!1,g=o(d.d.keys());!(s=g()).done;){var w=s.value;if(w!==l&&f.has(w)){p=!0;break}}if(p){var y=E(l,c);a(l,y),h(d,y)||f.add(l)}u.delete(l)}}},M=function n(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var c=t.write.apply(t,[function(n){return w(E(n))},function(e){var o,a=r.length>0;a||r.push(new Set([e]));for(var c=arguments.length,v=new Array(c>1?c-1:0),l=1;l<c;l++)v[l-1]=arguments[l];if(u(t,e)){if(!f(e))throw new Error("atom not writable");var d=i(e),s=S(e,v[0]);h(d,s)||A(e)}else o=n.apply(void 0,[e].concat(v));return a||x(r.pop()),o}].concat(o));return c},j=function(n){r.push(new Set([n]));for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var o=M.apply(void 0,[n].concat(e));return x(r.pop()),o},k=function n(r,e,o){var a,u=t.get(r);if(u)return e&&u.t.add(e),u;var f=o||[];null==(a=i(r))||a.d.forEach((function(t,e){e!==r&&n(e,r,f)})),E(r);var v={t:new Set(e&&[e]),l:new Set};if(t.set(r,v),c(r)&&r.onMount){var l=r.onMount;f.push((function(){var n=l((function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}));n&&(v.u=n)}))}return o||f.forEach((function(n){return n()})),v},z=function n(r,e){if(function(n,t){return!t.l.size&&(!t.t.size||1===t.t.size&&t.t.has(n))}(r,e)){var o=e.u;o&&o(),t.delete(r);var a=i(r);a&&(g(a)&&l(a.v),a.d.forEach((function(e,i){if(i!==r){var o=t.get(i);o&&(o.t.delete(r),n(i,o))}})))}},P=function(n,r,e){var i=new Set(r.d.keys()),o=new Set;null==e||e.forEach((function(r,e){if(i.has(e))i.delete(e);else{o.add(e);var a=t.get(e);a&&a.t.delete(n)}})),i.forEach((function(t){k(t,n)})),o.forEach((function(n){var r=t.get(n);r&&z(n,r)}))},x=function(n){var r=[];n.forEach((function n(t){var o;if(e.has(t)){var a=e.get(t),u=a[0],f=a[1];e.delete(t),r.push([t,u]),f.forEach(n),null==(o=i(t))||o.d.forEach((function(t,r){return n(r)}))}})),r.forEach((function(n){var r=n[0],e=n[1],o=i(r);if(o&&o!==e){var a=t.get(r);a&&o.d!==(null==e?void 0:e.d)&&P(r,o,null==e?void 0:e.d),a&&(g(e)||!h(e,o)&&!p(e,o))&&a.l.forEach((function(n){return n()}))}}))};return{get:function(n){return w(E(n))},set:j,sub:function(n,t){var r=k(n);x([n]);var e=r.l;return e.add(t),function(){e.delete(t),z(n,r)}}}},b=y,m=function(){return a||(a=y()),a};n.atom=function(n,i){var o="atom"+ ++t,a={toString:function(){return o}};return"function"==typeof n?a.read=n:(a.init=n,a.read=r,a.write=e),i&&(a.write=i),a},n.createStore=b,n.getDefaultStore=m}));
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((n="undefined"!=typeof globalThis?globalThis:n||self).jotaiVanilla={})}(this,(function(n){"use strict";var t=0;function r(n){return n(this)}function e(n,t,r){return t(this,"function"==typeof r?r(n(this)):r)}function i(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=Array(t);r<t;r++)e[r]=n[r];return e}function o(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(r)return(r=r.call(n)).next.bind(r);if(Array.isArray(n)||(r=function(n,t){if(n){if("string"==typeof n)return i(n,t);var r={}.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(n,t):void 0}}(n))||t){r&&(n=r);var e=0;return function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=function(n,t){return n.unstable_is?n.unstable_is(t):t===n},f=function(n){return"init"in n},c=function(n){return!!n.write},v=new WeakMap,l=function(n,t){var r=v.get(n);r&&(v.delete(n),r(t))},d=function(n,t){n.status="fulfilled",n.value=t},s=function(n,t){n.status="rejected",n.reason=t},h=function(n,t){return!!n&&"v"in n&&"v"in t&&Object.is(n.v,t.v)},p=function(n,t){return!!n&&"e"in n&&"e"in t&&Object.is(n.e,t.e)},g=function(n){return!!n&&"v"in n&&n.v instanceof Promise},w=function(n){if("e"in n)throw n.e;return n.v},y=function(){var n=new WeakMap,t=new WeakMap,r=[],e=new WeakMap,i=function(t){return n.get(t)},a=function n(t,r){r.d.forEach((function(r,o){if(!e.has(o)){var a=i(o);e.set(o,[a,new Set]),a&&n(o,a)}e.get(o)[1].add(t)}))},y=function(t,o){var u,f=i(t);if(n.set(t,o),null==(u=r[r.length-1])||u.add(t),e.has(t)||(e.set(t,[f,new Set]),a(t,o)),g(f)){var c="v"in o?o.v instanceof Promise?o.v:Promise.resolve(o.v):Promise.reject(o.e);f.v!==c&&l(f.v,c)}},m=function(n,t,r,e){var i=new Map(e?t.d:null),o=!1;r.forEach((function(r,e){!r&&u(n,e)&&(r=t),r&&(i.set(e,r),t.d.get(e)!==r&&(o=!0))})),(o||t.d.size!==i.size)&&(t.d=i)},b=function(n,t,r,e){var o,a,u=i(n),f={d:(null==u?void 0:u.d)||new Map,v:t};if(r&&m(n,f,r,e),h(u,f)&&u.d===f.d)return u;if(g(u)&&g(f)&&(a=f,"v"in(o=u)&&"v"in a&&o.v.orig&&o.v.orig===a.v.orig)){if(u.d===f.d)return u;f.v=u.v}return y(n,f),f},S=function(n,r,e,o){if("function"==typeof(null==(c=r)?void 0:c.then)){var a,u=function(){var r=i(n);if(g(r)&&r.v===f){var o=b(n,f,e);t.has(n)&&r.d!==o.d&&P(n,o,r.d)}},f=new Promise((function(n,t){var e=!1;r.then((function(t){e||(e=!0,d(f,t),n(t),u())}),(function(n){e||(e=!0,s(f,n),t(n),u())})),a=function(t){e||(e=!0,t.then((function(n){return d(f,n)}),(function(n){return s(f,n)})),n(t))}}));return f.orig=r,f.status="pending",function(n,t){v.set(n,t),n.catch((function(){})).finally((function(){return v.delete(n)}))}(f,(function(n){n&&a(n),null==o||o()})),b(n,f,e,!0)}var c;return b(n,r,e)},E=function n(r,e){var o=i(r);if((null==e||!e(r))&&o){if(t.has(r))return o;if(Array.from(o.d).every((function(t){var i=t[0],o=t[1];if(i===r)return!0;var a=n(i,e);return a===o||h(a,o)})))return o}var a,v,l=new Map,d=!0,s={get signal(){return a||(a=new AbortController),a.signal},get setSelf(){return!v&&c(r)&&(v=function(){if(!d){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}}),v}};try{var g=r.read((function(t){if(u(r,t)){var o=i(t);if(o)return l.set(t,o),w(o);if(f(t))return l.set(t,void 0),t.init;throw new Error("no atom init")}var a=n(t,e);return l.set(t,a),w(a)}),s);return S(r,g,l,(function(){var n;return null==(n=a)?void 0:n.abort()}))}catch(n){return function(n,t,r){var e=i(n),o={d:(null==e?void 0:e.d)||new Map,e:t};return r&&m(n,o,r),p(e,o)&&e.d===o.d?e:(y(n,o),o)}(r,n,l)}finally{d=!1}},A=function(n){var r=new Array,u=new Set;!function n(i){if(!u.has(i)){u.add(i);for(var a,f=o(function(n){var r,i,o=new Set(null==(r=t.get(n))?void 0:r.t);return null==(i=e.get(n))||i[1].forEach((function(n){o.add(n)})),o}(i));!(a=f()).done;){var c=a.value;i!==c&&n(c)}r.push(i)}}(n);for(var f=new Set([n]),c=function(n){return u.has(n)},v=r.length-1;v>=0;--v){var l=r[v],d=i(l);if(d){for(var s,p=!1,g=o(d.d.keys());!(s=g()).done;){var w=s.value;if(w!==l&&f.has(w)){p=!0;break}}if(p){var y=E(l,c);a(l,y),h(d,y)||f.add(l)}u.delete(l)}}},M=function n(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),a=1;a<e;a++)o[a-1]=arguments[a];var c=t.write.apply(t,[function(n){return w(E(n))},function(e){var o,a=r.length>0;a||r.push(new Set([e]));for(var c=arguments.length,v=new Array(c>1?c-1:0),l=1;l<c;l++)v[l-1]=arguments[l];if(u(t,e)){if(!f(e))throw new Error("atom not writable");var d=i(e),s=S(e,v[0]);h(d,s)||A(e)}else o=n.apply(void 0,[e].concat(v));return a||x(r.pop()),o}].concat(o));return c},j=function(n){r.push(new Set([n]));for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];var o=M.apply(void 0,[n].concat(e));return x(r.pop()),o},k=function n(r,e,o){var a,u=t.get(r);if(u)return e&&u.t.add(e),u;var f=o||[];null==(a=i(r))||a.d.forEach((function(t,e){e!==r&&n(e,r,f)})),E(r);var v={t:new Set(e&&[e]),l:new Set};if(t.set(r,v),c(r)&&r.onMount){var l=r.onMount;f.push((function(){var n=l((function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];return j.apply(void 0,[r].concat(t))}));n&&(v.u=n)}))}return o||f.forEach((function(n){return n()})),v},z=function n(r,e){if(function(n,t){return!t.l.size&&(!t.t.size||1===t.t.size&&t.t.has(n))}(r,e)){var o=e.u;o&&o(),t.delete(r);var a=i(r);a&&(g(a)&&l(a.v),a.d.forEach((function(e,i){if(i!==r){var o=t.get(i);o&&(o.t.delete(r),n(i,o))}})))}},P=function(n,r,e){var i=new Set(r.d.keys()),o=new Set;null==e||e.forEach((function(r,e){if(i.has(e))i.delete(e);else{o.add(e);var a=t.get(e);a&&a.t.delete(n)}})),i.forEach((function(t){k(t,n)})),o.forEach((function(n){var r=t.get(n);r&&z(n,r)}))},x=function(n){var r=[];n.forEach((function n(t){var o;if(e.has(t)){var a=e.get(t),u=a[0],f=a[1];e.delete(t),r.push([t,u]),f.forEach(n),null==(o=i(t))||o.d.forEach((function(t,r){return n(r)}))}})),r.forEach((function(n){var r=n[0],e=n[1],o=i(r);if(o&&o!==e){var a=t.get(r);a&&o.d!==(null==e?void 0:e.d)&&P(r,o,null==e?void 0:e.d),a&&(g(e)||!h(e,o)&&!p(e,o))&&a.l.forEach((function(n){return n()}))}}))};return{get:function(n){return w(E(n))},set:j,sub:function(n,t){var r=k(n);x([n]);var e=r.l;return e.add(t),function(){e.delete(t),z(n,r)}}}},m=y,b=function(){return a||(a=y()),a};n.atom=function(n,i){var o="atom"+ ++t,a={toString:function(){return o}};return"function"==typeof n?a.read=n:(a.init=n,a.read=r,a.write=e),i&&(a.write=i),a},n.createStore=m,n.getDefaultStore=b}));

@@ -23,43 +23,20 @@ (function (global, factory) {

function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -69,2 +46,18 @@ }

}
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -398,2 +391,3 @@ function atomFamily(initializeAtom, areEqual) {

function createJSONStorage(getStringStorage, options) {
var _getStringStorage4;
if (getStringStorage === void 0) {

@@ -445,16 +439,21 @@ getStringStorage = function getStringStorage() {

};
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage) {
storage.subscribe = function (key, callback, initialValue) {
if (!(getStringStorage() instanceof window.Storage)) {
return function () {};
}
var createHandleSubscribe = function createHandleSubscribe(subscriber) {
return function (key, callback, initialValue) {
return subscriber(key, function (v) {
var newValue;
try {
newValue = JSON.parse(v || '');
} catch (_unused2) {
newValue = initialValue;
}
callback(newValue);
});
};
};
var subscriber = (_getStringStorage4 = getStringStorage()) == null ? void 0 : _getStringStorage4.subscribe;
if (!subscriber && typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage && getStringStorage() instanceof window.Storage) {
subscriber = function subscriber(key, callback) {
var storageEventCallback = function storageEventCallback(e) {
if (e.storageArea === getStringStorage() && e.key === key) {
var newValue;
try {
newValue = JSON.parse(e.newValue || '');
} catch (_unused2) {
newValue = initialValue;
}
callback(newValue);
callback(e.newValue);
}

@@ -468,2 +467,5 @@ };

}
if (subscriber) {
storage.subscribe = createHandleSubscribe(subscriber);
}
return storage;

@@ -470,0 +472,0 @@ }

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

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiVanillaUtils={},t.jotaiVanilla)}(this,(function(t,n){"use strict";var e=Symbol("");function r(){return r=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},r.apply(this,arguments)}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}function i(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return o(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,n):void 0}}(t))||n){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},u=new WeakMap;var f=new WeakSet,c=function t(n){if("object"==typeof n&&null!==n){Object.freeze(n);for(var e,r=i(Object.getOwnPropertyNames(n));!(e=r()).done;){t(n[e.value])}return n}};function l(t){if(f.has(t))return t;f.add(t);var n=t.read;if(t.read=function(t,e){return c(n.call(this,t,e))},"write"in t){var e=t.write;t.write=function(n,r){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];return e.call.apply(e,[this,n,function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];return e[0]===t&&(e[1]=c(e[1])),r.apply(void 0,e)}].concat(i))}}return t}var s=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},v=new WeakMap,d={},m=function(t){return!!t.write};var h=function(t){return"function"==typeof(null==t?void 0:t.then)};function p(t,n){var e,r;void 0===t&&(t=function(){try{return window.localStorage}catch(t){return}});var o={getItem:function(o,i){var a,u,f=function(t){if(e!==(t=t||"")){try{r=JSON.parse(t,null==n?void 0:n.reviver)}catch(t){return i}e=t}return r},c=null!=(a=null==(u=t())?void 0:u.getItem(o))?a:null;return h(c)?c.then(f):f(c)},setItem:function(e,r){var o;return null==(o=t())?void 0:o.setItem(e,JSON.stringify(r,null==n?void 0:n.replacer))},removeItem:function(n){var e;return null==(e=t())?void 0:e.removeItem(n)}};return"undefined"!=typeof window&&"function"==typeof window.addEventListener&&window.Storage&&(o.subscribe=function(n,e,r){if(!(t()instanceof window.Storage))return function(){};var o=function(o){if(o.storageArea===t()&&o.key===n){var i;try{i=JSON.parse(o.newValue||"")}catch(t){i=r}e(i)}};return window.addEventListener("storage",o),function(){window.removeEventListener("storage",o)}}),o}var y=p();var b=new WeakMap,w={state:"loading"};var g=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},O=new WeakMap,k=function(){};t.RESET=e,t.atomFamily=function(t,n){var e=null,r=new Map,o=function o(a){var u;if(void 0===n)u=r.get(a);else for(var f,c=i(r);!(f=c()).done;){var l=f.value,s=l[0],v=l[1];if(n(s,a)){u=v;break}}if(void 0!==u){if(null==e||!e(u[1],a))return u[0];o.remove(a)}var d=t(a);return r.set(a,[d,Date.now()]),d};return o.remove=function(t){if(void 0===n)r.delete(t);else for(var e,o=i(r);!(e=o()).done;){var a=e.value[0];if(n(a,t)){r.delete(a);break}}},o.setShouldRemove=function(t){if(e=t)for(var n,o=i(r);!(n=o()).done;){var a=n.value,u=a[0],f=a[1];e(f[1],u)&&r.delete(u)}},o},t.atomWithDefault=function(t){var r=Symbol(),o=n.atom(r),i=n.atom((function(n,e){var i=n(o);return i!==r?i:t(n,e)}),(function(t,n,a){if(a===e)n(o,r);else if("function"==typeof a){var u=t(i);n(o,a(u))}else n(o,a)}));return i},t.atomWithLazy=function(t){var e=n.atom(void 0);return delete e.init,Object.defineProperty(e,"init",{get:function(){return t()}}),e},t.atomWithObservable=function(t,e){var r=function(t){if("e"in t)throw t.e;return t.d},o=n.atom((function(r){var o,i,a,u=t(r),f=null==(o=(i=u)[Symbol.observable])?void 0:o.call(i);f&&(u=f);var c,l,s,v,d=function(){return new Promise((function(t){a=t}))},m=e&&"initialValue"in e?{d:"function"==typeof e.initialValue?e.initialValue():e.initialValue}:d(),h=function(t){l=t,null==a||a(t),null==c||c(t)},p=function(){return!c},y=function(){s&&(clearTimeout(v),s.unsubscribe()),s=u.subscribe({next:function(t){return h({d:t})},error:function(t){return h({e:t})},complete:function(){}}),p()&&null!=e&&e.unstable_timeout&&(v=setTimeout((function(){s&&(s.unsubscribe(),s=void 0)}),e.unstable_timeout))};y();var b=n.atom(l||m);return b.onMount=function(t){return c=t,l&&t(l),s?clearTimeout(v):y(),function(){c=void 0,s&&(s.unsubscribe(),s=void 0)}},[b,u,d,y,p]}));return n.atom((function(t){var n=t(o),e=t(n[0]);return e instanceof Promise?e.then(r):r(e)}),(function(t,n,e){var r=t(o),i=r[0],a=r[1],u=r[2],f=r[3],c=r[4];if(!("next"in a))throw new Error("observable is not subject");c()&&(n(i,u()),f()),a.next(e)}))},t.atomWithReducer=function(t,e){return n.atom(t,(function(t,n,r){n(this,e(t(this),r))}))},t.atomWithRefresh=function(t,e){var r=n.atom(0);return n.atom((function(n,e){return n(r),t(n,e)}),(function(t,n){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];if(0===i.length)n(r,(function(t){return t+1}));else if(e)return e.apply(void 0,[t,n].concat(i))}))},t.atomWithReset=function(t){var r=n.atom(t,(function(n,o,i){var a="function"==typeof i?i(n(r)):i;o(r,a===e?t:a)}));return r},t.atomWithStorage=function(t,r,o,i){void 0===o&&(o=y);var a=null==i?void 0:i.getOnInit,u=n.atom(a?o.getItem(t,r):r);return u.onMount=function(n){var e;return n(o.getItem(t,r)),o.subscribe&&(e=o.subscribe(t,n,r)),e},n.atom((function(t){return t(u)}),(function(n,i,a){var f="function"==typeof a?a(n(u)):a;return f===e?(i(u,r),o.removeItem(t)):f instanceof Promise?f.then((function(n){return i(u,n),o.setItem(t,n)})):(i(u,f),o.setItem(t,f))}))},t.createJSONStorage=p,t.freezeAtom=l,t.freezeAtomCreator=function(t){return function(){return l(t.apply(void 0,arguments))}},t.loadable=function(t){return e=function(){var e=new WeakMap,r=n.atom(0),o=n.atom((function(n,o){var i,a=o.setSelf;n(r);try{i=n(t)}catch(t){return{state:"hasError",error:t}}if(!(i instanceof Promise))return{state:"hasData",data:i};var u=i,f=e.get(u);if(f)return f;"fulfilled"===u.status?e.set(u,{state:"hasData",data:u.value}):"rejected"===u.status?e.set(u,{state:"hasError",error:u.reason}):u.then((function(t){e.set(u,{state:"hasData",data:t})}),(function(t){e.set(u,{state:"hasError",error:t})})).finally(a);var c=e.get(u);return c||(e.set(u,w),w)}),(function(t,n){n(r,(function(t){return t+1}))}));return n.atom((function(t){return t(o)}))},r=t,(b.has(r)?b:b.set(r,e())).get(r);var e,r},t.selectAtom=function(t,e,r){return void 0===r&&(r=Object.is),o=function(){var o=Symbol(),i=n.atom((function(n){var a=n(i);return function(t){var n=t[0],i=t[1];if(i===o)return e(n);var a=e(n,i);return r(i,a)?i:a}([n(t),a])}));return i.init=o,i},i=e,f=r,c=a((function(){return new WeakMap}),u,t),l=a((function(){return new WeakMap}),c,i),a(o,l,f);var o,i,f,c,l},t.splitAtom=function(t,e){return r=function(){var r=new WeakMap,o=function o(a,u){var f=r.get(a);if(f)return f;var c=u&&r.get(u),l=[],s=[];return a.forEach((function(r,u){var f=e?e(r):u;s[u]=f;var v=c&&c.atomList[c.keyList.indexOf(f)];if(v)l[u]=v;else{var d=function(n){var e=n(i),r=n(t),u=o(r,null==e?void 0:e.arr).keyList.indexOf(f);if(u<0||u>=r.length){var c=a[o(a).keyList.indexOf(f)];if(c)return c;throw new Error("splitAtom: index out of bounds for read")}return r[u]};l[u]=m(t)?n.atom(d,(function(n,e,r){var a=n(i),u=n(t),c=o(u,null==a?void 0:a.arr).keyList.indexOf(f);if(c<0||c>=u.length)throw new Error("splitAtom: index out of bounds for write");var l="function"==typeof r?r(u[c]):r;Object.is(u[c],l)||e(t,[].concat(u.slice(0,c),[l],u.slice(c+1)))})):n.atom(d)}})),f=c&&c.keyList.length===s.length&&c.keyList.every((function(t,n){return t===s[n]}))?c:{arr:a,atomList:l,keyList:s},r.set(a,f),f},i=n.atom((function(n){var e=n(i),r=n(t);return o(r,null==e?void 0:e.arr)}));i.init=void 0;var a=m(t)?n.atom((function(t){return t(i).atomList}),(function(n,e,r){switch(r.type){case"remove":var o=n(a).indexOf(r.atom);if(o>=0){var i=n(t);e(t,[].concat(i.slice(0,o),i.slice(o+1)))}break;case"insert":var u=r.before?n(a).indexOf(r.before):n(a).length;if(u>=0){var f=n(t);e(t,[].concat(f.slice(0,u),[r.value],f.slice(u)))}break;case"move":var c=n(a).indexOf(r.atom),l=r.before?n(a).indexOf(r.before):n(a).length;if(c>=0&&l>=0){var s=n(t);e(t,c<l?[].concat(s.slice(0,c),s.slice(c+1,l),[s[c]],s.slice(l)):[].concat(s.slice(0,l),[s[c]],s.slice(l,c),s.slice(c+1)))}}})):n.atom((function(t){return t(i).atomList}));return a},o=e||d,i=s((function(){return new WeakMap}),v,t),s(r,i,o);var r,o,i},t.unstable_withStorageValidator=function(t){return function(n){return r({},n,{getItem:function(e,r){var o=function(n){return t(n)?n:r},i=n.getItem(e,r);return h(i)?i.then(o):o(i)}})}},t.unwrap=function(t,e){return void 0===e&&(e=k),r=function(){var r=new WeakMap,o=new WeakMap,i=n.atom(0),a=n.atom((function(n,u){var f=u.setSelf;n(i);var c=n(a),l=n(t);if(!(l instanceof Promise))return{v:l};if(l!==(null==c?void 0:c.p)&&("fulfilled"===l.status?o.set(l,l.value):"rejected"===l.status?r.set(l,l.reason):l.then((function(t){return o.set(l,t)}),(function(t){return r.set(l,t)})).finally(f)),r.has(l))throw r.get(l);return o.has(l)?{p:l,v:o.get(l)}:c&&"v"in c?{p:l,f:e(c.v),v:c.v}:{p:l,f:e()}}),(function(t,n){n(i,(function(t){return t+1}))}));return a.init=void 0,n.atom((function(t){var n=t(a);return"f"in n?n.f:n.v}),(function(n,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(void 0,[t].concat(o))}))},o=e,i=g((function(){return new WeakMap}),O,t),g(r,i,o);var r,o,i}}));
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("jotai/vanilla")):"function"==typeof define&&define.amd?define(["exports","jotai/vanilla"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiVanillaUtils={},t.jotaiVanilla)}(this,(function(t,n){"use strict";var e=Symbol("");function r(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=Array(n);e<n;e++)r[e]=t[e];return r}function o(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return r(t,n);var e={}.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?r(t,n):void 0}}(t))||n){e&&(t=e);var o=0;return function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(){return i=Object.assign?Object.assign.bind():function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)({}).hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},i.apply(null,arguments)}var a=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},u=new WeakMap;var f=new WeakSet,c=function t(n){if("object"==typeof n&&null!==n){Object.freeze(n);for(var e,r=o(Object.getOwnPropertyNames(n));!(e=r()).done;){t(n[e.value])}return n}};function l(t){if(f.has(t))return t;f.add(t);var n=t.read;if(t.read=function(t,e){return c(n.call(this,t,e))},"write"in t){var e=t.write;t.write=function(n,r){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];return e.call.apply(e,[this,n,function(){for(var n=arguments.length,e=new Array(n),o=0;o<n;o++)e[o]=arguments[o];return e[0]===t&&(e[1]=c(e[1])),r.apply(void 0,e)}].concat(i))}}return t}var s=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},v=new WeakMap,d={},m=function(t){return!!t.write};var h=function(t){return"function"==typeof(null==t?void 0:t.then)};function p(t,n){var e,r,o;void 0===t&&(t=function(){try{return window.localStorage}catch(t){return}});var i={getItem:function(e,i){var a,u,f=function(t){if(r!==(t=t||"")){try{o=JSON.parse(t,null==n?void 0:n.reviver)}catch(t){return i}r=t}return o},c=null!=(a=null==(u=t())?void 0:u.getItem(e))?a:null;return h(c)?c.then(f):f(c)},setItem:function(e,r){var o;return null==(o=t())?void 0:o.setItem(e,JSON.stringify(r,null==n?void 0:n.replacer))},removeItem:function(n){var e;return null==(e=t())?void 0:e.removeItem(n)}},a=null==(e=t())?void 0:e.subscribe;return!a&&"undefined"!=typeof window&&"function"==typeof window.addEventListener&&window.Storage&&t()instanceof window.Storage&&(a=function(n,e){var r=function(r){r.storageArea===t()&&r.key===n&&e(r.newValue)};return window.addEventListener("storage",r),function(){window.removeEventListener("storage",r)}}),a&&(i.subscribe=function(t){return function(n,e,r){return t(n,(function(t){var n;try{n=JSON.parse(t||"")}catch(t){n=r}e(n)}))}}(a)),i}var b=p();var y=new WeakMap,w={state:"loading"};var g=function(t,n,e){return(n.has(e)?n:n.set(e,t())).get(e)},k=new WeakMap,O=function(){};t.RESET=e,t.atomFamily=function(t,n){var e=null,r=new Map,i=function i(a){var u;if(void 0===n)u=r.get(a);else for(var f,c=o(r);!(f=c()).done;){var l=f.value,s=l[0],v=l[1];if(n(s,a)){u=v;break}}if(void 0!==u){if(null==e||!e(u[1],a))return u[0];i.remove(a)}var d=t(a);return r.set(a,[d,Date.now()]),d};return i.remove=function(t){if(void 0===n)r.delete(t);else for(var e,i=o(r);!(e=i()).done;){var a=e.value[0];if(n(a,t)){r.delete(a);break}}},i.setShouldRemove=function(t){if(e=t)for(var n,i=o(r);!(n=i()).done;){var a=n.value,u=a[0],f=a[1];e(f[1],u)&&r.delete(u)}},i},t.atomWithDefault=function(t){var r=Symbol(),o=n.atom(r),i=n.atom((function(n,e){var i=n(o);return i!==r?i:t(n,e)}),(function(t,n,a){if(a===e)n(o,r);else if("function"==typeof a){var u=t(i);n(o,a(u))}else n(o,a)}));return i},t.atomWithLazy=function(t){var e=n.atom(void 0);return delete e.init,Object.defineProperty(e,"init",{get:function(){return t()}}),e},t.atomWithObservable=function(t,e){var r=function(t){if("e"in t)throw t.e;return t.d},o=n.atom((function(r){var o,i,a,u=t(r),f=null==(o=(i=u)[Symbol.observable])?void 0:o.call(i);f&&(u=f);var c,l,s,v,d=function(){return new Promise((function(t){a=t}))},m=e&&"initialValue"in e?{d:"function"==typeof e.initialValue?e.initialValue():e.initialValue}:d(),h=function(t){l=t,null==a||a(t),null==c||c(t)},p=function(){return!c},b=function(){s&&(clearTimeout(v),s.unsubscribe()),s=u.subscribe({next:function(t){return h({d:t})},error:function(t){return h({e:t})},complete:function(){}}),p()&&null!=e&&e.unstable_timeout&&(v=setTimeout((function(){s&&(s.unsubscribe(),s=void 0)}),e.unstable_timeout))};b();var y=n.atom(l||m);return y.onMount=function(t){return c=t,l&&t(l),s?clearTimeout(v):b(),function(){c=void 0,s&&(s.unsubscribe(),s=void 0)}},[y,u,d,b,p]}));return n.atom((function(t){var n=t(o),e=t(n[0]);return e instanceof Promise?e.then(r):r(e)}),(function(t,n,e){var r=t(o),i=r[0],a=r[1],u=r[2],f=r[3],c=r[4];if(!("next"in a))throw new Error("observable is not subject");c()&&(n(i,u()),f()),a.next(e)}))},t.atomWithReducer=function(t,e){return n.atom(t,(function(t,n,r){n(this,e(t(this),r))}))},t.atomWithRefresh=function(t,e){var r=n.atom(0);return n.atom((function(n,e){return n(r),t(n,e)}),(function(t,n){for(var o=arguments.length,i=new Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=arguments[a];if(0===i.length)n(r,(function(t){return t+1}));else if(e)return e.apply(void 0,[t,n].concat(i))}))},t.atomWithReset=function(t){var r=n.atom(t,(function(n,o,i){var a="function"==typeof i?i(n(r)):i;o(r,a===e?t:a)}));return r},t.atomWithStorage=function(t,r,o,i){void 0===o&&(o=b);var a=null==i?void 0:i.getOnInit,u=n.atom(a?o.getItem(t,r):r);return u.onMount=function(n){var e;return n(o.getItem(t,r)),o.subscribe&&(e=o.subscribe(t,n,r)),e},n.atom((function(t){return t(u)}),(function(n,i,a){var f="function"==typeof a?a(n(u)):a;return f===e?(i(u,r),o.removeItem(t)):f instanceof Promise?f.then((function(n){return i(u,n),o.setItem(t,n)})):(i(u,f),o.setItem(t,f))}))},t.createJSONStorage=p,t.freezeAtom=l,t.freezeAtomCreator=function(t){return function(){return l(t.apply(void 0,arguments))}},t.loadable=function(t){return e=function(){var e=new WeakMap,r=n.atom(0),o=n.atom((function(n,o){var i,a=o.setSelf;n(r);try{i=n(t)}catch(t){return{state:"hasError",error:t}}if(!(i instanceof Promise))return{state:"hasData",data:i};var u=i,f=e.get(u);if(f)return f;"fulfilled"===u.status?e.set(u,{state:"hasData",data:u.value}):"rejected"===u.status?e.set(u,{state:"hasError",error:u.reason}):u.then((function(t){e.set(u,{state:"hasData",data:t})}),(function(t){e.set(u,{state:"hasError",error:t})})).finally(a);var c=e.get(u);return c||(e.set(u,w),w)}),(function(t,n){n(r,(function(t){return t+1}))}));return n.atom((function(t){return t(o)}))},r=t,(y.has(r)?y:y.set(r,e())).get(r);var e,r},t.selectAtom=function(t,e,r){return void 0===r&&(r=Object.is),o=function(){var o=Symbol(),i=n.atom((function(n){var a=n(i);return function(t){var n=t[0],i=t[1];if(i===o)return e(n);var a=e(n,i);return r(i,a)?i:a}([n(t),a])}));return i.init=o,i},i=e,f=r,c=a((function(){return new WeakMap}),u,t),l=a((function(){return new WeakMap}),c,i),a(o,l,f);var o,i,f,c,l},t.splitAtom=function(t,e){return r=function(){var r=new WeakMap,o=function o(a,u){var f=r.get(a);if(f)return f;var c=u&&r.get(u),l=[],s=[];return a.forEach((function(r,u){var f=e?e(r):u;s[u]=f;var v=c&&c.atomList[c.keyList.indexOf(f)];if(v)l[u]=v;else{var d=function(n){var e=n(i),r=n(t),u=o(r,null==e?void 0:e.arr).keyList.indexOf(f);if(u<0||u>=r.length){var c=a[o(a).keyList.indexOf(f)];if(c)return c;throw new Error("splitAtom: index out of bounds for read")}return r[u]};l[u]=m(t)?n.atom(d,(function(n,e,r){var a=n(i),u=n(t),c=o(u,null==a?void 0:a.arr).keyList.indexOf(f);if(c<0||c>=u.length)throw new Error("splitAtom: index out of bounds for write");var l="function"==typeof r?r(u[c]):r;Object.is(u[c],l)||e(t,[].concat(u.slice(0,c),[l],u.slice(c+1)))})):n.atom(d)}})),f=c&&c.keyList.length===s.length&&c.keyList.every((function(t,n){return t===s[n]}))?c:{arr:a,atomList:l,keyList:s},r.set(a,f),f},i=n.atom((function(n){var e=n(i),r=n(t);return o(r,null==e?void 0:e.arr)}));i.init=void 0;var a=m(t)?n.atom((function(t){return t(i).atomList}),(function(n,e,r){switch(r.type){case"remove":var o=n(a).indexOf(r.atom);if(o>=0){var i=n(t);e(t,[].concat(i.slice(0,o),i.slice(o+1)))}break;case"insert":var u=r.before?n(a).indexOf(r.before):n(a).length;if(u>=0){var f=n(t);e(t,[].concat(f.slice(0,u),[r.value],f.slice(u)))}break;case"move":var c=n(a).indexOf(r.atom),l=r.before?n(a).indexOf(r.before):n(a).length;if(c>=0&&l>=0){var s=n(t);e(t,c<l?[].concat(s.slice(0,c),s.slice(c+1,l),[s[c]],s.slice(l)):[].concat(s.slice(0,l),[s[c]],s.slice(l,c),s.slice(c+1)))}}})):n.atom((function(t){return t(i).atomList}));return a},o=e||d,i=s((function(){return new WeakMap}),v,t),s(r,i,o);var r,o,i},t.unstable_withStorageValidator=function(t){return function(n){return i({},n,{getItem:function(e,r){var o=function(n){return t(n)?n:r},i=n.getItem(e,r);return h(i)?i.then(o):o(i)}})}},t.unwrap=function(t,e){return void 0===e&&(e=O),r=function(){var r=new WeakMap,o=new WeakMap,i=n.atom(0),a=n.atom((function(n,u){var f=u.setSelf;n(i);var c=n(a),l=n(t);if(!(l instanceof Promise))return{v:l};if(l!==(null==c?void 0:c.p)&&("fulfilled"===l.status?o.set(l,l.value):"rejected"===l.status?r.set(l,l.reason):l.then((function(t){return o.set(l,t)}),(function(t){return r.set(l,t)})).finally(f)),r.has(l))throw r.get(l);return o.has(l)?{p:l,v:o.get(l)}:c&&"v"in c?{p:l,f:e(c.v),v:c.v}:{p:l,f:e()}}),(function(t,n){n(i,(function(t){return t+1}))}));return a.init=void 0,n.atom((function(t){var n=t(a);return"f"in n?n.f:n.v}),(function(n,e){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return e.apply(void 0,[t].concat(o))}))},o=e,i=g((function(){return new WeakMap}),k,t),g(r,i,o);var r,o,i}}));

@@ -30,29 +30,20 @@ 'use strict';

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -62,2 +53,9 @@ }

}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -133,5 +131,3 @@ var isSelfAtom = function isSelfAtom(atom, a) {

if (!pendingMap.has(a)) {
var _pendingStack;
var aState = getAtomState(a);
(_pendingStack = pendingStack[pendingStack.length - 1]) == null || _pendingStack.add(a);
pendingMap.set(a, [aState, new Set()]);

@@ -146,2 +142,3 @@ if (aState) {

var setAtomState = function setAtomState(atom, atomState) {
var _pendingStack;
if (process.env.NODE_ENV !== 'production') {

@@ -152,5 +149,4 @@ Object.freeze(atomState);

atomStateMap.set(atom, atomState);
(_pendingStack = pendingStack[pendingStack.length - 1]) == null || _pendingStack.add(atom);
if (!pendingMap.has(atom)) {
var _pendingStack2;
(_pendingStack2 = pendingStack[pendingStack.length - 1]) == null || _pendingStack2.add(atom);
pendingMap.set(atom, [prevAtomState, new Set()]);

@@ -157,0 +153,0 @@ addPendingDependent(atom, atomState);

@@ -50,3 +50,2 @@ import type { Atom, WritableAtom } from './atom';

dev4_get_internal_weak_map: () => WeakMap<AnyAtom, AtomState>;
dev4_override_method: <K extends keyof PrdStore>(key: K, fn: PrdStore[K]) => void;
dev4_restore_atoms: (values: Iterable<readonly [AnyAtom, AnyValue]>) => void;

@@ -53,0 +52,0 @@ };

@@ -21,43 +21,20 @@ 'use strict';

function _extends() {
_extends = Object.assign ? Object.assign.bind() : function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
function _arrayLikeToArray(r, a) {
(null == a || a > r.length) && (a = r.length);
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
return n;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (it) return (it = it.call(o)).next.bind(it);
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
if (it) o = it;
var i = 0;
function _createForOfIteratorHelperLoose(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (t) return (t = t.call(r)).next.bind(t);
if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e ) {
t && (r = t);
var o = 0;
return function () {
if (i >= o.length) return {
done: true
return o >= r.length ? {
done: !0
} : {
done: !1,
value: r[o++]
};
return {
done: false,
value: o[i++]
};
};

@@ -67,2 +44,18 @@ }

}
function _extends() {
return _extends = Object.assign ? Object.assign.bind() : function (n) {
for (var e = 1; e < arguments.length; e++) {
var t = arguments[e];
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
}
return n;
}, _extends.apply(null, arguments);
}
function _unsupportedIterableToArray(r, a) {
if (r) {
if ("string" == typeof r) return _arrayLikeToArray(r, a);
var t = {}.toString.call(r).slice(8, -1);
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
}
}

@@ -396,2 +389,3 @@ function atomFamily(initializeAtom, areEqual) {

function createJSONStorage(getStringStorage, options) {
var _getStringStorage4;
if (getStringStorage === void 0) {

@@ -443,16 +437,21 @@ getStringStorage = function getStringStorage() {

};
if (typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage) {
storage.subscribe = function (key, callback, initialValue) {
if (!(getStringStorage() instanceof window.Storage)) {
return function () {};
}
var createHandleSubscribe = function createHandleSubscribe(subscriber) {
return function (key, callback, initialValue) {
return subscriber(key, function (v) {
var newValue;
try {
newValue = JSON.parse(v || '');
} catch (_unused2) {
newValue = initialValue;
}
callback(newValue);
});
};
};
var subscriber = (_getStringStorage4 = getStringStorage()) == null ? void 0 : _getStringStorage4.subscribe;
if (!subscriber && typeof window !== 'undefined' && typeof window.addEventListener === 'function' && window.Storage && getStringStorage() instanceof window.Storage) {
subscriber = function subscriber(key, callback) {
var storageEventCallback = function storageEventCallback(e) {
if (e.storageArea === getStringStorage() && e.key === key) {
var newValue;
try {
newValue = JSON.parse(e.newValue || '');
} catch (_unused2) {
newValue = initialValue;
}
callback(newValue);
callback(e.newValue);
}

@@ -466,2 +465,5 @@ };

}
if (subscriber) {
storage.subscribe = createHandleSubscribe(subscriber);
}
return storage;

@@ -468,0 +470,0 @@ }

import type { WritableAtom } from 'jotai/vanilla';
import { RESET } from './constants';
type Unsubscribe = () => void;
type Subscribe<Value> = (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
type StringSubscribe = (key: string, callback: (value: string | null) => void) => Unsubscribe;
type SetStateActionWithReset<Value> = Value | typeof RESET | ((prev: Value) => Value | typeof RESET);

@@ -9,3 +11,3 @@ export interface AsyncStorage<Value> {

removeItem: (key: string) => PromiseLike<void>;
subscribe?: (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
subscribe?: Subscribe<Value>;
}

@@ -16,3 +18,3 @@ export interface SyncStorage<Value> {

removeItem: (key: string) => void;
subscribe?: (key: string, callback: (value: Value) => void, initialValue: Value) => Unsubscribe;
subscribe?: Subscribe<Value>;
}

@@ -23,2 +25,3 @@ export interface AsyncStringStorage {

removeItem: (key: string) => PromiseLike<void>;
subscribe?: StringSubscribe;
}

@@ -29,2 +32,3 @@ export interface SyncStringStorage {

removeItem: (key: string) => void;
subscribe?: StringSubscribe;
}

@@ -31,0 +35,0 @@ export declare function withStorageValidator<Value>(validator: (value: unknown) => value is Value): {

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 not supported yet

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