'use client';
import React, { memo } from 'react';
import {
BaseEdge,
getSmoothStepPath,
type EdgeProps,
} from '@xyflow/react';
import { useCanvasState } from '../../hooks/useCanvasState';
export const ConnectionEdge = memo(function ConnectionEdge({
id,
sourceX,
sourceY,
targetX,
targetY,
sourcePosition,
targetPosition,
source,
target,
style = {},
markerEnd,
}: EdgeProps) {
const selectedNodeId = useCanvasState((s) => s.selectedNodeId);
const isHighlighted = selectedNodeId === source || selectedNodeId === target;
const [edgePath] = getSmoothStepPath({
sourceX,
sourceY,
sourcePosition,
targetX,
targetY,
targetPosition,
borderRadius: 16,
});
return (
<>
{/* Glow layer for highlighted state */}
{isHighlighted && (
)}
{/* Main edge */}
{/* CSS animation for dash flow */}
>
);
});