{"version":3,"file":"DOMContextProvider.mjs","sources":["../../../../src/lib/layouts/context-aware/DOMContextProvider.tsx"],"sourcesContent":["/**\n * @fileoverview DOM Context Provider Component\n *\n * This component provides comprehensive DOM context to its descendants:\n * - Layout ancestry tracking\n * - Viewport awareness\n * - Scroll container detection\n * - Portal context bridging\n * - Z-index management\n *\n * Features:\n * - Automatic context updates on layout changes\n * - Performance-optimized batched updates\n * - Memory-efficient context storage\n * - SSR-compatible with graceful degradation\n *\n * @module layouts/context-aware/DOMContextProvider\n * @author Agent 4 - PhD Context Systems Expert\n * @version 1.0.0\n */\n\n/* eslint-disable react-refresh/only-export-components */\n\nimport React, {\n  createContext,\n  useContext,\n  useEffect,\n  useRef,\n  useState,\n  useCallback,\n  useMemo,\n  type ReactNode,\n} from 'react';\n\nimport type {\n  DOMContext,\n  DOMContextProviderProps,\n  ViewportInfo,\n  LayoutAncestor,\n  ScrollContainer,\n  PortalContext,\n  ZIndexContext,\n} from './types';\nimport { DEFAULT_TRACKING_CONFIG } from './types';\nimport { getDOMContextTracker } from './dom-context';\nimport { getViewportTracker } from './viewport-awareness';\nimport { findScrollContainer } from './scroll-tracker';\nimport { getPortalContextManager } from './portal-bridge';\nimport { getZIndexManager } from './z-index-manager';\n\n// ============================================================================\n// Context Creation\n// ============================================================================\n\n/* @refresh reset */\n\n/**\n * Default DOM context for SSR and initial render.\n */\nconst defaultDOMContext: DOMContext = {\n  ancestors: [],\n  viewport: {\n    width: 1024,\n    height: 768,\n    scrollX: 0,\n    scrollY: 0,\n    scrollWidth: 1024,\n    scrollHeight: 768,\n    devicePixelRatio: 1,\n    isTouch: false,\n    orientation: 'landscape',\n    safeAreaInsets: { top: 0, right: 0, bottom: 0, left: 0 },\n  },\n  scrollContainer: null,\n  portal: null,\n  zIndex: {\n    zIndex: 0,\n    layer: 'base',\n    stackingContextRoot: null,\n    createsStackingContext: false,\n    orderInLayer: 0,\n    layerCount: 0,\n  },\n  isInitialized: false,\n  isSSR: typeof window === 'undefined',\n  contextId: 'default',\n  lastUpdated: 0,\n};\n\n/**\n * React context for DOM context state.\n */\nexport const DOMContextReactContext = createContext<DOMContext>(defaultDOMContext);\n\n/**\n * React context for DOM context update function.\n */\nexport const DOMContextUpdateContext = createContext<(() => void) | null>(null);\n\n// ============================================================================\n// Context ID Generation\n// ============================================================================\n\nlet contextIdCounter = 0;\n\nfunction generateContextId(): string {\n  return `dom-ctx-${++contextIdCounter}-${Date.now()}`;\n}\n\n// ============================================================================\n// DOMContextProvider Component\n// ============================================================================\n\n/**\n * Provides DOM context to descendant components.\n *\n * @remarks\n * This is the main provider component that should wrap your application\n * or the parts of your application that need DOM context awareness.\n *\n * @example\n * ```tsx\n * // Basic usage\n * <DOMContextProvider>\n *   <App />\n * </DOMContextProvider>\n *\n * // With options\n * <DOMContextProvider\n *   updateDebounceMs={100}\n *   trackScrollContainers={true}\n *   onContextUpdate={(ctx) => console.log('Context updated:', ctx)}\n * >\n *   <App />\n * </DOMContextProvider>\n * ```\n */\nexport function DOMContextProvider({\n  children,\n  className,\n  style,\n  initialViewport,\n  updateDebounceMs = DEFAULT_TRACKING_CONFIG.debounceMs,\n  trackScrollContainers = true,\n  trackZIndex = true,\n  onContextUpdate,\n  'data-testid': testId,\n}: DOMContextProviderProps): React.JSX.Element {\n  // Generate context ID once\n  const [contextId] = useState(() => generateContextId());\n\n  // Refs\n  const containerRef = useRef<HTMLDivElement>(null);\n  const contextIdRef = useRef<string>(contextId);\n  const rafHandleRef = useRef<number | null>(null);\n  const debounceTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n  const isSSR = typeof window === 'undefined';\n\n  // State - generate initial state inline to avoid ref issues\n  const [context, setContext] = useState<DOMContext>(() => ({\n    ...defaultDOMContext,\n    viewport:\n      initialViewport != null\n        ? { ...defaultDOMContext.viewport, ...initialViewport }\n        : defaultDOMContext.viewport,\n    contextId,\n    isSSR,\n  }));\n\n  /**\n   * Computes the full DOM context.\n   */\n  const computeContext = useCallback((): DOMContext => {\n    if (isSSR || !containerRef.current) {\n      return {\n        ...defaultDOMContext,\n        contextId: contextIdRef.current,\n        isSSR,\n        isInitialized: false,\n      };\n    }\n\n    const element = containerRef.current;\n    const domTracker = getDOMContextTracker();\n    const viewportTracker = getViewportTracker();\n    const zIndexManager = getZIndexManager();\n\n    // Get ancestors\n    const ancestors: readonly LayoutAncestor[] = domTracker.getAncestry(element);\n\n    // Get viewport\n    const viewport: ViewportInfo = viewportTracker.getViewport();\n\n    // Get scroll container\n    let scrollContainer: ScrollContainer | null = null;\n    if (trackScrollContainers === true) {\n      const scrollTracker = findScrollContainer(element);\n      if (scrollTracker != null) {\n        scrollContainer = scrollTracker.getState();\n      }\n    }\n\n    // Get portal context\n    const portalManager = getPortalContextManager();\n    const portal: PortalContext | null = portalManager.getContextForElement(element);\n\n    // Get z-index context\n    const zIndex: ZIndexContext =\n      trackZIndex === true ? zIndexManager.getZIndexContext(element) : defaultDOMContext.zIndex;\n\n    return {\n      ancestors,\n      viewport,\n      scrollContainer,\n      portal,\n      zIndex,\n      isInitialized: true,\n      isSSR: false,\n      contextId: contextIdRef.current,\n      lastUpdated: Date.now(),\n    };\n  }, [isSSR, trackScrollContainers, trackZIndex]);\n\n  /**\n   * Updates context with debouncing.\n   */\n  const updateContext = useCallback(() => {\n    if (debounceTimerRef.current) {\n      clearTimeout(debounceTimerRef.current);\n    }\n\n    debounceTimerRef.current = setTimeout(() => {\n      const { current: rafHandle } = rafHandleRef;\n      if (rafHandle != null) {\n        cancelAnimationFrame(rafHandle);\n      }\n\n      rafHandleRef.current = requestAnimationFrame(() => {\n        const newContext = computeContext();\n        setContext(newContext);\n        onContextUpdate?.(newContext);\n        rafHandleRef.current = null;\n      });\n\n      debounceTimerRef.current = null;\n    }, updateDebounceMs);\n  }, [computeContext, updateDebounceMs, onContextUpdate]);\n\n  /**\n   * Forces immediate context update (bypasses debounce).\n   */\n  const forceUpdate = useCallback(() => {\n    const { current: debounceTimer } = debounceTimerRef;\n    if (debounceTimer != null) {\n      clearTimeout(debounceTimer);\n      debounceTimerRef.current = null;\n    }\n    const { current: rafHandle } = rafHandleRef;\n    if (rafHandle != null) {\n      cancelAnimationFrame(rafHandle);\n      rafHandleRef.current = null;\n    }\n\n    const newContext = computeContext();\n    setContext(newContext);\n    onContextUpdate?.(newContext);\n  }, [computeContext, onContextUpdate]);\n\n  // Initialize context on mount\n  useEffect(() => {\n    if (isSSR) {\n      return;\n    }\n\n    // Initial context computation - schedule to avoid setState in effect warning\n    const timeoutId = setTimeout(() => {\n      forceUpdate();\n    }, 0);\n\n    // Subscribe to viewport changes\n    const viewportTracker = getViewportTracker();\n    const unsubscribeViewport = viewportTracker.onViewportChange(() => {\n      updateContext();\n    });\n\n    // Set up resize observer\n    let resizeObserver: ResizeObserver | null = null;\n    if (containerRef.current) {\n      resizeObserver = new ResizeObserver(() => {\n        updateContext();\n      });\n      resizeObserver.observe(containerRef.current);\n    }\n\n    // Set up mutation observer\n    let mutationObserver: MutationObserver | null = null;\n    if (containerRef.current) {\n      mutationObserver = new MutationObserver(() => {\n        updateContext();\n      });\n      mutationObserver.observe(containerRef.current, {\n        childList: true,\n        subtree: true,\n        attributes: true,\n        attributeFilter: ['style', 'class'],\n      });\n    }\n\n    // Cleanup\n    return () => {\n      clearTimeout(timeoutId);\n      unsubscribeViewport();\n      resizeObserver?.disconnect();\n      mutationObserver?.disconnect();\n\n      const { current: debounceTimer } = debounceTimerRef;\n      if (debounceTimer != null) {\n        clearTimeout(debounceTimer);\n      }\n      const { current: rafHandle } = rafHandleRef;\n      if (rafHandle != null) {\n        cancelAnimationFrame(rafHandle);\n      }\n    };\n  }, [isSSR, forceUpdate, updateContext]);\n\n  // Memoize context value to prevent unnecessary re-renders\n  const contextValue = useMemo(() => context, [context]);\n\n  return (\n    <DOMContextReactContext.Provider value={contextValue}>\n      <DOMContextUpdateContext.Provider value={forceUpdate}>\n        <div\n          ref={containerRef}\n          className={className}\n          style={style}\n          data-testid={testId}\n          data-dom-context-root={context.contextId}\n        >\n          {children}\n        </div>\n      </DOMContextUpdateContext.Provider>\n    </DOMContextReactContext.Provider>\n  );\n}\n\n// ============================================================================\n// Consumer Components\n// ============================================================================\n\n/**\n * Props for DOMContextConsumer render prop component.\n */\nexport interface DOMContextConsumerProps {\n  children: (context: DOMContext) => ReactNode;\n}\n\n/**\n * Render prop component for consuming DOM context.\n *\n * @example\n * ```tsx\n * <DOMContextConsumer>\n *   {(context) => (\n *     <div>\n *       Viewport: {context.viewport.width}x{context.viewport.height}\n *     </div>\n *   )}\n * </DOMContextConsumer>\n * ```\n */\nexport function DOMContextConsumer({ children }: DOMContextConsumerProps): React.JSX.Element {\n  const context = useContext(DOMContextReactContext);\n  return <>{children(context)}</>;\n}\n\n// ============================================================================\n// Hook Exports\n// ============================================================================\n\n/**\n * Hook to access the full DOM context.\n *\n * @returns Current DOMContext\n *\n * @example\n * ```tsx\n * function MyComponent() {\n *   const context = useDOMContextValue();\n *   return <div>Initialized: {context.isInitialized}</div>;\n * }\n * ```\n */\nexport function useDOMContextValue(): DOMContext {\n  return useContext(DOMContextReactContext);\n}\n\n/**\n * Hook to get the context update function.\n *\n * @returns Update function or null\n *\n * @example\n * ```tsx\n * function MyComponent() {\n *   const refresh = useDOMContextRefresh();\n *   return <button onClick={() => refresh?.()}>Refresh</button>;\n * }\n * ```\n */\nexport function useDOMContextRefresh(): (() => void) | null {\n  return useContext(DOMContextUpdateContext);\n}\n\n// ============================================================================\n// Higher-Order Component\n// ============================================================================\n\n/**\n * Props injected by withDOMContext HOC.\n */\nexport interface WithDOMContextProps {\n  domContext: DOMContext;\n}\n\n/**\n * Higher-order component that injects DOM context as a prop.\n *\n * @param Component - Component to wrap\n * @returns Wrapped component with DOM context\n *\n * @example\n * ```tsx\n * interface MyComponentProps extends WithDOMContextProps {\n *   title: string;\n * }\n *\n * function MyComponent({ title, domContext }: MyComponentProps) {\n *   return (\n *     <div>\n *       {title} - {domContext.viewport.width}px\n *     </div>\n *   );\n * }\n *\n * export default withDOMContext(MyComponent);\n * ```\n */\nexport function withDOMContext<P extends WithDOMContextProps>(\n  Component: React.ComponentType<P>\n): React.ComponentType<Omit<P, 'domContext'>> {\n  const displayName =\n    Component.displayName != null && Component.displayName !== ''\n      ? Component.displayName\n      : (Component.name ?? 'Component');\n\n  const WrappedComponent = (props: Omit<P, 'domContext'>): React.JSX.Element => {\n    const domContext = useDOMContextValue();\n    return <Component {...(props as P)} domContext={domContext} />;\n  };\n\n  WrappedComponent.displayName = `withDOMContext(${displayName})`;\n\n  return WrappedComponent;\n}\n\n// ============================================================================\n// Nested Provider\n// ============================================================================\n\n/**\n * Props for NestedDOMContextProvider.\n */\nexport interface NestedDOMContextProviderProps extends Omit<\n  DOMContextProviderProps,\n  'initialViewport'\n> {\n  /** Whether to inherit from parent context */\n  inheritParent?: boolean;\n}\n\n/**\n * Nested DOM context provider that can optionally inherit from parent.\n *\n * @remarks\n * Use this when you need a sub-tree to have its own DOM context\n * while optionally inheriting some state from the parent context.\n *\n * @example\n * ```tsx\n * <DOMContextProvider>\n *   <NestedDOMContextProvider inheritParent>\n *     <MyComponent />\n *   </NestedDOMContextProvider>\n * </DOMContextProvider>\n * ```\n */\nexport function NestedDOMContextProvider({\n  children,\n  inheritParent = true,\n  ...props\n}: NestedDOMContextProviderProps): React.JSX.Element {\n  const parentContext = useDOMContextValue();\n\n  // If inheriting and parent is initialized, merge viewport\n  const initialViewport =\n    inheritParent && parentContext.isInitialized ? parentContext.viewport : undefined;\n\n  return (\n    <DOMContextProvider {...props} initialViewport={initialViewport}>\n      {children}\n    </DOMContextProvider>\n  );\n}\n\n// ============================================================================\n// Selector Hook\n// ============================================================================\n\n/**\n * Hook to select a specific part of DOM context with memoization.\n *\n * @param selector - Selector function\n * @returns Selected value\n *\n * @example\n * ```tsx\n * function MyComponent() {\n *   const viewport = useDOMContextSelector((ctx) => ctx.viewport);\n *   const isInitialized = useDOMContextSelector((ctx) => ctx.isInitialized);\n *\n *   return <div>Width: {viewport.width}</div>;\n * }\n * ```\n */\nexport function useDOMContextSelector<T>(selector: (context: DOMContext) => T): T {\n  const context = useDOMContextValue();\n  return useMemo(() => selector(context), [context, selector]);\n}\n"],"names":["defaultDOMContext","DOMContextReactContext","createContext","DOMContextUpdateContext","contextIdCounter","generateContextId","DOMContextProvider","children","className","style","initialViewport","updateDebounceMs","DEFAULT_TRACKING_CONFIG","trackScrollContainers","trackZIndex","onContextUpdate","testId","contextId","useState","containerRef","useRef","contextIdRef","rafHandleRef","debounceTimerRef","isSSR","context","setContext","computeContext","useCallback","element","domTracker","getDOMContextTracker","viewportTracker","getViewportTracker","zIndexManager","getZIndexManager","ancestors","viewport","scrollContainer","scrollTracker","findScrollContainer","portal","getPortalContextManager","zIndex","updateContext","rafHandle","newContext","forceUpdate","debounceTimer","useEffect","timeoutId","unsubscribeViewport","resizeObserver","mutationObserver","contextValue","useMemo","jsx","DOMContextConsumer","useContext","Fragment","useDOMContextValue","useDOMContextRefresh","withDOMContext","Component","displayName","WrappedComponent","props","domContext","NestedDOMContextProvider","inheritParent","parentContext","useDOMContextSelector","selector"],"mappings":";;;;;;;;AA2DA,MAAMA,IAAgC;AAAA,EACpC,WAAW,CAAA;AAAA,EACX,UAAU;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,SAAS;AAAA,IACT,aAAa;AAAA,IACb,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,SAAS;AAAA,IACT,aAAa;AAAA,IACb,gBAAgB,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAA;AAAA,EAAE;AAAA,EAEzD,iBAAiB;AAAA,EACjB,QAAQ;AAAA,EACR,QAAQ;AAAA,IACN,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,qBAAqB;AAAA,IACrB,wBAAwB;AAAA,IACxB,cAAc;AAAA,IACd,YAAY;AAAA,EAAA;AAAA,EAEd,eAAe;AAAA,EACf,OAAO,OAAO,SAAW;AAAA,EACzB,WAAW;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