'use client';
'use strict';

var _tslib = require('../_virtual/_tslib.js');
var index = require('../external/classnames/index.js');
var React = require('react');
var reactVirtualizedAutoSizer_esm = require('../external/react-virtualized-auto-sizer/dist/react-virtualized-auto-sizer.esm.js');
var barChart_module = require('./bar-chart.module.css.js');
var chartComponents = require('./chart-components.js');
var Bar = require('../external/recharts/es6/cartesian/Bar.js');
var BarChart$1 = require('../external/recharts/es6/chart/BarChart.js');
var CartesianGrid = require('../external/recharts/es6/cartesian/CartesianGrid.js');
var XAxis = require('../external/recharts/es6/cartesian/XAxis.js');
var YAxis = require('../external/recharts/es6/cartesian/YAxis.js');
var Tooltip = require('../external/recharts/es6/component/Tooltip.js');
var Legend = require('../external/recharts/es6/component/Legend.js');

var BarChart = React.forwardRef(function BarChart(_a, ref) {
    var className = _a.className, categories = _a.categories, _b = _a.colors, colors = _b === void 0 ? chartComponents.DEFAULT_COLORS : _b, dark = _a.dark, data = _a.data, index$1 = _a.index, stacked = _a.stacked, otherProps = _tslib.__rest(_a, ["className", "categories", "colors", "dark", "data", "index", "stacked"]);
    var colorMap = chartComponents.createColorMap({ categories: categories, colors: colors });
    var bars = categories.map(function (category, index) {
        var color = colors[index % colors.length];
        return (React.createElement(Bar.Bar, { key: index, dataKey: category, fill: color, stackId: stacked ? "a" : undefined, isAnimationActive: false }));
    });
    return (React.createElement("div", _tslib.__assign({ className: index(className, barChart_module.root), ref: ref }, otherProps, { style: _tslib.__assign(_tslib.__assign({}, otherProps.style), { minHeight: 200, minWidth: 300 }) }),
        React.createElement(reactVirtualizedAutoSizer_esm, null, function (_a) {
            var _b;
            var height = _a.height, width = _a.width;
            return (React.createElement(BarChart$1.BarChart, { className: index((_b = {}, _b[barChart_module.dark] = dark, _b)), data: data, height: height, width: width },
                React.createElement(CartesianGrid.CartesianGrid, { className: barChart_module.grid, horizontal: true, vertical: false, strokeWidth: 1 }),
                React.createElement(XAxis.XAxis, { axisLine: false, tickLine: false, padding: { left: 20, right: 20 }, dataKey: index$1 }),
                React.createElement(YAxis.YAxis, { axisLine: false, tickLine: false, width: 30 }),
                React.createElement(Tooltip.Tooltip, { content: function (_a) {
                        var active = _a.active, payload = _a.payload, label = _a.label;
                        return (React.createElement(chartComponents.ChartTooltip, { active: active, colorMap: colorMap, dark: dark, label: label, payload: payload }));
                    }, cursor: { fill: "#D1D5DB", opacity: "0.15" }, isAnimationActive: false }),
                React.createElement(Legend.Legend, { content: function (_a) {
                        var payload = _a.payload;
                        return React.createElement(chartComponents.ChartLegend, { colorMap: colorMap, dark: dark, payload: payload });
                    }, verticalAlign: "bottom" }),
                bars));
        })));
});

exports.BarChart = BarChart;
//# sourceMappingURL=bar-chart.js.map
