/**
 * Hot Reload Manager for Awake Lambda Development
 *
 * Coordinates file watching, require cache clearing, and handler reloading
 * for hot reload support. Integrates FileWatcher, LocalHandlerResolver,
 * and WorkerManager for seamless code updates.
 *
 * @module bin/commands/dev/hot-reload-manager
 *
 * @see Requirements 5.1, 5.4, 5.5, 7.3, 7.4
 */
import { EventEmitter } from 'events';
import { FileChangeEvent, FileWatcher } from './file-watcher';
import { LocalHandlerResolver } from './handler-resolver';
import { WorkerManager } from './worker-manager';
/**
 * Hot reload manager configuration.
 */
export interface HotReloadManagerConfig {
    /** Paths to watch for changes */
    readonly watchPaths: string[];
    /** Patterns to ignore */
    readonly ignorePatterns?: string[];
    /** Debounce delay in milliseconds */
    readonly debounceMs?: number;
    /** Base path for resolution */
    readonly basePath?: string;
    /** Microservice names for targeted reloading */
    readonly microserviceNames?: string[];
}
/**
 * Hot reload event.
 */
export interface HotReloadEvent {
    /** Changed files */
    readonly changedFiles: FileChangeEvent[];
    /** Affected microservices (if determinable) */
    readonly affectedMicroservices: string[];
    /** Timestamp of reload */
    readonly timestamp: number;
    /** Duration of reload in milliseconds */
    readonly durationMs: number;
}
/**
 * Events emitted by HotReloadManager.
 */
export interface HotReloadManagerEvents {
    'reload-start': (changedFiles: FileChangeEvent[]) => void;
    'reload-complete': (event: HotReloadEvent) => void;
    'reload-error': (error: Error, changedFiles: FileChangeEvent[]) => void;
    'file-change': (event: FileChangeEvent) => void;
    'ready': () => void;
    'stopped': () => void;
}
/**
 * Hot reload manager state.
 */
export type HotReloadManagerState = 'idle' | 'starting' | 'watching' | 'reloading' | 'stopped';
/**
 * Error class for hot reload failures.
 */
export declare class HotReloadError extends Error {
    readonly cause?: Error | undefined;
    constructor(message: string, cause?: Error | undefined);
}
/**
 * Hot Reload Manager for Awake Lambda Development.
 *
 * Coordinates file watching, require cache clearing, and handler reloading.
 * When files change, it clears the Node.js require cache, recreates
 * MicroserviceBundle instances, and notifies the worker process.
 *
 * @see Requirements 5.1, 5.4, 5.5
 *
 * @example
 * ```typescript
 * const manager = new HotReloadManager({
 *   watchPaths: ['./src'],
 *   microserviceNames: ['payments', 'users'],
 * });
 *
 * manager.setHandlerResolver(resolver);
 * manager.setWorkerManager(workerManager);
 *
 * manager.on('reload-complete', (event) => {
 *   console.log('Reloaded:', event.affectedMicroservices);
 * });
 *
 * await manager.start();
 * ```
 */
export declare class HotReloadManager extends EventEmitter {
    /** File watcher instance */
    private fileWatcher;
    /** Handler resolver reference */
    private handlerResolver;
    /** Worker manager reference */
    private workerManager;
    /** Current state */
    private state;
    /** Configuration */
    private readonly config;
    /** Reload count for statistics */
    private reloadCount;
    /** Last reload timestamp */
    private lastReloadTimestamp;
    /**
     * Create a new HotReloadManager.
     *
     * @param config - Hot reload manager configuration
     */
    constructor(config: HotReloadManagerConfig);
    /**
     * Set the handler resolver for reloading.
     *
     * @param resolver - LocalHandlerResolver instance
     */
    setHandlerResolver(resolver: LocalHandlerResolver): void;
    /**
     * Set the worker manager for notification.
     *
     * @param manager - WorkerManager instance
     */
    setWorkerManager(manager: WorkerManager): void;
    /**
     * Get current state.
     */
    getState(): HotReloadManagerState;
    /**
     * Check if manager is actively watching.
     */
    isWatching(): boolean;
    /**
     * Get reload statistics.
     */
    getStats(): {
        reloadCount: number;
        lastReloadTimestamp: number;
        state: HotReloadManagerState;
    };
    /**
     * Start watching for file changes.
     *
     * @returns Promise that resolves when watcher is ready
     * @throws HotReloadError if watcher fails to start
     *
     * @see Requirements 5.1
     */
    start(): Promise<void>;
    /**
     * Stop watching for file changes.
     *
     * @returns Promise that resolves when watcher is stopped
     */
    stop(): Promise<void>;
    /**
     * Handle a batch of file changes.
     *
     * Clears require cache, reloads affected microservices, and notifies worker.
     *
     * @param events - File change events
     * @private
     *
     * @see Requirements 5.4, 5.5
     */
    private handleFileChangeBatch;
    /**
     * Determine which microservices are affected by file changes.
     *
     * @param events - File change events
     * @returns Array of affected microservice names
     * @private
     */
    private determineAffectedMicroservices;
    /**
     * Clear Node.js require cache for a module and its dependents.
     *
     * @param modulePath - Path to the module to clear
     * @private
     *
     * @see Requirements 5.5
     */
    private clearRequireCache;
    /**
     * Manually trigger a reload for specific files.
     *
     * @param filePaths - Paths to reload
     */
    triggerReload(filePaths: string[]): Promise<void>;
    /**
     * Get diagnostic information.
     */
    getDiagnostics(): {
        state: HotReloadManagerState;
        reloadCount: number;
        lastReloadTimestamp: number;
        watchPaths: string[];
        microserviceNames: string[];
        fileWatcherDiagnostics: ReturnType<FileWatcher['getDiagnostics']> | null;
    };
}
/**
 * Clear the entire Node.js require cache.
 *
 * Use with caution - this clears ALL cached modules.
 *
 * @param preservePatterns - Patterns to preserve (e.g., 'node_modules')
 */
export declare function clearEntireRequireCache(preservePatterns?: string[]): void;
/**
 * Clear require cache for a specific module and its dependents.
 *
 * @param modulePath - Path to the module to clear
 * @returns Number of modules cleared
 */
export declare function clearModuleCache(modulePath: string): number;
/**
 * Get all modules in the require cache matching a pattern.
 *
 * @param pattern - Pattern to match (substring or regex)
 * @returns Array of matching module paths
 */
export declare function getCachedModules(pattern: string | RegExp): string[];
