import { CSSProperties } from "vue";

declare type FlowField = {
	field: string; // 自定义命名
	type?: string; // 字段类型 string number ...
	value?: string; // 自定义值
	name?: string; // 选择的变量名
	nodeId?: string; // 选择的节点ID
	nodeType?: string; // 选择的节点类型 start end ...
	label?: string; // 显示名称
	required?: boolean; // 是否必填
	[key: string]: any;
};

declare interface FlowData {
	inputParams?: FlowField[];
	outputParams?: FlowField[];
	options?: any;
}

declare interface FlowNode {
	enable?: boolean;
	id?: string;
	label?: string;
	description?: string;
	type?: string;
	icon?: string;
	name?: `node-${string}`;
	position?: {
		x: number;
		y: number;
	};
	form?: {
		width?: string;
		focus?: string;
		items: ClForm.Item[];
	};
	handle?: {
		target?: boolean;
		source?: boolean;
		next?: { label: string; value: string; [key: string]: any }[];
	};
	data?: FlowData;
	validator?(data: FlowData): void | string;
	isDisableDrag?: boolean; // 是否禁用拖拽（部分组件跟拖拽事件冲突，需禁用。例：伪富文本dom）
	[key: string]: any;
}

declare interface FlowEdge {
	id: string;
	type?: string;
	target: string;
	source: string;
	targetHandle?: string | null;
	sourceHandle?: string | null;
	animated?: boolean;
	style?: CSSProperties;
	[key: string]: any;
}

declare interface FlowNodeResult {
	duration: number;
	isEnd: boolean;
	nodeId?: string;
	node?: FlowNode;
	nextNodeId?: string;
	inputParams?: any;
	outputParams?: any;
	llmStream?: boolean;
	count?: {
		tokenUsage: number;
	};
	result: {
		success: boolean;
		result: {
			[key: string]: any;
		};
		error: {
			message: string;
		};
	};
	[key: string]: any;
}
