import React, { useMemo } from 'react'; import { motion } from 'framer-motion'; const buildPath = (points, width, height) => { if (!points.length) { return ''; } const prices = points.map((point) => point.price); const min = Math.min(...prices); const max = Math.max(...prices); const range = max - min || 1; return points .map((point, index) => { const x = (index / Math.max(points.length - 1, 1)) * width; const y = height - ((point.price - min) / range) * height; return `${index === 0 ? 'M' : 'L'} ${x.toFixed(2)} ${y.toFixed(2)}`; }) .join(' '); }; export const MarketPanel = ({ chart, history, trade, engine, lastPriceDelta }) => { const path = useMemo(() => buildPath(history || [], 250, 90), [history]); const priceTone = lastPriceDelta < 0 ? '#d95d5d' : '#52b788'; return (