@deijose/nix-js 1.8.1 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@deijose/nix-js.svg)](https://www.npmjs.com/package/@deijose/nix-js)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
- [![Tests](https://img.shields.io/badge/tests-462%20passing-brightgreen.svg)]()
6
- [![Coverage](https://img.shields.io/badge/coverage-97%25-brightgreen.svg)]()
5
+ [![Tests](https://img.shields.io/badge/tests-484%20passing-brightgreen.svg)]()
6
+ [![Coverage](https://img.shields.io/badge/coverage-95.86%25-brightgreen.svg)]()
7
7
  [![Bundle size](https://img.shields.io/badge/min%2Bgzip-~10%20KB-orange.svg)]()
8
8
  [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-success.svg)]()
9
9
  [![Website](https://img.shields.io/badge/website-nix--js-indigo.svg)](https://nix-js.dev/)
@@ -96,11 +96,19 @@ Everything ships in a single zero-dependency import:
96
96
  | **Router** | `createRouter`, `RouterView`, `Link`, `useRouter`, guards, nested routes |
97
97
  | **Forms** | `useField`, `createForm`, built-in validators, Zod/Valibot interop |
98
98
  | **State** | `createStore`, `provide`, `inject`, `createInjectionKey` |
99
- | **Async** | `suspend` (with `invalidate` for re-fetching), `createQuery`, `invalidateQueries`, `lazy` |
99
+ | **Async** | `suspend` (with `invalidate` for re-fetching), `lazy` |
100
100
  | **Error handling** | `createErrorBoundary` |
101
101
 
102
102
  ## Documentation
103
103
 
104
+ ## Query Package
105
+
106
+ `createQuery` and query cache utilities now live in `@deijose/nix-query`.
107
+
108
+ ```bash
109
+ npm install @deijose/nix-query
110
+ ```
111
+
104
112
  Full API reference, guides, and examples:
105
113
 
106
114
  **→ [github.com/DeijoseDevelop/nix-js](https://github.com/DeijoseDevelop/nix-js)**
@@ -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, createQuery, invalidateQueries, clearQueryCache, setQueryCacheTime, 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, SuspenseOptions, QueryOptions, 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, 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";
@@ -9,42 +9,6 @@ export interface SuspenseOptions {
9
9
  cacheKey?: string;
10
10
  staleTime?: number;
11
11
  }
12
- export type QueryStatus = "pending" | "success" | "error";
13
- export interface QueryResult<T> {
14
- /** Reactive signal with the current fetch status. */
15
- readonly status: Signal<QueryStatus>;
16
- /** Reactive signal with the resolved data. `undefined` while pending. */
17
- readonly data: Signal<T | undefined>;
18
- /** Reactive signal with the captured error. `undefined` if no error. */
19
- readonly error: Signal<unknown>;
20
- /** Clears the cache for this key and re-fetches immediately. */
21
- refetch(): void;
22
- }
23
- export interface QueryOptions {
24
- /**
25
- * Time in ms that cached data is considered fresh.
26
- * While fresh, mounting will not trigger a background refetch.
27
- * @default 0
28
- */
29
- staleTime?: number;
30
- /**
31
- * - `"always"` — background refetch on every mount (default).
32
- * - `"stale"` — refetch only when data has exceeded `staleTime`.
33
- * - `false` — never refetch on mount; only via `refetch()` or `invalidateQueries()`.
34
- * @default "always"
35
- */
36
- refetchOnMount?: "always" | "stale" | false;
37
- }
38
- /**
39
- * Clears one or all entries from the global query cache.
40
- * Passing no argument clears everything.
41
- */
42
- export declare function clearQueryCache(key?: string): void;
43
- /**
44
- * Sets how long cache entries with zero subscribers are kept alive.
45
- * @param ms Milliseconds. Pass `Infinity` to keep entries forever.
46
- */
47
- export declare function setQueryCacheTime(ms: number): void;
48
12
  /**
49
13
  * Runs an async function and renders based on its state (pending/resolved/error).
50
14
  *
@@ -55,40 +19,6 @@ export declare function setQueryCacheTime(ms: number): void;
55
19
  * ```
56
20
  */
57
21
  export declare function suspend<T>(asyncFn: () => Promise<T>, renderFn: (data: T) => NixTemplate | NixComponent, options?: SuspenseOptions): NixComponent;
58
- /**
59
- * Forces all active `createQuery()` instances with the given key to re-fetch.
60
- * Clears the cached data so subsequent mounts also fetch fresh data.
61
- * Instances that have been garbage-collected are pruned automatically.
62
- */
63
- export declare function invalidateQueries(key: string): void;
64
- /**
65
- * Key-based async data fetching with global cache and invalidation.
66
- * Returns reactive signals — render them directly in your component.
67
- *
68
- * Cache persists across route changes. Navigating back renders cached
69
- * data instantly, then background-refetches if stale.
70
- *
71
- * ```ts
72
- * class PostsPage extends NixComponent {
73
- * private q = createQuery("posts", () => api.getPosts());
74
- *
75
- * render() {
76
- * return html`
77
- * ${() => this.q.status.value === "pending" && html`<p>Loading…</p>`}
78
- * ${() => this.q.status.value === "error" && html`<p>Error</p>`}
79
- * ${() => this.q.status.value === "success" && html`
80
- * <ul>${() => repeat(this.q.data.value!, r => r.id,
81
- * r => html`<li>${() => r.name}</li>`)}</ul>
82
- * `}
83
- * `;
84
- * }
85
- * }
86
- *
87
- * // After a mutation:
88
- * invalidateQueries("posts");
89
- * ```
90
- */
91
- export declare function createQuery<T>(key: string, asyncFn: () => Promise<T>, options?: QueryOptions): QueryResult<T>;
92
22
  /**
93
23
  * Wraps a dynamic import for lazy-loading route components.
94
24
  * The module is loaded once and cached. The imported module must use a default export.
@@ -24,4 +24,4 @@ export declare function provide<T>(key: InjectionKey<T> | string | symbol, value
24
24
  * Retrieves a value provided by an ancestor component.
25
25
  * Searches child-to-parent; returns `undefined` if the key was not provided.
26
26
  */
27
- export declare function inject<T>(key: InjectionKey<T> | string | symbol): T | undefined;
27
+ export declare function inject<T>(key: InjectionKey<T> | string | symbol, defaultValue?: T): T | undefined;
@@ -1,6 +1,10 @@
1
1
  import type { Signal } from "./reactivity";
2
- /** A validator function. Return an error string, or null/undefined if valid. */
3
- export type Validator<T> = (value: T) => string | null | undefined;
2
+ /**
3
+ * A validator function. Return an error string, or null/undefined if valid.
4
+ *
5
+ * `allValues` is optional and is provided when the validator runs inside `createForm`.
6
+ */
7
+ export type Validator<T, AllValues = unknown> = (value: T, allValues?: AllValues) => string | null | undefined;
4
8
  export declare function required(message?: string): Validator<unknown>;
5
9
  export declare function minLength(n: number, message?: string): Validator<string>;
6
10
  export declare function maxLength(n: number, message?: string): Validator<string>;
@@ -9,7 +13,7 @@ export declare function email(message?: string): Validator<string>;
9
13
  export declare function min(n: number, message?: string): Validator<number>;
10
14
  export declare function max(n: number, message?: string): Validator<number>;
11
15
  /** Creates a typed custom validator compatible with `useField` and `createForm`. */
12
- export declare function createValidator<T>(fn: (value: T) => string | null | undefined): Validator<T>;
16
+ export declare function createValidator<T, AllValues = unknown>(fn: (value: T, allValues?: AllValues) => string | null | undefined): Validator<T, AllValues>;
13
17
  /** All built-in validators grouped as a namespace. Extensible via `extendValidators`. */
14
18
  export declare const validators: {
15
19
  readonly required: typeof required;
@@ -64,7 +68,7 @@ export interface FieldState<T> {
64
68
  _dispose(): void;
65
69
  }
66
70
  /** Creates a standalone reactive form field with optional validators. */
67
- export declare function useField<T>(initialValue: T, fieldValidators?: Validator<T>[], validateOn?: ValidateOn): FieldState<T>;
71
+ export declare function useField<T, AllValues = unknown>(initialValue: T, fieldValidators?: Validator<T, AllValues>[], validateOn?: ValidateOn, getAllValues?: () => AllValues): FieldState<T>;
68
72
  /** Public state of a field array (dynamic list of field groups). */
69
73
  export interface FieldArrayState<T extends Record<string, unknown>> {
70
74
  /** Reactive list of field group states. */
@@ -100,17 +104,23 @@ export interface FieldArrayState<T extends Record<string, unknown>> {
100
104
  * items.remove(0);
101
105
  */
102
106
  export declare function useFieldArray<T extends Record<string, unknown>>(initialItems: T[], fieldValidators?: {
103
- [K in keyof T]?: Validator<T[K]>[];
107
+ [K in keyof T]?: Validator<T[K], unknown>[];
104
108
  }, validateOn?: ValidateOn): FieldArrayState<T>;
109
+ /** Field-name map that supports top-level keys and dot-path nested keys. */
110
+ export type FormFields<T extends Record<string, unknown>> = {
111
+ [K in keyof T]: FieldState<T[K]>;
112
+ } & Record<string, FieldState<unknown>>;
105
113
  /** Map of field-name → error message for external validation results. */
106
114
  export type FieldErrors<T extends Record<string, unknown>> = {
107
115
  [K in keyof T]?: string | null;
108
- };
116
+ } & Record<string, string | null | undefined>;
117
+ /** Validators map supporting both top-level and dot-path keys. */
118
+ export type FormValidators<T extends Record<string, unknown>> = {
119
+ [K in keyof T]?: Validator<T[K], T>[];
120
+ } & Record<string, Validator<any, any>[] | undefined>;
109
121
  export interface FormState<T extends Record<string, unknown>> {
110
122
  /** Individual field states — access value, error, event handlers. */
111
- fields: {
112
- [K in keyof T]: FieldState<T[K]>;
113
- };
123
+ fields: FormFields<T>;
114
124
  /** Computed snapshot of all current field values. */
115
125
  readonly values: Signal<T>;
116
126
  /** Computed map of all currently visible field errors. */
@@ -148,10 +158,8 @@ export interface FormState<T extends Record<string, unknown>> {
148
158
  dispose(): void;
149
159
  }
150
160
  export interface FormOptions<T extends Record<string, unknown>> {
151
- /** Per-field built-in validators. */
152
- validators?: {
153
- [K in keyof T]?: Validator<T[K]>[];
154
- };
161
+ /** Per-field validators. Each validator receives `(value, allValues?)`. */
162
+ validators?: FormValidators<T>;
155
163
  /**
156
164
  * Controls when validation errors become visible.
157
165
  * - `"blur"` — after the field loses focus (default)
@@ -176,9 +184,7 @@ export interface FormOptions<T extends Record<string, unknown>> {
176
184
  * }
177
185
  * ```
178
186
  */
179
- validate?: (values: T) => {
180
- [K in keyof T]?: string | string[] | null | undefined;
181
- } | null | undefined;
187
+ validate?: (values: T) => Record<string, string | string[] | null | undefined> | null | undefined;
182
188
  }
183
189
  /**
184
190
  * Creates a managed form with reactive fields, built-in validation,
@@ -8,9 +8,9 @@ export type { NixChildren } from "./lifecycle";
8
8
  export { createStore } from "./store";
9
9
  export type { Store, StoreSignals } from "./store";
10
10
  export { createRouter, RouterView, Link, useRouter } from "./router";
11
- export type { Router, RouteRecord, RouterOptions, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute } from "./router";
12
- export { suspend, lazy, createQuery, invalidateQueries, clearQueryCache, setQueryCacheTime } from "./async";
13
- export type { SuspenseOptions, QueryOptions } from "./async";
11
+ export type { Router, RouteRecord, RouterOptions, NavigationGuard, NavigationGuardResult, AfterEachHook, ResolvedRoute, ScrollPosition, ScrollBehavior, RouterMode, } from "./router";
12
+ export { suspend, lazy } from "./async";
13
+ export type { SuspenseOptions } from "./async";
14
14
  export { provide, inject, createInjectionKey } from "./context";
15
15
  export type { InjectionKey } from "./context";
16
16
  export { useField, useFieldArray, createForm, required, minLength, maxLength, email, pattern, min, max, createValidator, validators, extendValidators, } from "./form";
@@ -15,6 +15,8 @@ export interface RouteRecord {
15
15
  path: string;
16
16
  /** Factory returning the view for this route level. */
17
17
  component: () => NixTemplate | NixComponent;
18
+ /** Optional arbitrary metadata for guards, layouts, and auth checks. */
19
+ meta?: Record<string, unknown>;
18
20
  /** Child routes. Paths are joined with the parent. */
19
21
  children?: RouteRecord[];
20
22
  /** Route-level guard. Runs only when entering this specific route. */
@@ -24,6 +26,20 @@ export interface RouteRecord {
24
26
  * Callback for `afterEach` hooks — receives the committed `to` and `from` paths.
25
27
  */
26
28
  export type AfterEachHook = (to: string, from: string) => void;
29
+ /** Serializable scroll position used by the router for history restoration. */
30
+ export interface ScrollPosition {
31
+ left: number;
32
+ top: number;
33
+ }
34
+ /**
35
+ * Scroll behavior callback.
36
+ * - `savedPosition` is non-null on popstate (back/forward) when a saved position exists.
37
+ * - Return `{ left, top }` to scroll there.
38
+ * - Return `false` or `undefined` to skip router scrolling.
39
+ */
40
+ export type ScrollBehavior = (to: string, from: string, savedPosition: ScrollPosition | null) => ScrollPosition | false | void;
41
+ /** Router URL mode strategy. */
42
+ export type RouterMode = "history" | "hash";
27
43
  /**
28
44
  * Result of `router.resolve(path)` — inspect what would match without navigating.
29
45
  */
@@ -55,6 +71,14 @@ export interface RouterOptions {
55
71
  * createRouter(routes, { base: "/my-app/" });
56
72
  */
57
73
  base?: string;
74
+ /** URL handling mode. `history` by default. */
75
+ mode?: RouterMode;
76
+ /**
77
+ * Optional custom scroll behavior for navigation.
78
+ * If omitted, router scrolls to top on push/replace and restores saved
79
+ * positions on back/forward when available.
80
+ */
81
+ scrollBehavior?: ScrollBehavior;
58
82
  }
59
83
  export interface Router {
60
84
  /** Signal with the current active pathname (without the base prefix). */
@@ -3,17 +3,22 @@ import { Signal } from "./reactivity";
3
3
  export type StoreSignals<T extends Record<string, unknown>> = {
4
4
  readonly [K in keyof T]: Signal<T[K]>;
5
5
  };
6
- /** The store as seen by the consumer: signals + actions + `$reset`. */
7
- export type Store<T extends Record<string, unknown>, A extends Record<string, unknown> = Record<never, never>> = StoreSignals<T> & A & {
6
+ /** Subscriber callback used by `$subscribe`. */
7
+ export type StoreSubscriber<T extends Record<string, unknown>> = (key: keyof T, newValue: T[keyof T], oldValue: T[keyof T] | undefined) => void;
8
+ /** The store as seen by the consumer: signals + actions + getters + built-ins. */
9
+ export type Store<T extends Record<string, unknown>, A extends Record<string, unknown> = Record<never, never>, G extends Record<string, Signal<unknown>> = Record<never, never>> = StoreSignals<T> & A & G & {
8
10
  /** The current state snapshot. Reactive. */
9
11
  readonly $state: T;
10
12
  /** Resets all signals to their initial values. */
11
13
  $reset(): void;
12
14
  /** Patches the store with a partial state. */
13
15
  $patch(partial: Partial<T>): void;
16
+ /** Subscribes to all store signal changes. Returns an unsubscribe function. */
17
+ $subscribe(listener: StoreSubscriber<T>): () => void;
14
18
  };
15
19
  /**
16
20
  * Creates a reactive global store. Each property becomes a Signal.
17
21
  * Optional `actionsFactory` receives the signals and returns action methods.
22
+ * Optional `gettersFactory` receives the signals and returns derived getter signals.
18
23
  */
19
- export declare function createStore<T extends Record<string, unknown>, A extends Record<string, unknown> = Record<never, never>>(initialState: T, actionsFactory?: (signals: StoreSignals<T>) => A): Store<T, A>;
24
+ export declare function createStore<T extends Record<string, unknown>, A extends Record<string, unknown> = Record<never, never>, G extends Record<string, Signal<unknown>> = Record<never, never>>(initialState: T, actionsFactory?: (signals: StoreSignals<T>) => A, gettersFactory?: (signals: StoreSignals<T>) => G): Store<T, A, G>;
@@ -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 _(l){let o,u=!1,a=new Set,s=new Set,c=i,p=()=>{if(u)return;"function"==typeof o&&o();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 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 a)s.has(e)||e._removeSub(p)}};return p(),()=>{u=!0,"function"==typeof o&&o();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,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,u=!0,a=!1,s=_(()=>{let e=i();if(u){if(u=!1,l&&!a){let n=e;b(()=>t(n,void 0)),o&&(a=!0,Promise.resolve().then(s))}r=e}else if(!a){let n=e,l=r;r=e,b(()=>t(n,l)),o&&(a=!0,Promise.resolve().then(s))}});return()=>{a=!0,s()}}function ee(e){return e?Promise.resolve().then(e):Promise.resolve()}function te(){return{el:null}}var S={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function C(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ne(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var w=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 T(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function E(e){return Symbol(e)}var D=[];function re(){return[...D]}function O(){D.push(new Map)}function k(){D.pop()}function ie(e,t){let n=D.splice(0);e.forEach(e=>D.push(e)),D.push(new Map);try{return t()}finally{D.splice(0),n.forEach(e=>D.push(e))}}function ae(e,t){let n=D[D.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function oe(e){for(let t=D.length-1;t>=0;t--)if(D[t].has(e))return D[t].get(e)}function se(e,t,n){let r,l;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{k()}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 ce(e,t,n){let r,l;O();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function A(e,t,n,r){let l,o;ie(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 le(e,t,n,r,l){let o,i;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{k()}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 ue(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function de(e){let t,n,r,l,o,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,l=u.length-1;r<l;)o=r+l>>1,e[u[o]]<a?r=o+1:l=o;a<e[u[r]]&&(r>0&&(i[t]=u[r-1]),u[r]=t)}}for(r=u.length,l=u[r-1];r-- >0;)u[r]=l,l=i[l];return u}var j=new Set,M=!1;function N(e){j.add(e),M||(M=!0,queueMicrotask(()=>{for(let e of j)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}j.clear(),M=!1}))}function fe(e,t,n,r){if("function"!=typeof t){if(T(t))le(t,e.parentNode,e,r,n);else if(C(t))n.push(t._render(e.parentNode,e));else if(Array.isArray(t))for(let l of t)T(l)?le(l,e.parentNode,e,r,n):C(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,u=[],a=null,s=re(),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,N(t)))}if(c=!1,d=!1,l&&=(l.parentNode?.removeChild(l),null),o&&=(o(),null),null!=n&&!1!==n)if(C(n))o=n._render(e.parentNode,e);else if(T(n))o=A(n,e.parentNode,e,s);else if(ne(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)),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(a),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],u=document.createTextNode(""),a=document.createTextNode("");l.appendChild(u),l.appendChild(a);let c=n.renderFn(o,e),f=T(c)?A(c,l,a,s):c._render(l,a);i?.set(t,{start:u,end:a,cleanup:f})}}),t.insertBefore(l,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?de(f):[],v=h.length-1,m=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(""),u=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(o),a.appendChild(u);let c=n.renderFn(r,e),f=T(c)?A(c,a,u,s):c._render(a,u);i.set(l,{start:o,end:u,cleanup:f}),t.insertBefore(a,m),m=o}else{let n=i.get(l);if(d)if(v<0||e!==h[v]){let e=n.start;for(;e;){let r=e===n.end?null:e.nextSibling;if(t.insertBefore(e,m),!r)break;e=r}}else v--;m=n.start}}u=r}else if(Array.isArray(n)){let t=[];for(let r of n)if(T(r))t.push(se(r,e.parentNode,e));else if(C(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,a=null}})}function pe(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function me(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 u=r.slice(i,l);if("@"===u[0]){let e=u.slice(1).split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o}}return{type:"attr",attrName:u,hadOpenQuote:o}}var he={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ge=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),P=new Set;function _e(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=he[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 ve=new Map;function ye(e,t,n,r){let l=[],o=[],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(!ge.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(!P.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>_e(e,t,n);ve.set(e,r),document.addEventListener(e,r),P.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"===u.type){let e=s.name,t=c;if("ref"===e){a.el=t,l.push(()=>{a.el=null});continue}if("show"===e||"hide"===e){let n=t,r=null;if("function"==typeof a){let t=!1,o=!1,i=!0,u=_(()=>{o=!!a();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,N(l))});l.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,o=!1,i=!0,u=_(()=>{r=a();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,N(l))});l.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),fe(d,a,l,o)}return{disposes:l,postMountHooks:o}}function be(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 F=new WeakMap;function I(e,...t){let n=F.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(me(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=be(e,t);let o,i=Array(t.length).fill(null),u=l.content,a=document.createTreeWalker(u,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),s=0;for(;o=a.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},F.set(e,n)}let{contexts:r,tpl:l,pathMap:o}=n;function i(e,n){let i=l.content.cloneNode(!0),{disposes:u,postMountHooks:a}=ye(i,r,t,o),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 xe(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 L(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function R(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(L(r.transitionDuration||"0"),L(r.animationDuration||"0")),o=l>0?l+100:t;if(o<=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()},o)})}function Se(e,t={}){let n=xe(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(S.TRANSITION);r.insertBefore(o,l);let i=null,u=null,a=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 T(e)?ce(e,r,l):e._render(r,l)}let d=(e,r=!1)=>{a++,u&&=(u(),null),i=f(e);let l=c();if(l&&(!s||t.appear)&&!r){let e=a;(async()=>{t.onBeforeEnter?.(l),l.classList.add(n.enterFrom,n.enterActive),l.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===e&&(l.classList.remove(n.enterFrom),l.classList.add(n.enterTo),await R(l,t.duration),a===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=++a;u=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),a===l&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await R(r,t.duration),a===l&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),u?.(),u=null))})().catch(()=>{})},h=null;if("function"!=typeof e||T(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&&(a++,u?.(),u=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{a++,h?.(),i?.(),u?.(),i=null,u=null,o.remove()}}}}function Ce(){return{__isPortalOutlet:!0,_container:null}}function we(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 Te(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,T(e)?se(e,l,null):e._render(l,null)}}}var z=E("nix:portal-outlet");function Ee(e){ae(z,e)}function De(){return oe(z)}function Oe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(S.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||T(t)?t:t(e);u=T(o)?ce(o,n,r):o._render(n,r)};o(e=>{a||(a=!0,c?(u?.(),u=null,d(e)):(i=e,f=!0))});try{if(T(e)){O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}u=e.render()._render(n,r)}finally{k()}if(!a)try{let t=e.onMount?.(),n=u;u=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else u=e._render(n,r)}catch(e){a=!0,u?.(),u=null,i=e,f=!0}finally{s(),c=!0}return f&&(u?.(),u=null,d(i)),()=>{u?.(),l.remove()}}}}function ke(e,t){if(T(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{k()}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 Ae(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=g(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var B=null,V=null;function H(){if(!B)throw Error("[Nix] No active router. Call createRouter() first.");return B}function U(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function je(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 Me(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 Ne(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Pe(e,t="",n=[]){let r=[];for(let l of e){let e=Ne(t,l.path),o=[...n,l.component],i=Me(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Pe(l.children,e,o))}return r}function Fe(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 Ie(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function W(e,t){let n,r={},l=-1;for(let o of t){let t=Fe(e,o);if(null===t)continue;let i=Ie(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function G(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Le(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return G(new URL(t,window.location.origin).pathname)}catch{return G(t)}}function Re(e,t){let n=null==t?.base?Le():G(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=Pe(e),u=W(o,i),a=g(o),s=g(u?.params??{}),c=g(U(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let u=0;!function n(a){if(i!==p)return;if(!1===a)return void l?.();if("string"==typeof a)return void(a===e?r():_(a));if(u>=o.length)return void r();let s=o[u++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function m(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:U(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}}V&&=(V(),null);let y=()=>{let e=r(),t=a.value,n=c.value,o=W(e,i),u=U(window.location.search);h(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=u,a.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+je(n))})};function x(e,t,n,r,o){s.value=r?.params??{},c.value=t,a.value=e;let i=l(e)+je(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function _(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=a.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!1))}window.addEventListener("popstate",y),V=()=>window.removeEventListener("popstate",y);let b={current:a,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=a.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>x(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=a.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=W(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return B&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),B=b,queueMicrotask(()=>{v||h(o,"",W(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=W("/",i);a.value="/",s.value=e?.params??{},c.value={}})}),b}function ze(){return H()}var Be=class extends w{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=H(),n=W(t.current.value,t._flat);return n?e>=n.route.chain.length?I`<span></span>`:n.route.chain[e]():I`<div style="color:#f87171;padding:16px 0">
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=[],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">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},Ve=class extends w{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return I`<a
4
- href=${(H()._base||"")+(e.startsWith("/")?e:"/"+e)}
5
- style=${()=>H().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(),H().navigate(e)}}
7
- >${t}</a>`}};function He(){return I`
3
+ </div>`}}</div>`}},ze=class extends E{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label,n=K(),r=e.startsWith("/")?e:"/"+e,o=(n._base?n._base+r:r).replace(/\/+/g,"/");return U`<a
4
+ href=${"hash"===n._mode?"#"+o:o}
5
+ style=${()=>K().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(),K().navigate(e)}}
7
+ >${t}</a>`}};function Be(){return U`
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 Ue(e){return I`
17
+ `}function Ve(e){return U`
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `}var K=new Map,We=3e5,q=null,Ge=We;function Ke(){null===q&&(q=setInterval(()=>{let e=Date.now();for(let[t,n]of K)n.subscribers<=0&&e-n.fetchedAt>Ge&&K.delete(t);0===K.size&&null!==q&&(clearInterval(q),q=null)},6e4))}function J(e){let t=K.get(e);if(t&&t.fetchedAt>0)return t}function qe(e,t){let n=K.get(e);K.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ke()}function Je(e){let t=K.get(e);t?t.subscribers++:K.set(e,{fetchedAt:0,subscribers:1})}function Ye(e){let t=K.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Xe(e,t){let n=K.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Ze(e){void 0===e?(K.clear(),null!==q&&(clearInterval(q),q=null)):K.delete(e)}function Qe(e){Ge=e}function $e(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:u,staleTime:a=0}=n,s=r??He(),c=l??Ue;return new class extends w{_state;_disposeWatcher;constructor(){super();let e=u?J(u):void 0;this._state=g(e&&void 0!==e.data?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){u&&Je(u);let e=u?J(u):void 0;if(e&&Xe(u,a)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(u&&K.delete(u),this._run())})}return()=>{this._disposeWatcher?.(),u&&Ye(u)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{u&&qe(u,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Y=new Map,et=new FinalizationRegistry(({key:e,ref:t})=>{let n=Y.get(e);n&&(n.delete(t),0===n.size&&Y.delete(e))});function tt(e){K.delete(e);let t=Y.get(e);if(t){for(let e of t){let n=e.deref();n?n():t.delete(e)}0===t.size&&Y.delete(e)}}function nt(e,t,n={}){let{staleTime:r=0,refetchOnMount:l="always"}=n,o=J(e),i=g(o?"success":"pending"),u=g(o?.data),a=g(void 0),s=()=>{t().then(t=>{qe(e,t),u.value=t,a.value=void 0,i.value="success"},e=>{a.value=e,i.value="error"})},c=()=>{"pending"===i.peek()&&(u.value=void 0,a.value=void 0),s()};Y.has(e)||Y.set(e,new Set);let f=Y.get(e),d=new WeakRef(c);f.add(d),et.register(c,{key:e,ref:d});let p=Xe(e,r);return o?!1===l||"stale"===l&&p||"always"===l&&p&&r>0||s():c(),{status:i,data:u,error:a,refetch:()=>{K.delete(e),c()}}}function rt(e,t){let n=null;return()=>n?new n:$e(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function it(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function X(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function at(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Z(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function ot(e="Invalid email"){return Z(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function st(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function ct(e){return e}var lt={required:it,minLength:X,maxLength:at,email:ot,pattern:Z,min:st,max:Q};function ut(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=g(e),l=g(!1),o=g(!1),i=g(null),u=g(!1),a=v(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?u.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:a,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,u.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,u.value=!0},_dispose:function(){a.dispose()}}}function dt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=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,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=g(!1),o=g(0),i=v(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),u=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),a=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:u,valid:a,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let u=i.value;if(t.validate){let e=t.validate(u);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let a=e(u);a instanceof Promise&&(l.value=!0,a.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),u.dispose(),a.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}exports.Link=Ve,exports.NixComponent=w,exports.RouterView=Be,exports.Signal=h,exports.batch=y,exports.clearQueryCache=Ze,exports.computed=v,exports.createErrorBoundary=Oe,exports.createForm=ft,exports.createInjectionKey=E,exports.createPortalOutlet=Ce,exports.createQuery=nt,exports.createRouter=Re,exports.createStore=Ae,exports.createValidator=ct,exports.effect=_,exports.email=ot,exports.extendValidators=ut,exports.html=I,exports.inject=oe,exports.injectOutlet=De,exports.invalidateQueries=tt,exports.lazy=rt,exports.max=Q,exports.maxLength=at,exports.min=st,exports.minLength=X,exports.mount=ke,exports.nextTick=ee,exports.pattern=Z,exports.portal=Te,exports.portalOutlet=we,exports.provide=ae,exports.provideOutlet=Ee,exports.ref=te,exports.repeat=ue,exports.required=it,exports.setQueryCacheTime=Qe,exports.showWhen=pe,exports.signal=g,exports.suspend=$e,exports.transition=Se,exports.untrack=b,exports.useField=$,exports.useFieldArray=dt,exports.useRouter=ze,exports.validators=lt,exports.watch=x;
21
+ `}var Q=new Map,He=3e5,$=null,Ue=He;function We(){null===$&&($=setInterval(()=>{let e=Date.now();for(let[t,n]of Q)n.subscribers<=0&&e-n.fetchedAt>Ue&&Q.delete(t);0===Q.size&&null!==$&&(clearInterval($),$=null)},6e4))}function Ge(e){let t=Q.get(e);if(t&&t.fetchedAt>0)return t}function Ke(e,t){let n=Q.get(e);Q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),We()}function qe(e){let t=Q.get(e);t?t.subscribers++:Q.set(e,{fetchedAt:0,subscribers:1})}function Je(e){let t=Q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ye(e,t){let n=Q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Xe(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??Be(),c=o??Ve;return new class extends E{_state;_disposeWatcher;constructor(){super();let e=a?Ge(a):void 0;this._state=g(e&&void 0!==e.data?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&qe(a);let e=a?Ge(a):void 0;if(e&&Ye(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&&Je(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Ke(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return U`<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 Ze(e,t){let n=null;return()=>n?new n:Xe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Qe(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function $e(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function et(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function tt(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function nt(e="Invalid email"){return tt(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function rt(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function it(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function at(e){return e}var ot={required:Qe,minLength:$e,maxLength:et,email:nt,pattern:tt,min:rt,max:it};function st(e,t){return{...e,...t}}function ct(e,t=[],n="blur",r){let o=g(e),l=g(!1),i=g(!1),a=g(null),u=g(!1),s=v(()=>{if(a.value)return a.value;if(!("input"===n?i.value||l.value:"submit"===n?u.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,a.value=null},onBlur:()=>{l.value=!0},reset:function(){o.value=e,l.value=!1,i.value=!1,a.value=null,u.value=!1},_setExternalError:function(e){a.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,u.value=!0},_dispose:function(){s.dispose()}}}function lt(e,t={},n="blur"){function r(e){let r={};for(let o in e){let l=t[o]??[];r[o]=ct(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 ut(e){return"object"==typeof e&&!!e&&!Array.isArray(e)}function dt(e,t="",n=[]){for(let[r,o]of Object.entries(e)){let e=t?`${t}.${r}`:r;ut(o)&&Object.keys(o).length>0?dt(o,e,n):n.push([e,o])}return n}function ft(e,t,n){let r=t.split("."),o=e;for(let e=0;e<r.length-1;e++){let t=r[e];ut(o[t])||(o[t]={}),o=o[t]}o[r[r.length-1]]=n}function pt(e,t={}){let n=t.validateOn??"blur",r={},o=t.validators;function l(){let e={};for(let t in r)ft(e,t,r[t].value.value);return e}for(let[t,i]of dt(e))r[t]=ct(i,o?.[t]??[],n,l);let i=g(!1),a=g(0),u=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: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 o=u.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,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()}}}exports.Link=ze,exports.NixComponent=E,exports.RouterView=Re,exports.Signal=h,exports.batch=y,exports.computed=v,exports.createErrorBoundary=we,exports.createForm=pt,exports.createInjectionKey=O,exports.createPortalOutlet=ve,exports.createRouter=Ie,exports.createStore=Ee,exports.createValidator=at,exports.effect=_,exports.email=nt,exports.extendValidators=st,exports.html=U,exports.inject=F,exports.injectOutlet=Ce,exports.lazy=Ze,exports.max=it,exports.maxLength=et,exports.min=rt,exports.minLength=$e,exports.mount=Te,exports.nextTick=S,exports.pattern=tt,exports.portal=be,exports.portalOutlet=ye,exports.provide=P,exports.provideOutlet=Se,exports.ref=C,exports.repeat=te,exports.required=Qe,exports.showWhen=ie,exports.signal=g,exports.suspend=Xe,exports.transition=_e,exports.untrack=b,exports.useField=ct,exports.useFieldArray=lt,exports.useRouter=Le,exports.validators=ot,exports.watch=x;
@@ -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 ee(e){return e?Promise.resolve().then(e):Promise.resolve()}function te(){return{el:null}}var S={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function C(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ne(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var w=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 T(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function E(e){return Symbol(e)}var D=[];function re(){return[...D]}function O(){D.push(new Map)}function k(){D.pop()}function ie(e,t){let n=D.splice(0);e.forEach(e=>D.push(e)),D.push(new Map);try{return t()}finally{D.splice(0),n.forEach(e=>D.push(e))}}function ae(e,t){let n=D[D.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function oe(e){for(let t=D.length-1;t>=0;t--)if(D[t].has(e))return D[t].get(e)}function se(e,t,n){let r,l;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{k()}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 ce(e,t,n){let r,l;O();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{k()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function A(e,t,n,r){let l,o;ie(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 le(e,t,n,r,l){let o,i;O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=e.render()._render(t,n)}finally{k()}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 ue(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function de(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 j=new Set,M=!1;function N(e){j.add(e),M||(M=!0,queueMicrotask(()=>{for(let e of j)try{e()}catch(e){console.error("[Nix.js] Error in DOM write task:",e)}j.clear(),M=!1}))}function fe(e,t,n,r){if("function"!=typeof t){if(T(t))le(t,e.parentNode,e,r,n);else if(C(t))n.push(t._render(e.parentNode,e));else if(Array.isArray(t))for(let l of t)T(l)?le(l,e.parentNode,e,r,n):C(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=re(),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,N(t)))}if(c=!1,d=!1,l&&=(l.parentNode?.removeChild(l),null),o&&=(o(),null),null!=n&&!1!==n)if(C(n))o=n._render(e.parentNode,e);else if(T(n))o=A(n,e.parentNode,e,s);else if(ne(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=T(c)?A(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?de(f):[],v=h.length-1,m=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=T(c)?A(c,u,a,s):c._render(u,a);i.set(l,{start:o,end:a,cleanup:f}),t.insertBefore(u,m),m=o}else{let n=i.get(l);if(d)if(v<0||e!==h[v]){let e=n.start;for(;e;){let r=e===n.end?null:e.nextSibling;if(t.insertBefore(e,m),!r)break;e=r}}else v--;m=n.start}}a=r}else if(Array.isArray(n)){let t=[];for(let r of n)if(T(r))t.push(se(r,e.parentNode,e));else if(C(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 pe(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function me(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 he={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ge=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),P=new Set;function _e(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=he[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 ve=new Map;function ye(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(!ge.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(!P.has(e)){let t=`__nix_${e}`,n=`__nix_${e}_mods`,r=e=>_e(e,t,n);ve.set(e,r),document.addEventListener(e,r),P.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,N(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,N(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),fe(d,u,l,o)}return{disposes:l,postMountHooks:o}}function be(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 F=new WeakMap;function I(e,...t){let n=F.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(me(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=be(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},F.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}=ye(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 xe(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 L(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function R(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(L(r.transitionDuration||"0"),L(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 Se(e,t={}){let n=xe(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(S.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 T(e)?ce(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 R(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 R(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||T(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 Ce(){return{__isPortalOutlet:!0,_container:null}}function we(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 Te(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,T(e)?se(e,l,null):e._render(l,null)}}}var z=E("nix:portal-outlet");function Ee(e){ae(z,e)}function De(){return oe(z)}function Oe(e,t){return{__isNixTemplate:!0,mount(e){let t="string"==typeof e?document.querySelector(e)??document.body:e;return{unmount:this._render(t,null)}},_render(n,r){let l=document.createComment(S.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||T(t)?t:t(e);a=T(o)?ce(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(T(e)){O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{k()}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 ke(e,t){if(T(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)throw Error(`[Nix] mount: container not found: ${t}`);O();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(l,null)}finally{k()}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 Ae(e,t){let n={},r=new Set(["$reset","$patch","$state"]);for(let t of Object.keys(e)){if(r.has(t))throw Error(`[Nix] Store key "${t}" is reserved.`);n[t]=g(e[t])}let l=n;let o=Object.assign(Object.create(null),l,{$reset:function(){for(let t of Object.keys(e))n[t].value=e[t]},$patch:function(e){for(let t of Object.keys(e))t in n&&(n[t].value=e[t])}});if(Object.defineProperty(o,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(l);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):o[t]=e[t]}return o}var B=null,V=null;function H(){if(!B)throw Error("[Nix] No active router. Call createRouter() first.");return B}function U(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function je(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 Me(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 Ne(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function Pe(e,t="",n=[]){let r=[];for(let l of e){let e=Ne(t,l.path),o=[...n,l.component],i=Me(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...Pe(l.children,e,o))}return r}function Fe(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 Ie(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function W(e,t){let n,r={},l=-1;for(let o of t){let t=Fe(e,o);if(null===t)continue;let i=Ie(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function G(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Le(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return G(new URL(t,window.location.origin).pathname)}catch{return G(t)}}function Re(e,t){let n=null==t?.base?Le():G(t.base);function r(){let e=window.location.pathname||"/";if(n&&e.startsWith(n)){let t=e.slice(n.length);return""===t?"/":t}return e}function l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=Pe(e),a=W(o,i),u=g(o),s=g(a?.params??{}),c=g(U(window.location.search)),f=[],d=[],p=0;function h(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++p;if(0===o.length)return void r();let a=0;!function n(u){if(i!==p)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():b(u));if(a>=o.length)return void r();let s=o[a++](e,t);s instanceof Promise?s.then(n):n(s)}(void 0)}let v=!1;function m(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:U(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}}V&&=(V(),null);let y=()=>{let e=r(),t=u.value,n=c.value,o=W(e,i),a=U(window.location.search);h(e,t,o?.route.beforeEnter,()=>{s.value=o?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",l(t)+je(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+je(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function b(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",y),V=()=>window.removeEventListener("popstate",y);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=m(e,t),l=u.value,o=W(n,i);h(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!0))},back:function(){history.back()},forward:function(){history.forward()},go:function(e){history.go(e)},isActive:function(e,t=!0){let n=u.value;return t?n===e:n===e||n.startsWith(e.endsWith("/")?e:e+"/")},resolve:function(t){let n=W(t,i);if(!n)return{matched:!1,params:{},route:void 0};let r=n.route.chain[n.route.chain.length-1];return{matched:!0,params:n.params,route:function e(t){for(let n of t){if(n.component===r)return n;if(n.children){let t=e(n.children);if(t)return t}}}(e)}},beforeEach:function(e){return f.push(e),()=>{let t=f.indexOf(e);-1!==t&&f.splice(t,1)}},afterEach:function(e){return d.push(e),()=>{let t=d.indexOf(e);-1!==t&&d.splice(t,1)}},routes:e,_flat:i,_guards:f,_base:n};return B&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),B=x,queueMicrotask(()=>{v||h(o,"",W(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=W("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function ze(){return H()}var Be=class extends w{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return I`<div class="router-view">${()=>{let t=H(),n=W(t.current.value,t._flat);return n?e>=n.route.chain.length?I`<span></span>`:n.route.chain[e]():I`<div style="color:#f87171;padding:16px 0">
1
+ var e=[],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">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
- </div>`}}</div>`}},Ve=class extends w{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return I`<a
4
- href=${(H()._base||"")+(e.startsWith("/")?e:"/"+e)}
5
- style=${()=>H().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(),H().navigate(e)}}
7
- >${t}</a>`}};function He(){return I`
3
+ </div>`}}</div>`}},ze=class extends E{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label,n=K(),r=e.startsWith("/")?e:"/"+e,l=(n._base?n._base+r:r).replace(/\/+/g,"/");return U`<a
4
+ href=${"hash"===n._mode?"#"+l:l}
5
+ style=${()=>K().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(),K().navigate(e)}}
7
+ >${t}</a>`}};function Be(){return U`
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 Ue(e){return I`
17
+ `}function Ve(e){return U`
18
18
  <span style="color:#f87171;font-size:13px">
19
19
  ⚠ ${e instanceof Error?e.message:String(e)}
20
20
  </span>
21
- `}var K=new Map,We=3e5,q=null,Ge=We;function Ke(){null===q&&(q=setInterval(()=>{let e=Date.now();for(let[t,n]of K)n.subscribers<=0&&e-n.fetchedAt>Ge&&K.delete(t);0===K.size&&null!==q&&(clearInterval(q),q=null)},6e4))}function J(e){let t=K.get(e);if(t&&t.fetchedAt>0)return t}function qe(e,t){let n=K.get(e);K.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ke()}function Je(e){let t=K.get(e);t?t.subscribers++:K.set(e,{fetchedAt:0,subscribers:1})}function Ye(e){let t=K.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Xe(e,t){let n=K.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Ze(e){void 0===e?(K.clear(),null!==q&&(clearInterval(q),q=null)):K.delete(e)}function Qe(e){Ge=e}function $e(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 w{_state;_disposeWatcher;constructor(){super();let e=a?J(a):void 0;this._state=g(e&&void 0!==e.data?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Je(a);let e=a?J(a):void 0;if(e&&Xe(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=_(()=>{i.value,e?e=!1:(a&&K.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Ye(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&qe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return I`<div class="nix-suspense" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):t(e.data)}}</div>`}}}var Y=new Map,et=new FinalizationRegistry(({key:e,ref:t})=>{let n=Y.get(e);n&&(n.delete(t),0===n.size&&Y.delete(e))});function tt(e){K.delete(e);let t=Y.get(e);if(t){for(let e of t){let n=e.deref();n?n():t.delete(e)}0===t.size&&Y.delete(e)}}function nt(e,t,n={}){let{staleTime:r=0,refetchOnMount:l="always"}=n,o=J(e),i=g(o?"success":"pending"),a=g(o?.data),u=g(void 0),s=()=>{t().then(t=>{qe(e,t),a.value=t,u.value=void 0,i.value="success"},e=>{u.value=e,i.value="error"})},c=()=>{"pending"===i.peek()&&(a.value=void 0,u.value=void 0),s()};Y.has(e)||Y.set(e,new Set);let f=Y.get(e),d=new WeakRef(c);f.add(d),et.register(c,{key:e,ref:d});let p=Xe(e,r);return o?!1===l||"stale"===l&&p||"always"===l&&p&&r>0||s():c(),{status:i,data:a,error:u,refetch:()=>{K.delete(e),c()}}}function rt(e,t){let n=null;return()=>n?new n:$e(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function it(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function X(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function at(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Z(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function ot(e="Invalid email"){return Z(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function st(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Q(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function ct(e){return e}var lt={required:it,minLength:X,maxLength:at,email:ot,pattern:Z,min:st,max:Q};function ut(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=g(e),l=g(!1),o=g(!1),i=g(null),a=g(!1),u=v(()=>{if(i.value)return i.value;if(!("input"===n?o.value||l.value:"submit"===n?a.value:l.value))return null;for(let e of t){let t=e(r.value);if(t)return t}return null});function s(t){if(!t||!("value"in t))return e;let n=t;return"boolean"==typeof e?n.checked:"number"==typeof e?Number(n.value):n.value}return{value:r,error:u,touched:l,dirty:o,onInput:e=>{r.value=s(e.target),o.value=!0,i.value=null},onBlur:()=>{l.value=!0},reset:function(){r.value=e,l.value=!1,o.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(l.value=!0)},_forceVisible:function(){l.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function dt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=$(e[l],o,n)}return r}let l=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,t={}){let n=t.validateOn??"blur",r={};for(let l in e){let o=t.validators?.[l]??[];r[l]=$(e[l],o,n)}let l=g(!1),o=g(0),i=v(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=v(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=v(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=v(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=v(()=>{for(let e in r)if(r[e].touched.value)return!0;return!1});function f(e){for(let t in e)r[t]?._setExternalError(e[t]??null)}return{fields:r,values:i,errors:a,valid:u,dirty:s,touched:c,isSubmitting:l,submitCount:o,handleSubmit:function(e){return n=>{n.preventDefault(),o.value++;for(let e in r)r[e]._forceVisible();let a=i.value;if(t.validate){let e=t.validate(a);if(e){let t={},n=!1;for(let r in e){let l=e[r],o=Array.isArray(l)?l[0]??null:l??null;o&&(t[r]=o,n=!0)}if(n)return void f(t)}}for(let e in r)if(r[e].error.value)return;let u=e(a);u instanceof Promise&&(l.value=!0,u.finally(()=>{l.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();l.value=!1,o.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}export{Ve as Link,w as NixComponent,Be as RouterView,h as Signal,y as batch,Ze as clearQueryCache,v as computed,Oe as createErrorBoundary,ft as createForm,E as createInjectionKey,Ce as createPortalOutlet,nt as createQuery,Re as createRouter,Ae as createStore,ct as createValidator,_ as effect,ot as email,ut as extendValidators,I as html,oe as inject,De as injectOutlet,tt as invalidateQueries,rt as lazy,Q as max,at as maxLength,st as min,X as minLength,ke as mount,ee as nextTick,Z as pattern,Te as portal,we as portalOutlet,ae as provide,Ee as provideOutlet,te as ref,ue as repeat,it as required,Qe as setQueryCacheTime,pe as showWhen,g as signal,$e as suspend,Se as transition,b as untrack,$ as useField,dt as useFieldArray,ze as useRouter,lt as validators,x as watch};
21
+ `}var Q=new Map,He=3e5,$=null,Ue=He;function We(){null===$&&($=setInterval(()=>{let e=Date.now();for(let[t,n]of Q)n.subscribers<=0&&e-n.fetchedAt>Ue&&Q.delete(t);0===Q.size&&null!==$&&(clearInterval($),$=null)},6e4))}function Ge(e){let t=Q.get(e);if(t&&t.fetchedAt>0)return t}function Ke(e,t){let n=Q.get(e);Q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),We()}function qe(e){let t=Q.get(e);t?t.subscribers++:Q.set(e,{fetchedAt:0,subscribers:1})}function Je(e){let t=Q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ye(e,t){let n=Q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Xe(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??Be(),c=l??Ve;return new class extends E{_state;_disposeWatcher;constructor(){super();let e=a?Ge(a):void 0;this._state=g(e&&void 0!==e.data?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&qe(a);let e=a?Ge(a):void 0;if(e&&Ye(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&&Je(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Ke(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return U`<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 Ze(e,t){let n=null;return()=>n?new n:Xe(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Qe(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function $e(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function et(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function tt(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function nt(e="Invalid email"){return tt(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function rt(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function it(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function at(e){return e}var ot={required:Qe,minLength:$e,maxLength:et,email:nt,pattern:tt,min:rt,max:it};function st(e,t){return{...e,...t}}function ct(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 lt(e,t={},n="blur"){function r(e){let r={};for(let l in e){let o=t[l]??[];r[l]=ct(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 ut(e){return"object"==typeof e&&!!e&&!Array.isArray(e)}function dt(e,t="",n=[]){for(let[r,l]of Object.entries(e)){let e=t?`${t}.${r}`:r;ut(l)&&Object.keys(l).length>0?dt(l,e,n):n.push([e,l])}return n}function ft(e,t,n){let r=t.split("."),l=e;for(let e=0;e<r.length-1;e++){let t=r[e];ut(l[t])||(l[t]={}),l=l[t]}l[r[r.length-1]]=n}function pt(e,t={}){let n=t.validateOn??"blur",r={},l=t.validators;function o(){let e={};for(let t in r)ft(e,t,r[t].value.value);return e}for(let[t,i]of dt(e))r[t]=ct(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{ze as Link,E as NixComponent,Re as RouterView,h as Signal,y as batch,v as computed,we as createErrorBoundary,pt as createForm,O as createInjectionKey,ve as createPortalOutlet,Ie as createRouter,Ee as createStore,at as createValidator,_ as effect,nt as email,st as extendValidators,U as html,F as inject,Ce as injectOutlet,Ze as lazy,it as max,et as maxLength,rt as min,$e as minLength,Te as mount,S as nextTick,tt as pattern,be as portal,ye as portalOutlet,P as provide,Se as provideOutlet,C as ref,te as repeat,Qe as required,ie as showWhen,g as signal,Xe as suspend,_e as transition,b as untrack,ct as useField,lt as useFieldArray,Le as useRouter,ot as validators,x as watch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deijose/nix-js",
3
- "version": "1.8.1",
3
+ "version": "1.9.1",
4
4
  "description": "A lightweight, fully reactive micro-framework — no virtual DOM, no compiler, just signals and tagged templates.",
5
5
  "license": "MIT",
6
6
  "author": "Deiver Vasquez",