import { ContentAnalysis, LayoutComputeRequest, LayoutComputeResult, LayoutConstraint, LayoutEngineConfig, LayoutEngineInterface, LayoutMode } from './types'; /** * Generates a unique batch ID. */ /** * Content-aware layout engine that automatically selects and computes * optimal layouts based on content analysis. * * @example * ```typescript * const engine = createLayoutEngine({ contentAware: true }); * const analysis = engine.analyze(containerElement); * const result = engine.compute({ * containerId: 'my-container', * itemIds: ['item-1', 'item-2', 'item-3'], * containerDimensions: { width: 800, height: 600 } * }); * ``` */ export declare class LayoutEngine implements LayoutEngineInterface { private readonly _resizeObserver; private readonly _callbacks; private readonly _elementCache; private readonly _userPreferences; private _destroyed; /** * Creates a new LayoutEngine instance. * * @param config - Optional configuration overrides */ constructor(config?: Partial); private _config; /** * Current engine configuration. */ get config(): LayoutEngineConfig; /** * Updates the engine configuration. * * @param config - Partial configuration to merge */ configure(config: Partial): void; /** * Analyzes container content to determine optimal layout characteristics. * * @param container - The container element to analyze * @returns Content analysis result */ analyze(container: HTMLElement): ContentAnalysis; /** * Computes the complete layout for a container and its items. * * @param request - Layout computation request * @returns Layout computation result */ compute(request: LayoutComputeRequest): LayoutComputeResult; /** * Selects the optimal layout mode based on content analysis and constraints. * * @param analysis - Content analysis result * @param constraints - Active layout constraints * @returns Selected layout mode */ selectMode(analysis: ContentAnalysis, constraints: readonly LayoutConstraint[]): LayoutMode; /** * Observes a container element for size changes. * * @param container - Element to observe * @param callback - Callback for resize events * @returns Cleanup function */ observe(container: HTMLElement, callback: (entry: ResizeObserverEntry) => void): () => void; /** * Cleans up all resources used by the engine. */ destroy(): void; /** * Handles ResizeObserver callbacks with debouncing. */ private _handleResize; /** * Creates a minimal analysis for containers with few items. */ private _createMinimalAnalysis; /** * Classifies density ratio into a ContentDensity category. */ private _classifyDensity; /** * Calculates aspect ratio distribution from a list of ratios. */ private _calculateAspectRatioDistribution; /** * Recommends a layout mode based on content characteristics. */ private _recommendLayoutMode; /** * Calculates confidence score for the recommendation. */ private _calculateConfidence; /** * Computes item rectangles based on layout mode. */ private _computeItemRects; /** * Computes grid layout rectangles. */ private _computeGridRects; /** * Computes list layout rectangles. */ private _computeListRects; /** * Computes compact layout rectangles (tight grid with smaller items). */ private _computeCompactRects; /** * Computes expanded layout rectangles (larger items with more spacing). */ private _computeExpandedRects; /** * Computes dense layout rectangles (maximum items per area). */ private _computeDenseRects; /** * Computes sparse layout rectangles (generous spacing for readability). */ private _computeSparseRects; /** * Computes optimal grid configuration. */ private _computeGridConfig; /** * Computes optimal list configuration. */ private _computeListConfig; /** * Predicts CLS impact of a layout change. */ private _predictCLS; /** * Initializes user preferences storage. */ private _initializeUserPreferences; /** * Asserts that the engine has not been destroyed. */ private _assertNotDestroyed; } /** * Creates a new LayoutEngine instance. * * @param config - Optional configuration overrides * @returns A new LayoutEngine instance * * @example * ```typescript * const engine = createLayoutEngine({ * contentAware: true, * predictiveLayout: true, * performanceBudgetMs: 16 * }); * ``` */ export declare function createLayoutEngine(config?: Partial): LayoutEngineInterface; /** * Gets or creates the shared layout engine instance. * * @param config - Optional configuration (only used on first call) * @returns The shared LayoutEngine instance */ export declare function getSharedLayoutEngine(config?: Partial): LayoutEngineInterface; /** * Resets the shared layout engine (useful for testing). */ export declare function resetSharedLayoutEngine(): void;