{"version":3,"file":"PieChart.cjs","names":[],"sources":["../../src/charts/PieChart.tsx"],"sourcesContent":["import { Cell, Legend, Pie, PieChart as RPieChart, ResponsiveContainer, Tooltip } from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { PieChartProps } from \"./types\";\n\n/**\n * PieChart — themed wrapper over recharts `PieChart`.\n *\n * Renders one slice per row, reading the numeric value from `category` and the\n * label from `index`. Each slice is colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). When `donut` is set the pie gets a\n * non-zero inner radius. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function PieChart({\n    data,\n    category,\n    index,\n    colors,\n    height = 300,\n    width,\n    donut = false,\n    showLegend = true,\n    showTooltip = true,\n    valueFormatter,\n    className,\n}: PieChartProps) {\n    const palette = useChartColors(colors);\n    const chart = (\n        <RPieChart width={width} height={height}>\n            {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n            {showLegend ? <Legend /> : null}\n            <Pie\n                data={data}\n                dataKey={category}\n                nameKey={index}\n                innerRadius={donut ? \"60%\" : 0}\n                outerRadius=\"80%\"\n            >\n                {data.map((row, i) => (\n                    <Cell key={`${String(row[index])}-${i}`} fill={palette[i % palette.length]} />\n                ))}\n            </Pie>\n        </RPieChart>\n    );\n\n    return (\n        <div className={cn(className)}>\n            {width !== undefined ? (\n                chart\n            ) : (\n                <ResponsiveContainer width=\"100%\" height={height}>\n                    {chart}\n                </ResponsiveContainer>\n            )}\n        </div>\n    );\n}\n"],"mappings":"yJAeA,SAAgB,EAAS,CACrB,OACA,WACA,QACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,cAAc,GACd,iBACA,aACc,CACd,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,SAAD,CAAkB,QAAe,SAAjC,SAAA,CACK,GAAc,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAAS,UAAW,EAAA,mBAAmB,CAAc,CAAI,CAAA,EAAI,KAC3E,GAAa,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAS,CAAA,EAAI,MAC3B,EAAA,EAAA,IAAA,CAAC,EAAA,IAAD,CACU,OACN,QAAS,EACT,QAAS,EACT,YAAa,EAAQ,MAAQ,EAC7B,YAAY,MAEX,SAAA,EAAK,KAAK,EAAK,KACZ,EAAA,EAAA,IAAA,CAAC,EAAA,KAAD,CAAyC,KAAM,EAAQ,EAAI,EAAQ,OAAU,EAAlE,GAAG,OAAO,EAAI,EAAM,EAAE,GAAG,GAAyC,CAChF,CACA,CAAA,CACE,IAGf,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,CAAS,EACvB,SAAA,IAAU,IAAA,IAGP,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,MAAM,OAAe,SACrC,SAAA,CACgB,CAAA,EAJrB,CAMH,CAAA,CAEb"}