import { __assign } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { useContext, useMemo } from 'react';
import PanelCell from '../../components/PanelCell';
import PanelContext from '../../context/PanelContext';
import PickerContext from '../../context/PickerContext';
import getPanelCellsData from '../../utils/getPanelCellsData';
import { dateConfig } from '../../utils/dateUtils';
import { setYear } from 'date-fns';
import { MAX_YEAR } from '../../constants';
var COL_COUNT = 3;
var ROW_COUNT = 4;
var YearPickerBody = function (_a) {
    var firstYear = _a.firstYear, onSelected = _a.onSelected, selected = _a.selected, defaultPanelDate = _a.defaultPanelDate, disabledPanelDate = _a.disabledPanelDate, _b = _a.row, row = _b === void 0 ? ROW_COUNT : _b, _c = _a.col, col = _c === void 0 ? COL_COUNT : _c;
    var i18n = useContext(PickerContext).i18n;
    var onHover = useContext(PanelContext).onHover;
    var YearTexts = useMemo(function () {
        return Array.from({ length: 12 }, function (_, i) {
            return firstYear + i <= MAX_YEAR ? "" + (firstYear + i) + i18n.panel.year : '';
        });
    }, [firstYear, i18n]);
    var cells = useMemo(function () {
        return getPanelCellsData({
            selected: selected,
            disabledPanelDate: disabledPanelDate,
            defaultPanelDate: setYear(defaultPanelDate, firstYear),
            texts: YearTexts,
            row: row,
            col: col,
            dateConfig: dateConfig.year,
        });
    }, [
        selected,
        row,
        col,
        YearTexts,
        defaultPanelDate,
        firstYear,
        disabledPanelDate,
    ]);
    return (_jsx("div", __assign({ className: "zent-datepicker-ym-panel-body", "data-zv": 'v10.0.11' }, { children: _jsx(PanelCell, { col: col, cells: cells, onSelected: onSelected, onHover: onHover }, void 0) }), void 0));
};
export default YearPickerBody;
