@deijose/nix-js 1.0.0 → 1.0.2

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,4 +1,4 @@
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=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 d(e){return new u(e)}function f(o){let l,u=new Set,a=i,s=()=>{"function"==typeof l&&l(),u.forEach(e=>e._removeSub(s)),u=new Set,t.push(e),r.push(n),e=s,n=u;try{l=o()}catch(e){if(!a)throw e;a(e)}finally{e=t.pop()||null,n=r.pop()||null}};return s(),()=>{"function"==typeof l&&l(),u.forEach(e=>e._removeSub(s)),u.clear()}}function p(e){let t=new u(void 0);return f(()=>{t.value=e()}),t}function m(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function h(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function ee(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof u?()=>e.value:e,a=!0,s=!1,c=f(()=>{let e=i();if(a){if(a=!1,o&&!s){let n=e;h(()=>t(n,void 0)),l&&(s=!0,Promise.resolve().then(c))}r=e}else if(!s){let n=e,o=r;r=e,h(()=>t(n,o)),l&&(s=!0,Promise.resolve().then(c))}});return()=>{s=!0,c()}}function g(e){return e?Promise.resolve().then(e):Promise.resolve()}var _=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 v(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function y(e){return Symbol(e)}var b=[];function x(){return[...b]}function S(){b.push(new Map)}function C(){b.pop()}function w(e,t){let n=b.splice(0);e.forEach(e=>b.push(e)),b.push(new Map);try{return t()}finally{b.splice(0),n.forEach(e=>b.push(e))}}function T(e,t){let n=b[b.length-1];if(!n)throw Error("[Nix] provide() debe llamarse dentro de onInit() de un NixComponent.");n.set(e,t)}function E(e){for(let t=b.length-1;t>=0;t--)if(b[t].has(e))return b[t].get(e)}function D(){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 O(){return{__isPortalOutlet:!0,_container:null}}function re(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 ie(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;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,v(e)){let t,n;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{C()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var k=y("nix:portal-outlet");function A(e){T(k,e)}function ae(){return E(k)}function oe(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("nix-eb");n.insertBefore(l,r);let i,u=null,a=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||v(t)?t:t(e);if(v(o)){let e,t;S();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{C()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}u=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else u=o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(v(e)){S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{C()}if(!a)try{let t=e.onMount?.(),n=u;u=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else u=e._render(n,r)}catch(e){a=!0,u?.(),u=null,i=e,f=!0}finally{s(),c=!0}return f&&(u?.(),u=null,d(i)),()=>{u?.(),l.remove()}}}}function se(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)||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>0?t:0;if(l<=0)return void n();let i,u=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n())};e.addEventListener("transitionend",u),e.addEventListener("animationend",u),i=setTimeout(()=>{e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n()},l)})}function ce(e,t={}){let n=se(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("nix-t");r.insertBefore(l,o);let i=null,u=null,a=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 d(e){if(v(e)){let t,n=e;S();try{try{n.onInit?.()}catch{}t=n.render()}finally{C()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let p=(e,r=!1)=>{a++,u&&=(u(),null),i=d(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=a;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await M(o,t.duration),a===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},h=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++a;u=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),a===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=null))})().catch(()=>{})},m=null;if("function"!=typeof e||v(e))p(e);else{let t=e,n=null;m=f(()=>{let e=t(),r=null===n,o=null===e;r&&!o?p(e):!r&&o?h():!r&&!o&&(a++,u?.(),u=null,i?.(),i=null,p(e,!0)),n=e}),s=!1}return()=>{a++,m?.(),i?.(),u?.(),i=null,u=null,l.remove()}}}}function le(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 ue(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[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[o+1]=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[o+1]=1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function de(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function fe(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function P(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function F(e,t,n){let r=[],o=[],l=fe(e),i=P(e);for(let e=0;e<t.length;e++){let u=t[e],a=n[e];if("event"===u.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=a,s=u.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=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=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===u.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){a.el=n,r.push(()=>{a.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof a){let n=f(()=>{let n=!!a(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?a:!a)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof a){let e=f(()=>{let e=a();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=a??"":null!=a&&!1!==a&&n.setAttribute(o,String(a));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof a){if(v(a)){let e,n,l=a;S();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(N(a)){let e=a._render(s.parentNode,s);r.push(e)}else if(Array.isArray(a))for(let e of a)if(v(e)){let n,l;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=a&&!1!==a&&s.parentNode.insertBefore(document.createTextNode(String(a)),s);continue}let c=null,d=null,p=null,h=x(),m=f(()=>{let e=a();if("string"==typeof e||"number"==typeof e)return d&&=(d(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),d&&=(d(),null),null!=e&&!1!==e)if(N(e))d=e._render(s.parentNode,s);else if(v(e)){let t,n,r=e;w(h,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}d=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(de(e)){p||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of p)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),p.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(p.has(l)){let e=p.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;for(let e of n)t.insertBefore(e,o)}o=e.start}else{let n=document.createComment("nix-ke"),u=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(u,n);let a,s=e.renderFn(i,r);if(v(s)){let r,o;w(h,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}a=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else a=s._render(t,n);p.set(l,{start:u,end:n,cleanup:a}),o=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(v(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}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))}d=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(m(),d&&=(d(),null),c&&=(c.parentNode?.removeChild(c),null),p){for(let e of p.values())e.cleanup();p=null}})}return{disposes:r,postMountHooks:o}}function I(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=le(r);n.push(o),r+="__nix__"}let o=ue(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:u,postMountHooks:a}=F(i,n,t),s=document.createComment("nix-scope");e.insertBefore(s,r);let c=i.firstChild;for(;c;){let t=c.nextSibling;e.insertBefore(c,r),c=t}return a.forEach(e=>e()),()=>{u.forEach(e=>e());let e=s.nextSibling;for(;e&&e!==r;){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 L(e,t){if(v(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: contenedor no encontrado: ${t}`);S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{C()}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 R(e,t){let n={};for(let t of Object.keys(e))n[t]=d(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);Object.assign(o,e)}return o}var z=null;function B(){if(!z)throw Error("[Nix] No hay router activo. Llama a createRouter() antes.");return z}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 pe(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 me(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=me(t,o.path),l=[...n,o.component],i=pe(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 he(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"param"===t.kind&&(i[t.name]=decodeURIComponent(n[e]??""))}return i}function ge(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=he(e,l);if(null===t)continue;let i=ge(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function _e(e){function t(){return window.location.pathname||"/"}let n=t(),r=U(e),o=W(n,r),l=d(n),i=d(o?.params??{}),u=d(V(window.location.search)),a=[];function s(e,t,n,r,o){let l=[...a];if(n&&l.push(n),0===l.length)return void r();let i=0;!function n(u){if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():c(u));if(i>=l.length)return void r();let a=l[i++](e,t);a instanceof Promise?a.then(n):n(a)}(void 0)}function c(e,t){let{pathname:n,stringQuery:o}=function(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}}(e,t),a=l.value,c=W(n,r);s(n,a,c?.route.beforeEnter,()=>{i.value=c?.params??{},u.value=o,l.value=n,history.pushState(null,"",n+H(o))})}window.addEventListener("popstate",()=>{let e=t(),n=l.value,o=u.value,a=W(e,r),c=V(window.location.search);s(e,n,a?.route.beforeEnter,()=>{i.value=a?.params??{},u.value=c,l.value=e},()=>{history.pushState(null,"",n+H(o))})});let f={current:l,params:i,query:u,navigate:c,beforeEach:function(e){return a.push(e),()=>{let t=a.indexOf(e);-1!==t&&a.splice(t,1)}},routes:e,_flat:r,_guards:a};return z=f,f}function ve(){return B()}var ye=class extends _{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=B(),n=W(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">
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=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 d(e){return new u(e)}function f(o){let l,u=new Set,a=i,s=()=>{"function"==typeof l&&l(),u.forEach(e=>e._removeSub(s)),u=new Set,t.push(e),r.push(n),e=s,n=u;try{l=o()}catch(e){if(!a)throw e;a(e)}finally{e=t.pop()||null,n=r.pop()||null}};return s(),()=>{"function"==typeof l&&l(),u.forEach(e=>e._removeSub(s)),u.clear()}}function p(e){let t=new u(void 0);return f(()=>{t.value=e()}),t}function m(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function h(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function ee(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof u?()=>e.value:e,a=!0,s=!1,c=f(()=>{let e=i();if(a){if(a=!1,o&&!s){let n=e;h(()=>t(n,void 0)),l&&(s=!0,Promise.resolve().then(c))}r=e}else if(!s){let n=e,o=r;r=e,h(()=>t(n,o)),l&&(s=!0,Promise.resolve().then(c))}});return()=>{s=!0,c()}}function g(e){return e?Promise.resolve().then(e):Promise.resolve()}var _=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 v(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function y(e){return Symbol(e)}var b=[];function x(){return[...b]}function S(){b.push(new Map)}function C(){b.pop()}function w(e,t){let n=b.splice(0);e.forEach(e=>b.push(e)),b.push(new Map);try{return t()}finally{b.splice(0),n.forEach(e=>b.push(e))}}function T(e,t){let n=b[b.length-1];if(!n)throw Error("[Nix] provide() debe llamarse dentro de onInit() de un NixComponent.");n.set(e,t)}function E(e){for(let t=b.length-1;t>=0;t--)if(b[t].has(e))return b[t].get(e)}function D(){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 O(){return{__isPortalOutlet:!0,_container:null}}function re(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 ie(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;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,v(e)){let t,n;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{C()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var k=y("nix:portal-outlet");function A(e){T(k,e)}function ae(){return E(k)}function oe(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("nix-eb");n.insertBefore(l,r);let i,u=null,a=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||v(t)?t:t(e);if(v(o)){let e,t;S();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{C()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}u=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else u=o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(v(e)){S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{C()}if(!a)try{let t=e.onMount?.(),n=u;u=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else u=e._render(n,r)}catch(e){a=!0,u?.(),u=null,i=e,f=!0}finally{s(),c=!0}return f&&(u?.(),u=null,d(i)),()=>{u?.(),l.remove()}}}}function se(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)||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>0?t:0;if(l<=0)return void n();let i,u=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n())};e.addEventListener("transitionend",u),e.addEventListener("animationend",u),i=setTimeout(()=>{e.removeEventListener("transitionend",u),e.removeEventListener("animationend",u),n()},l)})}function ce(e,t={}){let n=se(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("nix-t");r.insertBefore(l,o);let i=null,u=null,a=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 d(e){if(v(e)){let t,n=e;S();try{try{n.onInit?.()}catch{}t=n.render()}finally{C()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let p=(e,r=!1)=>{a++,u&&=(u(),null),i=d(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=a;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await M(o,t.duration),a===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},h=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++a;u=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),a===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=null))})().catch(()=>{})},m=null;if("function"!=typeof e||v(e))p(e);else{let t=e,n=null;m=f(()=>{let e=t(),r=null===n,o=null===e;r&&!o?p(e):!r&&o?h():!r&&!o&&(a++,u?.(),u=null,i?.(),i=null,p(e,!0)),n=e}),s=!1}return()=>{a++,m?.(),i?.(),u?.(),i=null,u=null,l.remove()}}}}function le(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 ue(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[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[o+1]=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[o+1]=1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function de(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function fe(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function P(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function F(e,t,n){let r=[],o=[],l=fe(e),i=P(e);for(let e=0;e<t.length;e++){let u=t[e],a=n[e];if("event"===u.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=a,s=u.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=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=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===u.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){a.el=n,r.push(()=>{a.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof a){let n=f(()=>{let n=!!a(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?a:!a)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof a){let e=f(()=>{let e=a();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=a??"":null!=a&&!1!==a&&n.setAttribute(o,String(a));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof a){if(v(a)){let e,n,l=a;S();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(N(a)){let e=a._render(s.parentNode,s);r.push(e)}else if(Array.isArray(a))for(let e of a)if(v(e)){let n,l;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=a&&!1!==a&&s.parentNode.insertBefore(document.createTextNode(String(a)),s);continue}let c=null,d=null,p=null,h=x(),m=f(()=>{let e=a();if("string"==typeof e||"number"==typeof e)return d&&=(d(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),d&&=(d(),null),null!=e&&!1!==e)if(N(e))d=e._render(s.parentNode,s);else if(v(e)){let t,n,r=e;w(h,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}d=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(de(e)){p||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of p)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),p.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(p.has(l)){let e=p.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;for(let e of n)t.insertBefore(e,o)}o=e.start}else{let n=document.createComment("nix-ke"),u=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(u,n);let a,s=e.renderFn(i,r);if(v(s)){let r,o;w(h,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}a=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else a=s._render(t,n);p.set(l,{start:u,end:n,cleanup:a}),o=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(v(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}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))}d=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(m(),d&&=(d(),null),c&&=(c.parentNode?.removeChild(c),null),p){for(let e of p.values())e.cleanup();p=null}})}return{disposes:r,postMountHooks:o}}function I(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=le(r);n.push(o),r+="__nix__"}let o=ue(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:u,postMountHooks:a}=F(i,n,t),s=document.createComment("nix-scope");e.insertBefore(s,r);let c=i.firstChild;for(;c;){let t=c.nextSibling;e.insertBefore(c,r),c=t}return a.forEach(e=>e()),()=>{u.forEach(e=>e());let e=s.nextSibling;for(;e&&e!==r;){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 L(e,t){if(v(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: contenedor no encontrado: ${t}`);S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{C()}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 R(e,t){let n={};for(let t of Object.keys(e))n[t]=d(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);Object.assign(o,e)}return o}var z=null;function B(){if(!z)throw Error("[Nix] No hay router activo. Llama a createRouter() antes.");return z}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 pe(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 me(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=me(t,o.path),l=[...n,o.component],i=pe(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 he(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"param"===t.kind&&(i[t.name]=decodeURIComponent(n[e]??""))}return i}function ge(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=he(e,l);if(null===t)continue;let i=ge(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function _e(e){function t(){return window.location.pathname||"/"}let n=t(),r=U(e),o=W(n,r),l=d(n),i=d(o?.params??{}),u=d(V(window.location.search)),a=[];function s(e,t,n,r,o){let l=[...a];if(n&&l.push(n),0===l.length)return void r();let i=0;!function n(u){if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():c(u));if(i>=l.length)return void r();let a=l[i++](e,t);a instanceof Promise?a.then(n):n(a)}(void 0)}function c(e,t){let{pathname:n,stringQuery:o}=function(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}}(e,t),a=l.value,c=W(n,r);s(n,a,c?.route.beforeEnter,()=>{i.value=c?.params??{},u.value=o,l.value=n,history.pushState(null,"",n+H(o))})}window.addEventListener("popstate",()=>{let e=t(),n=l.value,o=u.value,a=W(e,r),c=V(window.location.search);s(e,n,a?.route.beforeEnter,()=>{i.value=a?.params??{},u.value=c,l.value=e},()=>{history.pushState(null,"",n+H(o))})});let f={current:l,params:i,query:u,navigate:c,beforeEach:function(e){return a.push(e),()=>{let t=a.indexOf(e);-1!==t&&a.splice(t,1)}},routes:e,_flat:r,_guards:a};return z=f,queueMicrotask(()=>{s(n,"",W(n,r)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"","/");let e=W("/",r);l.value="/",i.value=e?.params??{},u.value={}})}),f}function ve(){return B()}var ye=class extends _{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=B(),n=W(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 — Ruta no encontrada: <strong>${t.current.value}</strong>
3
3
  </div>`}}</div>`}},be=class extends _{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to;return I`<a
4
4
  href=${e}
@@ -18,4 +18,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `);return new class extends _{_state=d({status:"pending"});onMount(){this._run()}_run(){(l||"pending"===this._state.value.status)&&(this._state.value={status:"pending"}),e().then(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?i:"error"===e.status?u(e.error):t(e.data)}}</div>`}}}function xe(e,t){let n=null;return()=>n?new n:G(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function K(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function q(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function J(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Y(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function X(e="Invalid email"){return Y(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Z(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Se(e){return e}const Ce={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function we(e,t){return{...e,...t}}function $(e,t=[]){let n=d(e),r=d(!1),o=d(!1),l=d(null),i=p(()=>{if(l.value)return l.value;if(!r.value&&!o.value)return null;for(let e of t){let t=e(n.value);if(t)return t}return null});function u(t){return"boolean"==typeof e?t.checked:"number"==typeof e?Number(t.value):t.value}return{value:n,error:i,touched:r,dirty:o,onInput:e=>{n.value=u(e.target),o.value=!0,l.value=null},onBlur:()=>{r.value=!0},reset:function(){n.value=e,r.value=!1,o.value=!1,l.value=null},_setExternalError:function(e){l.value=e,e&&(r.value=!0)}}}function Te(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=p(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=p(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=p(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=p(()=>{for(let e in n)if(n[e].dirty.value)return!0;return!1});function u(e){for(let t in e)n[t]?._setExternalError(e[t]??null)}return{fields:n,values:r,errors:o,valid:l,dirty:i,handleSubmit:function(e){return o=>{o.preventDefault();for(let e in n)n[e].touched.value=!0;let l=r.value;if(t.validate){let e=t.validate(l);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 u(t)}}for(let e in n)if(n[e].error.value)return;e(l)}},reset:function(){for(let e in n)n[e].reset()},setErrors:u}}exports.Link=be,exports.NixComponent=_,exports.RouterView=ye,exports.Signal=u,exports.batch=m,exports.computed=p,exports.createErrorBoundary=oe,exports.createForm=Te,exports.createInjectionKey=y,exports.createPortalOutlet=O,exports.createRouter=_e,exports.createStore=R,exports.createValidator=Se,exports.effect=f,exports.email=X,exports.extendValidators=we,exports.html=I,exports.inject=E,exports.injectOutlet=ae,exports.lazy=xe,exports.max=Q,exports.maxLength=J,exports.min=Z,exports.minLength=q,exports.mount=L,exports.nextTick=g,exports.pattern=Y,exports.portal=ie,exports.portalOutlet=re,exports.provide=T,exports.provideOutlet=A,exports.ref=D,exports.repeat=ne,exports.required=K,exports.showWhen=te,exports.signal=d,exports.suspend=G,exports.transition=ce,exports.untrack=h,exports.useField=$,exports.useRouter=ve,exports.validators=Ce,exports.watch=ee;
21
+ `);return new class extends _{_state=d({status:"pending"});onMount(){this._run()}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),e().then(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?i:"error"===e.status?u(e.error):t(e.data)}}</div>`}}}function xe(e,t){let n=null;return()=>n?new n:G(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function K(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function q(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function J(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Y(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function X(e="Invalid email"){return Y(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Z(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Se(e){return e}const Ce={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function we(e,t){return{...e,...t}}function $(e,t=[]){let n=d(e),r=d(!1),o=d(!1),l=d(null),i=p(()=>{if(l.value)return l.value;if(!r.value&&!o.value)return null;for(let e of t){let t=e(n.value);if(t)return t}return null});function u(t){return"boolean"==typeof e?t.checked:"number"==typeof e?Number(t.value):t.value}return{value:n,error:i,touched:r,dirty:o,onInput:e=>{n.value=u(e.target),o.value=!0,l.value=null},onBlur:()=>{r.value=!0},reset:function(){n.value=e,r.value=!1,o.value=!1,l.value=null},_setExternalError:function(e){l.value=e,e&&(r.value=!0)}}}function Te(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=p(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=p(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=p(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=p(()=>{for(let e in n)if(n[e].dirty.value)return!0;return!1});function u(e){for(let t in e)n[t]?._setExternalError(e[t]??null)}return{fields:n,values:r,errors:o,valid:l,dirty:i,handleSubmit:function(e){return o=>{o.preventDefault();for(let e in n)n[e].touched.value=!0;let l=r.value;if(t.validate){let e=t.validate(l);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 u(t)}}for(let e in n)if(n[e].error.value)return;e(l)}},reset:function(){for(let e in n)n[e].reset()},setErrors:u}}exports.Link=be,exports.NixComponent=_,exports.RouterView=ye,exports.Signal=u,exports.batch=m,exports.computed=p,exports.createErrorBoundary=oe,exports.createForm=Te,exports.createInjectionKey=y,exports.createPortalOutlet=O,exports.createRouter=_e,exports.createStore=R,exports.createValidator=Se,exports.effect=f,exports.email=X,exports.extendValidators=we,exports.html=I,exports.inject=E,exports.injectOutlet=ae,exports.lazy=xe,exports.max=Q,exports.maxLength=J,exports.min=Z,exports.minLength=q,exports.mount=L,exports.nextTick=g,exports.pattern=Y,exports.portal=ie,exports.portalOutlet=re,exports.provide=T,exports.provideOutlet=A,exports.ref=D,exports.repeat=ne,exports.required=K,exports.showWhen=te,exports.signal=d,exports.suspend=G,exports.transition=ce,exports.untrack=h,exports.useField=$,exports.useRouter=ve,exports.validators=Ce,exports.watch=ee;
@@ -1,4 +1,4 @@
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=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 d(e){return new u(e)}function f(o){let l,a=new Set,u=i,s=()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(s)),a=new Set,t.push(e),r.push(n),e=s,n=a;try{l=o()}catch(e){if(!u)throw e;u(e)}finally{e=t.pop()||null,n=r.pop()||null}};return s(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(s)),a.clear()}}function p(e){let t=new u(void 0);return f(()=>{t.value=e()}),t}function m(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function h(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function ee(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof u?()=>e.value:e,a=!0,s=!1,c=f(()=>{let e=i();if(a){if(a=!1,o&&!s){let n=e;h(()=>t(n,void 0)),l&&(s=!0,Promise.resolve().then(c))}r=e}else if(!s){let n=e,o=r;r=e,h(()=>t(n,o)),l&&(s=!0,Promise.resolve().then(c))}});return()=>{s=!0,c()}}function g(e){return e?Promise.resolve().then(e):Promise.resolve()}var _=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 v(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function y(e){return Symbol(e)}var b=[];function x(){return[...b]}function S(){b.push(new Map)}function C(){b.pop()}function w(e,t){let n=b.splice(0);e.forEach(e=>b.push(e)),b.push(new Map);try{return t()}finally{b.splice(0),n.forEach(e=>b.push(e))}}function T(e,t){let n=b[b.length-1];if(!n)throw Error("[Nix] provide() debe llamarse dentro de onInit() de un NixComponent.");n.set(e,t)}function E(e){for(let t=b.length-1;t>=0;t--)if(b[t].has(e))return b[t].get(e)}function D(){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 O(){return{__isPortalOutlet:!0,_container:null}}function re(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 ie(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;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,v(e)){let t,n;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{C()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var k=y("nix:portal-outlet");function A(e){T(k,e)}function ae(){return E(k)}function oe(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("nix-eb");n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||v(t)?t:t(e);if(v(o)){let e,t;S();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{C()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}a=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else a=o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(v(e)){S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{C()}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 se(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)||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>0?t:0;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 ce(e,t={}){let n=se(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("nix-t");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 d(e){if(v(e)){let t,n=e;S();try{try{n.onInit?.()}catch{}t=n.render()}finally{C()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let p=(e,r=!1)=>{u++,a&&=(a(),null),i=d(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},h=()=>{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(()=>{})},m=null;if("function"!=typeof e||v(e))p(e);else{let t=e,n=null;m=f(()=>{let e=t(),r=null===n,o=null===e;r&&!o?p(e):!r&&o?h():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,p(e,!0)),n=e}),s=!1}return()=>{u++,m?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function le(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 ue(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[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[o+1]=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[o+1]=1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function de(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function fe(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function P(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function F(e,t,n){let r=[],o=[],l=fe(e),i=P(e);for(let e=0;e<t.length;e++){let a=t[e],u=n[e];if("event"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=u,s=a.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=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=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){u.el=n,r.push(()=>{u.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof u){let n=f(()=>{let n=!!u(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?u:!u)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof u){let e=f(()=>{let e=u();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=u??"":null!=u&&!1!==u&&n.setAttribute(o,String(u));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof u){if(v(u)){let e,n,l=u;S();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(N(u)){let e=u._render(s.parentNode,s);r.push(e)}else if(Array.isArray(u))for(let e of u)if(v(e)){let n,l;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=u&&!1!==u&&s.parentNode.insertBefore(document.createTextNode(String(u)),s);continue}let c=null,d=null,p=null,h=x(),m=f(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return d&&=(d(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),d&&=(d(),null),null!=e&&!1!==e)if(N(e))d=e._render(s.parentNode,s);else if(v(e)){let t,n,r=e;w(h,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}d=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(de(e)){p||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of p)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),p.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(p.has(l)){let e=p.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;for(let e of n)t.insertBefore(e,o)}o=e.start}else{let n=document.createComment("nix-ke"),a=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(a,n);let u,s=e.renderFn(i,r);if(v(s)){let r,o;w(h,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}u=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else u=s._render(t,n);p.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(v(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}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))}d=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(m(),d&&=(d(),null),c&&=(c.parentNode?.removeChild(c),null),p){for(let e of p.values())e.cleanup();p=null}})}return{disposes:r,postMountHooks:o}}function I(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=le(r);n.push(o),r+="__nix__"}let o=ue(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:a,postMountHooks:u}=F(i,n,t),s=document.createComment("nix-scope");e.insertBefore(s,r);let c=i.firstChild;for(;c;){let t=c.nextSibling;e.insertBefore(c,r),c=t}return u.forEach(e=>e()),()=>{a.forEach(e=>e());let e=s.nextSibling;for(;e&&e!==r;){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 L(e,t){if(v(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: contenedor no encontrado: ${t}`);S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{C()}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 R(e,t){let n={};for(let t of Object.keys(e))n[t]=d(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);Object.assign(o,e)}return o}var z=null;function B(){if(!z)throw Error("[Nix] No hay router activo. Llama a createRouter() antes.");return z}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 pe(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 me(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=me(t,o.path),l=[...n,o.component],i=pe(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 he(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"param"===t.kind&&(i[t.name]=decodeURIComponent(n[e]??""))}return i}function ge(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=he(e,l);if(null===t)continue;let i=ge(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function _e(e){function t(){return window.location.pathname||"/"}let n=t(),r=U(e),o=W(n,r),l=d(n),i=d(o?.params??{}),a=d(V(window.location.search)),u=[];function s(e,t,n,r,o){let l=[...u];if(n&&l.push(n),0===l.length)return void r();let i=0;!function n(a){if(!1===a)return void o?.();if("string"==typeof a)return void(a===e?r():c(a));if(i>=l.length)return void r();let u=l[i++](e,t);u instanceof Promise?u.then(n):n(u)}(void 0)}function c(e,t){let{pathname:n,stringQuery:o}=function(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}}(e,t),u=l.value,c=W(n,r);s(n,u,c?.route.beforeEnter,()=>{i.value=c?.params??{},a.value=o,l.value=n,history.pushState(null,"",n+H(o))})}window.addEventListener("popstate",()=>{let e=t(),n=l.value,o=a.value,u=W(e,r),c=V(window.location.search);s(e,n,u?.route.beforeEnter,()=>{i.value=u?.params??{},a.value=c,l.value=e},()=>{history.pushState(null,"",n+H(o))})});let f={current:l,params:i,query:a,navigate:c,beforeEach:function(e){return u.push(e),()=>{let t=u.indexOf(e);-1!==t&&u.splice(t,1)}},routes:e,_flat:r,_guards:u};return z=f,f}function ve(){return B()}var ye=class extends _{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=B(),n=W(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">
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=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 d(e){return new u(e)}function f(o){let l,a=new Set,u=i,s=()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(s)),a=new Set,t.push(e),r.push(n),e=s,n=a;try{l=o()}catch(e){if(!u)throw e;u(e)}finally{e=t.pop()||null,n=r.pop()||null}};return s(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(s)),a.clear()}}function p(e){let t=new u(void 0);return f(()=>{t.value=e()}),t}function m(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function h(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function ee(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof u?()=>e.value:e,a=!0,s=!1,c=f(()=>{let e=i();if(a){if(a=!1,o&&!s){let n=e;h(()=>t(n,void 0)),l&&(s=!0,Promise.resolve().then(c))}r=e}else if(!s){let n=e,o=r;r=e,h(()=>t(n,o)),l&&(s=!0,Promise.resolve().then(c))}});return()=>{s=!0,c()}}function g(e){return e?Promise.resolve().then(e):Promise.resolve()}var _=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 v(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function y(e){return Symbol(e)}var b=[];function x(){return[...b]}function S(){b.push(new Map)}function C(){b.pop()}function w(e,t){let n=b.splice(0);e.forEach(e=>b.push(e)),b.push(new Map);try{return t()}finally{b.splice(0),n.forEach(e=>b.push(e))}}function T(e,t){let n=b[b.length-1];if(!n)throw Error("[Nix] provide() debe llamarse dentro de onInit() de un NixComponent.");n.set(e,t)}function E(e){for(let t=b.length-1;t>=0;t--)if(b[t].has(e))return b[t].get(e)}function D(){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 O(){return{__isPortalOutlet:!0,_container:null}}function re(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 ie(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;if(o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,v(e)){let t,n;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{C()}try{let t=e.onMount?.();"function"==typeof t&&(n=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{n?.()}catch{}t()}}return e._render(o,null)}}}var k=y("nix:portal-outlet");function A(e){T(k,e)}function ae(){return E(k)}function oe(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("nix-eb");n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||v(t)?t:t(e);if(v(o)){let e,t;S();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{C()}try{let e=o.onMount?.();"function"==typeof e&&(t=e)}catch{}a=()=>{try{o.onUnmount?.()}catch{}t?.(),e()}}else a=o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(v(e)){S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{C()}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 se(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)||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>0?t:0;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 ce(e,t={}){let n=se(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("nix-t");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 d(e){if(v(e)){let t,n=e;S();try{try{n.onInit?.()}catch{}t=n.render()}finally{C()}let l,i=t._render(r,o);try{l=n.onMount?.()}catch{}return()=>{try{n.onUnmount?.()}catch{}if("function"==typeof l)try{l()}catch{}i()}}return e._render(r,o)}let p=(e,r=!1)=>{u++,a&&=(a(),null),i=d(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},h=()=>{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(()=>{})},m=null;if("function"!=typeof e||v(e))p(e);else{let t=e,n=null;m=f(()=>{let e=t(),r=null===n,o=null===e;r&&!o?p(e):!r&&o?h():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,p(e,!0)),n=e}),s=!1}return()=>{u++,m?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function le(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 ue(e,t){let n=Array(e.length).fill(0),r="";for(let o=0;o<e.length;o++){let l=e[o];if(1===n[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[o+1]=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[o+1]=1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function de(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function fe(e){let t,n=new Map,r=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT);for(;t=r.nextNode();){let e=t,r=e.nodeValue?.match(/^nix-(\d+)$/);r&&n.set(parseInt(r[1]),e)}return n}function P(e){let t=new Map;return e.querySelectorAll("*").forEach(e=>{let n=Array.from(e.attributes);for(let r of n){let n=r.name.match(/^data-nix-e-(\d+)$/);n?(t.set(parseInt(n[1]),{el:e,type:"event",name:r.value}),e.removeAttribute(r.name)):(n=r.name.match(/^data-nix-a-(\d+)$/),n&&(t.set(parseInt(n[1]),{el:e,type:"attr",name:r.value}),e.removeAttribute(r.name)))}}),t}function F(e,t,n){let r=[],o=[],l=fe(e),i=P(e);for(let e=0;e<t.length;e++){let a=t[e],u=n[e];if("event"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t,l=u,s=a.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},d=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=f[e];if(void 0!==n&&t.key!==n||!f[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}l(e)}};n.addEventListener(o,d,c),r.push(()=>n.removeEventListener(o,d,c));continue}if("attr"===a.type){let t=i.get(e);if(!t)continue;let{el:n,name:o}=t;if("ref"===o){u.el=n,r.push(()=>{u.el=null});continue}if("show"===o||"hide"===o){let e=n,t=null;if("function"==typeof u){let n=f(()=>{let n=!!u(),r="show"===o?n:!n;null===t&&(t=e.style.display||""),e.style.display=r?t:"none"});r.push(n)}else("show"===o?u:!u)||(n.style.display="none");continue}let l=("value"===o||"checked"===o||"selected"===o)&&o in n;if("function"==typeof u){let e=f(()=>{let e=u();l?n[o]=e??"":null==e||!1===e?n.removeAttribute(o):n.setAttribute(o,String(e))});r.push(e)}else l?n[o]=u??"":null!=u&&!1!==u&&n.setAttribute(o,String(u));continue}let s=l.get(e);if(!s)continue;if("function"!=typeof u){if(v(u)){let e,n,l=u;S();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let e=l.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!l.onError)throw e;l.onError(e)}}),r.push(()=>{try{l.onUnmount?.()}catch{}try{n?.()}catch{}e()})}else if(N(u)){let e=u._render(s.parentNode,s);r.push(e)}else if(Array.isArray(u))for(let e of u)if(v(e)){let n,l;S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{C()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),r.push(()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}n()})}else N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=u&&!1!==u&&s.parentNode.insertBefore(document.createTextNode(String(u)),s);continue}let c=null,d=null,p=null,h=x(),m=f(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return d&&=(d(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),d&&=(d(),null),null!=e&&!1!==e)if(N(e))d=e._render(s.parentNode,s);else if(v(e)){let t,n,r=e;w(h,()=>{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}t=r.render()._render(s.parentNode,s)});try{let e=r.onMount?.();"function"==typeof e&&(n=e)}catch(e){if(!r.onError)throw e;r.onError(e)}d=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(de(e)){p||=new Map;let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);for(let[e,n]of p)if(!r.has(e)){n.cleanup();let r=n.start;for(;r!==n.end;){let e=r.nextSibling;t.removeChild(r),r=e}t.removeChild(n.end),p.delete(e)}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(p.has(l)){let e=p.get(l);if(e.end.nextSibling!==o){let n=[],r=e.start;for(;n.push(r),r!==e.end;)r=r.nextSibling;for(let e of n)t.insertBefore(e,o)}o=e.start}else{let n=document.createComment("nix-ke"),a=document.createComment("nix-ks");t.insertBefore(n,o),t.insertBefore(a,n);let u,s=e.renderFn(i,r);if(v(s)){let r,o;w(h,()=>{try{s.onInit?.()}catch(e){if(!s.onError)throw e;s.onError(e)}r=s.render()._render(t,n)});try{let e=s.onMount?.();"function"==typeof e&&(o=e)}catch(e){if(!s.onError)throw e;s.onError(e)}u=()=>{try{s.onUnmount?.()}catch{}try{o?.()}catch{}r()}}else u=s._render(t,n);p.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(v(n)){try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}let r,o=n.render()._render(s.parentNode,s);try{let e=n.onMount?.();"function"==typeof e&&(r=e)}catch(e){if(!n.onError)throw e;n.onError(e)}t.push(()=>{try{n.onUnmount?.()}catch{}try{r?.()}catch{}o()})}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))}d=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(m(),d&&=(d(),null),c&&=(c.parentNode?.removeChild(c),null),p){for(let e of p.values())e.cleanup();p=null}})}return{disposes:r,postMountHooks:o}}function I(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=le(r);n.push(o),r+="__nix__"}let o=ue(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:a,postMountHooks:u}=F(i,n,t),s=document.createComment("nix-scope");e.insertBefore(s,r);let c=i.firstChild;for(;c;){let t=c.nextSibling;e.insertBefore(c,r),c=t}return u.forEach(e=>e()),()=>{a.forEach(e=>e());let e=s.nextSibling;for(;e&&e!==r;){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 L(e,t){if(v(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: contenedor no encontrado: ${t}`);S();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{C()}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 R(e,t){let n={};for(let t of Object.keys(e))n[t]=d(e[t]);let r=n;let o=Object.assign(Object.create(null),r,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]}});if(t){let e=t(r);Object.assign(o,e)}return o}var z=null;function B(){if(!z)throw Error("[Nix] No hay router activo. Llama a createRouter() antes.");return z}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 pe(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 me(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=me(t,o.path),l=[...n,o.component],i=pe(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 he(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"param"===t.kind&&(i[t.name]=decodeURIComponent(n[e]??""))}return i}function ge(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=he(e,l);if(null===t)continue;let i=ge(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function _e(e){function t(){return window.location.pathname||"/"}let n=t(),r=U(e),o=W(n,r),l=d(n),i=d(o?.params??{}),a=d(V(window.location.search)),u=[];function s(e,t,n,r,o){let l=[...u];if(n&&l.push(n),0===l.length)return void r();let i=0;!function n(a){if(!1===a)return void o?.();if("string"==typeof a)return void(a===e?r():c(a));if(i>=l.length)return void r();let u=l[i++](e,t);u instanceof Promise?u.then(n):n(u)}(void 0)}function c(e,t){let{pathname:n,stringQuery:o}=function(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}}(e,t),u=l.value,c=W(n,r);s(n,u,c?.route.beforeEnter,()=>{i.value=c?.params??{},a.value=o,l.value=n,history.pushState(null,"",n+H(o))})}window.addEventListener("popstate",()=>{let e=t(),n=l.value,o=a.value,u=W(e,r),c=V(window.location.search);s(e,n,u?.route.beforeEnter,()=>{i.value=u?.params??{},a.value=c,l.value=e},()=>{history.pushState(null,"",n+H(o))})});let f={current:l,params:i,query:a,navigate:c,beforeEach:function(e){return u.push(e),()=>{let t=u.indexOf(e);-1!==t&&u.splice(t,1)}},routes:e,_flat:r,_guards:u};return z=f,queueMicrotask(()=>{s(n,"",W(n,r)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"","/");let e=W("/",r);l.value="/",i.value=e?.params??{},a.value={}})}),f}function ve(){return B()}var ye=class extends _{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=B(),n=W(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 — Ruta no encontrada: <strong>${t.current.value}</strong>
3
3
  </div>`}}</div>`}},be=class extends _{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to;return I`<a
4
4
  href=${e}
@@ -18,4 +18,4 @@ var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s()
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `);return new class extends _{_state=d({status:"pending"});onMount(){this._run()}_run(){(l||"pending"===this._state.value.status)&&(this._state.value={status:"pending"}),e().then(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?i:"error"===e.status?a(e.error):t(e.data)}}</div>`}}}function xe(e,t){let n=null;return()=>n?new n:G(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function K(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function q(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function J(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Y(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function X(e="Invalid email"){return Y(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Z(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Se(e){return e}const Ce={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function we(e,t){return{...e,...t}}function $(e,t=[]){let n=d(e),r=d(!1),o=d(!1),l=d(null),i=p(()=>{if(l.value)return l.value;if(!r.value&&!o.value)return null;for(let e of t){let t=e(n.value);if(t)return t}return null});function a(t){return"boolean"==typeof e?t.checked:"number"==typeof e?Number(t.value):t.value}return{value:n,error:i,touched:r,dirty:o,onInput:e=>{n.value=a(e.target),o.value=!0,l.value=null},onBlur:()=>{r.value=!0},reset:function(){n.value=e,r.value=!1,o.value=!1,l.value=null},_setExternalError:function(e){l.value=e,e&&(r.value=!0)}}}function Te(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=p(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=p(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=p(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=p(()=>{for(let e in n)if(n[e].dirty.value)return!0;return!1});function a(e){for(let t in e)n[t]?._setExternalError(e[t]??null)}return{fields:n,values:r,errors:o,valid:l,dirty:i,handleSubmit:function(e){return o=>{o.preventDefault();for(let e in n)n[e].touched.value=!0;let l=r.value;if(t.validate){let e=t.validate(l);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 a(t)}}for(let e in n)if(n[e].error.value)return;e(l)}},reset:function(){for(let e in n)n[e].reset()},setErrors:a}}export{be as Link,_ as NixComponent,ye as RouterView,u as Signal,m as batch,p as computed,oe as createErrorBoundary,Te as createForm,y as createInjectionKey,O as createPortalOutlet,_e as createRouter,R as createStore,Se as createValidator,f as effect,X as email,we as extendValidators,I as html,E as inject,ae as injectOutlet,xe as lazy,Q as max,J as maxLength,Z as min,q as minLength,L as mount,g as nextTick,Y as pattern,ie as portal,re as portalOutlet,T as provide,A as provideOutlet,D as ref,ne as repeat,K as required,te as showWhen,d as signal,G as suspend,ce as transition,h as untrack,$ as useField,ve as useRouter,Ce as validators,ee as watch};
21
+ `);return new class extends _{_state=d({status:"pending"});onMount(){this._run()}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),e().then(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?i:"error"===e.status?a(e.error):t(e.data)}}</div>`}}}function xe(e,t){let n=null;return()=>n?new n:G(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function K(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function q(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function J(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Y(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function X(e="Invalid email"){return Y(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Z(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Se(e){return e}const Ce={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function we(e,t){return{...e,...t}}function $(e,t=[]){let n=d(e),r=d(!1),o=d(!1),l=d(null),i=p(()=>{if(l.value)return l.value;if(!r.value&&!o.value)return null;for(let e of t){let t=e(n.value);if(t)return t}return null});function a(t){return"boolean"==typeof e?t.checked:"number"==typeof e?Number(t.value):t.value}return{value:n,error:i,touched:r,dirty:o,onInput:e=>{n.value=a(e.target),o.value=!0,l.value=null},onBlur:()=>{r.value=!0},reset:function(){n.value=e,r.value=!1,o.value=!1,l.value=null},_setExternalError:function(e){l.value=e,e&&(r.value=!0)}}}function Te(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=p(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=p(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=p(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=p(()=>{for(let e in n)if(n[e].dirty.value)return!0;return!1});function a(e){for(let t in e)n[t]?._setExternalError(e[t]??null)}return{fields:n,values:r,errors:o,valid:l,dirty:i,handleSubmit:function(e){return o=>{o.preventDefault();for(let e in n)n[e].touched.value=!0;let l=r.value;if(t.validate){let e=t.validate(l);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 a(t)}}for(let e in n)if(n[e].error.value)return;e(l)}},reset:function(){for(let e in n)n[e].reset()},setErrors:a}}export{be as Link,_ as NixComponent,ye as RouterView,u as Signal,m as batch,p as computed,oe as createErrorBoundary,Te as createForm,y as createInjectionKey,O as createPortalOutlet,_e as createRouter,R as createStore,Se as createValidator,f as effect,X as email,we as extendValidators,I as html,E as inject,ae as injectOutlet,xe as lazy,Q as max,J as maxLength,Z as min,q as minLength,L as mount,g as nextTick,Y as pattern,ie as portal,re as portalOutlet,T as provide,A as provideOutlet,D as ref,ne as repeat,K as required,te as showWhen,d as signal,G as suspend,ce as transition,h as untrack,$ as useField,ve as useRouter,Ce as validators,ee as watch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deijose/nix-js",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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
  "repository": {