'use client' import { getSmoothStepPath, EdgeLabelRenderer, BaseEdge, type EdgeProps, } from '@xyflow/react' import type { StreamEdgeData } from '@/lib/types' const STATUS_COLORS: Record = { planned: { stroke: '#22c55e', bg: 'rgba(34,197,94,0.12)', text: '#16a34a', label: 'Planned' }, active: { stroke: '#3b82f6', bg: 'rgba(59,130,246,0.12)', text: '#2563eb', label: 'Active' }, paused: { stroke: '#f97316', bg: 'rgba(249,115,22,0.12)', text: '#ea580c', label: 'Paused' }, } export default function StreamEdge({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, data, markerEnd, }: EdgeProps) { const edgeData = data as StreamEdgeData | undefined const status = edgeData?.status ?? 'planned' const flowRate = edgeData?.flowRate ?? 0 const tokenSymbol = edgeData?.tokenSymbol ?? 'DAIx' const colors = STATUS_COLORS[status] || STATUS_COLORS.planned const [edgePath, labelX, labelY] = getSmoothStepPath({ sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, }) // Animated dashed line to simulate flowing tokens const isPaused = status === 'paused' return ( <> {/* Background glow path */} {/* Main path with animated dash */} {/* Inject animation keyframes */}
{/* Flow rate label */} {flowRate.toLocaleString()} {tokenSymbol}/mo {/* Status pill */} {colors.label}
) }