@deijose/nix-js 1.7.3-beta.1 → 1.7.3-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){let e=[...this._subs];c>0?e.forEach(e=>l.add(e)):e.forEach(e=>e())}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!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 j(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 M(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 N(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 re(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 ie(){return{__isPortalOutlet:!0,_container:null}}function ae(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 oe(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)?j(e,o,null):e._render(o,null)}}}var se=S("nix:portal-outlet");function ce(e){O(se,e)}function le(){return k(se)}function ue(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)?M(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 de(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 fe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function P(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(fe(r.transitionDuration||"0"),fe(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 pe(e,t={}){let n=de(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)?M(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 P(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 P(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 me(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 he(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 F(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ge(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function I(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 _e(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e],o=n.firstChild;for(let e=0;e<r;e++)o=o.nextSibling;n=o}return n}var L={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ve=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),R=new Set;function ye(e){let t=e.target,n=`__nix_${e.type}`,r=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,r.call(e)};t&&t!==document;){let r=t[n];if(r&&(r(e),o))break;t=t.parentNode}e.stopPropagation=r}function be(e,t,n,r){let o=[],l=[],i=Array(t.length);for(let n=0;n<t.length;n++){let t=r[n];i[n]=t?_e(e,t.path):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,r={};n.includes("once")&&(r.once=!0),n.includes("capture")&&(r.capture=!0),n.includes("passive")&&(r.passive=!0);let l=e=>{if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),!n.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of n){let n=L[e];if(void 0!==n&&t.key!==n||!L[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}t(e)}};!ve.has(e)||r.capture||r.once||n.includes("self")?(c.addEventListener(e,l,r),o.push(()=>c.removeEventListener(e,l,r))):(R.has(e)||(document.addEventListener(e,ye),R.add(e)),c[`__nix_${e}`]=l,o.push(()=>{c[`__nix_${e}`]=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=m(()=>{let t=!!u(),o="show"===e?t:!t;null===r&&(r=n.style.display||""),n.style.display=o?r:"none"});o.push(t)}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=m(()=>{let r=u();n?t[e]=r??"":null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,String(r))});o.push(r)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;if("function"!=typeof u){if(x(u))re(u,f.parentNode,f,l,o);else if(F(u)){let e=u._render(f.parentNode,f);o.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?re(e,f.parentNode,f,l,o):F(e)?e._render(f.parentNode,f):null!=e&&!1!==e&&f.parentNode.insertBefore(document.createTextNode(String(e)),f);else null!=u&&!1!==u&&f.parentNode.insertBefore(document.createTextNode(String(u)),f);continue}let d=null,p=null,h=null,v=[],y=null,g=w(),_=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return p&&=(p(),null),void(d?d.nodeValue=String(e):(d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)));if(d&&=(d.parentNode?.removeChild(d),null),p&&=(p(),null),null!=e&&!1!==e)if(F(e))p=e._render(f.parentNode,f);else if(x(e))p=N(e,f.parentNode,f,g);else if(ge(e)){h||(h=new Map,y=document.createComment(A.KEYED_ZONE),f.parentNode.insertBefore(y,f));let t=f.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n));if(0===v.length){if(h.size>0){let e=document.createRange();e.setStartAfter(y),e.setEndBefore(f),e.deleteContents();for(let e of h.values())e.cleanup();h.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let o=n[t],l=e.items[t],i=document.createComment(A.KEYED_START),a=document.createComment(A.KEYED_END);r.appendChild(i),r.appendChild(a);let u=e.renderFn(l,t),s=x(u)?N(u,r,a,g):u._render(r,a);h.set(o,{start:i,end:a,cleanup:s})}t.insertBefore(r,f)}return void(v=n)}let r=new Map;for(let e=0;e<n.length;e++)r.set(n[e],e);let o=new Int32Array(n.length),l=!1,i=0;for(let e=0;e<v.length;e++){let t=v[e],n=r.get(t);if(void 0===n){let e=h.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}h.delete(t)}else o[n]=e+1,n>=i?i=n:l=!0}let a=l?xe(o):[],u=a.length-1,s=f;for(let r=n.length-1;r>=0;r--){let i=n[r];if(0===o[r]){let n=e.items[r],o=document.createComment(A.KEYED_START),l=document.createComment(A.KEYED_END),a=document.createDocumentFragment();a.appendChild(o),a.appendChild(l);let u=e.renderFn(n,r),c=x(u)?N(u,a,l,g):u._render(a,l);h.set(i,{start:o,end:l,cleanup:c}),t.insertBefore(a,s),s=o}else{let e=h.get(i);if(l)if(u<0||r!==a[u]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,s),!r)break;n=r}}else u--;s=e.start}}v=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(j(n,f.parentNode,f));else if(F(n))t.push(n._render(f.parentNode,f));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));f.parentNode.insertBefore(e,f),t.push(()=>e.parentNode?.removeChild(e))}p=()=>t.forEach(e=>e())}else d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)});o.push(()=>{if(_(),p&&=(p(),null),d&&=(d.parentNode?.removeChild(d),null),h){for(let e of h.values())e.cleanup();h=null,y=null}})}return{disposes:o,postMountHooks:l}}function xe(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 z=new WeakMap;function B(e,...t){let n=z.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 o=document.createElement("template");o.innerHTML=he(e,t);let l,i=Array(t.length).fill(null),a=o.content,u=document.createTreeWalker(a,NodeFilter.SHOW_COMMENT);for(;l=u.nextNode();){let e=l,t=e.nodeValue?.match(/^nix-(\d+)$/);if(t){let n=parseInt(t[1]);i[n]={path:I(a,e)}}}a.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]);i[r]={path:I(a,e),name:n.value},e.removeAttribute(n.name);continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);i[r]={path:I(a,e),name:n.value},e.removeAttribute(n.name)}}}),n={contexts:t,tpl:o,pathMap:i},z.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}=be(i,r,t,l),s=document.createComment(A.SCOPE);return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Se(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 Ce(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 V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function we(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 Te(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 Ee(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function De(e,t="",n=[]){let r=[];for(let o of e){let e=Ee(t,o.path),l=[...n,o.component],i=Te(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...De(o.children,e,l))}return r}function Oe(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 ke(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=Oe(e,l);if(null===t)continue;let i=ke(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 Ae(){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 je(e,t){let n=null==t?.base?Ae():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=De(e),a=G(l,i),u=p(l),s=p(a?.params??{}),c=p(W(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():_(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?{}:W(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}}H&&=(H(),null);let g=()=>{let e=r(),t=u.value,n=c.value,l=G(e,i),a=W(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)+we(n))})};function x(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+we(t);l?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}=y(e,t),o=u.value,l=G(n,i);m(n,o,l?.route.beforeEnter,()=>x(n,r,o,l,!1))}window.addEventListener("popstate",g),H=()=>window.removeEventListener("popstate",g);let b={current:u,params:s,query:c,base:n||"/",navigate:_,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,()=>x(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 V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,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={}})}),b}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var e=null,t=[],n=null,r=[],i=null,a=[];function o(e){a.push(i),i=e}function s(){i=a.pop()??null}var c=0,l=new Set,u=100,d=0,f=class{_value;_subs=new Set;constructor(e){this._value=e}get value(){return e&&(this._subs.add(e),n?.add(this)),this._value}set value(e){Object.is(this._value,e)||(this._value=e,this._notify())}update(e){this.value=e(this._value)}peek(){return this._value}_removeSub(e){this._subs.delete(e)}_notify(){if(c>0)for(let e of this._subs)l.add(e);else{let e=Array.from(this._subs);for(let t=0;t<e.length;t++)e[t]()}}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(o){let l,a=!1,s=new Set,c=new Set,f=i,p=()=>{if(a)return;"function"==typeof l&&l();let i=s;if(s=c,c=i,c.clear(),t.push(e),r.push(n),e=p,n=c,++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(!f)throw e;f(e)}finally{d--,e=t.pop()||null,n=r.pop()||null;for(let e of s)c.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof l&&l();for(let e of c)e._removeSub(p);c.clear(),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function g(e){c++;try{e()}finally{if(0===--c&&l.size>0){for(let e of l)e();l.clear()}}}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 j(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 ae(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 oe(){return{__isPortalOutlet:!0,_container:null}}function se(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 ce(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 M=S("nix:portal-outlet");function le(e){O(M,e)}function ue(){return k(M)}function de(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 fe(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 pe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),o=1e3*Math.max(pe(r.transitionDuration||"0"),pe(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 me(e,t={}){let n=fe(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 N(o,t.duration),u===e&&(o.classList.remove(n.enterActive,n.enterTo),t.onAfterEnter?.(o)))})().catch(()=>{})}s=!1},p=()=>{let e=i;i=null;let r=c();if(!r)return void e?.();let o=++u;a=e??null,(async()=>{t.onBeforeLeave?.(r),r.classList.add(n.leaveFrom,n.leaveActive),r.getBoundingClientRect(),await new Promise(e=>requestAnimationFrame(()=>e())),u===o&&(r.classList.remove(n.leaveFrom),r.classList.add(n.leaveTo),await N(r,t.duration),u===o&&(r.classList.remove(n.leaveActive,n.leaveTo),t.onAfterLeave?.(r),a?.(),a=null))})().catch(()=>{})},h=null;if("function"!=typeof e||x(e))d(e);else{let t=e,n=null;h=m(()=>{let e=t(),r=null===n,o=null===e;r&&!o?d(e):!r&&o?p():!r&&!o&&(u++,a?.(),a=null,i?.(),i=null,d(e,!0)),n=e}),s=!1}return()=>{u++,h?.(),i?.(),a?.(),i=null,a=null,l.remove()}}}}function he(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}}function ge(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?1:0);r+=l.slice(0,-t)+` data-nix-e-${o}="${e.eventName}"`,e.hadOpenQuote&&(n[o+1]=1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=l.slice(0,-t)+` data-nix-a-${o}="${e.attrName}"`,e.hadOpenQuote&&(n[o+1]=1)}}else r+=l}return r}function P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function _e(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var ve={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ye=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),F=new Set;function be(e){let t=e.target,n=`__nix_${e.type}`,r=`__nix_${e.type}_mods`,o=e.stopPropagation,l=!1;for(e.stopPropagation=()=>{l=!0,o.call(e)};t&&t!==document;){let o=t[n];if(o){let n=t[r];if(n){if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),n.includes("self")&&e.target!==t){t=t.parentNode;continue}if("key"in e){let r=e,o=!0;for(let e of n){let t=ve[e];if(void 0!==t&&r.key!==t){o=!1;break}if(!t&&1===e.length&&r.key.toLowerCase()!==e){o=!1;break}}if(!o){t=t.parentNode;continue}}}if(o(e),l)break}t=t.parentNode}e.stopPropagation=o}var I=new Set,L=!1;function R(e){I.add(e),L||(L=!0,queueMicrotask(()=>{for(let e of I)e();I.clear(),L=!1}))}function xe(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=[e];if(a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=0;for(;r<a&&(t=n.nextNode());)r++,u.push(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(!ye.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 F.has(e)||(document.addEventListener(e,be),F.add(e)),c[`__nix_${e}`]=t,n.length>0&&(c[`__nix_${e}_mods`]=n),o.push(()=>{c[`__nix_${e}`]=null,c[`__nix_${e}_mods`]=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=m(()=>{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,R(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=m(()=>{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,R(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("");if(f.parentNode.replaceChild(d,f),"function"!=typeof u){if(x(u))ae(u,d.parentNode,d,l,o);else if(P(u)){let e=u._render(d.parentNode,d);o.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,d.parentNode,d,l,o):P(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=u&&!1!==u&&d.parentNode.insertBefore(document.createTextNode(String(u)),d);continue}let p=null,h=null,v=null,y=[],g=null,_=w(),b=!1,N="",E=!0,S=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e){N=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=N:(p=document.createTextNode(N),d.parentNode.insertBefore(p,d))};return void(E?(E=!1,t()):b||(b=!0,R(t)))}if(b=!1,E=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(P(e))h=e._render(d.parentNode,d);else if(x(e))h=j(e,d.parentNode,d,_);else if(_e(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),o=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){o=!0;break}if(!o){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let o=n[t],l=e.items[t],i=document.createTextNode(""),a=document.createTextNode("");r.appendChild(i),r.appendChild(a);let u=e.renderFn(l,t),s=x(u)?j(u,r,a,_):u._render(r,a);v.set(o,{start:i,end:a,cleanup:s})}t.insertBefore(r,d)}return void(y=n)}let l=new Map;for(let e=0;e<n.length;e++)l.set(n[e],e);let i=new Int32Array(n.length),a=!1,u=0;for(let e=0;e<y.length;e++){let t=y[e],n=l.get(t);if(void 0===n){let e=v.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}v.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Se(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let o=n[r];if(0===i[r]){let n=e.items[r],l=document.createTextNode(""),i=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(l),a.appendChild(i);let u=e.renderFn(n,r),s=x(u)?j(u,a,i,_):u._render(a,i);v.set(o,{start:l,end:i,cleanup:s}),t.insertBefore(a,f),f=l}else{let e=v.get(o);if(a)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}y=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,d.parentNode,d));else if(P(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});o.push(()=>{if(S(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:o,postMountHooks:l}}function Se(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 z=new WeakMap;function B(e,...t){let n=z.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(he(r)),r+="__nix__";let o=document.createElement("template");o.innerHTML=ge(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},z.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}=xe(i,r,t,l),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Ce(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 we(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 V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function Te(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 Ee(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 De(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function G(e,t="",n=[]){let r=[];for(let o of e){let e=De(t,o.path),l=[...n,o.component],i=Ee(e);r.push({fullPath:e,segments:i,chain:l,beforeEnter:o.beforeEnter}),o.children?.length&&r.push(...G(o.children,e,l))}return r}function Oe(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 ke(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function K(e,t){let n,r={},o=-1;for(let l of t){let t=Oe(e,l);if(null===t)continue;let i=ke(l);i>o&&(n=l,r=t,o=i)}return n?{route:n,params:r}:void 0}function q(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ae(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return q(new URL(t,window.location.origin).pathname)}catch{return q(t)}}function je(e,t){let n=null==t?.base?Ae():q(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=G(e),a=K(l,i),u=p(l),s=p(a?.params??{}),c=p(W(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():_(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?{}:W(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}}H&&=(H(),null);let x=()=>{let e=r(),t=u.value,n=c.value,l=K(e,i),a=W(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)+Te(n))})};function g(e,t,n,r,l){s.value=r?.params??{},c.value=t,u.value=e;let i=o(e)+Te(t);l?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}=y(e,t),o=u.value,l=K(n,i);m(n,o,l?.route.beforeEnter,()=>g(n,r,o,l,!1))}window.addEventListener("popstate",x),H=()=>window.removeEventListener("popstate",x);let b={current:u,params:s,query:c,base:n||"/",navigate:_,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),o=u.value,l=K(n,i);m(n,o,l?.route.beforeEnter,()=>g(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=K(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 V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,queueMicrotask(()=>{v||m(l,"",K(l,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",o("/"));let e=K("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=K(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
3
  </div>`}}</div>`}},Pe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return B`<a
4
4
  href=${(U()._base||"")+(e.startsWith("/")?e:"/"+e)}
@@ -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 q=new Map,Le=3e5,J=null,Re=Le;function ze(){null===J&&(J=setInterval(()=>{let e=Date.now();for(let[t,n]of q)n.subscribers<=0&&e-n.fetchedAt>Re&&q.delete(t);0===q.size&&null!==J&&(clearInterval(J),J=null)},6e4))}function Y(e){return q.get(e)}function Be(e,t){let n=q.get(e);q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),ze()}function Ve(e){let t=q.get(e);t&&t.subscribers++}function He(e){let t=q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ue(e,t){let n=q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function We(e){void 0===e?q.clear():q.delete(e)}function Ge(e){Re=e}function Ke(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??Fe(),c=o??Ie;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Y(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ve(a);let e=a?Y(a):void 0;if(e&&Ue(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&q.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&He(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Be(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 X=new Map;function qe(e){q.delete(e);let t=X.get(e);if(t)for(let e of t)e()}function Je(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??Fe(),c=l??Ie;return new class extends b{_state;constructor(){super();let t=Y(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){X.has(e)||X.set(e,new Set);let t=X.get(e),n=()=>this._run();t.add(n),Ve(e);let r=Y(e),o=Ue(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&X.delete(e),He(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Be(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 Ye(e,t){let n=null;return()=>n?new n:Ke(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Xe(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Z(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ze(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function Qe(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function $e(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function et(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function tt(e){return e}const nt={required:Xe,minLength:Z,maxLength:Ze,email:Qe,pattern:Q,min:$e,max:et};function rt(e,t){return{...e,...t}}function $(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 it(e,t={},n="blur"){function r(e){let r={};for(let o in e){let l=t[o]??[];r[o]=$(e[o],l,n)}return r}let o=p(e.map(r)),l=h(()=>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 at(e,t={}){let n=t.validateOn??"blur",r={};for(let o in e){let l=t.validators?.[o]??[];r[o]=$(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=Pe,exports.NixComponent=b,exports.RouterView=Ne,exports.Signal=f,exports.batch=g,exports.clearQueryCache=We,exports.computed=h,exports.createErrorBoundary=ue,exports.createForm=at,exports.createInjectionKey=S,exports.createPortalOutlet=ie,exports.createQuery=Je,exports.createRouter=je,exports.createStore=Ce,exports.createValidator=tt,exports.effect=m,exports.email=Qe,exports.extendValidators=rt,exports.html=B,exports.inject=k,exports.injectOutlet=le,exports.invalidateQueries=qe,exports.lazy=Ye,exports.max=et,exports.maxLength=Ze,exports.min=$e,exports.minLength=Z,exports.mount=Se,exports.nextTick=y,exports.pattern=Q,exports.portal=oe,exports.portalOutlet=ae,exports.provide=O,exports.provideOutlet=ce,exports.ref=ee,exports.repeat=ne,exports.required=Xe,exports.setQueryCacheTime=Ge,exports.showWhen=te,exports.signal=p,exports.suspend=Ke,exports.transition=pe,exports.untrack=_,exports.useField=$,exports.useFieldArray=it,exports.useRouter=Me,exports.validators=nt,exports.watch=v;
21
+ `}var J=new Map,Le=3e5,Y=null,Re=Le;function ze(){null===Y&&(Y=setInterval(()=>{let e=Date.now();for(let[t,n]of J)n.subscribers<=0&&e-n.fetchedAt>Re&&J.delete(t);0===J.size&&null!==Y&&(clearInterval(Y),Y=null)},6e4))}function X(e){return J.get(e)}function Be(e,t){let n=J.get(e);J.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),ze()}function Ve(e){let t=J.get(e);t&&t.subscribers++}function He(e){let t=J.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ue(e,t){let n=J.get(e);return!!n&&Date.now()-n.fetchedAt<t}function We(e){void 0===e?J.clear():J.delete(e)}function Ge(e){Re=e}function Ke(e,t,n={}){let{fallback:r,errorFallback:o,resetOnRefresh:l=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??Fe(),c=o??Ie;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?X(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ve(a);let e=a?X(a):void 0;if(e&&Ue(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&J.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&He(a)}}_run(){(l||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Be(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 Z=new Map;function qe(e){J.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Je(e,t,n,r={}){let{fallback:o,errorFallback:l,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=o??Fe(),c=l??Ie;return new class extends b{_state;constructor(){super();let t=X(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Ve(e);let r=X(e),o=Ue(e,a);return r?!1===u||"stale"===u&&o||"always"===u&&o&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),He(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Be(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 Ye(e,t){let n=null;return()=>n?new n:Ke(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Xe(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ze(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Qe(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function $e(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function et(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function tt(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function nt(e){return e}const rt={required:Xe,minLength:Ze,maxLength:Qe,email:$e,pattern:Q,min:et,max:tt};function it(e,t){return{...e,...t}}function $(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 at(e,t={},n="blur"){function r(e){let r={};for(let o in e){let l=t[o]??[];r[o]=$(e[o],l,n)}return r}let o=p(e.map(r)),l=h(()=>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 ot(e,t={}){let n=t.validateOn??"blur",r={};for(let o in e){let l=t.validators?.[o]??[];r[o]=$(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=Pe,exports.NixComponent=b,exports.RouterView=Ne,exports.Signal=f,exports.batch=g,exports.clearQueryCache=We,exports.computed=h,exports.createErrorBoundary=de,exports.createForm=ot,exports.createInjectionKey=S,exports.createPortalOutlet=oe,exports.createQuery=Je,exports.createRouter=je,exports.createStore=we,exports.createValidator=nt,exports.effect=m,exports.email=$e,exports.extendValidators=it,exports.html=B,exports.inject=k,exports.injectOutlet=ue,exports.invalidateQueries=qe,exports.lazy=Ye,exports.max=tt,exports.maxLength=Qe,exports.min=et,exports.minLength=Ze,exports.mount=Ce,exports.nextTick=y,exports.pattern=Q,exports.portal=ce,exports.portalOutlet=se,exports.provide=O,exports.provideOutlet=le,exports.ref=ee,exports.repeat=ne,exports.required=Xe,exports.setQueryCacheTime=Ge,exports.showWhen=te,exports.signal=p,exports.suspend=Ke,exports.transition=me,exports.untrack=_,exports.useField=$,exports.useFieldArray=at,exports.useRouter=Me,exports.validators=rt,exports.watch=v;
@@ -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(l){let o,a=!1,s=new Set,c=i,f=()=>{if(!a){if("function"==typeof o&&o(),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{o=l()}catch(e){if(!c)throw e;c(e)}finally{d--,e=t.pop()||null,n=r.pop()||null}}};return f(),()=>{a=!0,"function"==typeof o&&o(),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,l=n;e=null,n=null;try{return t()}finally{e=r,n=l}}function v(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;_(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,_(()=>t(n,l)),o&&(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 j(e,t,n){let r,l;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&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function M(e,t,n){let r,l;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function N(e,t,n,r){let l,o;D(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 re(e,t,n,r,l){let o,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=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)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function ie(){return{__isPortalOutlet:!0,_container:null}}function ae(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 oe(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,x(e)?j(e,l,null):e._render(l,null)}}}var se=S("nix:portal-outlet");function ce(e){O(se,e)}function le(){return k(se)}function ue(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)?M(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 de(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 fe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function P(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(fe(r.transitionDuration||"0"),fe(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 pe(e,t={}){let n=de(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(A.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 x(e)?M(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 P(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 P(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||x(e))d(e);else{let t=e,n=null;h=m(()=>{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 me(e){let t=e.lastIndexOf(">"),n=e.lastIndexOf("<");if(n<=t)return{type:"node"};let r=e.slice(n+1),l=r.match(/@([\w:.-]+)=["']?$/);if(l){let e=l[1].split(".");return{type:"event",eventName:e[0],modifiers:e.slice(1),hadOpenQuote:l[0].endsWith('"')||l[0].endsWith("'")}}let o=r.match(/([\w:.-]+)=["']?$/);return o?{type:"attr",attrName:o[1],hadOpenQuote:o[0].endsWith('"')||o[0].endsWith("'")}:{type:"node"}}function he(e,t){let n=new Set,r="";for(let l=0;l<e.length;l++){let o=e[l];if(n.has(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?1:0);r+=o.slice(0,-t)+` data-nix-e-${l}="${e.eventName}"`,e.hadOpenQuote&&n.add(l+1)}else{let t=`${e.attrName}=`.length+(e.hadOpenQuote?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&n.add(l+1)}}else r+=o}return r}function F(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function ge(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}function I(e,t){let n=[],r=t;for(;r&&r!==e;){let e=r.parentNode,t=0,l=e.firstChild;for(;l&&l!==r;)t++,l=l.nextSibling;n.unshift(t),r=e}return n}function _e(e,t){let n=e;for(let e=0;e<t.length;e++){let r=t[e],l=n.firstChild;for(let e=0;e<r;e++)l=l.nextSibling;n=l}return n}var L={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ve=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),R=new Set;function ye(e){let t=e.target,n=`__nix_${e.type}`,r=e.stopPropagation,l=!1;for(e.stopPropagation=()=>{l=!0,r.call(e)};t&&t!==document;){let r=t[n];if(r&&(r(e),l))break;t=t.parentNode}e.stopPropagation=r}function be(e,t,n,r){let l=[],o=[],i=Array(t.length);for(let n=0;n<t.length;n++){let t=r[n];i[n]=t?_e(e,t.path):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,r={};n.includes("once")&&(r.once=!0),n.includes("capture")&&(r.capture=!0),n.includes("passive")&&(r.passive=!0);let o=e=>{if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),!n.includes("self")||e.target===e.currentTarget){if("key"in e){let t=e;for(let e of n){let n=L[e];if(void 0!==n&&t.key!==n||!L[e]&&1===e.length&&t.key.toLowerCase()!==e)return}}t(e)}};!ve.has(e)||r.capture||r.once||n.includes("self")?(c.addEventListener(e,o,r),l.push(()=>c.removeEventListener(e,o,r))):(R.has(e)||(document.addEventListener(e,ye),R.add(e)),c[`__nix_${e}`]=o,l.push(()=>{c[`__nix_${e}`]=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=m(()=>{let t=!!u(),l="show"===e?t:!t;null===r&&(r=n.style.display||""),n.style.display=l?r:"none"});l.push(t)}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=m(()=>{let r=u();n?t[e]=r??"":null==r||!1===r?t.removeAttribute(e):t.setAttribute(e,String(r))});l.push(r)}else n?t[e]=u??"":null!=u&&!1!==u&&t.setAttribute(e,String(u));continue}let f=c;if(!f)continue;if("function"!=typeof u){if(x(u))re(u,f.parentNode,f,o,l);else if(F(u)){let e=u._render(f.parentNode,f);l.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?re(e,f.parentNode,f,o,l):F(e)?e._render(f.parentNode,f):null!=e&&!1!==e&&f.parentNode.insertBefore(document.createTextNode(String(e)),f);else null!=u&&!1!==u&&f.parentNode.insertBefore(document.createTextNode(String(u)),f);continue}let d=null,p=null,h=null,v=[],y=null,g=w(),_=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e)return p&&=(p(),null),void(d?d.nodeValue=String(e):(d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)));if(d&&=(d.parentNode?.removeChild(d),null),p&&=(p(),null),null!=e&&!1!==e)if(F(e))p=e._render(f.parentNode,f);else if(x(e))p=N(e,f.parentNode,f,g);else if(ge(e)){h||(h=new Map,y=document.createComment(A.KEYED_ZONE),f.parentNode.insertBefore(y,f));let t=f.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n));if(0===v.length){if(h.size>0){let e=document.createRange();e.setStartAfter(y),e.setEndBefore(f),e.deleteContents();for(let e of h.values())e.cleanup();h.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createComment(A.KEYED_START),a=document.createComment(A.KEYED_END);r.appendChild(i),r.appendChild(a);let u=e.renderFn(o,t),s=x(u)?N(u,r,a,g):u._render(r,a);h.set(l,{start:i,end:a,cleanup:s})}t.insertBefore(r,f)}return void(v=n)}let r=new Map;for(let e=0;e<n.length;e++)r.set(n[e],e);let l=new Int32Array(n.length),o=!1,i=0;for(let e=0;e<v.length;e++){let t=v[e],n=r.get(t);if(void 0===n){let e=h.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}h.delete(t)}else l[n]=e+1,n>=i?i=n:o=!0}let a=o?xe(l):[],u=a.length-1,s=f;for(let r=n.length-1;r>=0;r--){let i=n[r];if(0===l[r]){let n=e.items[r],l=document.createComment(A.KEYED_START),o=document.createComment(A.KEYED_END),a=document.createDocumentFragment();a.appendChild(l),a.appendChild(o);let u=e.renderFn(n,r),c=x(u)?N(u,a,o,g):u._render(a,o);h.set(i,{start:l,end:o,cleanup:c}),t.insertBefore(a,s),s=l}else{let e=h.get(i);if(o)if(u<0||r!==a[u]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,s),!r)break;n=r}}else u--;s=e.start}}v=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(j(n,f.parentNode,f));else if(F(n))t.push(n._render(f.parentNode,f));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));f.parentNode.insertBefore(e,f),t.push(()=>e.parentNode?.removeChild(e))}p=()=>t.forEach(e=>e())}else d=document.createTextNode(String(e)),f.parentNode.insertBefore(d,f)});l.push(()=>{if(_(),p&&=(p(),null),d&&=(d.parentNode?.removeChild(d),null),h){for(let e of h.values())e.cleanup();h=null,y=null}})}return{disposes:l,postMountHooks:o}}function xe(e){let t,n,r,l,o,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,l=a.length-1;r<l;)o=r+l>>1,e[a[o]]<u?r=o+1:l=o;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,l=a[r-1];r-- >0;)a[r]=l,l=i[l];return a}var z=new WeakMap;function B(e,...t){let n=z.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=he(e,t);let o,i=Array(t.length).fill(null),a=l.content,u=document.createTreeWalker(a,NodeFilter.SHOW_COMMENT);for(;o=u.nextNode();){let e=o,t=e.nodeValue?.match(/^nix-(\d+)$/);if(t){let n=parseInt(t[1]);i[n]={path:I(a,e)}}}a.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]);i[r]={path:I(a,e),name:n.value},e.removeAttribute(n.name);continue}if(t=n.name.match(/^data-nix-a-(\d+)$/),t){let r=parseInt(t[1]);i[r]={path:I(a,e),name:n.value},e.removeAttribute(n.name)}}}),n={contexts:t,tpl:l,pathMap:i},z.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}=be(i,r,t,o),s=document.createComment(A.SCOPE);return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Se(e,t){if(x(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)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(l,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 Ce(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 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 V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function we(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 Te(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 Ee(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function De(e,t="",n=[]){let r=[];for(let l of e){let e=Ee(t,l.path),o=[...n,l.component],i=Te(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...De(l.children,e,o))}return r}function Oe(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 ke(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={},l=-1;for(let o of t){let t=Oe(e,o);if(null===t)continue;let i=ke(o);i>l&&(n=o,r=t,l=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 Ae(){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 je(e,t){let n=null==t?.base?Ae():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 l(e){return n?n+(e.startsWith("/")?e:"/"+e):e}let o=r(),i=De(e),a=G(o,i),u=p(o),s=p(a?.params??{}),c=p(W(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++h;if(0===o.length)return void r();let a=0;!function n(u){if(i!==h)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 y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:W(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}}H&&=(H(),null);let g=()=>{let e=r(),t=u.value,n=c.value,o=G(e,i),a=W(window.location.search);m(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)+we(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+we(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}=y(e,t),l=u.value,o=G(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",g),H=()=>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),l=u.value,o=G(n,i);m(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=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 V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=x,queueMicrotask(()=>{v||m(o,"",G(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=G("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),x}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=G(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<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(){if(c>0)for(let e of this._subs)l.add(e);else{let e=Array.from(this._subs);for(let t=0;t<e.length;t++)e[t]()}}dispose(){this._subs.clear()}};function p(e){return new f(e)}function m(l){let o,a=!1,s=new Set,c=new Set,f=i,p=()=>{if(a)return;"function"==typeof o&&o();let i=s;if(s=c,c=i,c.clear(),t.push(e),r.push(n),e=p,n=c,++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{o=l()}catch(e){if(!f)throw e;f(e)}finally{d--,e=t.pop()||null,n=r.pop()||null;for(let e of s)c.has(e)||e._removeSub(p)}};return p(),()=>{a=!0,"function"==typeof o&&o();for(let e of c)e._removeSub(p);c.clear(),s.clear()}}function h(e){let t=new f(void 0),n=m(()=>{t.value=e()}),r=t.dispose;return t.dispose=()=>{n(),r.call(t)},t}function g(e){c++;try{e()}finally{if(0===--c&&l.size>0){for(let e of l)e();l.clear()}}}function _(t){let r=e,l=n;e=null,n=null;try{return t()}finally{e=r,n=l}}function v(e,t,n={}){let r,{immediate:l=!1,once:o=!1}=n,i=e instanceof f?()=>e.value:e,a=!0,u=!1,s=m(()=>{let e=i();if(a){if(a=!1,l&&!u){let n=e;_(()=>t(n,void 0)),o&&(u=!0,Promise.resolve().then(s))}r=e}else if(!u){let n=e,l=r;r=e,_(()=>t(n,l)),o&&(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,l;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&&(l=t)}catch(t){if(!e.onError)throw t;e.onError(t)}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function ie(e,t,n){let r,l;T();try{try{e.onInit?.()}catch{}r=e.render()._render(t,n)}finally{E()}try{let t=e.onMount?.();"function"==typeof t&&(l=t)}catch{}return()=>{try{e.onUnmount?.()}catch{}try{l?.()}catch{}r()}}function j(e,t,n,r){let l,o;D(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 ae(e,t,n,r,l){let o,i;T();try{try{e.onInit?.()}catch(t){if(!e.onError)throw t;e.onError(t)}o=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)}}),l.push(()=>{try{e.onUnmount?.()}catch{}try{i?.()}catch{}o()})}function oe(){return{__isPortalOutlet:!0,_container:null}}function se(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 ce(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,x(e)?re(e,l,null):e._render(l,null)}}}var M=S("nix:portal-outlet");function le(e){O(M,e)}function ue(){return k(M)}function de(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 fe(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 pe(e){return Math.max(0,...e.split(",").map(e=>parseFloat(e.trim())||0))}function N(e,t=0){return new Promise(n=>{let r=getComputedStyle(e),l=1e3*Math.max(pe(r.transitionDuration||"0"),pe(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 me(e,t={}){let n=fe(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(A.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 x(e)?ie(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 N(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 N(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||x(e))d(e);else{let t=e,n=null;h=m(()=>{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 he(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}}function ge(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?1:0);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?1:0);r+=o.slice(0,-t)+` data-nix-a-${l}="${e.attrName}"`,e.hadOpenQuote&&(n[l+1]=1)}}else r+=o}return r}function P(e){return"object"==typeof e&&!!e&&!0===e.__isNixTemplate}function _e(e){return"object"==typeof e&&!!e&&!0===e.__isKeyedList}var ve={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",delete:"Delete",backspace:"Backspace",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"},ye=new Set(["click","dblclick","mousedown","mouseup","keydown","keyup","input","change","submit"]),F=new Set;function be(e){let t=e.target,n=`__nix_${e.type}`,r=`__nix_${e.type}_mods`,l=e.stopPropagation,o=!1;for(e.stopPropagation=()=>{o=!0,l.call(e)};t&&t!==document;){let l=t[n];if(l){let n=t[r];if(n){if(n.includes("prevent")&&e.preventDefault(),n.includes("stop")&&e.stopPropagation(),n.includes("self")&&e.target!==t){t=t.parentNode;continue}if("key"in e){let r=e,l=!0;for(let e of n){let t=ve[e];if(void 0!==t&&r.key!==t){l=!1;break}if(!t&&1===e.length&&r.key.toLowerCase()!==e){l=!1;break}}if(!l){t=t.parentNode;continue}}}if(l(e),o)break}t=t.parentNode}e.stopPropagation=l}var I=new Set,L=!1;function R(e){I.add(e),L||(L=!0,queueMicrotask(()=>{for(let e of I)e();I.clear(),L=!1}))}function xe(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=[e];if(a>0){let t,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT),r=0;for(;r<a&&(t=n.nextNode());)r++,u.push(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(!ye.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 F.has(e)||(document.addEventListener(e,be),F.add(e)),c[`__nix_${e}`]=t,n.length>0&&(c[`__nix_${e}_mods`]=n),l.push(()=>{c[`__nix_${e}`]=null,c[`__nix_${e}_mods`]=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=m(()=>{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,R(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=m(()=>{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,R(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("");if(f.parentNode.replaceChild(d,f),"function"!=typeof u){if(x(u))ae(u,d.parentNode,d,o,l);else if(P(u)){let e=u._render(d.parentNode,d);l.push(e)}else if(Array.isArray(u))for(let e of u)x(e)?ae(e,d.parentNode,d,o,l):P(e)?e._render(d.parentNode,d):null!=e&&!1!==e&&d.parentNode.insertBefore(document.createTextNode(String(e)),d);else null!=u&&!1!==u&&d.parentNode.insertBefore(document.createTextNode(String(u)),d);continue}let p=null,h=null,v=null,y=[],g=null,_=w(),b=!1,N="",E=!0,S=m(()=>{let e=u();if("string"==typeof e||"number"==typeof e){N=String(e);let t=()=>{b=!1,h&&=(h(),null),p?p.nodeValue=N:(p=document.createTextNode(N),d.parentNode.insertBefore(p,d))};return void(E?(E=!1,t()):b||(b=!0,R(t)))}if(b=!1,E=!1,p&&=(p.parentNode?.removeChild(p),null),h&&=(h(),null),null!=e&&!1!==e)if(P(e))h=e._render(d.parentNode,d);else if(x(e))h=j(e,d.parentNode,d,_);else if(_e(e)){v||(v=new Map,g=document.createTextNode(""),d.parentNode.insertBefore(g,d));let t=d.parentNode,n=e.items.map((t,n)=>e.keyFn(t,n)),r=new Set(n),l=!1;if(v.size>0)for(let e of v.keys())if(r.has(e)){l=!0;break}if(!l){if(v.size>0){let e=document.createRange();e.setStartAfter(g),e.setEndBefore(d),e.deleteContents();for(let e of v.values())e.cleanup();v.clear()}if(n.length>0){let r=document.createDocumentFragment();for(let t=0;t<n.length;t++){let l=n[t],o=e.items[t],i=document.createTextNode(""),a=document.createTextNode("");r.appendChild(i),r.appendChild(a);let u=e.renderFn(o,t),s=x(u)?j(u,r,a,_):u._render(r,a);v.set(l,{start:i,end:a,cleanup:s})}t.insertBefore(r,d)}return void(y=n)}let o=new Map;for(let e=0;e<n.length;e++)o.set(n[e],e);let i=new Int32Array(n.length),a=!1,u=0;for(let e=0;e<y.length;e++){let t=y[e],n=o.get(t);if(void 0===n){let e=v.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}v.delete(t)}else i[n]=e+1,n>=u?u=n:a=!0}let s=a?Se(i):[],c=s.length-1,f=d;for(let r=n.length-1;r>=0;r--){let l=n[r];if(0===i[r]){let n=e.items[r],o=document.createTextNode(""),i=document.createTextNode(""),a=document.createDocumentFragment();a.appendChild(o),a.appendChild(i);let u=e.renderFn(n,r),s=x(u)?j(u,a,i,_):u._render(a,i);v.set(l,{start:o,end:i,cleanup:s}),t.insertBefore(a,f),f=o}else{let e=v.get(l);if(a)if(c<0||r!==s[c]){let n=e.start;for(;n;){let r=n===e.end?null:n.nextSibling;if(t.insertBefore(n,f),!r)break;n=r}}else c--;f=e.start}}y=n}else if(Array.isArray(e)){let t=[];for(let n of e)if(x(n))t.push(re(n,d.parentNode,d));else if(P(n))t.push(n._render(d.parentNode,d));else if(null!=n&&!1!==n){let e=document.createTextNode(String(n));d.parentNode.insertBefore(e,d),t.push(()=>e.parentNode?.removeChild(e))}h=()=>t.forEach(e=>e())}else p=document.createTextNode(String(e)),d.parentNode.insertBefore(p,d)});l.push(()=>{if(S(),h&&=(h(),null),p&&=(p.parentNode?.removeChild(p),null),v){for(let e of v.values())e.cleanup();v=null,g=null}})}return{disposes:l,postMountHooks:o}}function Se(e){let t,n,r,l,o,i=e.slice(),a=[0],u=e.length;for(t=0;t<u;t++){let u=e[t];if(0!==u){if(n=a[a.length-1],e[n]<u){i[t]=n,a.push(t);continue}for(r=0,l=a.length-1;r<l;)o=r+l>>1,e[a[o]]<u?r=o+1:l=o;u<e[a[r]]&&(r>0&&(i[t]=a[r-1]),a[r]=t)}}for(r=a.length,l=a[r-1];r-- >0;)a[r]=l,l=i[l];return a}var z=new WeakMap;function B(e,...t){let n=z.get(e);if(!n){let t=[],r="";for(let n=0;n<e.length-1;n++)r+=e[n],t.push(he(r)),r+="__nix__";let l=document.createElement("template");l.innerHTML=ge(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},z.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}=xe(i,r,t,o),s=document.createTextNode("");return e.insertBefore(s,n),e.insertBefore(i,n),u.forEach(e=>e()),()=>{for(let e=a.length-1;e>=0;e--)a[e]();let e=s.nextSibling;for(;e&&e!==n;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}s.parentNode?.removeChild(s)}}return{__isNixTemplate:!0,_render:i,mount(e){let t="string"==typeof e?document.querySelector(e):e;if(!t)throw Error(`[Nix] mount: contenedor no encontrado: ${e}`);let n=i(t,null);return{unmount(){n()}}}}}function Ce(e,t){if(x(e)){let n,r,l="string"==typeof t?document.querySelector(t):t;if(!l)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(l,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 we(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 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 V=null,H=null;function U(){if(!V)throw Error("[Nix] No active router. Call createRouter() first.");return V}function W(e){let t={};return new URLSearchParams(e).forEach((e,n)=>{t[n]=e}),t}function Te(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 Ee(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 De(e,t){return"*"===t?""===e?"*":e+"/*":(e+(t.startsWith("/")?t:"/"+t)).replace(/\/+/g,"/")||"/"}function G(e,t="",n=[]){let r=[];for(let l of e){let e=De(t,l.path),o=[...n,l.component],i=Ee(e);r.push({fullPath:e,segments:i,chain:o,beforeEnter:l.beforeEnter}),l.children?.length&&r.push(...G(l.children,e,o))}return r}function Oe(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 ke(e){return e.segments.reduce((e,t)=>"literal"===t.kind?e+2:"param"===t.kind?e+1:e,0)}function K(e,t){let n,r={},l=-1;for(let o of t){let t=Oe(e,o);if(null===t)continue;let i=ke(o);i>l&&(n=o,r=t,l=i)}return n?{route:n,params:r}:void 0}function q(e){let t=e.trim();return t&&"/"!==t?(t.startsWith("/")||(t="/"+t),t.endsWith("/")&&(t=t.slice(0,-1)),t):""}function Ae(){if(typeof document>"u")return"";let e=document.querySelector("base");if(!e)return"";let t=e.getAttribute("href")||"";try{return q(new URL(t,window.location.origin).pathname)}catch{return q(t)}}function je(e,t){let n=null==t?.base?Ae():q(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=G(e),a=K(o,i),u=p(o),s=p(a?.params??{}),c=p(W(window.location.search)),f=[],d=[],h=0;function m(e,t,n,r,l){let o=[...f];n&&o.push(n);let i=++h;if(0===o.length)return void r();let a=0;!function n(u){if(i!==h)return;if(!1===u)return void l?.();if("string"==typeof u)return void(u===e?r():x(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 y(e,t){let n=e.indexOf("?"),r=-1===n?e:e.slice(0,n),l=-1===n?{}:W(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}}H&&=(H(),null);let g=()=>{let e=r(),t=u.value,n=c.value,o=K(e,i),a=W(window.location.search);m(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)+Te(n))})};function _(e,t,n,r,o){s.value=r?.params??{},c.value=t,u.value=e;let i=l(e)+Te(t);o?history.replaceState(null,"",i):history.pushState(null,"",i);for(let t of d)try{t(e,n)}catch{}}function x(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=K(n,i);m(n,l,o?.route.beforeEnter,()=>_(n,r,l,o,!1))}window.addEventListener("popstate",g),H=()=>window.removeEventListener("popstate",g);let b={current:u,params:s,query:c,base:n||"/",navigate:x,replace:function(e,t){v=!0;let{pathname:n,stringQuery:r}=y(e,t),l=u.value,o=K(n,i);m(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=K(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 V&&console.warn("[Nix] A router already exists. The previous router is being replaced. Only one router instance should be active at a time."),V=b,queueMicrotask(()=>{v||m(o,"",K(o,i)?.route.beforeEnter,()=>{},()=>{history.replaceState(null,"",l("/"));let e=K("/",i);u.value="/",s.value=e?.params??{},c.value={}})}),b}function Me(){return U()}var Ne=class extends b{_depth;constructor(e=0){super(),this._depth=e}render(){let e=this._depth;return B`<div class="router-view">${()=>{let t=U(),n=K(t.current.value,t._flat);return n?e>=n.route.chain.length?B`<span></span>`:n.route.chain[e]():B`<div style="color:#f87171;padding:16px 0">
2
2
  404 — Route not found: <strong>${t.current.value}</strong>
3
3
  </div>`}}</div>`}},Pe=class extends b{_to;_label;constructor(e,t){super(),this._to=e,this._label=t}render(){let e=this._to,t=this._label;return B`<a
4
4
  href=${(U()._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 q=new Map,Le=3e5,J=null,Re=Le;function ze(){null===J&&(J=setInterval(()=>{let e=Date.now();for(let[t,n]of q)n.subscribers<=0&&e-n.fetchedAt>Re&&q.delete(t);0===q.size&&null!==J&&(clearInterval(J),J=null)},6e4))}function Y(e){return q.get(e)}function Be(e,t){let n=q.get(e);q.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),ze()}function Ve(e){let t=q.get(e);t&&t.subscribers++}function He(e){let t=q.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ue(e,t){let n=q.get(e);return!!n&&Date.now()-n.fetchedAt<t}function We(e){void 0===e?q.clear():q.delete(e)}function Ge(e){Re=e}function Ke(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??Fe(),c=l??Ie;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?Y(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ve(a);let e=a?Y(a):void 0;if(e&&Ue(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&q.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&He(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Be(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 X=new Map;function qe(e){q.delete(e);let t=X.get(e);if(t)for(let e of t)e()}function Je(e,t,n,r={}){let{fallback:l,errorFallback:o,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=l??Fe(),c=o??Ie;return new class extends b{_state;constructor(){super();let t=Y(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){X.has(e)||X.set(e,new Set);let t=X.get(e),n=()=>this._run();t.add(n),Ve(e);let r=Y(e),l=Ue(e,a);return r?!1===u||"stale"===u&&l||"always"===u&&l&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&X.delete(e),He(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Be(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 Ye(e,t){let n=null;return()=>n?new n:Ke(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Xe(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Z(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Ze(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function Qe(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function $e(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function et(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function tt(e){return e}const nt={required:Xe,minLength:Z,maxLength:Ze,email:Qe,pattern:Q,min:$e,max:et};function rt(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=p(e),l=p(!1),o=p(!1),i=p(null),a=p(!1),u=h(()=>{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 it(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=p(e.map(r)),o=h(()=>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 at(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=p(!1),o=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: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{Pe as Link,b as NixComponent,Ne as RouterView,f as Signal,g as batch,We as clearQueryCache,h as computed,ue as createErrorBoundary,at as createForm,S as createInjectionKey,ie as createPortalOutlet,Je as createQuery,je as createRouter,Ce as createStore,tt as createValidator,m as effect,Qe as email,rt as extendValidators,B as html,k as inject,le as injectOutlet,qe as invalidateQueries,Ye as lazy,et as max,Ze as maxLength,$e as min,Z as minLength,Se as mount,y as nextTick,Q as pattern,oe as portal,ae as portalOutlet,O as provide,ce as provideOutlet,ee as ref,ne as repeat,Xe as required,Ge as setQueryCacheTime,te as showWhen,p as signal,Ke as suspend,pe as transition,_ as untrack,$ as useField,it as useFieldArray,Me as useRouter,nt as validators,v as watch};
21
+ `}var J=new Map,Le=3e5,Y=null,Re=Le;function ze(){null===Y&&(Y=setInterval(()=>{let e=Date.now();for(let[t,n]of J)n.subscribers<=0&&e-n.fetchedAt>Re&&J.delete(t);0===J.size&&null!==Y&&(clearInterval(Y),Y=null)},6e4))}function X(e){return J.get(e)}function Be(e,t){let n=J.get(e);J.set(e,{data:t,fetchedAt:Date.now(),subscribers:n?.subscribers??0}),ze()}function Ve(e){let t=J.get(e);t&&t.subscribers++}function He(e){let t=J.get(e);t&&(t.subscribers=Math.max(0,t.subscribers-1))}function Ue(e,t){let n=J.get(e);return!!n&&Date.now()-n.fetchedAt<t}function We(e){void 0===e?J.clear():J.delete(e)}function Ge(e){Re=e}function Ke(e,t,n={}){let{fallback:r,errorFallback:l,resetOnRefresh:o=!1,invalidate:i,cacheKey:a,staleTime:u=0}=n,s=r??Fe(),c=l??Ie;return new class extends b{_state;_disposeWatcher;constructor(){super();let e=a?X(a):void 0;this._state=p(e?{status:"resolved",data:e.data}:{status:"pending"})}onMount(){a&&Ve(a);let e=a?X(a):void 0;if(e&&Ue(a,u)||(e?this._fetch():this._run()),i){let e=!0;this._disposeWatcher=m(()=>{i.value,e?e=!1:(a&&J.delete(a),this._run())})}return()=>{this._disposeWatcher?.(),a&&He(a)}}_run(){(o||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){e().then(e=>{a&&Be(a,e),this._state.value={status:"resolved",data:e}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 Z=new Map;function qe(e){J.delete(e);let t=Z.get(e);if(t)for(let e of t)e()}function Je(e,t,n,r={}){let{fallback:l,errorFallback:o,resetOnRefresh:i=!1,staleTime:a=0,refetchOnMount:u="always"}=r,s=l??Fe(),c=o??Ie;return new class extends b{_state;constructor(){super();let t=X(e);this._state=p(t?{status:"resolved",data:t.data}:{status:"pending"})}onMount(){Z.has(e)||Z.set(e,new Set);let t=Z.get(e),n=()=>this._run();t.add(n),Ve(e);let r=X(e),l=Ue(e,a);return r?!1===u||"stale"===u&&l||"always"===u&&l&&a>0||this._fetch():this._run(),()=>{t.delete(n),0===t.size&&Z.delete(e),He(e)}}_run(){(i||"pending"===this._state.peek().status)&&(this._state.value={status:"pending"}),this._fetch()}_fetch(){t().then(t=>{Be(e,t),this._state.value={status:"resolved",data:t}},e=>{this._state.value={status:"error",error:e}})}render(){return B`<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 Ye(e,t){let n=null;return()=>n?new n:Ke(async()=>(n=(await e()).default,n),e=>new e,{fallback:t})}function Xe(e="Required"){return t=>null==t||""===t||Array.isArray(t)&&0===t.length?e:null}function Ze(e,t){return n=>"string"==typeof n&&n.length<e?t??`Minimum ${e} characters`:null}function Qe(e,t){return n=>"string"==typeof n&&n.length>e?t??`Maximum ${e} characters`:null}function Q(e,t="Invalid format"){return n=>"string"!=typeof n||e.test(n)?null:t}function $e(e="Invalid email"){return Q(/^[^\s@]+@[^\s@]+\.[^\s@]+$/,e)}function et(e,t){return n=>"number"==typeof n&&n<e?t??`Minimum value is ${e}`:null}function tt(e,t){return n=>"number"==typeof n&&n>e?t??`Maximum value is ${e}`:null}function nt(e){return e}const rt={required:Xe,minLength:Ze,maxLength:Qe,email:$e,pattern:Q,min:et,max:tt};function it(e,t){return{...e,...t}}function $(e,t=[],n="blur"){let r=p(e),l=p(!1),o=p(!1),i=p(null),a=p(!1),u=h(()=>{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 at(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=p(e.map(r)),o=h(()=>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 ot(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=p(!1),o=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: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{Pe as Link,b as NixComponent,Ne as RouterView,f as Signal,g as batch,We as clearQueryCache,h as computed,de as createErrorBoundary,ot as createForm,S as createInjectionKey,oe as createPortalOutlet,Je as createQuery,je as createRouter,we as createStore,nt as createValidator,m as effect,$e as email,it as extendValidators,B as html,k as inject,ue as injectOutlet,qe as invalidateQueries,Ye as lazy,tt as max,Qe as maxLength,et as min,Ze as minLength,Ce as mount,y as nextTick,Q as pattern,ce as portal,se as portalOutlet,O as provide,le as provideOutlet,ee as ref,ne as repeat,Xe as required,Ge as setQueryCacheTime,te as showWhen,p as signal,Ke as suspend,me as transition,_ as untrack,$ as useField,at as useFieldArray,Me as useRouter,rt as validators,v as watch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deijose/nix-js",
3
- "version": "1.7.3-beta.1",
3
+ "version": "1.7.3-beta.10",
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/",