import type { AggregationFn, Aggregator, Dimension, DimensionAgg, DimensionSort, FilterFn, GroupFn, GroupIdFn, LeafIdFn, RowGroup, RowLeaf, RowNode, RowSelectionState, RowSource, SortFn } from "@1771technologies/lytenyte-shared";
import type { PivotState } from "./hooks/use-pivot/use-pivot-columns.js";
import type { Column, Field } from "../types.js";
import type { Grid } from "@1771technologies/lytenyte-core";
export type PivotField<Spec extends Grid.GridSpec = Grid.GridSpec> = {
    field?: Field<Spec["data"]>;
};
export type HavingFilterFn = (node: RowGroup) => boolean;
export interface RowSourceClient<Spec extends Grid.GridSpec = Grid.GridSpec> extends RowSource<Spec["data"]> {
    readonly usePivotProps: () => {
        readonly columns?: Column<Spec>[];
        readonly onColumnsChange: Grid.Props<Spec>["onColumnsChange"];
        readonly columnGroupExpansions: Grid.Props<Spec>["columnGroupExpansions"];
        readonly onColumnGroupExpansionChange: Grid.Props<Spec>["onColumnGroupExpansionChange"];
    };
    readonly rowUpdate: (rows: Map<RowNode<Spec["data"]>, Spec["data"]>) => void;
    readonly rowDelete: (rows: RowNode<Spec["data"]>[]) => void;
    readonly rowAdd: (rows: Spec["data"][], placement?: "start" | "end" | number) => void;
}
export type LabelFilter = (s: string | null) => boolean;
export interface PivotModel<Spec extends Grid.GridSpec = Grid.GridSpec> {
    readonly columns?: (Column<Spec> | PivotField<Spec>)[];
    readonly rows?: (Column<Spec> | PivotField<Spec>)[];
    readonly measures?: {
        dim: Column<Spec>;
        fn: Aggregator<Spec["data"]> | string;
    }[];
    readonly sort?: SortFn<Spec["data"]> | DimensionSort<Spec["data"]>[] | null;
    readonly filter?: (HavingFilterFn | null)[];
    readonly rowLabelFilter?: (LabelFilter | null)[];
    readonly colLabelFilter?: (LabelFilter | null)[];
}
export interface UseClientDataSourceParams<Spec extends Grid.GridSpec = Grid.GridSpec, T = Spec["data"]> {
    readonly data: T[];
    readonly topData?: T[];
    readonly botData?: T[];
    readonly pivotMode?: boolean;
    readonly pivotModel?: PivotModel<Spec>;
    readonly pivotGrandTotals?: "top" | "bottom" | null;
    readonly pivotColumnProcessor?: (columns: Column<Spec>[]) => Column<Spec>[];
    readonly pivotState?: PivotState;
    readonly onPivotStateChange?: (p: PivotState) => void;
    readonly pivotApplyExistingFilter?: boolean;
    readonly rowGroupExpansions?: {
        [rowId: string]: boolean | undefined;
    };
    readonly rowGroupDefaultExpansion?: boolean | number;
    readonly rowGroupCollapseBehavior?: "no-collapse" | "last-only" | "full-tree";
    readonly rowGroupSuppressLeafExpansion?: boolean;
    readonly onRowGroupExpansionChange?: (state: Record<string, boolean | undefined>) => void;
    readonly sort?: SortFn<T> | DimensionSort<T>[] | null;
    readonly group?: GroupFn<T> | Dimension<T>[];
    readonly filter?: FilterFn<T> | FilterFn<T>[] | null;
    readonly aggregate?: AggregationFn<T> | DimensionAgg<T>[];
    readonly aggregateFns?: Record<string, Aggregator<T>>;
    readonly having?: (HavingFilterFn | null)[] | null;
    readonly labelFilter?: (LabelFilter | null)[] | null;
    readonly leafIdFn?: LeafIdFn<T>;
    readonly groupIdFn?: GroupIdFn;
    readonly rowsIsolatedSelection?: boolean;
    readonly rowSelectKey?: unknown[];
    readonly rowSelection?: RowSelectionState;
    readonly rowSelectionIdUniverseAdditions?: {
        readonly id: string;
        readonly root: boolean;
    }[];
    readonly rowSelectionIdUniverseSubtractions?: Set<string>;
    readonly onRowSelectionChange?: (state: RowSelectionState) => void;
    readonly onRowsAdded?: (params: {
        newData: T[];
        placement: "start" | "end" | number;
        top: T[];
        center: T[];
        bottom: T[];
    }) => void;
    readonly onRowsDeleted?: (params: {
        rows: RowLeaf<T>[];
        sourceIndices: number[];
        top: T[];
        center: T[];
        bottom: T[];
    }) => void;
    readonly onRowDataChange?: (params: {
        readonly rows: Map<RowNode<T>, T>;
        readonly top: Map<number, T>;
        readonly bottom: Map<number, T>;
        readonly center: Map<number, T>;
    }) => void;
}
export declare function useClientDataSource<Spec extends Grid.GridSpec = Grid.GridSpec>(props: UseClientDataSourceParams<Spec>): RowSourceClient<Spec>;
