{"version":3,"file":"BarChart.cjs","names":[],"sources":["../../src/charts/BarChart.tsx"],"sourcesContent":["import {\n    Bar,\n    BarChart as RBarChart,\n    CartesianGrid,\n    Legend,\n    ResponsiveContainer,\n    Tooltip,\n    XAxis,\n    YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * BarChart — themed wrapper over recharts `BarChart`.\n *\n * Plots one bar series per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * bars share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function BarChart({\n    data,\n    index,\n    categories,\n    colors,\n    height = 300,\n    width,\n    stack = false,\n    showLegend = true,\n    showGrid = true,\n    showTooltip = true,\n    valueFormatter,\n    className,\n}: CartesianChartProps) {\n    const palette = useChartColors(colors);\n    const stackId = stack ? \"stack\" : undefined;\n\n    const chart = (\n        <RBarChart data={data} width={width} height={height}>\n            {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n            <XAxis dataKey={index} />\n            <YAxis tickFormatter={valueFormatter} />\n            {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n            {showLegend ? <Legend /> : null}\n            {categories.map((category, i) => (\n                <Bar\n                    key={category}\n                    dataKey={category}\n                    stackId={stackId}\n                    fill={palette[i % palette.length]}\n                />\n            ))}\n        </RBarChart>\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":"yJAuBA,SAAgB,EAAS,CACrB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,WAAW,GACX,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,EAAU,EAAQ,QAAU,IAAA,GAE5B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,SAAD,CAAiB,OAAa,QAAe,SAA7C,SAAA,CACK,GAAW,EAAA,EAAA,IAAA,CAAC,EAAA,cAAD,CAAe,gBAAgB,KAAO,CAAA,EAAI,MACtD,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,QAAS,CAAQ,CAAA,GACxB,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,cAAe,CAAiB,CAAA,EACtC,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,KAC1B,EAAW,KAAK,EAAU,KACvB,EAAA,EAAA,IAAA,CAAC,EAAA,IAAD,CAEI,QAAS,EACA,UACT,KAAM,EAAQ,EAAI,EAAQ,OAC7B,EAJQ,CAIR,CACJ,CACM,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"}