UNPKG

0x1

Version:

0x1: Lightning-fast web framework for JavaScript/TypeScript with zero overhead and maximum performance, powered by Bun

66 lines 92.4 kB
import{a as P,b as $Y,c as mY}from"./chunk-nkbhtxh8.js";import{d as RY,e as zZ,f as HY}from"./chunk-2n6713cf.js";var D=Symbol.for("react.fragment"),$4=Symbol.for("react.element"),lY=Symbol.for("react.fragment");function m(Y,$){let{__0x1_enterComponentContext:Z,__0x1_exitComponentContext:X}=globalThis;if(!Z||!X){console.warn("[0x1 JSX] Hooks context not available, component will run without hooks");try{return Y($)}catch(Q){return console.error("[0x1 JSX] Component error (no hooks context):",Q),{type:"div",props:{className:"error-boundary",style:{color:"red",padding:"10px",border:"1px solid red"}},children:[`Error in component: ${Q.message}`],key:null}}}let G=Y.name||"AnonymousComponent",J,q=(typeof window!=="undefined"?window.location.pathname:"/").replace(/[^a-zA-Z0-9]/g,"_")||"root",W=`${G}_${q}`;if(typeof window!=="undefined"){if(!window.__0x1_stableComponentIds)window.__0x1_stableComponentIds=new Map;let Q=window.__0x1_stableComponentIds;if(Q.has(W))J=Q.get(W);else J=`${G}_${q}_${Math.random().toString(36).slice(2,3)}`,Q.set(W,J)}else J=`${G}_${Math.random().toString(36).slice(2,5)}`;Z(J);try{let Q=Y($);return rY(Q,J,G)}catch(Q){return console.error(`[0x1 JSX] Error in component ${J}:`,Q),{type:"div",props:{className:"error-boundary",style:{color:"red",padding:"10px",border:"1px solid red"}},children:[`Error in ${G}: ${Q.message}`],key:null}}finally{X()}}function rY(Y,$,Z){if(!Y||typeof Y!=="object")return Y;if("type"in Y&&"children"in Y&&typeof Y.type==="symbol"){let X=Y;if(Array.isArray(X.children)){let G=X.children.map((J,q)=>{if(J&&typeof J==="object"&&"type"in J&&"props"in J){let W={...J};if(!W.props)W.props={};return W.props["data-component-id"]=$,W.props["data-component-name"]=Z,W.props["data-fragment-index"]=q,W}return J});return{...X,children:G}}return X}if("type"in Y&&"props"in Y){let X=Y;if(!X.props)X.props={};if(X.props["data-component-id"]=$,X.props["data-component-name"]=Z,Z.includes("Layout")||Z.includes("layout")){if(Array.isArray(X.children)&&X.children.length>0){let G=X.children[0];if(G&&typeof G==="object"&&"type"in G&&"props"in G){let J=G.type;if(["div","main","section","article","aside","header","footer"].includes(J)){if(!G.props)G.props={};G.props["data-component-id"]=$,G.props["data-component-name"]=Z}}}}return X}if(Array.isArray(Y))return Y.map((G,J)=>{if(G&&typeof G==="object"&&"type"in G&&"props"in G){let q={...G};if(!q.props)q.props={};if(q.props["data-component-id"]=$,q.props["data-component-name"]=Z,q.props["data-fragment-index"]=J,(Z.includes("Layout")||Z.includes("layout"))&&J===0)q.props["data-component-id"]=$,q.props["data-component-name"]=Z;return q}return G});return Y}function C(Y,$,Z){let{children:X,...G}=$||{};if(Y===D||Y===lY)return{type:D,props:{},children:Array.isArray(X)?X.flat().filter((J)=>J!=null):X!=null?[X]:[],key:null};if(typeof Y==="function"){let J={...G};if(X!==void 0)J.children=X;return m(Y,J)}return{type:Y,props:{...G,children:Array.isArray(X)?X.flat().filter((J)=>J!=null):X!=null?[X]:[]},children:Array.isArray(X)?X.flat().filter((J)=>J!=null):X!=null?[X]:[],key:Z||null}}function p(Y,$,Z){return C(Y,$,Z)}function qY(Y,$,Z,X,G,J){if(G&&$&&typeof $==="object")$.__source=G;if(J!==void 0&&$&&typeof $==="object")$.__self=J;return C(Y,$,Z)}function d(Y,$,...Z){let X=Z.flat().filter((G)=>G!=null);if(typeof Y==="function"){let G={...$};if(X.length>0)G.children=X.length===1?X[0]:X;return m(Y,G)}return C(Y,{...$,children:X})}function j(Y,$){try{if(Y===null||Y===void 0)return null;if(typeof Y==="string"||typeof Y==="number")return document.createTextNode(String(Y));if(Array.isArray(Y)){let Z=document.createDocumentFragment();return Y.forEach((X)=>{let G=j(X,$);if(G)Z.appendChild(G)}),Z}if(typeof Y==="object"&&Y.type){if(Y.type===D){let J=document.createDocumentFragment();if(Y.children)(Array.isArray(Y.children)?Y.children:[Y.children]).forEach((W)=>{let Q=j(W,$);if(Q)J.appendChild(Q)});return J}if(typeof Y.type==="function"){let J=m(Y.type,Y.props);if(J&&typeof J==="object"&&"props"in J&&Y.props){let q=Y.props["data-component-id"],W=Y.props["data-component-name"];if(q&&!J.props["data-component-id"]){if(!J.props)J.props={};J.props["data-component-id"]=q}if(W&&!J.props["data-component-name"]){if(!J.props)J.props={};J.props["data-component-name"]=W}}return j(J,$)}let Z=Y.type,X,G=new Set(["svg","path","circle","rect","line","ellipse","polygon","polyline","g","defs","use","symbol","marker","clipPath","mask","pattern","linearGradient","radialGradient","stop","text","tspan","textPath","foreignObject","switch","animate","animateTransform","animateMotion"]);if(G.has(Z))X=document.createElementNS("http://www.w3.org/2000/svg",Z);else X=document.createElement(Z);if(Object.entries(Y.props||{}).forEach(([J,q])=>{if(J==="children")return;if(J==="className")if(G.has(Z))X.setAttribute("class",String(q));else X.className=String(q);else if(J.startsWith("on")&&typeof q==="function"){let W=J.slice(2).toLowerCase();if(X[`__0x1_${W}_handler`]=q,X.addEventListener(W,q),W==="click"||W==="change")X.addEventListener("0x1-state-change",(Q)=>{let _=Q,{componentId:B,hookIndex:U,newValue:L,oldValue:O}=_.detail;if(Z==="button"){if(typeof L==="boolean")if(L)X.classList.add("active","pressed"),X.setAttribute("aria-pressed","true");else X.classList.remove("active","pressed"),X.setAttribute("aria-pressed","false")}if(X.classList.contains("dropdown-toggle")||X.getAttribute("data-dropdown")){let K=X.getAttribute("data-dropdown");if(K&&typeof L==="boolean"){let A=document.getElementById(K)||document.querySelector(`[data-dropdown-content="${K}"]`);if(A)if(L)A.classList.remove("hidden"),A.classList.add("block");else A.classList.add("hidden"),A.classList.remove("block")}}if(X.getAttribute("data-toggle")||X.classList.contains("toggle")){if(typeof L==="boolean"){X.setAttribute("data-state",L?"on":"off");let K=X.textContent||"";if(K.includes("ON")||K.includes("OFF"))X.textContent=K.replace(/ON|OFF/g,L?"ON":"OFF");if(L)X.classList.add("toggle-on","active"),X.classList.remove("toggle-off");else X.classList.add("toggle-off"),X.classList.remove("toggle-on","active")}}X.__0x1_state=X.__0x1_state||{},X.__0x1_state[U]=L})}else if(J==="style"&&typeof q==="object")Object.assign(X.style,q);else if(typeof q==="boolean"){if(q)X.setAttribute(J,"")}else if(q!=null){if(X.setAttribute(J,String(q)),J==="data-component-id"){let W=X.getAttribute("data-component-id");try{X.addEventListener("0x1-state-change",(Q)=>{try{let _=Q,{hookIndex:B,newValue:U,oldValue:L,componentId:O}=_.detail||{};if(O===W)X.__0x1_state=X.__0x1_state||{},X.__0x1_state[B]=U}catch(_){console.error(`[0x1 JSX] ❌ Error in state-change listener for ${Z}:`,_)}})}catch(Q){console.error(`[0x1 JSX] ❌ Failed to attach event listener to ${Z}:`,Q)}}}}),Y.children)(Array.isArray(Y.children)?Y.children:[Y.children]).forEach((q)=>{let W=j(q,X);if(W)X.appendChild(W)});return X}return null}catch(Z){return console.error("[0x1 JSX] renderToDOM error:",Z),document.createTextNode(`[Render Error: ${Z.message}]`)}}function g(Y){if(!Y)return"";if(typeof Y==="string"||typeof Y==="number")return String(Y);if(Array.isArray(Y))return Y.map(($)=>g($)).join("");if(typeof Y==="object"&&Y&&"type"in Y){if(Y.type===D)return Y.children.map((J)=>g(J)).join("");if(typeof Y.type==="function"){let J=m(Y.type,Y.props);return g(J)}let $=Y.type,Z=Object.entries(Y.props||{}).filter(([J,q])=>q!=null&&J!=="children").map(([J,q])=>{if(typeof q==="boolean")return q?J:"";return`${J==="className"?"class":J}="${String(q).replace(/"/g,"&quot;")}"`}).filter((J)=>J).join(" "),X=Y.children?.map((J)=>g(J)).join("")||"";if(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes($))return`<${$}${Z?" "+Z:""} />`;return`<${$}${Z?" "+Z:""}>${X}</${$}>`}return""}function WY(Y,$={},Z){let X=document.createElement(Y);if(Object.entries($).forEach(([G,J])=>{if(G==="className")X.className=String(J);else if(G.startsWith("on")&&typeof J==="function"){let q=G.slice(2).toLowerCase();X.addEventListener(q,J)}else if(G==="style"&&typeof J==="object")Object.assign(X.style,J);else if(typeof J==="boolean"){if(J)X.setAttribute(G,"")}else if(J!=null)X.setAttribute(G,String(J))}),Z)X.addEventListener("0x1-state-change",(G)=>{Z(X,G.detail)});return X}function TY(Y,$,Z,X){return WY("button",{className:X||"toggle-button",onClick:Z},(G,J)=>{if(J.hookIndex===$)if(J.newValue)G.classList.add("active"),G.setAttribute("aria-pressed","true");else G.classList.remove("active"),G.setAttribute("aria-pressed","false")})}function nY(){if(typeof window!=="undefined"){if(window.jsx=C,window.jsxs=p,window.jsxDEV=qY,window.createElement=d,window.Fragment=D,window.renderToDOM=j,window.createStateResponsiveElement=WY,window.createToggleButton=TY,window.jsxToDom=j,window.__0x1_renderToDOM=j,!window.React)window.React={};window.React.createElement=d,window.React.Fragment=D,window.React.jsx=C,window.React.jsxs=p}}if(typeof window!=="undefined")setTimeout(nY,0);function VY(Y){let{href:$,children:Z,className:X="",target:G,rel:J,onClick:q,...W}=Y,Q=(()=>{if(Z===void 0||Z===null)return[];if(typeof Z==="string"||typeof Z==="number")return[Z];if(Array.isArray(Z))return Z;return[Z]})();return{type:"a",props:{href:$,className:X,target:G,rel:J,...W,onClick:(_)=>{if($.startsWith("/")&&!G)if(_.preventDefault(),typeof window!=="undefined"&&window.__0x1_ROUTER__)window.__0x1_ROUTER__.navigate($);else if(typeof window!=="undefined"&&window.router)window.router.navigate($);else window.history.pushState(null,"",$),window.dispatchEvent(new PopStateEvent("popstate"));if(q)q(_)}},children:Q,key:null}}VY.preload=(Y)=>{let $=window.__0x1_ROUTER__;if($&&$.preload)$.preload(Y)};var aY=VY;class SY{routes=[];currentPath="/";listeners=[];middleware=[];isServer=typeof window==="undefined";options;scrollPositions=new Map;isBackForward=!1;layoutCache={};constructor(Y={}){if(this.options={mode:"history",debug:!1,base:"",scrollBehavior:"auto",scrollToTop:!0,...Y},!this.isServer)this.initializeHookSystem(),window.addEventListener("popstate",($)=>{this.saveScrollPosition(this.currentPath),this.isBackForward=!0,this.navigate(window.location.pathname,!1)}),window.__0x1_router=this,this.currentPath=window.location.pathname}initializeHookSystem(){if(typeof window==="undefined")return;if(window.__0x1_real_hooks_loaded)return;if(!window.__0x1_hooks)window.__0x1_hooks={currentComponent:null,stateIndex:0,states:new Map,isRenderingComponent:!1,componentStack:[]};if(typeof window.__0x1_enterComponentContext!=="function")console.log("[0x1 Router] Setting up minimal hook fallbacks (real hooks not detected)"),window.__0x1_enterComponentContext=(Y)=>{let $=window.__0x1_hooks;if($)$.componentStack=$.componentStack||[],$.componentStack.push($.currentComponent),$.currentComponent=Y,$.stateIndex=0,$.isRenderingComponent=!0};if(typeof window.__0x1_exitComponentContext!=="function")window.__0x1_exitComponentContext=()=>{let Y=window.__0x1_hooks;if(Y)Y.componentStack=Y.componentStack||[],Y.currentComponent=Y.componentStack.pop()||null,Y.isRenderingComponent=!1};if(typeof window.__0x1_triggerUpdate!=="function")window.__0x1_triggerUpdate=(Y)=>{if(Y){let $=document.querySelector(`[data-component-id="${Y}"]`);if($&&$.getAttribute("data-update-callback")){let Z=$.__updateCallback;if(typeof Z==="function")Z()}}}}init(){if(this.isServer)return;document.addEventListener("click",(Y)=>{let Z=Y.target.closest("a[href]");if(!Z)return;let X=Z.getAttribute("href");if(!X)return;if(X.startsWith("http")||X.startsWith("mailto:")||X.startsWith("tel:"))return;if(Z.target&&Z.target!=="_self")return;if(Y.ctrlKey||Y.metaKey||Y.shiftKey)return;Y.preventDefault(),this.navigate(X,!0)}),window.addEventListener("popstate",()=>{let Y=new URLSearchParams(location.search)})}addRoute(Y,$,Z){if(typeof Y==="string"){let X={path:Y,component:$,exact:Z?.exact!==!1,meta:Z?.layout?{layout:Z.layout}:{}};this.routes.push(X)}else this.routes.push(Y)}async navigate(Y,$=!0,Z){if(this.isServer)return;if($)this.saveScrollPosition(this.currentPath);if($&&Y!==this.currentPath)window.history.pushState({},"",Y);let X=this.currentPath;this.currentPath=Y,await this.executeMiddleware(Y),await this.renderCurrentRoute(),this.handleScrollBehavior(Y,X,Z),this.isBackForward=!1,this.listeners.forEach(async(G)=>{try{await G()}catch(J){console.error("[0x1 Router] Error in route change listener:",J)}})}saveScrollPosition(Y){if(this.isServer)return;this.scrollPositions.set(Y,{x:window.scrollX||window.pageXOffset,y:window.scrollY||window.pageYOffset})}handleScrollBehavior(Y,$,Z){if(this.isServer)return;let[X,G]=Y.split("#"),J=Z||this.options.scrollBehavior||"auto";if(J==="preserve")return;if(J==="auto")if(G)this.scrollToHash(G);else if(this.isBackForward)this.restoreScrollPosition(Y);else this.scrollToTop();else if(J==="top")this.scrollToTop();else if(J==="smooth")this.scrollToTop("smooth")}scrollToTop(Y="auto"){if(this.isServer)return;try{window.scrollTo({top:0,left:0,behavior:Y})}catch($){window.scrollTo(0,0)}}scrollToHash(Y){if(this.isServer)return;setTimeout(()=>{try{let $=document.getElementById(Y)||document.querySelector(`[name="${Y}"]`)||document.querySelector(`a[name="${Y}"]`);if($){if($.scrollIntoView({behavior:"smooth",block:"start"}),!window.location.hash.includes(Y))window.history.replaceState({},"",`${window.location.pathname}#${Y}`)}else console.warn(`[0x1 Router] Hash target not found: #${Y}`),this.scrollToTop()}catch($){console.error("[0x1 Router] Error scrolling to hash:",$),this.scrollToTop()}},50)}restoreScrollPosition(Y){if(this.isServer)return;let $=this.scrollPositions.get(Y);if($)setTimeout(()=>{try{window.scrollTo({left:$.x,top:$.y,behavior:"auto"})}catch(Z){window.scrollTo($.x,$.y)}},10);else this.scrollToTop()}async executeMiddleware(Y){let $=this.matchRoute(Y);if(!$)return;let Z={path:Y,params:$.params,query:new URLSearchParams(window?.location.search||""),meta:$.route.meta||{}},X=[...this.middleware,...$.route.middleware||[]],G=0,J=async()=>{if(G<X.length)await X[G++](Z,J)};await J()}matchRoute(Y){for(let $ of this.routes){let Z=this.pathToRegExp($.path,$.exact),X=Y.match(Z.regex);if(X){let G={};return Z.keys.forEach((J,q)=>{G[J]=X[q+1]||""}),{route:$,params:G}}}return null}pathToRegExp(Y,$){if(!Y||typeof Y!=="string")return console.warn("[0x1 Router] Invalid path provided to pathToRegExp:",Y),{regex:new RegExp("^/$"),keys:[]};if(Y==="*")return{regex:new RegExp(".*"),keys:[]};let Z=[],X=Y.replace(/\//g,"/").replace(/:([^/]+)/g,(G,J)=>{return Z.push(J),"([^/]+)"});if($)X=`^${X}$`;else X=`^${X}`;return{regex:new RegExp(X),keys:Z}}reRender(){if(this.isServer)return;this.renderCurrentRoute().catch((Y)=>{console.error("[0x1 Router] reRender failed:",Y)})}async renderCurrentRoute(){if(this.isServer)return;if(this._isRendering)return;if(this._isRendering=!0,this._currentRouteId)this[`_cancelled_${this._currentRouteId}`]=!0;let Y=Math.random().toString(36).slice(2,8);this._currentRouteId=Y;let $=setTimeout(()=>{if(this._isRendering)console.warn("[0x1 Router] Rendering took too long, forcing reset"),this._isRendering=!1},5000),Z=this.options?.rootElement;if(!Z){console.warn("[0x1 Router] No root element specified for rendering"),clearTimeout($),this._isRendering=!1;return}let X=this.matchRoute(this.currentPath);if(X)try{let G=X.route.component,J=X.route.meta?.layout;if(J){if(this.layoutCache.layoutComponent!==J||!this.layoutCache.element||!this.layoutCache.contentSlot){this.layoutCache={};let Q=null;try{Q=this.jsxToDom(J({children:null}),Y)}catch(B){console.error("[0x1 Router] Layout rendering failed:",B);let U=this.jsxToDom(G(X.params),Y);if(U)Z.innerHTML="",Z.appendChild(U);clearTimeout($),this._isRendering=!1;return}if(!Q){console.error("[0x1 Router] Failed to render layout component"),clearTimeout($),this._isRendering=!1;return}let _=Q.querySelector('[data-slot="children"]')||Q.querySelector("main")||Q;this.layoutCache={element:Q,layoutComponent:J,contentSlot:_},Z.innerHTML="",Z.appendChild(Q)}if(!this.layoutCache.contentSlot){console.error("[0x1 Router] Content slot not found in cached layout"),clearTimeout($),this._isRendering=!1;return}let W=null;try{let Q=G(X.params);if(Q&&typeof Q==="object"&&typeof Q.then==="function"){let _=document.getElementById("app-loading");if(_)_.classList.remove("loaded");try{let B=await Q;if(W=this.jsxToDom(B,Y),_)_.classList.add("loaded")}catch(B){if(console.error("[0x1 Router] Promise component failed:",B),_)_.classList.add("loaded");this.layoutCache.contentSlot.innerHTML=` <div style="padding: 20px; text-align: center; color: #ef4444;"> <div>❌ Error loading page</div> <div style="font-size: 12px; margin-top: 4px; opacity: 0.7;">${B instanceof Error?B.message:"Promise component error"}</div> </div> `,clearTimeout($),this._isRendering=!1;return}}else W=this.jsxToDom(Q,Y)}catch(Q){console.error("[0x1 Router] Component rendering failed:",Q),this.layoutCache.contentSlot.innerHTML=` <div style="padding: 20px; text-align: center; color: #ef4444;"> <div>❌ Error loading page</div> <div style="font-size: 12px; margin-top: 4px; opacity: 0.7;">${Q instanceof Error?Q.message:"Component error"}</div> </div> `,clearTimeout($),this._isRendering=!1;return}if(!W){console.error("[0x1 Router] Failed to render page component"),clearTimeout($),this._isRendering=!1;return}this.layoutCache.contentSlot.innerHTML="",this.layoutCache.contentSlot.appendChild(W)}else{this.layoutCache={};let q=null;try{let W=G(X.params);if(W&&typeof W==="object"&&typeof W.then==="function"){let Q=document.getElementById("app-loading");if(Q)Q.classList.remove("loaded");try{let _=await W;if(q=this.jsxToDom(_,Y),Q)Q.classList.add("loaded")}catch(_){if(console.error("[0x1 Router] Promise component failed:",_),Q)Q.classList.add("loaded");Z.innerHTML=` <div style="padding: 40px; text-align: center; color: #ef4444;"> <div>❌ Error loading page</div> <div style="font-size: 12px; margin-top: 4px; opacity: 0.7;">${_ instanceof Error?_.message:"Promise component error"}</div> </div> `,clearTimeout($),this._isRendering=!1;return}}else q=this.jsxToDom(W,Y)}catch(W){console.error("[0x1 Router] Component rendering failed:",W),Z.innerHTML=` <div style="padding: 40px; text-align: center; color: #ef4444;"> <div>❌ Error loading page</div> <div style="font-size: 12px; margin-top: 4px; opacity: 0.7;">${W instanceof Error?W.message:"Component error"}</div> </div> `,clearTimeout($),this._isRendering=!1;return}if(!q){console.error("[0x1 Router] Failed to render component"),clearTimeout($),this._isRendering=!1;return}if("startViewTransition"in document)document.startViewTransition(()=>{Z.innerHTML="",Z.appendChild(q)});else Z.innerHTML="",Z.appendChild(q)}}catch(G){console.error("[0x1 Router] Error rendering route:",G)}else if(console.warn(`[0x1 Router] No route found for: ${this.currentPath}`),this.layoutCache.element&&this.layoutCache.contentSlot)this.layoutCache.contentSlot.innerHTML=` <div style="padding: 40px; text-align: center; font-family: system-ui, sans-serif;"> <div style="font-size: 4rem; font-weight: bold; color: #8b5cf6; margin-bottom: 16px;">404</div> <div style="font-size: 1.5rem; font-weight: bold; margin-bottom: 8px;">Page Not Found</div> <div style="color: #6b7280; margin-bottom: 24px;">The page you're looking for doesn't exist.</div> <a href="/" style="display: inline-block; padding: 8px 16px; background: #8b5cf6; color: white; border-radius: 6px; text-decoration: none;">← Back to Home</a> </div> `;else this.layoutCache={},Z.innerHTML=` <div style="display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; padding: 16px; font-family: system-ui, sans-serif;"> <div style="font-size: 6rem; font-weight: bold; color: #8b5cf6; margin-bottom: 16px;">404</div> <div style="font-size: 1.875rem; font-weight: bold; margin-bottom: 16px;">Page Not Found</div> <div style="color: #6b7280; margin-bottom: 32px;">The page you're looking for doesn't exist or has been moved.</div> <a href="/" onclick="event.preventDefault(); window.router?.navigate('/') || (window.location.href = '/')" style="display: inline-block; padding: 12px 24px; background: #8b5cf6; color: white; border-radius: 8px; text-decoration: none; font-weight: 500;">\uD83C\uDFE0 Back to Home</a> </div> `;clearTimeout($),this._isRendering=!1}renderFallback404(Y){Y.innerHTML="",Y.appendChild(this.createFallback404Element())}createFallback404Element(){let Y=document.createElement("div");return Y.style.cssText=` display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; padding: 16px; font-family: system-ui, -apple-system, sans-serif; `,Y.innerHTML=` <div style="margin-bottom: 32px;"> <h1 style="font-size: 6rem; font-weight: bold; color: #8b5cf6; margin-bottom: 16px; line-height: 1;">404</h1> </div> <div style="max-width: 28rem; margin: 0 auto;"> <h2 style="font-size: 1.875rem; font-weight: bold; color: #1f2937; margin-bottom: 16px;">Page Not Found</h2> <p style="font-size: 1.125rem; color: #6b7280; margin-bottom: 32px;">The page you're looking for doesn't exist or has been moved.</p> <div style="display: flex; flex-direction: column; gap: 16px; align-items: center;"> <a href="/" onclick="event.preventDefault(); window.router?.navigate('/') || (window.location.href = '/')" style="display: inline-block; padding: 12px 24px; background: linear-gradient(135deg, #8b5cf6, #7c3aed); color: white; border-radius: 8px; text-decoration: none; font-weight: 500; transition: all 0.2s; box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3); cursor: pointer;"> \uD83C\uDFE0 Back to Home </a> </div> </div> `,Y}jsxToDom(Y,$){try{if(!Y)return null;if(Y&&typeof Y==="object"&&typeof Y.then==="function"){let Z=document.createElement("div");return Z.innerHTML='<span style="color: #f59e0b;">⚠️ Promise JSX not resolved</span>',Z}if(typeof Y==="string"||typeof Y==="number"){let Z=document.createTextNode(String(Y)),X=document.createElement("span");return X.appendChild(Z),X}if(typeof Y==="boolean")return null;if(Array.isArray(Y)){let Z=document.createDocumentFragment();Y.forEach((G)=>{let J=this.jsxToDom(G,$);if(J)Z.appendChild(J)});let X=document.createElement("div");return X.appendChild(Z),X}if(Y instanceof Node)return Y;if(typeof Y==="object"&&(Y.type||Y.__isVNode)){if(Y.type===Symbol.for("react.fragment")||Y.type===Symbol.for("React.Fragment")){let Z=[];try{let G=Y.children||Y.props?.children;if(G===null||G===void 0)Z=[];else if(Array.isArray(G))Z=G.filter((J)=>J!==null&&J!==void 0);else Z=[G]}catch(G){console.warn("[0x1 Router] Error normalizing fragment children:",G),Z=[]}if(!Array.isArray(Z))console.warn("[0x1 Router] Fragment children normalization failed, forcing array"),Z=[];let X=document.createDocumentFragment();if(Z.forEach((G)=>{let J=this.jsxToDom(G,$);if(J)X.appendChild(J)}),X.children.length===1)return X.children[0];else{let G=document.createElement("div");return G.appendChild(X),G}}else if(typeof Y.type==="string"){let X=["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","use","text","tspan"].includes(Y.type.toLowerCase())?document.createElementNS("http://www.w3.org/2000/svg",Y.type):document.createElement(Y.type);if(Y.props)Object.keys(Y.props).forEach((J)=>{try{if(J==="children")return;else if(J==="__self"||J==="__source"||J==="ref"||J==="key")return;else if(J==="className"){if(Y.props[J])if(X instanceof SVGElement)X.setAttribute("class",Y.props[J]);else X.className=Y.props[J]}else if(J==="onClick"||J==="onclick"){let q=Y.props[J];if(typeof q==="function")X.addEventListener("click",(W)=>{try{q(W)}catch(Q){console.error("[0x1 Router] Error in click handler:",Q)}});else if(typeof q==="string")X.setAttribute("onclick",q)}else if(J.startsWith("on")&&typeof Y.props[J]==="function"){let q=J.slice(2).toLowerCase();X.addEventListener(q,(W)=>{Y.props[J](W)})}else if(J==="style"&&typeof Y.props[J]==="object")Object.assign(X.style,Y.props[J]);else if(J==="dangerouslySetInnerHTML"){if(Y.props[J]&&Y.props[J].__html)X.innerHTML=Y.props[J].__html}else if(Y.props[J]!==null&&Y.props[J]!==void 0&&Y.props[J]!==!1&&(typeof Y.props[J]==="string"||typeof Y.props[J]==="number"||typeof Y.props[J]==="boolean"))if(X instanceof SVGElement||["path","circle","rect","line","polygon","polyline","ellipse","g","defs","use"].includes(X.tagName.toLowerCase())){let W={viewbox:"viewBox",strokewidth:"stroke-width",strokelinecap:"stroke-linecap",strokelinejoin:"stroke-linejoin",strokemiterlimit:"stroke-miterlimit",strokeopacity:"stroke-opacity",strokedasharray:"stroke-dasharray",strokedashoffset:"stroke-dashoffset",stopcolor:"stop-color",stopopacity:"stop-opacity",fillrule:"fill-rule",fillopacity:"fill-opacity",clippath:"clip-path",clippathunits:"clipPathUnits"}[J.toLowerCase()]||J;if(J==="xmlns")X.setAttribute("xmlns",String(Y.props[J]));else X.setAttributeNS(null,W,String(Y.props[J]))}else X.setAttribute(J,String(Y.props[J]))}catch(q){console.error(`[0x1 Router] Error setting prop ${J} on element:`,q)}});let G=[];try{let J=Y.__isVNode&&Y.children!==void 0?Y.children:Y.children!==void 0?Y.children:Y.props?.children;if(J===null||J===void 0)G=[];else if(Array.isArray(J))G=J.filter((q)=>q!==null&&q!==void 0);else G=[J]}catch(J){console.warn("[0x1 Router] Error normalizing children:",J),G=[]}if(!Array.isArray(G))console.warn("[0x1 Router] Children normalization failed, forcing array"),G=[];if(G.forEach((J)=>{if(J===null||J===void 0||J===!1||J===!0)return;if(typeof J==="string"||typeof J==="number")X.appendChild(document.createTextNode(String(J)));else if(J&&typeof J==="object"){let q=this.jsxToDom(J,$);if(q)X.appendChild(q)}}),Y.props&&X.setAttribute){let J=Y.props["data-component-id"],q=Y.props["data-component-name"];if(J)X.setAttribute("data-component-id",J);if(q)X.setAttribute("data-component-name",q)}return X}else if(typeof Y.type==="function")try{let Z=this.renderComponentWithHookContext(Y.type,Y.props||{}),X=this.jsxToDom(Z,$);if(X&&X.setAttribute){let G=Z?.props?.["data-component-id"],J=Z?.props?.["data-component-name"];if(G)X.setAttribute("data-component-id",G);if(J)X.setAttribute("data-component-name",J)}return X}catch(Z){console.error("[0x1 Router] Error rendering component:",Z);let X=document.createElement("div");return X.className="component-error p-4 bg-red-50/80 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg shadow-sm",X.innerHTML=` <h3 class="text-red-700 dark:text-red-300 font-medium mb-2">Component Error</h3> <p class="text-red-600 dark:text-red-400 text-sm font-mono break-words">${Z?.message||String(Z)}</p> `,X}}return console.warn("[0x1 Router] Component returned invalid JSX object. Expected object with string|function type, got:",typeof Y.type,Y.type,` Full object:`,Y,` This usually means a component is returning hyperscript/h() calls instead of proper JSX. Check your component's return statement.`),null}catch(Z){console.error("[0x1 Router] Error in jsxToDom:",Z);let X=document.createElement("div");return X.className="jsx-error p-2 bg-red-100 dark:bg-red-900/30 border border-red-300 dark:border-red-700 rounded text-red-700 dark:text-red-300",X.textContent=`JSX Render Error: ${Z?.message||String(Z)}`,X}}renderComponentWithHookContext(Y,$){if(typeof window==="undefined")return Y($);if(typeof Y!=="function")return console.warn("[0x1 Router] Invalid component provided to renderComponentWithHookContext"),null;let Z=Y.name&&Y.name.trim()||"AnonymousComponent",X=window.__0x1_hooks;if(X?.componentRegistry){let q=X.componentRegistry,W=[];for(let[Q,_]of q.entries())if(Q.startsWith(`${Z}_`)&&Q!==Z){if(!document.querySelector(`[data-component-id="${Q}"]`))W.push(Q)}W.forEach((Q)=>{if(q.delete(Q),X?.componentUpdateCallbacks)X.componentUpdateCallbacks.delete(Q)})}let G=`${Z}_${Math.random().toString(36).slice(2,8)}`;if(!G||G==="undefined"||G==="null"||G.includes("undefined")||G.includes("null"))return console.warn("[0x1 Router] Generated invalid componentId, rendering without hook context:",G),Y($);if(!window.__0x1_hooks||typeof window.__0x1_enterComponentContext!=="function"||typeof window.__0x1_exitComponentContext!=="function")return Y($);try{let q=()=>{requestAnimationFrame(()=>{try{let Q=document.querySelector(`[data-component-id="${G}"]`);if(Q&&Q.parentNode){window.__0x1_enterComponentContext(G);let _=Y($),B=this.jsxToDom(_,G);if(window.__0x1_exitComponentContext(),B){if(B.setAttribute)B.setAttribute("data-component-id",G),B.setAttribute("data-component-name",Z);Q.parentNode.replaceChild(B,Q)}}}catch(Q){console.error("[0x1 Router] Error updating component:",Q)}})};window.__0x1_enterComponentContext(G,q);let W=Y($);if(W&&typeof W==="object"&&W.props)W.props["data-component-id"]=G,W.props["data-component-name"]=Z;return W}catch(q){throw console.error(`[0x1 Router] Error in component ${G}:`,q),q}finally{window.__0x1_exitComponentContext()}}hashProps(Y){if(!Y||typeof Y!=="object")return"no-props";try{let Z=Object.keys(Y).sort().map((G)=>`${G}:${typeof Y[G]}`).join("|"),X=0;for(let G=0;G<Z.length;G++){let J=Z.charCodeAt(G);X=(X<<5)-X+J,X=X&X}return Math.abs(X).toString(36)}catch($){return"hash-error"}}use(Y){this.middleware.push(Y)}getCurrentRoute(){return this.matchRoute(this.currentPath)}onRouteChange(Y){return this.listeners.push(Y),()=>{this.listeners=this.listeners.filter(($)=>$!==Y)}}resolveRoute(Y){return this.matchRoute(Y)}prefetch(Y){let $=this.matchRoute(Y)}generateStaticRoutes(){return this.routes.filter((Y)=>!Y.path.includes(":")).map((Y)=>Y.path)}getRoutes(){return this.routes}}function w(){if(typeof window==="undefined")return null;return window.__0x1_ROUTER__||window.__0x1_router||window.router||null}function oY({href:Y,className:$,children:Z,prefetch:X,scrollBehavior:G,scrollToTop:J}){let q=w();if(X&&q)q.prefetch(Y);let W=J?"top":G;return{type:"a",props:{href:Y,className:$,onClick:(Q)=>{if(Q.preventDefault(),Q.stopPropagation(),Y.startsWith("/")){let _=w();if(_)_.navigate(Y,!0,W);else if(typeof window!=="undefined")window.history.pushState(null,"",Y),window.dispatchEvent(new PopStateEvent("popstate"))}else window.location.href=Y},children:Z}}}function tY(){let Y=w();if(!Y)return{navigate:($,Z=!0,X)=>{if(typeof window!=="undefined")window.location.href=$},currentPath:"/",getCurrentRoute:()=>null,prefetch:()=>{}};return{navigate:($,Z=!0,X)=>Y.navigate($,Z,X),currentPath:Y.currentPath,getCurrentRoute:()=>Y.getCurrentRoute(),prefetch:($)=>Y.prefetch($)}}function eY(){let Y=w();return(Y?Y.getCurrentRoute():null)?.params||{}}function YZ(){let Y=w();if(!Y){if(typeof window!=="undefined")return new URLSearchParams(window.location.search);return new URLSearchParams("")}let $=Y.currentPath,Z=$.includes("?")?$.split("?")[1]:"";return new URLSearchParams(Z)}function ZZ(Y){let{href:$,className:Z,children:X,activeClass:G="active",prefetch:J}=Y,q=w(),Q=(q?q.currentPath===$:!1)?`${Z||""} ${G}`.trim():Z;if(J&&q)q.prefetch($);return{type:"a",props:{href:$,className:Q,onClick:(_)=>{if(_.preventDefault(),_.stopPropagation(),$.startsWith("/")){let B=w();if(B)B.navigate($);else if(typeof window!=="undefined")window.history.pushState(null,"",$),window.dispatchEvent(new PopStateEvent("popstate"))}else window.location.href=$},children:X}}}function $Z({to:Y}){if(typeof window!=="undefined")setTimeout(()=>{let $=w();if($)$.navigate(Y);else window.location.href=Y},0);return null}var PY={};zZ(PY,{thunk:()=>JZ,logger:()=>QZ,initializeStore:()=>BZ,createStore:()=>QY,createSlice:()=>WZ,createSimpleStore:()=>bY,createSelector2:()=>qZ,createSelector:()=>GZ,createReduxStore:()=>QY,createAdvancedStore:()=>QY,connect:()=>_Z,combineReducers:()=>XZ});function bY(Y,$={}){let{persist:Z=!1,key:X="store"}=$,G=Y;if(Z&&typeof window!=="undefined")try{let W=window.localStorage.getItem(X);if(W)G={...Y,...JSON.parse(W)}}catch(W){console.warn("Failed to load persisted state:",W)}let J=new Set,q=()=>{if(Z&&typeof window!=="undefined")try{window.localStorage.setItem(X,JSON.stringify(G))}catch(W){console.warn("Failed to persist state:",W)}};return{getState:()=>G,setState:(W)=>{G=typeof W==="function"?{...G,...W(G)}:{...G,...W},q(),J.forEach((_)=>_(G))},subscribe:(W)=>{return J.add(W),()=>J.delete(W)},reset:()=>{G=Y,q(),J.forEach((W)=>W(G))}}}function QY(Y,$,Z=[]){let X=$,G=new Set,J=new Map,q=(W)=>{return X=Y(X,W),J.clear(),G.forEach((Q)=>Q(X)),W};if(Z.length>0){let W={getState:()=>X,dispatch:(_)=>q(_)};q=Z.map((_)=>_(W)).reduce((_,B)=>B(_),q)}return{getState:()=>X,dispatch:q,subscribe:(W)=>{return G.add(W),()=>{G.delete(W)}},select:function(W,Q){let _=()=>{if(J.has(W))return J.get(W);let B=W(X);return J.set(W,B),B};if(Q){let B=_(),U=this.subscribe((L)=>{let O=W(L);if(O!==B)B=O,Q(O)});return()=>{return U(),_()}}return _}}}function XZ(Y){return($={},Z)=>{let X={},G=!1;return Object.entries(Y).forEach(([J,q])=>{let W=$[J],Q=q(W,Z);X[J]=Q,G=G||Q!==W}),G?{...$,...X}:$}}var JZ=(Y)=>($)=>(Z)=>{if(typeof Z==="function")return Z(Y.dispatch,Y.getState);return $(Z)};function GZ(Y,$){let Z,X,G;return(J)=>{if(J!==G){let q=Y(J);if(q!==Z)X=$(q);Z=q,G=J}return X}}function qZ(Y,$,Z){let X,G,J,q;return(W)=>{if(W!==q){let Q=Y(W),_=$(W);if(Q!==X||_!==G)J=Z(Q,_);X=Q,G=_,q=W}return J}}function WZ({name:Y,initialState:$,reducers:Z}){let X={},G=(J=$,q)=>{let W=Z[q.type.replace(`${Y}/`,"")];if(W){let Q=W(J,q.payload);return Q===void 0?J:Q}return J};return Object.keys(Z).forEach((J)=>{let q=`${Y}/${J}`,W=(Q)=>({type:q,payload:Q});Object.defineProperty(W,"type",{value:q,writable:!1}),X[J]=W}),{name:Y,reducer:G,actions:X}}var QZ=(Y)=>($)=>(Z)=>{console.group(`Action: ${Z.type}`),console.log("Previous State:",Y.getState());let X=$(Z);return console.log("Next State:",Y.getState()),console.groupEnd(),X};function _Z(Y,$){return(Z)=>{return(X)=>{let G=window.__0x1_STORE__;if(!G)return console.error("Store not found. Make sure to initialize store first."),Z(X);let J=Y(G.getState()),q={};if($)q=Object.entries($).reduce((_,[B,U])=>{return _[B]=(...L)=>U(G.dispatch)(...L),_},{});let W={...X,...J,...q},Q=Z(W);return G.subscribe((_)=>{let B=Y(_),U={...X,...B,...q};if(JSON.stringify(B)!==JSON.stringify(J)){let L=Z(U);if(Q.parentNode)Q.parentNode.replaceChild(L,Q)}}),Q}}}function BZ(Y){window.__0x1_STORE__=Y}var R=new Map,KZ=new Set;var EY=new Map;function UZ(Y,$,Z="object"){let X=EY.get(Y),G=X?.listeners||new Set;EY.set(Y,{value:$,listeners:G,type:Z}),G.forEach((J)=>{f(J);let q=document.querySelector(`[data-component-id="${J}"]`);if(q){if(R.get(J))wY(q,J,0,$,X?.value)}})}var r=new Map;var I=[],H=null,b=0;var c=!1,_Y=null,s=!1;function n(Y,$){if(!Y||Y==="undefined"||Y==="null")return;let Z=Y.includes("Layout")||Y.includes("layout"),X=Y.includes("RootLayout")||Y.includes("rootLayout"),G=Y.includes("ChatLayout")||Y.includes("chatLayout"),J=Y.includes("Page")||Y.includes("page");if(H&&H!==Y)if(!(X&&H.includes("Chat")||G&&H.includes("Page")||J&&H.includes("Layout")))I.push({id:H,hookIndex:b});else I.length=0;if(H=Y,b=0,c=!0,!R.has(Y)){if(R.set(Y,{states:[],effects:[],memos:[],callbacks:[],refs:[],hookIndex:0,isMounted:!1,needsUpdate:!1,updateScheduled:!1}),typeof window!=="undefined")k(),v()}if($)r.set(Y,$);let q=R.get(Y);q.isMounted=!0,q.hookIndex=0,console.log(`[0x1 Hooks] ✅ Context set for ${Y} (stack depth: ${I.length})`)}function a(){let Y=I.pop();if(Y)H=Y.id,b=Y.hookIndex,c=I.length>0;else H=null,b=0,c=!1}function h(){if(!H)throw new Error("[0x1 Hooks] Hook called outside of component context");let Y=R.get(H);if(!Y)console.warn(`[0x1 Hooks] ⚠️ Component data missing for ${H} - auto-initializing`),Y={states:[],effects:[],memos:[],callbacks:[],refs:[],hookIndex:0,isMounted:!0,needsUpdate:!1,updateScheduled:!1},R.set(H,Y);if(!Y.states)Y.states=[];if(!Y.effects)Y.effects=[];if(!Y.memos)Y.memos=[];if(!Y.callbacks)Y.callbacks=[];if(!Y.refs)Y.refs=[];return Y}function jY(Y,$=2){let Z=R.get(Y);if(!Z)return;if(Z.updateScheduled)return;Z.updateScheduled=!0,TZ.scheduleUpdate(Y,$)}function KY(Y,$){if(!Y||!$)return!0;if(Y.length!==$.length)return!0;if(Y===$)return!1;if(i.has($))return i.get($);for(let Z=0;Z<Y.length;Z++)if(Y[Z]!==$[Z])return i.set($,!0),!0;return i.set($,!1),!1}function BY(Y,$){n(Y,$)}function zY(){a()}function f(Y){if(!Y||Y==="undefined"||Y==="null")return;jY(Y)}function OZ(){if(typeof window!=="undefined"){if(window.__0x1_enterComponentContext=BY,window.__0x1_exitComponentContext=zY,window.__0x1_triggerUpdate=f,window.__0x1_markComponentMounted=AZ,window.__0x1_executeMountEffects=MZ,window.__0x1_debug=window.__0x1_debug||!1,!window.React)window.React={};if(window.React.useState=S,window.React.useEffect=y,window.React.useLayoutEffect=UY,window.React.useRef=t,window.React.useMemo=o,window.React.useCallback=V,window.__0x1_hooks={isInitialized:!0,componentRegistry:R,updateQueue:KZ,componentContextStack:I,currentComponentId:H,currentHookIndex:b,isRenderingComponent:c,componentUpdateCallbacks:r},window.__0x1_hooksSystem={isInitialized:!0,forceUpdateAll:LZ,triggerUpdate:f,getAllComponents:()=>Array.from(R.keys()),getComponentData:(Y)=>R.get(Y),setComponentContext:n,clearComponentContext:a,componentRegistry:R},document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{k(),v()});else k(),v()}}function LZ(){let Y=0;for(let[$,Z]of R.entries())if(Z.isMounted)jY($),Y++;if(typeof window!=="undefined"){if(window.__0x1_polyfillsReady=!0,!window.__0x1_lateComponentCallbacks)window.__0x1_lateComponentCallbacks=[];(window.__0x1_lateComponentCallbacks||[]).forEach((Z,X)=>{try{Z()}catch(G){console.error(`[0x1 Hooks] Error in late callback ${X+1}:`,G)}}),window.__0x1_lateComponentCallbacks=[]}}function S(Y){if(!H)throw new Error("[0x1 Hooks] useState must be called within a component context");let $;try{$=h()}catch(Q){throw console.error(`[0x1 Hooks] ❌ Failed to get component data for ${H}:`,Q),Q}if(!Array.isArray($.states))console.warn(`[0x1 Hooks] ⚠️ States is not an array for ${H}, fixing...`),$.states=[];if(typeof $.hookIndex!=="number")console.warn(`[0x1 Hooks] ⚠️ hookIndex is not a number for ${H}, resetting to 0`),$.hookIndex=0;let Z=$.hookIndex++,X=H,G=Array.isArray($.states)?$.states.length:0;if(Z>=G){let Q=typeof Y==="function"?Y():Y;if(!Array.isArray($.states))$.states=[];$.states[Z]=Q}let J=()=>{let Q=R.get(X);if(Q&&Array.isArray(Q.states)&&Z<Q.states.length)return Q.states[Z];if(Array.isArray($.states)&&Z<$.states.length)return $.states[Z];return typeof Y==="function"?Y():Y};return[J(),(Q)=>{let _=R.get(X);if(!_){console.warn(`[0x1 Hooks] No component data found for ${X}`);return}if(!Array.isArray(_.states))console.warn(`[0x1 Hooks] States array missing in setValue for ${X}, initializing...`),_.states=[];let B=Array.isArray(_.states)&&Z<_.states.length?_.states[Z]:J(),U=typeof Q==="function"?Q(B):Q;if(B!==U){if(!Array.isArray(_.states))_.states=[];while(_.states.length<=Z)_.states.push(void 0);_.states[Z]=U;let L=document.querySelectorAll(`[data-component-id="${X}"]`);if(L.length>0)L.forEach((K)=>{K.__0x1_state=K.__0x1_state||{},K.__0x1_state[Z]=U;let A=new CustomEvent("0x1-state-change",{detail:{componentId:X,hookIndex:Z,oldValue:B,newValue:U,stateSnapshot:_.states.slice()}});K.dispatchEvent(A)});let O=r.get(X);if(O)try{O()}catch(K){console.error(`[0x1 Hooks] Legacy update callback failed for ${X}:`,K)}}}]}function y(Y,$){let Z=h(),X=b++,G=H||"unknown";if(Z.effects.length<=X)Z.effects[X]={effect:Y,cleanup:void 0,deps:void 0,id:`${G}:${X}`};let J=Z.effects[X];if(KY(J.deps,$)){if(J.deps=$?[...$]:void 0,J.effect=Y,J.cleanup){try{J.cleanup()}catch(W){console.error("[0x1 Hooks] Effect cleanup error:",W)}J.cleanup=void 0}try{let W=Y();if(typeof W==="function")J.cleanup=W}catch(W){console.error(`[0x1 Hooks] Effect execution error for ${G}:`,W)}}}function UY(Y,$){let Z=h(),X=b++,G=H||"unknown";if(Z.effects.length<=X)Z.effects[X]={effect:Y,cleanup:void 0,deps:void 0,id:`${G}:${X}`};let J=Z.effects[X];if(KY(J.deps,$)){J.deps=$?[...$]:void 0,J.effect=Y;try{if(J.cleanup&&typeof J.cleanup==="function")J.cleanup();let W=Y();J.cleanup=W}catch(W){l(W,"useLayoutEffect")}}}function o(Y,$){let Z=h(),X=b++;if(Z.memos.length<=X)Z.memos[X]={value:Y(),deps:[...$]};let G=Z.memos[X];if(KY(G.deps,$))G.value=Y(),G.deps=[...$];return G.value}function V(Y,$){return o(()=>Y,$)}function t(Y=null){let $=h(),Z=b++;if($.refs.length<=Z)$.refs[Z]={current:Y};return $.refs[Z]}function AZ(Y){let $=R.get(Y);if($)$.isMounted=!0}function MZ(Y){let $=R.get(Y);if(!$)return;$.effects.forEach((Z,X)=>{if(!Z.deps||Z.deps.length===0)try{if(Z.cleanup&&typeof Z.cleanup==="function")Z.cleanup();let G=Z.effect();Z.cleanup=G}catch(G){console.error(`[0x1 Hooks] Error executing mount effect for ${Y}:`,G),l(G,`mount effect for ${Y}`)}})}function FZ(Y){let $=t(null);return y(()=>{let Z=(X)=>{if($.current&&!$.current.contains(X.target))Y()};return document.addEventListener("mousedown",Z),()=>{document.removeEventListener("mousedown",Z)}},[Y]),$}function RZ(Y,$){let[Z,X]=S(null),[G,J]=S(!0),[q,W]=S(null);return y(()=>{if(!Y)return;let Q=!1;return J(!0),W(null),fetch(Y,$).then((_)=>{if(!_.ok)throw new Error(`HTTP error! status: ${_.status}`);return _.json()}).then((_)=>{if(!Q)X(_),J(!1)}).catch((_)=>{if(!Q)W(_),J(!1)}),()=>{Q=!0}},[Y,JSON.stringify($)]),{data:Z,loading:G,error:q}}function HZ(Y,$){let[Z,X]=S(Y),[G,J]=S({}),[q,W]=S({}),Q=V((K,A)=>{if(X((N)=>({...N,[K]:A})),q[K]&&$?.[K]){let N=$[K](A);J((F)=>({...F,[K]:N||void 0}))}},[q,$]),_=V((K,A=!0)=>{W((N)=>({...N,[K]:A}))},[]),B=V((K)=>{if(!$?.[K])return null;let A=$[K](Z[K]);return J((N)=>({...N,[K]:A||void 0})),A},[Z,$]),U=V(()=>{if(!$)return!0;let K={},A=!0;return Object.keys($).forEach((N)=>{let F=$[N](Z[N]);if(F)K[N]=F,A=!1}),J(K),A},[Z,$]),L=V(()=>{X(Y),J({}),W({})},[Y]),O=V((K)=>{return(A)=>{if(A&&typeof A.preventDefault==="function")A.preventDefault();if(U())K(Z)}},[Z,U]);return{values:Z,errors:G,touched:q,setValue:Q,setFieldTouched:_,validateField:B,validateAll:U,reset:L,handleSubmit:O,isValid:Object.keys(G).filter((K)=>G[K]).length===0}}function NZ(Y,$){let[Z,X]=S(()=>{try{if(typeof window==="undefined")return $;let J=window.localStorage.getItem(Y);return J?JSON.parse(J):$}catch(J){return $}}),G=V((J)=>{try{let q=typeof J==="function"?J(Z):J;if(X(q),typeof window!=="undefined")window.localStorage.setItem(Y,JSON.stringify(q))}catch(q){console.warn(`[0x1 useLocalStorage] Error setting localStorage key "${Y}":`,q)}},[Y,Z]);return y(()=>{if(typeof window==="undefined")return;let J=(q)=>{if(q.key===Y&&q.newValue!==null)try{X(JSON.parse(q.newValue))}catch(W){console.warn(`[0x1 useLocalStorage] Error parsing storage event for key "${Y}":`,W)}};return window.addEventListener("storage",J),()=>window.removeEventListener("storage",J)},[Y]),[Z,G]}function l(Y,$){console.error(`[0x1 Hooks] Error in ${$}:`,Y)}if(typeof window!=="undefined"){if(window.__0x1_real_hooks_loaded=!0,window.__0x1_enterComponentContext=BY,window.__0x1_exitComponentContext=zY,window.__0x1_triggerUpdate=f,OZ(),document.readyState==="loading")document.addEventListener("DOMContentLoaded",()=>{k(),v()});else k(),v();if(!s)vY(),s=!0;window.__0x1_hooks_real_system_loaded=!0;let Y={enterComponentContext:BY,exitComponentContext:zY,setComponentContext:n,clearComponentContext:a,triggerComponentUpdate:f,useState:S,useEffect:y,useLayoutEffect:UY,useMemo:o,useCallback:V,useRef:t};try{delete window.__0x1_enterComponentContext,delete window.__0x1_exitComponentContext,delete window.__0x1_triggerUpdate}catch($){}if(window.__0x1_enterComponentContext=Y.enterComponentContext,window.__0x1_exitComponentContext=Y.exitComponentContext,window.__0x1_triggerUpdate=Y.triggerComponentUpdate,window.__0x1_real_hooks_loaded=!0,!window.React)window.React={};Object.assign(window.React,Y)}class DY{updateQueues=new Map;effectQueues=new Map;isScheduling=!1;frameId=null;immediateTimeoutId=null;constructor(){[0,1,2,3,4].forEach(($)=>{this.updateQueues.set($,new Set),this.effectQueues.set($,new Set)})}scheduleUpdate(Y,$=2){this.updateQueues.get($).add(Y),this.markComponentNeedsUpdate(Y),this.scheduleWork($)}scheduleEffect(Y,$=2){this.effectQueues.get($).add(Y),this.scheduleWork($)}scheduleWork(Y){if(this.isScheduling)return;if(this.isScheduling=!0,Y===0){if(this.immediateTimeoutId)clearTimeout(this.immediateTimeoutId);this.immediateTimeoutId=setTimeout(()=>this.flushWork(),0);return}if(this.frameId)cancelAnimationFrame(this.frameId);this.frameId=requestAnimationFrame(()=>{this.flushWork()})}flushWork(){try{for(let Y of[0,1,2,3,4]){let $=this.updateQueues.get(Y);if($.size>0){let X=Array.from($);$.clear();for(let G of X)this.flushComponentUpdate(G)}let Z=this.effectQueues.get(Y);if(Z.size>0){let X=Array.from(Z);Z.clear(),this.flushEffects(X)}}}finally{this.isScheduling=!1,this.frameId=null,this.immediateTimeoutId=null}}markComponentNeedsUpdate(Y){let $=R.get(Y);if($)$.needsUpdate=!0}flushComponentUpdate(Y){let $=R.get(Y);if(!$||!$.needsUpdate)return;$.needsUpdate=!1,$.updateScheduled=!1;let Z=r.get(Y);if(Z)try{Z()}catch(X){l(X,`Component update: ${Y}`)}}flushEffects(Y){let $=new Map;for(let Z of Y){let[X]=Z.split(":");if(!$.has(X))$.set(X,[]);$.get(X).push(Z)}for(let[Z,X]of $){let G=R.get(Z);if(!G)continue;for(let J of X){let q=parseInt(J.split(":")[1]),W=G.effects[q];if(W)this.executeEffect(W)}}}executeEffect(Y){try{if(Y.cleanup&&typeof Y.cleanup==="function")Y.cleanup(),Y.cleanup=void 0;let $=Y.effect();if(typeof $==="function")Y.cleanup=$}catch($){l($,`Effect execution: ${Y.id}`)}}}var TZ=new DY,i=new WeakMap;function wY(Y,$,Z,X,G){try{document.documentElement.style.setProperty(`--0x1-${$}-${Z}`,String(X)),document.documentElement.style.setProperty(`--0x1-${$}-${Z}-bool`,typeof X==="boolean"?X?"1":"0":"0"),Y.setAttribute(`data-0x1-state-${Z}`,String(X)),Y.setAttribute(`data-0x1-value-${Z}`,String(X));let J=new CustomEvent("0x1-state-update",{detail:{componentId:$,hookIndex:Z,newValue:X,oldValue:G,type:typeof X},bubbles:!0,cancelable:!1});if(Y.dispatchEvent(J),$.includes("ThemeToggle")){let Q=X,_=document.documentElement,B=document.body;if(Q)_.classList.add("dark"),B.classList.add("dark");else _.classList.remove("dark"),B.classList.remove("dark");return}let q=document.querySelectorAll(`[data-component-id="${$}"]`);if(q.length>0)q.forEach((Q)=>{if(Z===0&&typeof X==="string")if(X.startsWith("entity-")){let B={"entity-swift":{name:"Entity Swift",badge:"Swift",color:"from-cyan-500 to-blue-500",learning:"Session-adaptive"},"entity-fusion":{name:"Entity Fusion",badge:"Fusion",color:"from-violet-500 to-purple-500",learning:"Workflow-adaptive"},"entity-quantum":{name:"Entity Quantum",badge:"Quantum",color:"from-emerald-500 to-teal-500",learning:"Self-integrating"}}[X];if(B)Q.querySelectorAll("[data-model-name]").forEach((F)=>{F.textContent=B.name}),Q.querySelectorAll("[data-model-badge]").forEach((F)=>{F.textContent=B.badge,F.className=F.className.replace(/from-\w+-\d+\s+to-\w+-\d+/g,B.color)}),Q.querySelectorAll("[data-model-dot]").forEach((F)=>{F.className=F.className.replace(/from-\w+-\d+\s+to-\w+-\d+/g,B.color)}),Q.querySelectorAll("[data-model-learning]").forEach((F)=>{F.textContent=B.learning}),Q.querySelectorAll("[data-model-name]").forEach((F)=>{let XY=F.parentElement;if(XY)XY.querySelectorAll("span").forEach((T)=>{if(T!==F&&(T.className.includes("orange-")||T.textContent?.includes("-adaptive")||T.textContent?.includes("integrating")))T.textContent=B.learning,console.log(`[0x1 Direct DOM] ✅ Updated learning type (fallback) to: ${B.learning}`)})}),Q.querySelectorAll("[data-model-select]").forEach((F)=>{let JY=F.getAttribute("data-model-select")===X;if(JY)F.classList.add("bg-primary/5","border-l-2","border-l-primary");else F.classList.remove("bg-primary/5","border-l-2","border-l-primary");let T=F.querySelector(".w-6.h-6.rounded-full.bg-primary");if(JY)if(!T){let GY=document.createElement("div");GY.className="w-6 h-6 rounded-full bg-primary flex items-center justify-center flex-shrink-0",GY.innerHTML=` <svg class="w-3 h-3 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="3" d="M5 13l4 4L19 7" /> </svg> `;let NY=F.querySelector(".flex.items-start.justify-between");if(NY)NY.appendChild(GY)}else T.style.display="flex";else if(T)T.style.display="none"})}else Q.querySelectorAll("[data-selected-display], .selected-display, [data-current-model], [data-model-name]").forEach((B)=>{if(B.textContent!==null)B.textContent=X});else if(Z===1&&typeof X==="boolean")Q.querySelectorAll('[data-action="toggle-web-search"], [data-web-search-toggle]').forEach((B)=>{if(X)B.classList.add("bg-blue-600","text-white"),B.classList.remove("bg-gray-200","text-gray-700");else B.classList.add("bg-gray-200","text-gray-700"),B.classList.remove("bg-blue-600","text-white");let U=B.querySelector("[data-web-search-switch], span");if(U)if(X)U.classList.add("translate-x-5"),U.classList.remove("translate-x-0","translate-x-1");else U.classList.add("translate-x-1"),U.classList.remove("translate-x-5","translate-x-0")});else if(Z===2&&typeof X==="boolean")Q.querySelectorAll("[data-dropdown-content]").forEach((B)=>{if(X)B.classList.remove("hidden","opacity-0","scale-95"),B.classList.add("block","opacity-100","scale-100"),B.style.display="block";else B.classList.add("hidden","opacity-0","scale-95"),B.classList.remove("block","opacity-100","scale-100"),B.style.display="none"})});let W=`${$}.${Z}`;UZ(W,X)}catch(J){console.error(`[0x1 Visual] Error in universal visual updates for ${$}[${Z}]:`,J)}}function CY(Y){le