import React__default from 'react';
import { getId } from '../../../../utils/index.js';
import { Chip } from '../../../Chip/Chip.js';
import { YEARS_TO_DISPLAY } from '../../dateUtils.js';
import { PeriodWrapper, PeriodName } from '../../styles.js';

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

export { Year };
