import type { WarpState } from '../JoinReducer.ts';
import type Patch from '../../types/Patch.ts';
import type CodecPort from '../../../ports/CodecPort.ts';
import type { VisibleStateScope, CoordinateComparisonSide } from '../../types/CoordinateComparison.ts';
import type { StrandDescriptor } from '../../types/StrandDescriptor.ts';
import type CryptoPort from '../../../ports/CryptoPort.ts';
export type PatchEntry = {
    patch: Patch;
    sha: string;
};
type ComparisonMaterializedState = {
    state: WarpState;
};
/**
 * Materialize options for the coordinate materialization path.
 *
 * This mirrors the options accepted by the WarpRuntime materialize
 * controller: a frontier record and an optional lamport ceiling.
 */
export type MaterializeCoordinateOptions = {
    frontier: Map<string, string>;
    ceiling?: number | null;
};
export type ComparisonDigestHost = {
    _crypto: CryptoPort;
    _codec: CodecPort;
    _stateHashService: {
        compute(state: WarpState): Promise<string>;
    } | null;
};
export type ComparisonPatchEntrySource = {
    _loadPatchChainFromSha(sha: string): Promise<PatchEntry[]>;
};
export type ComparisonCoordinateSideReadSource = ComparisonPatchEntrySource & {
    getFrontier(): Promise<Map<string, string>>;
    _materializeCoordinateGraph(opts: MaterializeCoordinateOptions): Promise<ComparisonMaterializedState>;
};
export type MaterializeStrandOptions = {
    ceiling?: number | null;
};
/**
 * Host surface still required by transfer planning and full strand overlay
 * comparison. Coordinate-backed selector resolution uses
 * ComparisonCoordinateSideReadPort instead.
 */
export type ComparisonHost = ComparisonDigestHost & {
    _blobStorage: {
        retrieve(oid: string): Promise<Uint8Array>;
    } | null;
    _persistence: {
        readBlob(oid: string): Promise<Uint8Array>;
    };
    _materializeStrandGraph(strandId: string, options?: MaterializeStrandOptions): Promise<ComparisonMaterializedState>;
};
/**
 * The `requested` payload captured for each resolved comparison side,
 * discriminated by selector kind. Carries enough context to replay the
 * resolution deterministically and to show back to the caller.
 */
export type ComparisonRequestedSide = {
    kind: 'live';
    ceiling?: number | null;
} | {
    kind: 'coordinate';
    frontier: Record<string, string>;
    ceiling: number | null;
} | {
    kind: 'strand';
    strandId: string;
    ceiling?: number | null;
} | {
    kind: 'strand_base';
    strandId: string;
    frontier: Record<string, string>;
    baseLamportCeiling: number | null;
    ceiling?: number | null;
};
/** Strand metadata attached to a strand-kind resolved side. */
export type StrandComparisonMetadata = NonNullable<CoordinateComparisonSide['resolved']['strand']>;
/** Resolved payload shape for a finalized comparison side. */
export type ComparisonResolvedSide = CoordinateComparisonSide['resolved'];
export declare function compareStrings(a: string, b: string): number;
export declare function normalizeLamportCeiling(value: number | null | undefined, field: string): number | null;
export declare function normalizeOptionalString(value: string | null | undefined, field: string): string | null;
export declare function normalizeRequiredString(value: string | null | undefined, field: string): string;
export declare function normalizeFrontierRecord(frontier: Map<string, string> | Record<string, string>, field: string): Record<string, string>;
export declare function frontierRecordToMap(frontierRecord: Record<string, string>): Map<string, string>;
export declare function optionalCeiling(ceiling: number | null): Record<string, number>;
export declare function combineCeilings(left: number | null, right: number | null): number | null;
export declare function buildCoordinateRequest(frontierRecord: Record<string, string>, ceiling: number | null): {
    frontier: Record<string, string>;
    ceiling: number | null;
};
export declare function patchFrontierFromEntries(entries: readonly PatchEntry[]): Record<string, string>;
export declare function lamportFrontierFromEntries(entries: readonly PatchEntry[]): Record<string, number>;
export declare function uniqueSortedPatchShas(entries: readonly PatchEntry[]): string[];
export declare function collectPatchEntriesForFrontier(graph: ComparisonPatchEntrySource, frontierRecord: Record<string, string>, ceiling: number | null): Promise<PatchEntry[]>;
export declare function buildStrandMetadata(strandId: string, descriptor: StrandDescriptor): StrandComparisonMetadata;
export declare function computeStateHashForGraph(graph: ComparisonDigestHost, state: WarpState): Promise<string>;
export declare class ResolvedComparisonSide {
    readonly requested: ComparisonRequestedSide;
    readonly resolved: ComparisonResolvedSide;
    readonly state: WarpState;
    readonly patchEntries: PatchEntry[];
    constructor(params: {
        requested: ComparisonRequestedSide;
        state: WarpState;
        patchEntries: readonly PatchEntry[];
        resolved: ComparisonResolvedSide;
    });
}
type FinalizeSideParams = {
    requested: ComparisonRequestedSide;
    state: WarpState;
    patchEntries: readonly PatchEntry[];
    coordinateKind: 'frontier' | 'strand' | 'strand_base';
    lamportCeiling: number | null;
    strand?: StrandComparisonMetadata;
};
export declare function finalizeSide(graph: ComparisonDigestHost, params: FinalizeSideParams, scope: VisibleStateScope | null): Promise<ResolvedComparisonSide>;
export {};
