@deijose/nix-js 1.9.3 → 1.9.5

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.
package/README.md CHANGED
@@ -22,6 +22,24 @@ A lightweight, fully reactive micro-framework for building modern web UIs — no
22
22
  npm install @deijose/nix-js
23
23
  ```
24
24
 
25
+ ## Subpath Imports (Tree-Shaking)
26
+
27
+ When you only need one module, import from subpaths:
28
+
29
+ ```typescript
30
+ import { signal, effect } from "@deijose/nix-js/signals";
31
+ import { createRouter } from "@deijose/nix-js/router";
32
+ import { createStore } from "@deijose/nix-js/store";
33
+ import { createForm } from "@deijose/nix-js/form";
34
+ import { suspend, lazy } from "@deijose/nix-js/async";
35
+ import { html, repeat, transition } from "@deijose/nix-js/template";
36
+ import { mount } from "@deijose/nix-js/component";
37
+ import { NixComponent } from "@deijose/nix-js/lifecycle";
38
+ import { provide, inject, createInjectionKey } from "@deijose/nix-js/context";
39
+ ```
40
+
41
+ This is optional: `import { ... } from "@deijose/nix-js"` remains fully supported.
42
+
25
43
  ## Quick Start
26
44
 
27
45
  ```typescript
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./signals.cjs"),t=require("./template2.cjs"),n=require("./lifecycle.cjs");function r(){return t.l`
2
+ <span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
3
+ <span class="nix-spinner" style="
4
+ display:inline-block;width:14px;height:14px;border-radius:50%;
5
+ border:2px solid #38bdf840;border-top-color:#38bdf8;
6
+ animation:nix-spin .7s linear infinite
7
+ "></span>
8
+ Loading…
9
+ </span>
10
+ <style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
11
+ `}function i(e){return t.l`
12
+ <span style="color:#f87171;font-size:13px">
13
+ ⚠ ${e instanceof Error?e.message:String(e)}
14
+ </span>
15
+ `}var a=new Map,o=3e5,s=null,c=o;function l(){null===s&&(s=setInterval(()=>{let e=Date.now();for(let[t,s]of a)s.subscribers<=0&&e-s.fetchedAt>c&&a.delete(t);0===a.size&&null!==s&&(clearInterval(s),s=null)},6e4))}function u(e){let t=a.get(e);if(t&&t.fetchedAt>0)return t}function d(e,t){let s=a.get(e);a.set(e,{data:t,fetchedAt:Date.now(),subscribers:s?.subscribers??0}),l()}function f(e){let t=a.get(e);t?t.subscribers++:a.set(e,{fetchedAt:0,subscribers:1})}function p(e){let t=a.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function m(e,t){let s=a.get(e);return!!s&&Date.now()-s.fetchedAt<t}function h(s,l,o={}){let{fallback:c,errorFallback:h,resetOnRefresh:b=!1,invalidate:g,cacheKey:v,staleTime:x=0}=o,y=c??r(),_=h??i;class w extends n.NixComponent{_state;_disposeWatcher;constructor(){super();let t=v?u(v):void 0;this._state=e.signal(t&&void 0!==t.data?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){v&&f(v);let t=v?u(v):void 0;if(t&&m(v,x)||(t?this._fetch():this._run()),g){let t=!0;this._disposeWatcher=e.effect(()=>{g.value,t?t=!1:(v&&a.delete(v),this._run())})}return()=>{this._disposeWatcher?.(),v&&p(v)}}_run(){(b||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){s().then(e=>{v&&d(v,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return t.l`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?y:"error"===e.status?_(e.error):l(e.data)}}</div>`}}return new w}function g(e,t){let s=null;return()=>s?new s:h(async()=>(s=(await e()).default,s),e=>new e,{fallback:t})}exports.lazy=g,exports.suspend=h;
@@ -0,0 +1,15 @@
1
+ import{effect as e,signal as t}from"./signals.js";import{l as n}from"./template2.js";import{NixComponent as r}from"./lifecycle.js";function i(){return n`
2
+ <span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
3
+ <span class="nix-spinner" style="
4
+ display:inline-block;width:14px;height:14px;border-radius:50%;
5
+ border:2px solid #38bdf840;border-top-color:#38bdf8;
6
+ animation:nix-spin .7s linear infinite
7
+ "></span>
8
+ Loading…
9
+ </span>
10
+ <style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
11
+ `}function a(e){return n`
12
+ <span style="color:#f87171;font-size:13px">
13
+ ⚠ ${e instanceof Error?e.message:String(e)}
14
+ </span>
15
+ `}var o=new Map,s=3e5,c=null,l=s;function u(){null===c&&(c=setInterval(()=>{let e=Date.now();for(let[t,s]of o)s.subscribers<=0&&e-s.fetchedAt>l&&o.delete(t);0===o.size&&null!==c&&(clearInterval(c),c=null)},6e4))}function d(e){let t=o.get(e);if(t&&t.fetchedAt>0)return t}function f(e,t){let s=o.get(e);o.set(e,{data:t,fetchedAt:Date.now(),subscribers:s?.subscribers??0}),u()}function p(e){let t=o.get(e);t?t.subscribers++:o.set(e,{fetchedAt:0,subscribers:1})}function m(e){let t=o.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function h(e,t){let s=o.get(e);return!!s&&Date.now()-s.fetchedAt<t}function g(s,l,c={}){let{fallback:u,errorFallback:b,resetOnRefresh:g=!1,invalidate:_,cacheKey:v,staleTime:x=0}=c,y=u??i(),w=b??a;return new class extends r{_state;_disposeWatcher;constructor(){super();let e=v?d(v):void 0;this._state=t(e&&void 0!==e.data?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){v&&p(v);let t=v?d(v):void 0;if(t&&h(v,x)||(t?this._fetch():this._run()),_){let t=!0;this._disposeWatcher=e(()=>{_.value,t?t=!1:(v&&o.delete(v),this._run())})}return()=>{this._disposeWatcher?.(),v&&m(v)}}_run(){(g||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){s().then(e=>{v&&f(v,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return n`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?y:"error"===e.status?w(e.error):l(e.data)}}</div>`}}}function _(e,t){let s=null;return()=>s?new s:g(async()=>(s=(await e()).default,s),e=>new e,{fallback:t})}export{_ as lazy,g as suspend};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./lifecycle.cjs"),t=require("./context.cjs"),n=require("./router.cjs");function r(t){let r="string"==typeof t?document.querySelector(t):t;if(!r)throw Error(`[Nix] mount: container not found: ${t}`);return r}function i(o,u,i){if(e.isNixComponent(o)){let e,c,l=r(u);t._pushComponentContext();try{i?.router&&t.provide(n.RouterKey,i.router);try{o.onInit?.()}catch(t){if(!o.onError)throw t;o.onError(t)}e=o.render()._render(l,null)}finally{t._popComponentContext()}try{let t=o.onMount?.();"function"==typeof t&&(c=t)}catch(t){if(!o.onError)throw t;o.onError(t)}return{unmount(){try{o.onUnmount?.()}catch{}try{c?.()}catch{}e()}}}if(!i?.router)return o.mount(u);let c,l=r(u);t._pushComponentContext();try{t.provide(n.RouterKey,i.router),c=o._render(l,null)}finally{t._popComponentContext()}return{unmount(){c()}}}exports.mount=i;
@@ -0,0 +1 @@
1
+ import{isNixComponent as e}from"./lifecycle.js";import{_popComponentContext as t,_pushComponentContext as n,provide as r}from"./context.js";import{RouterKey as i}from"./router.js";function a(r){let t="string"==typeof r?document.querySelector(r):r;if(!t)throw Error(`[Nix] mount: container not found: ${r}`);return t}function o(o,u,c){if(e(o)){let e,f,m=a(u);n();try{c?.router&&r(i,c.router);try{o.onInit?.()}catch(r){if(!o.onError)throw r;o.onError(r)}e=o.render()._render(m,null)}finally{t()}try{let r=o.onMount?.();"function"==typeof r&&(f=r)}catch(r){if(!o.onError)throw r;o.onError(r)}return{unmount(){try{o.onUnmount?.()}catch{}try{f?.()}catch{}e()}}}if(!c?.router)return o.mount(u);let f,m=a(u);n();try{r(i,c.router),f=o._render(m,null)}finally{t()}return{unmount(){f()}}}export{o as mount};
@@ -0,0 +1 @@
1
+ function e(t){return Symbol(t)}Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var t=[];function n(){return[...t]}function r(){t.push(new Map)}function i(){t.pop()}function a(e,n){let o=t.splice(0);e.forEach(e=>t.push(e)),t.push(new Map);try{return n()}finally{t.splice(0),o.forEach(e=>t.push(e))}}function o(e,n){let o=t[t.length-1];if(!o)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");o.set(e,n)}function s(e,n){for(let n=t.length-1;n>=0;n--)if(t[n].has(e))return t[n].get(e);return n}exports._captureContextSnapshot=n,exports._popComponentContext=i,exports._pushComponentContext=r,exports._withComponentContext=a,exports.createInjectionKey=e,exports.inject=s,exports.provide=o;
@@ -0,0 +1 @@
1
+ function e(t){return Symbol(t)}var t=[];function n(){return[...t]}function r(){t.push(new Map)}function i(){t.pop()}function a(n,e){let o=t.splice(0);n.forEach(n=>t.push(n)),t.push(new Map);try{return e()}finally{t.splice(0),o.forEach(n=>t.push(n))}}function o(n,e){let o=t[t.length-1];if(!o)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");o.set(n,e)}function s(n,e){for(let e=t.length-1;e>=0;e--)if(t[e].has(n))return t[e].get(n);return e}export{n as _captureContextSnapshot,i as _popComponentContext,r as _pushComponentContext,a as _withComponentContext,e as createInjectionKey,s as inject,o as provide};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./signals.cjs");function t(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function n(e,t){return r=>"string"==typeof r&&r.length<e?t??`Minimum ${e} characters`:null}function r(e,t){return r=>"string"==typeof r&&r.length>e?t??`Maximum ${e} characters`:null}function i(e,t="Invalid format"){return r=>"string"!=typeof r||e.test(r)?null:t}function a(e="Invalid email"){return i(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function o(e,t){return r=>"number"==typeof r&&r<e?t??`Minimum value is ${e}`:null}function s(e,t){return r=>"number"==typeof r&&r>e?t??`Maximum value is ${e}`:null}function c(e){return e}var l={required:t,minLength:n,maxLength:r,email:a,pattern:i,min:o,max:s};function u(e,t){return{...e,...t}}function d(t,r=[],n="blur",l){let u=e.signal(t),i=e.signal(!1),o=e.signal(!1),a=e.signal(null),s=e.signal(!1),f=e.computed(()=>{if(a.value)return a.value;if(!("input"===n?o.value||i.value:"submit"===n?s.value:i.value))return null;let e=l?.();for(let t of r){let r=t(u.value,e);if(r)return r}return null});return{value:u,error:f,touched:i,dirty:o,onInput:e=>{u.value=function(e){if(!e||!("value"in e))return t;let r=e;return"boolean"==typeof t?r.checked:"number"==typeof t?Number(r.value):r.value}(e.target),o.value=!0,a.value=null},onBlur:()=>{i.value=!0},reset:function(){u.value=t,i.value=!1,o.value=!1,a.value=null,s.value=!1},_setExternalError:function(e){a.value=e,e&&(i.value=!0)},_forceVisible:function(){i.value=!0,s.value=!0},_dispose:function(){f.dispose()}}}function f(t,r={},n="blur"){function l(e){let t={};for(let l in e){let u=r[l]??[];t[l]=d(e[l],u,n)}return t}let u=e.signal(t.map(l)),i=e.computed(()=>u.value.length);return{fields:u,append:function(e){u.value=[...u.value,l(e)]},remove:function(e){let t=u.value;if(!(e<0||e>=t.length)){for(let r in t[e])t[e][r]._dispose();u.value=t.filter((t,r)=>r!==e)}},move:function(e,t){let r=[...u.value];if(e<0||e>=r.length||t<0||t>=r.length||e===t)return;let[n]=r.splice(e,1);r.splice(t,0,n),u.value=r},replace:function(e,t){let r=[...u.value];if(!(e<0||e>=r.length)){for(let t in r[e])r[e][t]._dispose();r[e]=l(t),u.value=r}},length:i,reset:function(){for(let e of u.value)for(let t in e)e[t]._dispose();u.value=t.map(l)},_dispose:function(){for(let e of u.value)for(let t in e)e[t]._dispose();i.dispose()}}}function p(e){return"object"==typeof e&&!!e&&!Array.isArray(e)}function m(e,t="",r=[]){for(let[n,l]of Object.entries(e)){let e=t?`${t}.${n}`:n;p(l)&&Object.keys(l).length>0?m(l,e,r):r.push([e,l])}return r}function h(e,t,r){let n=t.split("."),l=e;for(let e=0;e<n.length-1;e++){let t=n[e];p(l[t])||(l[t]={}),l=l[t]}l[n[n.length-1]]=r}function g(t,r={}){let n=r.validateOn??"blur",l={},u=r.validators;function i(){let e={};for(let t in l)h(e,t,l[t].value.value);return e}for(let[e,r]of m(t))l[e]=d(r,u?.[e]??[],n,i);let o=e.signal(!1),a=e.signal(0),s=e.computed(()=>i()),f=e.computed(()=>{let e={};for(let t in l){let r=l[t].error.value;r&&(e[t]=r)}return e}),c=e.computed(()=>{for(let e in l)if(l[e].error.value)return!1;return!0}),v=e.computed(()=>{for(let e in l)if(l[e].dirty.value)return!0;return!1}),p=e.computed(()=>{for(let e in l)if(l[e].touched.value)return!0;return!1});function g(e){for(let t in e)l[t]?._setExternalError(e[t]??null)}return{fields:l,values:s,errors:f,valid:c,dirty:v,touched:p,isSubmitting:o,submitCount:a,handleSubmit:function(e){return t=>{t.preventDefault(),a.value++;for(let e in l)l[e]._forceVisible();let n=s.value;if(r.validate){let e=r.validate(n);if(e){let t={},r=!1;for(let n in e){let l=e[n],u=Array.isArray(l)?l[0]??null:l??null;u&&(t[n]=u,r=!0)}if(r)return void g(t)}}for(let e in l)if(l[e].error.value)return;let u=e(n);u instanceof Promise&&(o.value=!0,u.finally(()=>{o.value=!1}).catch(()=>{}))}},reset:function(){for(let e in l)l[e].reset();o.value=!1,a.value=0},setErrors:g,dispose:function(){s.dispose(),f.dispose(),c.dispose(),v.dispose(),p.dispose();for(let e in l)l[e]._dispose()}}}exports.createForm=g,exports.createValidator=c,exports.email=a,exports.extendValidators=u,exports.max=s,exports.maxLength=r,exports.min=o,exports.minLength=n,exports.pattern=i,exports.required=t,exports.useField=d,exports.useFieldArray=f,exports.validators=l;
@@ -0,0 +1 @@
1
+ import{computed as e,signal as t}from"./signals.js";function n(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function r(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function i(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function a(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function o(e="Invalid email"){return a(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function s(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function c(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function l(e){return e}var u={required:n,minLength:r,maxLength:i,email:o,pattern:a,min:s,max:c};function d(e,t){return{...e,...t}}function f(n,r=[],l="blur",u){let i=t(n),a=t(!1),o=t(!1),s=t(null),f=t(!1),v=e(()=>{if(s.value)return s.value;if(!("input"===l?o.value||a.value:"submit"===l?f.value:a.value))return null;let e=u?.();for(let t of r){let n=t(i.value,e);if(n)return n}return null});return{value:i,error:v,touched:a,dirty:o,onInput:e=>{i.value=function(e){if(!e||!("value"in e))return n;let t=e;return"boolean"==typeof n?t.checked:"number"==typeof n?Number(t.value):t.value}(e.target),o.value=!0,s.value=null},onBlur:()=>{a.value=!0},reset:function(){i.value=n,a.value=!1,o.value=!1,s.value=null,f.value=!1},_setExternalError:function(e){s.value=e,e&&(a.value=!0)},_forceVisible:function(){a.value=!0,f.value=!0},_dispose:function(){v.dispose()}}}function p(n,r={},l="blur"){function u(e){let t={};for(let n in e){let u=r[n]??[];t[n]=f(e[n],u,l)}return t}let i=t(n.map(u)),a=e(()=>i.value.length);return{fields:i,append:function(e){i.value=[...i.value,u(e)]},remove:function(e){let t=i.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();i.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...i.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),i.value=n},replace:function(e,t){let n=[...i.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=u(t),i.value=n}},length:a,reset:function(){for(let e of i.value)for(let t in e)e[t]._dispose();i.value=n.map(u)},_dispose:function(){for(let e of i.value)for(let t in e)e[t]._dispose();a.dispose()}}}function m(e){return"object"==typeof e&&!!e&&!Array.isArray(e)}function h(e,t="",n=[]){for(let[r,l]of Object.entries(e)){let e=t?`${t}.${r}`:r;m(l)&&Object.keys(l).length>0?h(l,e,n):n.push([e,l])}return n}function g(e,t,n){let r=t.split("."),l=e;for(let e=0;e<r.length-1;e++){let t=r[e];m(l[t])||(l[t]={}),l=l[t]}l[r[r.length-1]]=n}function _(n,r={}){let l=r.validateOn??"blur",u={},i=r.validators;function a(){let e={};for(let t in u)g(e,t,u[t].value.value);return e}for(let[e,t]of h(n))u[e]=f(t,i?.[e]??[],l,a);let o=t(!1),s=t(0),v=e(()=>a()),c=e(()=>{let e={};for(let t in u){let n=u[t].error.value;n&&(e[t]=n)}return e}),d=e(()=>{for(let e in u)if(u[e].error.value)return!1;return!0}),p=e(()=>{for(let e in u)if(u[e].dirty.value)return!0;return!1}),m=e(()=>{for(let e in u)if(u[e].touched.value)return!0;return!1});function y(e){for(let t in e)u[t]?._setExternalError(e[t]??null)}return{fields:u,values:v,errors:c,valid:d,dirty:p,touched:m,isSubmitting:o,submitCount:s,handleSubmit:function(e){return t=>{t.preventDefault(),s.value++;for(let e in u)u[e]._forceVisible();let n=v.value;if(r.validate){let e=r.validate(n);if(e){let t={},n=!1;for(let r in e){let l=e[r],u=Array.isArray(l)?l[0]??null:l??null;u&&(t[r]=u,n=!0)}if(n)return void y(t)}}for(let e in u)if(u[e].error.value)return;let l=e(n);l instanceof Promise&&(o.value=!0,l.finally(()=>{o.value=!1}).catch(()=>{}))}},reset:function(){for(let e in u)u[e].reset();o.value=!1,s.value=0},setErrors:y,dispose:function(){v.dispose(),c.dispose(),d.dispose(),p.dispose(),m.dispose();for(let e in u)u[e]._dispose()}}}export{_ as createForm,l as createValidator,o as email,d as extendValidators,c as max,i as maxLength,s as min,r as minLength,a as pattern,n as required,f as useField,p as useFieldArray,u as validators};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=class{__isNixComponent=!0;children;_slots=new Map;setChildren(t){return this.children=t,this}setSlot(t,e){return this._slots.set(t,e),this}slot(t){return this._slots.get(t)}};function t(t){return"object"==typeof t&&!!t&&!0===t.__isNixComponent}exports.NixComponent=e,exports.isNixComponent=t;
@@ -0,0 +1 @@
1
+ var e=class{__isNixComponent=!0;children;_slots=new Map;setChildren(t){return this.children=t,this}setSlot(t,s){return this._slots.set(t,s),this}slot(t){return this._slots.get(t)}};function t(t){return"object"==typeof t&&!!t&&!0===t.__isNixComponent}export{e as NixComponent,t as isNixComponent};
@@ -1,21 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(o){let l,u=!1,a=new Set,s=new Set,c=i,p=()=>{if(u)return;"function"==typeof l&&l();let i=a;a=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let o=t.pop();throw n=o.effect,r=o.deps,o.effect=null,o.deps=null,e.push(o),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{l=o()}catch(e){if(!c)throw e;c(e)}finally{f--;let o=t.pop();n=o.effect,r=o.deps,o.effect=null,o.deps=null,e.push(o);for(let e of a)s.has(e)||e._removeSub(p)}};return p(),()=>{u=!0,"function"==typeof l&&l();for(let e of s)e._removeSub(p);s.clear(),a.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,o=r;n=null,r=null;try{return e()}finally{n=t,r=o}}function x(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof h?()=>e.value:e,u=!0,a=!1,s=_(()=>{let e=i();if(u){if(u=!1,o&&!a){let n=e;b(()=>t(n,void 0)),l&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,o=r;r=e,b(()=>t(n,o)),l&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!0,s()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}function C(){return{el:null}}var w={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function T(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function E(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var D=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 O(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function k(e){return Symbol(e)}var A=[];function j(){return[...A]}function M(){A.push(new Map)}function N(){A.pop()}function ee(e,t){let n=A.splice(0);e.forEach(e=>A.push(e)),A.push(new Map);try{return t()}finally{A.splice(0),n.forEach(e=>A.push(e))}}function P(e,t){let n=A[A.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function F(e,t){for(let t=A.length-1;t>=0;t--)if(A[t].has(e))return A[t].get(e);return t}function I(e,t,n){let r,o;M();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{N()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function L(e,t,n){let r,o;M();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{N()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function R(e,t,n,r){let o,l;ee(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function z(e,t,n,r,o){let l,i;M();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{N()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),o.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}l()})}function te(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function ne(e){let t,n,r,o,l,i=e.slice(),u=[0],a=e.length;for(t=0;t<a;t++){let a=e[t];if(0!==a){if(n=u[u.length-1],e[n]<a){i[t]=n,u.push(t);continue}for(r=0,o=u.length-1;r<o;)l=r+o>>1,e[u[l]]<a?r=l+1:o=l;a<e[u[r]]&&(r>0&&(i[t]=u[r-1]),u[r]=t)}}for(r=u.length,o=u[r-1];r-- >0;)u[r]=o,o=i[o];return u}var B=new Set,V=!1;function H(e){B.add(e),V||(V=!0,queueMicrotask(()=>{for(let e of B)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}B.clear(),V=!1}))}function re(e,t,n,r){if("function"!=typeof t){if(O(t))z(t,e.parentNode,e,r,n);else if(T(t))n.push(t._render(e.parentNode,e));else if(Array.isArray(t))for(let o of t)O(o)?z(o,e.parentNode,e,r,n):T(o)?o._render(e.parentNode,e):null!=o&&!1!==o&&e.parentNode.insertBefore(document.createTextNode(String(o)),e);else null!=t&&!1!==t&&e.parentNode.insertBefore(document.createTextNode(String(t)),e);return}let o=null,l=null,i=null,u=[],a=null,s=j(),c=!1,f="",d=!0,p=_(()=>{let n=t();if("string"==typeof n||"number"==typeof n){f=String(n);let t=()=>{c=!1,l&&=(l(),null),o?o.nodeValue=f:(o=document.createTextNode(f),e.parentNode.insertBefore(o,e))};return void(d?(d=!1,t()):c||(c=!0,H(t)))}if(c=!1,d=!1,o&&=(o.parentNode?.removeChild(o),null),l&&=(l(),null),null!=n&&!1!==n)if(T(n))l=n._render(e.parentNode,e);else if(O(n))l=R(n,e.parentNode,e,s);else if(E(n)){i||(i=new Map,a=document.createTextNode(""),e.parentNode.insertBefore(a,e));let t=e.parentNode,r=n.items.map((e,t)=>n.keyFn(e,t)),o=new Set(r),l=!1;if(i.size>0)for(let e of i.keys())if(o.has(e)){l=!0;break}if(!l){if(i.size>0){let t=document.createRange();t.setStartAfter(a),t.setEndBefore(e),t.deleteContents();for(let e of i.values())e.cleanup();i.clear()}if(r.length>0){let o=document.createDocumentFragment();y(()=>{for(let e=0;e<r.length;e++){let t=r[e],l=n.items[e],u=document.createTextNode(""),a=document.createTextNode("");o.appendChild(u),o.appendChild(a);let c=n.renderFn(l,e),f=O(c)?R(c,o,a,s):c._render(o,a);i?.set(t,{start:u,end:a,cleanup:f})}}),t.insertBefore(o,e)}return void(u=r)}let c=new Map;for(let e=0;e<r.length;e++)c.set(r[e],e);let f=new Int32Array(r.length),d=!1,p=0;for(let e=0;e<u.length;e++){let t=u[e],n=c.get(t);if(void 0===n){let e=i.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}i.delete(t)}else f[n]=e+1,n>=p?p=n:d=!0}let h=d?ne(f):[],m=h.length-1,v=e;for(let e=r.length-1;e>=0;e--){let o=r[e];if(0===f[e]){let r=n.items[e],l=document.createTextNode(""),u=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(l),a.appendChild(u);let c=n.renderFn(r,e),f=O(c)?R(c,a,u,s):c._render(a,u);i.set(o,{start:l,end:u,cleanup:f}),t.insertBefore(a,v),v=l}else{let n=i.get(o);if(d)if(m<0||e!==h[m]){let e=n.start;for(;e;){let r=e===n.end?null:e.nextSibling;if(t.insertBefore(e,v),!r)break;e=r}}else m--;v=n.start}}u=r}else if(Array.isArray(n)){let t=[];for(let r of n)if(O(r))t.push(I(r,e.parentNode,e));else if(T(r))t.push(r._render(e.parentNode,e));else if(null!=r&&!1!==r){let n=document.createTextNode(String(r));e.parentNode.insertBefore(n,e),t.push(()=>n.parentNode?.removeChild(n))}l=()=>t.forEach(e=>e())}else o=document.createTextNode(String(n)),e.parentNode.insertBefore(o,e)});n.push(()=>{if(p(),l&&=(l(),null),o&&=(o.parentNode?.removeChild(o),null),i){for(let e of i.values())e.cleanup();i=null,a=null}})}function U(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ie(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.lastIndexOf("=");if(-1===o)return{type:"node"};let l=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=o-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let u=r.slice(i,o);if("@"===u[0]){let e=u.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l}}return{type:"attr",attrName:u,hadOpenQuote:l}}var ae={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},oe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),se=new Set;function ce(e,t,n){let r=e.target,o=e.stopPropagation,l=!1;for(e.stopPropagation=()=>{l=!0,o.call(e)};r&&r!==document;){let o=r[t];if(o){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,o=!0;for(let e of t){let t=ae[e];if(void 0!==t&&n.key!==t){o=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){o=!1;break}}if(!o){r=r.parentNode;continue}}}if(o(e),l)break}r=r.parentNode}e.stopPropagation=o}var le=new Map;function ue(e,t,n,r){let o=[],l=[],i=Array(t.length),u=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>u&&(u=r[e].nodeIndex);let a=Array(u+1);if(a[0]=e,u>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=u&&(t=n.nextNode());)a[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?a[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let u=t[e],a=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===u.type){let e=s.name,t=a,n=u.modifiers;if(!oe.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},l=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,l,r),o.push(()=>c.removeEventListener(e,l,r))}else{if(!se.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>ce(e,t,n);le.set(e,r),document.addEventListener(e,r),se.add(e)}let r=`__nix_${e}`,l=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[l]=n),o.push(()=>{c[r]=null,c[l]=null})}continue}if("attr"===u.type){let e=s.name,t=c;if("ref"===e){a.el=t,o.push(()=>{a.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof a){let t=!1,l=!1,i=!0,u=_(()=>{l=!!a();let o=()=>{t=!1;let o="show"===e?l:!l;null===r&&(r=n.style.display||""),n.style.display=o?r:"none"};i?(i=!1,o()):t||(t=!0,H(o))});o.push(u)}else("show"===e?a:!a)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof a){let r,l=!1,i=!0,u=_(()=>{r=a();let o=()=>{l=!1;let o=r;n?t[e]=o??"":null==o||!1===o?t.removeAttribute(e):t.setAttribute(e,String(o))};i?(i=!1,o()):l||(l=!0,H(o))});o.push(u)}else n?t[e]=a??"":null!=a&&!1!==a&&t.setAttribute(e,String(a));continue}let f=c;if(!f)continue;let d=document.createTextNode("");f.parentNode.replaceChild(d,f),re(d,a,o,l)}return{disposes:o,postMountHooks:l}}function de(e,t){let n=new Uint8Array(e.length),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;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;r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}var fe=new WeakMap;function W(e,...t){let n=fe.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ie(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=de(e,t);let l,i=Array(t.length).fill(null),u=o.content,a=document.createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;l=a.nextNode();)if(s++,8===l.nodeType){let e=l.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===l.nodeType){let e=l,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],o=r.name;if(o.startsWith("data-nix-e-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o));continue}if(o.startsWith("data-nix-a-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o))}}}n={contexts:t,tpl:o,pathMap:i},fe.set(e,n)}let{contexts:r,tpl:o,pathMap:l}=n;function i(e,n){let i=o.content.cloneNode(!0),{disposes:u,postMountHooks:a}=ue(i,r,t,l),s=document.createTextNode(""),c=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),e.insertBefore(c,n),a.forEach(e=>e()),()=>{for(let e=u.length-1;e>=0;e--)u[e]();let e=s.nextSibling;for(;e&&e!==c;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s),c.parentNode?.removeChild(c)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function pe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function me(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function he(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(me(r.transitionDuration||"0"),me(r.animationDuration||"0")),l=o>0?o+100:t;if(l<=0)return void n();let i,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 ge(e,t={}){let n=pe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment(w.TRANSITION);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){return O(e)?L(e,r,o):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 he(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 he(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||O(e))d(e);else{let t=e,n=null;h=_(()=>{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 _e(){return{__isPortalOutlet:!0,_container:null}}function ve(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 ye(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;return o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,O(e)?I(e,o,null):e._render(o,null)}}}var be=k("nix:portal-outlet");function xe(e){P(be,e)}function Se(){return F(be)}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(w.ERROR_BOUNDARY);n.insertBefore(l,r);let i,u=null,a=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||O(t)?t:t(e);u=O(o)?L(o,n,r):o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(O(e)){M();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{N()}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()}}}}var G=k("nix:router"),K=null,q=null,we="__nix_scroll";function Te(){if(!K)throw Error("[Nix] No active router. Call createRouter() first.");return K}function J(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function Ee(e){if(!e||"object"!=typeof e)return null;let t=e[we];if(!t||"object"!=typeof t)return null;let n=t.left,r=t.top;return"number"!=typeof n||"number"!=typeof r?null:{left:n,top:r}}function Y(e,t){let n=e&&"object"==typeof e?{...e}:{};return n[we]={left:t.left,top:t.top},n}function X(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function De(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 Oe(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 ke(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Ae(e,t="",n=[]){let r=[];for(let o of e){let e=ke(t,o.path),l=[...n,o.component],i=Oe(e);r.push({fullPath:e,segments:i,chain:l,name:o.name,meta:o.meta,beforeEnter:o.beforeEnter,record:o}),o.children?.length&&r.push(...Ae(o.children,e,l))}return r}function je(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 Me(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function Z(e,t){let n,r={},o=-1;for(let l of t){let t=je(e,l);if(null===t)continue;let i=Me(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function Ne(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Pe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return Ne(new URL(t,window.location.origin).pathname)}catch{return Ne(t)}}function Fe(e,t){let n=null==t?.base?Pe():Ne(t.base),r=t?.mode??"history",o="hash"===r,l=t?.scrollBehavior,i=new Map,u=!1;function a(e){return e?e.startsWith("/")?e:"/"+e:"/"}function s(e){let t=a(e||"/");if(n&&t.startsWith(n)){let e=t.slice(n.length);return""===e?"/":a(e)}return t}function c(e){let t=a(e);return n?(n+t).replace(/\/+/g,"/")||"/":t}function f(){return o?function(){let e=window.location.hash||"";if(e.startsWith("#")&&(e=e.slice(1)),!e)return{pathname:"/",search:""};e.startsWith("/")||(e="/"+e);let t=e.indexOf("?"),n=-1===t?e:e.slice(0,t),r=-1===t?"":e.slice(t);return{pathname:s(n),search:r}}():{pathname:s(window.location.pathname||"/"),search:window.location.search||""}}function d(e,t){let n=c(e)+De(t);return o?"#"+n:n}function p(e,t){return a(e)+De(t)}let h=f(),m=h.pathname,v=X(h.search),y=Ae(e),x=new Map;for(let e of y)e.name&&(x.has(e.name)&&console.warn(`[Nix Router] Duplicate route name: "${e.name}"`),x.set(e.name,e));let _=Z(m,y),b=g(m),w=g(_?.params??{}),N=g(v);function E(e){window.scrollTo(e.left,e.top)}function S(e,t,n){if(l){let r=l(e,t,n);if(!1===r||null==r)return;return void E(r)}E(n??{left:0,top:0})}o?i.set(p(m,v),J()):history.replaceState(Y(history.state,J()),"");let k=[],O=[],A=0;function T(e,t,n,r,o){let l=[...k];n&&l.push(n);let i=++A;if(0===l.length)return void r();let u=0;!function n(a){if(i!==A)return;if(!1===a)return void o?.();if("string"==typeof a)return void(a===e?r():R(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 $=!1;function M(e,t){let n=e.indexOf("?"),r=a((-1===n?e:e.slice(0,n))||"/"),o=-1===n?{}:X(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}}function L(e,t){return"string"==typeof e?M(e,t):M(function(e){let t=x.get(e.name);if(!t)throw Error(`[Nix Router] No route with name "${e.name}"`);return"/"+t.segments.map(t=>{if("literal"===t.kind)return t.value;if("wildcard"===t.kind)return"";let n=e.params?.[t.name];if(null==n)throw Error(`[Nix Router] Missing param "${t.name}" for route "${e.name}"`);return encodeURIComponent(String(n))}).filter(Boolean).join("/")}(e),{...e.query??{},...t??{}})}q&&=(q(),null);let I=(e,t,n,r)=>{let o=b.value,l={...N.value},i=Z(e,y);T(e,o,i?.route.beforeEnter,()=>{w.value=i?.params??{},N.value=t,b.value=e,S(e,o,n);for(let t of O)try{t(e,o)}catch{}},()=>r(o,l))};if(o){let e=()=>{if(u)return void(u=!1);let e=f(),t=X(e.search),n=i.get(p(e.pathname,t))??null;I(e.pathname,t,n,(e,t)=>{u=!0,window.location.hash=d(e,t).slice(1),queueMicrotask(()=>{u=!1})})};window.addEventListener("hashchange",e),q=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=f(),n=X(t.search),r=Ee(e.state??history.state);I(t.pathname,n,r,(e,t)=>{history.pushState(Y({},J()),"",d(e,t))})};window.addEventListener("popstate",e),q=()=>window.removeEventListener("popstate",e)}function W(e,t,n,r,l,a){a||function(e,t){let n=J();o?i.set(p(e,t),n):history.replaceState(Y(history.state,n),"")}(n,r),w.value=l?.params??{},N.value=t,b.value=e;let s=d(e,t);if(o)i.set(p(e,t),{left:0,top:0}),a?history.replaceState(history.state,"",s):(u=!0,window.location.hash=s.slice(1),queueMicrotask(()=>{u=!1}));else{let e=Y({},{left:0,top:0});a?history.replaceState(e,"",s):history.pushState(e,"",s)}S(e,n,null);for(let t of O)try{t(e,n)}catch{}}function R(e,t){$=!0;let{pathname:n,stringQuery:r}=L(e,t),o=b.value,l={...N.value},i=Z(n,y);T(n,o,i?.route.beforeEnter,()=>W(n,r,o,l,i,!1))}let B={current:b,params:w,query:N,base:n||"/",navigate:R,replace:function(e,t){$=!0;let{pathname:n,stringQuery:r}=L(e,t),o=b.value,l={...N.value},i=Z(n,y);T(n,o,i?.route.beforeEnter,()=>W(n,r,o,l,i,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=b.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=Z(e,y);return t?{matched:!0,params:t.params,route:t.route.record}:{matched:!1,params:{},route:void 0}},beforeEach:function(e){return k.push(e),()=>{let t=k.indexOf(e);-1!==t&&k.splice(t,1)}},afterEach:function(e){return O.push(e),()=>{let t=O.indexOf(e);-1!==t&&O.splice(t,1)}},routes:e,_flat:y,_guards:k,_base:n,_mode:r};return K&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),K=B,queueMicrotask(()=>{$||T(m,"",Z(m,y)?.route.beforeEnter,()=>{},()=>{let e=d("/",{});o?(i.set(p("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(Y({},{left:0,top:0}),"",e);let t=Z("/",y);b.value="/",w.value=t?.params??{},N.value={},S("/",m,null)})}),B}function Ie(){return F(G)||Te()}var Le=class extends D{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return W`<div class="router-view">${()=>{let t=Ie(),n=Z(t.current.value,t._flat);return n?e>=n.route.chain.length?W`<span></span>`:n.route.chain[e]():W`<div style="color:#f87171;padding:16px 0">
2
- 404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},Re=class extends D{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label,n=Ie(),r=e.startsWith("/")?e:"/"+e,o=(n._base?n._base+r:r).replace(/\/+/g,"/");return W`<a
4
- href=${"hash"===n._mode?"#"+o:o}
5
- style=${()=>n.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(),n.navigate(e)}}
7
- >${t}</a>`}};function ze(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: container not found: ${e}`);return t}function Be(e,t,n){if(O(e)){let r,o,l=ze(t);M();try{n?.router&&P(G,n.router);try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(l,null)}finally{N()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}}if(!n?.router)return e.mount(t);let r,o=ze(t);M();try{P(G,n.router),r=e._render(o,null)}finally{N()}return{unmount(){r()}}}function Ve(e,t,n){let r={},o=new Set(["$reset","$patch","$state","$subscribe"]);for(let t of Object.keys(e)){if(o.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);r[t]=g(e[t])}let l=r;let i=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))r[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in r&&(r[t].value=e[t])},$subscribe:function(t){let n=[];for(let r of Object.keys(e)){let e=x(l[r],(e,n)=>{t(r,e,n)});n.push(e)}return()=>{for(let e of n)e()}}});if(Object.defineProperty(i,"$state",{get(){let e={};for(let t in r)e[t]=r[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))o.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):i[t]=e[t]}if(n){let e=n(l);for(let t of Object.keys(e))o.has(t)?console.warn(`[Nix] Store getter name "${t}" is reserved and will be ignored.`):i[t]=e[t]}return i}function He(){return W`
8
- <span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
9
- <span class="nix-spinner" style="
10
- display:inline-block;width:14px;height:14px;border-radius:50%;
11
- border:2px solid #38bdf840;border-top-color:#38bdf8;
12
- animation:nix-spin .7s linear infinite
13
- "></span>
14
- Loading…
15
- </span>
16
- <style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
17
- `}function Ue(e){return W`
18
- <span style="color:#f87171;font-size:13px">
19
- ⚠ ${e instanceof Error?e.message:String(e)}
20
- </span>
21
- `}var Q=new Map,We=3e5,$=null,Ge=We;function Ke(){null===$&&($=setInterval(()=>{let e=Date.now();for(let[t,n]of Q)n.subscribers<=0&&e-n.fetchedAt>Ge&&Q.delete(t);0===Q.size&&null!==$&&(clearInterval($),$=null)},6e4))}function qe(e){let t=Q.get(e);if(t&&t.fetchedAt>0)return t}function Je(e,t){let n=Q.get(e);Q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ke()}function Ye(e){let t=Q.get(e);t?t.subscribers++:Q.set(e,{fetchedAt:0,subscribers:1})}function Xe(e){let t=Q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ze(e,t){let n=Q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Qe(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:u,staleTime:a=0}=n,s=r??He(),c=o??Ue;return new class extends D{_state;_disposeWatcher;constructor(){super();let e=u?qe(u):void 0;this._state=g(e&&void 0!==e.data?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){u&&Ye(u);let e=u?qe(u):void 0;if(e&&Ze(u,a)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(u&&Q.delete(u),this._run())})}return()=>{this._disposeWatcher?.(),u&&Xe(u)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{u&&Je(u,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return W`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}function $e(e,t){let n=null;return()=>n?new n:Qe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function et(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function tt(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function nt(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function rt(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function it(e="Invalid email"){return rt(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function at(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function ot(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function st(e){return e}var ct={required:et,minLength:tt,maxLength:nt,email:it,pattern:rt,min:at,max:ot};function lt(e,t){return{...e,...t}}function ut(e,t=[],n="blur",r){let o=g(e),l=g(!1),i=g(!1),u=g(null),a=g(!1),s=v(()=>{if(u.value)return u.value;if(!("input"===n?i.value||l.value:"submit"===n?a.value:l.value))return null;let e=r?.();for(let n of t){let t=n(o.value,e);if(t)return t}return null});function c(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:o,error:s,touched:l,dirty:i,onInput:e=>{o.value=c(e.target),i.value=!0,u.value=null},onBlur:()=>{l.value=!0},reset:function(){o.value=e,l.value=!1,i.value=!1,u.value=null,a.value=!1},_setExternalError:function(e){u.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,a.value=!0},_dispose:function(){s.dispose()}}}function dt(e,t={},n="blur"){function r(e){let r={};for(let o in e){let l=t[o]??[];r[o]=ut(e[o],l,n)}return r}let o=g(e.map(r)),l=v(()=>o.value.length);return{fields:o,append:function(e){o.value=[...o.value,r(e)]},remove:function(e){let t=o.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();o.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...o.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),o.value=n},replace:function(e,t){let n=[...o.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),o.value=n}},length:l,reset:function(){for(let e of o.value)for(let t in e)e[t]._dispose();o.value=e.map(r)},_dispose:function(){for(let e of o.value)for(let t in e)e[t]._dispose();l.dispose()}}}function ft(e){return"object"==typeof e&&!!e&&!Array.isArray(e)}function pt(e,t="",n=[]){for(let[r,o]of Object.entries(e)){let e=t?`${t}.${r}`:r;ft(o)&&Object.keys(o).length>0?pt(o,e,n):n.push([e,o])}return n}function mt(e,t,n){let r=t.split("."),o=e;for(let e=0;e<r.length-1;e++){let t=r[e];ft(o[t])||(o[t]={}),o=o[t]}o[r[r.length-1]]=n}function ht(e,t={}){let n=t.validateOn??"blur",r={},o=t.validators;function l(){let e={};for(let t in r)mt(e,t,r[t].value.value);return e}for(let[t,i]of pt(e))r[t]=ut(i,o?.[t]??[],n,l);let i=g(!1),u=g(0),a=v(()=>l()),s=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),c=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),f=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),d=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function p(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:a,errors:s,valid:c,dirty:f,touched:d,isSubmitting:i,submitCount:u,handleSubmit:function(e){return n=>{n.preventDefault(),u.value++;for(let e in r)r[e]._forceVisible();let o=a.value;if(t.validate){let e=t.validate(o);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 p(t)}}for(let e in r)if(r[e].error.value)return;let l=e(o);l instanceof Promise&&(i.value=!0,l.finally(()=>{i.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();i.value=!1,u.value=0},setErrors:p,dispose:function(){a.dispose(),s.dispose(),c.dispose(),f.dispose(),d.dispose();for(let e in r)r[e]._dispose()}}}exports.Link=Re,exports.NixComponent=D,exports.RouterKey=G,exports.RouterView=Le,exports.Signal=h,exports.batch=y,exports.computed=v,exports.createErrorBoundary=Ce,exports.createForm=ht,exports.createInjectionKey=k,exports.createPortalOutlet=_e,exports.createRouter=Fe,exports.createStore=Ve,exports.createValidator=st,exports.effect=_,exports.email=it,exports.extendValidators=lt,exports.html=W,exports.inject=F,exports.injectOutlet=Se,exports.lazy=$e,exports.max=ot,exports.maxLength=nt,exports.min=at,exports.minLength=tt,exports.mount=Be,exports.nextTick=S,exports.pattern=rt,exports.portal=ye,exports.portalOutlet=ve,exports.provide=P,exports.provideOutlet=xe,exports.ref=C,exports.repeat=te,exports.required=et,exports.showWhen=U,exports.signal=g,exports.suspend=Qe,exports.transition=ge,exports.untrack=b,exports.useField=ut,exports.useFieldArray=dt,exports.useRouter=Ie,exports.validators=ct,exports.watch=x;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./signals.cjs"),t=require("./template2.cjs"),n=require("./lifecycle.cjs"),r=require("./context.cjs"),i=require("./router.cjs"),a=require("./component.cjs"),o=require("./store.cjs"),s=require("./async.cjs"),c=require("./form.cjs");exports.Link=i.Link,exports.NixComponent=n.NixComponent,exports.RouterKey=i.RouterKey,exports.RouterView=i.RouterView,exports.Signal=e.Signal,exports.batch=e.batch,exports.computed=e.computed,exports.createErrorBoundary=t.t,exports.createForm=c.createForm,exports.createInjectionKey=r.createInjectionKey,exports.createPortalOutlet=t.n,exports.createRouter=i.createRouter,exports.createStore=o.createStore,exports.createValidator=c.createValidator,exports.effect=e.effect,exports.email=c.email,exports.extendValidators=c.extendValidators,exports.html=t.l,exports.inject=r.inject,exports.injectOutlet=t.r,exports.lazy=s.lazy,exports.max=c.max,exports.maxLength=c.maxLength,exports.min=c.min,exports.minLength=c.minLength,exports.mount=a.mount,exports.nextTick=e.nextTick,exports.pattern=c.pattern,exports.portal=t.i,exports.portalOutlet=t.a,exports.provide=r.provide,exports.provideOutlet=t.o,exports.ref=t.h,exports.repeat=t.d,exports.required=c.required,exports.showWhen=t.u,exports.signal=e.signal,exports.suspend=s.suspend,exports.transition=t.s,exports.untrack=e.untrack,exports.useField=c.useField,exports.useFieldArray=c.useFieldArray,exports.useRouter=i.useRouter,exports.validators=c.validators,exports.watch=e.watch;
@@ -1,21 +1 @@
1
- var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let n of this._subs)p[e+t++]=n;m=e+t;try{for(let n=0;n<t;n++){let t=p[e+n];p[e+n]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,a=!1,u=new Set,s=new Set,c=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=u;u=s,s=i,s.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=p,r=s,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of u)s.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of s)e._removeSub(p);s.clear(),u.clear()}}function v(e){let t=new h(void 0),n=_(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof h?()=>e.value:e,a=!0,u=!1,s=_(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;b(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}function C(){return{el:null}}var w={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function T(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function E(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var D=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 O(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function k(e){return Symbol(e)}var A=[];function j(){return[...A]}function M(){A.push(new Map)}function N(){A.pop()}function ee(e,t){let n=A.splice(0);e.forEach(e=>A.push(e)),A.push(new Map);try{return t()}finally{A.splice(0),n.forEach(e=>A.push(e))}}function P(e,t){let n=A[A.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function F(e,t){for(let t=A.length-1;t>=0;t--)if(A[t].has(e))return A[t].get(e);return t}function I(e,t,n){let r,l;M();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{N()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function L(e,t,n){let r,l;M();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{N()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function R(e,t,n,r){let l,o;ee(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}l()}}function z(e,t,n,r,l){let o,i;M();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{N()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function te(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function ne(e){let t,n,r,l,o,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,l=a.length-1;r<l;)o=r+l>>1,e[a[o]]<u?r=o+1:l=o;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,l=a[r-1];r-- >0;)a[r]=l,l=i[l];return a}var B=new Set,V=!1;function H(e){B.add(e),V||(V=!0,queueMicrotask(()=>{for(let e of B)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}B.clear(),V=!1}))}function re(e,t,n,r){if("function"!=typeof t){if(O(t))z(t,e.parentNode,e,r,n);else if(T(t))n.push(t._render(e.parentNode,e));else if(Array.isArray(t))for(let l of t)O(l)?z(l,e.parentNode,e,r,n):T(l)?l._render(e.parentNode,e):null!=l&&!1!==l&&e.parentNode.insertBefore(document.createTextNode(String(l)),e);else null!=t&&!1!==t&&e.parentNode.insertBefore(document.createTextNode(String(t)),e);return}let l=null,o=null,i=null,a=[],u=null,s=j(),c=!1,f="",d=!0,p=_(()=>{let n=t();if("string"==typeof n||"number"==typeof n){f=String(n);let t=()=>{c=!1,o&&=(o(),null),l?l.nodeValue=f:(l=document.createTextNode(f),e.parentNode.insertBefore(l,e))};return void(d?(d=!1,t()):c||(c=!0,H(t)))}if(c=!1,d=!1,l&&=(l.parentNode?.removeChild(l),null),o&&=(o(),null),null!=n&&!1!==n)if(T(n))o=n._render(e.parentNode,e);else if(O(n))o=R(n,e.parentNode,e,s);else if(E(n)){i||(i=new Map,u=document.createTextNode(""),e.parentNode.insertBefore(u,e));let t=e.parentNode,r=n.items.map((e,t)=>n.keyFn(e,t)),l=new Set(r),o=!1;if(i.size>0)for(let e of i.keys())if(l.has(e)){o=!0;break}if(!o){if(i.size>0){let t=document.createRange();t.setStartAfter(u),t.setEndBefore(e),t.deleteContents();for(let e of i.values())e.cleanup();i.clear()}if(r.length>0){let l=document.createDocumentFragment();y(()=>{for(let e=0;e<r.length;e++){let t=r[e],o=n.items[e],a=document.createTextNode(""),u=document.createTextNode("");l.appendChild(a),l.appendChild(u);let c=n.renderFn(o,e),f=O(c)?R(c,l,u,s):c._render(l,u);i?.set(t,{start:a,end:u,cleanup:f})}}),t.insertBefore(l,e)}return void(a=r)}let c=new Map;for(let e=0;e<r.length;e++)c.set(r[e],e);let f=new Int32Array(r.length),d=!1,p=0;for(let e=0;e<a.length;e++){let t=a[e],n=c.get(t);if(void 0===n){let e=i.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}i.delete(t)}else f[n]=e+1,n>=p?p=n:d=!0}let h=d?ne(f):[],m=h.length-1,v=e;for(let e=r.length-1;e>=0;e--){let l=r[e];if(0===f[e]){let r=n.items[e],o=document.createTextNode(""),a=document.createTextNode(""),u=document.createDocumentFragment();u.appendChild(o),u.appendChild(a);let c=n.renderFn(r,e),f=O(c)?R(c,u,a,s):c._render(u,a);i.set(l,{start:o,end:a,cleanup:f}),t.insertBefore(u,v),v=o}else{let n=i.get(l);if(d)if(m<0||e!==h[m]){let e=n.start;for(;e;){let r=e===n.end?null:e.nextSibling;if(t.insertBefore(e,v),!r)break;e=r}}else m--;v=n.start}}a=r}else if(Array.isArray(n)){let t=[];for(let r of n)if(O(r))t.push(I(r,e.parentNode,e));else if(T(r))t.push(r._render(e.parentNode,e));else if(null!=r&&!1!==r){let n=document.createTextNode(String(r));e.parentNode.insertBefore(n,e),t.push(()=>n.parentNode?.removeChild(n))}o=()=>t.forEach(e=>e())}else l=document.createTextNode(String(n)),e.parentNode.insertBefore(l,e)});n.push(()=>{if(p(),o&&=(o(),null),l&&=(l.parentNode?.removeChild(l),null),i){for(let e of i.values())e.cleanup();i=null,u=null}})}function U(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ie(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.lastIndexOf("=");if(-1===l)return{type:"node"};let o=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=l-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,l);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:a,hadOpenQuote:o}}var ae={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},oe=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),se=new Set;function ce(e,t,n){let r=e.target,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};r&&r!==document;){let l=r[t];if(l){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,l=!0;for(let e of t){let t=ae[e];if(void 0!==t&&n.key!==t){l=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){l=!1;break}}if(!l){r=r.parentNode;continue}}}if(l(e),o)break}r=r.parentNode}e.stopPropagation=l}var le=new Map;function ue(e,t,n,r){let l=[],o=[],i=Array(t.length),a=-1;for(let e=0;e<t.length;e++)r[e]&&r[e].nodeIndex>a&&(a=r[e].nodeIndex);let u=Array(a+1);if(u[0]=e,a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=a&&(t=n.nextNode());)u[r++]=t}for(let e=0;e<t.length;e++){let t=r[e];i[e]=t?u[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let a=t[e],u=n[e],s=r[e];if(!s)continue;let c=i[e];if("event"===a.type){let e=s.name,t=u,n=a.modifiers;if(!oe.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))}else{if(!se.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>ce(e,t,n);le.set(e,r),document.addEventListener(e,r),se.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;c[r]=t,n.length>0&&(c[o]=n),l.push(()=>{c[r]=null,c[o]=null})}continue}if("attr"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,l.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,o=!1,i=!0,a=_(()=>{o=!!u();let l=()=>{t=!1;let l="show"===e?o:!o;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"};i?(i=!1,l()):t||(t=!0,H(l))});l.push(a)}else("show"===e?u:!u)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof u){let r,o=!1,i=!0,a=_(()=>{r=u();let l=()=>{o=!1;let l=r;n?t[e]=l??"":null==l||!1===l?t.removeAttribute(e):t.setAttribute(e,String(l))};i?(i=!1,l()):o||(o=!0,H(l))});l.push(a)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;let d=document.createTextNode("");f.parentNode.replaceChild(d,f),re(d,u,l,o)}return{disposes:l,postMountHooks:o}}function de(e,t){let n=new Uint8Array(e.length),r="";for(let l=0;l<e.length;l++){let o=e[l];if(1===n[l]&&('"'===o[0]||"'"===o[0])&&(o=o.slice(1)),l<t.length){let e=t[l];if("node"===e.type)r+=o+`\x3c!--nix-${l}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+ +!!e.hadOpenQuote;r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&(n[l+1]=1)}else{let t=`${e.attrName}=`.length+ +!!e.hadOpenQuote;r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}var fe=new WeakMap;function W(e,...t){let n=fe.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ie(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=de(e,t);let o,i=Array(t.length).fill(null),a=l.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=u.nextNode();)if(s++,8===o.nodeType){let e=o.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===o.nodeType){let e=o,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],l=r.name;if(l.startsWith("data-nix-e-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l));continue}if(l.startsWith("data-nix-a-")){let t=parseInt(l.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(l))}}}n={contexts:t,tpl:l,pathMap:i},fe.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:a,postMountHooks:u}=ue(i,r,t,o),s=document.createTextNode(""),c=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),e.insertBefore(c,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==c;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s),c.parentNode?.removeChild(c)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function pe(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function me(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function he(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(me(r.transitionDuration||"0"),me(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},o)})}function ge(e,t={}){let n=pe(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(w.TRANSITION);r.insertBefore(o,l);let i=null,a=null,u=0,s=!0,c=()=>{let e=o.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return O(e)?L(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await he(l,t.duration),u===e&&(l.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(l)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let l=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await he(r,t.duration),u===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||O(e))d(e);else{let t=e,n=null;h=_(()=>{let e=t(),r=null===n,l=null===e;r&&!l?d(e):!r&&l?p():!r&&!l&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,o.remove()}}}}function _e(){return{__isPortalOutlet:!0,_container:null}}function ve(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 ye(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l;return l="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,O(e)?I(e,l,null):e._render(l,null)}}}var be=k("nix:portal-outlet");function xe(e){P(be,e)}function Se(){return F(be)}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(w.ERROR_BOUNDARY);n.insertBefore(l,r);let i,a=null,u=!1,c=!1,f=!1,d=e=>{let n=l.parentNode,o="function"!=typeof t||O(t)?t:t(e);a=O(o)?L(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(O(e)){M();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{N()}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()}}}}var G=k("nix:router"),K=null,q=null,we="__nix_scroll";function Te(){if(!K)throw Error("[Nix] No active router. Call createRouter() first.");return K}function J(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function Ee(e){if(!e||"object"!=typeof e)return null;let t=e[we];if(!t||"object"!=typeof t)return null;let n=t.left,r=t.top;return"number"!=typeof n||"number"!=typeof r?null:{left:n,top:r}}function Y(e,t){let n=e&&"object"==typeof e?{...e}:{};return n[we]={left:t.left,top:t.top},n}function X(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function De(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 Oe(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 ke(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Ae(e,t="",n=[]){let r=[];for(let l of e){let e=ke(t,l.path),o=[...n,l.component],i=Oe(e);r.push({fullPath:e,segments:i,chain:o,name:l.name,meta:l.meta,beforeEnter:l.beforeEnter,record:l}),l.children?.length&&r.push(...Ae(l.children,e,o))}return r}function je(e,t){let n=e.split("/").filter(Boolean),r=t.segments;if(1===r.length&&"wildcard"===r[0].kind)return{};let l=r.length>0&&"wildcard"===r[r.length-1].kind,o=l?r.slice(0,-1):r;if(l){if(n.length<o.length)return null}else if(n.length!==o.length)return null;let i={};for(let e=0;e<o.length;e++){let t=o[e];if("literal"===t.kind){if(n[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(n[e]??"")}catch{i[t.name]=n[e]??""}}return i}function Me(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function Z(e,t){let n,r={},l=-1;for(let o of t){let t=je(e,o);if(null===t)continue;let i=Me(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function Ne(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Pe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return Ne(new URL(t,window.location.origin).pathname)}catch{return Ne(t)}}function Fe(e,t){let n=null==t?.base?Pe():Ne(t.base),r=t?.mode??"history",l="hash"===r,o=t?.scrollBehavior,i=new Map,a=!1;function u(e){return e?e.startsWith("/")?e:"/"+e:"/"}function s(e){let t=u(e||"/");if(n&&t.startsWith(n)){let e=t.slice(n.length);return""===e?"/":u(e)}return t}function c(e){let t=u(e);return n?(n+t).replace(/\/+/g,"/")||"/":t}function f(){return l?function(){let e=window.location.hash||"";if(e.startsWith("#")&&(e=e.slice(1)),!e)return{pathname:"/",search:""};e.startsWith("/")||(e="/"+e);let t=e.indexOf("?"),n=-1===t?e:e.slice(0,t),r=-1===t?"":e.slice(t);return{pathname:s(n),search:r}}():{pathname:s(window.location.pathname||"/"),search:window.location.search||""}}function d(e,t){let n=c(e)+De(t);return l?"#"+n:n}function p(e,t){return u(e)+De(t)}let h=f(),m=h.pathname,v=X(h.search),y=Ae(e),_=new Map;for(let e of y)e.name&&(_.has(e.name)&&console.warn(`[Nix Router] Duplicate route name: "${e.name}"`),_.set(e.name,e));let b=Z(m,y),x=g(m),w=g(b?.params??{}),N=g(v);function E(e){window.scrollTo(e.left,e.top)}function k(e,t,n){if(o){let r=o(e,t,n);if(!1===r||null==r)return;return void E(r)}E(n??{left:0,top:0})}l?i.set(p(m,v),J()):history.replaceState(Y(history.state,J()),"");let S=[],A=[],O=0;function T(e,t,n,r,l){let o=[...S];n&&o.push(n);let i=++O;if(0===o.length)return void r();let a=0;!function n(u){if(i!==O)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():R(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let $=!1;function M(e,t){let n=e.indexOf("?"),r=u((-1===n?e:e.slice(0,n))||"/"),l=-1===n?{}:X(e.slice(n)),o=t?{...l,...t}:l,i={};for(let[e,t]of Object.entries(o))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:r,stringQuery:i}}function L(e,t){return"string"==typeof e?M(e,t):M(function(e){let t=_.get(e.name);if(!t)throw Error(`[Nix Router] No route with name "${e.name}"`);return"/"+t.segments.map(t=>{if("literal"===t.kind)return t.value;if("wildcard"===t.kind)return"";let n=e.params?.[t.name];if(null==n)throw Error(`[Nix Router] Missing param "${t.name}" for route "${e.name}"`);return encodeURIComponent(String(n))}).filter(Boolean).join("/")}(e),{...e.query??{},...t??{}})}q&&=(q(),null);let I=(e,t,n,r)=>{let l=x.value,o={...N.value},i=Z(e,y);T(e,l,i?.route.beforeEnter,()=>{w.value=i?.params??{},N.value=t,x.value=e,k(e,l,n);for(let t of A)try{t(e,l)}catch{}},()=>r(l,o))};if(l){let e=()=>{if(a)return void(a=!1);let e=f(),t=X(e.search),n=i.get(p(e.pathname,t))??null;I(e.pathname,t,n,(e,t)=>{a=!0,window.location.hash=d(e,t).slice(1),queueMicrotask(()=>{a=!1})})};window.addEventListener("hashchange",e),q=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=f(),n=X(t.search),r=Ee(e.state??history.state);I(t.pathname,n,r,(e,t)=>{history.pushState(Y({},J()),"",d(e,t))})};window.addEventListener("popstate",e),q=()=>window.removeEventListener("popstate",e)}function W(e,t,n,r,o,u){u||function(e,t){let n=J();l?i.set(p(e,t),n):history.replaceState(Y(history.state,n),"")}(n,r),w.value=o?.params??{},N.value=t,x.value=e;let s=d(e,t);if(l)i.set(p(e,t),{left:0,top:0}),u?history.replaceState(history.state,"",s):(a=!0,window.location.hash=s.slice(1),queueMicrotask(()=>{a=!1}));else{let e=Y({},{left:0,top:0});u?history.replaceState(e,"",s):history.pushState(e,"",s)}k(e,n,null);for(let t of A)try{t(e,n)}catch{}}function R(e,t){$=!0;let{pathname:n,stringQuery:r}=L(e,t),l=x.value,o={...N.value},i=Z(n,y);T(n,l,i?.route.beforeEnter,()=>W(n,r,l,o,i,!1))}let B={current:x,params:w,query:N,base:n||"/",navigate:R,replace:function(e,t){$=!0;let{pathname:n,stringQuery:r}=L(e,t),l=x.value,o={...N.value},i=Z(n,y);T(n,l,i?.route.beforeEnter,()=>W(n,r,l,o,i,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=x.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=Z(e,y);return t?{matched:!0,params:t.params,route:t.route.record}:{matched:!1,params:{},route:void 0}},beforeEach:function(e){return S.push(e),()=>{let t=S.indexOf(e);-1!==t&&S.splice(t,1)}},afterEach:function(e){return A.push(e),()=>{let t=A.indexOf(e);-1!==t&&A.splice(t,1)}},routes:e,_flat:y,_guards:S,_base:n,_mode:r};return K&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),K=B,queueMicrotask(()=>{$||T(m,"",Z(m,y)?.route.beforeEnter,()=>{},()=>{let e=d("/",{});l?(i.set(p("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(Y({},{left:0,top:0}),"",e);let t=Z("/",y);x.value="/",w.value=t?.params??{},N.value={},k("/",m,null)})}),B}function Ie(){return F(G)||Te()}var Le=class extends D{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return W`<div class="router-view">${()=>{let t=Ie(),n=Z(t.current.value,t._flat);return n?e>=n.route.chain.length?W`<span></span>`:n.route.chain[e]():W`<div style="color:#f87171;padding:16px 0">
2
- 404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},Re=class extends D{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label,n=Ie(),r=e.startsWith("/")?e:"/"+e,l=(n._base?n._base+r:r).replace(/\/+/g,"/");return W`<a
4
- href=${"hash"===n._mode?"#"+l:l}
5
- style=${()=>n.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(),n.navigate(e)}}
7
- >${t}</a>`}};function ze(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: container not found: ${e}`);return t}function Be(e,t,n){if(O(e)){let r,l,o=ze(t);M();try{n?.router&&P(G,n.router);try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(o,null)}finally{N()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}}if(!n?.router)return e.mount(t);let r,l=ze(t);M();try{P(G,n.router),r=e._render(l,null)}finally{N()}return{unmount(){r()}}}function Ve(e,t,n){let r={},l=new Set(["$reset","$patch","$state","$subscribe"]);for(let t of Object.keys(e)){if(l.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);r[t]=g(e[t])}let o=r;let i=Object.assign(Object.create(null),o,{$reset:function(){for(let t of Object.keys(e))r[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in r&&(r[t].value=e[t])},$subscribe:function(t){let n=[];for(let r of Object.keys(e)){let e=x(o[r],(e,n)=>{t(r,e,n)});n.push(e)}return()=>{for(let e of n)e()}}});if(Object.defineProperty(i,"$state",{get(){let e={};for(let t in r)e[t]=r[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(o);for(let t of Object.keys(e))l.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):i[t]=e[t]}if(n){let e=n(o);for(let t of Object.keys(e))l.has(t)?console.warn(`[Nix] Store getter name "${t}" is reserved and will be ignored.`):i[t]=e[t]}return i}function He(){return W`
8
- <span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
9
- <span class="nix-spinner" style="
10
- display:inline-block;width:14px;height:14px;border-radius:50%;
11
- border:2px solid #38bdf840;border-top-color:#38bdf8;
12
- animation:nix-spin .7s linear infinite
13
- "></span>
14
- Loading…
15
- </span>
16
- <style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
17
- `}function Ue(e){return W`
18
- <span style="color:#f87171;font-size:13px">
19
- ⚠ ${e instanceof Error?e.message:String(e)}
20
- </span>
21
- `}var Q=new Map,We=3e5,$=null,Ge=We;function Ke(){null===$&&($=setInterval(()=>{let e=Date.now();for(let[t,n]of Q)n.subscribers<=0&&e-n.fetchedAt>Ge&&Q.delete(t);0===Q.size&&null!==$&&(clearInterval($),$=null)},6e4))}function qe(e){let t=Q.get(e);if(t&&t.fetchedAt>0)return t}function Je(e,t){let n=Q.get(e);Q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ke()}function Ye(e){let t=Q.get(e);t?t.subscribers++:Q.set(e,{fetchedAt:0,subscribers:1})}function Xe(e){let t=Q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ze(e,t){let n=Q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Qe(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??He(),c=l??Ue;return new class extends D{_state;_disposeWatcher;constructor(){super();let e=a?qe(a):void 0;this._state=g(e&&void 0!==e.data?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ye(a);let e=a?qe(a):void 0;if(e&&Ze(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(a&&Q.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Xe(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Je(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return W`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}function $e(e,t){let n=null;return()=>n?new n:Qe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function et(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function tt(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function nt(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function rt(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function it(e="Invalid email"){return rt(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function at(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function ot(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function st(e){return e}var ct={required:et,minLength:tt,maxLength:nt,email:it,pattern:rt,min:at,max:ot};function lt(e,t){return{...e,...t}}function ut(e,t=[],n="blur",r){let l=g(e),o=g(!1),i=g(!1),a=g(null),u=g(!1),s=v(()=>{if(a.value)return a.value;if(!("input"===n?i.value||o.value:"submit"===n?u.value:o.value))return null;let e=r?.();for(let n of t){let t=n(l.value,e);if(t)return t}return null});function c(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:l,error:s,touched:o,dirty:i,onInput:e=>{l.value=c(e.target),i.value=!0,a.value=null},onBlur:()=>{o.value=!0},reset:function(){l.value=e,o.value=!1,i.value=!1,a.value=null,u.value=!1},_setExternalError:function(e){a.value=e,e&&(o.value=!0)},_forceVisible:function(){o.value=!0,u.value=!0},_dispose:function(){s.dispose()}}}function dt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=ut(e[l],o,n)}return r}let l=g(e.map(r)),o=v(()=>l.value.length);return{fields:l,append:function(e){l.value=[...l.value,r(e)]},remove:function(e){let t=l.value;if(!(e<0||e>=t.length)){for(let n in t[e])t[e][n]._dispose();l.value=t.filter((t,n)=>n!==e)}},move:function(e,t){let n=[...l.value];if(e<0||e>=n.length||t<0||t>=n.length||e===t)return;let[r]=n.splice(e,1);n.splice(t,0,r),l.value=n},replace:function(e,t){let n=[...l.value];if(!(e<0||e>=n.length)){for(let t in n[e])n[e][t]._dispose();n[e]=r(t),l.value=n}},length:o,reset:function(){for(let e of l.value)for(let t in e)e[t]._dispose();l.value=e.map(r)},_dispose:function(){for(let e of l.value)for(let t in e)e[t]._dispose();o.dispose()}}}function ft(e){return"object"==typeof e&&!!e&&!Array.isArray(e)}function pt(e,t="",n=[]){for(let[r,l]of Object.entries(e)){let e=t?`${t}.${r}`:r;ft(l)&&Object.keys(l).length>0?pt(l,e,n):n.push([e,l])}return n}function mt(e,t,n){let r=t.split("."),l=e;for(let e=0;e<r.length-1;e++){let t=r[e];ft(l[t])||(l[t]={}),l=l[t]}l[r[r.length-1]]=n}function ht(e,t={}){let n=t.validateOn??"blur",r={},l=t.validators;function o(){let e={};for(let t in r)mt(e,t,r[t].value.value);return e}for(let[t,i]of pt(e))r[t]=ut(i,l?.[t]??[],n,o);let i=g(!1),a=g(0),u=v(()=>o()),s=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),c=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),f=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),d=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function p(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:u,errors:s,valid:c,dirty:f,touched:d,isSubmitting:i,submitCount:a,handleSubmit:function(e){return n=>{n.preventDefault(),a.value++;for(let e in r)r[e]._forceVisible();let l=u.value;if(t.validate){let e=t.validate(l);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void p(t)}}for(let e in r)if(r[e].error.value)return;let o=e(l);o instanceof Promise&&(i.value=!0,o.finally(()=>{i.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();i.value=!1,a.value=0},setErrors:p,dispose:function(){u.dispose(),s.dispose(),c.dispose(),f.dispose(),d.dispose();for(let e in r)r[e]._dispose()}}}export{Re as Link,D as NixComponent,G as RouterKey,Le as RouterView,h as Signal,y as batch,v as computed,Ce as createErrorBoundary,ht as createForm,k as createInjectionKey,_e as createPortalOutlet,Fe as createRouter,Ve as createStore,st as createValidator,_ as effect,it as email,lt as extendValidators,W as html,F as inject,Se as injectOutlet,$e as lazy,ot as max,nt as maxLength,at as min,tt as minLength,Be as mount,S as nextTick,rt as pattern,ye as portal,ve as portalOutlet,P as provide,xe as provideOutlet,C as ref,te as repeat,et as required,U as showWhen,g as signal,Qe as suspend,ge as transition,b as untrack,ut as useField,dt as useFieldArray,Ie as useRouter,ct as validators,x as watch};
1
+ import{Signal as e,batch as t,computed as n,effect as r,nextTick as i,signal as a,untrack as o,watch as s}from"./signals.js";import{a as c,d as l,h as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v}from"./template2.js";import{NixComponent as y}from"./lifecycle.js";import{createInjectionKey as b,inject as x,provide as S}from"./context.js";import{Link as C,RouterKey as w,RouterView as T,createRouter as E,useRouter as D}from"./router.js";import{mount as O}from"./component.js";import{createStore as k}from"./store.js";import{lazy as A,suspend as j}from"./async.js";import{createForm as M,createValidator as N,email as P,extendValidators as F,max as I,maxLength as L,min as R,minLength as z,pattern as B,required as V,useField as H,useFieldArray as U,validators as W}from"./form.js";export{C as Link,y as NixComponent,w as RouterKey,T as RouterView,e as Signal,t as batch,n as computed,_ as createErrorBoundary,M as createForm,b as createInjectionKey,p as createPortalOutlet,E as createRouter,k as createStore,N as createValidator,r as effect,P as email,F as extendValidators,f as html,x as inject,h as injectOutlet,A as lazy,I as max,L as maxLength,R as min,z as minLength,O as mount,i as nextTick,B as pattern,d as portal,c as portalOutlet,S as provide,m as provideOutlet,u as ref,l as repeat,V as required,v as showWhen,a as signal,j as suspend,g as transition,o as untrack,H as useField,U as useFieldArray,D as useRouter,W as validators,s as watch};
@@ -0,0 +1,7 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./signals.cjs"),t=require("./template2.cjs"),n=require("./lifecycle.cjs"),r=require("./context.cjs");var i=r.createInjectionKey("nix:router"),a=null,o=null,s="__nix_scroll";function c(){if(!a)throw Error("[Nix] No active router. Call createRouter() first.");return a}function l(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function u(e){if(!e||"object"!=typeof e)return null;let t=e[s];if(!t||"object"!=typeof t)return null;let r=t.left,n=t.top;return"number"!=typeof r||"number"!=typeof n?null:{left:r,top:n}}function d(e,t){let r=e&&"object"==typeof e?{...e}:{};return r[s]={left:t.left,top:t.top},r}function f(e){let t={};return new URLSearchParams(e).forEach((e,r)=>{t[r]=e}),t}function p(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))null!=n&&!1!==n&&t.set(r,String(n));let r=t.toString();return r?"?"+r:""}function m(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 h(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function g(e,t="",r=[]){let n=[];for(let o of e){let e=h(t,o.path),i=[...r,o.component],a=m(e);n.push({fullPath:e,segments:a,chain:i,name:o.name,meta:o.meta,beforeEnter:o.beforeEnter,record:o}),o.children?.length&&n.push(...g(o.children,e,i))}return n}function _(e,t){let r=e.split("/").filter(Boolean),n=t.segments;if(1===n.length&&"wildcard"===n[0].kind)return{};let o=n.length>0&&"wildcard"===n[n.length-1].kind,i=o?n.slice(0,-1):n;if(o){if(r.length<i.length)return null}else if(r.length!==i.length)return null;let a={};for(let e=0;e<i.length;e++){let t=i[e];if("literal"===t.kind){if(r[e]!==t.value)return null}else if("param"===t.kind)try{a[t.name]=decodeURIComponent(r[e]??"")}catch{a[t.name]=r[e]??""}}return a}function v(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function y(e,t){let r,n={},o=-1;for(let i of t){let t=_(e,i);if(null===t)continue;let a=v(i);a>o&&(r=i,n=t,o=a)}return r?{route:r,params:n}:void 0}function b(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function x(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return b(new URL(t,window.location.origin).pathname)}catch{return b(t)}}function S(t,r){let n=null==r?.base?x():b(r.base),i=r?.mode??"history",s="hash"===i,c=r?.scrollBehavior,h=new Map,m=!1;function v(e){return e?e.startsWith("/")?e:"/"+e:"/"}function w(e){let t=v(e||"/");if(n&&t.startsWith(n)){let e=t.slice(n.length);return""===e?"/":v(e)}return t}function _(){return s?function(){let e=window.location.hash||"";if(e.startsWith("#")&&(e=e.slice(1)),!e)return{pathname:"/",search:""};e.startsWith("/")||(e="/"+e);let t=e.indexOf("?"),r=-1===t?e:e.slice(0,t),n=-1===t?"":e.slice(t);return{pathname:w(r),search:n}}():{pathname:w(window.location.pathname||"/"),search:window.location.search||""}}function k(e,t){let r=function(e){let t=v(e);return n?(n+t).replace(/\/+/g,"/")||"/":t}(e)+p(t);return s?"#"+r:r}function S(e,t){return v(e)+p(t)}let E=_(),R=E.pathname,j=f(E.search),W=g(t),q=new Map;for(let e of W)e.name&&(q.has(e.name)&&console.warn(`[Nix Router] Duplicate route name: "${e.name}"`),q.set(e.name,e));let O=y(R,W),$=e.signal(R),C=e.signal(O?.params??{}),N=e.signal(j);function L(e){window.scrollTo(e.left,e.top)}function M(e,t,r){if(c){let n=c(e,t,r);if(!1===n||null==n)return;return void L(n)}L(r??{left:0,top:0})}s?h.set(S(R,j),l()):history.replaceState(d(history.state,l()),"");let P=[],T=[],U=0;function B(e,t,r,n,o){let i=[...P];r&&i.push(r);let a=++U;if(0===i.length)return void n();let l=0;!function r(u){if(a!==U)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?n():X(u));if(l>=i.length)return void n();let s=i[l++](e,t);s instanceof Promise?s.then(r):r(s)}(void 0)}let A=!1;function I(e,t){let r=e.indexOf("?"),n=v((-1===r?e:e.slice(0,r))||"/"),o=-1===r?{}:f(e.slice(r)),i=t?{...o,...t}:o,a={};for(let[e,t]of Object.entries(i))null!=t&&!1!==t&&(a[e]=String(t));return{pathname:n,stringQuery:a}}function Q(e,t){return"string"==typeof e?I(e,t):I(function(e){let t=q.get(e.name);if(!t)throw Error(`[Nix Router] No route with name "${e.name}"`);return"/"+t.segments.map(t=>{if("literal"===t.kind)return t.value;if("wildcard"===t.kind)return"";let r=e.params?.[t.name];if(null==r)throw Error(`[Nix Router] Missing param "${t.name}" for route "${e.name}"`);return encodeURIComponent(String(r))}).filter(Boolean).join("/")}(e),{...e.query??{},...t??{}})}o&&=(o(),null);let D=(e,t,r,n)=>{let o=$.value,i={...N.value},a=y(e,W);B(e,o,a?.route.beforeEnter,()=>{C.value=a?.params??{},N.value=t,$.value=e,M(e,o,r);for(let t of T)try{t(e,o)}catch{}},()=>n(o,i))};if(s){let e=()=>{if(m)return void(m=!1);let e=_(),t=f(e.search),r=h.get(S(e.pathname,t))??null;D(e.pathname,t,r,(e,t)=>{m=!0,window.location.hash=k(e,t).slice(1),queueMicrotask(()=>{m=!1})})};window.addEventListener("hashchange",e),o=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=_(),r=f(t.search),n=u(e.state??history.state);D(t.pathname,r,n,(e,t)=>{history.pushState(d({},l()),"",k(e,t))})};window.addEventListener("popstate",e),o=()=>window.removeEventListener("popstate",e)}function K(e,t,r,n,o,i){i||function(e,t){let r=l();s?h.set(S(e,t),r):history.replaceState(d(history.state,r),"")}(r,n),C.value=o?.params??{},N.value=t,$.value=e;let a=k(e,t);if(s)h.set(S(e,t),{left:0,top:0}),i?history.replaceState(history.state,"",a):(m=!0,window.location.hash=a.slice(1),queueMicrotask(()=>{m=!1}));else{let e=d({},{left:0,top:0});i?history.replaceState(e,"",a):history.pushState(e,"",a)}M(e,r,null);for(let t of T)try{t(e,r)}catch{}}function X(e,t){A=!0;let{pathname:r,stringQuery:n}=Q(e,t),o=$.value,i={...N.value},a=y(r,W);B(r,o,a?.route.beforeEnter,()=>K(r,n,o,i,a,!1))}let Y={current:$,params:C,query:N,base:n||"/",navigate:X,replace:function(e,t){A=!0;let{pathname:r,stringQuery:n}=Q(e,t),o=$.value,i={...N.value},a=y(r,W);B(r,o,a?.route.beforeEnter,()=>K(r,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 r=$.value;return t?r===e:r===e||r.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=y(e,W);return t?{matched:!0,params:t.params,route:t.route.record}:{matched:!1,params:{},route:void 0}},beforeEach:function(e){return P.push(e),()=>{let t=P.indexOf(e);-1!==t&&P.splice(t,1)}},afterEach:function(e){return T.push(e),()=>{let t=T.indexOf(e);-1!==t&&T.splice(t,1)}},routes:t,_flat:W,_guards:P,_base:n,_mode:i};return a&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),a=Y,queueMicrotask(()=>{A||B(R,"",y(R,W)?.route.beforeEnter,()=>{},()=>{let e=k("/",{});s?(h.set(S("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(d({},{left:0,top:0}),"",e);let t=y("/",W);$.value="/",C.value=t?.params??{},N.value={},M("/",R,null)})}),Y}function C(){return r.inject(i)||c()}function w(){o&&=(o(),null),a=null}var T=class extends n.NixComponent{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return t.l`<div class="router-view">${()=>{let r=C(),n=y(r.current.value,r._flat);return n?e>=n.route.chain.length?t.l`<span></span>`:n.route.chain[e]():t.l`<div style="color:#f87171;padding:16px 0">
2
+ 404 — Route not found: <strong>${r.current.value}</strong>
3
+ </div>`}}</div>`}},E=class extends n.NixComponent{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,r=this._label,n=C(),o=e.startsWith("/")?e:"/"+e,i=(n._base?n._base+o:o).replace(/\/+/g,"/");return t.l`<a
4
+ href=${"hash"===n._mode?"#"+i:i}
5
+ style=${()=>n.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(),n.navigate(e)}}
7
+ >${r}</a>`}};exports.Link=E,exports.RouterKey=i,exports.RouterView=T,exports._resetRouter=w,exports.createRouter=S,exports.useRouter=C;
@@ -0,0 +1,7 @@
1
+ import{signal as e}from"./signals.js";import{l as t}from"./template2.js";import{NixComponent as n}from"./lifecycle.js";import{createInjectionKey as r,inject as i}from"./context.js";var a=r("nix:router"),o=null,s=null,c="__nix_scroll";function l(){if(!o)throw Error("[Nix] No active router. Call createRouter() first.");return o}function u(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function d(e){if(!e||"object"!=typeof e)return null;let t=e[c];if(!t||"object"!=typeof t)return null;let r=t.left,n=t.top;return"number"!=typeof r||"number"!=typeof n?null:{left:r,top:n}}function f(e,t){let r=e&&"object"==typeof e?{...e}:{};return r[c]={left:t.left,top:t.top},r}function p(e){let t={};return new URLSearchParams(e).forEach((e,r)=>{t[r]=e}),t}function m(e){let t=new URLSearchParams;for(let[r,n]of Object.entries(e))null!=n&&!1!==n&&t.set(r,String(n));let r=t.toString();return r?"?"+r:""}function h(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 g(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function _(e,t="",r=[]){let n=[];for(let o of e){let e=g(t,o.path),a=[...r,o.component],i=h(e);n.push({fullPath:e,segments:i,chain:a,name:o.name,meta:o.meta,beforeEnter:o.beforeEnter,record:o}),o.children?.length&&n.push(..._(o.children,e,a))}return n}function v(e,t){let r=e.split("/").filter(Boolean),n=t.segments;if(1===n.length&&"wildcard"===n[0].kind)return{};let o=n.length>0&&"wildcard"===n[n.length-1].kind,a=o?n.slice(0,-1):n;if(o){if(r.length<a.length)return null}else if(r.length!==a.length)return null;let i={};for(let e=0;e<a.length;e++){let t=a[e];if("literal"===t.kind){if(r[e]!==t.value)return null}else if("param"===t.kind)try{i[t.name]=decodeURIComponent(r[e]??"")}catch{i[t.name]=r[e]??""}}return i}function y(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function b(e,t){let r,n={},o=-1;for(let a of t){let t=v(e,a);if(null===t)continue;let i=y(a);i>o&&(r=a,n=t,o=i)}return r?{route:r,params:n}:void 0}function x(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function S(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return x(new URL(t,window.location.origin).pathname)}catch{return x(t)}}function C(t,r){let n=null==r?.base?S():x(r.base),a=r?.mode??"history",i="hash"===a,l=r?.scrollBehavior,c=new Map,h=!1;function g(e){return e?e.startsWith("/")?e:"/"+e:"/"}function v(e){let t=g(e||"/");if(n&&t.startsWith(n)){let e=t.slice(n.length);return""===e?"/":g(e)}return t}function w(){return i?function(){let e=window.location.hash||"";if(e.startsWith("#")&&(e=e.slice(1)),!e)return{pathname:"/",search:""};e.startsWith("/")||(e="/"+e);let t=e.indexOf("?"),r=-1===t?e:e.slice(0,t),n=-1===t?"":e.slice(t);return{pathname:v(r),search:n}}():{pathname:v(window.location.pathname||"/"),search:window.location.search||""}}function y(e,t){let r=function(e){let t=g(e);return n?(n+t).replace(/\/+/g,"/")||"/":t}(e)+m(t);return i?"#"+r:r}function k(e,t){return g(e)+m(t)}let E=w(),R=E.pathname,j=p(E.search),W=_(t),$=new Map;for(let e of W)e.name&&($.has(e.name)&&console.warn(`[Nix Router] Duplicate route name: "${e.name}"`),$.set(e.name,e));let O=b(R,W),L=e(R),N=e(O?.params??{}),q=e(j);function C(e){window.scrollTo(e.left,e.top)}function M(e,t,r){if(l){let n=l(e,t,r);if(!1===n||null==n)return;return void C(n)}C(r??{left:0,top:0})}i?c.set(k(R,j),u()):history.replaceState(f(history.state,u()),"");let U=[],B=[],D=0;function P(e,t,r,n,o){let a=[...U];r&&a.push(r);let i=++D;if(0===a.length)return void n();let l=0;!function r(u){if(i!==D)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?n():X(u));if(l>=a.length)return void n();let s=a[l++](e,t);s instanceof Promise?s.then(r):r(s)}(void 0)}let T=!1;function A(e,t){let r=e.indexOf("?"),n=g((-1===r?e:e.slice(0,r))||"/"),o=-1===r?{}:p(e.slice(r)),a=t?{...o,...t}:o,i={};for(let[e,t]of Object.entries(a))null!=t&&!1!==t&&(i[e]=String(t));return{pathname:n,stringQuery:i}}function I(e,t){return"string"==typeof e?A(e,t):A(function(e){let t=$.get(e.name);if(!t)throw Error(`[Nix Router] No route with name "${e.name}"`);return"/"+t.segments.map(t=>{if("literal"===t.kind)return t.value;if("wildcard"===t.kind)return"";let r=e.params?.[t.name];if(null==r)throw Error(`[Nix Router] Missing param "${t.name}" for route "${e.name}"`);return encodeURIComponent(String(r))}).filter(Boolean).join("/")}(e),{...e.query??{},...t??{}})}s&&=(s(),null);let Q=(e,t,r,n)=>{let o=L.value,a={...q.value},i=b(e,W);P(e,o,i?.route.beforeEnter,()=>{N.value=i?.params??{},q.value=t,L.value=e,M(e,o,r);for(let t of B)try{t(e,o)}catch{}},()=>n(o,a))};if(i){let e=()=>{if(h)return void(h=!1);let e=w(),t=p(e.search),r=c.get(k(e.pathname,t))??null;Q(e.pathname,t,r,(e,t)=>{h=!0,window.location.hash=y(e,t).slice(1),queueMicrotask(()=>{h=!1})})};window.addEventListener("hashchange",e),s=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=w(),r=p(t.search),n=d(e.state??history.state);Q(t.pathname,r,n,(e,t)=>{history.pushState(f({},u()),"",y(e,t))})};window.addEventListener("popstate",e),s=()=>window.removeEventListener("popstate",e)}function K(e,t,r,n,o,a){a||function(e,t){let r=u();i?c.set(k(e,t),r):history.replaceState(f(history.state,r),"")}(r,n),N.value=o?.params??{},q.value=t,L.value=e;let l=y(e,t);if(i)c.set(k(e,t),{left:0,top:0}),a?history.replaceState(history.state,"",l):(h=!0,window.location.hash=l.slice(1),queueMicrotask(()=>{h=!1}));else{let e=f({},{left:0,top:0});a?history.replaceState(e,"",l):history.pushState(e,"",l)}M(e,r,null);for(let t of B)try{t(e,r)}catch{}}function X(e,t){T=!0;let{pathname:r,stringQuery:n}=I(e,t),o=L.value,a={...q.value},i=b(r,W);P(r,o,i?.route.beforeEnter,()=>K(r,n,o,a,i,!1))}let Y={current:L,params:N,query:q,base:n||"/",navigate:X,replace:function(e,t){T=!0;let{pathname:r,stringQuery:n}=I(e,t),o=L.value,a={...q.value},i=b(r,W);P(r,o,i?.route.beforeEnter,()=>K(r,n,o,a,i,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let r=L.value;return t?r===e:r===e||r.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=b(e,W);return t?{matched:!0,params:t.params,route:t.route.record}:{matched:!1,params:{},route:void 0}},beforeEach:function(e){return U.push(e),()=>{let t=U.indexOf(e);-1!==t&&U.splice(t,1)}},afterEach:function(e){return B.push(e),()=>{let t=B.indexOf(e);-1!==t&&B.splice(t,1)}},routes:t,_flat:W,_guards:U,_base:n,_mode:a};return o&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),o=Y,queueMicrotask(()=>{T||P(R,"",b(R,W)?.route.beforeEnter,()=>{},()=>{let e=y("/",{});i?(c.set(k("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(f({},{left:0,top:0}),"",e);let t=b("/",W);L.value="/",N.value=t?.params??{},q.value={},M("/",R,null)})}),Y}function w(){return i(a)||l()}function T(){s&&=(s(),null),o=null}var E=class extends n{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return t`<div class="router-view">${()=>{let r=w(),n=b(r.current.value,r._flat);return n?e>=n.route.chain.length?t`<span></span>`:n.route.chain[e]():t`<div style="color:#f87171;padding:16px 0">
2
+ 404 — Route not found: <strong>${r.current.value}</strong>
3
+ </div>`}}</div>`}},D=class extends n{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,r=this._label,n=w(),o=e.startsWith("/")?e:"/"+e,a=(n._base?n._base+o:o).replace(/\/+/g,"/");return t`<a
4
+ href=${"hash"===n._mode?"#"+a:a}
5
+ style=${()=>n.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(),n.navigate(e)}}
7
+ >${r}</a>`}};export{D as Link,a as RouterKey,E as RouterView,T as _resetRouter,C as createRouter,w as useRouter};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let l of this._subs)p[e+t++]=l;m=e+t;try{for(let l=0;l<t;l++){let t=p[e+l];p[e+l]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let o,s=!1,u=new Set,p=new Set,a=i,c=()=>{if(s)return;"function"==typeof o&&o();let i=u;u=p,p=i,p.clear();let h=e.length>0?e.pop():{effect:null,deps:null};if(h.effect=n,h.deps=r,t.push(h),n=c,r=p,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{o=l()}catch(e){if(!a)throw e;a(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of u)p.has(e)||e._removeSub(c)}};return c(),()=>{s=!0,"function"==typeof o&&o();for(let e of p)e._removeSub(c);p.clear(),u.clear()}}function v(e){let t=new h(void 0),l=_(()=>{t.value=e()}),n=t.dispose;return t.dispose=()=>{l(),n.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,l={}){let n,{immediate:r=!1,once:o=!1}=l,s=e instanceof h?()=>e.value:e,u=!0,i=!1,f=_(()=>{let e=s();if(u){if(u=!1,r&&!i){let l=e;b(()=>t(l,void 0)),o&&(i=!0,Promise.resolve().then(f))}n=e}else if(!i){let l=e,r=n;n=e,b(()=>t(l,r)),o&&(i=!0,Promise.resolve().then(f))}});return()=>{i=!0,f()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}exports.Signal=h,exports._popErrorHandler=s,exports._pushErrorHandler=o,exports.batch=y,exports.computed=v,exports.effect=_,exports.nextTick=S,exports.signal=g,exports.untrack=b,exports.watch=x;
@@ -0,0 +1 @@
1
+ var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=[],d=100,f=0,p=[],m=0,h=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return n&&(this._subs.add(n),r?.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(){if(c>0){for(let e of this._subs)l.has(e)||(l.add(e),u.push(e));return}let e=m,t=0;for(let l of this._subs)p[e+t++]=l;m=e+t;try{for(let l=0;l<t;l++){let t=p[e+l];p[e+l]=null,t?.()}}finally{m=e}}dispose(){this._subs.clear()}};function g(e){return new h(e)}function _(l){let s,u=!1,o=new Set,a=new Set,c=i,h=()=>{if(u)return;"function"==typeof s&&s();let i=o;o=a,a=i,a.clear();let p=e.length>0?e.pop():{effect:null,deps:null};if(p.effect=n,p.deps=r,t.push(p),n=h,r=a,++f>d){f=0;let l=t.pop();throw n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l),Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).")}try{s=l()}catch(e){if(!c)throw e;c(e)}finally{f--;let l=t.pop();n=l.effect,r=l.deps,l.effect=null,l.deps=null,e.push(l);for(let e of o)a.has(e)||e._removeSub(h)}};return h(),()=>{u=!0,"function"==typeof s&&s();for(let e of a)e._removeSub(h);a.clear(),o.clear()}}function v(e){let t=new h(void 0),l=_(()=>{t.value=e()}),n=t.dispose;return t.dispose=()=>{l(),n.call(t)},t}function y(e){c++;try{e()}finally{if(0===--c&&u.length>0){let e=u.length;for(let t=0;t<e;t++)u[t]();u.length=0,l.clear()}}}function b(e){let t=n,l=r;n=null,r=null;try{return e()}finally{n=t,r=l}}function x(e,t,l={}){let n,{immediate:s=!1,once:r=!1}=l,u=e instanceof h?()=>e.value:e,i=!0,o=!1,f=_(()=>{let e=u();if(i){if(i=!1,s&&!o){let l=e;b(()=>t(l,void 0)),r&&(o=!0,Promise.resolve().then(f))}n=e}else if(!o){let l=e,s=n;n=e,b(()=>t(l,s)),r&&(o=!0,Promise.resolve().then(f))}});return()=>{o=!0,f()}}function S(e){return e?Promise.resolve().then(e):Promise.resolve()}export{h as Signal,s as _popErrorHandler,o as _pushErrorHandler,y as batch,v as computed,_ as effect,S as nextTick,g as signal,b as untrack,x as watch};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./signals.cjs");function t(t,r,o){let n={},s=new Set(["$reset","$patch","$state","$subscribe"]);for(let r of Object.keys(t)){if(s.has(r))throw Error(`[Nix] Store key "${r}" is reserved.`);n[r]=e.signal(t[r])}let l=n;let i=Object.assign(Object.create(null),l,{$reset:function(){for(let e of Object.keys(t))n[e].value=t[e]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])},$subscribe:function(r){let o=[];for(let n of Object.keys(t)){let t=l[n],s=e.watch(t,(e,t)=>{r(n,e,t)});o.push(s)}return()=>{for(let e of o)e()}}});if(Object.defineProperty(i,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),r){let e=r(l);for(let t of Object.keys(e))s.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):i[t]=e[t]}if(o){let e=o(l);for(let t of Object.keys(e))s.has(t)?console.warn(`[Nix] Store getter name "${t}" is reserved and will be ignored.`):i[t]=e[t]}return i}exports.createStore=t;
@@ -0,0 +1 @@
1
+ import{signal as e,watch as t}from"./signals.js";function n(r,o,s){let n={},l=new Set(["$reset","$patch","$state","$subscribe"]);for(let t of Object.keys(r)){if(l.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=e(r[t])}let a=n;let i=Object.assign(Object.create(null),a,{$reset:function(){for(let e of Object.keys(r))n[e].value=r[e]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])},$subscribe:function(e){let o=[];for(let s of Object.keys(r)){let r=a[s],n=t(r,(t,r)=>{e(s,t,r)});o.push(n)}return()=>{for(let e of o)e()}}});if(Object.defineProperty(i,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),o){let e=o(a);for(let t of Object.keys(e))l.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):i[t]=e[t]}if(s){let e=s(a);for(let t of Object.keys(e))l.has(t)?console.warn(`[Nix] Store getter name "${t}" is reserved and will be ignored.`):i[t]=e[t]}return i}export{n as createStore};
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./template2.cjs");exports.COMMENT=e.f,exports.buildHTML=e.c,exports.createErrorBoundary=e.t,exports.createPortalOutlet=e.n,exports.html=e.l,exports.injectOutlet=e.r,exports.isKeyedList=e.p,exports.isNixTemplate=e.m,exports.portal=e.i,exports.portalOutlet=e.a,exports.provideOutlet=e.o,exports.ref=e.h,exports.repeat=e.d,exports.showWhen=e.u,exports.transition=e.s;
@@ -0,0 +1 @@
1
+ import{a as e,c as t,d as n,f as r,h as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./template2.js";export{r as COMMENT,t as buildHTML,p as createErrorBoundary,c as createPortalOutlet,o as html,d as injectOutlet,u as isKeyedList,s as isNixTemplate,a as portal,e as portalOutlet,l as provideOutlet,i as ref,n as repeat,m as showWhen,f as transition};
@@ -0,0 +1 @@
1
+ const e=require("./signals.cjs"),t=require("./lifecycle.cjs"),n=require("./context.cjs");function r(){return{el:null}}var i={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function a(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function o(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function s(e,t,r){let o,l;n._pushComponentContext();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,r)}finally{n._popComponentContext()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function c(e,t,r){let o,l;n._pushComponentContext();try{try{e.onInit?.()}catch{}o=e.render()._render(t,r)}finally{n._popComponentContext()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function l(e,t,r,o){let l,i;n._withComponentContext(o,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,r)});try{let t=e.onMount?.();"function"==typeof t&&(i=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}l()}}function u(e,t,r,o,l){let i,a;n._pushComponentContext();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}i=e.render()._render(t,r)}finally{n._popComponentContext()}o.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(a=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{a?.()}catch{}i()})}function d(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function f(e){let t,n,r,o,l,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,o=a.length-1;r<o;)l=r+o>>1,e[a[l]]<u?r=l+1:o=l;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,o=a[r-1];r-- >0;)a[r]=o,o=i[o];return a}var p=new Set,m=!1;function h(e){p.add(e),m||(m=!0,queueMicrotask(()=>{for(let e of p)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}p.clear(),m=!1}))}function g(r,i,c,d){if("function"!=typeof i){if(t.isNixComponent(i))u(i,r.parentNode,r,d,c);else if(a(i))c.push(i._render(r.parentNode,r));else if(Array.isArray(i))for(let e of i)t.isNixComponent(e)?u(e,r.parentNode,r,d,c):a(e)?e._render(r.parentNode,r):null!=e&&!1!==e&&r.parentNode.insertBefore(document.createTextNode(String(e)),r);else null!=i&&!1!==i&&r.parentNode.insertBefore(document.createTextNode(String(i)),r);return}let p=null,m=null,y=null,x=[],N=null,g=n._captureContextSnapshot(),v=!1,_="",b=!0,E=e.effect(()=>{let n=i();if("string"==typeof n||"number"==typeof n){_=String(n);let e=()=>{v=!1,m&&=(m(),null),p?p.nodeValue=_:(p=document.createTextNode(_),r.parentNode.insertBefore(p,r))};return void(b?(b=!1,e()):v||(v=!0,h(e)))}if(v=!1,b=!1,p&&=(p.parentNode?.removeChild(p),null),m&&=(m(),null),null!=n&&!1!==n)if(a(n))m=n._render(r.parentNode,r);else if(t.isNixComponent(n))m=l(n,r.parentNode,r,g);else if(o(n)){y||(y=new Map,N=document.createTextNode(""),r.parentNode.insertBefore(N,r));let o=r.parentNode,i=n.items.map((e,t)=>n.keyFn(e,t)),a=new Set(i),u=!1;if(y.size>0)for(let e of y.keys())if(a.has(e)){u=!0;break}if(!u){if(y.size>0){let e=document.createRange();e.setStartAfter(N),e.setEndBefore(r),e.deleteContents();for(let e of y.values())e.cleanup();y.clear()}if(i.length>0){let a=document.createDocumentFragment();e.batch(()=>{for(let e=0;e<i.length;e++){let r=i[e],o=n.items[e],u=document.createTextNode(""),c=document.createTextNode("");a.appendChild(u),a.appendChild(c);let s=n.renderFn(o,e),d=t.isNixComponent(s)?l(s,a,c,g):s._render(a,c);y?.set(r,{start:u,end:c,cleanup:d})}}),o.insertBefore(a,r)}return void(x=i)}let c=new Map;for(let e=0;e<i.length;e++)c.set(i[e],e);let s=new Int32Array(i.length),d=!1,p=0;for(let e=0;e<x.length;e++){let t=x[e],n=c.get(t);if(void 0===n){let e=y.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}y.delete(t)}else s[n]=e+1,n>=p?p=n:d=!0}let m=d?f(s):[],h=m.length-1,v=r;for(let e=i.length-1;e>=0;e--){let r=i[e];if(0===s[e]){let i=n.items[e],a=document.createTextNode(""),u=document.createTextNode(""),c=document.createDocumentFragment();c.appendChild(a),c.appendChild(u);let s=n.renderFn(i,e),d=t.isNixComponent(s)?l(s,c,u,g):s._render(c,u);y.set(r,{start:a,end:u,cleanup:d}),o.insertBefore(c,v),v=a}else{let t=y.get(r);if(d)if(h<0||e!==m[h]){let e=t.start;for(;e;){let n=e===t.end?null:e.nextSibling;if(o.insertBefore(e,v),!n)break;e=n}}else h--;v=t.start}}x=i}else if(Array.isArray(n)){let e=[];for(let o of n)if(t.isNixComponent(o))e.push(s(o,r.parentNode,r));else if(a(o))e.push(o._render(r.parentNode,r));else if(null!=o&&!1!==o){let t=document.createTextNode(String(o));r.parentNode.insertBefore(t,r),e.push(()=>t.parentNode?.removeChild(t))}m=()=>e.forEach(e=>e())}else p=document.createTextNode(String(n)),r.parentNode.insertBefore(p,r)});c.push(()=>{if(E(),m&&=(m(),null),p&&=(p.parentNode?.removeChild(p),null),y){for(let e of y.values())e.cleanup();y=null,N=null}})}function _(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function v(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.lastIndexOf("=");if(-1===o)return{type:"node"};let l=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=o-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,o);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l}}return{type:"attr",attrName:a,hadOpenQuote:l}}var y={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},b=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),x=new Set;function S(e,t,n){let r=e.target,o=e.stopPropagation,l=!1;for(e.stopPropagation=()=>{l=!0,o.call(e)};r&&r!==document;){let o=r[t];if(o){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,o=!0;for(let e of t){let t=y[e];if(void 0!==t&&n.key!==t){o=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){o=!1;break}}if(!o){r=r.parentNode;continue}}}if(o(e),l)break}r=r.parentNode}e.stopPropagation=o}var C=new Map;function w(t,n,r,o){let l=[],i=[],a=Array(n.length),u=-1;for(let e=0;e<n.length;e++)o[e]&&o[e].nodeIndex>u&&(u=o[e].nodeIndex);let c=Array(u+1);if(c[0]=t,u>0){let e,n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=u&&(e=n.nextNode());)c[r++]=e}for(let e=0;e<n.length;e++){let t=o[e];a[e]=t?c[t.nodeIndex]:null}for(let t=0;t<n.length;t++){let u=n[t],c=r[t],s=o[t];if(!s)continue;let d=a[t];if("event"===u.type){let e=s.name,t=c,n=u.modifiers;if(!b.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};d.addEventListener(e,o,r),l.push(()=>d.removeEventListener(e,o,r))}else{if(!x.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>S(e,t,n);C.set(e,r),document.addEventListener(e,r),x.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;d[r]=t,n.length>0&&(d[o]=n),l.push(()=>{d[r]=null,d[o]=null})}continue}if("attr"===u.type){let t=s.name,n=d;if("ref"===t){c.el=n,l.push(()=>{c.el=null});continue}if("show"===t||"hide"===t){let r=n,o=null;if("function"==typeof c){let n=!1,i=!1,a=!0,u=e.effect(()=>{i=!!c();let e=()=>{n=!1;let e="show"===t?i:!i;null===o&&(o=r.style.display||""),r.style.display=e?o:"none"};a?(a=!1,e()):n||(n=!0,h(e))});l.push(u)}else("show"===t?c:!c)||(r.style.display="none");continue}let r=("value"===t||"checked"===t||"selected"===t)&&t in n;if("function"==typeof c){let o,i=!1,a=!0,u=e.effect(()=>{o=c();let e=()=>{i=!1;let e=o;r?n[t]=e??"":null==e||!1===e?n.removeAttribute(t):n.setAttribute(t,String(e))};a?(a=!1,e()):i||(i=!0,h(e))});l.push(u)}else r?n[t]=c??"":null!=c&&!1!==c&&n.setAttribute(t,String(c));continue}let f=d;if(!f)continue;let p=document.createTextNode("");f.parentNode.replaceChild(p,f),g(p,c,l,i)}return{disposes:l,postMountHooks:i}}function T(e,t){let n=new Uint8Array(e.length),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;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;r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}var E=new WeakMap;function D(e,...t){let n=E.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(v(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=T(e,t);let l,i=Array(t.length).fill(null),a=o.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),c=0;for(;l=u.nextNode();)if(c++,8===l.nodeType){let e=l.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:c})}}else if(1===l.nodeType){let e=l,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],o=r.name;if(o.startsWith("data-nix-e-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:c,name:r.value},e.removeAttribute(o));continue}if(o.startsWith("data-nix-a-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:c,name:r.value},e.removeAttribute(o))}}}n={contexts:t,tpl:o,pathMap:i},E.set(e,n)}let{contexts:r,tpl:o,pathMap:l}=n;function i(e,n){let i=o.content.cloneNode(!0),{disposes:a,postMountHooks:u}=w(i,r,t,l),c=document.createTextNode(""),s=document.createTextNode("");return e.insertBefore(c,n),e.insertBefore(i,n),e.insertBefore(s,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=c.nextSibling;for(;e&&e!==s;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}c.parentNode?.removeChild(c),s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function O(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 k(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function A(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(k(r.transitionDuration||"0"),k(r.animationDuration||"0")),l=o>0?o+100:t;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function j(n,r={}){let o=O(r);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(l,a){let u=document.createComment(i.TRANSITION);l.insertBefore(u,a);let s=null,d=null,f=0,p=!0,m=()=>{let e=u.nextSibling;for(;e&&e!==a;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function h(e){return t.isNixComponent(e)?c(e,l,a):e._render(l,a)}let y=(e,t=!1)=>{f++,d&&=(d(),null),s=h(e);let n=m();if(n&&(!p||r.appear)&&!t){let e=f;(async()=>{r.onBeforeEnter?.(n),n.classList.add(o.enterFrom,o.enterActive),n.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),f===e&&(n.classList.remove(o.enterFrom),n.classList.add(o.enterTo),await A(n,r.duration),f===e&&(n.classList.remove(o.enterActive,o.enterTo),r.onAfterEnter?.(n)))})().catch(()=>{})}p=!1},x=()=>{let e=s;s=null;let t=m();if(!t)return void e?.();let n=++f;d=e??null,(async()=>{r.onBeforeLeave?.(t),t.classList.add(o.leaveFrom,o.leaveActive),t.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),f===n&&(t.classList.remove(o.leaveFrom),t.classList.add(o.leaveTo),await A(t,r.duration),f===n&&(t.classList.remove(o.leaveActive,o.leaveTo),r.onAfterLeave?.(t),d?.(),d=null))})().catch(()=>{})},N=null;if("function"!=typeof n||t.isNixComponent(n))y(n);else{let t=n,r=null;N=e.effect(()=>{let e=t(),n=null===r,o=null===e;n&&!o?y(e):!n&&o?x():!n&&!o&&(f++,d?.(),d=null,s?.(),s=null,y(e,!0)),r=e}),p=!1}return()=>{f++,N?.(),s?.(),d?.(),s=null,d=null,u.remove()}}}}function M(){return{__isPortalOutlet:!0,_container:null}}function N(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 P(e,n=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(r,o){let l;return l="string"==typeof n?document.querySelector(n)??document.body:n instanceof Element?n:"__isPortalOutlet"in n?n._container??document.body:n.el??document.body,t.isNixComponent(e)?s(e,l,null):e._render(l,null)}}}var F=n.createInjectionKey("nix:portal-outlet");function I(e){n.provide(F,e)}function L(){return n.inject(F)}function R(r,o){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(l,a){let u=document.createComment(i.ERROR_BOUNDARY);l.insertBefore(u,a);let s,d=null,f=!1,p=!1,m=!1,h=e=>{let n=u.parentNode,r="function"!=typeof o||t.isNixComponent(o)?o:o(e);d=t.isNixComponent(r)?c(r,n,a):r._render(n,a)};e._pushErrorHandler(e=>{f||(f=!0,p?(d?.(),d=null,h(e)):(s=e,m=!0))});try{if(t.isNixComponent(r)){n._pushComponentContext();try{try{r.onInit?.()}catch(e){if(!r.onError)throw e;r.onError(e)}d=r.render()._render(l,a)}finally{n._popComponentContext()}if(!f)try{let e=r.onMount?.(),t=d;d=()=>{try{r.onUnmount?.()}catch{}if("function"==typeof e)try{e()}catch{}t?.()}}catch(e){if(!r.onError)throw e;r.onError(e)}}else d=r._render(l,a)}catch(e){f=!0,d?.(),d=null,s=e,m=!0}finally{e._popErrorHandler(),p=!0}return m&&(d?.(),d=null,h(s)),()=>{d?.(),u.remove()}}}}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return _}});
@@ -0,0 +1 @@
1
+ import{_popErrorHandler as e,_pushErrorHandler as t,batch as n,effect as r}from"./signals.js";import{isNixComponent as i}from"./lifecycle.js";import{_captureContextSnapshot as a,_popComponentContext as o,_pushComponentContext as s,_withComponentContext as c,createInjectionKey as l,inject as u,provide as d}from"./context.js";function f(){return{el:null}}var p={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function m(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function h(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function g(e,t,n){let r,l;s();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{o()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function _(e,t,n){let r,l;s();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{o()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function v(e,t,n,r){let o,l;c(r,()=>{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)});try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}o()}}function y(e,t,n,r,l){let i,a;s();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}i=e.render()._render(t,n)}finally{o()}r.push(()=>{try{let t=e.onMount?.();"function"==typeof t&&(a=t)}catch(t){if(!e.onError)throw t;e.onError(t)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{a?.()}catch{}i()})}function b(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function x(e){let t,n,r,o,l,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,o=a.length-1;r<o;)l=r+o>>1,e[a[l]]<u?r=l+1:o=l;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,o=a[r-1];r-- >0;)a[r]=o,o=i[o];return a}var S=new Set,C=!1;function w(e){S.add(e),C||(C=!0,queueMicrotask(()=>{for(let e of S)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}S.clear(),C=!1}))}function T(e,t,o,l){if("function"!=typeof t){if(i(t))y(t,e.parentNode,e,l,o);else if(m(t))o.push(t._render(e.parentNode,e));else if(Array.isArray(t))for(let n of t)i(n)?y(n,e.parentNode,e,l,o):m(n)?n._render(e.parentNode,e):null!=n&&!1!==n&&e.parentNode.insertBefore(document.createTextNode(String(n)),e);else null!=t&&!1!==t&&e.parentNode.insertBefore(document.createTextNode(String(t)),e);return}let u=null,s=null,c=null,d=[],f=null,p=a(),N=!1,_="",E=!0,T=r(()=>{let r=t();if("string"==typeof r||"number"==typeof r){_=String(r);let t=()=>{N=!1,s&&=(s(),null),u?u.nodeValue=_:(u=document.createTextNode(_),e.parentNode.insertBefore(u,e))};return void(E?(E=!1,t()):N||(N=!0,w(t)))}if(N=!1,E=!1,u&&=(u.parentNode?.removeChild(u),null),s&&=(s(),null),null!=r&&!1!==r)if(m(r))s=r._render(e.parentNode,e);else if(i(r))s=v(r,e.parentNode,e,p);else if(h(r)){c||(c=new Map,f=document.createTextNode(""),e.parentNode.insertBefore(f,e));let t=e.parentNode,o=r.items.map((e,t)=>r.keyFn(e,t)),l=new Set(o),a=!1;if(c.size>0)for(let e of c.keys())if(l.has(e)){a=!0;break}if(!a){if(c.size>0){let t=document.createRange();t.setStartAfter(f),t.setEndBefore(e),t.deleteContents();for(let e of c.values())e.cleanup();c.clear()}if(o.length>0){let l=document.createDocumentFragment();n(()=>{for(let e=0;e<o.length;e++){let t=o[e],n=r.items[e],a=document.createTextNode(""),u=document.createTextNode("");l.appendChild(a),l.appendChild(u);let s=r.renderFn(n,e),d=i(s)?v(s,l,u,p):s._render(l,u);c?.set(t,{start:a,end:u,cleanup:d})}}),t.insertBefore(l,e)}return void(d=o)}let u=new Map;for(let e=0;e<o.length;e++)u.set(o[e],e);let s=new Int32Array(o.length),m=!1,h=0;for(let e=0;e<d.length;e++){let t=d[e],n=u.get(t);if(void 0===n){let e=c.get(t);e.cleanup();let n=e.start;for(;n;){let t=n===e.end?null:n.nextSibling;if(n.parentNode?.removeChild(n),!t)break;n=t}c.delete(t)}else s[n]=e+1,n>=h?h=n:m=!0}let y=m?x(s):[],N=y.length-1,_=e;for(let e=o.length-1;e>=0;e--){let n=o[e];if(0===s[e]){let o=r.items[e],l=document.createTextNode(""),a=document.createTextNode(""),u=document.createDocumentFragment();u.appendChild(l),u.appendChild(a);let s=r.renderFn(o,e),d=i(s)?v(s,u,a,p):s._render(u,a);c.set(n,{start:l,end:a,cleanup:d}),t.insertBefore(u,_),_=l}else{let r=c.get(n);if(m)if(N<0||e!==y[N]){let e=r.start;for(;e;){let n=e===r.end?null:e.nextSibling;if(t.insertBefore(e,_),!n)break;e=n}}else N--;_=r.start}}d=o}else if(Array.isArray(r)){let t=[];for(let n of r)if(i(n))t.push(g(n,e.parentNode,e));else if(m(n))t.push(n._render(e.parentNode,e));else if(null!=n&&!1!==n){let r=document.createTextNode(String(n));e.parentNode.insertBefore(r,e),t.push(()=>r.parentNode?.removeChild(r))}s=()=>t.forEach(e=>e())}else u=document.createTextNode(String(r)),e.parentNode.insertBefore(u,e)});o.push(()=>{if(T(),s&&=(s(),null),u&&=(u.parentNode?.removeChild(u),null),c){for(let e of c.values())e.cleanup();c=null,f=null}})}function E(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function D(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.lastIndexOf("=");if(-1===o)return{type:"node"};let l=r.endsWith('"')||r.endsWith("'")||'"'===r[r.length-1]||"'"===r[r.length-1],i=o-1;for(;i>=0&&/\S/.test(r[i]);)i--;i++;let a=r.slice(i,o);if("@"===a[0]){let e=a.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l}}return{type:"attr",attrName:a,hadOpenQuote:l}}var O={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},k=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),A=new Set;function j(e,t,n){let r=e.target,o=e.stopPropagation,l=!1;for(e.stopPropagation=()=>{l=!0,o.call(e)};r&&r!==document;){let o=r[t];if(o){let t=r[n];if(t){if(t.includes("prevent")&&e.preventDefault(),t.includes("stop")&&e.stopPropagation(),t.includes("self")&&e.target!==r){r=r.parentNode;continue}if("key"in e){let n=e,o=!0;for(let e of t){let t=O[e];if(void 0!==t&&n.key!==t){o=!1;break}if(!t&&1===e.length&&n.key.toLowerCase()!==e){o=!1;break}}if(!o){r=r.parentNode;continue}}}if(o(e),l)break}r=r.parentNode}e.stopPropagation=o}var M=new Map;function N(e,t,n,o){let l=[],i=[],a=Array(t.length),u=-1;for(let e=0;e<t.length;e++)o[e]&&o[e].nodeIndex>u&&(u=o[e].nodeIndex);let s=Array(u+1);if(s[0]=e,u>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=1;for(;r<=u&&(t=n.nextNode());)s[r++]=t}for(let e=0;e<t.length;e++){let t=o[e];a[e]=t?s[t.nodeIndex]:null}for(let e=0;e<t.length;e++){let u=t[e],s=n[e],c=o[e];if(!c)continue;let d=a[e];if("event"===u.type){let e=c.name,t=s,n=u.modifiers;if(!k.has(e)||n.includes("capture")||n.includes("once")){let r={once:n.includes("once"),capture:n.includes("capture"),passive:n.includes("passive")},o=e=>{n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),(!n.includes("self")||e.target===e.currentTarget)&&t(e)};d.addEventListener(e,o,r),l.push(()=>d.removeEventListener(e,o,r))}else{if(!A.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>j(e,t,n);M.set(e,r),document.addEventListener(e,r),A.add(e)}let r=`__nix_${e}`,o=`__nix_${e}_mods`;d[r]=t,n.length>0&&(d[o]=n),l.push(()=>{d[r]=null,d[o]=null})}continue}if("attr"===u.type){let e=c.name,t=d;if("ref"===e){s.el=t,l.push(()=>{s.el=null});continue}if("show"===e||"hide"===e){let n=t,o=null;if("function"==typeof s){let t=!1,i=!1,a=!0,u=r(()=>{i=!!s();let r=()=>{t=!1;let r="show"===e?i:!i;null===o&&(o=n.style.display||""),n.style.display=r?o:"none"};a?(a=!1,r()):t||(t=!0,w(r))});l.push(u)}else("show"===e?s:!s)||(n.style.display="none");continue}let n=("value"===e||"checked"===e||"selected"===e)&&e in t;if("function"==typeof s){let o,i=!1,a=!0,u=r(()=>{o=s();let r=()=>{i=!1;let r=o;n?t[e]=r??"":null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,String(r))};a?(a=!1,r()):i||(i=!0,w(r))});l.push(u)}else n?t[e]=s??"":null!=s&&!1!==s&&t.setAttribute(e,String(s));continue}let f=d;if(!f)continue;let p=document.createTextNode("");f.parentNode.replaceChild(p,f),T(p,s,l,i)}return{disposes:l,postMountHooks:i}}function P(e,t){let n=new Uint8Array(e.length),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;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;r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}var F=new WeakMap;function I(e,...t){let n=F.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(D(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=P(e,t);let l,i=Array(t.length).fill(null),a=o.content,u=document.createTreeWalker(a,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;l=u.nextNode();)if(s++,8===l.nodeType){let e=l.nodeValue;if(e&&e.startsWith("nix-")){let t=parseInt(e.slice(4),10);isNaN(t)||(i[t]={nodeIndex:s})}}else if(1===l.nodeType){let e=l,t=Array.from(e.attributes);for(let n=0;n<t.length;n++){let r=t[n],o=r.name;if(o.startsWith("data-nix-e-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o));continue}if(o.startsWith("data-nix-a-")){let t=parseInt(o.slice(11),10);isNaN(t)||(i[t]={nodeIndex:s,name:r.value},e.removeAttribute(o))}}}n={contexts:t,tpl:o,pathMap:i},F.set(e,n)}let{contexts:r,tpl:o,pathMap:l}=n;function i(e,n){let i=o.content.cloneNode(!0),{disposes:a,postMountHooks:u}=N(i,r,t,l),s=document.createTextNode(""),c=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),e.insertBefore(c,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==c;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s),c.parentNode?.removeChild(c)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function L(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 R(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function z(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(R(r.transitionDuration||"0"),R(r.animationDuration||"0")),l=o>0?o+100:t;if(l<=0)return void n();let i,a=t=>{t.target===e&&(clearTimeout(i),e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n())};e.addEventListener("transitionend",a),e.addEventListener("animationend",a),i=setTimeout(()=>{e.removeEventListener("transitionend",a),e.removeEventListener("animationend",a),n()},l)})}function B(e,t={}){let n=L(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(o,l){let a=document.createComment(p.TRANSITION);o.insertBefore(a,l);let u=null,s=null,c=0,d=!0,f=()=>{let e=a.nextSibling;for(;e&&e!==l;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function m(e){return i(e)?_(e,o,l):e._render(o,l)}let h=(e,r=!1)=>{c++,s&&=(s(),null),u=m(e);let o=f();if(o&&(!d||t.appear)&&!r){let e=c;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),c===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await z(o,t.duration),c===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}d=!1},y=()=>{let e=u;u=null;let r=f();if(!r)return void e?.();let o=++c;s=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),c===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await z(r,t.duration),c===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),s?.(),s=null))})().catch(()=>{})},v=null;if("function"!=typeof e||i(e))h(e);else{let t=e,n=null;v=r(()=>{let e=t(),r=null===n,o=null===e;r&&!o?h(e):!r&&o?y():!r&&!o&&(c++,s?.(),s=null,u?.(),u=null,h(e,!0)),n=e}),d=!1}return()=>{c++,v?.(),u?.(),s?.(),u=null,s=null,a.remove()}}}}function V(){return{__isPortalOutlet:!0,_container:null}}function H(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 U(e,t=document.body){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let o;return o="string"==typeof t?document.querySelector(t)??document.body:t instanceof Element?t:"__isPortalOutlet"in t?t._container??document.body:t.el??document.body,i(e)?g(e,o,null):e._render(o,null)}}}var W=l("nix:portal-outlet");function G(e){d(W,e)}function K(){return u(W)}function q(n,r){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(l,a){let u=document.createComment(p.ERROR_BOUNDARY);l.insertBefore(u,a);let c,d=null,f=!1,m=!1,h=!1,y=e=>{let t=u.parentNode,n="function"!=typeof r||i(r)?r:r(e);d=i(n)?_(n,t,a):n._render(t,a)};t(e=>{f||(f=!0,m?(d?.(),d=null,y(e)):(c=e,h=!0))});try{if(i(n)){s();try{try{n.onInit?.()}catch(e){if(!n.onError)throw e;n.onError(e)}d=n.render()._render(l,a)}finally{o()}if(!f)try{let e=n.onMount?.(),t=d;d=()=>{try{n.onUnmount?.()}catch{}if("function"==typeof e)try{e()}catch{}t?.()}}catch(e){if(!n.onError)throw e;n.onError(e)}}else d=n._render(l,a)}catch(e){f=!0,d?.(),d=null,c=e,h=!0}finally{e(),m=!0}return h&&(d?.(),d=null,y(c)),()=>{d?.(),u.remove()}}}}export{H as a,P as c,b as d,p as f,f as h,U as i,I as l,m,V as n,G as o,h as p,K as r,B as s,q as t,E as u};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deijose/nix-js",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
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
  "author": "Deiver Vasquez",
@@ -22,14 +22,54 @@
22
22
  ],
23
23
  "exports": {
24
24
  ".": {
25
- "import": {
26
- "types": "./dist/lib/index.d.ts",
27
- "default": "./dist/lib/nix-js.js"
28
- },
29
- "require": {
30
- "types": "./dist/lib/index.d.ts",
31
- "default": "./dist/lib/nix-js.cjs"
32
- }
25
+ "types": "./dist/lib/index.d.ts",
26
+ "import": "./dist/lib/nix-js.js",
27
+ "require": "./dist/lib/nix-js.cjs"
28
+ },
29
+ "./signals": {
30
+ "types": "./dist/lib/nix/reactivity.d.ts",
31
+ "import": "./dist/lib/signals.js",
32
+ "require": "./dist/lib/signals.cjs"
33
+ },
34
+ "./router": {
35
+ "types": "./dist/lib/nix/router.d.ts",
36
+ "import": "./dist/lib/router.js",
37
+ "require": "./dist/lib/router.cjs"
38
+ },
39
+ "./form": {
40
+ "types": "./dist/lib/nix/form.d.ts",
41
+ "import": "./dist/lib/form.js",
42
+ "require": "./dist/lib/form.cjs"
43
+ },
44
+ "./store": {
45
+ "types": "./dist/lib/nix/store.d.ts",
46
+ "import": "./dist/lib/store.js",
47
+ "require": "./dist/lib/store.cjs"
48
+ },
49
+ "./async": {
50
+ "types": "./dist/lib/nix/async.d.ts",
51
+ "import": "./dist/lib/async.js",
52
+ "require": "./dist/lib/async.cjs"
53
+ },
54
+ "./template": {
55
+ "types": "./dist/lib/nix/template/index.d.ts",
56
+ "import": "./dist/lib/template.js",
57
+ "require": "./dist/lib/template.cjs"
58
+ },
59
+ "./component": {
60
+ "types": "./dist/lib/nix/component.d.ts",
61
+ "import": "./dist/lib/component.js",
62
+ "require": "./dist/lib/component.cjs"
63
+ },
64
+ "./context": {
65
+ "types": "./dist/lib/nix/context.d.ts",
66
+ "import": "./dist/lib/context.js",
67
+ "require": "./dist/lib/context.cjs"
68
+ },
69
+ "./lifecycle": {
70
+ "types": "./dist/lib/nix/lifecycle.d.ts",
71
+ "import": "./dist/lib/lifecycle.js",
72
+ "require": "./dist/lib/lifecycle.cjs"
33
73
  }
34
74
  },
35
75
  "main": "./dist/lib/nix-js.cjs",
@@ -48,7 +88,7 @@
48
88
  "dev": "vite",
49
89
  "build": "tsc && vite build",
50
90
  "preview": "vite preview",
51
- "build:lib": "vite build --config vite.lib.config.ts && tsc --project tsconfig.lib.json && terser dist/lib/nix-js.js -c -m -o dist/lib/nix-js.js && terser dist/lib/nix-js.cjs -c -m -o dist/lib/nix-js.cjs",
91
+ "build:lib": "vite build --config vite.lib.config.ts && tsc --project tsconfig.lib.json && find dist/lib -type f \\( -name \"*.js\" -o -name \"*.cjs\" \\) -exec terser \"{}\" -c -m -o \"{}\" \\;",
52
92
  "typecheck": "tsc --noEmit",
53
93
  "test": "vitest run",
54
94
  "coverage": "vitest run --coverage",