@deijose/nix-js 1.0.9 → 1.1.1

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,2 +1,2 @@
1
- export { Signal, signal, effect, computed, batch, watch, untrack, nextTick, html, repeat, ref, showWhen, portal, createPortalOutlet, portalOutlet, provideOutlet, injectOutlet, createErrorBoundary, transition, mount, NixComponent, createStore, createRouter, RouterView, Link, useRouter, suspend, lazy, provide, inject, createInjectionKey, useField, createForm, required, minLength, maxLength, email, pattern, min, max, createValidator, validators, extendValidators, } from "./nix";
2
- export type { WatchOptions, NixTemplate, NixMountHandle, KeyedList, NixRef, PortalOutlet, ErrorFallback, TransitionOptions, TransitionContent, Store, StoreSignals, Router, RouteRecord, NavigationGuard, NavigationGuardResult, SuspenseOptions, InjectionKey, Validator, FieldState, FieldErrors, FormState, FormOptions, ValidatorsBase, NixChildren, } from "./nix";
1
+ export { Signal, signal, effect, computed, batch, watch, untrack, nextTick, html, repeat, ref, showWhen, portal, createPortalOutlet, portalOutlet, provideOutlet, injectOutlet, createErrorBoundary, transition, mount, NixComponent, createStore, createRouter, RouterView, Link, useRouter, suspend, lazy, createQuery, invalidateQueries, provide, inject, createInjectionKey, useField, createForm, required, minLength, maxLength, email, pattern, min, max, createValidator, validators, extendValidators, } from "./nix";
2
+ export type { WatchOptions, NixTemplate, NixMountHandle, KeyedList, NixRef, PortalOutlet, ErrorFallback, TransitionOptions, TransitionContent, Store, StoreSignals, Router, RouteRecord, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute, SuspenseOptions, QueryOptions, InjectionKey, Validator, FieldState, FieldErrors, FormState, FormOptions, ValidatorsBase, NixChildren, } from "./nix";
@@ -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=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++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(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),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,u=!0,a=!1,s=m(()=>{let e=i();if(u){if(u=!1,o&&!a){let n=e;_(()=>t(n,void 0)),l&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!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)}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(){return{__isPortalOutlet:!0,_container:null}}function ie(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 ae(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,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}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 A=S("nix:portal-outlet");function oe(e){O(A,e)}function se(){return k(A)}function ce(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||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}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(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{E()}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 j(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 M(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e)||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(M(r.transitionDuration||"0"),M(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 le(e,t={}){let n=j(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 f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}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 d=(e,r=!1)=>{a++,u&&=(u(),null),i=f(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 N(o,t.duration),a===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=++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 N(r,t.duration),a===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=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&&(a++,u?.(),u=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{a++,h?.(),i?.(),u?.(),i=null,u=null,l.remove()}}}}function ue(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 de(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 P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function fe(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function pe(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 me(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 he(e,t,n){let r=[],o=[],l=pe(e),i=me(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=m(()=>{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=m(()=>{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(x(a)){let e,n,l=a;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}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(P(a)){let e=a._render(s.parentNode,s);r.push(e)}else if(Array.isArray(a))for(let e of a)if(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}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 P(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,f=null,d=null,p=w(),h=m(()=>{let e=a();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(P(e))f=e._render(s.parentNode,s);else if(x(e)){let t,n,r=e;D(p,()=>{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)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(fe(e)){d||=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 d)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),d.delete(e)}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=[],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(x(s)){let r,o;D(p,()=>{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);d.set(l,{start:u,end:n,cleanup:a}),o=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(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(P(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)});r.push(()=>{if(h(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}function F(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=ue(r);n.push(o),r+="__nix__"}let o=de(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:u,postMountHooks:a}=he(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 ge(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 I(e,t){let n={};for(let t of Object.keys(e))n[t]=p(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);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}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 _e(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 ve(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=ve(t,o.path),l=[...n,o.component],i=_e(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 ye(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 be(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=ye(e,l);if(null===t)continue;let i=be(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function xe(e){function t(){return window.location.pathname||"/"}let n=t(),r=H(e),o=U(n,r),l=p(n),i=p(o?.params??{}),u=p(B(window.location.search)),a=[],s=[],c=0;function f(e,t,n,r,o){let l=[...a];n&&l.push(n);let i=++c;if(0===l.length)return void r();let u=0;!function n(a){if(i!==c)return;if(!1===a)return void o?.();if("string"==typeof a)return void(a===e?r():v(a));if(u>=l.length)return void r();let s=l[u++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let d=!1;function h(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 m=()=>{let e=t(),n=l.value,o=u.value,a=U(e,r),c=B(window.location.search);f(e,n,a?.route.beforeEnter,()=>{i.value=a?.params??{},u.value=c,l.value=e;for(let t of s)try{t(e,n)}catch{}},()=>{history.pushState(null,"",n+V(o))})};function y(e,t,n,r,o){i.value=r?.params??{},u.value=t,l.value=e;let a=e+V(t);o?history.replaceState(null,"",a):history.pushState(null,"",a);for(let t of s)try{t(e,n)}catch{}}function v(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,u=U(n,r);f(n,i,u?.route.beforeEnter,()=>y(n,o,i,u,!1))}window.addEventListener("popstate",m),R=()=>window.removeEventListener("popstate",m);let x={current:l,params:i,query:u,navigate:v,replace:function(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,u=U(n,r);f(n,i,u?.route.beforeEnter,()=>y(n,o,i,u,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=l.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=U(t,r);if(!n)return{matched:!1,params:{},route:void 0};let o=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===o)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return a.push(e),()=>{let t=a.indexOf(e);-1!==t&&a.splice(t,1)}},afterEach:function(e){return s.push(e),()=>{let t=s.indexOf(e);-1!==t&&s.splice(t,1)}},routes:e,_flat:r,_guards:a};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(()=>{d||f(n,"",U(n,r)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"","/");let e=U("/",r);l.value="/",i.value=e?.params??{},u.value={}})}),x}function Se(){return z()}var W=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return F`<div class="router-view">${()=>{let t=z(),n=U(t.current.value,t._flat);return n?e>=n.route.chain.length?F`<span></span>`:n.route.chain[e]():F`<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=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++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(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),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,u=!0,a=!1,s=m(()=>{let e=i();if(u){if(u=!1,o&&!a){let n=e;_(()=>t(n,void 0)),l&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!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)}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(){return{__isPortalOutlet:!0,_container:null}}function ie(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 ae(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,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}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 A=S("nix:portal-outlet");function oe(e){O(A,e)}function se(){return k(A)}function ce(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||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}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(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{E()}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 le(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 ue(e,t={}){let n=le(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 f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}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 d=(e,r=!1)=>{a++,u&&=(u(),null),i=f(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},p=()=>{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(()=>{})},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&&(a++,u?.(),u=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{a++,h?.(),i?.(),u?.(),i=null,u=null,l.remove()}}}}function de(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 fe(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 pe(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function me(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 he(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 ge(e,t,n){let r=[],o=[],l=me(e),i=he(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=m(()=>{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=m(()=>{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(x(a)){let e,n,l=a;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}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(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}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,f=null,d=null,p=w(),h=m(()=>{let e=a();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)){let t,n,r=e;D(p,()=>{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)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(pe(e)){d||=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 d)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),d.delete(e)}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=[],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(x(s)){let r,o;D(p,()=>{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);d.set(l,{start:u,end:n,cleanup:a}),o=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(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))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(h(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}function P(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=de(r);n.push(o),r+="__nix__"}let o=fe(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:u,postMountHooks:a}=ge(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 _e(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 ve(e,t){let n={};for(let t of Object.keys(e))n[t]=p(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);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}return o}var F=null,I=null;function L(){if(!F)throw Error("[Nix] No active router. Call createRouter() first.");return F}function R(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function z(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 ye(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 be(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function B(e,t="",n=[]){let r=[];for(let o of e){let e=be(t,o.path),l=[...n,o.component],i=ye(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...B(o.children,e,l))}return r}function xe(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 Se(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function V(e,t){let n,r={},o=-1;for(let l of t){let t=xe(e,l);if(null===t)continue;let i=Se(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function Ce(e){function t(){return window.location.pathname||"/"}let n=t(),r=B(e),o=V(n,r),l=p(n),i=p(o?.params??{}),u=p(R(window.location.search)),a=[],s=[],c=0;function f(e,t,n,r,o){let l=[...a];n&&l.push(n);let i=++c;if(0===l.length)return void r();let u=0;!function n(a){if(i!==c)return;if(!1===a)return void o?.();if("string"==typeof a)return void(a===e?r():y(a));if(u>=l.length)return void r();let s=l[u++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let d=!1;function h(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:R(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}}I&&=(I(),null);let m=()=>{let e=t(),n=l.value,o=u.value,a=V(e,r),c=R(window.location.search);f(e,n,a?.route.beforeEnter,()=>{i.value=a?.params??{},u.value=c,l.value=e;for(let t of s)try{t(e,n)}catch{}},()=>{history.pushState(null,"",n+z(o))})};function v(e,t,n,r,o){i.value=r?.params??{},u.value=t,l.value=e;let a=e+z(t);o?history.replaceState(null,"",a):history.pushState(null,"",a);for(let t of s)try{t(e,n)}catch{}}function y(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,u=V(n,r);f(n,i,u?.route.beforeEnter,()=>v(n,o,i,u,!1))}window.addEventListener("popstate",m),I=()=>window.removeEventListener("popstate",m);let x={current:l,params:i,query:u,navigate:y,replace:function(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,u=V(n,r);f(n,i,u?.route.beforeEnter,()=>v(n,o,i,u,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=l.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=V(t,r);if(!n)return{matched:!1,params:{},route:void 0};let o=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===o)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return a.push(e),()=>{let t=a.indexOf(e);-1!==t&&a.splice(t,1)}},afterEach:function(e){return s.push(e),()=>{let t=s.indexOf(e);-1!==t&&s.splice(t,1)}},routes:e,_flat:r,_guards:a};return F&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),F=x,queueMicrotask(()=>{d||f(n,"",V(n,r)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"","/");let e=V("/",r);l.value="/",i.value=e?.params??{},u.value={}})}),x}function we(){return L()}var Te=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return P`<div class="router-view">${()=>{let t=L(),n=V(t.current.value,t._flat);return n?e>=n.route.chain.length?P`<span></span>`:n.route.chain[e]():P`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},Ce=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to;return F`<a
3
+ </div>`}}</div>`}},Ee=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to;return P`<a
4
4
  href=${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
- >${this._label}</a>`}};function we(){return F`
5
+ style=${()=>L().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(),L().navigate(e)}}
7
+ >${this._label}</a>`}};function H(){return P`
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 Te(e){return F`
17
+ `}function U(e){return P`
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `}function G(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i}=n,u=r??we(),a=o??Te;return new class extends b{_state=p({status:"pending"});_disposeWatcher;onMount(){if(this._run(),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:this._run()})}return()=>{this._disposeWatcher?.()}}_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 F`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?u:"error"===e.status?a(e.error):t(e.data)}}</div>`}}}function Ee(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 De(e){return e}const Oe={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function ke(e,t){return{...e,...t}}function $(e,t=[]){let n=p(e),r=p(!1),o=p(!1),l=p(null),i=h(()=>{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){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: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 Ae(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=h(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=h(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=h(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=h(()=>{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=Ce,exports.NixComponent=b,exports.RouterView=W,exports.Signal=f,exports.batch=g,exports.computed=h,exports.createErrorBoundary=ce,exports.createForm=Ae,exports.createInjectionKey=S,exports.createPortalOutlet=re,exports.createRouter=xe,exports.createStore=I,exports.createValidator=De,exports.effect=m,exports.email=X,exports.extendValidators=ke,exports.html=F,exports.inject=k,exports.injectOutlet=se,exports.lazy=Ee,exports.max=Q,exports.maxLength=J,exports.min=Z,exports.minLength=q,exports.mount=ge,exports.nextTick=y,exports.pattern=Y,exports.portal=ae,exports.portalOutlet=ie,exports.provide=O,exports.provideOutlet=oe,exports.ref=ee,exports.repeat=ne,exports.required=K,exports.showWhen=te,exports.signal=p,exports.suspend=G,exports.transition=le,exports.untrack=_,exports.useField=$,exports.useRouter=Se,exports.validators=Oe,exports.watch=v;
21
+ `}function W(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i}=n,u=r??H(),a=o??U;return new class extends b{_state=p({status:"pending"});_disposeWatcher;onMount(){if(this._run(),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:this._run()})}return()=>{this._disposeWatcher?.()}}_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 P`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?u:"error"===e.status?a(e.error):t(e.data)}}</div>`}}}var G=new Map;function De(e){let t=G.get(e);if(t)for(let e of t)e()}function Oe(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1}=r,u=o??H(),a=l??U;return new class extends b{_state=p({status:"pending"});onMount(){G.has(e)||G.set(e,new Set);let t=G.get(e),n=()=>this._run();return t.add(n),this._run(),()=>{t.delete(n),0===t.size&&G.delete(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),t().then(e=>{this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return P`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?u:"error"===e.status?a(e.error):n(e.data)}}</div>`}}}function ke(e,t){let n=null;return()=>n?new n:W(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 Ae(e){return e}const je={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function Me(e,t){return{...e,...t}}function $(e,t=[]){let n=p(e),r=p(!1),o=p(!1),l=p(null),i=h(()=>{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){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: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 Ne(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=h(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=h(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=h(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=h(()=>{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=Ee,exports.NixComponent=b,exports.RouterView=Te,exports.Signal=f,exports.batch=g,exports.computed=h,exports.createErrorBoundary=ce,exports.createForm=Ne,exports.createInjectionKey=S,exports.createPortalOutlet=re,exports.createQuery=Oe,exports.createRouter=Ce,exports.createStore=ve,exports.createValidator=Ae,exports.effect=m,exports.email=X,exports.extendValidators=Me,exports.html=P,exports.inject=k,exports.injectOutlet=se,exports.invalidateQueries=De,exports.lazy=ke,exports.max=Q,exports.maxLength=J,exports.min=Z,exports.minLength=q,exports.mount=_e,exports.nextTick=y,exports.pattern=Y,exports.portal=ae,exports.portalOutlet=ie,exports.provide=O,exports.provideOutlet=oe,exports.ref=ee,exports.repeat=ne,exports.required=K,exports.showWhen=te,exports.signal=p,exports.suspend=W,exports.transition=ue,exports.untrack=_,exports.useField=$,exports.useRouter=we,exports.validators=je,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(o){let l,a=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++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(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),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)}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(){return{__isPortalOutlet:!0,_container:null}}function ie(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 ae(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,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}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 A=S("nix:portal-outlet");function oe(e){O(A,e)}function se(){return k(A)}function ce(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||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}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(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 j(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 M(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e)||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(M(r.transitionDuration||"0"),M(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 le(e,t={}){let n=j(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 f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}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 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 N(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 N(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 ue(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 de(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 P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function fe(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function pe(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 me(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 he(e,t,n){let r=[],o=[],l=pe(e),i=me(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=m(()=>{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=m(()=>{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(x(u)){let e,n,l=u;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}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(P(u)){let e=u._render(s.parentNode,s);r.push(e)}else if(Array.isArray(u))for(let e of u)if(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}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 P(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,f=null,d=null,p=w(),h=m(()=>{let e=u();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(P(e))f=e._render(s.parentNode,s);else if(x(e)){let t,n,r=e;D(p,()=>{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)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(fe(e)){d||=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 d)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),d.delete(e)}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=[],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(x(s)){let r,o;D(p,()=>{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);d.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(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(P(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)});r.push(()=>{if(h(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}function F(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=ue(r);n.push(o),r+="__nix__"}let o=de(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:a,postMountHooks:u}=he(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 ge(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 I(e,t){let n={};for(let t of Object.keys(e))n[t]=p(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);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}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 _e(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 ve(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=ve(t,o.path),l=[...n,o.component],i=_e(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 ye(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 be(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=ye(e,l);if(null===t)continue;let i=be(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function xe(e){function t(){return window.location.pathname||"/"}let n=t(),r=H(e),o=U(n,r),l=p(n),i=p(o?.params??{}),a=p(B(window.location.search)),u=[],s=[],c=0;function f(e,t,n,r,o){let l=[...u];n&&l.push(n);let i=++c;if(0===l.length)return void r();let a=0;!function n(u){if(i!==c)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():v(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 d=!1;function h(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 m=()=>{let e=t(),n=l.value,o=a.value,u=U(e,r),c=B(window.location.search);f(e,n,u?.route.beforeEnter,()=>{i.value=u?.params??{},a.value=c,l.value=e;for(let t of s)try{t(e,n)}catch{}},()=>{history.pushState(null,"",n+V(o))})};function y(e,t,n,r,o){i.value=r?.params??{},a.value=t,l.value=e;let u=e+V(t);o?history.replaceState(null,"",u):history.pushState(null,"",u);for(let t of s)try{t(e,n)}catch{}}function v(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,a=U(n,r);f(n,i,a?.route.beforeEnter,()=>y(n,o,i,a,!1))}window.addEventListener("popstate",m),R=()=>window.removeEventListener("popstate",m);let g={current:l,params:i,query:a,navigate:v,replace:function(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,a=U(n,r);f(n,i,a?.route.beforeEnter,()=>y(n,o,i,a,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=l.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=U(t,r);if(!n)return{matched:!1,params:{},route:void 0};let o=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===o)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return u.push(e),()=>{let t=u.indexOf(e);-1!==t&&u.splice(t,1)}},afterEach:function(e){return s.push(e),()=>{let t=s.indexOf(e);-1!==t&&s.splice(t,1)}},routes:e,_flat:r,_guards:u};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=g,queueMicrotask(()=>{d||f(n,"",U(n,r)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"","/");let e=U("/",r);l.value="/",i.value=e?.params??{},a.value={}})}),g}function Se(){return z()}var W=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return F`<div class="router-view">${()=>{let t=z(),n=U(t.current.value,t._flat);return n?e>=n.route.chain.length?F`<span></span>`:n.route.chain[e]():F`<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(o){let l,a=new Set,s=i,c=()=>{if("function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a=new Set,t.push(e),r.push(n),e=c,n=a,++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(!s)throw e;s(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}};return c(),()=>{"function"==typeof l&&l(),a.forEach(e=>e._removeSub(c)),a.clear()}}function h(e){let t=new f(void 0);return m(()=>{t.value=e()}),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)}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(){return{__isPortalOutlet:!0,_container:null}}function ie(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 ae(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,x(e)){let t,n;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}t=e.render()._render(o,null)}finally{E()}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 A=S("nix:portal-outlet");function oe(e){O(A,e)}function se(){return k(A)}function ce(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||x(t)?t:t(e);if(x(o)){let e,t;T();try{try{o.onInit?.()}catch{}e=o.render()._render(n,r)}finally{E()}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(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 le(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 ue(e,t={}){let n=le(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 f(e){if(x(e)){let t,n=e;T();try{try{n.onInit?.()}catch{}t=n.render()}finally{E()}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 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 de(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 fe(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 pe(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function me(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 he(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 ge(e,t,n){let r=[],o=[],l=me(e),i=he(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=m(()=>{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=m(()=>{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(x(u)){let e,n,l=u;T();try{try{l.onInit?.()}catch(t){if(!l.onError)throw t;l.onError(t)}e=l.render()._render(s.parentNode,s)}finally{E()}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(x(e)){let n,l;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(s.parentNode,s)}finally{E()}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,f=null,d=null,p=w(),h=m(()=>{let e=u();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)){let t,n,r=e;D(p,()=>{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)}f=()=>{try{r.onUnmount?.()}catch{}try{n?.()}catch{}t()}}else if(pe(e)){d||=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 d)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),d.delete(e)}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=[],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(x(s)){let r,o;D(p,()=>{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);d.set(l,{start:a,end:n,cleanup:u}),o=a}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(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))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});r.push(()=>{if(h(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null}})}return{disposes:r,postMountHooks:o}}function P(e,...t){let n=[],r="";for(let t=0;t<e.length-1;t++){r+=e[t];let o=de(r);n.push(o),r+="__nix__"}let o=fe(e,n);function l(e,r){let l=document.createElement("template");l.innerHTML=o;let i=l.content,{disposes:a,postMountHooks:u}=ge(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 _e(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 ve(e,t){let n={};for(let t of Object.keys(e))n[t]=p(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);for(let t of Object.keys(e))"$reset"!==t?o[t]=e[t]:console.warn('[Nix] Store action name "$reset" is reserved and will be ignored.')}return o}var F=null,I=null;function L(){if(!F)throw Error("[Nix] No active router. Call createRouter() first.");return F}function R(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function z(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 ye(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 be(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function B(e,t="",n=[]){let r=[];for(let o of e){let e=be(t,o.path),l=[...n,o.component],i=ye(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...B(o.children,e,l))}return r}function xe(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 Se(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function V(e,t){let n,r={},o=-1;for(let l of t){let t=xe(e,l);if(null===t)continue;let i=Se(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function Ce(e){function t(){return window.location.pathname||"/"}let n=t(),r=B(e),o=V(n,r),l=p(n),i=p(o?.params??{}),a=p(R(window.location.search)),u=[],s=[],c=0;function f(e,t,n,r,o){let l=[...u];n&&l.push(n);let i=++c;if(0===l.length)return void r();let a=0;!function n(u){if(i!==c)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():y(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 d=!1;function h(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:R(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}}I&&=(I(),null);let m=()=>{let e=t(),n=l.value,o=a.value,u=V(e,r),c=R(window.location.search);f(e,n,u?.route.beforeEnter,()=>{i.value=u?.params??{},a.value=c,l.value=e;for(let t of s)try{t(e,n)}catch{}},()=>{history.pushState(null,"",n+z(o))})};function v(e,t,n,r,o){i.value=r?.params??{},a.value=t,l.value=e;let u=e+z(t);o?history.replaceState(null,"",u):history.pushState(null,"",u);for(let t of s)try{t(e,n)}catch{}}function y(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,a=V(n,r);f(n,i,a?.route.beforeEnter,()=>v(n,o,i,a,!1))}window.addEventListener("popstate",m),I=()=>window.removeEventListener("popstate",m);let g={current:l,params:i,query:a,navigate:y,replace:function(e,t){d=!0;let{pathname:n,stringQuery:o}=h(e,t),i=l.value,a=V(n,r);f(n,i,a?.route.beforeEnter,()=>v(n,o,i,a,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=l.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=V(t,r);if(!n)return{matched:!1,params:{},route:void 0};let o=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===o)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return u.push(e),()=>{let t=u.indexOf(e);-1!==t&&u.splice(t,1)}},afterEach:function(e){return s.push(e),()=>{let t=s.indexOf(e);-1!==t&&s.splice(t,1)}},routes:e,_flat:r,_guards:u};return F&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),F=g,queueMicrotask(()=>{d||f(n,"",V(n,r)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"","/");let e=V("/",r);l.value="/",i.value=e?.params??{},a.value={}})}),g}function we(){return L()}var Te=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return P`<div class="router-view">${()=>{let t=L(),n=V(t.current.value,t._flat);return n?e>=n.route.chain.length?P`<span></span>`:n.route.chain[e]():P`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},Ce=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to;return F`<a
3
+ </div>`}}</div>`}},Ee=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to;return P`<a
4
4
  href=${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
- >${this._label}</a>`}};function we(){return F`
5
+ style=${()=>L().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(),L().navigate(e)}}
7
+ >${this._label}</a>`}};function H(){return P`
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 Te(e){return F`
17
+ `}function U(e){return P`
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `}function G(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i}=n,a=r??we(),u=o??Te;return new class extends b{_state=p({status:"pending"});_disposeWatcher;onMount(){if(this._run(),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:this._run()})}return()=>{this._disposeWatcher?.()}}_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 F`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?a:"error"===e.status?u(e.error):t(e.data)}}</div>`}}}function Ee(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 De(e){return e}const Oe={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function ke(e,t){return{...e,...t}}function $(e,t=[]){let n=p(e),r=p(!1),o=p(!1),l=p(null),i=h(()=>{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){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: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 Ae(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=h(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=h(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=h(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=h(()=>{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{Ce as Link,b as NixComponent,W as RouterView,f as Signal,g as batch,h as computed,ce as createErrorBoundary,Ae as createForm,S as createInjectionKey,re as createPortalOutlet,xe as createRouter,I as createStore,De as createValidator,m as effect,X as email,ke as extendValidators,F as html,k as inject,se as injectOutlet,Ee as lazy,Q as max,J as maxLength,Z as min,q as minLength,ge as mount,y as nextTick,Y as pattern,ae as portal,ie as portalOutlet,O as provide,oe as provideOutlet,ee as ref,ne as repeat,K as required,te as showWhen,p as signal,G as suspend,le as transition,_ as untrack,$ as useField,Se as useRouter,Oe as validators,v as watch};
21
+ `}function W(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i}=n,a=r??H(),u=o??U;return new class extends b{_state=p({status:"pending"});_disposeWatcher;onMount(){if(this._run(),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:this._run()})}return()=>{this._disposeWatcher?.()}}_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 P`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?a:"error"===e.status?u(e.error):t(e.data)}}</div>`}}}var G=new Map;function De(e){let t=G.get(e);if(t)for(let e of t)e()}function Oe(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1}=r,a=o??H(),u=l??U;return new class extends b{_state=p({status:"pending"});onMount(){G.has(e)||G.set(e,new Set);let t=G.get(e),n=()=>this._run();return t.add(n),this._run(),()=>{t.delete(n),0===t.size&&G.delete(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),t().then(e=>{this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return P`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?a:"error"===e.status?u(e.error):n(e.data)}}</div>`}}}function ke(e,t){let n=null;return()=>n?new n:W(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 Ae(e){return e}const je={required:K,minLength:q,maxLength:J,email:X,pattern:Y,min:Z,max:Q};function Me(e,t){return{...e,...t}}function $(e,t=[]){let n=p(e),r=p(!1),o=p(!1),l=p(null),i=h(()=>{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){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: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 Ne(e,t={}){let n={};for(let r in e){let o=t.validators?.[r]??[];n[r]=$(e[r],o)}let r=h(()=>{let e={};for(let t in n)e[t]=n[t].value.value;return e}),o=h(()=>{let e={};for(let t in n){let r=n[t].error.value;r&&(e[t]=r)}return e}),l=h(()=>{for(let e in n)if(n[e].error.value)return!1;return!0}),i=h(()=>{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{Ee as Link,b as NixComponent,Te as RouterView,f as Signal,g as batch,h as computed,ce as createErrorBoundary,Ne as createForm,S as createInjectionKey,re as createPortalOutlet,Oe as createQuery,Ce as createRouter,ve as createStore,Ae as createValidator,m as effect,X as email,Me as extendValidators,P as html,k as inject,se as injectOutlet,De as invalidateQueries,ke as lazy,Q as max,J as maxLength,Z as min,q as minLength,_e as mount,y as nextTick,Y as pattern,ae as portal,ie as portalOutlet,O as provide,oe as provideOutlet,ee as ref,ne as repeat,K as required,te as showWhen,p as signal,W as suspend,ue as transition,_ as untrack,$ as useField,we as useRouter,je as validators,v as watch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deijose/nix-js",
3
- "version": "1.0.9",
3
+ "version": "1.1.1",
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": {