{"version":3,"file":"types.mjs","sources":["../../../../src/lib/layouts/adaptive/types.ts"],"sourcesContent":["/**\n * @fileoverview Adaptive Layout System Type Definitions\n *\n * This module provides comprehensive type definitions for the Automatic Adaptive\n * & Morphing Layouts system. All types are designed with strict type safety,\n * supporting content-aware layout computation, FLIP-based animations, and\n * zero-CLS layout reservations.\n *\n * @module layouts/adaptive/types\n * @version 1.0.0\n * @license MIT\n */\n\nimport type { CSSProperties, ReactNode, RefObject } from 'react';\n\n// =============================================================================\n// FOUNDATIONAL TYPES\n// =============================================================================\n\n/**\n * Available layout modes that the system can transition between.\n * These represent the primary layout strategies available.\n */\nexport type LayoutMode = 'grid' | 'list' | 'compact' | 'expanded' | 'dense' | 'sparse';\n\n/**\n * Layout transition direction for determining animation paths.\n */\nexport type TransitionDirection = 'horizontal' | 'vertical' | 'diagonal' | 'radial';\n\n/**\n * Content density classification for automatic layout selection.\n */\nexport type ContentDensity = 'minimal' | 'low' | 'medium' | 'high' | 'extreme';\n\n/**\n * Priority levels for layout constraint solving.\n */\nexport type ConstraintPriority = 'required' | 'strong' | 'medium' | 'weak';\n\n/**\n * Animation easing functions available for morph transitions.\n */\nexport type EasingFunction =\n  | 'linear'\n  | 'ease'\n  | 'ease-in'\n  | 'ease-out'\n  | 'ease-in-out'\n  | 'spring'\n  | 'bounce'\n  | `cubic-bezier(${number}, ${number}, ${number}, ${number})`;\n\n/**\n * GPU-accelerated transform properties for optimal performance.\n */\nexport type GPUAcceleratedProperty = 'transform' | 'opacity' | 'filter';\n\n// =============================================================================\n// DIMENSIONAL TYPES\n// =============================================================================\n\n/**\n * Represents a 2D point in layout space.\n */\nexport interface Point2D {\n  readonly x: number;\n  readonly y: number;\n}\n\n/**\n * Represents dimensions with width and height.\n */\nexport interface Dimensions {\n  readonly width: number;\n  readonly height: number;\n}\n\n/**\n * Complete bounding box information including position and size.\n */\nexport interface BoundingBox extends Point2D, Dimensions {\n  readonly right: number;\n  readonly bottom: number;\n}\n\n/**\n * Padding/margin specification with all four sides.\n */\nexport interface BoxSpacing {\n  readonly top: number;\n  readonly right: number;\n  readonly bottom: number;\n  readonly left: number;\n}\n\n/**\n * Represents a layout rectangle for FLIP calculations.\n */\nexport interface LayoutRect {\n  readonly x: number;\n  readonly y: number;\n  readonly width: number;\n  readonly height: number;\n  readonly scaleX: number;\n  readonly scaleY: number;\n  readonly rotation: number;\n  readonly opacity: number;\n}\n\n// =============================================================================\n// LAYOUT ENGINE TYPES\n// =============================================================================\n\n/**\n * Configuration for the layout engine.\n */\nexport interface LayoutEngineConfig {\n  /** Enable content-aware layout selection */\n  readonly contentAware: boolean;\n  /** Enable predictive layout pre-computation */\n  readonly predictiveLayout: boolean;\n  /** Performance budget in milliseconds for layout computation */\n  readonly performanceBudgetMs: number;\n  /** Enable user preference learning */\n  readonly learnPreferences: boolean;\n  /** Default layout mode when content analysis is indeterminate */\n  readonly defaultMode: LayoutMode;\n  /** Debounce interval for resize observations in milliseconds */\n  readonly resizeDebounceMs: number;\n  /** Enable accessibility mode adaptations */\n  readonly accessibilityMode: boolean;\n  /** Dark mode specific layout adaptations */\n  readonly darkModeAdaptations: boolean;\n}\n\n/**\n * Default layout engine configuration values.\n */\nexport const DEFAULT_LAYOUT_ENGINE_CONFIG: LayoutEngineConfig = {\n  contentAware: true,\n  predictiveLayout: true,\n  performanceBudgetMs: 16, // One frame at 60fps\n  learnPreferences: true,\n  defaultMode: 'grid',\n  resizeDebounceMs: 100,\n  accessibilityMode: false,\n  darkModeAdaptations: true,\n} as const;\n\n/**\n * Content analysis result from the layout engine.\n */\nexport interface ContentAnalysis {\n  /** Number of items in the content */\n  readonly itemCount: number;\n  /** Average item dimensions */\n  readonly averageItemSize: Dimensions;\n  /** Variance in item sizes */\n  readonly sizeVariance: number;\n  /** Detected content density */\n  readonly density: ContentDensity;\n  /** Recommended layout mode based on analysis */\n  readonly recommendedMode: LayoutMode;\n  /** Confidence score (0-1) for the recommendation */\n  readonly confidence: number;\n  /** Whether content appears to be image-heavy */\n  readonly isImageHeavy: boolean;\n  /** Whether content appears to be text-heavy */\n  readonly isTextHeavy: boolean;\n  /** Aspect ratio distribution of content items */\n  readonly aspectRatioDistribution: AspectRatioDistribution;\n}\n\n/**\n * Distribution of aspect ratios in content items.\n */\nexport interface AspectRatioDistribution {\n  readonly portrait: number;\n  readonly square: number;\n  readonly landscape: number;\n  readonly ultrawide: number;\n}\n\n/**\n * Complete layout state at a given point in time.\n */\nexport interface LayoutState {\n  /** Current layout mode */\n  readonly mode: LayoutMode;\n  /** Container dimensions */\n  readonly containerDimensions: Dimensions;\n  /** Individual item positions and sizes */\n  readonly itemRects: ReadonlyMap<string, LayoutRect>;\n  /** Grid-specific configuration if in grid mode */\n  readonly gridConfig?: GridLayoutConfig;\n  /** List-specific configuration if in list mode */\n  readonly listConfig?: ListLayoutConfig;\n  /** Timestamp of this state */\n  readonly timestamp: number;\n  /** Whether this is a transitional state */\n  readonly isTransitioning: boolean;\n}\n\n/**\n * Grid layout specific configuration.\n */\nexport interface GridLayoutConfig {\n  /** Number of columns */\n  readonly columns: number;\n  /** Gap between items */\n  readonly gap: number;\n  /** Row height (can be 'auto' or fixed) */\n  readonly rowHeight: number | 'auto';\n  /** Grid auto-flow direction */\n  readonly autoFlow: 'row' | 'column' | 'dense';\n  /** Alignment of items within grid cells */\n  readonly itemAlignment: 'start' | 'center' | 'end' | 'stretch';\n}\n\n/**\n * List layout specific configuration.\n */\nexport interface ListLayoutConfig {\n  /** Gap between list items */\n  readonly gap: number;\n  /** List direction */\n  readonly direction: 'vertical' | 'horizontal';\n  /** Item height (can be 'auto' or fixed) */\n  readonly itemHeight: number | 'auto';\n  /** Whether to alternate row backgrounds */\n  readonly alternateRows: boolean;\n}\n\n/**\n * Layout computation request.\n */\nexport interface LayoutComputeRequest {\n  /** ID of the container element */\n  readonly containerId: string;\n  /** IDs of child items */\n  readonly itemIds: readonly string[];\n  /** Current container dimensions */\n  readonly containerDimensions: Dimensions;\n  /** Optional forced layout mode */\n  readonly forcedMode?: LayoutMode;\n  /** Animation context for smooth transitions */\n  readonly animationContext?: AnimationContext;\n}\n\n/**\n * Layout computation result.\n */\nexport interface LayoutComputeResult {\n  /** Computed layout state */\n  readonly state: LayoutState;\n  /** Content analysis used for computation */\n  readonly analysis: ContentAnalysis;\n  /** Computation time in milliseconds */\n  readonly computeTimeMs: number;\n  /** Whether performance budget was exceeded */\n  readonly budgetExceeded: boolean;\n  /** CLS impact prediction */\n  readonly predictedCLS: number;\n}\n\n// =============================================================================\n// MORPH TRANSITION TYPES\n// =============================================================================\n\n/**\n * Configuration for morph transitions.\n */\nexport interface MorphTransitionConfig {\n  /** Duration of the transition in milliseconds */\n  readonly duration: number;\n  /** Easing function for the transition */\n  readonly easing: EasingFunction;\n  /** Whether the transition can be interrupted */\n  readonly interruptible: boolean;\n  /** Delay before starting the transition */\n  readonly delay: number;\n  /** Stagger delay between items in milliseconds */\n  readonly staggerDelay: number;\n  /** Maximum stagger delay to prevent long transitions */\n  readonly maxStaggerDelay: number;\n  /** Whether to use GPU acceleration */\n  readonly gpuAccelerated: boolean;\n  /** Properties to animate (GPU-accelerated only) */\n  readonly animatedProperties: readonly GPUAcceleratedProperty[];\n  /** Callback when transition starts */\n  readonly onStart?: () => void;\n  /** Callback for each animation frame */\n  readonly onFrame?: (progress: number) => void;\n  /** Callback when transition completes */\n  readonly onComplete?: () => void;\n  /** Callback if transition is interrupted */\n  readonly onInterrupt?: () => void;\n}\n\n/**\n * Default morph transition configuration.\n */\nexport const DEFAULT_MORPH_TRANSITION_CONFIG: MorphTransitionConfig = {\n  duration: 300,\n  easing: 'ease-out',\n  interruptible: true,\n  delay: 0,\n  staggerDelay: 20,\n  maxStaggerDelay: 200,\n  gpuAccelerated: true,\n  animatedProperties: ['transform', 'opacity'],\n} as const;\n\n/**\n * FLIP animation snapshot for an element.\n */\nexport interface FLIPSnapshot {\n  /** Element identifier */\n  readonly id: string;\n  /** First position (before layout change) */\n  readonly first: LayoutRect;\n  /** Last position (after layout change) */\n  readonly last: LayoutRect;\n  /** Invert transform to apply */\n  readonly invert: Transform3D;\n  /** Play state tracking */\n  readonly playState: 'pending' | 'running' | 'completed' | 'interrupted';\n}\n\n/**\n * 3D transform representation.\n */\nexport interface Transform3D {\n  readonly translateX: number;\n  readonly translateY: number;\n  readonly translateZ: number;\n  readonly scaleX: number;\n  readonly scaleY: number;\n  readonly scaleZ: number;\n  readonly rotateX: number;\n  readonly rotateY: number;\n  readonly rotateZ: number;\n}\n\n/**\n * Animation context for coordinating transitions.\n */\nexport interface AnimationContext {\n  /** Unique identifier for this animation batch */\n  readonly batchId: string;\n  /** Snapshots of elements being animated */\n  readonly snapshots: ReadonlyMap<string, FLIPSnapshot>;\n  /** Current progress (0-1) */\n  readonly progress: number;\n  /** Whether animation is running */\n  readonly isRunning: boolean;\n  /** Start timestamp */\n  readonly startTime: number | null;\n  /** Cancel function */\n  readonly cancel: () => void;\n}\n\n/**\n * Morph transition state.\n */\nexport interface MorphState {\n  /** Current transition configuration */\n  readonly config: MorphTransitionConfig;\n  /** Active animation context */\n  readonly context: AnimationContext | null;\n  /** Previous layout state */\n  readonly fromState: LayoutState | null;\n  /** Target layout state */\n  readonly toState: LayoutState | null;\n  /** Queue of pending transitions */\n  readonly queue: readonly PendingTransition[];\n}\n\n/**\n * Pending transition in the queue.\n */\nexport interface PendingTransition {\n  readonly id: string;\n  readonly targetState: LayoutState;\n  readonly config: Partial<MorphTransitionConfig>;\n  readonly timestamp: number;\n}\n\n// =============================================================================\n// CONSTRAINT SOLVER TYPES\n// =============================================================================\n\n/**\n * Layout constraint definition.\n */\nexport interface LayoutConstraint {\n  /** Unique identifier for this constraint */\n  readonly id: string;\n  /** Type of constraint */\n  readonly type: ConstraintType;\n  /** Priority of this constraint */\n  readonly priority: ConstraintPriority;\n  /** Constraint parameters */\n  readonly params: ConstraintParams;\n  /** Whether this constraint is currently active */\n  readonly active: boolean;\n}\n\n/**\n * Types of layout constraints.\n */\nexport type ConstraintType =\n  | 'min-width'\n  | 'max-width'\n  | 'min-height'\n  | 'max-height'\n  | 'aspect-ratio'\n  | 'alignment'\n  | 'spacing'\n  | 'order'\n  | 'visibility'\n  | 'containment';\n\n/**\n * Parameters for different constraint types.\n */\nexport type ConstraintParams =\n  | MinMaxConstraintParams\n  | AspectRatioConstraintParams\n  | AlignmentConstraintParams\n  | SpacingConstraintParams\n  | OrderConstraintParams\n  | VisibilityConstraintParams\n  | ContainmentConstraintParams;\n\n/**\n * Min/max dimension constraint parameters.\n */\nexport interface MinMaxConstraintParams {\n  readonly type: 'dimension';\n  readonly value: number;\n  readonly unit: 'px' | '%' | 'vw' | 'vh';\n}\n\n/**\n * Aspect ratio constraint parameters.\n */\nexport interface AspectRatioConstraintParams {\n  readonly type: 'aspect-ratio';\n  readonly ratio: number;\n  readonly tolerance: number;\n}\n\n/**\n * Alignment constraint parameters.\n */\nexport interface AlignmentConstraintParams {\n  readonly type: 'alignment';\n  readonly horizontal: 'start' | 'center' | 'end' | 'stretch';\n  readonly vertical: 'start' | 'center' | 'end' | 'stretch';\n}\n\n/**\n * Spacing constraint parameters.\n */\nexport interface SpacingConstraintParams {\n  readonly type: 'spacing';\n  readonly min: number;\n  readonly max: number;\n  readonly preferred: number;\n}\n\n/**\n * Order constraint parameters.\n */\nexport interface OrderConstraintParams {\n  readonly type: 'order';\n  readonly before?: readonly string[];\n  readonly after?: readonly string[];\n}\n\n/**\n * Visibility constraint parameters.\n */\nexport interface VisibilityConstraintParams {\n  readonly type: 'visibility';\n  readonly condition: 'always' | 'viewport' | 'container' | 'custom';\n  readonly threshold: number;\n}\n\n/**\n * Containment constraint parameters.\n */\nexport interface ContainmentConstraintParams {\n  readonly type: 'containment';\n  readonly contain: boolean;\n  readonly overflow: 'visible' | 'hidden' | 'scroll' | 'auto';\n}\n\n/**\n * Constraint solution result.\n */\nexport interface ConstraintSolution {\n  /** Whether all required constraints were satisfied */\n  readonly feasible: boolean;\n  /** Computed positions for each item */\n  readonly positions: ReadonlyMap<string, Point2D>;\n  /** Computed sizes for each item */\n  readonly sizes: ReadonlyMap<string, Dimensions>;\n  /** Constraint violations (if any) */\n  readonly violations: readonly ConstraintViolation[];\n  /** Solve time in milliseconds */\n  readonly solveTimeMs: number;\n}\n\n/**\n * Information about a constraint violation.\n */\nexport interface ConstraintViolation {\n  readonly constraintId: string;\n  readonly severity: 'error' | 'warning';\n  readonly message: string;\n  readonly affectedItems: readonly string[];\n}\n\n// =============================================================================\n// CLS GUARD TYPES\n// =============================================================================\n\n/**\n * CLS Guard configuration.\n */\nexport interface CLSGuardConfig {\n  /** Enable CLS prevention */\n  readonly enabled: boolean;\n  /** Maximum allowed CLS score */\n  readonly maxCLS: number;\n  /** Enable layout reservation */\n  readonly reserveLayout: boolean;\n  /** Reservation strategy */\n  readonly reservationStrategy: ReservationStrategy;\n  /** Enable CLS monitoring */\n  readonly monitor: boolean;\n  /** Callback when CLS threshold is exceeded */\n  readonly onThresholdExceeded?: (score: number) => void;\n}\n\n/**\n * Default CLS guard configuration.\n */\nexport const DEFAULT_CLS_GUARD_CONFIG: CLSGuardConfig = {\n  enabled: true,\n  maxCLS: 0.05,\n  reserveLayout: true,\n  reservationStrategy: 'skeleton',\n  monitor: true,\n} as const;\n\n/**\n * Layout reservation strategies.\n */\nexport type ReservationStrategy =\n  | 'skeleton' // Show skeleton placeholder\n  | 'dimensions' // Reserve exact dimensions\n  | 'aspect-ratio' // Reserve with aspect ratio\n  | 'minimum' // Reserve minimum dimensions\n  | 'none'; // No reservation\n\n/**\n * Layout reservation specification.\n */\nexport interface LayoutReservation {\n  /** Unique identifier */\n  readonly id: string;\n  /** Reserved dimensions */\n  readonly dimensions: Dimensions;\n  /** Aspect ratio (if using aspect-ratio strategy) */\n  readonly aspectRatio?: number;\n  /** Minimum dimensions (if using minimum strategy) */\n  readonly minDimensions?: Dimensions;\n  /** Whether reservation is currently active */\n  readonly active: boolean;\n  /** Timestamp when reservation was created */\n  readonly createdAt: number;\n  /** Expected content load time (for optimization) */\n  readonly expectedLoadTimeMs?: number;\n}\n\n/**\n * CLS measurement result.\n */\nexport interface CLSMeasurement {\n  /** Current CLS score */\n  readonly score: number;\n  /** Individual layout shift entries */\n  readonly entries: readonly LayoutShiftEntry[];\n  /** Whether threshold was exceeded */\n  readonly thresholdExceeded: boolean;\n  /** Timestamp of measurement */\n  readonly timestamp: number;\n}\n\n/**\n * Individual layout shift entry.\n */\nexport interface LayoutShiftEntry {\n  /** Element that shifted */\n  readonly elementId: string | null;\n  /** Shift value */\n  readonly value: number;\n  /** Whether shift had user interaction */\n  readonly hadRecentInput: boolean;\n  /** Timestamp */\n  readonly startTime: number;\n}\n\n// =============================================================================\n// COMPONENT PROPS TYPES\n// =============================================================================\n\n/**\n * Props for the AdaptiveLayout component.\n */\nexport interface AdaptiveLayoutProps {\n  /** Child elements to layout */\n  readonly children: ReactNode;\n  /** Initial layout mode */\n  readonly initialMode?: LayoutMode;\n  /** Layout engine configuration */\n  readonly config?: Partial<LayoutEngineConfig>;\n  /** Morph transition configuration */\n  readonly transitionConfig?: Partial<MorphTransitionConfig>;\n  /** CLS guard configuration */\n  readonly clsConfig?: Partial<CLSGuardConfig>;\n  /** Layout constraints */\n  readonly constraints?: readonly LayoutConstraint[];\n  /** Callback when layout mode changes */\n  readonly onModeChange?: (mode: LayoutMode, analysis: ContentAnalysis) => void;\n  /** Callback when layout computation completes */\n  readonly onLayoutComputed?: (result: LayoutComputeResult) => void;\n  /** Custom className */\n  readonly className?: string;\n  /** Custom styles */\n  readonly style?: CSSProperties;\n  /** Test ID for testing */\n  readonly testId?: string;\n}\n\n/**\n * Props for the AdaptiveGrid component.\n */\nexport interface AdaptiveGridProps {\n  /** Child elements */\n  readonly children: ReactNode;\n  /** Minimum column width */\n  readonly minColumnWidth?: number;\n  /** Maximum columns */\n  readonly maxColumns?: number;\n  /** Gap between items */\n  readonly gap?: number;\n  /** Enable auto-sizing rows */\n  readonly autoRows?: boolean;\n  /** Grid auto-flow */\n  readonly autoFlow?: 'row' | 'column' | 'dense';\n  /** Enable masonry layout for variable height items */\n  readonly masonry?: boolean;\n  /** Custom className */\n  readonly className?: string;\n  /** Custom styles */\n  readonly style?: CSSProperties;\n}\n\n/**\n * Props for the AdaptiveStack component.\n */\nexport interface AdaptiveStackProps {\n  /** Child elements */\n  readonly children: ReactNode;\n  /** Stack direction */\n  readonly direction?: 'vertical' | 'horizontal' | 'responsive';\n  /** Breakpoint for responsive direction switch */\n  readonly breakpoint?: number;\n  /** Gap between items */\n  readonly gap?: number;\n  /** Alignment */\n  readonly align?: 'start' | 'center' | 'end' | 'stretch';\n  /** Justify content */\n  readonly justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';\n  /** Enable wrapping */\n  readonly wrap?: boolean;\n  /** Custom className */\n  readonly className?: string;\n  /** Custom styles */\n  readonly style?: CSSProperties;\n}\n\n/**\n * Props for the AdaptiveContainer component.\n */\nexport interface AdaptiveContainerProps {\n  /** Child elements */\n  readonly children: ReactNode;\n  /** Container query breakpoints */\n  readonly breakpoints?: ContainerBreakpoints;\n  /** Enable content density detection */\n  readonly detectDensity?: boolean;\n  /** Padding configuration */\n  readonly padding?: number | BoxSpacing;\n  /** Maximum width */\n  readonly maxWidth?: number | string;\n  /** Center container */\n  readonly centered?: boolean;\n  /** Custom className */\n  readonly className?: string;\n  /** Custom styles */\n  readonly style?: CSSProperties;\n}\n\n/**\n * Container query breakpoints.\n */\nexport interface ContainerBreakpoints {\n  readonly xs?: number;\n  readonly sm?: number;\n  readonly md?: number;\n  readonly lg?: number;\n  readonly xl?: number;\n}\n\n/**\n * Props for the MorphTransition component.\n */\nexport interface MorphTransitionProps {\n  /** Child element */\n  readonly children: ReactNode;\n  /** Unique key for FLIP tracking */\n  readonly layoutId: string;\n  /** Transition configuration */\n  readonly config?: Partial<MorphTransitionConfig>;\n  /** Whether element is present (for enter/exit animations) */\n  readonly present?: boolean;\n  /** Initial animation state */\n  readonly initial?: Partial<LayoutRect>;\n  /** Animation state when present */\n  readonly animate?: Partial<LayoutRect>;\n  /** Animation state when exiting */\n  readonly exit?: Partial<LayoutRect>;\n  /** Custom className */\n  readonly className?: string;\n  /** Custom styles */\n  readonly style?: CSSProperties;\n}\n\n// =============================================================================\n// HOOK RETURN TYPES\n// =============================================================================\n\n/**\n * Return type for useAdaptiveLayout hook.\n */\nexport interface UseAdaptiveLayoutReturn {\n  /** Current layout state */\n  readonly layoutState: LayoutState | null;\n  /** Current layout mode */\n  readonly mode: LayoutMode;\n  /** Content analysis */\n  readonly analysis: ContentAnalysis | null;\n  /** Whether layout is computing */\n  readonly isComputing: boolean;\n  /** Whether layout is transitioning */\n  readonly isTransitioning: boolean;\n  /** Force a specific layout mode */\n  readonly setMode: (mode: LayoutMode) => void;\n  /** Trigger layout recomputation */\n  readonly recompute: () => void;\n  /** Container ref to attach */\n  readonly containerRef: RefObject<HTMLDivElement | null>;\n}\n\n/**\n * Return type for useLayoutMode hook.\n */\nexport interface UseLayoutModeReturn {\n  /** Current layout mode */\n  readonly mode: LayoutMode;\n  /** Previous layout mode */\n  readonly previousMode: LayoutMode | null;\n  /** Set layout mode */\n  readonly setMode: (mode: LayoutMode) => void;\n  /** Whether mode is locked (manual override) */\n  readonly isLocked: boolean;\n  /** Lock mode to prevent auto-changes */\n  readonly lockMode: () => void;\n  /** Unlock mode to allow auto-changes */\n  readonly unlockMode: () => void;\n}\n\n/**\n * Return type for useLayoutMorph hook.\n */\nexport interface UseLayoutMorphReturn {\n  /** Trigger a morph transition */\n  readonly morph: (targetState: Partial<LayoutState>) => Promise<void>;\n  /** Cancel current transition */\n  readonly cancel: () => void;\n  /** Current transition progress (0-1) */\n  readonly progress: number;\n  /** Whether transitioning */\n  readonly isTransitioning: boolean;\n  /** Register an element for FLIP tracking */\n  readonly registerElement: (id: string, ref: RefObject<HTMLElement>) => void;\n  /** Unregister an element */\n  readonly unregisterElement: (id: string) => void;\n  /** Take FLIP snapshot */\n  readonly snapshot: () => void;\n}\n\n/**\n * Return type for useContentDensity hook.\n */\nexport interface UseContentDensityReturn {\n  /** Current content density */\n  readonly density: ContentDensity;\n  /** Item count */\n  readonly itemCount: number;\n  /** Average item size */\n  readonly averageItemSize: Dimensions | null;\n  /** Size variance */\n  readonly sizeVariance: number;\n  /** Is content image-heavy */\n  readonly isImageHeavy: boolean;\n  /** Is content text-heavy */\n  readonly isTextHeavy: boolean;\n  /** Force density recalculation */\n  readonly recalculate: () => void;\n}\n\n/**\n * Return type for useCLSGuard hook.\n */\nexport interface UseCLSGuardReturn {\n  /** Current CLS score */\n  readonly clsScore: number;\n  /** Whether CLS threshold exceeded */\n  readonly thresholdExceeded: boolean;\n  /** Create a layout reservation */\n  readonly reserve: (id: string, dimensions: Dimensions) => LayoutReservation;\n  /** Release a reservation */\n  readonly release: (id: string) => void;\n  /** Get active reservations */\n  readonly reservations: ReadonlyMap<string, LayoutReservation>;\n  /** CLS measurements history */\n  readonly measurements: readonly CLSMeasurement[];\n}\n\n// =============================================================================\n// CONTEXT TYPES\n// =============================================================================\n\n/**\n * Adaptive layout context value.\n */\nexport interface AdaptiveLayoutContextValue {\n  /** Layout engine instance */\n  readonly engine: LayoutEngineInterface;\n  /** Morph transition controller */\n  readonly morphController: MorphControllerInterface;\n  /** CLS guard instance */\n  readonly clsGuard: CLSGuardInterface;\n  /** Constraint solver instance */\n  readonly constraintSolver: ConstraintSolverInterface;\n  /** Current configuration */\n  readonly config: LayoutEngineConfig;\n  /** Current layout state */\n  readonly layoutState: LayoutState | null;\n  /** Register child element */\n  readonly registerChild: (id: string, ref: RefObject<HTMLElement>) => void;\n  /** Unregister child element */\n  readonly unregisterChild: (id: string) => void;\n}\n\n// =============================================================================\n// INTERFACE TYPES (for implementations)\n// =============================================================================\n\n/**\n * Layout engine interface.\n */\nexport interface LayoutEngineInterface {\n  readonly config: LayoutEngineConfig;\n  configure(config: Partial<LayoutEngineConfig>): void;\n  analyze(container: HTMLElement): ContentAnalysis;\n  compute(request: LayoutComputeRequest): LayoutComputeResult;\n  selectMode(analysis: ContentAnalysis, constraints: readonly LayoutConstraint[]): LayoutMode;\n  observe(container: HTMLElement, callback: (entry: ResizeObserverEntry) => void): () => void;\n  destroy(): void;\n}\n\n/**\n * Morph controller interface.\n */\nexport interface MorphControllerInterface {\n  readonly config: MorphTransitionConfig;\n  readonly isTransitioning: boolean;\n  configure(config: Partial<MorphTransitionConfig>): void;\n  snapshotFirst(elements: Map<string, HTMLElement>): Map<string, LayoutRect>;\n  snapshotLast(elements: Map<string, HTMLElement>): Map<string, LayoutRect>;\n  createAnimation(\n    first: Map<string, LayoutRect>,\n    last: Map<string, LayoutRect>,\n    elements: Map<string, HTMLElement>\n  ): AnimationContext;\n  play(context: AnimationContext): Promise<void>;\n  cancel(): void;\n  destroy(): void;\n}\n\n/**\n * CLS guard interface.\n */\nexport interface CLSGuardInterface {\n  readonly config: CLSGuardConfig;\n  readonly currentScore: number;\n  configure(config: Partial<CLSGuardConfig>): void;\n  createReservation(\n    id: string,\n    dimensions: Dimensions,\n    strategy?: ReservationStrategy\n  ): LayoutReservation;\n  releaseReservation(id: string): void;\n  measureCLS(): CLSMeasurement;\n  observeCLS(callback: (measurement: CLSMeasurement) => void): () => void;\n  destroy(): void;\n}\n\n/**\n * Constraint solver interface.\n */\nexport interface ConstraintSolverInterface {\n  addConstraint(constraint: LayoutConstraint): void;\n  removeConstraint(id: string): void;\n  updateConstraint(id: string, updates: Partial<LayoutConstraint>): void;\n  solve(\n    items: ReadonlyMap<string, Dimensions>,\n    containerDimensions: Dimensions\n  ): ConstraintSolution;\n  validate(solution: ConstraintSolution): readonly ConstraintViolation[];\n  clear(): void;\n}\n\n// =============================================================================\n// USER PREFERENCE TYPES\n// =============================================================================\n\n/**\n * User layout preferences learned over time.\n */\nexport interface UserLayoutPreferences {\n  /** Preferred layout mode for different content types */\n  readonly modePreferences: ReadonlyMap<ContentDensity, LayoutMode>;\n  /** Preferred animation settings */\n  readonly animationPreferences: AnimationPreferences;\n  /** Accessibility preferences */\n  readonly accessibilityPreferences: AccessibilityPreferences;\n  /** Timestamps of preference updates */\n  readonly lastUpdated: number;\n}\n\n/**\n * Animation-related preferences.\n */\nexport interface AnimationPreferences {\n  readonly reducedMotion: boolean;\n  readonly preferredDuration: number;\n  readonly preferredEasing: EasingFunction;\n}\n\n/**\n * Accessibility-related preferences.\n */\nexport interface AccessibilityPreferences {\n  readonly highContrast: boolean;\n  readonly largeText: boolean;\n  readonly reducedMotion: boolean;\n  readonly screenReader: boolean;\n}\n\n// =============================================================================\n// PERFORMANCE TYPES\n// =============================================================================\n\n/**\n * Performance metrics for layout operations.\n */\nexport interface LayoutPerformanceMetrics {\n  /** Layout computation time */\n  readonly computeTimeMs: number;\n  /** Animation frame time */\n  readonly frameTimeMs: number;\n  /** Memory usage estimate */\n  readonly memoryUsageBytes: number;\n  /** Number of elements tracked */\n  readonly trackedElements: number;\n  /** Number of active constraints */\n  readonly activeConstraints: number;\n  /** Frame rate during animations */\n  readonly fps: number;\n  /** Whether performance budget was exceeded */\n  readonly budgetExceeded: boolean;\n}\n\n/**\n * Performance budget configuration.\n */\nexport interface PerformanceBudget {\n  /** Maximum compute time per frame */\n  readonly maxComputeTimeMs: number;\n  /** Maximum memory usage */\n  readonly maxMemoryBytes: number;\n  /** Minimum acceptable FPS */\n  readonly minFps: number;\n  /** Maximum tracked elements */\n  readonly maxTrackedElements: number;\n}\n\n/**\n * Default performance budget.\n */\nexport const DEFAULT_PERFORMANCE_BUDGET: PerformanceBudget = {\n  maxComputeTimeMs: 16,\n  maxMemoryBytes: 50 * 1024 * 1024, // 50MB\n  minFps: 55,\n  maxTrackedElements: 1000,\n} as const;\n"],"names":["DEFAULT_LAYOUT_ENGINE_CONFIG","DEFAULT_MORPH_TRANSITION_CONFIG","DEFAULT_CLS_GUARD_CONFIG","DEFAULT_PERFORMANCE_BUDGET"],"mappings":"AA2IO,MAAMA,IAAmD;AAAA,EAC9D,cAAc;AAAA,EACd,kBAAkB;AAAA,EAClB,qBAAqB;AAAA;AAAA,EACrB,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EACnB,qBAAqB;AACvB,GA2JaC,IAAyD;AAAA,EACpE,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,OAAO;AAAA,EACP,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,oBAAoB,CAAC,aAAa,SAAS;AAC7C,GA+OaC,IAA2C;AAAA,EACtD,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,SAAS;AACX,GAwdaC,IAAgD;AAAA,EAC3D,kBAAkB;AAAA,EAClB,gBAAgB,KAAK,OAAO;AAAA;AAAA,EAC5B,QAAQ;AAAA,EACR,oBAAoB;AACtB;"}