{"version":3,"sources":["../src/dom/f.ts","../src/dom/hydrate.ts","../src/dom/components/suspenseContext.ts","../src/dom/components/Suspense.tsx","../src/dom/components/ErrorBoundary.tsx","../src/dom/components/lazy.ts"],"names":["f","type","props","children","hydrationCursor","hydratedInstanceRegistry","currentHydratingInstance","hydrate","app","container","options","state","onHydrated","onMismatch","fnode","isFNode","hydrateNode","error","render","value","parent","skipEmptyTextNodes","hydrateTextNode","nodes","child","result","hydrateComponent","hydrateElement","text","current","tag","key","eventName","elWithHandlers","savedCursor","Component","contextId","isProvider","prevContextValue","pushContext","parentRegistry","hasExplicitKey","instanceCount","componentName","_","k","instance","previousHydratingInstance","runWithComponent","isFirstRender","renderFn","currentProps","newNodes","renderNode","nodeParent","marker","lastNode","tempContainer","newNodesArray","reconciledNodes","reconcile","unsafeEffect","popContext","defaultValue","SuspenseCtx","Context","suspenseContext","use","Suspense","fallback","pendingSet","hook","setPendingCount","showFallback","setShowFallback","contextValue","promise","sync","c","newCount","content","ErrorBoundary","onError","resetKey","errorState","setErrorState","prevResetKeyRef","lazy","loader","resolved","LazyWrapper","suspense","module","err"],"mappings":"+NAKO,SAASA,CAAAA,CAEZC,CAAAA,CACAC,CAAAA,CAAAA,GACGC,CAAAA,CACE,CACL,OAAO,CACH,IAAA,CAAAF,CAAAA,CACA,KAAA,CAAOC,CAAAA,EAAS,EAAC,CACjB,SAAAC,CAAAA,CACA,GAAA,CAAKD,CAAAA,EAAO,GAChB,CACJ,CCTA,IACIE,CAAAA,CAA+B,IAAA,CAoC7BC,CAAAA,CAA2B,IAAI,OAAA,CACjCC,CAAAA,CAAwD,KAarD,SAASC,CAAAA,CACdC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CAA0B,EAAC,CACrB,CACN,GAAM,CAAE,KAAA,CAAAC,EAAO,UAAA,CAAAC,CAAAA,CAAY,UAAA,CAAAC,CAAW,CAAA,CAAIH,CAAAA,CAO1CN,CAAAA,CAAkBK,CAAAA,CAAU,UAAA,CAE5B,GAA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CAAUF,CAAAA,CAEtCE,CACT","file":"chunk-RYAZ5OLA.mjs","sourcesContent":["import type { FNode, FNodeChild } from './types'\n\n/**\n * f() - Create FNodes without JSX\n */\nexport function f(\n    // eslint-disable-next-line @typescript-eslint/no-explicit-any -- f() is a JSX factory accepting any component function or HTML tag name\n    type: string | ((...args: any[]) => unknown),\n    props?: Record<string, unknown>,\n    ...children: FNodeChild[]\n): FNode {\n    return {\n        type,\n        props: props || {},\n        children,\n        key: props?.key\n    }\n}\n","import type { FNode, FNodeChild } from './types'\nimport type { SerializedState } from '../server/types'\nimport { runWithComponent, type ComponentInstance } from '../core/hook'\nimport { pushContext, popContext } from '../core/context'\nimport { unsafeEffect } from '../core/lifecycle'\nimport { renderNode, reconcile } from './render'\n\n// Hydration state\nlet isHydrating = false\nlet hydrationCursor: Node | null = null\nlet hydrationState: SerializedState | null = null\n\nexport interface HydrateOptions {\n  /**\n   * Serialized state from server\n   * Typically embedded in HTML as JSON script tag\n   */\n  state?: SerializedState\n\n  /**\n   * Called when hydration completes successfully\n   */\n  onHydrated?: () => void\n\n  /**\n   * Called when hydration fails (falls back to full render)\n   */\n  onMismatch?: (error: Error) => void\n}\n\n// Extended ComponentInstance for DOM tracking (mirrors render.ts shape).\n// Phase 5C: pre-initialize every field at construction; `null` is the\n// unallocated sentinel for slots that get populated later.\ninterface DOMComponentInstance extends ComponentInstance {\n  nodes: Node[]\n  parent: HTMLElement\n  fnode: FNode\n  props: Record<string, unknown>\n  key: unknown\n  renderFn: (() => void) | null\n  children: Set<DOMComponentInstance>\n  parentInstance: DOMComponentInstance | null\n}\n\n// Registry for hydrated components\nconst hydratedInstanceRegistry = new WeakMap<HTMLElement, Map<unknown, DOMComponentInstance>>()\nlet currentHydratingInstance: DOMComponentInstance | null = null\n\nexport function getIsHydrating(): boolean {\n  return isHydrating\n}\n\nexport function getHydrationState(): SerializedState | null {\n  return hydrationState\n}\n\n/**\n * Hydrate server-rendered HTML with client-side interactivity\n */\nexport function hydrate(\n  app: FNodeChild | (() => FNodeChild),\n  container: HTMLElement,\n  options: HydrateOptions = {}\n): void {\n  const { state, onHydrated, onMismatch } = options\n\n  // Store state for rehydration\n  hydrationState = state || null\n\n  // Initialize hydration mode\n  isHydrating = true\n  hydrationCursor = container.firstChild\n\n  try {\n    // Normalize input\n    let fnode: FNodeChild\n    if (typeof app === 'function' && !isFNode(app)) {\n      fnode = { type: app, props: {}, children: [], key: undefined }\n    } else {\n      fnode = app\n    }\n\n    // Hydrate the tree\n    hydrateNode(fnode, container)\n\n    onHydrated?.()\n  } catch (error) {\n    // Hydration mismatch - fall back to full render\n    onMismatch?.(error as Error)\n\n    // Clear and re-render\n    container.innerHTML = ''\n    // Import dynamically to avoid circular deps\n    import('./render').then(({ render }) => {\n      render(app, container)\n    })\n  } finally {\n    isHydrating = false\n    hydrationCursor = null\n    hydrationState = null\n  }\n}\n\nfunction isFNode(value: unknown): value is FNode {\n  return value !== null && typeof value === 'object' && 'type' in value && 'props' in value\n}\n\nfunction hydrateNode(fnode: FNodeChild, parent: HTMLElement): Node | Node[] | null {\n  // Null/undefined/boolean -> skip empty text nodes\n  if (fnode === null || fnode === undefined || typeof fnode === 'boolean') {\n    // Server might have rendered an empty text node\n    skipEmptyTextNodes()\n    return null\n  }\n\n  // String/number -> expect text node\n  if (typeof fnode === 'string' || typeof fnode === 'number') {\n    return hydrateTextNode(String(fnode))\n  }\n\n  // Array -> hydrate each child\n  if (Array.isArray(fnode)) {\n    const nodes: Node[] = []\n    for (const child of fnode) {\n      const result = hydrateNode(child, parent)\n      if (result) {\n        if (Array.isArray(result)) {\n          nodes.push(...result)\n        } else {\n          nodes.push(result)\n        }\n      }\n    }\n    return nodes\n  }\n\n  // Function (standalone) -> wrap in FNode and hydrate\n  if (typeof fnode === 'function') {\n    const wrappedFnode: FNode = { type: fnode, props: {}, children: [], key: undefined }\n    return hydrateComponent(wrappedFnode, parent)\n  }\n\n  // Object (FNode)\n  if (typeof fnode === 'object' && isFNode(fnode)) {\n    if (typeof fnode.type === 'string') {\n      return hydrateElement(fnode)\n    }\n\n    if (typeof fnode.type === 'function') {\n      return hydrateComponent(fnode, parent)\n    }\n  }\n\n  return null\n}\n\nfunction skipEmptyTextNodes(): void {\n  while (\n    hydrationCursor &&\n    hydrationCursor.nodeType === Node.TEXT_NODE &&\n    (!hydrationCursor.textContent || hydrationCursor.textContent.trim() === '')\n  ) {\n    hydrationCursor = hydrationCursor.nextSibling\n  }\n}\n\nfunction hydrateTextNode(text: string): Node | null {\n  skipEmptyTextNodes()\n\n  const current = hydrationCursor\n\n  if (!current) {\n    // No node to hydrate - this is okay for conditional rendering\n    return null\n  }\n\n  if (current.nodeType !== Node.TEXT_NODE) {\n    // Try to find a text node nearby (whitespace handling)\n    if (text.trim() === '') {\n      return null\n    }\n    throw new Error(`Hydration mismatch: expected text node \"${text}\", got ${current.nodeName}`)\n  }\n\n  // Update cursor\n  hydrationCursor = current.nextSibling\n\n  return current\n}\n\nfunction hydrateElement(fnode: FNode): Node {\n  skipEmptyTextNodes()\n\n  const current = hydrationCursor as Element\n  const tag = fnode.type as string\n\n  // Validate element type\n  if (!current || current.nodeType !== Node.ELEMENT_NODE) {\n    throw new Error(`Hydration mismatch: expected element <${tag}>, got ${current?.nodeName || 'nothing'}`)\n  }\n\n  if (current.tagName.toLowerCase() !== tag.toLowerCase()) {\n    throw new Error(`Hydration mismatch: expected <${tag}>, got <${current.tagName.toLowerCase()}>`)\n  }\n\n  // Attach event handlers and refs (don't modify DOM structure)\n  if (fnode.props) {\n    for (const [key, value] of Object.entries(fnode.props)) {\n      if (key === 'ref') {\n        if (typeof value === 'function') {\n          value(current)\n        } else if (value && typeof value === 'object' && 'current' in value) {\n          value.current = current\n        }\n      } else if (key.startsWith('on') && typeof value === 'function') {\n        const eventName = key.slice(2).toLowerCase()\n        current.addEventListener(eventName, value as EventListener)\n\n        // Store for reconciliation\n        type ElWithHandlers = Element & { __eventHandlers?: Record<string, EventListener> }\n        const elWithHandlers = current as ElWithHandlers\n        if (!elWithHandlers.__eventHandlers) {\n          elWithHandlers.__eventHandlers = {}\n        }\n        elWithHandlers.__eventHandlers[eventName] = value as EventListener\n      }\n    }\n  }\n\n  // Move cursor past this element\n  hydrationCursor = current.nextSibling\n\n  // Hydrate children\n  if (fnode.children && fnode.children.length > 0) {\n    const savedCursor = hydrationCursor\n\n    hydrationCursor = current.firstChild\n\n    for (const child of fnode.children) {\n      hydrateNode(child, current as HTMLElement)\n    }\n\n    hydrationCursor = savedCursor\n  }\n\n  return current\n}\n\nfunction hydrateComponent(fnode: FNode, parent: HTMLElement): Node | Node[] | null {\n  const Component = fnode.type as (props: Record<string, unknown>) => FNodeChild\n\n  // Merge props\n  const props: Record<string, unknown> = { ...fnode.props }\n  if (fnode.children && fnode.children.length > 0) {\n    props.children = fnode.children.length === 1\n      ? fnode.children[0]\n      : fnode.children\n  }\n\n  // Handle context providers\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ._contextId is a dynamic property set by Context constructor on Provider functions\n  const contextId = (Component as any)._contextId as symbol | undefined\n  const isProvider = contextId !== undefined\n  let prevContextValue: unknown\n\n  if (isProvider) {\n    prevContextValue = pushContext(contextId, props.value)\n  }\n\n  // Generate key (same logic as render.ts)\n  if (!hydratedInstanceRegistry.has(parent)) {\n    hydratedInstanceRegistry.set(parent, new Map())\n  }\n  const parentRegistry = hydratedInstanceRegistry.get(parent)!\n\n  const hasExplicitKey = fnode.key !== undefined\n  let key: unknown\n  if (hasExplicitKey) {\n    key = fnode.key\n  } else {\n    let instanceCount = 0\n    const componentName = Component.name || 'anonymous'\n    parentRegistry.forEach((_, k) => {\n      if (typeof k === 'string' && k.startsWith(`__auto_${componentName}_`)) {\n        instanceCount++\n      }\n    })\n    key = `__auto_${componentName}_${instanceCount}`\n  }\n\n  // Create component instance. Phase 5C: every field pre-initialized.\n  const instance: DOMComponentInstance = {\n    hooks: [],\n    hookIndex: 0,\n    componentName: Component.name || 'Component',\n    hookSignatures: null,\n    prevHookSignatures: null,\n    effects: null,\n    globalKeys: null,\n    nodes: [],\n    parent,\n    fnode,\n    props,\n    key,\n    renderFn: null,\n    children: new Set(),\n    parentInstance: currentHydratingInstance ?? null,\n  }\n\n  if (currentHydratingInstance) {\n    currentHydratingInstance.children.add(instance)\n  }\n\n  parentRegistry.set(key, instance)\n\n  const previousHydratingInstance = currentHydratingInstance\n  currentHydratingInstance = instance\n\n  try {\n    // First render during hydration - just match DOM\n    const result = runWithComponent(instance, () => Component(props))\n    const nodes = hydrateNode(result, parent)\n    instance.nodes = nodes ? (Array.isArray(nodes) ? nodes : [nodes]) : []\n\n    // Set up reactive re-rendering for future updates\n    let isFirstRender = true\n    const renderFn = () => {\n      // Re-render with reconciliation (same logic as render.ts)\n      const currentProps = instance.props\n\n      // Always run the component to establish reactive tracking\n      const result = runWithComponent(instance, () => Component(currentProps))\n\n      if (isFirstRender) {\n        isFirstRender = false\n        return // Skip DOM manipulation on first render, already done during hydration\n      }\n\n      if (instance.nodes.length === 0) {\n        const newNodes = renderNode(result, parent)\n        instance.nodes = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n        return\n      }\n\n      const firstNode = instance.nodes[0]\n      const nodeParent = firstNode.parentNode as HTMLElement\n\n      if (!nodeParent) {\n        return\n      }\n\n      const marker = document.createComment('flexium-marker')\n      const lastNode = instance.nodes[instance.nodes.length - 1]\n      if (lastNode.nextSibling) {\n        nodeParent.insertBefore(marker, lastNode.nextSibling)\n      } else {\n        nodeParent.appendChild(marker)\n      }\n\n      instance.children.clear()\n\n      const tempContainer = document.createElement('div')\n      const newNodes = renderNode(result, tempContainer, nodeParent)\n      const newNodesArray = newNodes ? (Array.isArray(newNodes) ? newNodes : [newNodes]) : []\n\n      const reconciledNodes = reconcile(instance.nodes, newNodesArray, nodeParent, marker)\n\n      nodeParent.removeChild(marker)\n\n      instance.nodes = reconciledNodes\n    }\n\n    instance.renderFn = renderFn\n    // Framework-internal root effect: drives this component's reactive re-renders after hydration.\n    // Use .detached so it is NOT registered on the parent component — ownership is\n    // tracked via DOMComponentInstance itself and stopped in removeComponentInstance.\n    unsafeEffect.detached(renderFn)\n\n    return instance.nodes\n  } finally {\n    currentHydratingInstance = previousHydratingInstance\n\n    if (isProvider) {\n      popContext(contextId, prevContextValue)\n    }\n  }\n}\n","import { Context } from '../../core/context'\nimport { use } from '../../core/use'\nimport type { SuspenseContextValue } from './types'\n\nconst defaultValue: SuspenseContextValue = {\n  register: () => {},\n  hasBoundary: false\n}\n\nexport const SuspenseCtx = new Context<SuspenseContextValue>(defaultValue)\n\nexport function suspenseContext(): SuspenseContextValue {\n  const [value] = use(SuspenseCtx)\n  return value\n}\n","import { use } from '../../core/use'\nimport { sync } from '../../core/lifecycle'\nimport { hook } from '../../core/hook'\nimport { SuspenseCtx } from './suspenseContext'\nimport type { SuspenseProps, SuspenseContextValue } from './types'\nimport type { FNodeChild } from '../types'\n\n/**\n * Suspense component that shows fallback while children are loading\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n *\n * function App() {\n *   return (\n *     <Suspense fallback={<div>Loading...</div>}>\n *       <Dashboard />\n *     </Suspense>\n *   )\n * }\n * ```\n */\nexport function Suspense(props: SuspenseProps): FNodeChild {\n  const { fallback, children } = props\n\n  // Track pending promises using hook for mutable Set\n  const pendingSet = hook(() => new Set<Promise<unknown>>())\n  const [, setPendingCount] = use(0)\n  const [showFallback, setShowFallback] = use(false)\n\n  // Register function for lazy components\n  const register = (promise: Promise<unknown>) => {\n    if (!pendingSet.has(promise)) {\n      // Add to pending set\n      pendingSet.add(promise)\n      sync(() => {\n        setPendingCount(c => c + 1)\n        setShowFallback(true)\n      })\n\n      // Wait for resolution\n      promise.finally(() => {\n        pendingSet.delete(promise)\n        const newCount = pendingSet.size\n        sync(() => {\n          setPendingCount(() => newCount)\n          if (newCount === 0) {\n            setShowFallback(false)\n          }\n        })\n      })\n    }\n  }\n\n  const contextValue: SuspenseContextValue = {\n    register,\n    hasBoundary: true\n  }\n\n  // Render fallback or children based on pending state\n  const content = showFallback ? fallback : children\n\n  // Wrap content with Suspense context provider\n  return {\n    type: SuspenseCtx.Provider as unknown as (props: Record<string, unknown>) => unknown,\n    props: { value: contextValue as unknown },\n    children: [content],\n    key: undefined\n  }\n}\n","import { use } from '../../core/use'\nimport { hook } from '../../core/hook'\nimport { getRequestContext } from '../../core/request-context'\nimport type { FNodeChild } from '../types'\nimport type { ErrorInfo, ErrorBoundaryProps } from './types'\n\n// Component name stack — per-request via RequestContext\nexport function pushComponentName(name: string): void {\n  getRequestContext().componentNameStack.push(name)\n}\n\nexport function popComponentName(): void {\n  getRequestContext().componentNameStack.pop()\n}\n\nexport function getComponentStack(): string {\n  return getRequestContext().componentNameStack\n    .map(name => `    at ${name}`)\n    .reverse()\n    .join('\\n')\n}\n\n// Stack of error boundaries for nested error propagation\ninterface ErrorBoundaryInstance {\n  handleError: (error: Error, phase: 'render' | 'effect' | 'event') => void\n}\n\nconst errorBoundaryStack: ErrorBoundaryInstance[] = []\n\nexport function pushErrorBoundary(instance: ErrorBoundaryInstance): void {\n  errorBoundaryStack.push(instance)\n}\n\nexport function popErrorBoundary(): void {\n  errorBoundaryStack.pop()\n}\n\nexport function getNearestErrorBoundary(): ErrorBoundaryInstance | null {\n  return errorBoundaryStack[errorBoundaryStack.length - 1] || null\n}\n\n/**\n * ErrorBoundary component that catches errors in its children and displays fallback UI\n *\n * @example\n * ```tsx\n * <ErrorBoundary\n *   fallback={(error, info) => <div>Error: {error.message}</div>}\n *   onError={(error, info) => console.error(error)}\n * >\n *   <App />\n * </ErrorBoundary>\n * ```\n */\nexport function ErrorBoundary(props: ErrorBoundaryProps): FNodeChild {\n  const { fallback, onError, children, resetKey } = props\n\n  // Error state\n  const [errorState, setErrorState] = use<{\n    error: Error | null\n    info: ErrorInfo | null\n  }>({ error: null, info: null })\n\n  // Track reset key changes to clear error\n  const prevResetKeyRef = hook(() => ({ current: resetKey }))\n\n  if (resetKey !== prevResetKeyRef.current) {\n    prevResetKeyRef.current = resetKey\n    if (errorState.error !== null) {\n      setErrorState({ error: null, info: null })\n    }\n  }\n\n  // Error boundary instance\n  const boundaryInstance: ErrorBoundaryInstance = {\n    handleError: (error: Error, phase: 'render' | 'effect' | 'event') => {\n      const info: ErrorInfo = {\n        componentStack: getComponentStack(),\n        phase\n      }\n\n      // Call error callback\n      onError?.(error, info)\n\n      // Update error state (triggers re-render with fallback)\n      setErrorState({ error, info })\n    }\n  }\n\n  // If we have an error, render fallback\n  if (errorState.error) {\n    if (typeof fallback === 'function') {\n      return fallback(errorState.error, errorState.info!)\n    }\n    return fallback\n  }\n\n  // Push boundary onto stack for children to use\n  pushErrorBoundary(boundaryInstance)\n\n  try {\n    // Return children - they will be rendered with this boundary active\n    return children\n  } finally {\n    popErrorBoundary()\n  }\n}\n","import { suspenseContext } from './suspenseContext'\nimport type { FNodeChild } from '../types'\nimport type { LazyComponent } from './types'\n\n/**\n * Creates a lazy-loaded component for code splitting\n *\n * @example\n * ```tsx\n * const Dashboard = lazy(() => import('./Dashboard'))\n * const Settings = lazy(() => import('./Settings'))\n *\n * function App() {\n *   return (\n *     <Suspense fallback={<div>Loading...</div>}>\n *       <Dashboard />\n *     </Suspense>\n *   )\n * }\n * ```\n */\nexport function lazy<P = Record<string, unknown>>(\n  loader: () => Promise<{ default: (props: P) => FNodeChild }>\n): LazyComponent<P> {\n  // Shared state across all instances\n  let resolved: ((props: P) => FNodeChild) | null = null\n  let promise: Promise<unknown> | null = null\n  let error: Error | null = null\n\n  // The wrapper component\n  const LazyWrapper = (props: P): FNodeChild => {\n    // If already resolved, render immediately\n    if (resolved) {\n      return resolved(props)\n    }\n\n    // If error occurred, throw it (will be caught by ErrorBoundary)\n    if (error) {\n      throw error\n    }\n\n    // Get suspense context\n    const suspense = suspenseContext()\n\n    // Start loading if not already\n    if (!promise) {\n      promise = loader()\n        .then(module => {\n          resolved = module.default\n        })\n        .catch(err => {\n          error = err instanceof Error ? err : new Error(String(err))\n        })\n    }\n\n    // Register with suspense boundary if available\n    if (suspense.hasBoundary) {\n      suspense.register(promise)\n    }\n\n    // Return null - Suspense will show fallback\n    return null\n  }\n\n  // Mark as lazy component\n  ;(LazyWrapper as LazyComponent<P>)._lazy = true\n  ;(LazyWrapper as LazyComponent<P>)._loader = loader\n\n  return LazyWrapper as LazyComponent<P>\n}\n"]}