var w=(e)=>typeof e==="function",j=(e)=>e&&typeof e==="object",b=Array.isArray,E=typeof document<"u"?document:null,B=(e)=>e?._isRuntime?e.container:e instanceof Node?e:E.createTextNode(e==null?"":String(e)),d=null,_=null,g=!1,A=0,R=new Set,I=new WeakMap,C=Symbol("iter"),k=new WeakMap,$="http://www.w3.org/2000/svg",M="http://www.w3.org/1999/xlink",W=new Set("svg,path,circle,rect,line,polyline,polygon,g,defs,text,textPath,tspan,use,symbol,image,marker,ellipse".split(",")),S=(e)=>{if(!e||e._disposed)return;e._disposed=!0;let s=[e];while(s.length){let n=s.pop();if(n._cleanups)n._cleanups.forEach((r)=>r()),n._cleanups.clear();if(n._children)n._children.forEach((r)=>s.push(r)),n._children.clear();if(n._deps)n._deps.forEach((r)=>r.delete(n)),n._deps.clear()}},N=(e)=>{if(_)(_._cleanups||=new Set).add(e)},K=(e)=>{let s=d;d=null;try{return e()}finally{d=s}},v=(e,s=!1)=>{let n=()=>{if(n._disposed)return;if(n._deps)n._deps.forEach((i)=>i.delete(n));if(n._cleanups)n._cleanups.forEach((i)=>i()),n._cleanups.clear();let r=d,o=_;d=_=n;try{return n._result=e()}catch(i){console.error("[SigPro]",i)}finally{d=r,_=o}};if(n._deps=n._cleanups=n._children=null,n._disposed=!1,n._isComputed=s,n._depth=d?d._depth+1:0,n._mounts=[],n._parent=_,_)(_._children||=new Set).add(n);return n},P=()=>{if(g)return;g=!0;let e=Array.from(R).sort((s,n)=>s._depth-n._depth);R.clear();for(let s of e)if(!s._disposed)s();g=!1},Q=(e)=>{A++;try{return e()}finally{if(A--,A===0&&R.size>0&&!g)P()}},m=(e,s=!1)=>{if(!s&&d&&!d._disposed)e.add(d),(d._deps||=new Set).add(e);else if(s&&e.size>0){let n=!1;for(let r of e){if(r===d||r._disposed)continue;if(r._isComputed){if(r._dirty=!0,r._subs)m(r._subs,!0)}else R.add(r),n=!0}if(n&&!g&&A===0)queueMicrotask(P)}},D=(e,s=null)=>{let n=new Set;if(w(e)){let r,o=()=>{if(o._dirty){let i=d;d=o;try{let t=e();if(!Object.is(r,t))r=t,m(n,!0)}finally{d=i}o._dirty=!1}return m(n),r};return o._isComputed=!0,o._subs=n,o._dirty=!0,o._deps=null,o._disposed=!1,o}if(s)try{e=JSON.parse(localStorage.getItem(s))??e}catch(r){}return(...r)=>{if(r.length){let o=w(r[0])?r[0](e):r[0];if(!Object.is(e,o)){if(e=o,s)localStorage.setItem(s,JSON.stringify(e));m(n,!0)}}return m(n),e}},q=(e)=>{if(!j(e))return e;let s=I.get(e);if(s)return s;let n=new Map,r=(i)=>{let t=n.get(i);if(!t)n.set(i,t=new Set);return t},o=new Proxy(e,{get(i,t,c){if(typeof t!=="symbol")m(r(t));return q(Reflect.get(i,t,c))},set(i,t,c,l){let a=Reflect.has(i,t),f=Reflect.get(i,t,l),u=Reflect.set(i,t,c,l);if(u&&!Object.is(f,c)){if(m(r(t),!0),!a)m(r(C),!0)}return u},deleteProperty(i,t){let c=Reflect.deleteProperty(i,t);if(c)m(r(t),!0),m(r(C),!0);return c},ownKeys(i){return m(r(C)),Reflect.ownKeys(i)}});return I.set(e,o),o},U=(e,s)=>{if(s===void 0){let r=v(e);return r(),()=>S(r)}let n=v(()=>{let r=b(e)?e.map((o)=>o()):e();K(()=>s(r))});return n(),()=>S(n)},V=(e)=>{if(!e)return;if(e._cleanups)e._cleanups.forEach((s)=>s()),e._cleanups.clear();if(e._ownerEffect)S(e._ownerEffect);if(e.childNodes)e.childNodes.forEach((s)=>V(s))},z=/^\s*(javascript|data|vbscript):/i,F=new Set(["src","href","formaction","action","background","code","archive"]),J=(e)=>F.has(e)||e.startsWith("on"),L=(e,s)=>{if(s==null||s===!1)return null;if(J(e)){let n=String(s);if(z.test(n))return"#"}return s},O=(e,s={},n=[])=>{if(s instanceof Node||b(s)||!j(s))n=s,s={};if(w(e)){let t=v(()=>{let f=e(s,{children:n,emit:(u,...h)=>s[`on${u[0].toUpperCase()}${u.slice(1)}`]?.(...h)});return t._result=f,f});t();let c=t._result;if(c==null)return null;let l=c instanceof Node||b(c)&&c.every((f)=>f instanceof Node)?c:E.createTextNode(String(c)),a=(f)=>{if(j(f)&&!f._isRuntime)f._mounts=t._mounts||[],f._cleanups=t._cleanups||new Set,f._ownerEffect=t};return b(l)?l.forEach(a):a(l),l}let r=W.has(e),o=r?E.createElementNS($,e):E.createElement(e);o._cleanups=new Set;for(let t of Object.keys(s)){let c=s[t];if(t==="ref"){w(c)?c(o):c.current=o;continue}if(r&&t.startsWith("xlink:")){let l=L(t.slice(6),c);l==null?o.removeAttributeNS(M,t.slice(6)):o.setAttributeNS(M,t.slice(6),l);continue}if(t.startsWith("on")){let l=t.slice(2).toLowerCase();o.addEventListener(l,c);let a=()=>o.removeEventListener(l,c);o._cleanups.add(a),N(a)}else if(w(c)){let l=v(()=>{let a=L(t,c());if(t==="class")o.className=a||"";else if(a==null)o.removeAttribute(t);else if(t==="style"&&typeof a==="string")o.setAttribute("style",a);else if(t in o&&!r)o[t]=a;else o.setAttribute(t,a===!0?"":a)});if(l(),o._cleanups.add(()=>S(l)),N(()=>S(l)),/^(INPUT|TEXTAREA|SELECT)$/.test(o.tagName)&&(t==="value"||t==="checked")){let a=t==="checked"?"change":"input";o.addEventListener(a,(f)=>c(f.target[t]))}}else{let l=L(t,c);if(l!=null)if(t==="style"&&typeof l==="string")o.setAttribute("style",l);else if(t in o&&!r)o[t]=l;else o.setAttribute(t,l===!0?"":l)}}let i=(t)=>{if(b(t))return t.forEach(i);if(w(t)){let c=E.createTextNode("");o.appendChild(c);let l=[],a=v(()=>{let f=t(),u=(b(f)?f:[f]).map(B);l.forEach((p)=>{if(p._isRuntime)p.destroy();else V(p);if(p.parentNode)p.remove()});let h=c;for(let p=u.length-1;p>=0;p--){let y=u[p];if(y.parentNode!==h.parentNode)h.parentNode?.insertBefore(y,h);if(y._mounts)y._mounts.forEach((G)=>G());h=y}l=u});a(),o._cleanups.add(()=>S(a)),N(()=>S(a))}else{let c=B(t);if(o.appendChild(c),c._mounts)c._mounts.forEach((l)=>l())}};return i(n),o},T=(e)=>{let s=new Set,n=_,r=d,o=E.createElement("div");o.style.display="contents",o.setAttribute("role","presentation"),_={_cleanups:s},d=null;let i=(t)=>{if(!t)return;if(t._isRuntime)s.add(t.destroy),o.appendChild(t.container);else if(b(t))t.forEach(i);else o.appendChild(t instanceof Node?t:E.createTextNode(String(t==null?"":t)))};try{i(e({onCleanup:(t)=>s.add(t)}))}finally{_=n,d=r}return{_isRuntime:!0,container:o,destroy:()=>{s.forEach((t)=>t()),V(o),o.remove()}}},X=(e,s,n=null)=>{let r=E.createTextNode(""),o=O("div",{style:"display:contents"},[r]),i=null;return U(()=>!!(w(e)?e():e),(t)=>{if(i)i.destroy(),i=null;let c=t?s:n;if(c)i=T(()=>w(c)?c():c),o.insertBefore(i.container,r)}),N(()=>i?.destroy()),o},H=(e,s,n)=>{let r=E.createTextNode(""),o=O("div",{style:"display:contents"},[r]),i=new Map;return U(()=>(w(e)?e():e)||[],(t)=>{let c=new Map,l=[],a=t||[];for(let u=0;us(h,u));else i.delete(p);c.set(p,y),l.push(y)}i.forEach((u)=>u.destroy());let f=r;for(let u=l.length-1;u>=0;u--){let p=l[u].container;if(p.nextSibling!==f)o.insertBefore(p,f);f=p}i=c}),o},x=(e)=>{let s=()=>window.location.hash.slice(1)||"/",n=D(s()),r=()=>n(s());window.addEventListener("hashchange",r),N(()=>window.removeEventListener("hashchange",r));let o=O("div",{class:"router-hook"}),i=null;return U([n],()=>{let t=n(),c=e.find((l)=>{let a=l.path.split("/").filter(Boolean),f=t.split("/").filter(Boolean);return a.length===f.length&&a.every((u,h)=>u[0]===":"||u===f[h])})||e.find((l)=>l.path==="*");if(c){i?.destroy();let l={};c.path.split("/").filter(Boolean).forEach((a,f)=>{if(a[0]===":")l[a.slice(1)]=t.split("/").filter(Boolean)[f]}),x.params(l),i=T(()=>w(c.component)?c.component(l):c.component),o.replaceChildren(i.container)}}),o};x.params=D({});x.to=(e)=>window.location.hash=e.replace(/^#?\/?/,"#/");x.back=()=>window.history.back();x.path=()=>window.location.hash.replace(/^#/,"")||"/";var Y=(e)=>e.children,Z=(e,s)=>{let n=typeof s==="string"?E.querySelector(s):s;if(!n)return;if(k.has(n))k.get(n).destroy();let r=T(w(e)?e:()=>e);return n.replaceChildren(r.container),k.set(n,r),r};if(typeof window<"u")"a abbr article aside audio b blockquote br button canvas caption cite code col colgroup datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hr i iframe img input ins kbd label legend li main mark meter nav object ol optgroup option output p picture pre progress section select slot small source span strong sub summary sup svg table tbody td template textarea tfoot th thead time tr u ul video".split(" ").forEach((e)=>{window[e]=(s,n)=>O(e,s,n)});export{X as when,U as watch,x as router,N as onUnmount,Z as mount,j as isObj,w as isFunc,b as isArr,O as h,H as each,Q as batch,Y as Fragment,q as $$,D as $};