@deijose/nix-js 1.7.1 → 1.7.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,10 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!1,s=new Set,c=i,f=()=>{if(!a){if("function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s=new Set,t.push(e),r.push(n),e=f,n=s,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!c)throw e;c(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}}};return f(),()=>{a=!0,"function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose.bind(t);return t.dispose=()=>{n(),r()},t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,o;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function ie(e,t,n){let r,o;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function ae(e,t,n,r){let o,l;D(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function oe(e,t,n,r,o){let l,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),o.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}l()})}function se(){return{__isPortalOutlet:!0,_container:null}}function ce(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function le(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;return o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?re(e,o,null):e._render(o,null)}}}var ue=S("nix:portal-outlet");function de(e){O(ue,e)}function fe(){return k(ue)}function pe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(A.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function me(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function j(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function M(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(j(r.transitionDuration||"0"),j(r.animationDuration||"0")),l=o>0?o+100:t;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function he(e,t={}){let n=me(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment(A.TRANSITION);r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,o):e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await M(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function ge(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function _e(e,t){let n=new Set,r="";for(let o=0;o<e.length;o++){let l=e[o];if(n.has(o)&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&n.add(o+1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&n.add(o+1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ve(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function P(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode,t=0,o=e.firstChild;for(;o&&o!==r;)t++,o=o.nextSibling;n.unshift(t),r=e}return n}function F(e,t){let n=e;for(let e of t)n=n.childNodes[e];return n}var I={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};function ye(e,t,n,r,o){let l=[],i=[],a=new Map;for(let[t,n]of r)a.set(t,F(e,n));let u=new Map;for(let[t,n]of o){let r=F(e,n.path);r.removeAttribute("event"===n.type?`data-nix-e-${t}`:`data-nix-a-${t}`),u.set(t,{el:r,type:n.type,name:n.name})}for(let e=0;e<t.length;e++){let r=t[e],o=n[e];if("event"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:i}=t,a=o,s=r.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=I[e];if(void 0!==n&&t.key!==n||!I[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}a(e)}};n.addEventListener(i,f,c),l.push(()=>n.removeEventListener(i,f,c));continue}if("attr"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:r}=t;if("ref"===r){o.el=n,l.push(()=>{o.el=null});continue}if("show"===r||"hide"===r){let e=n,t=null;if("function"==typeof o){let n=m(()=>{let n=!!o(),l="show"===r?n:!n;null===t&&(t=e.style.display||""),e.style.display=l?t:"none"});l.push(n)}else("show"===r?o:!o)||(n.style.display="none");continue}let i=("value"===r||"checked"===r||"selected"===r)&&r in n;if("function"==typeof o){let e=m(()=>{let e=o();i?n[r]=e??"":null==e||!1===e?n.removeAttribute(r):n.setAttribute(r,String(e))});l.push(e)}else i?n[r]=o??"":null!=o&&!1!==o&&n.setAttribute(r,String(o));continue}let s=a.get(e);if(!s)continue;if("function"!=typeof o){if(x(o))oe(o,s.parentNode,s,i,l);else if(N(o)){let e=o._render(s.parentNode,s);l.push(e)}else if(Array.isArray(o))for(let e of o)x(e)?oe(e,s.parentNode,s,i,l):N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=o&&!1!==o&&s.parentNode.insertBefore(document.createTextNode(String(o)),s);continue}let c=null,f=null,d=null,p=null,h=w(),v=m(()=>{let e=o();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(N(e))f=e._render(s.parentNode,s);else if(x(e))f=ae(e,s.parentNode,s,h);else if(ve(e)){d||(d=new Map,p=document.createComment(A.KEYED_ZONE),s.parentNode.insertBefore(p,s));let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);if(0===r.size&&d.size>0){let e=document.createRange();e.setStartAfter(p),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();return void d.clear()}if(![...d.keys()].some(e=>r.has(e))&&d.size>0){let e=document.createRange();e.setStartAfter(p),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();d.clear()}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(d.has(l)){let e=d.get(l);if(e.end.nextSibling!==o){let n=document.createDocumentFragment(),r=e.start;for(;;){let t=r===e.end?null:r.nextSibling;if(n.appendChild(r),!t)break;r=t}t.insertBefore(n,o)}o=e.start}else{let n,a=document.createComment(A.KEYED_END),u=document.createComment(A.KEYED_START);t.insertBefore(a,o),t.insertBefore(u,a);try{let o=e.renderFn(i,r);n=x(o)?ae(o,t,a,h):o._render(t,a)}catch(e){let n=u.nextSibling;for(;n&&n!==a;){let e=n.nextSibling;t.removeChild(n),n=e}throw u.remove(),a.remove(),e}d.set(l,{start:u,end:a,cleanup:n}),o=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,s.parentNode,s));else if(N(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});l.push(()=>{if(v(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null,p=null}})}return{disposes:l,postMountHooks:i}}var be=new WeakMap;function L(e,...t){let n=be.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ge(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=_e(e,t);let l,i=new Map,a=new Map,u=o.content,s=document.createTreeWalker(u,NodeFilter.SHOW_COMMENT);for(;l=s.nextNode();){let e=l,t=e.nodeValue?.match(/^nix-(\d+)$/);t&&i.set(parseInt(t[1]),P(u,e))}u.querySelectorAll("*").forEach(e=>{let t=Array.from(e.attributes);for(let n of t){let t=n.name.match(/^data-nix-e-(\d+)$/);if(t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"event",name:n.value});continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"attr",name:n.value})}}}),n={contexts:t,tpl:o,markerPaths:i,attrEventPaths:a},be.set(e,n)}let{contexts:r,tpl:o}=n;function l(e,l){let i=o.content.cloneNode(!0),{disposes:a,postMountHooks:u}=ye(i,r,t,n.markerPaths,n.attrEventPaths),s=document.createComment(A.SCOPE);return e.insertBefore(s,l),e.insertBefore(i,l),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==l;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:l,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=l(t,null);return{unmount(){n()}}}}}function xe(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Se(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let o=n;let l=Object.assign(Object.create(null),o,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(l,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(o);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):l[t]=e[t]}return l}var R=null,z=null;function B(){if(!R)throw Error("[Nix] No active router. Call createRouter() first.");return R}function V(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function H(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ce(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function we(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function U(e,t="",n=[]){let r=[];for(let o of e){let e=we(t,o.path),l=[...n,o.component],i=Ce(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...U(o.children,e,l))}return r}function Te(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ee(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function W(e,t){let n,r={},o=-1;for(let l of t){let t=Te(e,l);if(null===t)continue;let i=Ee(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function G(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function De(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return G(new URL(t,window.location.origin).pathname)}catch{return G(t)}}function Oe(e,t){let n=null==t?.base?De():G(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=U(e),a=W(l,i),u=p(l),s=p(a?.params??{}),c=p(V(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():_(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:V(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}z&&=(z(),null);let x=()=>{let e=r(),t=u.value,n=c.value,l=W(e,i),a=V(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+H(n))})};function g(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+H(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=W(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!1))}window.addEventListener("popstate",x),z=()=>window.removeEventListener("popstate",x);let b={current:u,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=W(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=W(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return R&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),R=b,queueMicrotask(()=>{v||m(l,"",W(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=W("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function ke(){return B()}var Ae=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return L`<div class="router-view">${()=>{let t=B(),n=W(t.current.value,t._flat);return n?e>=n.route.chain.length?L`<span></span>`:n.route.chain[e]():L`<div style="color:#f87171;padding:16px 0">
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!1,s=new Set,c=i,f=()=>{if(!a){if("function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s=new Set,t.push(e),r.push(n),e=f,n=s,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!c)throw e;c(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}}};return f(),()=>{a=!0,"function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose.bind(t);return t.dispose=()=>{n(),r()},t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function ee(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function D(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function O(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var k={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function te(){return{el:null}}function ne(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function re(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function A(e,t,n){let r,o;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function ie(e,t,n){let r,o;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function j(e,t,n,r){let o,l;ee(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function ae(e,t,n,r,o){let l,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),o.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}l()})}function oe(){return{__isPortalOutlet:!0,_container:null}}function se(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ce(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;return o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?A(e,o,null):e._render(o,null)}}}var le=S("nix:portal-outlet");function ue(e){D(le,e)}function de(){return O(le)}function fe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(k.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function pe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function me(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function M(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(me(r.transitionDuration||"0"),me(r.animationDuration||"0")),l=o>0?o+100:t;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function he(e,t={}){let n=pe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment(k.TRANSITION);r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,o):e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await M(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function ge(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function _e(e,t){let n=new Set,r="";for(let o=0;o<e.length;o++){let l=e[o];if(n.has(o)&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&n.add(o+1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&n.add(o+1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ve(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function P(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode,t=0,o=e.firstChild;for(;o&&o!==r;)t++,o=o.nextSibling;n.unshift(t),r=e}return n}function ye(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e],o=n.firstChild;for(let e=0;e<r;e++)o=o.nextSibling;n=o}return n}var F={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};function be(e,t,n,r){let o=[],l=[];for(let i=0;i<t.length;i++){let a=t[i],u=n[i],s=r[i];if(!s)continue;let c=ye(e,s.path);if("event"===a.type){let e=s.name,t=u,n=a.modifiers,r={};n.includes("once")&&(r.once=!0),n.includes("capture")&&(r.capture=!0),n.includes("passive")&&(r.passive=!0);let l=e=>{if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),!n.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of n){let n=F[e];if(void 0!==n&&t.key!==n||!F[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}t(e)}};c.addEventListener(e,l,r),o.push(()=>c.removeEventListener(e,l,r));continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,o.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=m(()=>{let t=!!u(),o="show"===e?t:!t;null===r&&(r=n.style.display||""),n.style.display=o?r:"none"});o.push(t)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r=m(()=>{let r=u();n?t[e]=r??"":null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,String(r))});o.push(r)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;if("function"!=typeof u){if(x(u))ae(u,f.parentNode,f,l,o);else if(N(u)){let e=u._render(f.parentNode,f);o.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,f.parentNode,f,l,o):N(e)?e._render(f.parentNode,f):null!=e&&!1!==e&&f.parentNode.insertBefore(document.createTextNode(String(e)),f);else null!=u&&!1!==u&&f.parentNode.insertBefore(document.createTextNode(String(u)),f);continue}let d=null,p=null,h=null,v=null,y=w(),g=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return p&&=(p(),null),void(d?d.nodeValue=String(e):(d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)));if(d&&=(d.parentNode?.removeChild(d),null),p&&=(p(),null),null!=e&&!1!==e)if(N(e))p=e._render(f.parentNode,f);else if(x(e))p=j(e,f.parentNode,f,y);else if(ve(e)){h||(h=new Map,v=document.createComment(k.KEYED_ZONE),f.parentNode.insertBefore(v,f));let t=f.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),o=!1;if(h.size>0)for(let e of h.keys())if(r.has(e)){o=!0;break}if(!o){if(h.size>0){let e=document.createRange();e.setStartAfter(v),e.setEndBefore(f),e.deleteContents();for(let e of h.values())e.cleanup();h.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let o=n[t],l=e.items[t],i=document.createComment(k.KEYED_START),a=document.createComment(k.KEYED_END);r.appendChild(i);let u=e.renderFn(l,t),s=x(u)?j(u,r,null,y):u._render(r,null);r.appendChild(a),h.set(o,{start:i,end:a,cleanup:s})}t.insertBefore(r,f)}return}for(let[e,t]of h.entries())if(!r.has(e)){let n=t.start;for(;n;){let e=n===t.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!e)break;n=e}t.cleanup(),h.delete(e)}let l=f;for(let r=n.length-1;r>=0;r--){let o=n[r];if(h.has(o)){let e=h.get(o);if(e.end.nextSibling!==l){let n=document.createDocumentFragment(),r=e.start;for(;;){let t=r===e.end?null:r.nextSibling;if(n.appendChild(r),!t)break;r=t}t.insertBefore(n,l)}l=e.start}else{let o=r;for(;o>0&&!h.has(n[o-1]);)o--;let i=document.createDocumentFragment(),a=[];for(let t=o;t<=r;t++){let r=n[t],o=e.items[t],l=document.createComment(k.KEYED_START),u=document.createComment(k.KEYED_END);i.appendChild(l);let s=e.renderFn(o,t),c=x(s)?j(s,i,null,y):s._render(i,null);i.appendChild(u),a.push({key:r,start:l,end:u,cleanup:c})}t.insertBefore(i,l);for(let e of a)h.set(e.key,e);l=a[0].start,r=o}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(A(n,f.parentNode,f));else if(N(n))t.push(n._render(f.parentNode,f));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));f.parentNode.insertBefore(e,f),t.push(()=>e.parentNode?.removeChild(e))}p=()=>t.forEach(e=>e())}else d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)});o.push(()=>{if(g(),p&&=(p(),null),d&&=(d.parentNode?.removeChild(d),null),h){for(let e of h.values())e.cleanup();h=null,v=null}})}return{disposes:o,postMountHooks:l}}var xe=new WeakMap;function I(e,...t){let n=xe.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ge(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=_e(e,t);let l,i=Array(t.length).fill(null),a=o.content,u=document.createTreeWalker(a,NodeFilter.SHOW_COMMENT);for(;l=u.nextNode();){let e=l,t=e.nodeValue?.match(/^nix-(\d+)$/);if(t){let n=parseInt(t[1]);i[n]={path:P(a,e)}}}a.querySelectorAll("*").forEach(e=>{let t=Array.from(e.attributes);for(let n of t){let t=n.name.match(/^data-nix-e-(\d+)$/);if(t){let r=parseInt(t[1]);i[r]={path:P(a,e),name:n.value},e.removeAttribute(n.name);continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);i[r]={path:P(a,e),name:n.value},e.removeAttribute(n.name)}}}),n={contexts:t,tpl:o,pathMap:i},xe.set(e,n)}let{contexts:r,tpl:o,pathMap:l}=n;function i(e,n){let i=o.content.cloneNode(!0),{disposes:a,postMountHooks:u}=be(i,r,t,l),s=document.createComment(k.SCOPE);return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Se(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Ce(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let o=n;let l=Object.assign(Object.create(null),o,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(l,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(o);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):l[t]=e[t]}return l}var L=null,R=null;function z(){if(!L)throw Error("[Nix] No active router. Call createRouter() first.");return L}function B(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function V(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function we(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function Te(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function H(e,t="",n=[]){let r=[];for(let o of e){let e=Te(t,o.path),l=[...n,o.component],i=we(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...H(o.children,e,l))}return r}function Ee(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let o=r.length>0&&"wildcard"===r[r.length-1].kind,l=o?r.slice(0,-1):r;if(o){if(n.length<l.length)return null}else if(n.length!==l.length)return null;let i={};for(let e=0;e<l.length;e++){let t=l[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function De(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function U(e,t){let n,r={},o=-1;for(let l of t){let t=Ee(e,l);if(null===t)continue;let i=De(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function W(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Oe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return W(new URL(t,window.location.origin).pathname)}catch{return W(t)}}function ke(e,t){let n=null==t?.base?Oe():W(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=H(e),a=U(l,i),u=p(l),s=p(a?.params??{}),c=p(B(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():_(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:B(e.slice(n)),l=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(l))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}R&&=(R(),null);let x=()=>{let e=r(),t=u.value,n=c.value,l=U(e,i),a=B(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+V(n))})};function g(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+V(t);l?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=U(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!1))}window.addEventListener("popstate",x),R=()=>window.removeEventListener("popstate",x);let b={current:u,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=U(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=U(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return L&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),L=b,queueMicrotask(()=>{v||m(l,"",U(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=U("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Ae(){return z()}var je=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=z(),n=U(t.current.value,t._flat);return n?e>=n.route.chain.length?I`<span></span>`:n.route.chain[e]():I`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},je=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return L`<a
4
- href=${(B()._base||"")+(e.startsWith("/")?e:"/"+e)}
5
- style=${()=>B().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
6
- @click=${t=>{t.preventDefault(),B().navigate(e)}}
7
- >${t}</a>`}};function K(){return L`
3
+ </div>`}}</div>`}},Me=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return I`<a
4
+ href=${(z()._base||"")+(e.startsWith("/")?e:"/"+e)}
5
+ style=${()=>z().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
6
+ @click=${t=>{t.preventDefault(),z().navigate(e)}}
7
+ >${t}</a>`}};function G(){return I`
8
8
  <span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
9
9
  <span class="nix-spinner" style="
10
10
  display:inline-block;width:14px;height:14px;border-radius:50%;
@@ -14,8 +14,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=
14
14
  Loading…
15
15
  </span>
16
16
  <style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
17
- `}function q(e){return L`
17
+ `}function K(e){return I`
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `}var J=new Map,Me=3e5,Y=null,Ne=Me;function Pe(){null===Y&&(Y=setInterval(()=>{let e=Date.now();for(let[t,n]of J)n.subscribers<=0&&e-n.fetchedAt>Ne&&J.delete(t);0===J.size&&null!==Y&&(clearInterval(Y),Y=null)},6e4))}function X(e){return J.get(e)}function Fe(e,t){let n=J.get(e);J.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Pe()}function Ie(e){let t=J.get(e);t&&t.subscribers++}function Le(e){let t=J.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Re(e,t){let n=J.get(e);return!!n&&Date.now()-n.fetchedAt<t}function ze(e){void 0===e?J.clear():J.delete(e)}function Be(e){Ne=e}function Ve(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??K(),c=o??q;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?X(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ie(a);let e=a?X(a):void 0;if(e&&Re(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&J.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Le(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Fe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return L`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function He(e){J.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Ue(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??K(),c=l??q;return new class extends b{_state;constructor(){super();let t=X(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Ie(e);let r=X(e),o=Re(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),Le(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Fe(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return L`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function We(e,t){let n=null;return()=>n?new n:Ve(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Ge(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ke(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function qe(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function Je(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Ye(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Xe(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Ze(e){return e}const Qe={required:Ge,minLength:Ke,maxLength:qe,email:Je,pattern:Q,min:Ye,max:Xe};function $e(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=p(e),o=p(!1),l=p(!1),i=p(null),a=p(!1),u=h(()=>{if(i.value)return i.value;if(!("input"===n?l.value||o.value:"submit"===n?a.value:o.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:u,touched:o,dirty:l,onInput:e=>{r.value=s(e.target),l.value=!0,i.value=null},onBlur:()=>{o.value=!0},reset:function(){r.value=e,o.value=!1,l.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(o.value=!0)},_forceVisible:function(){o.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function et(e,t={},n="blur"){function r(e){let r={};for(let o in e){let l=t[o]??[];r[o]=$(e[o],l,n)}return r}let o=p(e.map(r)),l=h(()=>o.value.length);return{fields:o,append:function(e){o.value=[...o.value,r(e)]},remove:function(e){let t=o.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();o.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...o.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),o.value=n},replace:function(e,t){let n=[...o.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),o.value=n}},length:l,reset:function(){for(let e of o.value)for(let t in e)e[t]._dispose();o.value=e.map(r)},_dispose:function(){for(let e of o.value)for(let t in e)e[t]._dispose();l.dispose()}}}function tt(e,t={}){let n=t.validateOn??"blur",r={};for(let o in e){let l=t.validators?.[o]??[];r[o]=$(e[o],l,n)}let o=p(!1),l=p(0),i=h(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=h(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=h(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=h(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=h(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:a,valid:u,dirty:s,touched:c,isSubmitting:o,submitCount:l,handleSubmit:function(e){return n=>{n.preventDefault(),l.value++;for(let e in r)r[e]._forceVisible();let a=i.value;if(t.validate){let e=t.validate(a);if(e){let t={},n=!1;for(let r in e){let o=e[r],l=Array.isArray(o)?o[0]??null:o??null;l&&(t[r]=l,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let u=e(a);u instanceof Promise&&(o.value=!0,u.finally(()=>{o.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();o.value=!1,l.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}exports.Link=je,exports.NixComponent=b,exports.RouterView=Ae,exports.Signal=f,exports.batch=g,exports.clearQueryCache=ze,exports.computed=h,exports.createErrorBoundary=pe,exports.createForm=tt,exports.createInjectionKey=S,exports.createPortalOutlet=se,exports.createQuery=Ue,exports.createRouter=Oe,exports.createStore=Se,exports.createValidator=Ze,exports.effect=m,exports.email=Je,exports.extendValidators=$e,exports.html=L,exports.inject=k,exports.injectOutlet=fe,exports.invalidateQueries=He,exports.lazy=We,exports.max=Xe,exports.maxLength=qe,exports.min=Ye,exports.minLength=Ke,exports.mount=xe,exports.nextTick=y,exports.pattern=Q,exports.portal=le,exports.portalOutlet=ce,exports.provide=O,exports.provideOutlet=de,exports.ref=ee,exports.repeat=ne,exports.required=Ge,exports.setQueryCacheTime=Be,exports.showWhen=te,exports.signal=p,exports.suspend=Ve,exports.transition=he,exports.untrack=_,exports.useField=$,exports.useFieldArray=et,exports.useRouter=ke,exports.validators=Qe,exports.watch=v;
21
+ `}var q=new Map,Ne=3e5,J=null,Pe=Ne;function Fe(){null===J&&(J=setInterval(()=>{let e=Date.now();for(let[t,n]of q)n.subscribers<=0&&e-n.fetchedAt>Pe&&q.delete(t);0===q.size&&null!==J&&(clearInterval(J),J=null)},6e4))}function Y(e){return q.get(e)}function Ie(e,t){let n=q.get(e);q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Fe()}function Le(e){let t=q.get(e);t&&t.subscribers++}function Re(e){let t=q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function ze(e,t){let n=q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Be(e){void 0===e?q.clear():q.delete(e)}function Ve(e){Pe=e}function X(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??G(),c=o??K;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Y(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Le(a);let e=a?Y(a):void 0;if(e&&ze(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&q.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Re(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Ie(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function He(e){q.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Ue(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??G(),c=l??K;return new class extends b{_state;constructor(){super();let t=Y(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Le(e);let r=Y(e),o=ze(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),Re(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Ie(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function We(e,t){let n=null;return()=>n?new n:X(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Ge(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ke(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function qe(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function Je(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Ye(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Xe(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Ze(e){return e}const Qe={required:Ge,minLength:Ke,maxLength:qe,email:Je,pattern:Q,min:Ye,max:Xe};function $e(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=p(e),o=p(!1),l=p(!1),i=p(null),a=p(!1),u=h(()=>{if(i.value)return i.value;if(!("input"===n?l.value||o.value:"submit"===n?a.value:o.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:u,touched:o,dirty:l,onInput:e=>{r.value=s(e.target),l.value=!0,i.value=null},onBlur:()=>{o.value=!0},reset:function(){r.value=e,o.value=!1,l.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(o.value=!0)},_forceVisible:function(){o.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function et(e,t={},n="blur"){function r(e){let r={};for(let o in e){let l=t[o]??[];r[o]=$(e[o],l,n)}return r}let o=p(e.map(r)),l=h(()=>o.value.length);return{fields:o,append:function(e){o.value=[...o.value,r(e)]},remove:function(e){let t=o.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();o.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...o.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),o.value=n},replace:function(e,t){let n=[...o.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),o.value=n}},length:l,reset:function(){for(let e of o.value)for(let t in e)e[t]._dispose();o.value=e.map(r)},_dispose:function(){for(let e of o.value)for(let t in e)e[t]._dispose();l.dispose()}}}function tt(e,t={}){let n=t.validateOn??"blur",r={};for(let o in e){let l=t.validators?.[o]??[];r[o]=$(e[o],l,n)}let o=p(!1),l=p(0),i=h(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=h(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=h(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=h(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=h(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:a,valid:u,dirty:s,touched:c,isSubmitting:o,submitCount:l,handleSubmit:function(e){return n=>{n.preventDefault(),l.value++;for(let e in r)r[e]._forceVisible();let a=i.value;if(t.validate){let e=t.validate(a);if(e){let t={},n=!1;for(let r in e){let o=e[r],l=Array.isArray(o)?o[0]??null:o??null;l&&(t[r]=l,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let u=e(a);u instanceof Promise&&(o.value=!0,u.finally(()=>{o.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();o.value=!1,l.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}exports.Link=Me,exports.NixComponent=b,exports.RouterView=je,exports.Signal=f,exports.batch=g,exports.clearQueryCache=Be,exports.computed=h,exports.createErrorBoundary=fe,exports.createForm=tt,exports.createInjectionKey=S,exports.createPortalOutlet=oe,exports.createQuery=Ue,exports.createRouter=ke,exports.createStore=Ce,exports.createValidator=Ze,exports.effect=m,exports.email=Je,exports.extendValidators=$e,exports.html=I,exports.inject=O,exports.injectOutlet=de,exports.invalidateQueries=He,exports.lazy=We,exports.max=Xe,exports.maxLength=qe,exports.min=Ye,exports.minLength=Ke,exports.mount=Se,exports.nextTick=y,exports.pattern=Q,exports.portal=ce,exports.portalOutlet=se,exports.provide=D,exports.provideOutlet=ue,exports.ref=te,exports.repeat=re,exports.required=Ge,exports.setQueryCacheTime=Ve,exports.showWhen=ne,exports.signal=p,exports.suspend=X,exports.transition=he,exports.untrack=_,exports.useField=$,exports.useFieldArray=et,exports.useRouter=Ae,exports.validators=Qe,exports.watch=v;
@@ -1,10 +1,10 @@
1
- var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(l){let o,a=!1,s=new Set,c=i,f=()=>{if(!a){if("function"==typeof o&&o(),s.forEach(e=>e._removeSub(f)),s=new Set,t.push(e),r.push(n),e=f,n=s,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{o=l()}catch(e){if(!c)throw e;c(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}}};return f(),()=>{a=!0,"function"==typeof o&&o(),s.forEach(e=>e._removeSub(f)),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose.bind(t);return t.dispose=()=>{n(),r()},t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,l=n;e=null,n=null;try{return t()}finally{e=r,n=l}}function v(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;_(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,_(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ie(e,t,n){let r,l;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ae(e,t,n,r){let l,o;D(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function oe(e,t,n,r,l){let o,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function se(){return{__isPortalOutlet:!0,_container:null}}function ce(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function le(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?re(e,l,null):e._render(l,null)}}}var ue=S("nix:portal-outlet");function de(e){O(ue,e)}function fe(){return k(ue)}function pe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(A.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function me(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function j(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function M(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(j(r.transitionDuration||"0"),j(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},o)})}function he(e,t={}){let n=me(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(A.TRANSITION);r.insertBefore(o,l);let i=null,a=null,u=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await M(l,t.duration),u===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),u===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,o.remove()}}}}function ge(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.match(/@([\w:.-]+)=["']?$/);if(l){let e=l[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}}let o=r.match(/([\w:.-]+)=["']?$/);return o?{type:"attr",attrName:o[1],hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}:{type:"node"}}function _e(e,t){let n=new Set,r="";for(let l=0;l<e.length;l++){let o=e[l];if(n.has(l)&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&n.add(l+1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&n.add(l+1)}}else r+=o}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ve(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function P(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode,t=0,l=e.firstChild;for(;l&&l!==r;)t++,l=l.nextSibling;n.unshift(t),r=e}return n}function F(e,t){let n=e;for(let e of t)n=n.childNodes[e];return n}var I={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};function ye(e,t,n,r,l){let o=[],i=[],a=new Map;for(let[t,n]of r)a.set(t,F(e,n));let u=new Map;for(let[t,n]of l){let r=F(e,n.path);r.removeAttribute("event"===n.type?`data-nix-e-${t}`:`data-nix-a-${t}`),u.set(t,{el:r,type:n.type,name:n.name})}for(let e=0;e<t.length;e++){let r=t[e],l=n[e];if("event"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:i}=t,a=l,s=r.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=I[e];if(void 0!==n&&t.key!==n||!I[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}a(e)}};n.addEventListener(i,f,c),o.push(()=>n.removeEventListener(i,f,c));continue}if("attr"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:r}=t;if("ref"===r){l.el=n,o.push(()=>{l.el=null});continue}if("show"===r||"hide"===r){let e=n,t=null;if("function"==typeof l){let n=m(()=>{let n=!!l(),o="show"===r?n:!n;null===t&&(t=e.style.display||""),e.style.display=o?t:"none"});o.push(n)}else("show"===r?l:!l)||(n.style.display="none");continue}let i=("value"===r||"checked"===r||"selected"===r)&&r in n;if("function"==typeof l){let e=m(()=>{let e=l();i?n[r]=e??"":null==e||!1===e?n.removeAttribute(r):n.setAttribute(r,String(e))});o.push(e)}else i?n[r]=l??"":null!=l&&!1!==l&&n.setAttribute(r,String(l));continue}let s=a.get(e);if(!s)continue;if("function"!=typeof l){if(x(l))oe(l,s.parentNode,s,i,o);else if(N(l)){let e=l._render(s.parentNode,s);o.push(e)}else if(Array.isArray(l))for(let e of l)x(e)?oe(e,s.parentNode,s,i,o):N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=l&&!1!==l&&s.parentNode.insertBefore(document.createTextNode(String(l)),s);continue}let c=null,f=null,d=null,p=null,h=w(),v=m(()=>{let e=l();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(N(e))f=e._render(s.parentNode,s);else if(x(e))f=ae(e,s.parentNode,s,h);else if(ve(e)){d||(d=new Map,p=document.createComment(A.KEYED_ZONE),s.parentNode.insertBefore(p,s));let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);if(0===r.size&&d.size>0){let e=document.createRange();e.setStartAfter(p),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();return void d.clear()}if(![...d.keys()].some(e=>r.has(e))&&d.size>0){let e=document.createRange();e.setStartAfter(p),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();d.clear()}let l=s;for(let r=n.length-1;r>=0;r--){let o=n[r],i=e.items[r];if(d.has(o)){let e=d.get(o);if(e.end.nextSibling!==l){let n=document.createDocumentFragment(),r=e.start;for(;;){let t=r===e.end?null:r.nextSibling;if(n.appendChild(r),!t)break;r=t}t.insertBefore(n,l)}l=e.start}else{let n,a=document.createComment(A.KEYED_END),u=document.createComment(A.KEYED_START);t.insertBefore(a,l),t.insertBefore(u,a);try{let l=e.renderFn(i,r);n=x(l)?ae(l,t,a,h):l._render(t,a)}catch(e){let n=u.nextSibling;for(;n&&n!==a;){let e=n.nextSibling;t.removeChild(n),n=e}throw u.remove(),a.remove(),e}d.set(o,{start:u,end:a,cleanup:n}),l=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,s.parentNode,s));else if(N(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});o.push(()=>{if(v(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null,p=null}})}return{disposes:o,postMountHooks:i}}var be=new WeakMap;function L(e,...t){let n=be.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ge(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=_e(e,t);let o,i=new Map,a=new Map,u=l.content,s=document.createTreeWalker(u,NodeFilter.SHOW_COMMENT);for(;o=s.nextNode();){let e=o,t=e.nodeValue?.match(/^nix-(\d+)$/);t&&i.set(parseInt(t[1]),P(u,e))}u.querySelectorAll("*").forEach(e=>{let t=Array.from(e.attributes);for(let n of t){let t=n.name.match(/^data-nix-e-(\d+)$/);if(t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"event",name:n.value});continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"attr",name:n.value})}}}),n={contexts:t,tpl:l,markerPaths:i,attrEventPaths:a},be.set(e,n)}let{contexts:r,tpl:l}=n;function o(e,o){let i=l.content.cloneNode(!0),{disposes:a,postMountHooks:u}=ye(i,r,t,n.markerPaths,n.attrEventPaths),s=document.createComment(A.SCOPE);return e.insertBefore(s,o),e.insertBefore(i,o),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==o;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:o,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=o(t,null);return{unmount(){n()}}}}}function xe(e,t){if(x(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Se(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var R=null,z=null;function B(){if(!R)throw Error("[Nix] No active router. Call createRouter() first.");return R}function V(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function H(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function Ce(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function we(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function U(e,t="",n=[]){let r=[];for(let l of e){let e=we(t,l.path),o=[...n,l.component],i=Ce(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...U(l.children,e,o))}return r}function Te(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Ee(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function W(e,t){let n,r={},l=-1;for(let o of t){let t=Te(e,o);if(null===t)continue;let i=Ee(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function G(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function De(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return G(new URL(t,window.location.origin).pathname)}catch{return G(t)}}function Oe(e,t){let n=null==t?.base?De():G(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=U(e),a=W(o,i),u=p(o),s=p(a?.params??{}),c=p(V(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++h;if(0===o.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():b(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:V(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}z&&=(z(),null);let g=()=>{let e=r(),t=u.value,n=c.value,o=W(e,i),a=V(window.location.search);m(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+H(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+H(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=W(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",g),z=()=>window.removeEventListener("popstate",g);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=W(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=W(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return R&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),R=x,queueMicrotask(()=>{v||m(o,"",W(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=W("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function ke(){return B()}var Ae=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return L`<div class="router-view">${()=>{let t=B(),n=W(t.current.value,t._flat);return n?e>=n.route.chain.length?L`<span></span>`:n.route.chain[e]():L`<div style="color:#f87171;padding:16px 0">
1
+ var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(l){let o,a=!1,s=new Set,c=i,f=()=>{if(!a){if("function"==typeof o&&o(),s.forEach(e=>e._removeSub(f)),s=new Set,t.push(e),r.push(n),e=f,n=s,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{o=l()}catch(e){if(!c)throw e;c(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}}};return f(),()=>{a=!0,"function"==typeof o&&o(),s.forEach(e=>e._removeSub(f)),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose.bind(t);return t.dispose=()=>{n(),r()},t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,l=n;e=null,n=null;try{return t()}finally{e=r,n=l}}function v(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;_(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,_(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function ee(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function D(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function O(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var k={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function te(){return{el:null}}function ne(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function re(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function A(e,t,n){let r,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ie(e,t,n){let r,l;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function j(e,t,n,r){let l,o;ee(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function ae(e,t,n,r,l){let o,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{E()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function oe(){return{__isPortalOutlet:!0,_container:null}}function se(e){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(t,n){let r=document.createElement("div");return r.setAttribute("data-nix-outlet",""),e._container=r,t.insertBefore(r,n),()=>{e._container=null,r.remove()}}}}function ce(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,x(e)?A(e,l,null):e._render(l,null)}}}var le=S("nix:portal-outlet");function ue(e){D(le,e)}function de(){return O(le)}function fe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(k.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function pe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function me(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function M(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(me(r.transitionDuration||"0"),me(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},o)})}function he(e,t={}){let n=pe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(k.TRANSITION);r.insertBefore(o,l);let i=null,a=null,u=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return x(e)?ie(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await M(l,t.duration),u===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),u===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,o.remove()}}}}function ge(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.match(/@([\w:.-]+)=["']?$/);if(l){let e=l[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}}let o=r.match(/([\w:.-]+)=["']?$/);return o?{type:"attr",attrName:o[1],hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}:{type:"node"}}function _e(e,t){let n=new Set,r="";for(let l=0;l<e.length;l++){let o=e[l];if(n.has(l)&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&n.add(l+1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&n.add(l+1)}}else r+=o}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ve(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function P(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode,t=0,l=e.firstChild;for(;l&&l!==r;)t++,l=l.nextSibling;n.unshift(t),r=e}return n}function ye(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e],l=n.firstChild;for(let e=0;e<r;e++)l=l.nextSibling;n=l}return n}var F={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};function be(e,t,n,r){let l=[],o=[];for(let i=0;i<t.length;i++){let a=t[i],u=n[i],s=r[i];if(!s)continue;let c=ye(e,s.path);if("event"===a.type){let e=s.name,t=u,n=a.modifiers,r={};n.includes("once")&&(r.once=!0),n.includes("capture")&&(r.capture=!0),n.includes("passive")&&(r.passive=!0);let o=e=>{if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),!n.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of n){let n=F[e];if(void 0!==n&&t.key!==n||!F[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}t(e)}};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r));continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,l.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=m(()=>{let t=!!u(),l="show"===e?t:!t;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"});l.push(t)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r=m(()=>{let r=u();n?t[e]=r??"":null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,String(r))});l.push(r)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;if("function"!=typeof u){if(x(u))ae(u,f.parentNode,f,o,l);else if(N(u)){let e=u._render(f.parentNode,f);l.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,f.parentNode,f,o,l):N(e)?e._render(f.parentNode,f):null!=e&&!1!==e&&f.parentNode.insertBefore(document.createTextNode(String(e)),f);else null!=u&&!1!==u&&f.parentNode.insertBefore(document.createTextNode(String(u)),f);continue}let d=null,p=null,h=null,v=null,y=w(),g=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return p&&=(p(),null),void(d?d.nodeValue=String(e):(d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)));if(d&&=(d.parentNode?.removeChild(d),null),p&&=(p(),null),null!=e&&!1!==e)if(N(e))p=e._render(f.parentNode,f);else if(x(e))p=j(e,f.parentNode,f,y);else if(ve(e)){h||(h=new Map,v=document.createComment(k.KEYED_ZONE),f.parentNode.insertBefore(v,f));let t=f.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(h.size>0)for(let e of h.keys())if(r.has(e)){l=!0;break}if(!l){if(h.size>0){let e=document.createRange();e.setStartAfter(v),e.setEndBefore(f),e.deleteContents();for(let e of h.values())e.cleanup();h.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createComment(k.KEYED_START),a=document.createComment(k.KEYED_END);r.appendChild(i);let u=e.renderFn(o,t),s=x(u)?j(u,r,null,y):u._render(r,null);r.appendChild(a),h.set(l,{start:i,end:a,cleanup:s})}t.insertBefore(r,f)}return}for(let[e,t]of h.entries())if(!r.has(e)){let n=t.start;for(;n;){let e=n===t.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!e)break;n=e}t.cleanup(),h.delete(e)}let o=f;for(let r=n.length-1;r>=0;r--){let l=n[r];if(h.has(l)){let e=h.get(l);if(e.end.nextSibling!==o){let n=document.createDocumentFragment(),r=e.start;for(;;){let t=r===e.end?null:r.nextSibling;if(n.appendChild(r),!t)break;r=t}t.insertBefore(n,o)}o=e.start}else{let l=r;for(;l>0&&!h.has(n[l-1]);)l--;let i=document.createDocumentFragment(),a=[];for(let t=l;t<=r;t++){let r=n[t],l=e.items[t],o=document.createComment(k.KEYED_START),u=document.createComment(k.KEYED_END);i.appendChild(o);let s=e.renderFn(l,t),c=x(s)?j(s,i,null,y):s._render(i,null);i.appendChild(u),a.push({key:r,start:o,end:u,cleanup:c})}t.insertBefore(i,o);for(let e of a)h.set(e.key,e);o=a[0].start,r=l}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(A(n,f.parentNode,f));else if(N(n))t.push(n._render(f.parentNode,f));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));f.parentNode.insertBefore(e,f),t.push(()=>e.parentNode?.removeChild(e))}p=()=>t.forEach(e=>e())}else d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)});l.push(()=>{if(g(),p&&=(p(),null),d&&=(d.parentNode?.removeChild(d),null),h){for(let e of h.values())e.cleanup();h=null,v=null}})}return{disposes:l,postMountHooks:o}}var xe=new WeakMap;function I(e,...t){let n=xe.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ge(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=_e(e,t);let o,i=Array(t.length).fill(null),a=l.content,u=document.createTreeWalker(a,NodeFilter.SHOW_COMMENT);for(;o=u.nextNode();){let e=o,t=e.nodeValue?.match(/^nix-(\d+)$/);if(t){let n=parseInt(t[1]);i[n]={path:P(a,e)}}}a.querySelectorAll("*").forEach(e=>{let t=Array.from(e.attributes);for(let n of t){let t=n.name.match(/^data-nix-e-(\d+)$/);if(t){let r=parseInt(t[1]);i[r]={path:P(a,e),name:n.value},e.removeAttribute(n.name);continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);i[r]={path:P(a,e),name:n.value},e.removeAttribute(n.name)}}}),n={contexts:t,tpl:l,pathMap:i},xe.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:a,postMountHooks:u}=be(i,r,t,o),s=document.createComment(k.SCOPE);return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Se(e,t){if(x(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Ce(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=p(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var L=null,R=null;function z(){if(!L)throw Error("[Nix] No active router. Call createRouter() first.");return L}function B(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function V(e){let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&!1!==r&&t.set(n,String(r));let n=t.toString();return n?"?"+n:""}function we(e){return"*"===e?[{kind:"wildcard"}]:e.split("/").filter(Boolean).map(e=>"*"===e?{kind:"wildcard"}:e.startsWith(":")?{kind:"param",name:e.slice(1)}:{kind:"literal",value:e})}function Te(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function H(e,t="",n=[]){let r=[];for(let l of e){let e=Te(t,l.path),o=[...n,l.component],i=we(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...H(l.children,e,o))}return r}function Ee(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function De(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function U(e,t){let n,r={},l=-1;for(let o of t){let t=Ee(e,o);if(null===t)continue;let i=De(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function W(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Oe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return W(new URL(t,window.location.origin).pathname)}catch{return W(t)}}function ke(e,t){let n=null==t?.base?Oe():W(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=H(e),a=U(o,i),u=p(o),s=p(a?.params??{}),c=p(B(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++h;if(0===o.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():b(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:B(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}R&&=(R(),null);let g=()=>{let e=r(),t=u.value,n=c.value,o=U(e,i),a=B(window.location.search);m(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+V(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+V(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=U(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",g),R=()=>window.removeEventListener("popstate",g);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=U(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=U(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return L&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),L=x,queueMicrotask(()=>{v||m(o,"",U(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=U("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Ae(){return z()}var je=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=z(),n=U(t.current.value,t._flat);return n?e>=n.route.chain.length?I`<span></span>`:n.route.chain[e]():I`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},je=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return L`<a
4
- href=${(B()._base||"")+(e.startsWith("/")?e:"/"+e)}
5
- style=${()=>B().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
6
- @click=${t=>{t.preventDefault(),B().navigate(e)}}
7
- >${t}</a>`}};function K(){return L`
3
+ </div>`}}</div>`}},Me=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return I`<a
4
+ href=${(z()._base||"")+(e.startsWith("/")?e:"/"+e)}
5
+ style=${()=>z().current.value===e?"color:#38bdf8;font-weight:700;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px;background:#0c2a3a":"color:#a3a3a3;text-decoration:none;cursor:pointer;padding:4px 10px;border-radius:4px"}
6
+ @click=${t=>{t.preventDefault(),z().navigate(e)}}
7
+ >${t}</a>`}};function G(){return I`
8
8
  <span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
9
9
  <span class="nix-spinner" style="
10
10
  display:inline-block;width:14px;height:14px;border-radius:50%;
@@ -14,8 +14,8 @@ var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s()
14
14
  Loading…
15
15
  </span>
16
16
  <style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
17
- `}function q(e){return L`
17
+ `}function K(e){return I`
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `}var J=new Map,Me=3e5,Y=null,Ne=Me;function Pe(){null===Y&&(Y=setInterval(()=>{let e=Date.now();for(let[t,n]of J)n.subscribers<=0&&e-n.fetchedAt>Ne&&J.delete(t);0===J.size&&null!==Y&&(clearInterval(Y),Y=null)},6e4))}function X(e){return J.get(e)}function Fe(e,t){let n=J.get(e);J.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Pe()}function Ie(e){let t=J.get(e);t&&t.subscribers++}function Le(e){let t=J.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Re(e,t){let n=J.get(e);return!!n&&Date.now()-n.fetchedAt<t}function ze(e){void 0===e?J.clear():J.delete(e)}function Be(e){Ne=e}function Ve(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??K(),c=l??q;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?X(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ie(a);let e=a?X(a):void 0;if(e&&Re(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&J.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Le(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Fe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return L`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function He(e){J.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Ue(e,t,n,r={}){let{fallback:l,errorFallback:o,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=l??K(),c=o??q;return new class extends b{_state;constructor(){super();let t=X(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Ie(e);let r=X(e),l=Re(e,a);return r?!1===u||"stale"===u&&l||"always"===u&&l&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),Le(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Fe(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return L`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function We(e,t){let n=null;return()=>n?new n:Ve(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Ge(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ke(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function qe(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function Je(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Ye(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Xe(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Ze(e){return e}const Qe={required:Ge,minLength:Ke,maxLength:qe,email:Je,pattern:Q,min:Ye,max:Xe};function $e(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=p(e),l=p(!1),o=p(!1),i=p(null),a=p(!1),u=h(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?a.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:u,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function et(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=p(e.map(r)),o=h(()=>l.value.length);return{fields:l,append:function(e){l.value=[...l.value,r(e)]},remove:function(e){let t=l.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();l.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...l.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),l.value=n},replace:function(e,t){let n=[...l.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),l.value=n}},length:o,reset:function(){for(let e of l.value)for(let t in e)e[t]._dispose();l.value=e.map(r)},_dispose:function(){for(let e of l.value)for(let t in e)e[t]._dispose();o.dispose()}}}function tt(e,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=p(!1),o=p(0),i=h(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=h(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=h(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=h(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=h(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:a,valid:u,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let a=i.value;if(t.validate){let e=t.validate(a);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let u=e(a);u instanceof Promise&&(l.value=!0,u.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}export{je as Link,b as NixComponent,Ae as RouterView,f as Signal,g as batch,ze as clearQueryCache,h as computed,pe as createErrorBoundary,tt as createForm,S as createInjectionKey,se as createPortalOutlet,Ue as createQuery,Oe as createRouter,Se as createStore,Ze as createValidator,m as effect,Je as email,$e as extendValidators,L as html,k as inject,fe as injectOutlet,He as invalidateQueries,We as lazy,Xe as max,qe as maxLength,Ye as min,Ke as minLength,xe as mount,y as nextTick,Q as pattern,le as portal,ce as portalOutlet,O as provide,de as provideOutlet,ee as ref,ne as repeat,Ge as required,Be as setQueryCacheTime,te as showWhen,p as signal,Ve as suspend,he as transition,_ as untrack,$ as useField,et as useFieldArray,ke as useRouter,Qe as validators,v as watch};
21
+ `}var q=new Map,Ne=3e5,J=null,Pe=Ne;function Fe(){null===J&&(J=setInterval(()=>{let e=Date.now();for(let[t,n]of q)n.subscribers<=0&&e-n.fetchedAt>Pe&&q.delete(t);0===q.size&&null!==J&&(clearInterval(J),J=null)},6e4))}function Y(e){return q.get(e)}function Ie(e,t){let n=q.get(e);q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Fe()}function Le(e){let t=q.get(e);t&&t.subscribers++}function Re(e){let t=q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function ze(e,t){let n=q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Be(e){void 0===e?q.clear():q.delete(e)}function Ve(e){Pe=e}function X(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??G(),c=l??K;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Y(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Le(a);let e=a?Y(a):void 0;if(e&&ze(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&q.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Re(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Ie(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Z=new Map;function He(e){q.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Ue(e,t,n,r={}){let{fallback:l,errorFallback:o,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=l??G(),c=o??K;return new class extends b{_state;constructor(){super();let t=Y(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Le(e);let r=Y(e),l=ze(e,a);return r?!1===u||"stale"===u&&l||"always"===u&&l&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),Re(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Ie(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function We(e,t){let n=null;return()=>n?new n:X(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Ge(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ke(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function qe(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function Je(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Ye(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Xe(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Ze(e){return e}const Qe={required:Ge,minLength:Ke,maxLength:qe,email:Je,pattern:Q,min:Ye,max:Xe};function $e(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=p(e),l=p(!1),o=p(!1),i=p(null),a=p(!1),u=h(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?a.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:u,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function et(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=p(e.map(r)),o=h(()=>l.value.length);return{fields:l,append:function(e){l.value=[...l.value,r(e)]},remove:function(e){let t=l.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();l.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...l.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),l.value=n},replace:function(e,t){let n=[...l.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),l.value=n}},length:o,reset:function(){for(let e of l.value)for(let t in e)e[t]._dispose();l.value=e.map(r)},_dispose:function(){for(let e of l.value)for(let t in e)e[t]._dispose();o.dispose()}}}function tt(e,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=p(!1),o=p(0),i=h(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=h(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=h(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=h(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=h(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:a,valid:u,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let a=i.value;if(t.validate){let e=t.validate(a);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let u=e(a);u instanceof Promise&&(l.value=!0,u.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}export{Me as Link,b as NixComponent,je as RouterView,f as Signal,g as batch,Be as clearQueryCache,h as computed,fe as createErrorBoundary,tt as createForm,S as createInjectionKey,oe as createPortalOutlet,Ue as createQuery,ke as createRouter,Ce as createStore,Ze as createValidator,m as effect,Je as email,$e as extendValidators,I as html,O as inject,de as injectOutlet,He as invalidateQueries,We as lazy,Xe as max,qe as maxLength,Ye as min,Ke as minLength,Se as mount,y as nextTick,Q as pattern,ce as portal,se as portalOutlet,D as provide,ue as provideOutlet,te as ref,re as repeat,Ge as required,Ve as setQueryCacheTime,ne as showWhen,p as signal,X as suspend,he as transition,_ as untrack,$ as useField,et as useFieldArray,Ae as useRouter,Qe as validators,v as watch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deijose/nix-js",
3
- "version": "1.7.1",
3
+ "version": "1.7.2-beta.0",
4
4
  "description": "A lightweight, fully reactive micro-framework — no virtual DOM, no compiler, just signals and tagged templates.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://nix-js-landing.vercel.app/",