'use client';
'use strict';

var index = require('../external/classnames/index.js');
var React = require('react');
var chartComponents_module = require('./chart-components.module.css.js');

/* Default palette is Blue */
var DEFAULT_COLORS = ["3b82f6", "bfdbfe", "2563eb", "93c5fd", "1d4ed8", "60a5fa"];
function createColorMap(_a) {
    var categories = _a.categories, colors = _a.colors;
    var colorMap = new Map();
    for (var i = 0; i < categories.length; i++) {
        colorMap.set(categories[i], colors[i % colors.length]);
    }
    return colorMap;
}
function ChartLegend(_a) {
    var _b;
    var colorMap = _a.colorMap, dark = _a.dark, payload = _a.payload;
    return (React.createElement("div", { className: index(chartComponents_module.legend, (_b = {}, _b[chartComponents_module.dark] = dark, _b)) }, payload.map(function (_a, index) {
        var value = _a.value;
        return (React.createElement("div", { className: chartComponents_module.row, key: index },
            React.createElement("span", { className: chartComponents_module.dot, style: { backgroundColor: colorMap.get(String(value)) } }),
            React.createElement("span", { className: chartComponents_module.name }, value)));
    })));
}
function ChartTooltip(_a) {
    var _b;
    var active = _a.active, colorMap = _a.colorMap, dark = _a.dark, payload = _a.payload, label = _a.label;
    if (active && payload && payload.length) {
        return (React.createElement("div", { className: index(chartComponents_module.tooltip, (_b = {}, _b[chartComponents_module.dark] = dark, _b)) },
            label ? React.createElement("div", null, label) : null,
            payload.map(function (_a, index) {
                var name = _a.name, value = _a.value;
                return (React.createElement("div", { className: chartComponents_module.row, key: index },
                    React.createElement("span", { className: chartComponents_module.dot, style: { backgroundColor: colorMap.get(String(name)) } }),
                    React.createElement("span", { className: chartComponents_module.name }, name !== null && name !== void 0 ? name : ""),
                    React.createElement("span", { className: chartComponents_module.value }, value)));
            })));
    }
    return null;
}

exports.ChartLegend = ChartLegend;
exports.ChartTooltip = ChartTooltip;
exports.DEFAULT_COLORS = DEFAULT_COLORS;
exports.createColorMap = createColorMap;
//# sourceMappingURL=chart-components.js.map
