import { useMemo } from 'react' import type { Categoria } from '../../../types' interface RuletaSVGProps { categorias: Categoria[] rotacion: number isSpinning: boolean onClick: () => void } /* ─── Constantes geométricas ──────────────────── */ const CX = 250 const CY = 265 const SEGMENT_R = 195 const RING_R = 207 const RING_STROKE = 26 const CENTER_R = 28 const VIEWBOX_W = 500 const VIEWBOX_H = 550 const TOTAL_SEGMENTS = 4 /* ─── Estilos visuales por segmento ───────────── */ interface SegmentStyle { bg: string textColor: string iconColor: string } const SEGMENT_STYLES: SegmentStyle[] = [ { bg: '#DC2626', textColor: '#FFFFFF', iconColor: '#FFFFFF' }, // Agua — rojo { bg: '#D1D5DB', textColor: '#1F2937', iconColor: '#374151' }, // Residuos — gris claro { bg: '#374151', textColor: '#FFFFFF', iconColor: '#FBBF24' }, // Energía — gris oscuro { bg: '#F9FAFB', textColor: '#1F2937', iconColor: '#2563EB' }, // Electromovilidad — blanco ] /* ─── Utilidad: polar → cartesiano ────────────── */ function polarToCartesian(cx: number, cy: number, angle: number, radius: number) { const rad = (angle - 90) * (Math.PI / 180) return { x: cx + radius * Math.cos(rad), y: cy + radius * Math.sin(rad), } } /* ─── Path de sector circular ─────────────────── */ function sectorPath(cx: number, cy: number, r: number, startAngle: number, endAngle: number) { const start = polarToCartesian(cx, cy, startAngle, r) const end = polarToCartesian(cx, cy, endAngle, r) const largeArc = endAngle - startAngle > 180 ? 1 : 0 return `M ${cx} ${cy} L ${start.x} ${start.y} A ${r} ${r} 0 ${largeArc} 1 ${end.x} ${end.y} Z` } /* ═══════════════════════════════════════════════ COMPONENTE PRINCIPAL ═══════════════════════════════════════════════ */ export default function RuletaSVG({ categorias, rotacion, isSpinning, onClick }: RuletaSVGProps) { const angleStep = 360 / TOTAL_SEGMENTS /* Puntos decorativos del anillo exterior */ const decorElements = useMemo(() => { const dots: { x: number; y: number; isStar: boolean }[] = [] for (let i = 0; i < 24; i++) { const angle = (i * 15) const pos = polarToCartesian(CX, CY, angle, RING_R) dots.push({ x: pos.x, y: pos.y, isStar: i % 3 === 0 }) } return dots }, []) return (