import { Node, Edge } from '../FlowPanel';
import { default as FlowManager } from '.';
import { FlowNode, Flow, FlowNodeLog, WithNodesFlow } from '../type';

export type AddNode = (node: Omit<Node, 'position'>) => void;
export type AddEdge = (edge: Edge) => void;
export type FlowData<T extends Record<string, any>> = Pick<WithNodesFlow<T>, 'type' | 'params' | 'result' | 'nodes' | 'customVar'>;
export interface NodeManager<P = any> {
    type: string;
    RenderWhenFlowNode: (props: any) => JSX.Element;
    RenderWhenCreate: () => JSX.Element;
    RenderWhenLog?: (props: any) => JSX.Element;
    onHandleInsert?: (node: FlowNode<P>, newNode: FlowNode, data: any) => boolean | void;
    onHandleRemove?: (node: FlowNode<P>, willRemoveNode: FlowNode) => boolean | void;
    onBeforeInsert?: (manager: FlowManager, id: string) => Omit<FlowNode<P>, 'name' | 'type'>;
    onBeforeRemove?: (manager: FlowManager, node: FlowNode<P>) => void;
    checkComplete: (params?: P) => boolean;
    onCreateUi: (manager: FlowManager, node: FlowNode<P>, options: {
        payload?: any;
        preNodeId: string;
        addNode: AddNode;
        addEdge: AddEdge;
    }) => {
        endNodeId: string;
        payload?: any;
    };
    onComputedLog: (manager: FlowManager, nodeLog: FlowNodeLog) => void;
}
export interface StartManager<P = any> {
    type: string;
    Render: () => JSX.Element;
    RenderWhenLog?: () => JSX.Element;
    checkComplete: (params?: P) => boolean;
}
export interface EndManager {
    type: string;
    Render: () => JSX.Element;
    RenderWhenLog?: () => JSX.Element;
    checkComplete: (result?: Flow['result']) => boolean;
}
