'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
var index = require('../../../../utils/index.js');
var Chip = require('../../../Chip/Chip.js');
var dateUtils = require('../../dateUtils.js');
var styles = require('../../styles.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var React__default = /*#__PURE__*/_interopDefaultLegacy(React);

function Year({ width, height, currentYear, minimumYear, maximumYear, 'data-testid': dataTestId, updateCurrentYear, }) {
    const appendTestId = index.getId(dataTestId);
    const onYearSelect = (year) => {
        updateCurrentYear(year);
    };
    const isYearInRange = (year) => {
        return (year >= (minimumYear || Number.MIN_VALUE) &&
            year <= (maximumYear || Number.MAX_VALUE));
    };
    return (React__default['default'].createElement(styles.PeriodWrapper, { style: { width, height }, "data-testid": dataTestId }, [...Array(dateUtils.YEARS_TO_DISPLAY)].map((_, index) => (React__default['default'].createElement(styles.PeriodName, { key: index },
        React__default['default'].createElement(Chip.Chip, { selected: index === 0, onClick: () => onYearSelect(index + currentYear), label: `${index + currentYear}`, disabled: !isYearInRange(index + currentYear), variant: 'ghost', "data-testid": appendTestId(`chip-${index}`) }))))));
}

exports.Year = Year;
