@deijose/nix-js 1.6.1 → 1.7.0
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/dist/lib/nix/form.d.ts +70 -18
- package/dist/lib/nix-js.cjs +1 -1
- package/dist/lib/nix-js.js +2 -2
- package/package.json +1 -1
package/dist/lib/nix/form.d.ts
CHANGED
|
@@ -27,13 +27,20 @@ export type ValidatorsBase = typeof validators;
|
|
|
27
27
|
* Returns a new object — the original is never mutated.
|
|
28
28
|
*/
|
|
29
29
|
export declare function extendValidators<E extends Record<string, (...args: any[]) => Validator<any>>>(base: ValidatorsBase, extensions: E): ValidatorsBase & E;
|
|
30
|
+
/**
|
|
31
|
+
* Controls when validation errors become visible.
|
|
32
|
+
* - `"blur"` — after the field loses focus (default)
|
|
33
|
+
* - `"input"` — as soon as the user types
|
|
34
|
+
* - `"submit"` — only after the first submit attempt
|
|
35
|
+
*/
|
|
36
|
+
export type ValidateOn = "blur" | "input" | "submit";
|
|
30
37
|
/** Public state of a single form field. */
|
|
31
38
|
export interface FieldState<T> {
|
|
32
39
|
/** Current value — read/write signal. */
|
|
33
40
|
value: Signal<T>;
|
|
34
41
|
/**
|
|
35
42
|
* Current error message, or null.
|
|
36
|
-
*
|
|
43
|
+
* Visibility depends on `validateOn` option.
|
|
37
44
|
*/
|
|
38
45
|
readonly error: Signal<string | null>;
|
|
39
46
|
/** True after the input has lost focus at least once. */
|
|
@@ -51,9 +58,50 @@ export interface FieldState<T> {
|
|
|
51
58
|
* The error clears automatically when the user next edits the field.
|
|
52
59
|
*/
|
|
53
60
|
_setExternalError(msg: string | null): void;
|
|
61
|
+
/** @internal — force error visibility (e.g., on submit). */
|
|
62
|
+
_forceVisible(): void;
|
|
63
|
+
/** @internal — dispose computed signals. */
|
|
64
|
+
_dispose(): void;
|
|
54
65
|
}
|
|
55
66
|
/** Creates a standalone reactive form field with optional validators. */
|
|
56
|
-
export declare function useField<T>(initialValue: T,
|
|
67
|
+
export declare function useField<T>(initialValue: T, fieldValidators?: Validator<T>[], validateOn?: ValidateOn): FieldState<T>;
|
|
68
|
+
/** Public state of a field array (dynamic list of field groups). */
|
|
69
|
+
export interface FieldArrayState<T extends Record<string, unknown>> {
|
|
70
|
+
/** Reactive list of field group states. */
|
|
71
|
+
readonly fields: Signal<Array<{
|
|
72
|
+
[K in keyof T]: FieldState<T[K]>;
|
|
73
|
+
}>>;
|
|
74
|
+
/** Appends a new item to the end of the array. */
|
|
75
|
+
append(value: T): void;
|
|
76
|
+
/** Removes the item at the given index. */
|
|
77
|
+
remove(index: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Moves an item from `from` to `to` index.
|
|
80
|
+
* Items between the two positions shift to fill the gap.
|
|
81
|
+
*/
|
|
82
|
+
move(from: number, to: number): void;
|
|
83
|
+
/** Replaces the item at the given index with new values. */
|
|
84
|
+
replace(index: number, value: T): void;
|
|
85
|
+
/** Number of items in the array. Reactive. */
|
|
86
|
+
readonly length: Signal<number>;
|
|
87
|
+
/** Resets the array to its initial value. */
|
|
88
|
+
reset(): void;
|
|
89
|
+
/** @internal */
|
|
90
|
+
_dispose(): void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Creates a reactive array of field groups for dynamic list forms.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const items = useFieldArray([{ name: "" }], {
|
|
97
|
+
* name: [required()],
|
|
98
|
+
* });
|
|
99
|
+
* items.append({ name: "nuevo" });
|
|
100
|
+
* items.remove(0);
|
|
101
|
+
*/
|
|
102
|
+
export declare function useFieldArray<T extends Record<string, unknown>>(initialItems: T[], fieldValidators?: {
|
|
103
|
+
[K in keyof T]?: Validator<T[K]>[];
|
|
104
|
+
}, validateOn?: ValidateOn): FieldArrayState<T>;
|
|
57
105
|
/** Map of field-name → error message for external validation results. */
|
|
58
106
|
export type FieldErrors<T extends Record<string, unknown>> = {
|
|
59
107
|
[K in keyof T]?: string | null;
|
|
@@ -71,12 +119,19 @@ export interface FormState<T extends Record<string, unknown>> {
|
|
|
71
119
|
readonly valid: Signal<boolean>;
|
|
72
120
|
/** True when at least one field has been modified. */
|
|
73
121
|
readonly dirty: Signal<boolean>;
|
|
122
|
+
/** True when at least one field has been touched (lost focus). */
|
|
123
|
+
readonly touched: Signal<boolean>;
|
|
124
|
+
/** True while the submit callback is executing (async-safe). */
|
|
125
|
+
readonly isSubmitting: Signal<boolean>;
|
|
126
|
+
/** Number of times the form has been submitted (including failed validations). */
|
|
127
|
+
readonly submitCount: Signal<number>;
|
|
74
128
|
/**
|
|
75
129
|
* Wraps a submit callback. Returned handler:
|
|
76
130
|
* 1. Calls `e.preventDefault()`
|
|
77
|
-
* 2.
|
|
131
|
+
* 2. Increments `submitCount` and marks all fields as visible
|
|
78
132
|
* 3. Runs `options.validate` if provided (Zod, etc.)
|
|
79
133
|
* 4. Only calls `fn(values)` if all validations pass
|
|
134
|
+
* 5. Manages `isSubmitting` across async callbacks
|
|
80
135
|
*/
|
|
81
136
|
handleSubmit(fn: (values: T) => void | Promise<void>): (e: Event) => void;
|
|
82
137
|
/** Reset all fields to their initial values. */
|
|
@@ -84,17 +139,26 @@ export interface FormState<T extends Record<string, unknown>> {
|
|
|
84
139
|
/**
|
|
85
140
|
* Inject external errors (e.g., from a server response) into specific fields.
|
|
86
141
|
* Each field's error clears automatically the next time the user edits it.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* form.setErrors({ email: "Email already in use" });
|
|
90
142
|
*/
|
|
91
143
|
setErrors(errors: FieldErrors<T>): void;
|
|
144
|
+
/**
|
|
145
|
+
* Disposes all internal computed signals.
|
|
146
|
+
* Call in `onUnmount` when the form lives inside a component.
|
|
147
|
+
*/
|
|
148
|
+
dispose(): void;
|
|
92
149
|
}
|
|
93
150
|
export interface FormOptions<T extends Record<string, unknown>> {
|
|
94
151
|
/** Per-field built-in validators. */
|
|
95
152
|
validators?: {
|
|
96
153
|
[K in keyof T]?: Validator<T[K]>[];
|
|
97
154
|
};
|
|
155
|
+
/**
|
|
156
|
+
* Controls when validation errors become visible.
|
|
157
|
+
* - `"blur"` — after the field loses focus (default)
|
|
158
|
+
* - `"input"` — as soon as the user types
|
|
159
|
+
* - `"submit"` — only after the first submit attempt
|
|
160
|
+
*/
|
|
161
|
+
validateOn?: ValidateOn;
|
|
98
162
|
/**
|
|
99
163
|
* Optional schema-level validator — runs on submit after built-in validators pass.
|
|
100
164
|
* Return `null` / `undefined` if valid, or a field→error map if not.
|
|
@@ -111,18 +175,6 @@ export interface FormOptions<T extends Record<string, unknown>> {
|
|
|
111
175
|
* );
|
|
112
176
|
* }
|
|
113
177
|
* ```
|
|
114
|
-
*
|
|
115
|
-
* @example Valibot interop
|
|
116
|
-
* ```typescript
|
|
117
|
-
* validate(values) {
|
|
118
|
-
* const r = safeParse(schema, values);
|
|
119
|
-
* if (r.success) return null;
|
|
120
|
-
* const errs: Record<string, string> = {};
|
|
121
|
-
* for (const issue of r.issues)
|
|
122
|
-
* if (issue.path?.[0]?.key) errs[issue.path[0].key as string] = issue.message;
|
|
123
|
-
* return errs;
|
|
124
|
-
* }
|
|
125
|
-
* ```
|
|
126
178
|
*/
|
|
127
179
|
validate?: (values: T) => {
|
|
128
180
|
[K in keyof T]?: string | string[] | null | undefined;
|
package/dist/lib/nix-js.cjs
CHANGED
|
@@ -18,4 +18,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=
|
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var Y=new Map,je=3e5,X=null,Me=je;function Ne(){null===X&&(X=setInterval(()=>{let e=Date.now();for(let[t,n]of Y)n.subscribers<=0&&e-n.fetchedAt>Me&&Y.delete(t);0===Y.size&&null!==X&&(clearInterval(X),X=null)},6e4))}function Z(e){return Y.get(e)}function Pe(e,t){let n=Y.get(e);Y.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ne()}function Fe(e){let t=Y.get(e);t&&t.subscribers++}function Ie(e){let t=Y.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Le(e,t){let n=Y.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Re(e){void 0===e?Y.clear():Y.delete(e)}function ze(e){Me=e}function Be(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??q(),c=o??J;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Z(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Fe(a);let e=a?Z(a):void 0;if(e&&Le(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&Y.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Ie(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Pe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<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 Q=new Map;function Ve(e){Y.delete(e);let t=Q.get(e);if(t)for(let e of t)e()}function He(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??q(),c=l??J;return new class extends b{_state;constructor(){super();let t=Z(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Q.has(e)||Q.set(e,new Set);let t=Q.get(e),n=()=>this._run();t.add(n),Fe(e);let r=Z(e),o=Le(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Q.delete(e),Ie(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Pe(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function Ue(e,t){let n=null;return()=>n?new n:Be(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function We(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ge(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ke(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function $(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function qe(e="Invalid email"){return $(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Je(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Ye(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Xe(e){return e}const Ze={required:We,minLength:Ge,maxLength:Ke,email:qe,pattern:$,min:Je,max:Ye};function Qe(e,t){return{...e,...t}}function $e(e,t=[]){let
|
|
21
|
+
`}var Y=new Map,je=3e5,X=null,Me=je;function Ne(){null===X&&(X=setInterval(()=>{let e=Date.now();for(let[t,n]of Y)n.subscribers<=0&&e-n.fetchedAt>Me&&Y.delete(t);0===Y.size&&null!==X&&(clearInterval(X),X=null)},6e4))}function Z(e){return Y.get(e)}function Pe(e,t){let n=Y.get(e);Y.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ne()}function Fe(e){let t=Y.get(e);t&&t.subscribers++}function Ie(e){let t=Y.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Le(e,t){let n=Y.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Re(e){void 0===e?Y.clear():Y.delete(e)}function ze(e){Me=e}function Be(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??q(),c=o??J;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Z(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Fe(a);let e=a?Z(a):void 0;if(e&&Le(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&Y.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Ie(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Pe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<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 Q=new Map;function Ve(e){Y.delete(e);let t=Q.get(e);if(t)for(let e of t)e()}function He(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??q(),c=l??J;return new class extends b{_state;constructor(){super();let t=Z(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Q.has(e)||Q.set(e,new Set);let t=Q.get(e),n=()=>this._run();t.add(n),Fe(e);let r=Z(e),o=Le(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Q.delete(e),Ie(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Pe(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function Ue(e,t){let n=null;return()=>n?new n:Be(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function We(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ge(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ke(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function $(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function qe(e="Invalid email"){return $(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Je(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Ye(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Xe(e){return e}const Ze={required:We,minLength:Ge,maxLength:Ke,email:qe,pattern:$,min:Je,max:Ye};function Qe(e,t){return{...e,...t}}function $e(e,t=[],n="blur"){let r=p(e),o=p(!1),l=p(!1),i=p(null),a=p(!1),u=h(()=>{if(i.value)return i.value;if(!("input"===n?l.value||o.value:"submit"===n?a.value:o.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:o,dirty:l,onInput:e=>{r.value=s(e.target),l.value=!0,i.value=null},onBlur:()=>{o.value=!0},reset:function(){r.value=e,o.value=!1,l.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(o.value=!0)},_forceVisible:function(){o.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function et(e,t={}){let n=t.validateOn??"blur",r={};for(let o in e){let l=t.validators?.[o]??[];r[o]=$e(e[o],l,n)}let o=p(!1),l=p(0),i=h(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=h(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=h(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=h(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=h(()=>{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:o,submitCount:l,handleSubmit:function(e){return n=>{n.preventDefault(),l.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 o=e[r],l=Array.isArray(o)?o[0]??null:o??null;l&&(t[r]=l,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&&(o.value=!0,u.finally(()=>{o.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();o.value=!1,l.value=0},setErrors:f,dispose:function(){i.dispose(),a.dispose(),u.dispose(),s.dispose(),c.dispose();for(let e in r)r[e]._dispose()}}}exports.Link=Ae,exports.NixComponent=b,exports.RouterView=ke,exports.Signal=f,exports.batch=g,exports.clearQueryCache=Re,exports.computed=h,exports.createErrorBoundary=pe,exports.createForm=et,exports.createInjectionKey=S,exports.createPortalOutlet=se,exports.createQuery=He,exports.createRouter=De,exports.createStore=xe,exports.createValidator=Xe,exports.effect=m,exports.email=qe,exports.extendValidators=Qe,exports.html=R,exports.inject=k,exports.injectOutlet=fe,exports.invalidateQueries=Ve,exports.lazy=Ue,exports.max=Ye,exports.maxLength=Ke,exports.min=Je,exports.minLength=Ge,exports.mount=be,exports.nextTick=y,exports.pattern=$,exports.portal=le,exports.portalOutlet=ce,exports.provide=O,exports.provideOutlet=de,exports.ref=ee,exports.repeat=ne,exports.required=We,exports.setQueryCacheTime=ze,exports.showWhen=te,exports.signal=p,exports.suspend=Be,exports.transition=he,exports.untrack=_,exports.useField=$e,exports.useRouter=Oe,exports.validators=Ze,exports.watch=v;
|
package/dist/lib/nix-js.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!1,s=new Set,c=i,f=()=>{if(!a){if("function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s=new Set,t.push(e),r.push(n),e=f,n=s,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!c)throw e;c(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}}};return f(),()=>{a=!0,"function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose.bind(t);return t.dispose=()=>{n(),r()},t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,o;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}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 ie(e,t,n){let r,o;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function ae(e,t,n,r){let o,l;D(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 oe(e,t,n,r,o){let l,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{E()}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 se(){return{__isPortalOutlet:!0,_container:null}}function ce(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 le(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,x(e)?re(e,o,null):e._render(o,null)}}}var ue=S("nix:portal-outlet");function de(e){O(ue,e)}function fe(){return k(ue)}function pe(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(A.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||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function 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 j(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function M(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(j(r.transitionDuration||"0"),j(r.animationDuration||"0")),l=o>0?o+100:t;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 he(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(A.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 x(e)?ie(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 M(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},h=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},p=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;p=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?h():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,p?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function ge(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function _e(e,t){let n=new Set,r="";for(let o=0;o<e.length;o++){let l=e[o];if(n.has(o)&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&n.add(o+1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&n.add(o+1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ve(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function P(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode,t=0,o=e.firstChild;for(;o&&o!==r;)t++,o=o.nextSibling;n.unshift(t),r=e}return n}function F(e,t){let n=e;for(let e of t)n=n.childNodes[e];return n}var I={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};function ye(e,t,n,r,o){let l=[],i=[],a=new Map;for(let[t,n]of r)a.set(t,F(e,n));let u=new Map;for(let[t,n]of o){let r=F(e,n.path);r.removeAttribute("event"===n.type?`data-nix-e-${t}`:`data-nix-a-${t}`),u.set(t,{el:r,type:n.type,name:n.name})}for(let e=0;e<t.length;e++){let r=t[e],o=n[e];if("event"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:i}=t,a=o,s=r.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=I[e];if(void 0!==n&&t.key!==n||!I[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}a(e)}};n.addEventListener(i,f,c),l.push(()=>n.removeEventListener(i,f,c));continue}if("attr"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:r}=t;if("ref"===r){o.el=n,l.push(()=>{o.el=null});continue}if("show"===r||"hide"===r){let e=n,t=null;if("function"==typeof o){let n=m(()=>{let n=!!o(),l="show"===r?n:!n;null===t&&(t=e.style.display||""),e.style.display=l?t:"none"});l.push(n)}else("show"===r?o:!o)||(n.style.display="none");continue}let i=("value"===r||"checked"===r||"selected"===r)&&r in n;if("function"==typeof o){let e=m(()=>{let e=o();i?n[r]=e??"":null==e||!1===e?n.removeAttribute(r):n.setAttribute(r,String(e))});l.push(e)}else i?n[r]=o??"":null!=o&&!1!==o&&n.setAttribute(r,String(o));continue}let s=a.get(e);if(!s)continue;if("function"!=typeof o){if(x(o))oe(o,s.parentNode,s,i,l);else if(N(o)){let e=o._render(s.parentNode,s);l.push(e)}else if(Array.isArray(o))for(let e of o)x(e)?oe(e,s.parentNode,s,i,l):N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=o&&!1!==o&&s.parentNode.insertBefore(document.createTextNode(String(o)),s);continue}let c=null,f=null,d=null,h=null,p=w(),v=m(()=>{let e=o();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(N(e))f=e._render(s.parentNode,s);else if(x(e))f=ae(e,s.parentNode,s,p);else if(ve(e)){d||(d=new Map,h=document.createComment(A.KEYED_ZONE),s.parentNode.insertBefore(h,s));let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);if(0===r.size&&d.size>0){let e=document.createRange();e.setStartAfter(h),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();return void d.clear()}if(![...d.keys()].some(e=>r.has(e))&&d.size>0){let e=document.createRange();e.setStartAfter(h),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();d.clear()}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(d.has(l)){let e=d.get(l);if(e.end.nextSibling!==o){let n=document.createDocumentFragment(),r=e.start;for(;;){let t=r===e.end?null:r.nextSibling;if(n.appendChild(r),!t)break;r=t}t.insertBefore(n,o)}o=e.start}else{let n,a=document.createComment(A.KEYED_END),u=document.createComment(A.KEYED_START);t.insertBefore(a,o),t.insertBefore(u,a);try{let o=e.renderFn(i,r);n=x(o)?ae(o,t,a,p):o._render(t,a)}catch(e){let n=u.nextSibling;for(;n&&n!==a;){let e=n.nextSibling;t.removeChild(n),n=e}throw u.remove(),a.remove(),e}d.set(l,{start:u,end:a,cleanup:n}),o=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,s.parentNode,s));else if(N(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});l.push(()=>{if(v(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null,h=null}})}return{disposes:l,postMountHooks:i}}var L=new WeakMap;function R(e,...t){let n=L.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ge(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=_e(e,t);let l,i=new Map,a=new Map,u=o.content,s=document.createTreeWalker(u,NodeFilter.SHOW_COMMENT);for(;l=s.nextNode();){let e=l,t=e.nodeValue?.match(/^nix-(\d+)$/);t&&i.set(parseInt(t[1]),P(u,e))}u.querySelectorAll("*").forEach(e=>{let t=Array.from(e.attributes);for(let n of t){let t=n.name.match(/^data-nix-e-(\d+)$/);if(t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"event",name:n.value});continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"attr",name:n.value})}}}),n={contexts:t,tpl:o,markerPaths:i,attrEventPaths:a},L.set(e,n)}let{contexts:r,tpl:o}=n;function l(e,l){let i=o.content.cloneNode(!0),{disposes:a,postMountHooks:u}=ye(i,r,t,n.markerPaths,n.attrEventPaths),s=document.createComment(A.SCOPE);return e.insertBefore(s,l),e.insertBefore(i,l),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==l;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:l,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=l(t,null);return{unmount(){n()}}}}}function be(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function xe(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]=p(e[t])}let o=n;let l=Object.assign(Object.create(null),o,{$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(l,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(o);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):l[t]=e[t]}return l}var z=null,B=null;function V(){if(!z)throw Error("[Nix] No active router. Call createRouter() first.");return z}function H(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function U(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 Se(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 Ce(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function W(e,t="",n=[]){let r=[];for(let o of e){let e=Ce(t,o.path),l=[...n,o.component],i=Se(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...W(o.children,e,l))}return r}function we(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 Te(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},o=-1;for(let l of t){let t=we(e,l);if(null===t)continue;let i=Te(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ee(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function De(e,t){let n=null==t?.base?Ee():K(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 o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=W(e),a=G(l,i),u=p(l),s=p(a?.params??{}),c=p(H(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():b(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 v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:H(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}}B&&=(B(),null);let g=()=>{let e=r(),t=u.value,n=c.value,l=G(e,i),a=H(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+U(n))})};function _(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+U(t);l?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}=y(e,t),o=u.value,l=G(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!1))}window.addEventListener("popstate",g),B=()=>window.removeEventListener("popstate",g);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=G(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!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=G(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 z&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),z=x,queueMicrotask(()=>{v||m(l,"",G(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=G("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Oe(){return V()}var ke=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return R`<div class="router-view">${()=>{let t=V(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?R`<span></span>`:n.route.chain[e]():R`<div style="color:#f87171;padding:16px 0">
|
|
1
|
+
var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!1,s=new Set,c=i,f=()=>{if(!a){if("function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s=new Set,t.push(e),r.push(n),e=f,n=s,++d>u)throw d=0,e=t.pop()||null,n=r.pop()||null,Error("[Nix] Maximum effect re-execution depth exceeded (possible infinite loop).");try{l=o()}catch(e){if(!c)throw e;c(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}}};return f(),()=>{a=!0,"function"==typeof l&&l(),s.forEach(e=>e._removeSub(f)),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose.bind(t);return t.dispose=()=>{n(),r()},t}function g(e){c++;try{e()}finally{if(0===--c){let e=[...l];l.clear(),e.forEach(e=>e())}}}function _(t){let r=e,o=n;e=null,n=null;try{return t()}finally{e=r,n=o}}function v(e,t,n={}){let r,{immediate:o=!1,once:l=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,o&&!u){let n=e;_(()=>t(n,void 0)),l&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,o=r;r=e,_(()=>t(n,o)),l&&(u=!0,Promise.resolve().then(s))}});return()=>{u=!0,s()}}function y(e){return e?Promise.resolve().then(e):Promise.resolve()}var b=class{__isNixComponent=!0;children;_slots=new Map;setChildren(e){return this.children=e,this}setSlot(e,t){return this._slots.set(e,t),this}slot(e){return this._slots.get(e)}};function x(e){return"object"==typeof e&&!!e&&!0===e.__isNixComponent}function S(e){return Symbol(e)}var C=[];function w(){return[...C]}function T(){C.push(new Map)}function E(){C.pop()}function D(e,t){let n=C.splice(0);e.forEach(e=>C.push(e)),C.push(new Map);try{return t()}finally{C.splice(0),n.forEach(e=>C.push(e))}}function O(e,t){let n=C[C.length-1];if(!n)throw Error("[Nix] provide() must be called inside onInit() of a NixComponent.");n.set(e,t)}function k(e){for(let t=C.length-1;t>=0;t--)if(C[t].has(e))return C[t].get(e)}var A={SCOPE:"nix-scope",ERROR_BOUNDARY:"nix-eb",TRANSITION:"nix-t",KEYED_START:"nix-ks",KEYED_END:"nix-ke",KEYED_ZONE:"nix-kz"};function ee(){return{el:null}}function te(e,t){t?"none"===e.style.display&&(e.style.display=""):"none"!==e.style.display&&(e.style.display="none")}function ne(e,t,n){return{__isKeyedList:!0,items:e,keyFn:t,renderFn:n}}function re(e,t,n){let r,o;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}r=e.render()._render(t,n)}finally{E()}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 ie(e,t,n){let r,o;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(o=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{o?.()}catch{}r()}}function ae(e,t,n,r){let o,l;D(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 oe(e,t,n,r,o){let l,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}l=e.render()._render(t,n)}finally{E()}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 se(){return{__isPortalOutlet:!0,_container:null}}function ce(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 le(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,x(e)?re(e,o,null):e._render(o,null)}}}var ue=S("nix:portal-outlet");function de(e){O(ue,e)}function fe(){return k(ue)}function pe(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(A.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||x(t)?t:t(e);a=x(o)?ie(o,n,r):o._render(n,r)};o(e=>{u||(u=!0,c?(a?.(),a=null,d(e)):(i=e,f=!0))});try{if(x(e)){T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}a=e.render()._render(n,r)}finally{E()}if(!u)try{let t=e.onMount?.(),n=a;a=()=>{try{e.onUnmount?.()}catch{}if("function"==typeof t)try{t()}catch{}n?.()}}catch(t){if(!e.onError)throw t;e.onError(t)}}else a=e._render(n,r)}catch(e){u=!0,a?.(),a=null,i=e,f=!0}finally{s(),c=!0}return f&&(a?.(),a=null,d(i)),()=>{a?.(),l.remove()}}}}function 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 j(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function M(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(j(r.transitionDuration||"0"),j(r.animationDuration||"0")),l=o>0?o+100:t;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 he(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(A.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 x(e)?ie(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 M(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await M(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function ge(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),o=r.match(/@([\w:.-]+)=["']?$/);if(o){let e=o[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}}let l=r.match(/([\w:.-]+)=["']?$/);return l?{type:"attr",attrName:l[1],hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}:{type:"node"}}function _e(e,t){let n=new Set,r="";for(let o=0;o<e.length;o++){let l=e[o];if(n.has(o)&&('"'===l[0]||"'"===l[0])&&(l=l.slice(1)),o<t.length){let e=t[o];if("node"===e.type)r+=l+`\x3c!--nix-${o}--\x3e`;else if("event"===e.type){let t=`@${e.modifiers.length?`${e.eventName}.${e.modifiers.join(".")}`:e.eventName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&n.add(o+1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&n.add(o+1)}}else r+=l}return r}function N(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ve(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function P(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode,t=0,o=e.firstChild;for(;o&&o!==r;)t++,o=o.nextSibling;n.unshift(t),r=e}return n}function F(e,t){let n=e;for(let e of t)n=n.childNodes[e];return n}var I={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};function ye(e,t,n,r,o){let l=[],i=[],a=new Map;for(let[t,n]of r)a.set(t,F(e,n));let u=new Map;for(let[t,n]of o){let r=F(e,n.path);r.removeAttribute("event"===n.type?`data-nix-e-${t}`:`data-nix-a-${t}`),u.set(t,{el:r,type:n.type,name:n.name})}for(let e=0;e<t.length;e++){let r=t[e],o=n[e];if("event"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:i}=t,a=o,s=r.modifiers,c={};s.includes("once")&&(c.once=!0),s.includes("capture")&&(c.capture=!0),s.includes("passive")&&(c.passive=!0);let f=e=>{if(s.includes("prevent")&&e.preventDefault(),s.includes("stop")&&e.stopPropagation(),!s.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of s){let n=I[e];if(void 0!==n&&t.key!==n||!I[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}a(e)}};n.addEventListener(i,f,c),l.push(()=>n.removeEventListener(i,f,c));continue}if("attr"===r.type){let t=u.get(e);if(!t)continue;let{el:n,name:r}=t;if("ref"===r){o.el=n,l.push(()=>{o.el=null});continue}if("show"===r||"hide"===r){let e=n,t=null;if("function"==typeof o){let n=m(()=>{let n=!!o(),l="show"===r?n:!n;null===t&&(t=e.style.display||""),e.style.display=l?t:"none"});l.push(n)}else("show"===r?o:!o)||(n.style.display="none");continue}let i=("value"===r||"checked"===r||"selected"===r)&&r in n;if("function"==typeof o){let e=m(()=>{let e=o();i?n[r]=e??"":null==e||!1===e?n.removeAttribute(r):n.setAttribute(r,String(e))});l.push(e)}else i?n[r]=o??"":null!=o&&!1!==o&&n.setAttribute(r,String(o));continue}let s=a.get(e);if(!s)continue;if("function"!=typeof o){if(x(o))oe(o,s.parentNode,s,i,l);else if(N(o)){let e=o._render(s.parentNode,s);l.push(e)}else if(Array.isArray(o))for(let e of o)x(e)?oe(e,s.parentNode,s,i,l):N(e)?e._render(s.parentNode,s):null!=e&&!1!==e&&s.parentNode.insertBefore(document.createTextNode(String(e)),s);else null!=o&&!1!==o&&s.parentNode.insertBefore(document.createTextNode(String(o)),s);continue}let c=null,f=null,d=null,p=null,h=w(),v=m(()=>{let e=o();if("string"==typeof e||"number"==typeof e)return f&&=(f(),null),void(c?c.nodeValue=String(e):(c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)));if(c&&=(c.parentNode?.removeChild(c),null),f&&=(f(),null),null!=e&&!1!==e)if(N(e))f=e._render(s.parentNode,s);else if(x(e))f=ae(e,s.parentNode,s,h);else if(ve(e)){d||(d=new Map,p=document.createComment(A.KEYED_ZONE),s.parentNode.insertBefore(p,s));let t=s.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n);if(0===r.size&&d.size>0){let e=document.createRange();e.setStartAfter(p),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();return void d.clear()}if(![...d.keys()].some(e=>r.has(e))&&d.size>0){let e=document.createRange();e.setStartAfter(p),e.setEndBefore(s),e.deleteContents();for(let e of d.values())e.cleanup();d.clear()}let o=s;for(let r=n.length-1;r>=0;r--){let l=n[r],i=e.items[r];if(d.has(l)){let e=d.get(l);if(e.end.nextSibling!==o){let n=document.createDocumentFragment(),r=e.start;for(;;){let t=r===e.end?null:r.nextSibling;if(n.appendChild(r),!t)break;r=t}t.insertBefore(n,o)}o=e.start}else{let n,a=document.createComment(A.KEYED_END),u=document.createComment(A.KEYED_START);t.insertBefore(a,o),t.insertBefore(u,a);try{let o=e.renderFn(i,r);n=x(o)?ae(o,t,a,h):o._render(t,a)}catch(e){let n=u.nextSibling;for(;n&&n!==a;){let e=n.nextSibling;t.removeChild(n),n=e}throw u.remove(),a.remove(),e}d.set(l,{start:u,end:a,cleanup:n}),o=u}}}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,s.parentNode,s));else if(N(n))t.push(n._render(s.parentNode,s));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));s.parentNode.insertBefore(e,s),t.push(()=>e.parentNode?.removeChild(e))}f=()=>t.forEach(e=>e())}else c=document.createTextNode(String(e)),s.parentNode.insertBefore(c,s)});l.push(()=>{if(v(),f&&=(f(),null),c&&=(c.parentNode?.removeChild(c),null),d){for(let e of d.values())e.cleanup();d=null,p=null}})}return{disposes:l,postMountHooks:i}}var L=new WeakMap;function R(e,...t){let n=L.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(ge(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=_e(e,t);let l,i=new Map,a=new Map,u=o.content,s=document.createTreeWalker(u,NodeFilter.SHOW_COMMENT);for(;l=s.nextNode();){let e=l,t=e.nodeValue?.match(/^nix-(\d+)$/);t&&i.set(parseInt(t[1]),P(u,e))}u.querySelectorAll("*").forEach(e=>{let t=Array.from(e.attributes);for(let n of t){let t=n.name.match(/^data-nix-e-(\d+)$/);if(t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"event",name:n.value});continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);a.set(r,{path:P(u,e),type:"attr",name:n.value})}}}),n={contexts:t,tpl:o,markerPaths:i,attrEventPaths:a},L.set(e,n)}let{contexts:r,tpl:o}=n;function l(e,l){let i=o.content.cloneNode(!0),{disposes:a,postMountHooks:u}=ye(i,r,t,n.markerPaths,n.attrEventPaths),s=document.createComment(A.SCOPE);return e.insertBefore(s,l),e.insertBefore(i,l),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==l;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:l,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=l(t,null);return{unmount(){n()}}}}}function be(e,t){if(x(e)){let n,r,o="string"==typeof t?document.querySelector(t):t;if(!o)throw Error(`[Nix] mount: container not found: ${t}`);T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}n=e.render()._render(o,null)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(r=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return{unmount(){try{e.onUnmount?.()}catch{}try{r?.()}catch{}n()}}}return e.mount(t)}function xe(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]=p(e[t])}let o=n;let l=Object.assign(Object.create(null),o,{$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(l,"$state",{get(){let e={};for(let t in n)e[t]=n[t].value;return e},enumerable:!0,configurable:!1}),t){let e=t(o);for(let t of Object.keys(e))r.has(t)?console.warn(`[Nix] Store action name "${t}" is reserved and will be ignored.`):l[t]=e[t]}return l}var z=null,B=null;function V(){if(!z)throw Error("[Nix] No active router. Call createRouter() first.");return z}function H(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function U(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 Se(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 Ce(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function W(e,t="",n=[]){let r=[];for(let o of e){let e=Ce(t,o.path),l=[...n,o.component],i=Se(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...W(o.children,e,l))}return r}function we(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 Te(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function G(e,t){let n,r={},o=-1;for(let l of t){let t=we(e,l);if(null===t)continue;let i=Te(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function K(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ee(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return K(new URL(t,window.location.origin).pathname)}catch{return K(t)}}function De(e,t){let n=null==t?.base?Ee():K(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 o(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let l=r(),i=W(e),a=G(l,i),u=p(l),s=p(a?.params??{}),c=p(H(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,o){let l=[...f];n&&l.push(n);let i=++h;if(0===l.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void o?.();if("string"==typeof u)return void(u===e?r():b(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 v=!1;function y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),o=-1===n?{}:H(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}}B&&=(B(),null);let g=()=>{let e=r(),t=u.value,n=c.value,l=G(e,i),a=H(window.location.search);m(e,t,l?.route.beforeEnter,()=>{s.value=l?.params??{},c.value=a,u.value=e;for(let n of d)try{n(e,t)}catch{}},()=>{history.pushState(null,"",o(t)+U(n))})};function _(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+U(t);l?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}=y(e,t),o=u.value,l=G(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!1))}window.addEventListener("popstate",g),B=()=>window.removeEventListener("popstate",g);let x={current:u,params:s,query:c,base:n||"/",navigate:b,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=G(n,i);m(n,o,l?.route.beforeEnter,()=>_(n,r,o,l,!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=G(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 z&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),z=x,queueMicrotask(()=>{v||m(l,"",G(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=G("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Oe(){return V()}var ke=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return R`<div class="router-view">${()=>{let t=V(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?R`<span></span>`:n.route.chain[e]():R`<div style="color:#f87171;padding:16px 0">
|
|
2
2
|
404 — Route not found: <strong>${t.current.value}</strong>
|
|
3
3
|
</div>`}}</div>`}},Ae=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return R`<a
|
|
4
4
|
href=${(V()._base||"")+(e.startsWith("/")?e:"/"+e)}
|
|
@@ -18,4 +18,4 @@ var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s()
|
|
|
18
18
|
<span style="color:#f87171;font-size:13px">
|
|
19
19
|
⚠ ${e instanceof Error?e.message:String(e)}
|
|
20
20
|
</span>
|
|
21
|
-
`}var Y=new Map,je=3e5,X=null,Me=je;function Ne(){null===X&&(X=setInterval(()=>{let e=Date.now();for(let[t,n]of Y)n.subscribers<=0&&e-n.fetchedAt>Me&&Y.delete(t);0===Y.size&&null!==X&&(clearInterval(X),X=null)},6e4))}function Z(e){return Y.get(e)}function Pe(e,t){let n=Y.get(e);Y.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ne()}function Fe(e){let t=Y.get(e);t&&t.subscribers++}function Ie(e){let t=Y.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Le(e,t){let n=Y.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Re(e){void 0===e?Y.clear():Y.delete(e)}function ze(e){Me=e}function Be(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??q(),c=o??J;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Z(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Fe(a);let e=a?Z(a):void 0;if(e&&Le(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&Y.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Ie(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Pe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<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 Q=new Map;function Ve(e){Y.delete(e);let t=Q.get(e);if(t)for(let e of t)e()}function He(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??q(),c=l??J;return new class extends b{_state;constructor(){super();let t=Z(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Q.has(e)||Q.set(e,new Set);let t=Q.get(e),n=()=>this._run();t.add(n),Fe(e);let r=Z(e),o=Le(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Q.delete(e),Ie(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Pe(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function Ue(e,t){let n=null;return()=>n?new n:Be(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function We(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ge(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ke(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function $(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function qe(e="Invalid email"){return $(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Je(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Ye(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Xe(e){return e}const Ze={required:We,minLength:Ge,maxLength:Ke,email:qe,pattern:$,min:Je,max:Ye};function Qe(e,t){return{...e,...t}}function $e(e,t=[]){let
|
|
21
|
+
`}var Y=new Map,je=3e5,X=null,Me=je;function Ne(){null===X&&(X=setInterval(()=>{let e=Date.now();for(let[t,n]of Y)n.subscribers<=0&&e-n.fetchedAt>Me&&Y.delete(t);0===Y.size&&null!==X&&(clearInterval(X),X=null)},6e4))}function Z(e){return Y.get(e)}function Pe(e,t){let n=Y.get(e);Y.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),Ne()}function Fe(e){let t=Y.get(e);t&&t.subscribers++}function Ie(e){let t=Y.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Le(e,t){let n=Y.get(e);return!!n&&Date.now()-n.fetchedAt<t}function Re(e){void 0===e?Y.clear():Y.delete(e)}function ze(e){Me=e}function Be(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??q(),c=o??J;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Z(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Fe(a);let e=a?Z(a):void 0;if(e&&Le(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&Y.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&Ie(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Pe(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<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 Q=new Map;function Ve(e){Y.delete(e);let t=Q.get(e);if(t)for(let e of t)e()}function He(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??q(),c=l??J;return new class extends b{_state;constructor(){super();let t=Z(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Q.has(e)||Q.set(e,new Set);let t=Q.get(e),n=()=>this._run();t.add(n),Fe(e);let r=Z(e),o=Le(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Q.delete(e),Ie(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Pe(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return R`<div class="nix-query" style="display:contents">${()=>{let e=this._state.value;return"pending"===e.status?s:"error"===e.status?c(e.error):n(e.data)}}</div>`}}}function Ue(e,t){let n=null;return()=>n?new n:Be(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function We(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ge(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ke(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function $(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function qe(e="Invalid email"){return $(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function Je(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function Ye(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function Xe(e){return e}const Ze={required:We,minLength:Ge,maxLength:Ke,email:qe,pattern:$,min:Je,max:Ye};function Qe(e,t){return{...e,...t}}function $e(e,t=[],n="blur"){let r=p(e),o=p(!1),l=p(!1),i=p(null),a=p(!1),u=h(()=>{if(i.value)return i.value;if(!("input"===n?l.value||o.value:"submit"===n?a.value:o.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:o,dirty:l,onInput:e=>{r.value=s(e.target),l.value=!0,i.value=null},onBlur:()=>{o.value=!0},reset:function(){r.value=e,o.value=!1,l.value=!1,i.value=null,a.value=!1},_setExternalError:function(e){i.value=e,e&&(o.value=!0)},_forceVisible:function(){o.value=!0,a.value=!0},_dispose:function(){u.dispose()}}}function et(e,t={}){let n=t.validateOn??"blur",r={};for(let o in e){let l=t.validators?.[o]??[];r[o]=$e(e[o],l,n)}let o=p(!1),l=p(0),i=h(()=>{let e={};for(let t in r)e[t]=r[t].value.value;return e}),a=h(()=>{let e={};for(let t in r){let n=r[t].error.value;n&&(e[t]=n)}return e}),u=h(()=>{for(let e in r)if(r[e].error.value)return!1;return!0}),s=h(()=>{for(let e in r)if(r[e].dirty.value)return!0;return!1}),c=h(()=>{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:o,submitCount:l,handleSubmit:function(e){return n=>{n.preventDefault(),l.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 o=e[r],l=Array.isArray(o)?o[0]??null:o??null;l&&(t[r]=l,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&&(o.value=!0,u.finally(()=>{o.value=!1}).catch(()=>{}))}},reset:function(){for(let e in r)r[e].reset();o.value=!1,l.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{Ae as Link,b as NixComponent,ke as RouterView,f as Signal,g as batch,Re as clearQueryCache,h as computed,pe as createErrorBoundary,et as createForm,S as createInjectionKey,se as createPortalOutlet,He as createQuery,De as createRouter,xe as createStore,Xe as createValidator,m as effect,qe as email,Qe as extendValidators,R as html,k as inject,fe as injectOutlet,Ve as invalidateQueries,Ue as lazy,Ye as max,Ke as maxLength,Je as min,Ge as minLength,be as mount,y as nextTick,$ as pattern,le as portal,ce as portalOutlet,O as provide,de as provideOutlet,ee as ref,ne as repeat,We as required,ze as setQueryCacheTime,te as showWhen,p as signal,Be as suspend,he as transition,_ as untrack,$e as useField,Oe as useRouter,Ze as validators,v as watch};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deijose/nix-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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
|
"homepage": "https://nix-js-landing.vercel.app/",
|