@unsetsoft/ryunixjs 1.2.4-canary.14 → 1.2.4-canary.15

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,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={})}(this,function(e){"use strict";let t={containerRoot:null,nextUnitOfWork:null,currentRoot:null,wipRoot:null,deletions:[],wipFiber:null,hookIndex:0,effects:[]};const r=()=>t,o=/[A-Z]/g,n=Object.freeze({TEXT_ELEMENT:Symbol.for("ryunix.text.element"),RYUNIX_ELEMENT:Symbol.for("ryunix.element"),RYUNIX_EFFECT:Symbol.for("ryunix.effect"),RYUNIX_MEMO:Symbol.for("ryunix.memo"),RYUNIX_URL_QUERY:Symbol.for("ryunix.urlQuery"),RYUNIX_REF:Symbol.for("ryunix.ref"),RYUNIX_STORE:Symbol.for("ryunix.store"),RYUNIX_REDUCE:Symbol.for("ryunix.reduce"),RYUNIX_FRAGMENT:Symbol.for("ryunix.fragment"),RYUNIX_CONTEXT:Symbol.for("ryunix.context")}),s=Object.freeze({OBJECT:"object",FUNCTION:"function",STYLE:"ryunix-style",CLASS_NAME:"ryunix-class",CHILDREN:"children",BOOLEAN:"boolean",STRING:"string",UNDEFINED:"undefined"}),i=Object.freeze({STYLE:"style",CLASS_NAME:"className"}),a=Object.freeze({PLACEMENT:Symbol.for("ryunix.reconciler.status.placement"),UPDATE:Symbol.for("ryunix.reconciler.status.update"),DELETION:Symbol.for("ryunix.reconciler.status.deletion"),NO_EFFECT:Symbol.for("ryunix.reconciler.status.no_effect"),HYDRATE:Symbol.for("ryunix.reconciler.status.hydrate")}),l=(e,t=1)=>Array.isArray(e)?t<1?e.slice():e.reduce((e,r)=>(Array.isArray(r)&&t>0?e.push(...l(r,t-1)):e.push(r),e),[]):[e],c=e=>null!==e&&typeof e===s.OBJECT,u=e=>typeof e===s.FUNCTION,d=e=>typeof e===s.STRING,p=e=>null===e,f=(e,t,...r)=>({type:e,props:{...t||{},children:r.flat().map(e=>{return typeof e===s.OBJECT?e:(t=e,{type:n.TEXT_ELEMENT,props:{nodeValue:t,children:[]}});var t})}}),h=e=>{const t=Array.isArray(e.children)?e.children:[e.children];return f(n.RYUNIX_FRAGMENT,{},...t)},y=e=>e.startsWith("on"),m=e=>e!==s.CHILDREN&&!y(e),E=(e,t)=>r=>!Object.is(e[r],t[r]),g=e=>t=>!(t in e),T=e=>{e&&(e.hooks?.length>0&&e.hooks.filter(e=>e.type===n.RYUNIX_EFFECT&&u(e.cancel)).forEach(e=>{try{e.cancel(),e.cancel=null}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in deep effect cleanup:",e)}}),e.child&&T(e.child),e.sibling&&T(e.sibling))},R=e=>{if(e?.hooks?.length)for(let t=0;t<e.hooks.length;t++){const r=e.hooks[t];if(r.type===n.RYUNIX_EFFECT&&u(r.effect)){if(u(r.cancel))try{r.cancel()}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in effect cleanup:",e)}try{const e=r.effect();u(e)?r.cancel=e:r.cancel=null}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in effect:",e),r.cancel=null}r.effect=null}}},N=e=>e.replace(o,e=>`-${e.toLowerCase()}`),b=(e,t,r)=>{if(!r||""===r.trim()){if(t){const r=t.split(/\s+/).filter(Boolean);e.classList.remove(...r)}return}if(t){const r=t.split(/\s+/).filter(Boolean);e.classList.remove(...r)}const o=r.split(/\s+/).filter(Boolean);o.length>0&&e.classList.add(...o)},w=e=>{if(e.type===n.RYUNIX_FRAGMENT||e.type===n.RYUNIX_CONTEXT)return null;let t;try{if(e.type===n.TEXT_ELEMENT)t=document.createTextNode("");else{if(!d(e.type))return"production"!==process.env.NODE_ENV&&console.warn("Attempted to create DOM for non-host component:",e.type),null;t=["svg","path","g","circle","polygon","rect","line","polyline","ellipse","text","tspan"].includes(e.type)?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type)}return S(t,{},e.props),t}catch(t){return"production"!==process.env.NODE_ENV&&console.error("Error creating DOM element:",t,e),null}},S=(e,t={},r={})=>{Object.keys(t).filter(y).filter(e=>g(r)(e)||E(t,r)(e)).forEach(r=>{const o=r.toLowerCase().substring(2);try{e.removeEventListener(o,t[r])}catch(e){"production"!==process.env.NODE_ENV&&console.warn("Error removing event listener:",e)}}),Object.keys(t).filter(m).filter(g(r)).forEach(t=>{if(![s.STYLE,i.STYLE,s.CLASS_NAME,i.CLASS_NAME].includes(t))if(e instanceof SVGElement){let r=t;"strokeWidth"===t&&(r="stroke-width"),"strokeLinecap"===t&&(r="stroke-linecap"),"strokeLinejoin"===t&&(r="stroke-linejoin"),"strokeDasharray"===t&&(r="stroke-dasharray"),"strokeDashoffset"===t&&(r="stroke-dashoffset"),"fillRule"===t&&(r="fill-rule"),"clipRule"===t&&(r="clip-rule"),e.removeAttribute(r)}else e[t]="",e.removeAttribute(t)}),Object.keys(r).filter(m).filter(E(t,r)).forEach(o=>{try{if(o===s.STYLE||o===i.STYLE){const t=r[o];((e,t)=>{if(c(t)&&!p(t))try{const r=Object.entries(t).filter(([e,t])=>null!=t).map(([e,t])=>`${N(e)}: ${t}`).join("; ");e.style.cssText=r}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error applying styles:",e)}else e.style.cssText=""})(e,t)}else if(o===s.CLASS_NAME)b(e,t[s.CLASS_NAME],r[s.CLASS_NAME]);else if(o===i.CLASS_NAME)b(e,t[i.CLASS_NAME],r[i.CLASS_NAME]);else if("value"===o||"checked"===o)e[o]!==r[o]&&(e[o]=r[o]);else{const t=e instanceof SVGElement;let n=o;t?("strokeWidth"===o&&(n="stroke-width"),"strokeLinecap"===o&&(n="stroke-linecap"),"strokeLinejoin"===o&&(n="stroke-linejoin"),"strokeDasharray"===o&&(n="stroke-dasharray"),"strokeDashoffset"===o&&(n="stroke-dashoffset"),"fillRule"===o&&(n="fill-rule"),"clipRule"===o&&(n="clip-rule"),e.setAttribute(n,r[o])):(e[o]=r[o],"object"!=typeof r[o]&&"function"!=typeof r[o]&&e.setAttribute(o,r[o]))}}catch(e){"production"!==process.env.NODE_ENV&&console.warn(`Error setting property ${o}:`,e)}}),Object.keys(r).filter(y).filter(E(t,r)).forEach(t=>{const o=t.toLowerCase().substring(2);try{e.addEventListener(o,r[t])}catch(e){"production"!==process.env.NODE_ENV&&console.warn("Error adding event listener:",e)}})},x=e=>{if(e)for(;e.firstChild;)e.removeChild(e.firstChild)},k=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const r=t.dom;if(e.effectTag===a.PLACEMENT)null!=e.dom&&r.appendChild(e.dom),R(e);else if(e.effectTag===a.UPDATE)(e=>{e?.hooks?.length&&e.hooks.filter(e=>e.type===n.RYUNIX_EFFECT&&u(e.cancel)).forEach(e=>{try{e.cancel(),e.cancel=null}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in effect cleanup:",e)}})})(e),null!=e.dom&&S(e.dom,e.alternate.props,e.props),R(e);else if(e.effectTag===a.HYDRATE)null!=e.dom&&S(e.dom,{},e.props),R(e);else if(e.effectTag===a.DELETION)return T(e),void v(e,r);k(e.child),k(e.sibling)},v=(e,t)=>{if(e.dom)t.removeChild(e.dom);else{let r=e.child;for(;r;)v(r,t),r=r.sibling}},_=(e,t)=>{const o=r();let n,s=0;const i=new Map;let l=e.alternate?.child,c=0;for(;l;){const e=l.key??`__index_${c}__`;i.set(e,l),l=l.sibling,c++}for(;s<t.length;){const r=t[s];if(!r){s++;continue}const l=r.key??`__index_${s}__`,c=i.get(l);let u;c&&r.type===c.type?(u={type:c.type,props:r.props,dom:c.dom,parent:e,alternate:c,effectTag:a.UPDATE,hooks:c.hooks,key:r.key},i.delete(l)):(u={type:r.type,props:r.props,dom:null,parent:e,alternate:null,effectTag:a.PLACEMENT,key:r.key},c&&(c.effectTag=a.DELETION,o.deletions.push(c),i.delete(l))),0===s?e.child=u:u&&(n.sibling=u),n=u,s++}i.forEach(e=>{e.effectTag=a.DELETION,o.deletions.push(e)})},C={IMMEDIATE:1,USER_BLOCKING:2,NORMAL:3,LOW:4,IDLE:5},A=()=>{const e=r();if(!e.wipFiber)throw new Error("Hooks can only be called inside the body of a function component.");Array.isArray(e.wipFiber.hooks)||(e.wipFiber.hooks=[])},I=(e,t)=>!e||!t||(e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))),O=e=>{if(r().isServerRendering)return[u(e)?e():e,()=>{}];return L((e,t)=>u(t)?t(e):t,e)},L=(e,t,o)=>{const s=r();if(s.isServerRendering)return[o?o(t):t,()=>{}];A();const{wipFiber:i,hookIndex:a}=s,l=i.alternate?.hooks?.[a],c={hookID:a,type:n.RYUNIX_STORE,state:l?l.state:o?o(t):t,queue:[]};l?.queue&&l.queue.forEach(t=>{try{c.state=e(c.state,t)}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in reducer:",e)}});return i.hooks[a]=c,s.hookIndex++,[c.state,e=>{if(void 0===e)return void("production"!==process.env.NODE_ENV&&console.warn("dispatch called with undefined action"));c.queue.push(e);const t=r();t.wipRoot=t.currentRoot?{dom:t.currentRoot.dom,props:t.currentRoot.props,alternate:t.currentRoot}:{dom:t.wipRoot?t.wipRoot.dom:t.containerRoot,props:t.wipRoot?t.wipRoot.props:{children:[]},alternate:null},t.deletions=[],t.hookIndex=0,ue(t.wipRoot)}]},M=(e,t)=>{const o=r();if(o.isServerRendering)return;if(A(),!u(e))throw new Error("useEffect callback must be a function");if(void 0!==t&&!Array.isArray(t))throw new Error("useEffect dependencies must be an array or undefined");const{wipFiber:s,hookIndex:i}=o,a=s.alternate?.hooks?.[i],l=I(a?.deps,t),c={hookID:i,type:n.RYUNIX_EFFECT,deps:t,effect:l?e:null,cancel:a?.cancel};s.hooks[i]=c,o.hookIndex++},D=e=>{const t=r();if(t.isServerRendering)return{current:e};A();const{wipFiber:o,hookIndex:s}=t,i=o.alternate?.hooks?.[s],a={hookID:s,type:n.RYUNIX_REF,value:i?i.value:{current:e}};return o.hooks[s]=a,t.hookIndex++,a.value},F=(e,t)=>{const o=r();if(o.isServerRendering)return e();if(A(),!u(e))throw new Error("useMemo callback must be a function");if(!Array.isArray(t))throw new Error("useMemo requires a dependencies array");const{wipFiber:s,hookIndex:i}=o,a=s.alternate?.hooks?.[i];let l;if(a&&!I(a.deps,t))l=a.value;else try{l=e()}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in useMemo computation:",e),l=void 0}const c={hookID:i,type:n.RYUNIX_MEMO,value:l,deps:t};return s.hooks[i]=c,o.hookIndex++,l},U=(e,t)=>{if(!u(e))throw new Error("useCallback requires a function as first argument");return F(()=>e,t)},X=(e=n.RYUNIX_CONTEXT,t={})=>{const o=({value:t,children:r})=>f(n.RYUNIX_CONTEXT,{value:t,children:r,_contextId:e},...l([r]));o._contextId=e;return{Provider:o,useContext:(o=e)=>{const n=r();if(n.isServerRendering)return n.ssrContexts&&void 0!==n.ssrContexts[o]?n.ssrContexts[o]:t;A();let s=n.wipFiber;for(;s;){if(s._contextId===o&&void 0!==s._contextValue)return s._contextValue;if(s.type?._contextId===o&&void 0!==s.props?.value)return s.props.value;s=s.parent}return t}}},Y=()=>{if("undefined"==typeof window)return{};const e=new URLSearchParams(window.location.search),t={};for(const[r,o]of e.entries())t[r]=o;return t},j=()=>{if("undefined"==typeof window)return"";const[e,t]=O(window.location.hash);return M(()=>{const e=()=>t(window.location.hash);return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]),e},$=(e={},t={})=>{M(()=>{if("undefined"==typeof document)return;let r="Ryunix App";const o=t.title?.template,n=t.title?.prefix||"Ryunix App",s=e.pageTitle||e.title;if(r=d(s)&&s.trim()?o?.includes("%s")?o.replace("%s",s):s:n,document.title=r,e.canonical){let t=document.querySelector('link[rel="canonical"]');t||(t=document.createElement("link"),t.setAttribute("rel","canonical"),document.head.appendChild(t)),t.setAttribute("href",e.canonical)}Object.entries(e).forEach(([e,t])=>{if(["title","pageTitle","canonical"].includes(e))return;const r=e.startsWith("og:")||e.startsWith("twitter:"),o=`meta[${r?"property":"name"}='${e}']`;let n=document.head.querySelector(o);n||(n=document.createElement("meta"),n.setAttribute(r?"property":"name",e),document.head.appendChild(n)),n.setAttribute("content",t)})},[JSON.stringify(e),JSON.stringify(t)])},P=X("ryunix.navigation",{location:"/",params:{},query:{},navigate:e=>{},route:null}),V=(e,t)=>{const r=t.split("?")[0].split("#")[0],o=e.find(e=>e.NotFound),n=o?{route:{component:o.NotFound},params:{}}:{route:{component:null},params:{}};for(const o of e){if(o.subRoutes){const e=V(o.subRoutes,t);if(e)return e}if("*"===o.path)return n;if(!o.path||"string"!=typeof o.path)continue;const e=[],s=new RegExp(`^${o.path.replace(/:(\.\.\.)?(\w+)/g,(t,r,o)=>(e.push({key:o,isCatchAll:!!r}),r?"(.+)":"([^/]+)"))}$`),i=r.match(s);if(i){return{route:o,params:e.reduce((e,t,r)=>{const o=i[r+1];return e[t.key]=t.isCatchAll&&o?o.split("/"):o,e},{})}}}return n},H=({routes:e,children:t})=>{const[r,o]=O(window.location.pathname);M(()=>{const e=()=>o(window.location.pathname);return window.addEventListener("popstate",e),window.addEventListener("hashchange",e),()=>{window.removeEventListener("popstate",e),window.removeEventListener("hashchange",e)}},[r]);const n=V(e,r)||{},s=Y(),i={location:r,params:n.params||{},query:s,navigate:e=>{window.history.pushState({},"",e),o(e)},route:n.route};return f(P.Provider,{value:i},h({children:t}))},q=()=>P.useContext("ryunix.navigation"),G=()=>{const{route:e,params:t,query:r,location:o}=q();if(!e||!e.component)return null;const n=j();return M(()=>{if(n){const e=n.slice(1),t=document.getElementById(e);t&&t.scrollIntoView({block:"start",behavior:"smooth"})}},[n]),f(e.component,{key:o,params:t,query:r,hash:n})},W=({to:e,exact:t=!1,...r})=>{const{location:o,navigate:n}=q(),s=t?o===e:o.startsWith(e),i=r["ryunix-class"]?"ryunix-class":"className",a="function"==typeof(l=r["ryunix-class"]||r.className)?l({isActive:s}):l||"";var l;const{"ryunix-class":c,className:u,...d}=r;return f("a",{href:e,onClick:t=>{t.preventDefault(),n(e)},[i]:a,...d},r.children)},B=e=>{const[t,r]=L((e,t)=>"function"==typeof t?t.value(e):t.value,e);return[t,(e,t=C.NORMAL)=>{r({value:e,priority:t})}]},z=()=>{const[e,t]=B(!1);return[e,e=>{t(!0,C.IMMEDIATE),setTimeout(()=>{e(),t(!1,C.IMMEDIATE)},0)}]},J=e=>{const[t,r]=B(e);return M(()=>{const t=setTimeout(()=>{r(e,C.LOW)},100);return()=>clearTimeout(t)},[e]),t},Q=(e,t="")=>{const[r,o]=O(()=>{try{const r=window.localStorage.getItem(e);return r?JSON.parse(r):t}catch(e){return t}});return[r,t=>{try{o(t),window.localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}]},K=(e=!1)=>{const[t,r]=O(e);return[t,()=>{r(!t)}]};var Z=Object.freeze({__proto__:null,Children:G,NavLink:W,RouterProvider:H,createContext:X,useCallback:U,useDeferredValue:J,useEffect:M,useHash:j,useMemo:F,useMetadata:$,usePersitentStore:Q,useQuery:Y,useReducer:L,useRef:D,useRouter:q,useStore:O,useStorePriority:B,useSwitch:K,useTransition:z});const{Provider:ee,useContext:te}=X("ryunix.mdx",{}),re=e=>({...te(),...e}),oe={h1:e=>f("h1",{...e}),h2:e=>f("h2",{...e}),h3:e=>f("h3",{...e}),h4:e=>f("h4",{...e}),h5:e=>f("h5",{...e}),h6:e=>f("h6",{...e}),p:e=>f("p",{...e}),a:e=>f("a",{...e}),strong:e=>f("strong",{...e}),em:e=>f("em",{...e}),code:e=>f("code",{...e}),ul:e=>f("ul",{...e}),ol:e=>f("ol",{...e}),li:e=>f("li",{...e}),blockquote:e=>f("blockquote",{...e}),pre:e=>f("pre",{...e}),hr:e=>f("hr",{...e}),table:e=>f("table",{...e}),thead:e=>f("thead",{...e}),tbody:e=>f("tbody",{...e}),tr:e=>f("tr",{...e}),th:e=>f("th",{...e}),td:e=>f("td",{...e}),img:e=>f("img",{...e})};const ne=new class{constructor(){this.enabled="production"!==process.env.NODE_ENV,this.measures=new Map,this.renderTimes=[],this.maxSamples=100}startMeasure(e){this.enabled&&this.measures.set(e,performance.now())}endMeasure(e){if(!this.enabled)return;const t=this.measures.get(e);if(!t)return;const r=performance.now()-t;return this.measures.delete(e),r}recordRender(e,t){this.enabled&&(this.renderTimes.push({component:e,duration:t,timestamp:Date.now()}),this.renderTimes.length>this.maxSamples&&this.renderTimes.shift())}getStats(){if(!this.enabled)return null;const e=this.renderTimes.reduce((e,t)=>e+t.duration,0);return{total:e,avg:e/this.renderTimes.length,max:Math.max(...this.renderTimes.map(e=>e.duration)),min:Math.min(...this.renderTimes.map(e=>e.duration)),count:this.renderTimes.length}}getSlowestComponents(e=10){if(!this.enabled)return[];const t=new Map;return this.renderTimes.forEach(({component:e,duration:r})=>{t.has(e)||t.set(e,{total:0,count:0,max:0});const o=t.get(e);o.total+=r,o.count++,o.max=Math.max(o.max,r)}),Array.from(t.entries()).map(([e,t])=>({name:e,avg:t.total/t.count,max:t.max,count:t.count})).sort((e,t)=>t.avg-e.avg).slice(0,e)}logStats(){if(!this.enabled)return;const e=this.getStats();if(!e)return;console.group("šŸ” Ryunix Performance Stats"),console.log(`Total renders: ${e.count}`),console.log(`Avg render time: ${e.avg.toFixed(2)}ms`),console.log(`Min: ${e.min.toFixed(2)}ms | Max: ${e.max.toFixed(2)}ms`);const t=this.getSlowestComponents(5);t.length>0&&(console.log("\nāš ļø Slowest components:"),t.forEach((e,t)=>{console.log(`${t+1}. ${e.name}: ${e.avg.toFixed(2)}ms avg (${e.count} renders)`)})),console.groupEnd()}clear(){this.renderTimes=[],this.measures.clear()}enable(){this.enabled=!0}disable(){this.enabled=!1}},se=e=>{const t=performance.now();return()=>{const r=performance.now()-t;ne.recordRender(e,r)}},ie=(e,t)=>r=>{ne.startMeasure(t);const o=e(r),n=ne.endMeasure(t);return n&&ne.recordRender(t,n),o},ae="undefined"!=typeof requestIdleCallback?requestIdleCallback:e=>setTimeout(()=>e({timeRemaining:()=>1}),1),le=e=>{const t=r();let o=!1;for(;t.nextUnitOfWork&&!o;)t.nextUnitOfWork=ce(t.nextUnitOfWork),o=e.timeRemaining()<1;!t.nextUnitOfWork&&t.wipRoot&&(()=>{const e=r();e.deletions.forEach(k),k(e.wipRoot.child),e.currentRoot=e.wipRoot,e.wipRoot=null})(),ae(le)};ae(le);const ce=e=>{const t=e.type?.name||e.type?.displayName||"Unknown";ne.startMeasure(t);e.type instanceof Function?(e=>{const t=r();t.wipFiber=e,t.hookIndex=0,t.wipFiber.hooks=[],t.isHydrating&&(e.effectTag=t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"));const o=[e.type(e.props)];e.type._contextId&&void 0!==e.props.value&&(e._contextId=e.type._contextId,e._contextValue=e.props.value),_(e,o)})(e):(e=>{const t=r();e.type===n.RYUNIX_CONTEXT&&(e._contextId=e.props?._contextId,e._contextValue=e.props?.value);const o=e.type===n.RYUNIX_FRAGMENT||e.type===n.RYUNIX_CONTEXT;if(t.isHydrating&&o)e.effectTag=t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate");else if(!e.dom)if(t.isHydrating&&t.hydrateCursor){const r=t.hydrateCursor,o=e.type===n.TEXT_ELEMENT&&3===r.nodeType,s="string"==typeof e.type&&1===r.nodeType&&r.tagName.toLowerCase()===e.type.toLowerCase();o||s?(e.dom=r,e.effectTag=t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"),t.hydrateCursor=r.nextSibling):(console.warn(`[Hydration] Mismatch at ${e.type}. Falling back to CSR.`),t.isHydrating=!1,x(t.containerRoot),e.dom=w(e),e.effectTag=t.EFFECT_TAGS?.PLACEMENT||Symbol.for("ryunix.reconciler.status.placement"))}else e.dom=w(e);let s=t.hydrateCursor;const i=null!=e.dom;t.isHydrating&&i&&e.effectTag===(t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"))&&(t.hydrateCursor=e.dom.firstChild);const a=e.props?.children||[];_(e,a),t.isHydrating&&e.effectTag===(t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"))&&i&&(t.hydrateCursor=s)})(e);const o=ne.endMeasure(t);if(o&&ne.recordRender(t,o),e.child)return e.child;let s=e;for(;s;){if(s.sibling)return s.sibling;s=s.parent}},ue=(e,t=C.NORMAL)=>{const o=r();o.nextUnitOfWork=e,o.wipRoot=e,o.deletions=[],o.hookIndex=0,o.effects=[],t<=C.USER_BLOCKING?ae(le):setTimeout(()=>ae(le),0)},de=(e,t)=>{const o=r();return x(t),o.wipRoot={dom:t,props:{children:[e]},alternate:o.currentRoot},o.isHydrating=!1,o.nextUnitOfWork=o.wipRoot,o.deletions=[],ue(o.wipRoot),o.wipRoot},pe=(e,t)=>(x(t),de(e,t)),fe=(e,t="__ryunix")=>{const o=r();return o.containerRoot=document.getElementById(t),process.env.RYUNIX_SSR&&o.containerRoot.hasChildNodes()?pe(e,o.containerRoot):de(e,o.containerRoot)},he=(e,t,r)=>{try{return e(t)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("Component error:",e),r&&r(e),null}},ye=e=>"string"!=typeof e?String(e):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),me=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ee=e=>{if(null==e||"boolean"==typeof e)return"";if("string"==typeof e||"number"==typeof e)return ye(e);if(e.type===n.TEXT_ELEMENT)return ye(e.props.nodeValue);if(e.type===n.RYUNIX_FRAGMENT){return(e.props?.children||[]).map(e=>Ee(e)).join("")}if(e.type===n.RYUNIX_CONTEXT){const t=r();t.ssrContexts=t.ssrContexts||{};const o=e.props?._contextId,n=t.ssrContexts[o];o&&(t.ssrContexts[o]=e.props?.value);const s=e.props?.children||[];let i="";return i=Array.isArray(s)?s.map(e=>Ee(e)).join(""):Ee(s),o&&(t.ssrContexts[o]=n),i}if("function"==typeof e.type){const t=e.props||{},r=e.type(t);return Ee(r)}const t=e.type,o=e.props||{};let a="",l="",u=null;if(Object.entries(o).forEach(([e,t])=>{if("children"===e)l=Array.isArray(t)?t.map(e=>Ee(e)).join(""):Ee(t);else if("dangerouslySetInnerHTML"===e&&t?.__html)u=t.__html;else if(e===s.STYLE||e===i.STYLE){const e=!c(r=t)||p(r)?"":Object.entries(r).filter(([e,t])=>null!=t).map(([e,t])=>`${N(e)}:${t}`).join(";");e&&(a+=` style="${ye(e)}"`)}else if(e===s.CLASS_NAME||e===i.CLASS_NAME)t&&(a+=` class="${ye(t)}"`);else if(!e.startsWith("on"))if("boolean"==typeof t)t&&(a+=` ${e}=""`);else if(null!=t){let r=e;"strokeWidth"===e&&(r="stroke-width"),"strokeLinecap"===e&&(r="stroke-linecap"),"strokeLinejoin"===e&&(r="stroke-linejoin"),"strokeDasharray"===e&&(r="stroke-dasharray"),"strokeDashoffset"===e&&(r="stroke-dashoffset"),"fillRule"===e&&(r="fill-rule"),"clipRule"===e&&(r="clip-rule"),a+=` ${r}="${ye(t)}"`}var r}),me.has(t))return`<${t}${a} />`;return`<${t}${a}>${null!==u?u:l}</${t}>`},ge=e=>{const t=r(),o=t.isServerRendering;t.isServerRendering=!0;try{return Ee(e)}finally{t.isServerRendering=o}},Te=(e,t)=>t=>F(()=>e(t),[...Object.values(t)]),Re=e=>{let t=null,r=null,o=null;return n=>{const[,s]=O(0);if(M(()=>{t||o||r||(r=e().then(e=>{t=e.default||e,s(e=>e+1)}).catch(e=>{o=e,s(e=>e+1)}))},[]),o)throw o;return t?f(t,n):null}},Ne=({fallback:e,children:t})=>{const[r,o]=O(!0);return M(()=>{o(!1)},[]),r&&e?e:t};let be=!1,we=[];const Se=e=>{const t=be;be=!0;try{e()}finally{be=t,!be&&we.length>0&&xe()}},xe=()=>{if(0===we.length)return;const e=we;we=[],e.forEach(e=>e())};var ke=Object.freeze({__proto__:null,Children:G,Fragment:h,Hooks:Z,NavLink:W,Priority:C,RouterProvider:H,Suspense:Ne,batchUpdates:Se,createContext:X,createElement:f,hydrate:pe,init:fe,lazy:Re,memo:Te,profiler:ne,render:de,renderToString:ge,safeRender:he,useCallback:U,useDeferredValue:J,useEffect:M,useHash:j,useMemo:F,useMetadata:$,usePersitentStore:Q,useProfiler:se,useQuery:Y,useReducer:L,useRef:D,useRouter:q,useStore:O,useStorePriority:B,useSwitch:K,useTransition:z,withProfiler:ie});"undefined"!=typeof window&&(window.Ryunix=ke),e.Children=G,e.Fragment=h,e.Hooks=Z,e.Image=({src:e,...t})=>f("img",{...t,src:e}),e.MDXContent=({children:e,components:t={}})=>{const r=re(t);return f(ee,{value:r},f("div",null,e))},e.MDXProvider=ee,e.NavLink=W,e.Priority=C,e.RouterProvider=H,e.Suspense=Ne,e.batchUpdates=Se,e.createContext=X,e.createElement=f,e.default=ke,e.defaultComponents=oe,e.getMDXComponents=re,e.hydrate=pe,e.init=fe,e.lazy=Re,e.memo=Te,e.profiler=ne,e.render=de,e.renderToString=ge,e.safeRender=he,e.useCallback=U,e.useDeferredValue=J,e.useEffect=M,e.useHash=j,e.useMDXComponents=te,e.useMemo=F,e.useMetadata=$,e.usePersitentStore=Q,e.useProfiler=se,e.useQuery=Y,e.useReducer=L,e.useRef=D,e.useRouter=q,e.useStore=O,e.useStorePriority=B,e.useSwitch=K,e.useTransition=z,e.withProfiler=ie,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={})}(this,function(e){"use strict";let t={containerRoot:null,nextUnitOfWork:null,currentRoot:null,wipRoot:null,deletions:[],wipFiber:null,hookIndex:0,effects:[]};const r=()=>t,o=/[A-Z]/g,n=Object.freeze({TEXT_ELEMENT:Symbol.for("ryunix.text.element"),RYUNIX_ELEMENT:Symbol.for("ryunix.element"),RYUNIX_EFFECT:Symbol.for("ryunix.effect"),RYUNIX_MEMO:Symbol.for("ryunix.memo"),RYUNIX_URL_QUERY:Symbol.for("ryunix.urlQuery"),RYUNIX_REF:Symbol.for("ryunix.ref"),RYUNIX_STORE:Symbol.for("ryunix.store"),RYUNIX_REDUCE:Symbol.for("ryunix.reduce"),RYUNIX_FRAGMENT:Symbol.for("ryunix.fragment"),RYUNIX_CONTEXT:Symbol.for("ryunix.context")}),s=Object.freeze({OBJECT:"object",FUNCTION:"function",STYLE:"ryunix-style",CLASS_NAME:"ryunix-class",CHILDREN:"children",BOOLEAN:"boolean",STRING:"string",UNDEFINED:"undefined"}),i=Object.freeze({STYLE:"style",CLASS_NAME:"className"}),a=Object.freeze({PLACEMENT:Symbol.for("ryunix.reconciler.status.placement"),UPDATE:Symbol.for("ryunix.reconciler.status.update"),DELETION:Symbol.for("ryunix.reconciler.status.deletion"),NO_EFFECT:Symbol.for("ryunix.reconciler.status.no_effect"),HYDRATE:Symbol.for("ryunix.reconciler.status.hydrate")}),l=(e,t=1)=>Array.isArray(e)?t<1?e.slice():e.reduce((e,r)=>(Array.isArray(r)&&t>0?e.push(...l(r,t-1)):e.push(r),e),[]):[e],c=e=>null!==e&&typeof e===s.OBJECT,u=e=>typeof e===s.FUNCTION,d=e=>typeof e===s.STRING,p=e=>null===e,f=(e,t,...r)=>({type:e,props:{...t||{},children:r.flat().map(e=>{return typeof e===s.OBJECT?e:(t=e,{type:n.TEXT_ELEMENT,props:{nodeValue:t,children:[]}});var t})}}),h=e=>{const t=Array.isArray(e.children)?e.children:[e.children];return f(n.RYUNIX_FRAGMENT,{},...t)},y=e=>e.startsWith("on"),m=e=>e!==s.CHILDREN&&!y(e),E=(e,t)=>r=>!Object.is(e[r],t[r]),g=e=>t=>!(t in e),T=e=>{e&&(e.hooks?.length>0&&e.hooks.filter(e=>e.type===n.RYUNIX_EFFECT&&u(e.cancel)).forEach(e=>{try{e.cancel(),e.cancel=null}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in deep effect cleanup:",e)}}),e.child&&T(e.child),e.sibling&&T(e.sibling))},N=e=>{if(e?.hooks?.length)for(let t=0;t<e.hooks.length;t++){const r=e.hooks[t];if(r.type===n.RYUNIX_EFFECT&&u(r.effect)){if(u(r.cancel))try{r.cancel()}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in effect cleanup:",e)}try{const e=r.effect();u(e)?r.cancel=e:r.cancel=null}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in effect:",e),r.cancel=null}r.effect=null}}},R=e=>e.replace(o,e=>`-${e.toLowerCase()}`),b=(e,t,r)=>{if(!r||""===r.trim()){if(t){const r=t.split(/\s+/).filter(Boolean);e.classList.remove(...r)}return}if(t){const r=t.split(/\s+/).filter(Boolean);e.classList.remove(...r)}const o=r.split(/\s+/).filter(Boolean);o.length>0&&e.classList.add(...o)},S=e=>{if(e.type===n.RYUNIX_FRAGMENT||e.type===n.RYUNIX_CONTEXT)return null;let t;try{if(e.type===n.TEXT_ELEMENT)t=document.createTextNode("");else{if(!d(e.type))return"production"!==process.env.NODE_ENV&&console.warn("Attempted to create DOM for non-host component:",e.type),null;t=["svg","path","g","circle","polygon","rect","line","polyline","ellipse","text","tspan"].includes(e.type)?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type)}return x(t,{},e.props),t}catch(t){return"production"!==process.env.NODE_ENV&&console.error("Error creating DOM element:",t,e),null}},x=(e,t={},r={})=>{Object.keys(t).filter(y).filter(e=>g(r)(e)||E(t,r)(e)).forEach(r=>{const o=r.toLowerCase().substring(2);try{e.removeEventListener(o,t[r])}catch(e){"production"!==process.env.NODE_ENV&&console.warn("Error removing event listener:",e)}}),Object.keys(t).filter(m).filter(g(r)).forEach(t=>{if(![s.STYLE,i.STYLE,s.CLASS_NAME,i.CLASS_NAME].includes(t))if(e instanceof SVGElement){let r=t;"strokeWidth"===t&&(r="stroke-width"),"strokeLinecap"===t&&(r="stroke-linecap"),"strokeLinejoin"===t&&(r="stroke-linejoin"),"strokeDasharray"===t&&(r="stroke-dasharray"),"strokeDashoffset"===t&&(r="stroke-dashoffset"),"fillRule"===t&&(r="fill-rule"),"clipRule"===t&&(r="clip-rule"),e.removeAttribute(r)}else e[t]="",e.removeAttribute(t)}),Object.keys(r).filter(m).filter(E(t,r)).forEach(o=>{try{if(o===s.STYLE||o===i.STYLE){const t=r[o];((e,t)=>{if(c(t)&&!p(t))try{const r=Object.entries(t).filter(([e,t])=>null!=t).map(([e,t])=>`${R(e)}: ${t}`).join("; ");e.style.cssText=r}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error applying styles:",e)}else e.style.cssText=""})(e,t)}else if(o===s.CLASS_NAME)b(e,t[s.CLASS_NAME],r[s.CLASS_NAME]);else if(o===i.CLASS_NAME)b(e,t[i.CLASS_NAME],r[i.CLASS_NAME]);else if("value"===o||"checked"===o)e[o]!==r[o]&&(e[o]=r[o]);else{const t=e instanceof SVGElement;let n=o;t?("strokeWidth"===o&&(n="stroke-width"),"strokeLinecap"===o&&(n="stroke-linecap"),"strokeLinejoin"===o&&(n="stroke-linejoin"),"strokeDasharray"===o&&(n="stroke-dasharray"),"strokeDashoffset"===o&&(n="stroke-dashoffset"),"fillRule"===o&&(n="fill-rule"),"clipRule"===o&&(n="clip-rule"),e.setAttribute(n,r[o])):(e[o]=r[o],"object"!=typeof r[o]&&"function"!=typeof r[o]&&e.setAttribute(o,r[o]))}}catch(e){"production"!==process.env.NODE_ENV&&console.warn(`Error setting property ${o}:`,e)}}),Object.keys(r).filter(y).filter(E(t,r)).forEach(t=>{const o=t.toLowerCase().substring(2);try{e.addEventListener(o,r[t])}catch(e){"production"!==process.env.NODE_ENV&&console.warn("Error adding event listener:",e)}})},w=e=>{if(e)for(;e.firstChild;)e.removeChild(e.firstChild)},k=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const r=t.dom;if(e.effectTag===a.PLACEMENT)null!=e.dom&&r.appendChild(e.dom),N(e);else if(e.effectTag===a.UPDATE)(e=>{e?.hooks?.length&&e.hooks.filter(e=>e.type===n.RYUNIX_EFFECT&&u(e.cancel)).forEach(e=>{try{e.cancel(),e.cancel=null}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in effect cleanup:",e)}})})(e),null!=e.dom&&x(e.dom,e.alternate.props,e.props),N(e);else if(e.effectTag===a.HYDRATE)null!=e.dom&&x(e.dom,{},e.props),N(e);else if(e.effectTag===a.DELETION)return T(e),void v(e);k(e.child),k(e.sibling)},v=(e,t)=>{if(e.dom)e.dom.parentNode&&e.dom.parentNode.removeChild(e.dom);else{let t=e.child;for(;t;)v(t),t=t.sibling}},_=(e,t)=>{const o=r();let n,s=0,i=!0;const l=new Map;let c=e.alternate?.child,u=0;for(;c;){const e=c.key??`__index_${c.index??u}__`;l.set(e,c),c=c.sibling,u++}for(;s<t.length;){const r=t[s];if(!r){s++;continue}const c=r.key??`__index_${s}__`,u=l.get(c);let d;u&&r.type===u.type?(d={type:u.type,props:r.props,dom:u.dom,parent:e,alternate:u,effectTag:a.UPDATE,hooks:u.hooks,key:r.key,index:s},l.delete(c)):(d={type:r.type,props:r.props,dom:null,parent:e,alternate:null,effectTag:a.PLACEMENT,key:r.key,index:s},u&&(u.effectTag=a.DELETION,o.deletions.push(u),l.delete(c))),i?(e.child=d,i=!1):d&&(n.sibling=d),n=d,s++}l.forEach(e=>{e.effectTag=a.DELETION,o.deletions.push(e)})},C={IMMEDIATE:1,USER_BLOCKING:2,NORMAL:3,LOW:4,IDLE:5},A=()=>{const e=r();if(!e.wipFiber)throw new Error("Hooks can only be called inside the body of a function component.");Array.isArray(e.wipFiber.hooks)||(e.wipFiber.hooks=[])},I=(e,t)=>!e||!t||(e.length!==t.length||e.some((e,r)=>!Object.is(e,t[r]))),O=e=>{if(r().isServerRendering)return[u(e)?e():e,()=>{}];return L((e,t)=>u(t)?t(e):t,e)},L=(e,t,o)=>{const s=r();if(s.isServerRendering)return[o?o(t):t,()=>{}];A();const{wipFiber:i,hookIndex:a}=s,l=i.alternate?.hooks?.[a],c={hookID:a,type:n.RYUNIX_STORE,state:l?l.state:o?o(t):t,queue:[]};l?.queue&&l.queue.forEach(t=>{try{c.state=e(c.state,t)}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in reducer:",e)}});return i.hooks[a]=c,s.hookIndex++,[c.state,e=>{if(void 0===e)return void("production"!==process.env.NODE_ENV&&console.warn("dispatch called with undefined action"));c.queue.push(e);const t=r();t.wipRoot={dom:t.currentRoot.dom,props:t.currentRoot.props,alternate:t.currentRoot},t.deletions=[],t.hookIndex=0,ue(t.wipRoot)}]},M=(e,t)=>{const o=r();if(o.isServerRendering)return;if(A(),!u(e))throw new Error("useEffect callback must be a function");if(void 0!==t&&!Array.isArray(t))throw new Error("useEffect dependencies must be an array or undefined");const{wipFiber:s,hookIndex:i}=o,a=s.alternate?.hooks?.[i],l=I(a?.deps,t),c={hookID:i,type:n.RYUNIX_EFFECT,deps:t,effect:l?e:null,cancel:a?.cancel};s.hooks[i]=c,o.hookIndex++},D=e=>{const t=r();if(t.isServerRendering)return{current:e};A();const{wipFiber:o,hookIndex:s}=t,i=o.alternate?.hooks?.[s],a={hookID:s,type:n.RYUNIX_REF,value:i?i.value:{current:e}};return o.hooks[s]=a,t.hookIndex++,a.value},F=(e,t)=>{const o=r();if(o.isServerRendering)return e();if(A(),!u(e))throw new Error("useMemo callback must be a function");if(!Array.isArray(t))throw new Error("useMemo requires a dependencies array");const{wipFiber:s,hookIndex:i}=o,a=s.alternate?.hooks?.[i];let l;if(a&&!I(a.deps,t))l=a.value;else try{l=e()}catch(e){"production"!==process.env.NODE_ENV&&console.error("Error in useMemo computation:",e),l=void 0}const c={hookID:i,type:n.RYUNIX_MEMO,value:l,deps:t};return s.hooks[i]=c,o.hookIndex++,l},U=(e,t)=>{if(!u(e))throw new Error("useCallback requires a function as first argument");return F(()=>e,t)},X=(e=n.RYUNIX_CONTEXT,t={})=>{const o=({value:t,children:r})=>f(n.RYUNIX_CONTEXT,{value:t,children:r,_contextId:e},...l([r]));o._contextId=e;return{Provider:o,useContext:(o=e)=>{const n=r();if(n.isServerRendering)return n.ssrContexts&&void 0!==n.ssrContexts[o]?n.ssrContexts[o]:t;A();let s=n.wipFiber;for(;s;){if(s._contextId===o&&void 0!==s._contextValue)return s._contextValue;if(s.type?._contextId===o&&void 0!==s.props?.value)return s.props.value;s=s.parent}return t}}},Y=()=>{if("undefined"==typeof window)return{};const e=new URLSearchParams(window.location.search),t={};for(const[r,o]of e.entries())t[r]=o;return t},j=()=>{if("undefined"==typeof window)return"";const[e,t]=O(window.location.hash);return M(()=>{const e=()=>t(window.location.hash);return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)},[]),e},$=(e={},t={})=>{M(()=>{if("undefined"==typeof document)return;let r="Ryunix App";const o=t.title?.template,n=t.title?.prefix||"Ryunix App",s=e.pageTitle||e.title;if(r=d(s)&&s.trim()?o?.includes("%s")?o.replace("%s",s):s:n,document.title=r,e.canonical){let t=document.querySelector('link[rel="canonical"]');t||(t=document.createElement("link"),t.setAttribute("rel","canonical"),document.head.appendChild(t)),t.setAttribute("href",e.canonical)}Object.entries(e).forEach(([e,t])=>{if(["title","pageTitle","canonical"].includes(e))return;const r=e.startsWith("og:")||e.startsWith("twitter:"),o=`meta[${r?"property":"name"}='${e}']`;let n=document.head.querySelector(o);n||(n=document.createElement("meta"),n.setAttribute(r?"property":"name",e),document.head.appendChild(n)),n.setAttribute("content",t)})},[JSON.stringify(e),JSON.stringify(t)])},P=X("ryunix.navigation",{location:"/",params:{},query:{},navigate:e=>{},route:null}),V=(e,t)=>{const r=t.split("?")[0].split("#")[0],o=e.find(e=>e.NotFound),n=o?{route:{component:o.NotFound},params:{}}:{route:{component:null},params:{}};for(const o of e){if(o.subRoutes){const e=V(o.subRoutes,t);if(e)return e}if("*"===o.path)return n;if(!o.path||"string"!=typeof o.path)continue;const e=[],s=new RegExp(`^${o.path.replace(/:(\.\.\.)?(\w+)/g,(t,r,o)=>(e.push({key:o,isCatchAll:!!r}),r?"(.+)":"([^/]+)"))}$`),i=r.match(s);if(i){return{route:o,params:e.reduce((e,t,r)=>{const o=i[r+1];return e[t.key]=t.isCatchAll&&o?o.split("/"):o,e},{})}}}return n},H=({routes:e,children:t})=>{const[r,o]=O(window.location.pathname);M(()=>{const e=()=>o(window.location.pathname);return window.addEventListener("popstate",e),window.addEventListener("hashchange",e),()=>{window.removeEventListener("popstate",e),window.removeEventListener("hashchange",e)}},[r]);const n=V(e,r)||{},s=Y(),i={location:r,params:n.params||{},query:s,navigate:e=>{window.history.pushState({},"",e),o(e)},route:n.route};return f(P.Provider,{value:i},h({children:t}))},q=()=>P.useContext("ryunix.navigation"),G=()=>{const{route:e,params:t,query:r,location:o}=q();if(!e||!e.component)return null;const n=j();return M(()=>{if(n){const e=n.slice(1),t=document.getElementById(e);t&&t.scrollIntoView({block:"start",behavior:"smooth"})}},[n]),f(e.component,{key:o,params:t,query:r,hash:n})},W=({to:e,exact:t=!1,...r})=>{const{location:o,navigate:n}=q(),s=t?o===e:o.startsWith(e),i=r["ryunix-class"]?"ryunix-class":"className",a="function"==typeof(l=r["ryunix-class"]||r.className)?l({isActive:s}):l||"";var l;const{"ryunix-class":c,className:u,...d}=r;return f("a",{href:e,onClick:t=>{t.preventDefault(),n(e)},[i]:a,...d},r.children)},B=e=>{const[t,r]=L((e,t)=>"function"==typeof t?t.value(e):t.value,e);return[t,(e,t=C.NORMAL)=>{r({value:e,priority:t})}]},z=()=>{const[e,t]=B(!1);return[e,e=>{t(!0,C.IMMEDIATE),setTimeout(()=>{e(),t(!1,C.IMMEDIATE)},0)}]},J=e=>{const[t,r]=B(e);return M(()=>{const t=setTimeout(()=>{r(e,C.LOW)},100);return()=>clearTimeout(t)},[e]),t},Q=(e,t="")=>{const[r,o]=O(()=>{try{const r=window.localStorage.getItem(e);return r?JSON.parse(r):t}catch(e){return t}});return[r,t=>{try{o(t),window.localStorage.setItem(e,JSON.stringify(t))}catch(e){console.error(e)}}]},K=(e=!1)=>{const[t,r]=O(e);return[t,()=>{r(!t)}]};var Z=Object.freeze({__proto__:null,Children:G,NavLink:W,RouterProvider:H,createContext:X,useCallback:U,useDeferredValue:J,useEffect:M,useHash:j,useMemo:F,useMetadata:$,usePersitentStore:Q,useQuery:Y,useReducer:L,useRef:D,useRouter:q,useStore:O,useStorePriority:B,useSwitch:K,useTransition:z});const{Provider:ee,useContext:te}=X("ryunix.mdx",{}),re=e=>({...te(),...e}),oe={h1:e=>f("h1",{...e}),h2:e=>f("h2",{...e}),h3:e=>f("h3",{...e}),h4:e=>f("h4",{...e}),h5:e=>f("h5",{...e}),h6:e=>f("h6",{...e}),p:e=>f("p",{...e}),a:e=>f("a",{...e}),strong:e=>f("strong",{...e}),em:e=>f("em",{...e}),code:e=>f("code",{...e}),ul:e=>f("ul",{...e}),ol:e=>f("ol",{...e}),li:e=>f("li",{...e}),blockquote:e=>f("blockquote",{...e}),pre:e=>f("pre",{...e}),hr:e=>f("hr",{...e}),table:e=>f("table",{...e}),thead:e=>f("thead",{...e}),tbody:e=>f("tbody",{...e}),tr:e=>f("tr",{...e}),th:e=>f("th",{...e}),td:e=>f("td",{...e}),img:e=>f("img",{...e})};const ne=new class{constructor(){this.enabled="production"!==process.env.NODE_ENV,this.measures=new Map,this.renderTimes=[],this.maxSamples=100}startMeasure(e){this.enabled&&this.measures.set(e,performance.now())}endMeasure(e){if(!this.enabled)return;const t=this.measures.get(e);if(!t)return;const r=performance.now()-t;return this.measures.delete(e),r}recordRender(e,t){this.enabled&&(this.renderTimes.push({component:e,duration:t,timestamp:Date.now()}),this.renderTimes.length>this.maxSamples&&this.renderTimes.shift())}getStats(){if(!this.enabled)return null;const e=this.renderTimes.reduce((e,t)=>e+t.duration,0);return{total:e,avg:e/this.renderTimes.length,max:Math.max(...this.renderTimes.map(e=>e.duration)),min:Math.min(...this.renderTimes.map(e=>e.duration)),count:this.renderTimes.length}}getSlowestComponents(e=10){if(!this.enabled)return[];const t=new Map;return this.renderTimes.forEach(({component:e,duration:r})=>{t.has(e)||t.set(e,{total:0,count:0,max:0});const o=t.get(e);o.total+=r,o.count++,o.max=Math.max(o.max,r)}),Array.from(t.entries()).map(([e,t])=>({name:e,avg:t.total/t.count,max:t.max,count:t.count})).sort((e,t)=>t.avg-e.avg).slice(0,e)}logStats(){if(!this.enabled)return;const e=this.getStats();if(!e)return;console.group("šŸ” Ryunix Performance Stats"),console.log(`Total renders: ${e.count}`),console.log(`Avg render time: ${e.avg.toFixed(2)}ms`),console.log(`Min: ${e.min.toFixed(2)}ms | Max: ${e.max.toFixed(2)}ms`);const t=this.getSlowestComponents(5);t.length>0&&(console.log("\nāš ļø Slowest components:"),t.forEach((e,t)=>{console.log(`${t+1}. ${e.name}: ${e.avg.toFixed(2)}ms avg (${e.count} renders)`)})),console.groupEnd()}clear(){this.renderTimes=[],this.measures.clear()}enable(){this.enabled=!0}disable(){this.enabled=!1}},se=e=>{const t=performance.now();return()=>{const r=performance.now()-t;ne.recordRender(e,r)}},ie=(e,t)=>r=>{ne.startMeasure(t);const o=e(r),n=ne.endMeasure(t);return n&&ne.recordRender(t,n),o},ae="undefined"!=typeof requestIdleCallback?requestIdleCallback:e=>setTimeout(()=>e({timeRemaining:()=>1}),1),le=e=>{const t=r();let o=!1;for(;t.nextUnitOfWork&&!o;)t.nextUnitOfWork=ce(t.nextUnitOfWork),o=e.timeRemaining()<1;!t.nextUnitOfWork&&t.wipRoot&&(()=>{const e=r();e.deletions.forEach(k),k(e.wipRoot.child),e.currentRoot=e.wipRoot,e.wipRoot=null})(),ae(le)};ae(le);const ce=e=>{const t=e.type?.name||e.type?.displayName||"Unknown";ne.startMeasure(t);e.type instanceof Function?(e=>{const t=r();t.wipFiber=e,t.hookIndex=0,t.wipFiber.hooks=[],t.isHydrating&&(e.effectTag=t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"));const o=[e.type(e.props)];e.type._contextId&&void 0!==e.props.value&&(e._contextId=e.type._contextId,e._contextValue=e.props.value),_(e,o)})(e):(e=>{const t=r();e.type===n.RYUNIX_CONTEXT&&(e._contextId=e.props?._contextId,e._contextValue=e.props?.value);const o=e.type===n.RYUNIX_FRAGMENT||e.type===n.RYUNIX_CONTEXT;if(t.isHydrating&&o)e.effectTag=t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate");else if(!e.dom)if(t.isHydrating&&t.hydrateCursor){const r=t.hydrateCursor,o=e.type===n.TEXT_ELEMENT&&3===r.nodeType,s="string"==typeof e.type&&1===r.nodeType&&r.tagName.toLowerCase()===e.type.toLowerCase();o||s?(e.dom=r,e.effectTag=t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"),t.hydrateCursor=r.nextSibling):(console.warn(`[Hydration] Mismatch at ${e.type}. Falling back to CSR.`),t.isHydrating=!1,w(t.containerRoot),e.dom=S(e),e.effectTag=t.EFFECT_TAGS?.PLACEMENT||Symbol.for("ryunix.reconciler.status.placement"))}else e.dom=S(e);let s=t.hydrateCursor;const i=null!=e.dom;t.isHydrating&&i&&e.effectTag===(t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"))&&(t.hydrateCursor=e.dom.firstChild);const a=e.props?.children||[];_(e,a),t.isHydrating&&e.effectTag===(t.EFFECT_TAGS?.HYDRATE||Symbol.for("ryunix.reconciler.status.hydrate"))&&i&&(t.hydrateCursor=s)})(e);const o=ne.endMeasure(t);if(o&&ne.recordRender(t,o),e.child)return e.child;let s=e;for(;s;){if(s.sibling)return s.sibling;s=s.parent}},ue=(e,t=C.NORMAL)=>{const o=r();o.nextUnitOfWork=e,o.wipRoot=e,o.deletions=[],o.hookIndex=0,o.effects=[],t<=C.USER_BLOCKING?ae(le):setTimeout(()=>ae(le),0)},de=(e,t)=>{const o=r();return w(t),o.wipRoot={dom:t,props:{children:[e]},alternate:o.currentRoot},o.isHydrating=!1,o.nextUnitOfWork=o.wipRoot,o.deletions=[],ue(o.wipRoot),o.wipRoot},pe=(e,t)=>(w(t),de(e,t)),fe=(e,t="__ryunix")=>{const o=r();return o.containerRoot=document.getElementById(t),process.env.RYUNIX_SSR&&o.containerRoot.hasChildNodes()?pe(e,o.containerRoot):de(e,o.containerRoot)},he=(e,t,r)=>{try{return e(t)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("Component error:",e),r&&r(e),null}},ye=e=>"string"!=typeof e?String(e):e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;"),me=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ee=e=>{if(null==e||"boolean"==typeof e)return"";if("string"==typeof e||"number"==typeof e)return ye(e);if(e.type===n.TEXT_ELEMENT)return ye(e.props.nodeValue);if(e.type===n.RYUNIX_FRAGMENT){return(e.props?.children||[]).map(e=>Ee(e)).join("")}if(e.type===n.RYUNIX_CONTEXT){const t=r();t.ssrContexts=t.ssrContexts||{};const o=e.props?._contextId,n=t.ssrContexts[o];o&&(t.ssrContexts[o]=e.props?.value);const s=e.props?.children||[];let i="";return i=Array.isArray(s)?s.map(e=>Ee(e)).join(""):Ee(s),o&&(t.ssrContexts[o]=n),i}if("function"==typeof e.type){const t=e.props||{},r=e.type(t);return Ee(r)}const t=e.type,o=e.props||{};let a="",l="",u=null;if(Object.entries(o).forEach(([e,t])=>{if("children"===e)l=Array.isArray(t)?t.map(e=>Ee(e)).join(""):Ee(t);else if("dangerouslySetInnerHTML"===e&&t?.__html)u=t.__html;else if(e===s.STYLE||e===i.STYLE){const e=!c(r=t)||p(r)?"":Object.entries(r).filter(([e,t])=>null!=t).map(([e,t])=>`${R(e)}:${t}`).join(";");e&&(a+=` style="${ye(e)}"`)}else if(e===s.CLASS_NAME||e===i.CLASS_NAME)t&&(a+=` class="${ye(t)}"`);else if(!e.startsWith("on"))if("boolean"==typeof t)t&&(a+=` ${e}=""`);else if(null!=t){let r=e;"strokeWidth"===e&&(r="stroke-width"),"strokeLinecap"===e&&(r="stroke-linecap"),"strokeLinejoin"===e&&(r="stroke-linejoin"),"strokeDasharray"===e&&(r="stroke-dasharray"),"strokeDashoffset"===e&&(r="stroke-dashoffset"),"fillRule"===e&&(r="fill-rule"),"clipRule"===e&&(r="clip-rule"),a+=` ${r}="${ye(t)}"`}var r}),me.has(t))return`<${t}${a} />`;return`<${t}${a}>${null!==u?u:l}</${t}>`},ge=e=>{const t=r(),o=t.isServerRendering;t.isServerRendering=!0;try{return Ee(e)}finally{t.isServerRendering=o}},Te=(e,t)=>t=>F(()=>e(t),[...Object.values(t)]),Ne=e=>{let t=null,r=null,o=null;return n=>{const[,s]=O(0);if(M(()=>{t||o||r||(r=e().then(e=>{t=e.default||e,s(e=>e+1)}).catch(e=>{o=e,s(e=>e+1)}))},[]),o)throw o;return t?f(t,n):null}},Re=({fallback:e,children:t})=>{const[r,o]=O(!0);return M(()=>{o(!1)},[]),r&&e?e:t};let be=!1,Se=[];const xe=e=>{const t=be;be=!0;try{e()}finally{be=t,!be&&Se.length>0&&we()}},we=()=>{if(0===Se.length)return;const e=Se;Se=[],e.forEach(e=>e())};var ke=Object.freeze({__proto__:null,Children:G,Fragment:h,Hooks:Z,NavLink:W,Priority:C,RouterProvider:H,Suspense:Re,batchUpdates:xe,createContext:X,createElement:f,hydrate:pe,init:fe,lazy:Ne,memo:Te,profiler:ne,render:de,renderToString:ge,safeRender:he,useCallback:U,useDeferredValue:J,useEffect:M,useHash:j,useMemo:F,useMetadata:$,usePersitentStore:Q,useProfiler:se,useQuery:Y,useReducer:L,useRef:D,useRouter:q,useStore:O,useStorePriority:B,useSwitch:K,useTransition:z,withProfiler:ie});"undefined"!=typeof window&&(window.Ryunix=ke),e.Children=G,e.Fragment=h,e.Hooks=Z,e.Image=({src:e,...t})=>f("img",{...t,src:e}),e.MDXContent=({children:e,components:t={}})=>{const r=re(t);return f(ee,{value:r},f("div",null,e))},e.MDXProvider=ee,e.NavLink=W,e.Priority=C,e.RouterProvider=H,e.Suspense=Re,e.batchUpdates=xe,e.createContext=X,e.createElement=f,e.default=ke,e.defaultComponents=oe,e.getMDXComponents=re,e.hydrate=pe,e.init=fe,e.lazy=Ne,e.memo=Te,e.profiler=ne,e.render=de,e.renderToString=ge,e.safeRender=he,e.useCallback=U,e.useDeferredValue=J,e.useEffect=M,e.useHash=j,e.useMDXComponents=te,e.useMemo=F,e.useMetadata=$,e.usePersitentStore=Q,e.useProfiler=se,e.useQuery=Y,e.useReducer=L,e.useRef=D,e.useRouter=q,e.useStore=O,e.useStorePriority=B,e.useSwitch=K,e.useTransition=z,e.withProfiler=ie,Object.defineProperty(e,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=Ryunix.umd.min.js.map