import BitmapIndexReader from './BitmapIndexReader.ts';
import type IndexStoragePort from '../../../ports/IndexStoragePort.ts';
import type LoggerPort from '../../../ports/LoggerPort.ts';
import type CodecPort from '../../../ports/CodecPort.ts';
import type BlobPort from '../../../ports/BlobPort.ts';
import type TreePort from '../../../ports/TreePort.ts';
type GraphService = {
    iterateNodes(opts: {
        ref: string;
        limit: number;
    }): AsyncIterable<{
        sha: string;
        parents: string[];
    }>;
};
type RebuildOptions = {
    limit?: number;
    maxMemoryBytes?: number;
    onFlush?: (stats: {
        flushedBytes: number;
        totalFlushedBytes: number;
        flushCount: number;
    }) => void;
    onProgress?: (stats: {
        processedNodes: number;
        currentMemoryBytes: number | null;
    }) => void;
    signal?: AbortSignal;
    frontier?: Map<string, string>;
};
type LoadOptions = {
    strict?: boolean;
    currentFrontier?: Map<string, string>;
    autoRebuild?: boolean;
    rebuildRef?: string;
};
/**
 * Service for building and loading the bitmap index from the graph.
 *
 * This service orchestrates index creation by walking the graph and persisting
 * the resulting bitmap shards to storage via the IndexStoragePort. The bitmap
 * index enables O(1) neighbor lookups (children/parents) after a one-time
 * O(N) rebuild cost.
 *
 * @module domain/services/index/IndexRebuildService
 * @see BitmapIndexBuilder
 * @see BitmapIndexReader
 * @see StreamingBitmapIndexBuilder
 */
export default class IndexRebuildService {
    private readonly graphService;
    private readonly storage;
    private readonly logger;
    private readonly _codec;
    constructor(options: {
        graphService: GraphService;
        storage: IndexStoragePort & BlobPort & TreePort;
        logger?: LoggerPort;
        codec?: CodecPort;
        crypto?: unknown;
    });
    /**
     * Rebuilds the bitmap index by walking the graph from a ref.
     *
     * @returns OID of the created tree containing the index
     */
    rebuild(ref: string, options?: RebuildOptions): Promise<string>;
    private _buildStreamOpts;
    private _requireStreamingStorage;
    private _rebuildInMemory;
    private _rebuildStreaming;
    private _persistIndex;
    /**
     * Loads a previously built index from a tree OID.
     *
     * @returns Configured reader ready for O(1) queries.
     */
    load(treeOid: string, options?: LoadOptions): Promise<BitmapIndexReader>;
}
export {};
