import type { Node, Edge } from '@xyflow/react';
import type { NodeType, NodeCategory } from './nodes/types';

// ✅ NodeType 和 NodeCategory 已从 nodes/types.ts 导入，避免重复定义

// React Flow 节点数据 - 添加索引签名以满足React Flow的类型约束
export interface FlowNodeData extends Record<string, unknown> {
    label: string;
    nodeType: NodeType;
    category: NodeCategory;
    icon: string;
    color: string;
    
    // 运行时数据
    configs?: Record<string, any>;          // 基本配置数据（包含基本信息+节点配置）
    inputMapping?: Record<string, any>;     // 输入映射（用户配置）
    outputs?: import('./nodes/types').OutputField[];  // 输出能力定义（从节点定义中获取）
    
    // 原始节点定义（使用新的节点定义接口）
    nodeDefinition?: import('./nodes/types').WorkflowNodeDefinition;
}

// React Flow 边数据 - 添加索引签名以满足React Flow的类型约束
export interface FlowEdgeData extends Record<string, unknown> {
    label?: string;
    condition?: {
        type: 'EXPRESSION' | 'SCRIPT' | 'DEFAULT';
        expression?: string;
        script?: string;
        priority: number;
    };
}

// 扩展的React Flow节点类型
export type FlowNode = Node<FlowNodeData>;

// 扩展的React Flow边类型
export type FlowEdge = Edge<FlowEdgeData>;

// 节点配置模态框属性
export interface NodeConfigModalProps {
    visible: boolean;
    node: FlowNode | null;
    onCancel: () => void;
    onOk: (node: FlowNode, updatedData: Partial<FlowNodeData>) => void;
}

// 边配置模态框属性
export interface EdgeConfigModalProps {
    visible: boolean;
    edge: FlowEdge | null;
    onCancel: () => void;
    onOk: (edge: FlowEdge, updatedData: Partial<FlowEdgeData>) => void;
}

// ✅ 已删除未使用的类型：ToolbarActions, CanvasState, DragNodeData
