import { ModuleResolver } from './module-resolver';
import { Program } from '../types';
import { ModuleSystemMetrics } from './metrics';
import { CircuitBreakerManager } from './circuit-breaker';
type BufferEncoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'base64url' | 'latin1' | 'binary' | 'hex';
export interface LoadedModule {
    id: string;
    resolvedPath: string;
    source: string;
    ast: Program;
    dependencies: string[];
    exports: ModuleExports;
    isLoaded: boolean;
    isLoading: boolean;
    lastAccessed: number;
    error?: Error;
}
export interface ModuleExports {
    default?: unknown;
    named: Record<string, unknown>;
}
export interface ModuleLoadOptions {
    encoding?: BufferEncoding;
    cache?: boolean;
    circularDependencyStrategy?: 'error' | 'warn' | 'ignore';
    externals?: string[];
    maxCacheSize?: number;
    maxCacheMemory?: number;
}
export declare class ModuleLoader {
    private readonly resolver;
    private readonly moduleCache;
    private readonly loadingStack;
    private readonly options;
    private externalSpecifiers;
    private currentMemoryUsage;
    private warnings;
    private readonly metrics?;
    private readonly circuitBreakers?;
    constructor(resolver: ModuleResolver, options?: ModuleLoadOptions, metrics?: ModuleSystemMetrics, circuitBreakers?: CircuitBreakerManager);
    /**
     * Load a module and all its dependencies
     */
    load(specifier: string, fromFile: string): Promise<LoadedModule>;
    /**
     * Load module synchronously
     */
    loadSync(specifier: string, fromFile: string): LoadedModule;
    private loadExternalModuleWithCircuitBreaker;
    private createStubExternalModule;
    private loadModule;
    private loadModuleSync;
    private handleCircularDependency;
    /**
     * Extract raw dependency specifiers from AST (e.g., "./utils", "../math")
     * These need to be resolved to absolute paths before being stored in the dependency graph
     */
    private extractDependencies;
    private getModuleId;
    /**
     * Get a loaded module from cache
     */
    getModule(moduleId: string): LoadedModule | undefined;
    /**
     * Check if a module is loaded
     */
    isLoaded(moduleId: string): boolean;
    /**
     * Clear module cache
     */
    clearCache(): void;
    /**
     * Get cache statistics
     */
    getCacheStats(): {
        size: number;
        memoryUsage: number;
        maxSize: number;
        maxMemory: number;
    };
    /**
     * Enforce cache limits by evicting least recently used modules
     */
    private enforceCacheLimits;
    /**
     * Evict a specific module from cache
     */
    private evictModule;
    /**
     * Estimate memory usage of a module
     */
    private estimateModuleSize;
    /**
     * Get all loaded modules
     */
    getAllModules(): LoadedModule[];
    /**
     * Get module dependency graph
     */
    getDependencyGraph(): Map<string, string[]>;
    /**
     * Note: topological ordering is provided by ModuleRegistry.
     */
    setExternals(externals?: string[]): void;
    getExternals(): string[];
    private matchExternal;
    private buildExternalCandidates;
    private getOrCreateExternalModule;
    private getExternalModuleId;
    /**
     * Get collected warnings
     */
    getWarnings(): string[];
    /**
     * Clear collected warnings
     */
    clearWarnings(): void;
}
export {};
//# sourceMappingURL=module-loader.d.ts.map