/**
 * Pipeline 类型定义
 *
 * 本文件是 pipeline 与插件系统的**唯一权威类型来源**。
 * 其他位置（如 plugins/operate-column/types）仅定义自身内部类型，
 * 对外 handler 接口统一引用此文件。
 */
import * as React from 'react';
import type { Pipeline } from './pipeline';
import type { PrimaryKeyType } from '../../../../utils/primary-key';
import type { CnAiListEventNamesMap } from '../../../../../../cn-ai-agent/constants/event-constants';
/** Pipeline 数据结构 */
export interface TablePipelineData {
    rows: any[];
    columns: any[];
}
/** 行选择配置（存储在 Pipeline config 中） */
export interface RowSelectionConfig {
    enabled: boolean;
    selectionType: 'single' | 'multiple';
    selectedKeys: any[];
    primaryKey: PrimaryKeyType;
    dataSource: any[];
}
/** 操作列配置（存储在 Pipeline config 中） */
export interface OperateColumnConfig {
    enabled: boolean;
    options: IOperateColumnOptions;
}
/** 操作列按钮配置 */
export interface IOperateColumnButton {
    children: string | React.ReactNode | ((row: any, index: number) => React.ReactNode);
    type?: 'primary' | 'secondary' | 'normal';
    onClick?: (event: React.MouseEvent, row: any, index: number) => void;
    visible?: (row: any, index: number) => boolean;
    isDisabled?: (row: any, index: number) => boolean;
    btnProps?: Record<string, any>;
}
/** 操作列选项 */
export interface IOperateColumnOptions {
    width?: number;
    buttons?: Array<IOperateColumnButton | ((row: any, index: number) => React.ReactNode)>;
    showButtonNum?: number;
    render?: (val: any, record: any, index: number) => React.ReactNode;
    split?: React.ReactNode;
    splitWidth?: number;
    moreBtnProps?: Record<string, any>;
    lock?: boolean | 'left' | 'right';
}
/** Pipeline 配置 */
export interface TablePipelineConfig {
    viewId: string;
    rowHeight: 'low' | 'medium' | 'high';
    showIndex: boolean;
    widthMap: Record<string, number>;
    rowSelection?: RowSelectionConfig;
    operateColumn?: OperateColumnConfig;
}
/** 行选择处理函数（由 row-selection plugin 写入 context） */
export interface RowSelectionHandlers {
    /** 处理单行选择变化（保持原始类型，宽松等值比较） */
    handleRowSelectChange: (rowId: any, selected: boolean) => void;
    /** 检查行是否被选中 */
    isRowSelected: (rowId: any) => boolean;
    /** 检查行是否被禁用选择 */
    isRowDisabled: (record: any) => boolean;
    /** 可选的行 key 列表（排除禁用行，保持原始类型） */
    selectableRowKeys: any[];
    /** 全选 / 半选状态 */
    selectAllState: {
        checked: boolean;
        indeterminate: boolean;
    };
    /** 全选 / 取消全选 */
    handleSelectAll: (checked: boolean) => void;
    /** 清空所有选中 */
    handleClearSelection: () => void;
}
/** 操作列处理函数（由 operate-column plugin 写入 context） */
export interface OperateColumnHandlers {
    getOperateColumn: () => Record<string, any>;
    renderOperateCell: (record: Record<string, any>, index: number) => React.ReactNode;
    getOperateColumnWidth: () => number;
    getOperateColumnTitle: () => string;
}
/** runPlugins 传给每个插件的上下文 */
export interface TablePipelineContext {
    dataModel: any;
    table: any;
    viewId: string;
}
/**
 * 传给插件 render 的 Props 快照。
 * 由 NormalTableView / Detail View 在调用 runPlugins 前构建。
 */
export interface PluginInputProps {
    viewId: string;
    table: any;
    columns: any[];
    viewColumnMetaData: any;
    rowHeight?: 'low' | 'medium' | 'high';
    showIndex?: boolean;
    rowSelectionProps?: {
        hasSelect?: boolean;
        selectKeys?: any[];
        setSelectKeys?: (...args: any[]) => void;
        selectionType?: 'single' | 'multiple';
        isDisabled?: (record: any, index: number) => boolean;
        primaryKey?: PrimaryKeyType;
    };
    operateColumn?: IOperateColumnOptions;
    customRowRenderer?: any;
    customRows?: Array<{
        type: 'data' | 'custom';
        row?: any;
        data?: any;
        groupRowIndex?: number;
    }>;
    onRowDragEnd?: (activeId: string | number, overId: string | number) => void;
    /** 与当前表格 `id` 对应的总线事件名（行选插件等使用） */
    cnAiListEventNames?: CnAiListEventNamesMap;
}
/**
 * @deprecated 请使用 PluginInputProps。保留别名仅为向后兼容。
 */
export type NormalTableViewProps = PluginInputProps;
/** 插件渲染函数类型 */
export type PluginRenderFunction = (props: PluginInputProps, pipeline: Pipeline, context: TablePipelineContext) => void;
/** 注册的插件描述 */
export interface RegisteredPlugin {
    name: string;
    render: PluginRenderFunction;
    /** 执行优先级，数值越小越先执行，默认 100 */
    priority: number;
}
