import { Effect } from 'effect';
import { type CellValue } from '@bilig/protocol';
import type { EngineOp } from '@bilig/workbook';
import type { FormulaTable } from '../../formula-table.js';
import type { RangeRegistry } from '../../range-registry.js';
import type { StringPool } from '../../string-pool.js';
import type { WasmKernelFacade } from '../../wasm-facade.js';
import { type WorkbookPivotRecord, type WorkbookStore } from '../../workbook-store.js';
import type { RuntimeFormula } from '../runtime-state.js';
import { EnginePivotError } from '../errors.js';
interface EnginePivotState {
    readonly workbook: WorkbookStore;
    readonly strings: StringPool;
    readonly formulas: FormulaTable<RuntimeFormula>;
    readonly ranges: RangeRegistry;
    readonly wasm: WasmKernelFacade;
    readonly pivotOutputOwners: Map<number, string>;
}
export interface EnginePivotService {
    readonly materializePivot: (pivot: WorkbookPivotRecord) => Effect.Effect<number[], EnginePivotError>;
    readonly resolvePivotData: (sheetName: string, address: string, dataField: string, filters: ReadonlyArray<{
        field: string;
        item: CellValue;
    }>) => Effect.Effect<CellValue, EnginePivotError>;
    readonly clearOwnedPivot: (pivot: WorkbookPivotRecord) => Effect.Effect<number[], EnginePivotError>;
    readonly clearPivotForCell: (cellIndex: number) => Effect.Effect<number[], EnginePivotError>;
    readonly materializePivotNow: (pivot: WorkbookPivotRecord) => number[];
    readonly resolvePivotDataNow: (sheetName: string, address: string, dataField: string, filters: ReadonlyArray<{
        field: string;
        item: CellValue;
    }>) => CellValue;
    readonly clearOwnedPivotNow: (pivot: WorkbookPivotRecord) => number[];
    readonly clearPivotForCellNow: (cellIndex: number) => number[];
}
export declare function createEnginePivotService(args: {
    readonly state: EnginePivotState;
    readonly ensureCellTrackedByCoords: (sheetId: number, row: number, col: number) => number;
    readonly forEachSheetCell: (sheetId: number, fn: (cellIndex: number, row: number, col: number) => void) => void;
    readonly flushDeferredKernelSync: () => void;
    readonly scheduleWasmProgramSync: () => void;
    readonly flushWasmProgramSync: () => void;
    readonly applyDerivedOp: (op: Extract<EngineOp, {
        kind: 'upsertSpillRange' | 'deleteSpillRange' | 'upsertPivotTable' | 'deletePivotTable';
    }>) => number[];
}): EnginePivotService;
export {};
