import { FileContents, FileDiffMetadata, HunkExpansionRegion, RenderDiffOptions, RenderDiffResult, RenderFileOptions, RenderFileResult, SupportedLanguages, ThemedDiffResult, ThemedFileResult } from "../types.js";
import { DiffRendererInstance, FileRendererInstance, WorkerInitializationRenderOptions, WorkerPoolOptions, WorkerRenderingOptions, WorkerStats } from "./types.js";
import LRUMapPkg from "lru_map";

//#region src/worker/WorkerPoolManager.d.ts
interface GetCachesResult {
  fileCache: LRUMapPkg.LRUMap<string, RenderFileResult>;
  diffCache: LRUMapPkg.LRUMap<string, RenderDiffResult>;
}
interface ThemeSubscriber {
  rerender(): void;
}
declare class WorkerPoolManager {
  private options;
  private highlighter;
  private readonly preferredHighlighter;
  private renderOptions;
  private initialized;
  private workers;
  private taskQueue;
  private pendingTasks;
  private nextRequestId;
  private themeSubscribers;
  private workersFailed;
  private instanceRequestMap;
  private statSubscribers;
  private fileCache;
  private diffCache;
  private _queuedBroadcast;
  constructor(options: WorkerPoolOptions, {
    langs,
    theme,
    lineDiffType,
    tokenizeMaxLineLength,
    preferredHighlighter
  }: WorkerInitializationRenderOptions);
  isWorkingPool(): boolean;
  getFileResultCache(file: FileContents): RenderFileResult | undefined;
  getDiffResultCache(diff: FileDiffMetadata): RenderDiffResult | undefined;
  inspectCaches(): GetCachesResult;
  evictFileFromCache(cacheKey: string): boolean;
  evictDiffFromCache(cacheKey: string): boolean;
  setRenderOptions({
    theme,
    lineDiffType,
    tokenizeMaxLineLength
  }: Partial<WorkerRenderingOptions>): Promise<void>;
  getFileRenderOptions(): RenderFileOptions;
  getDiffRenderOptions(): RenderDiffOptions;
  private setRenderOptionsOnWorkers;
  subscribeToThemeChanges(instance: ThemeSubscriber): () => void;
  unsubscribeToThemeChanges(instance: ThemeSubscriber): void;
  subscribeToStatChanges(callback: (stats: WorkerStats) => unknown): () => void;
  private queueBroadcastStateChanges;
  private _broadcastStateChanges;
  cleanUpPendingTasks(instance: FileRendererInstance | DiffRendererInstance): void;
  isInitialized(): boolean;
  initialize(languages?: SupportedLanguages[]): Promise<void>;
  private initializeWorkers;
  private drainQueue;
  highlightFileAST(instance: FileRendererInstance, file: FileContents): void;
  getPlainFileAST(file: FileContents, startingLine: number, totalLines: number, lines?: string[]): ThemedFileResult | undefined;
  highlightDiffAST(instance: DiffRendererInstance, diff: FileDiffMetadata): void;
  getPlainDiffAST(diff: FileDiffMetadata, startingLine: number, totalLines: number, expandedHunks?: Map<number, HunkExpansionRegion> | true, collapsedContextThreshold?: number): ThemedDiffResult | undefined;
  terminate(): void;
  private terminateWorkers;
  getStats(): WorkerStats;
  private submitTask;
  private resolveLanguagesAndExecuteTask;
  private handleWorkerMessage;
  private _queuedDrain;
  private queueDrain;
  private assignWorkerToTask;
  private clearWorkerTask;
  private executeTask;
  private getAvailableWorker;
  private generateRequestId;
}
//#endregion
export { WorkerPoolManager };
//# sourceMappingURL=WorkerPoolManager.d.ts.map