/**
 * Pure-domain bitmap accumulator for bitmap index building.
 *
 * Manages SHA→numeric-ID allocation and forward/reverse edge bitmaps.
 * No I/O — the orchestrator (StreamingBitmapIndexBuilder) owns flush
 * and persistence. Shared by both in-memory and streaming builders.
 *
 * @module domain/services/index/BitmapAccumulator
 */
import { type RoaringBitmapSubset } from '../../utils/roaring.ts';
export type BitmapDirection = 'fwd' | 'rev';
/**
 * Accumulates bitmap index data in memory.
 *
 * Assigns monotonically increasing numeric IDs to SHAs and maintains
 * forward/reverse edge bitmaps. Tracks estimated memory usage for
 * streaming builders that need to flush on pressure.
 */
export default class BitmapAccumulator {
    readonly shaToId: Map<string, number>;
    readonly idToSha: string[];
    readonly bitmaps: Map<string, RoaringBitmapSubset>;
    estimatedBitmapBytes: number;
    private readonly _RoaringBitmap32;
    constructor();
    /**
     * Registers a node and returns its numeric ID.
     * If the SHA was already registered, returns the existing ID.
     */
    registerNode(sha: string): number;
    /**
     * Adds a directed edge from source to target.
     * Both nodes are auto-registered if not already present.
     * Updates both forward (src→tgt) and reverse (tgt→src) bitmaps.
     */
    addEdge(srcSha: string, tgtSha: string): void;
    /** Estimated memory used by SHA→ID mappings. */
    get estimatedMappingBytes(): number;
    /** Total number of registered nodes. */
    get nodeCount(): number;
    /** Number of bitmaps currently held in memory. */
    get bitmapCount(): number;
    /**
     * Clears all bitmaps and resets memory estimate.
     * SHA→ID mappings are preserved (required for global ID consistency).
     */
    clearBitmaps(): void;
    /**
     * Groups bitmaps by direction and SHA prefix (first 2 hex chars).
     * Returns serialized shard data ready for encoding.
     */
    serializeBitmapsToShards(): {
        fwd: Record<string, Record<string, Uint8Array>>;
        rev: Record<string, Record<string, Uint8Array>>;
    };
    /**
     * Groups SHA→ID mappings by SHA prefix (first 2 hex chars).
     */
    buildMetaShards(): Record<string, Record<string, number>>;
    /**
     * Yields bounded meta-shard chunks grouped by SHA prefix.
     *
     * This avoids building a second full nested shard object during finalize.
     */
    iterateMetaShardChunks(maxEntriesPerChunk: number): Iterable<{
        prefix: string;
        entries: Array<[string, number]>;
    }>;
    private _getOrCreateId;
    private _addToBitmap;
}
