"use client"; import { motion } from "motion/react"; import { ChartFrame } from "@/components/charts/chart-frame"; import { catColor } from "@/lib/chart-utils"; export type VennSet = { label: string }; type VennDiagramProps = { /** 2 or 3 sets. */ sets: VennSet[]; /** Optional label for the central intersection. */ intersection?: string; size?: number; className?: string; }; /** VennDiagram — 2–3 overlapping circles that scale in; multiply blend builds the intersections; labels fade. */ export function VennDiagram({ sets, intersection, size = 420, className }: VennDiagramProps) { const n = Math.min(sets.length, 3); const cx = size / 2; const cy = size / 2; const r = size * 0.26; const layout = n === 2 ? [ { x: cx - r * 0.6, y: cy, lx: cx - r * 1.15, ly: cy }, { x: cx + r * 0.6, y: cy, lx: cx + r * 1.15, ly: cy }, ] : [ { x: cx, y: cy - r * 0.62, lx: cx, ly: cy - r * 1.5 }, { x: cx - r * 0.62, y: cy + r * 0.42, lx: cx - r * 1.35, ly: cy + r * 1.1 }, { x: cx + r * 0.62, y: cy + r * 0.42, lx: cx + r * 1.35, ly: cy + r * 1.1 }, ]; return ( {({ inView, reduce }) => ( <> {layout.slice(0, n).map((c, i) => ( ))} {layout.slice(0, n).map((c, i) => ( {sets[i].label} ))} {intersection && ( {intersection} )} )} ); }