'use client' import { memo } from 'react' import { BaseEdge, EdgeProps, getBezierPath } from '@xyflow/react' export interface AnimatedFlowEdgeData { flowRate: number isActive: boolean color?: string } function AnimatedFlowEdge({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, style = {}, }: EdgeProps) { const { flowRate = 0, isActive = false, color = '#3B82F6' } = (data || {}) as AnimatedFlowEdgeData const [edgePath] = getBezierPath({ sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, }) // Calculate animation speed based on flow rate const animationDuration = Math.max(2 - (flowRate / 100), 0.5) return ( <> {/* Background path */} {/* Animated dashed overlay when active */} {isActive && ( )} {/* Flow particles */} {isActive && ( <> )} {/* Flow rate label */} {isActive && flowRate > 0 && ( ${flowRate}/hr )} ) } export default memo(AnimatedFlowEdge)