import { jsx } from "react/jsx-runtime";
import { useAgentFlowStore } from "../store/agent-flow-store.js";
import { StaticEdge } from "./StaticEdge.js";
const Edge = (props)=>{
    const { nodes } = useAgentFlowStore();
    const { source, target } = props;
    const sourceNode = nodes.find((node)=>node.id === source);
    const targetNode = nodes.find((node)=>node.id === target);
    const getConnectedNodesStatus = ()=>{
        let hasError = false;
        let hasSuccess = false;
        let hasRunning = false;
        let isCurrentBreakpoint = false;
        let isSuggestion = false;
        let suggestionType;
        if (sourceNode?.type === 'resource') {
            hasError = hasError || (sourceNode.data?.hasError ?? false);
            hasSuccess = hasSuccess || (sourceNode.data?.hasSuccess ?? false);
            hasRunning = hasRunning || (sourceNode.data?.hasRunning ?? false);
            isCurrentBreakpoint = isCurrentBreakpoint || (sourceNode.data?.isCurrentBreakpoint ?? false);
            isSuggestion = isSuggestion || (sourceNode.data?.isSuggestion ?? false);
            suggestionType = sourceNode.data?.suggestionType;
        }
        if (targetNode?.type === 'resource') {
            hasError = hasError || (targetNode.data?.hasError ?? false);
            hasSuccess = hasSuccess || (targetNode.data?.hasSuccess ?? false);
            hasRunning = hasRunning || (targetNode.data?.hasRunning ?? false);
            isCurrentBreakpoint = isCurrentBreakpoint || (targetNode.data?.isCurrentBreakpoint ?? false);
            isSuggestion = isSuggestion || (targetNode.data?.isSuggestion ?? false);
            suggestionType = targetNode.data?.suggestionType;
        }
        return {
            hasError,
            hasSuccess,
            hasRunning,
            isCurrentBreakpoint,
            isSuggestion,
            suggestionType
        };
    };
    const { hasError, hasSuccess, hasRunning, isCurrentBreakpoint, isSuggestion, suggestionType } = getConnectedNodesStatus();
    const staticEdgeProps = {
        ...props,
        data: {
            label: null
        },
        hasError,
        hasSuccess,
        hasRunning,
        isCurrentBreakpoint,
        isSuggestion,
        suggestionType
    };
    return /*#__PURE__*/ jsx(StaticEdge, {
        ...staticEdgeProps
    });
};
export { Edge };
