var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React from 'react';
import { CartesianGrid, Line, LineChart as LineChartWidget, Tooltip, XAxis, YAxis } from 'recharts';
import { getLineChartSettings } from './helpers';
import { ChartTooltip } from '../ChartTooltip';
import { useClickableChartStyle } from '../hooks/useClickableChartStyle';
import { useDynamicYAxisWidth } from '../hooks/useDynamicYAxisWidth';
export var LineChart = function (_a) {
    var width = _a.width, height = _a.height, data = _a.data, _b = _a.options, options = _b === void 0 ? {} : _b, onItemClick = _a.onItemClick;
    var _c = getLineChartSettings(options), cartesianGrid = _c.cartesianGrid, tooltip = _c.tooltip, xAxis = _c.xAxis, yAxis = _c.yAxis, lineChart = _c.lineChart, line = _c.line;
    var _d = useDynamicYAxisWidth({ chartYAxisProps: yAxis }), chartRef = _d.chartRef, dynamicYAxisWidth = __rest(_d, ["chartRef"]);
    var clickable = useClickableChartStyle(onItemClick);
    return (React.createElement(LineChartWidget, __assign({ width: width, height: height, data: data }, lineChart, { ref: chartRef }),
        React.createElement(CartesianGrid, __assign({}, cartesianGrid)),
        React.createElement(XAxis, __assign({}, xAxis)),
        React.createElement(YAxis, __assign({}, yAxis, dynamicYAxisWidth)),
        React.createElement(Tooltip, __assign({ content: React.createElement(ChartTooltip, null) }, tooltip)),
        React.createElement(Line, __assign({}, line, { activeDot: __assign(__assign({}, line.activeDot), { className: clickable, onClick: function (_, event) { return onItemClick(event.payload.group); } }) }))));
};
