import type { IChartInfo, IChartSnapshot } from '@univerjs-pro/engine-chart';
import type { IFieldsCollectionJSON, IPivotTableFilterInfo, IPivotTableShowDataAsInfo, IPivotTableSnapshot, IPivotTableSortInfo, IPivotTableValueFilter, PivotDataFieldDataTypeEnum, PivotDateGroupFieldDateTypeEnum, PivotSubtotalTypeEnum, PivotTableFiledAreaEnum, PivotTableValuePositionEnum } from '@univerjs-pro/engine-pivot';
import type { ILinkedPivotChartDefinition, IOwnedPivotChartDefinition, IPivotChartCalculationResult, IPivotChartControls, IPivotChartPivotTableReference, IPivotChartRuntimeState, PivotChartSourceKind } from '@univerjs-pro/pivot-chart';
import type { ChartAnchorSpec } from '@univerjs-pro/sheets-chart';
import type { IUnitRangeNameWithSubUnitId } from '@univerjs-pro/sheets-pivot';
import type { IRange } from '@univerjs/core';
import type { ISheetCommandSharedParams } from '@univerjs/sheets';
export interface IPivotChartSourcePayload {
    sourceRangeInfo: IUnitRangeNameWithSubUnitId;
    collectionConfig: IFieldsCollectionJSON;
}
/** A local A1 range, zero-based range, or fully qualified Pivot source range. */
export type PivotChartRangeInput = string | IRange | IUnitRangeNameWithSubUnitId;
/** A detached PivotChart source that creates an independently owned PivotModel. */
export interface IPivotChartRangeSourceSpec {
    kind: PivotChartSourceKind.Range;
    sourceRangeInfo: IUnitRangeNameWithSubUnitId;
}
/** A detached PivotChart source linked to an existing PivotTable-owned PivotModel. */
export interface IPivotChartTableSourceSpec {
    kind: PivotChartSourceKind.PivotTable;
    pivotTableRef: IPivotChartPivotTableReference;
}
/** Exactly one report source used by a detached Sheet PivotChart. */
export type PivotChartSourceSpec = IPivotChartRangeSourceSpec | IPivotChartTableSourceSpec;
/** Detached Sheet PivotChart information produced by the Facade builder. */
export interface ISheetPivotChartInfo extends IChartInfo<PivotChartSourceSpec> {
    anchor?: ChartAnchorSpec;
    name?: string;
    controls?: Partial<IPivotChartControls>;
    initialFieldsConfig?: IPivotTableSnapshot;
}
/** Editable settings shared by PivotTable and PivotChart report fields. */
export interface IPivotChartFieldSettingOptions {
    displayName?: string;
    format?: string;
    subtotalType?: PivotSubtotalTypeEnum;
    showDataAs?: IPivotTableShowDataAsInfo;
}
/** Source field metadata available for configuring a PivotChart report. */
export interface IPivotChartDataFieldInfo {
    id: string;
    name: string;
    fieldDataType: PivotDataFieldDataTypeEnum;
    displayName?: string;
}
interface IAddOwnedPivotChartMutationParams extends ISheetCommandSharedParams {
    definition: IOwnedPivotChartDefinition;
    source?: IPivotChartSourcePayload;
}
interface IAddLinkedPivotChartMutationParams extends ISheetCommandSharedParams {
    definition: ILinkedPivotChartDefinition;
    source?: never;
}
export type IAddPivotChartMutationParams = IAddOwnedPivotChartMutationParams | IAddLinkedPivotChartMutationParams;
export interface IRemovePivotChartMutationParams extends ISheetCommandSharedParams {
    pivotChartId: string;
}
export interface IUpdatePivotChartMutationParams extends IRemovePivotChartMutationParams {
    pivotModel: IPivotTableSnapshot;
}
export interface IUpdatePivotChartCacheReferenceMutationParams extends IRemovePivotChartMutationParams {
    pivotCacheId: string;
}
export interface IUpdatePivotChartVisualMutationParams extends IRemovePivotChartMutationParams {
    chart: IChartSnapshot;
}
export interface IUpdatePivotChartControlsMutationParams extends IRemovePivotChartMutationParams {
    controls: IPivotChartControls;
}
export interface IUpdatePivotChartPresentationMutationParams extends IRemovePivotChartMutationParams {
    chart: IChartSnapshot;
    controls: IPivotChartControls;
    name: string | undefined;
}
export interface ISendPivotChartResultLocalMutationParams extends ISheetCommandSharedParams {
    result: IPivotChartCalculationResult;
}
export interface ISendPivotChartStateLocalMutationParams extends ISheetCommandSharedParams {
    pivotChartId: string;
    state: Omit<IPivotChartRuntimeState, 'error'> & {
        error?: string;
    };
}
export interface IRequestPivotChartSourceLocalMutationParams extends ISheetCommandSharedParams {
    requestId: string;
    pivotChartId: string;
}
export interface ISendPivotChartSourceLocalMutationParams {
    requestId: string;
    source?: IPivotChartSourcePayload;
    error?: string;
}
export interface ISendPivotChartSourceMetadataLocalMutationParams extends IRemovePivotChartMutationParams {
    source: IPivotChartSourcePayload;
}
export type IPivotChartEdit = {
    type: 'setFieldsConfig';
    config: IPivotTableSnapshot;
} | {
    type: 'addField';
    dataFieldId: string;
    fieldArea: PivotTableFiledAreaEnum;
    index: number;
} | {
    type: 'moveField';
    fieldId: string;
    fieldArea: PivotTableFiledAreaEnum;
    index: number;
} | {
    type: 'removeFields';
    fieldIds: string[];
} | {
    type: 'updateValuePosition';
    position: PivotTableValuePositionEnum;
    index: number;
} | {
    type: 'setFieldSetting';
    fieldId: string;
    setting: IPivotChartFieldSettingOptions;
} | {
    type: 'setFilter';
    fieldId: string;
    items: string[];
    isAll?: boolean;
} | {
    type: 'setValueFilter';
    fieldId: string;
    filterInfo?: IPivotTableValueFilter;
} | {
    type: 'setCollapse';
    fieldId: string;
    collapse: boolean;
    item?: string;
} | {
    type: 'setCategoryLevel';
    fieldId: string;
} | {
    type: 'setDateGroup';
    fieldId: string;
    dateType: PivotDateGroupFieldDateTypeEnum;
} | {
    type: 'setSort';
    fieldId: string;
    info?: IPivotTableSortInfo;
};
export interface IRequestPivotChartEditLocalMutationParams extends IRemovePivotChartMutationParams {
    requestId: string;
    edit: IPivotChartEdit;
}
export interface ISendPivotChartEditLocalMutationParams {
    requestId: string;
    pivotModel?: IPivotTableSnapshot;
    source?: IPivotChartSourcePayload;
    error?: string;
}
export interface IPivotChartFilterInfo {
    tableFieldId: string;
    pivotTableId: string;
    items: string[];
    itemTypes: PivotDataFieldDataTypeEnum[];
    format?: string;
    filterInfo: IPivotTableFilterInfo | undefined;
    sortInfo: IPivotTableSortInfo | undefined;
}
export interface IRequestPivotChartFilterInfoLocalMutationParams extends IRemovePivotChartMutationParams {
    requestId: string;
    fieldId: string;
}
export interface ISendPivotChartFilterInfoLocalMutationParams {
    requestId: string;
    filterInfo?: IPivotChartFilterInfo;
    error?: string;
}
export {};
