import { type CellRangeRef, type CellSnapshot, type CellValue, type DependencySnapshot, type EngineEvent, type ExplainCellSnapshot, type LiteralInput, type RecalcMetrics, type SelectionState, type SyncState, type WorkbookSnapshot } from '@bilig/protocol';
import type { CsvParseOptions } from './csv.js';
import type { EngineOp, EngineOpBatch } from '@bilig/workbook';
import type { EngineCellMutationRef, EngineExistingLiteralCellMutationRef, EngineExistingNumericCellMutationRef, EngineExistingNumericCellMutationsRef, EngineExistingNumericCellMutationResult, EngineFormulaSourceRefs } from './cell-mutations-at.js';
import { type EngineCounters } from './perf/engine-counters.js';
import type { CommitOp, EngineReplicaSnapshot, EngineSyncClient, SpreadsheetEngineOptions } from './engine/runtime-state.js';
import { SpreadsheetEngineWorkbookFacadeBase } from './engine/engine-workbook-facade-base.js';
import type { EngineSnapshotExportOptions } from './engine/services/snapshot-service.js';
export type { CommitOp, EngineReplicaSnapshot, EngineSyncClient, EngineSyncClientConnection, SpreadsheetEngineOptions, } from './engine/runtime-state.js';
export { selectors } from './engine-selectors.js';
export declare class SpreadsheetEngine extends SpreadsheetEngineWorkbookFacadeBase {
    private trustedExistingNumericDirectScalarFastPath;
    ready(): Promise<void>;
    subscribe(listener: (event: EngineEvent) => void): () => void;
    subscribeCell(sheetName: string, address: string, listener: () => void): () => void;
    subscribeCells(sheetName: string, addresses: readonly string[], listener: () => void): () => void;
    subscribeBatches(listener: (batch: EngineOpBatch) => void): () => void;
    subscribeSelection(listener: () => void): () => void;
    getSelectionState(): SelectionState;
    setSelection(sheetName: string, address: string | null, options?: {
        anchorAddress?: string | null;
        range?: {
            startAddress: string;
            endAddress: string;
        } | null;
        editMode?: SelectionState['editMode'];
    }): void;
    getLastMetrics(): RecalcMetrics;
    getPerformanceCounters(): EngineCounters;
    resetPerformanceCounters(): void;
    resetForReuse(options?: SpreadsheetEngineOptions): void;
    setUseColumnIndexEnabled(enabled: boolean): void;
    getSyncState(): SyncState;
    connectSyncClient(client: EngineSyncClient): Promise<void>;
    disconnectSyncClient(): Promise<void>;
    createSheet(name: string): void;
    createSheetForInitialization(name: string): number;
    moveSheet(name: string, order: number): void;
    renameSheet(oldName: string, newName: string): void;
    deleteSheet(name: string): void;
    setCellValue(sheetName: string, address: string, value: LiteralInput): CellValue;
    setCellValueAt(sheetId: number, row: number, col: number, value: LiteralInput): CellValue;
    setCellFormula(sheetName: string, address: string, formula: string): CellValue;
    setCellFormulaAt(sheetId: number, row: number, col: number, formula: string): CellValue;
    tryApplyExistingDirectScalarFormulaMutationAt(request: {
        readonly sheetId: number;
        readonly row: number;
        readonly col: number;
        readonly cellIndex: number;
        readonly formula: string;
    }): boolean;
    setCellFormat(sheetName: string, address: string, format: string | null): void;
    clearCellAt(sheetId: number, row: number, col: number): void;
    applyCellMutationsAt(refs: readonly EngineCellMutationRef[], potentialNewCells?: number): readonly EngineOp[] | null;
    applyCellMutationsAtWithOptions(refs: readonly EngineCellMutationRef[], options?: {
        captureUndo?: boolean;
        potentialNewCells?: number;
        source?: 'local' | 'restore';
        returnUndoOps?: boolean;
        reuseRefs?: boolean;
    }): readonly EngineOp[] | null;
    tryApplyExistingNumericCellMutationAt(request: EngineExistingNumericCellMutationRef): EngineExistingNumericCellMutationResult | null;
    private getTrustedExistingNumericDirectScalarFastPath;
    tryApplyExistingNumericCellMutationsAt(request: EngineExistingNumericCellMutationsRef): boolean;
    tryApplyExistingLiteralCellMutationAt(request: EngineExistingLiteralCellMutationRef): EngineExistingNumericCellMutationResult | null;
    initializeCellFormulasAt(refs: readonly EngineCellMutationRef[], potentialNewCells?: number): void;
    initializeCellFormulasAtNow(refs: readonly EngineCellMutationRef[], potentialNewCells?: number): void;
    initializeFormulaSourcesAtNow(refs: EngineFormulaSourceRefs, potentialNewCells?: number): void;
    recalculateNow(): number[];
    recalculateChangedValuesNowForRebuild(): number[];
    recalculateDifferential(): {
        js: CellSnapshot[];
        wasm: CellSnapshot[];
        drift: string[];
    };
    recalculateDirty(dirtyRegions: Array<{
        sheetName: string;
        rowStart: number;
        rowEnd: number;
        colStart: number;
        colEnd: number;
    }>): number[];
    clearCell(sheetName: string, address: string): void;
    setRangeValues(range: CellRangeRef, values: readonly (readonly LiteralInput[])[]): void;
    setRangeFormulas(range: CellRangeRef, formulas: readonly (readonly string[])[]): void;
    clearRange(range: CellRangeRef): void;
    fillRange(source: CellRangeRef, target: CellRangeRef): void;
    copyRange(source: CellRangeRef, target: CellRangeRef): void;
    moveRange(source: CellRangeRef, target: CellRangeRef): void;
    pasteRange(source: CellRangeRef, target: CellRangeRef): void;
    undo(): boolean;
    redo(): boolean;
    canUndo(): boolean;
    canRedo(): boolean;
    clearHistory(): void;
    exportSheetCsv(sheetName: string): string;
    importSheetCsv(sheetName: string, csv: string, options?: CsvParseOptions): void;
    getCellValue(sheetName: string, address: string): CellValue;
    getRangeValues(range: CellRangeRef): CellValue[][];
    getCell(sheetName: string, address: string): CellSnapshot;
    getCellByIndex(cellIndex: number): CellSnapshot;
    getDependencies(sheetName: string, address: string): DependencySnapshot;
    getDependents(sheetName: string, address: string): DependencySnapshot;
    explainCell(sheetName: string, address: string): ExplainCellSnapshot;
    exportSnapshot(options?: EngineSnapshotExportOptions): WorkbookSnapshot;
    importSnapshot(snapshot: WorkbookSnapshot): void;
    exportReplicaSnapshot(): EngineReplicaSnapshot;
    importReplicaSnapshot(snapshot: EngineReplicaSnapshot): void;
    renderCommit(ops: CommitOp[]): void;
    applyRemoteBatch(batch: EngineOpBatch): boolean;
    captureUndoOps<T>(mutate: () => T): {
        result: T;
        undoOps: readonly EngineOp[] | null;
    };
    applyOps(ops: readonly EngineOp[], options?: {
        captureUndo?: boolean;
        potentialNewCells?: number;
        source?: 'local' | 'restore';
        trusted?: boolean;
    }): readonly EngineOp[] | null;
}
