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