import { ErrorCode, FormulaMode, ValueTag } from '@bilig/protocol';
import { type EngineCounters } from '../../perf/engine-counters.js';
import type { RuntimeDirectCriteriaDescriptor, RuntimeDirectLookupDescriptor, RuntimeDirectScalarDescriptor, U32 } from '../runtime-state.js';
import type { DirectFormulaIndexCollection, DirectScalarCurrentOperand } from './direct-formula-index-collection.js';
export interface DirectFormulaMetricCounts {
    wasmFormulaCount: number;
    jsFormulaCount: number;
}
export interface OperationPostRecalcFormula {
    readonly compiled: {
        readonly producesSpill: boolean;
        readonly mode?: FormulaMode;
    };
    readonly directAggregate: object | undefined;
    readonly directCriteria: RuntimeDirectCriteriaDescriptor | undefined;
    readonly directLookup: RuntimeDirectLookupDescriptor | undefined;
    readonly directScalar: RuntimeDirectScalarDescriptor | undefined;
}
export interface OperationPostRecalcDirectFormulaState {
    readonly workbook: {
        readonly cellStore: {
            readonly flags: {
                readonly [index: number]: number | undefined;
            };
            readonly tags: ArrayLike<ValueTag | undefined>;
            readonly numbers: ArrayLike<number | undefined>;
            readonly errors: ArrayLike<ErrorCode | undefined>;
        };
        readonly withBatchedColumnVersionUpdates: (apply: () => void) => void;
    };
    readonly formulas: {
        readonly get: (cellIndex: number) => OperationPostRecalcFormula | undefined;
    };
    readonly counters: EngineCounters;
}
export interface ApplyPostRecalcDirectFormulaChangesArgs {
    readonly state: OperationPostRecalcDirectFormulaState;
    readonly collection: DirectFormulaIndexCollection;
    readonly recalculated: U32;
    readonly didRunRecalc: boolean;
    readonly captureChanged?: boolean;
    readonly metrics: DirectFormulaMetricCounts;
    readonly applyDirectFormulaCurrentResult: (cellIndex: number, result: DirectScalarCurrentOperand) => boolean;
    readonly applyDirectFormulaNumericDelta: (cellIndex: number, delta: number) => boolean;
    readonly applyDirectScalarCurrentValue: (cellIndex: number, directScalar: RuntimeDirectScalarDescriptor) => boolean;
    readonly tryApplyDirectScalarDeltas: (collection: DirectFormulaIndexCollection, captureChanged?: boolean) => U32 | undefined;
    readonly tryApplyDirectFormulaDeltas: (collection: DirectFormulaIndexCollection, captureChanged?: boolean) => U32 | undefined;
    readonly countPostRecalcDirectFormulaMetric: (cellIndex: number, counts: DirectFormulaMetricCounts) => void;
    readonly evaluateDirectFormula: (cellIndex: number) => readonly number[] | undefined;
    readonly hasCycleDependency?: (cellIndex: number) => boolean;
}
export declare function applyPostRecalcDirectFormulaChanges(args: ApplyPostRecalcDirectFormulaChangesArgs): U32;
export declare function countOperationPostRecalcDirectFormulaMetric(input: {
    readonly formulas: {
        readonly get: (cellIndex: number) => OperationPostRecalcFormula | undefined;
    };
    readonly cellIndex: number;
    readonly counts: DirectFormulaMetricCounts;
}): void;
export declare function tryApplySinglePostRecalcDirectFormula(args: ApplyPostRecalcDirectFormulaChangesArgs, captureChanged?: boolean): U32 | undefined;
