import{signal as n,Signal as t}from"@preact/signals-core";import{useSignal}from"@preact/signals";import{createElement as r,Fragment as e}from"preact";import{useMemo as o}from"preact/hooks";const i=n=>"function"==typeof n.children?n.children(n.v,n.i?n.i.value:void 0):n.children;i.displayName="Item";function c(n){const t="function"==typeof n.when?n.when():n.when.value;if(!t)return n.fallback||null;else return r(i,{v:t,children:n.children})}c.displayName="Show";function f(c){const f=o(()=>new Map,[]),u="function"==typeof c.each?c.each():c.each,s=u instanceof t?u.value:u;if(!s.length)return c.fallback||null;const l=new Set(f.keys()),p=s.map((t,e)=>{l.delete(t);let o=f.get(t);if(!o){const u=n(e),s=c.getKey?c.getKey(t,e):e;o={vnode:r(i,{key:s,v:t,i:u,children:c.children}),i:u};f.set(t,o)}else if(o.i.peek()!==e)o.i.value=e;return o.vnode});l.forEach(n=>{f.delete(n)});return r(e,null,p)}f.displayName="For";function u(n){const t=useSignal(n);if(t.peek()!==n)t.value=n;return t}function s(n){const t=useSignal(n);if(!("current"in t))Object.defineProperty(t,"current",l);return t}const l={configurable:!0,get(){return this.value},set(n){this.value=n}};export{f as For,c as Show,u as useLiveSignal,s as useSignalRef};//# sourceMappingURL=utils.mjs.map
