System.register(["valtio/vanilla","derive-valtio"],function(m){"use strict";var b,p,y,E,w,j;return{setters:[function(c){b=c.subscribe,p=c.snapshot,y=c.proxy,E=c.ref,w=c.unstable_buildProxyFunction},function(c){j=c.derive,m({derive:c.derive,underive:c.underive,unstable_deriveSubscriptions:c.unstable_deriveSubscriptions})}],execute:function(){m({addComputed:M,devtools:D,proxyMap:z,proxySet:R,proxyWithComputed:I,proxyWithHistory:H,subscribeKey:c,watch:C});function c(a,s,t,e){let r=a[s];return b(a,()=>{const o=a[s];Object.is(r,o)||t(r=o)},e)}let v;function C(a,s){let t=!0;const e=new Set,r=new Map,o=()=>{t&&(t=!1,e.forEach(i=>i()),e.clear(),r.forEach(i=>i()),r.clear())},l=async()=>{if(!t)return;e.forEach(d=>d()),e.clear();const i=new Set,O=v;v=e;try{const d=a(u=>{if(i.add(u),t&&!r.has(u)){const h=b(u,l,s==null?void 0:s.sync);r.set(u,h)}return u}),n=d&&d instanceof Promise?await d:d;n&&(t?e.add(n):o())}finally{v=O}r.forEach((d,n)=>{i.has(n)||(r.delete(n),d())})};return v&&v.add(o),l(),o}const x=Symbol();function D(a,s){typeof s=="string"&&(console.warn("string name option is deprecated, use { name }. https://github.com/pmndrs/valtio/pull/400"),s={name:s});const{enabled:t,name:e="",...r}=s||{};let o;try{o=(t!=null?t:!1)&&window.__REDUX_DEVTOOLS_EXTENSION__}catch{}if(!o)return;let l=!1;const i=o.connect({name:e,...r}),O=b(a,n=>{const u=n.filter(([h,f])=>f[0]!==x).map(([h,f])=>`${h}:${f.map(String).join(".")}`).join(", ");if(u)if(l)l=!1;else{const h=Object.assign({},p(a));delete h[x],i.send({type:u,updatedAt:new Date().toLocaleString()},h)}}),d=i.subscribe(n=>{var u,h,f,_,P,A;if(n.type==="ACTION"&&n.payload)try{Object.assign(a,JSON.parse(n.payload))}catch(S){console.error(`please dispatch a serializable value that JSON.parse() and proxy() support `,S)}if(n.type==="DISPATCH"&&n.state){if(((u=n.payload)==null?void 0:u.type)==="JUMP_TO_ACTION"||((h=n.payload)==null?void 0:h.type)==="JUMP_TO_STATE"){l=!0;const S=JSON.parse(n.state);Object.assign(a,S)}a[x]=n}else if(n.type==="DISPATCH"&&((f=n.payload)==null?void 0:f.type)==="COMMIT")i.init(p(a));else if(n.type==="DISPATCH"&&((_=n.payload)==null?void 0:_.type)==="IMPORT_STATE"){const S=(P=n.payload.nextLiftedState)==null?void 0:P.actionsById,U=((A=n.payload.nextLiftedState)==null?void 0:A.computedStates)||[];l=!0,U.forEach(({state:k},N)=>{const L=S[N]||"No action found";Object.assign(a,k),N===0?i.init(p(a)):i.send(L,p(a))})}});return i.init(p(a)),()=>{O(),d==null||d()}}function M(a,s,t=a){const e={};return Object.keys(s).forEach(r=>{e[r]=o=>s[r](o(a))}),j(e,{proxy:t})}function I(a,s){Object.keys(s).forEach(e=>{if(Object.getOwnPropertyDescriptor(a,e))throw new Error("object property already defined");const r=s[e],{get:o,set:l}=typeof r=="function"?{get:r}:r,i={};i.get=()=>o(p(t)),l&&(i.set=O=>l(t,O)),Object.defineProperty(a,e,i)});const t=y(a);return t}const J=a=>typeof a=="object"&&a!==null;let g;const T=a=>{if(g||(g=w()[2]),!J(a)||g.has(a))return a;const s=Array.isArray(a)?[]:Object.create(Object.getPrototypeOf(a));return Reflect.ownKeys(a).forEach(t=>{s[t]=T(a[t])}),s};function H(a,s=!1){const t=y({value:a,history:E({wip:void 0,snapshots:[],index:-1}),clone:T,canUndo:()=>t.history.index>0,undo:()=>{t.canUndo()&&(t.value=t.history.wip=t.clone(t.history.snapshots[--t.history.index]))},canRedo:()=>t.history.index{t.canRedo()&&(t.value=t.history.wip=t.clone(t.history.snapshots[++t.history.index]))},saveHistory:()=>{t.history.snapshots.splice(t.history.index+1),t.history.snapshots.push(p(t).value),++t.history.index},subscribe:()=>b(t,e=>{e.every(r=>r[1][0]==="value"&&(r[0]!=="set"||r[2]!==t.history.wip))&&t.saveHistory()})});return t.saveHistory(),s||t.subscribe(),t}function R(a){const s=y({data:Array.from(new Set(a)),has(t){return this.data.indexOf(t)!==-1},add(t){let e=!1;return typeof t=="object"&&t!==null&&(e=this.data.indexOf(y(t))!==-1),this.data.indexOf(t)===-1&&!e&&this.data.push(t),this},delete(t){const e=this.data.indexOf(t);return e===-1?!1:(this.data.splice(e,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},forEach(t){this.data.forEach(e=>{t(e,e,this)})},get[Symbol.toStringTag](){return"Set"},toJSON(){return new Set(this.data)},[Symbol.iterator](){return this.data[Symbol.iterator]()},values(){return this.data.values()},keys(){return this.data.values()},entries(){return new Set(this.data).entries()}});return Object.defineProperties(s,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(s),s}function z(a){const s=y({data:Array.from(a||[]),has(t){return this.data.some(e=>e[0]===t)},set(t,e){const r=this.data.find(o=>o[0]===t);return r?r[1]=e:this.data.push([t,e]),this},get(t){var e;return(e=this.data.find(r=>r[0]===t))==null?void 0:e[1]},delete(t){const e=this.data.findIndex(r=>r[0]===t);return e===-1?!1:(this.data.splice(e,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(t){this.data.forEach(e=>{t(e[1],e[0],this)})},keys(){return this.data.map(t=>t[0]).values()},values(){return this.data.map(t=>t[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(s,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(s),s}}}});