@deijose/nix-js 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -3
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/nix/component.d.ts +5 -1
- package/dist/lib/nix/index.d.ts +2 -1
- package/dist/lib/nix/router.d.ts +2 -0
- package/dist/lib/nix-js.cjs +7 -7
- package/dist/lib/nix-js.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ class Clock extends NixComponent {
|
|
|
66
66
|
|
|
67
67
|
// --- Router ---
|
|
68
68
|
|
|
69
|
-
createRouter([
|
|
69
|
+
const router = createRouter([
|
|
70
70
|
{ path: "/", component: () => HomePage() },
|
|
71
71
|
{ path: "/user/:id", component: () => UserPage() },
|
|
72
72
|
]);
|
|
@@ -81,9 +81,28 @@ function App(): NixTemplate {
|
|
|
81
81
|
`;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
mount(App(), "#app");
|
|
84
|
+
mount(App(), "#app", { router });
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
+
## Router DI at Mount Root
|
|
88
|
+
|
|
89
|
+
You can provide a router instance per mounted app tree:
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
const routerA = createRouter(routesA);
|
|
93
|
+
const routerB = createRouter(routesB);
|
|
94
|
+
|
|
95
|
+
mount(AppA(), "#app-a", { router: routerA });
|
|
96
|
+
mount(AppB(), "#app-b", { router: routerB });
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`useRouter()` now resolves in this order:
|
|
100
|
+
|
|
101
|
+
1. injected router from context (`mount(..., { router })`)
|
|
102
|
+
2. singleton fallback (legacy `createRouter(...)` behavior)
|
|
103
|
+
|
|
104
|
+
This enables isolated router instances for testing and micro-frontend scenarios while keeping backward compatibility.
|
|
105
|
+
|
|
87
106
|
## What's Included
|
|
88
107
|
|
|
89
108
|
Everything ships in a single zero-dependency import:
|
|
@@ -93,7 +112,7 @@ Everything ships in a single zero-dependency import:
|
|
|
93
112
|
| **Reactivity** | `signal`, `computed`, `effect`, `batch`, `watch`, `untrack`, `nextTick` |
|
|
94
113
|
| **Templates** | `` html` ` ``, `repeat`, `ref`, `portal`, `transition`, `showWhen` |
|
|
95
114
|
| **Components** | `NixTemplate` (function components), `NixComponent` (lifecycle class), `mount`, children & named slots |
|
|
96
|
-
| **Router** | `createRouter`, `RouterView`, `Link`, `useRouter`, guards, nested routes |
|
|
115
|
+
| **Router** | `createRouter`, `RouterView`, `Link`, `useRouter`, `RouterKey`, guards, nested routes, `mount(..., { router })` |
|
|
97
116
|
| **Forms** | `useField`, `createForm`, built-in validators, Zod/Valibot interop |
|
|
98
117
|
| **State** | `createStore`, `provide`, `inject`, `createInjectionKey` |
|
|
99
118
|
| **Async** | `suspend` (with `invalidate` for re-fetching), `lazy` |
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Signal, signal, effect, computed, batch, watch, untrack, nextTick, html, repeat, ref, showWhen, portal, createPortalOutlet, portalOutlet, provideOutlet, injectOutlet, createErrorBoundary, transition, mount, NixComponent, createStore, createRouter, RouterView, Link, useRouter, suspend, lazy, provide, inject, createInjectionKey, useField, useFieldArray, createForm, required, minLength, maxLength, email, pattern, min, max, createValidator, validators, extendValidators, } from "./nix";
|
|
2
|
-
export type { WatchOptions, NixTemplate, NixMountHandle, KeyedList, NixRef, PortalOutlet, ErrorFallback, TransitionOptions, TransitionContent, Store, StoreSignals, Router, RouteRecord, RouterOptions, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute, ScrollPosition, ScrollBehavior, RouterMode, SuspenseOptions, InjectionKey, Validator, ValidateOn, FieldState, FieldArrayState, FieldErrors, FormState, FormOptions, ValidatorsBase, NixChildren, } from "./nix";
|
|
1
|
+
export { Signal, signal, effect, computed, batch, watch, untrack, nextTick, html, repeat, ref, showWhen, portal, createPortalOutlet, portalOutlet, provideOutlet, injectOutlet, createErrorBoundary, transition, mount, NixComponent, createStore, createRouter, RouterView, Link, useRouter, RouterKey, suspend, lazy, provide, inject, createInjectionKey, useField, useFieldArray, createForm, required, minLength, maxLength, email, pattern, min, max, createValidator, validators, extendValidators, } from "./nix";
|
|
2
|
+
export type { WatchOptions, NixTemplate, NixMountHandle, MountOptions, KeyedList, NixRef, PortalOutlet, ErrorFallback, TransitionOptions, TransitionContent, Store, StoreSignals, Router, RouteRecord, RouterOptions, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute, ScrollPosition, ScrollBehavior, RouterMode, SuspenseOptions, InjectionKey, Validator, ValidateOn, FieldState, FieldArrayState, FieldErrors, FormState, FormOptions, ValidatorsBase, NixChildren, } from "./nix";
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { NixTemplate, NixMountHandle } from "./template";
|
|
2
2
|
import { type NixComponent } from "./lifecycle";
|
|
3
|
+
import { type Router } from "./router";
|
|
4
|
+
export interface MountOptions {
|
|
5
|
+
router?: Router;
|
|
6
|
+
}
|
|
3
7
|
/**
|
|
4
8
|
* Mounts a NixTemplate or NixComponent into the DOM.
|
|
5
9
|
*
|
|
@@ -10,4 +14,4 @@ import { type NixComponent } from "./lifecycle";
|
|
|
10
14
|
* @param container CSS selector or HTMLElement to mount into.
|
|
11
15
|
* @returns { unmount() } — disposes effects and removes DOM.
|
|
12
16
|
*/
|
|
13
|
-
export declare function mount(component: NixTemplate | NixComponent, container: Element | string): NixMountHandle;
|
|
17
|
+
export declare function mount(component: NixTemplate | NixComponent, container: Element | string, options?: MountOptions): NixMountHandle;
|
package/dist/lib/nix/index.d.ts
CHANGED
|
@@ -3,11 +3,12 @@ export type { WatchOptions } from "./reactivity";
|
|
|
3
3
|
export { html, repeat, ref, showWhen, portal, createPortalOutlet, portalOutlet, provideOutlet, injectOutlet, createErrorBoundary, transition } from "./template";
|
|
4
4
|
export type { NixTemplate, NixMountHandle, KeyedList, NixRef, PortalOutlet, ErrorFallback, TransitionOptions, TransitionContent } from "./template";
|
|
5
5
|
export { mount } from "./component";
|
|
6
|
+
export type { MountOptions } from "./component";
|
|
6
7
|
export { NixComponent } from "./lifecycle";
|
|
7
8
|
export type { NixChildren } from "./lifecycle";
|
|
8
9
|
export { createStore } from "./store";
|
|
9
10
|
export type { Store, StoreSignals } from "./store";
|
|
10
|
-
export { createRouter, RouterView, Link, useRouter } from "./router";
|
|
11
|
+
export { createRouter, RouterView, Link, useRouter, RouterKey } from "./router";
|
|
11
12
|
export type { Router, RouteRecord, RouterOptions, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute, ScrollPosition, ScrollBehavior, RouterMode, } from "./router";
|
|
12
13
|
export { suspend, lazy } from "./async";
|
|
13
14
|
export type { SuspenseOptions } from "./async";
|
package/dist/lib/nix/router.d.ts
CHANGED
|
@@ -110,6 +110,8 @@ export interface Router {
|
|
|
110
110
|
/** Register a hook that runs after every successful navigation. Returns a removal function. */
|
|
111
111
|
afterEach(hook: AfterEachHook): () => void;
|
|
112
112
|
}
|
|
113
|
+
/** DI key for router instances. Useful to mount multiple app trees with isolated routers. */
|
|
114
|
+
export declare const RouterKey: import("./context").InjectionKey<Router>;
|
|
113
115
|
/**
|
|
114
116
|
* Creates the History API router and sets it as the active singleton.
|
|
115
117
|
* In production the server must serve `index.html` for all non-file routes.
|
package/dist/lib/nix-js.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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,a=!1,u=new Set,s=new Set,c=i,p=()=>{if(a)return;"function"==typeof l&&l();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 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 u)s.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof l&&l();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,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,a=!0,u=!1,s=_(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;b(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,b(()=>t(n,o)),l&&(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 ee(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var E=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 D(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function O(e){return Symbol(e)}var k=[];function A(){return[...k]}function j(){k.push(new Map)}function M(){k.pop()}function N(e,t){let n=k.splice(0);e.forEach(e=>k.push(e)),k.push(new Map);try{return t()}finally{k.splice(0),n.forEach(e=>k.push(e))}}function P(e,t){let n=k[k.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=k.length-1;t>=0;t--)if(k[t].has(e))return k[t].get(e);return t}function I(e,t,n){let r,o;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{M()}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;j();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{M()}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;N(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;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{M()}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(),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 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(D(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)D(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,a=[],u=null,s=A(),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(D(n))l=R(n,e.parentNode,e,s);else if(ee(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)),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(u),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],a=document.createTextNode(""),u=document.createTextNode("");o.appendChild(a),o.appendChild(u);let c=n.renderFn(l,e),f=D(c)?R(c,o,u,s):c._render(o,u);i?.set(t,{start:a,end:u,cleanup:f})}}),t.insertBefore(o,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 o=r[e];if(0===f[e]){let r=n.items[e],l=document.createTextNode(""),a=document.createTextNode(""),u=document.createDocumentFragment();u.appendChild(l),u.appendChild(a);let c=n.renderFn(r,e),f=D(c)?R(c,u,a,s):c._render(u,a);i.set(o,{start:l,end:a,cleanup:f}),t.insertBefore(u,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}}a=r}else if(Array.isArray(n)){let t=[];for(let r of n)if(D(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,u=null}})}function ie(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ae(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 oe={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},se=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),ce=new Set;function le(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=oe[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 ue=new Map;function de(e,t,n,r){let o=[],l=[],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(!se.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(!ce.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>le(e,t,n);ue.set(e,r),document.addEventListener(e,r),ce.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"===a.type){let e=s.name,t=c;if("ref"===e){u.el=t,o.push(()=>{u.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof u){let t=!1,l=!1,i=!0,a=_(()=>{l=!!u();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(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,l=!1,i=!0,a=_(()=>{r=u();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(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,o,l)}return{disposes:o,postMountHooks:l}}function fe(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 pe=new WeakMap;function U(e,...t){let n=pe.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ae(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=fe(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},pe.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}=de(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 me(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function he(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function ge(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(he(r.transitionDuration||"0"),he(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 _e(e,t={}){let n=me(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,o){let l=document.createComment(w.TRANSITION);r.insertBefore(l,o);let i=null,a=null,u=0,s=!0,c=()=>{let e=l.nextSibling;for(;e&&e!==o;){if(e.nodeType===Node.ELEMENT_NODE)return e;e=e.nextSibling}return null};function f(e){return D(e)?L(e,r,o):e._render(r,o)}let d=(e,r=!1)=>{u++,a&&=(a(),null),i=f(e);let o=c();if(o&&(!s||t.appear)&&!r){let e=u;(async()=>{t.onBeforeEnter?.(o),o.classList.add(n.enterFrom,n.enterActive),o.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===e&&(o.classList.remove(n.enterFrom),o.classList.add(n.enterTo),await ge(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await ge(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||D(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&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function ve(){return{__isPortalOutlet:!0,_container:null}}function ye(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 be(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,D(e)?I(e,o,null):e._render(o,null)}}}var xe=O("nix:portal-outlet");function Se(e){P(xe,e)}function Ce(){return F(xe)}function we(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||D(t)?t:t(e);a=D(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(D(e)){j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{M()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function Te(e,t){if(D(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{M()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Ee(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}var W=null,G=null,De="__nix_scroll";function K(){if(!W)throw Error("[Nix] No active router. Call createRouter() first.");return W}function q(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function Oe(e){if(!e||"object"!=typeof e)return null;let t=e[De];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 J(e,t){let n=e&&"object"==typeof e?{...e}:{};return n[De]={left:t.left,top:t.top},n}function Y(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function ke(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let o of e){let e=je(t,o.path),l=[...n,o.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:l,meta:o.meta,beforeEnter:o.beforeEnter,record:o}),o.children?.length&&r.push(...Me(o.children,e,l))}return r}function Ne(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 Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function X(e,t){let n,r={},o=-1;for(let l of t){let t=Ne(e,l);if(null===t)continue;let i=Pe(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function Z(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Fe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return Z(new URL(t,window.location.origin).pathname)}catch{return Z(t)}}function Ie(e,t){let n=null==t?.base?Fe():Z(t.base),r=t?.mode??"history",o="hash"===r,l=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 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)+ke(t);return o?"#"+n:n}function p(e,t){return u(e)+ke(t)}let h=f(),m=h.pathname,v=Y(h.search),y=Me(e),x=X(m,y),_=g(m),b=g(x?.params??{}),w=g(v);function N(e){window.scrollTo(e.left,e.top)}function E(e,t,n){if(l){let r=l(e,t,n);if(!1===r||null==r)return;return void N(r)}N(n??{left:0,top:0})}o?i.set(p(m,v),q()):history.replaceState(J(history.state,q()),"");let k=[],S=[],O=0;function T(e,t,n,r,o){let l=[...k];n&&l.push(n);let i=++O;if(0===l.length)return void r();let a=0;!function n(u){if(i!==O)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():D(u));if(a>=l.length)return void r();let s=l[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let A=!1;function $(e,t){let n=e.indexOf("?"),r=u((-1===n?e:e.slice(0,n))||"/"),o=-1===n?{}:Y(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}}G&&=(G(),null);let M=(e,t,n,r)=>{let o=_.value,l={...w.value},i=X(e,y);T(e,o,i?.route.beforeEnter,()=>{b.value=i?.params??{},w.value=t,_.value=e,E(e,o,n);for(let t of S)try{t(e,o)}catch{}},()=>r(o,l))};if(o){let e=()=>{if(a)return void(a=!1);let e=f(),t=Y(e.search),n=i.get(p(e.pathname,t))??null;M(e.pathname,t,n,(e,t)=>{a=!0,window.location.hash=d(e,t).slice(1),queueMicrotask(()=>{a=!1})})};window.addEventListener("hashchange",e),G=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=f(),n=Y(t.search),r=Oe(e.state??history.state);M(t.pathname,n,r,(e,t)=>{history.pushState(J({},q()),"",d(e,t))})};window.addEventListener("popstate",e),G=()=>window.removeEventListener("popstate",e)}function L(e,t,n,r,l,u){u||function(e,t){let n=q();o?i.set(p(e,t),n):history.replaceState(J(history.state,n),"")}(n,r),b.value=l?.params??{},w.value=t,_.value=e;let s=d(e,t);if(o)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=J({},{left:0,top:0});u?history.replaceState(e,"",s):history.pushState(e,"",s)}E(e,n,null);for(let t of S)try{t(e,n)}catch{}}function D(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),o=_.value,l={...w.value},i=X(n,y);T(n,o,i?.route.beforeEnter,()=>L(n,r,o,l,i,!1))}let I={current:_,params:b,query:w,base:n||"/",navigate:D,replace:function(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),o=_.value,l={...w.value},i=X(n,y);T(n,o,i?.route.beforeEnter,()=>L(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=_.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=X(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 S.push(e),()=>{let t=S.indexOf(e);-1!==t&&S.splice(t,1)}},routes:e,_flat:y,_guards:k,_base:n,_mode:r};return W&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),W=I,queueMicrotask(()=>{A||T(m,"",X(m,y)?.route.beforeEnter,()=>{},()=>{let e=d("/",{});o?(i.set(p("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(J({},{left:0,top:0}),"",e);let t=X("/",y);_.value="/",b.value=t?.params??{},w.value={},E("/",m,null)})}),I}function Le(){return K()}var Re=class extends E{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return U`<div class="router-view">${()=>{let t=K(),n=X(t.current.value,t._flat);return n?e>=n.route.chain.length?U`<span></span>`:n.route.chain[e]():U`<div style="color:#f87171;padding:16px 0">
|
|
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 ee(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var E=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 D(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function O(e){return Symbol(e)}var k=[];function A(){return[...k]}function j(){k.push(new Map)}function M(){k.pop()}function N(e,t){let n=k.splice(0);e.forEach(e=>k.push(e)),k.push(new Map);try{return t()}finally{k.splice(0),n.forEach(e=>k.push(e))}}function P(e,t){let n=k[k.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=k.length-1;t>=0;t--)if(k[t].has(e))return k[t].get(e);return t}function I(e,t,n){let r,o;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{M()}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;j();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{M()}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;N(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 te(e,t,n,r,o){let l,i;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{M()}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 ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(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 z=new Set,B=!1;function V(e){z.add(e),B||(B=!0,queueMicrotask(()=>{for(let e of z)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}z.clear(),B=!1}))}function ie(e,t,n,r){if("function"!=typeof t){if(D(t))te(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)D(o)?te(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=A(),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,V(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(D(n))l=R(n,e.parentNode,e,s);else if(ee(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=D(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?re(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=D(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(D(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 ae(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function oe(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 se={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ce=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),le=new Set;function ue(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=se[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 de=new Map;function fe(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(!ce.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(!le.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>ue(e,t,n);de.set(e,r),document.addEventListener(e,r),le.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,V(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,V(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),ie(d,a,o,l)}return{disposes:o,postMountHooks:l}}function pe(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 me=new WeakMap;function H(e,...t){let n=me.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(oe(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=pe(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},me.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}=fe(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 he(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 ge(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function _e(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(ge(r.transitionDuration||"0"),ge(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 ve(e,t={}){let n=he(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 D(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 _e(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 _e(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||D(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 ye(){return{__isPortalOutlet:!0,_container:null}}function be(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 xe(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,D(e)?I(e,o,null):e._render(o,null)}}}var Se=O("nix:portal-outlet");function Ce(e){P(Se,e)}function we(){return F(Se)}function Te(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||D(t)?t:t(e);u=D(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(D(e)){j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{M()}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 U=O("nix:router"),W=null,G=null,Ee="__nix_scroll";function De(){if(!W)throw Error("[Nix] No active router. Call createRouter() first.");return W}function K(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function Oe(e){if(!e||"object"!=typeof e)return null;let t=e[Ee];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 q(e,t){let n=e&&"object"==typeof e?{...e}:{};return n[Ee]={left:t.left,top:t.top},n}function J(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function ke(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let o of e){let e=je(t,o.path),l=[...n,o.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:l,meta:o.meta,beforeEnter:o.beforeEnter,record:o}),o.children?.length&&r.push(...Me(o.children,e,l))}return r}function Ne(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 Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function Y(e,t){let n,r={},o=-1;for(let l of t){let t=Ne(e,l);if(null===t)continue;let i=Pe(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}: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 Fe(){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 Ie(e,t){let n=null==t?.base?Fe():X(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)+ke(t);return o?"#"+n:n}function p(e,t){return a(e)+ke(t)}let h=f(),m=h.pathname,v=J(h.search),y=Me(e),x=Y(m,y),_=g(m),b=g(x?.params??{}),w=g(v);function N(e){window.scrollTo(e.left,e.top)}function E(e,t,n){if(l){let r=l(e,t,n);if(!1===r||null==r)return;return void N(r)}N(n??{left:0,top:0})}o?i.set(p(m,v),K()):history.replaceState(q(history.state,K()),"");let k=[],S=[],O=0;function T(e,t,n,r,o){let l=[...k];n&&l.push(n);let i=++O;if(0===l.length)return void r();let u=0;!function n(a){if(i!==O)return;if(!1===a)return void o?.();if("string"==typeof a)return void(a===e?r():D(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 A=!1;function $(e,t){let n=e.indexOf("?"),r=a((-1===n?e:e.slice(0,n))||"/"),o=-1===n?{}:J(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}}G&&=(G(),null);let M=(e,t,n,r)=>{let o=_.value,l={...w.value},i=Y(e,y);T(e,o,i?.route.beforeEnter,()=>{b.value=i?.params??{},w.value=t,_.value=e,E(e,o,n);for(let t of S)try{t(e,o)}catch{}},()=>r(o,l))};if(o){let e=()=>{if(u)return void(u=!1);let e=f(),t=J(e.search),n=i.get(p(e.pathname,t))??null;M(e.pathname,t,n,(e,t)=>{u=!0,window.location.hash=d(e,t).slice(1),queueMicrotask(()=>{u=!1})})};window.addEventListener("hashchange",e),G=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=f(),n=J(t.search),r=Oe(e.state??history.state);M(t.pathname,n,r,(e,t)=>{history.pushState(q({},K()),"",d(e,t))})};window.addEventListener("popstate",e),G=()=>window.removeEventListener("popstate",e)}function L(e,t,n,r,l,a){a||function(e,t){let n=K();o?i.set(p(e,t),n):history.replaceState(q(history.state,n),"")}(n,r),b.value=l?.params??{},w.value=t,_.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=q({},{left:0,top:0});a?history.replaceState(e,"",s):history.pushState(e,"",s)}E(e,n,null);for(let t of S)try{t(e,n)}catch{}}function D(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),o=_.value,l={...w.value},i=Y(n,y);T(n,o,i?.route.beforeEnter,()=>L(n,r,o,l,i,!1))}let j={current:_,params:b,query:w,base:n||"/",navigate:D,replace:function(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),o=_.value,l={...w.value},i=Y(n,y);T(n,o,i?.route.beforeEnter,()=>L(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=_.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=Y(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 S.push(e),()=>{let t=S.indexOf(e);-1!==t&&S.splice(t,1)}},routes:e,_flat:y,_guards:k,_base:n,_mode:r};return W&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),W=j,queueMicrotask(()=>{A||T(m,"",Y(m,y)?.route.beforeEnter,()=>{},()=>{let e=d("/",{});o?(i.set(p("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(q({},{left:0,top:0}),"",e);let t=Y("/",y);_.value="/",b.value=t?.params??{},w.value={},E("/",m,null)})}),j}function Z(){return F(U)||De()}var Le=class extends E{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return H`<div class="router-view">${()=>{let t=Z(),n=Y(t.current.value,t._flat);return n?e>=n.route.chain.length?H`<span></span>`:n.route.chain[e]():H`<div style="color:#f87171;padding:16px 0">
|
|
2
2
|
404 — Route not found: <strong>${t.current.value}</strong>
|
|
3
|
-
</div>`}}</div>`}},
|
|
3
|
+
</div>`}}</div>`}},Re=class extends E{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label,n=Z(),r=e.startsWith("/")?e:"/"+e,o=(n._base?n._base+r:r).replace(/\/+/g,"/");return H`<a
|
|
4
4
|
href=${"hash"===n._mode?"#"+o:o}
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function Be(){return U`
|
|
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(D(e)){let r,o,l=ze(t);j();try{n?.router&&P(U,n.router);try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(l,null)}finally{M()}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);j();try{P(U,n.router),r=e._render(o,null)}finally{M()}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 H`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],t=[]
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function Ue(e){return H`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var Q=new Map,
|
|
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 E{_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 H`<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=E,exports.RouterKey=U,exports.RouterView=Le,exports.Signal=h,exports.batch=y,exports.computed=v,exports.createErrorBoundary=Te,exports.createForm=ht,exports.createInjectionKey=O,exports.createPortalOutlet=ye,exports.createRouter=Ie,exports.createStore=Ve,exports.createValidator=st,exports.effect=_,exports.email=it,exports.extendValidators=lt,exports.html=H,exports.inject=F,exports.injectOutlet=we,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=xe,exports.portalOutlet=be,exports.provide=P,exports.provideOutlet=Ce,exports.ref=C,exports.repeat=ne,exports.required=et,exports.showWhen=ae,exports.signal=g,exports.suspend=Qe,exports.transition=ve,exports.untrack=b,exports.useField=ut,exports.useFieldArray=dt,exports.useRouter=Z,exports.validators=ct,exports.watch=x;
|
package/dist/lib/nix-js.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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 ee(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var E=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 D(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function O(e){return Symbol(e)}var k=[];function A(){return[...k]}function j(){k.push(new Map)}function M(){k.pop()}function N(e,t){let n=k.splice(0);e.forEach(e=>k.push(e)),k.push(new Map);try{return t()}finally{k.splice(0),n.forEach(e=>k.push(e))}}function P(e,t){let n=k[k.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=k.length-1;t>=0;t--)if(k[t].has(e))return k[t].get(e);return t}function I(e,t,n){let r,l;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{M()}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;j();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{M()}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;N(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;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{M()}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(D(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)D(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=A(),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(D(n))o=R(n,e.parentNode,e,s);else if(ee(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=D(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=D(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(D(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 ie(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ae(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 oe={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},se=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),ce=new Set;function le(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=oe[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 ue=new Map;function de(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(!se.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(!ce.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>le(e,t,n);ue.set(e,r),document.addEventListener(e,r),ce.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 fe(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 pe=new WeakMap;function U(e,...t){let n=pe.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ae(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=fe(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},pe.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}=de(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 me(e){let t=e.name??"nix";return{enterFrom:e.enterFrom??`${t}-enter-from`,enterActive:e.enterActive??`${t}-enter-active`,enterTo:e.enterTo??`${t}-enter-to`,leaveFrom:e.leaveFrom??`${t}-leave-from`,leaveActive:e.leaveActive??`${t}-leave-active`,leaveTo:e.leaveTo??`${t}-leave-to`}}function he(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function ge(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(he(r.transitionDuration||"0"),he(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 _e(e,t={}){let n=me(t);return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(r,l){let o=document.createComment(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 D(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 ge(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 ge(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||D(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 ve(){return{__isPortalOutlet:!0,_container:null}}function ye(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 be(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,D(e)?I(e,l,null):e._render(l,null)}}}var xe=O("nix:portal-outlet");function Se(e){P(xe,e)}function Ce(){return F(xe)}function we(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||D(t)?t:t(e);a=D(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(D(e)){j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{M()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function Te(e,t){if(D(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{M()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function Ee(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}var W=null,G=null,De="__nix_scroll";function K(){if(!W)throw Error("[Nix] No active router. Call createRouter() first.");return W}function q(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function Oe(e){if(!e||"object"!=typeof e)return null;let t=e[De];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 J(e,t){let n=e&&"object"==typeof e?{...e}:{};return n[De]={left:t.left,top:t.top},n}function Y(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function ke(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,meta:l.meta,beforeEnter:l.beforeEnter,record:l}),l.children?.length&&r.push(...Me(l.children,e,o))}return r}function Ne(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 Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function X(e,t){let n,r={},l=-1;for(let o of t){let t=Ne(e,o);if(null===t)continue;let i=Pe(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function Z(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Fe(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return Z(new URL(t,window.location.origin).pathname)}catch{return Z(t)}}function Ie(e,t){let n=null==t?.base?Fe():Z(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)+ke(t);return l?"#"+n:n}function p(e,t){return u(e)+ke(t)}let h=f(),m=h.pathname,v=Y(h.search),y=Me(e),_=X(m,y),b=g(m),x=g(_?.params??{}),w=g(v);function N(e){window.scrollTo(e.left,e.top)}function E(e,t,n){if(o){let r=o(e,t,n);if(!1===r||null==r)return;return void N(r)}N(n??{left:0,top:0})}l?i.set(p(m,v),q()):history.replaceState(J(history.state,q()),"");let k=[],S=[],O=0;function T(e,t,n,r,l){let o=[...k];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():D(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 A=!1;function $(e,t){let n=e.indexOf("?"),r=u((-1===n?e:e.slice(0,n))||"/"),l=-1===n?{}:Y(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}}G&&=(G(),null);let M=(e,t,n,r)=>{let l=b.value,o={...w.value},i=X(e,y);T(e,l,i?.route.beforeEnter,()=>{x.value=i?.params??{},w.value=t,b.value=e,E(e,l,n);for(let t of S)try{t(e,l)}catch{}},()=>r(l,o))};if(l){let e=()=>{if(a)return void(a=!1);let e=f(),t=Y(e.search),n=i.get(p(e.pathname,t))??null;M(e.pathname,t,n,(e,t)=>{a=!0,window.location.hash=d(e,t).slice(1),queueMicrotask(()=>{a=!1})})};window.addEventListener("hashchange",e),G=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=f(),n=Y(t.search),r=Oe(e.state??history.state);M(t.pathname,n,r,(e,t)=>{history.pushState(J({},q()),"",d(e,t))})};window.addEventListener("popstate",e),G=()=>window.removeEventListener("popstate",e)}function L(e,t,n,r,o,u){u||function(e,t){let n=q();l?i.set(p(e,t),n):history.replaceState(J(history.state,n),"")}(n,r),x.value=o?.params??{},w.value=t,b.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=J({},{left:0,top:0});u?history.replaceState(e,"",s):history.pushState(e,"",s)}E(e,n,null);for(let t of S)try{t(e,n)}catch{}}function D(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),l=b.value,o={...w.value},i=X(n,y);T(n,l,i?.route.beforeEnter,()=>L(n,r,l,o,i,!1))}let I={current:b,params:x,query:w,base:n||"/",navigate:D,replace:function(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),l=b.value,o={...w.value},i=X(n,y);T(n,l,i?.route.beforeEnter,()=>L(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=b.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=X(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 S.push(e),()=>{let t=S.indexOf(e);-1!==t&&S.splice(t,1)}},routes:e,_flat:y,_guards:k,_base:n,_mode:r};return W&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),W=I,queueMicrotask(()=>{A||T(m,"",X(m,y)?.route.beforeEnter,()=>{},()=>{let e=d("/",{});l?(i.set(p("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(J({},{left:0,top:0}),"",e);let t=X("/",y);b.value="/",x.value=t?.params??{},w.value={},E("/",m,null)})}),I}function Le(){return K()}var Re=class extends E{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return U`<div class="router-view">${()=>{let t=K(),n=X(t.current.value,t._flat);return n?e>=n.route.chain.length?U`<span></span>`:n.route.chain[e]():U`<div style="color:#f87171;padding:16px 0">
|
|
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 ee(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var E=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 D(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function O(e){return Symbol(e)}var k=[];function A(){return[...k]}function j(){k.push(new Map)}function M(){k.pop()}function N(e,t){let n=k.splice(0);e.forEach(e=>k.push(e)),k.push(new Map);try{return t()}finally{k.splice(0),n.forEach(e=>k.push(e))}}function P(e,t){let n=k[k.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=k.length-1;t>=0;t--)if(k[t].has(e))return k[t].get(e);return t}function I(e,t,n){let r,l;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{M()}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;j();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{M()}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;N(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 te(e,t,n,r,l){let o,i;j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{M()}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 ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(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 z=new Set,B=!1;function V(e){z.add(e),B||(B=!0,queueMicrotask(()=>{for(let e of z)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}z.clear(),B=!1}))}function ie(e,t,n,r){if("function"!=typeof t){if(D(t))te(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)D(l)?te(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=A(),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,V(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(D(n))o=R(n,e.parentNode,e,s);else if(ee(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=D(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?re(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=D(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(D(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 ae(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function oe(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 se={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ce=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),le=new Set;function ue(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=se[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 de=new Map;function fe(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(!ce.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(!le.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>ue(e,t,n);de.set(e,r),document.addEventListener(e,r),le.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,V(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,V(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),ie(d,u,l,o)}return{disposes:l,postMountHooks:o}}function pe(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 me=new WeakMap;function H(e,...t){let n=me.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(oe(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=pe(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},me.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}=fe(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 he(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 ge(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function _e(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(ge(r.transitionDuration||"0"),ge(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 ve(e,t={}){let n=he(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 D(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 _e(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 _e(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||D(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 ye(){return{__isPortalOutlet:!0,_container:null}}function be(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 xe(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,D(e)?I(e,l,null):e._render(l,null)}}}var Se=O("nix:portal-outlet");function Ce(e){P(Se,e)}function we(){return F(Se)}function Te(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||D(t)?t:t(e);a=D(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(D(e)){j();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{M()}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 U=O("nix:router"),W=null,G=null,Ee="__nix_scroll";function De(){if(!W)throw Error("[Nix] No active router. Call createRouter() first.");return W}function K(){return{left:window.scrollX??window.pageXOffset??0,top:window.scrollY??window.pageYOffset??0}}function Oe(e){if(!e||"object"!=typeof e)return null;let t=e[Ee];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 q(e,t){let n=e&&"object"==typeof e?{...e}:{};return n[Ee]={left:t.left,top:t.top},n}function J(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function ke(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 Ae(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 je(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Me(e,t="",n=[]){let r=[];for(let l of e){let e=je(t,l.path),o=[...n,l.component],i=Ae(e);r.push({fullPath:e,segments:i,chain:o,meta:l.meta,beforeEnter:l.beforeEnter,record:l}),l.children?.length&&r.push(...Me(l.children,e,o))}return r}function Ne(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 Pe(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function Y(e,t){let n,r={},l=-1;for(let o of t){let t=Ne(e,o);if(null===t)continue;let i=Pe(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}: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 Fe(){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 Ie(e,t){let n=null==t?.base?Fe():X(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)+ke(t);return l?"#"+n:n}function p(e,t){return u(e)+ke(t)}let h=f(),m=h.pathname,v=J(h.search),y=Me(e),_=Y(m,y),b=g(m),x=g(_?.params??{}),w=g(v);function N(e){window.scrollTo(e.left,e.top)}function E(e,t,n){if(o){let r=o(e,t,n);if(!1===r||null==r)return;return void N(r)}N(n??{left:0,top:0})}l?i.set(p(m,v),K()):history.replaceState(q(history.state,K()),"");let k=[],S=[],O=0;function T(e,t,n,r,l){let o=[...k];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():D(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 A=!1;function $(e,t){let n=e.indexOf("?"),r=u((-1===n?e:e.slice(0,n))||"/"),l=-1===n?{}:J(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}}G&&=(G(),null);let M=(e,t,n,r)=>{let l=b.value,o={...w.value},i=Y(e,y);T(e,l,i?.route.beforeEnter,()=>{x.value=i?.params??{},w.value=t,b.value=e,E(e,l,n);for(let t of S)try{t(e,l)}catch{}},()=>r(l,o))};if(l){let e=()=>{if(a)return void(a=!1);let e=f(),t=J(e.search),n=i.get(p(e.pathname,t))??null;M(e.pathname,t,n,(e,t)=>{a=!0,window.location.hash=d(e,t).slice(1),queueMicrotask(()=>{a=!1})})};window.addEventListener("hashchange",e),G=()=>window.removeEventListener("hashchange",e)}else{let e=e=>{let t=f(),n=J(t.search),r=Oe(e.state??history.state);M(t.pathname,n,r,(e,t)=>{history.pushState(q({},K()),"",d(e,t))})};window.addEventListener("popstate",e),G=()=>window.removeEventListener("popstate",e)}function L(e,t,n,r,o,u){u||function(e,t){let n=K();l?i.set(p(e,t),n):history.replaceState(q(history.state,n),"")}(n,r),x.value=o?.params??{},w.value=t,b.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=q({},{left:0,top:0});u?history.replaceState(e,"",s):history.pushState(e,"",s)}E(e,n,null);for(let t of S)try{t(e,n)}catch{}}function D(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),l=b.value,o={...w.value},i=Y(n,y);T(n,l,i?.route.beforeEnter,()=>L(n,r,l,o,i,!1))}let I={current:b,params:x,query:w,base:n||"/",navigate:D,replace:function(e,t){A=!0;let{pathname:n,stringQuery:r}=$(e,t),l=b.value,o={...w.value},i=Y(n,y);T(n,l,i?.route.beforeEnter,()=>L(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=b.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(e){let t=Y(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 S.push(e),()=>{let t=S.indexOf(e);-1!==t&&S.splice(t,1)}},routes:e,_flat:y,_guards:k,_base:n,_mode:r};return W&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),W=I,queueMicrotask(()=>{A||T(m,"",Y(m,y)?.route.beforeEnter,()=>{},()=>{let e=d("/",{});l?(i.set(p("/",{}),{left:0,top:0}),history.replaceState(history.state,"",e)):history.replaceState(q({},{left:0,top:0}),"",e);let t=Y("/",y);b.value="/",x.value=t?.params??{},w.value={},E("/",m,null)})}),I}function Z(){return F(U)||De()}var Le=class extends E{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return H`<div class="router-view">${()=>{let t=Z(),n=Y(t.current.value,t._flat);return n?e>=n.route.chain.length?H`<span></span>`:n.route.chain[e]():H`<div style="color:#f87171;padding:16px 0">
|
|
2
2
|
404 — Route not found: <strong>${t.current.value}</strong>
|
|
3
|
-
</div>`}}</div>`}},
|
|
3
|
+
</div>`}}</div>`}},Re=class extends E{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label,n=Z(),r=e.startsWith("/")?e:"/"+e,l=(n._base?n._base+r:r).replace(/\/+/g,"/");return H`<a
|
|
4
4
|
href=${"hash"===n._mode?"#"+l:l}
|
|
5
|
-
style=${()=>
|
|
6
|
-
@click=${t=>{t.preventDefault(),
|
|
7
|
-
>${t}</a>`}};function Be(){return U`
|
|
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(D(e)){let r,l,o=ze(t);j();try{n?.router&&P(U,n.router);try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(o,null)}finally{M()}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);j();try{P(U,n.router),r=e._render(l,null)}finally{M()}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 H`
|
|
8
8
|
<span style="color:#52525b;font-size:13px;display:inline-flex;align-items:center;gap:6px">
|
|
9
9
|
<span class="nix-spinner" style="
|
|
10
10
|
display:inline-block;width:14px;height:14px;border-radius:50%;
|
|
@@ -14,8 +14,8 @@ var e=[],t=[],n=null,r=null,i=null,a=[];function o(e){a.push(i),i=e}function s()
|
|
|
14
14
|
Loading…
|
|
15
15
|
</span>
|
|
16
16
|
<style>@keyframes nix-spin{to{transform:rotate(360deg)}}</style>
|
|
17
|
-
`}function
|
|
17
|
+
`}function Ue(e){return H`
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var Q=new Map,
|
|
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 E{_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 H`<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,E as NixComponent,U as RouterKey,Le as RouterView,h as Signal,y as batch,v as computed,Te as createErrorBoundary,ht as createForm,O as createInjectionKey,ye as createPortalOutlet,Ie as createRouter,Ve as createStore,st as createValidator,_ as effect,it as email,lt as extendValidators,H as html,F as inject,we 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,xe as portal,be as portalOutlet,P as provide,Ce as provideOutlet,C as ref,ne as repeat,et as required,ae as showWhen,g as signal,Qe as suspend,ve as transition,b as untrack,ut as useField,dt as useFieldArray,Z as useRouter,ct as validators,x as watch};
|
package/package.json
CHANGED