'use strict';

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

var React = require('react');
var ChevronDown = require('../../../../icons/ChevronDown.js');
var ChevronLeft = require('../../../../icons/ChevronLeft.js');
var ChevronRight = require('../../../../icons/ChevronRight.js');
var ChevronUp = require('../../../../icons/ChevronUp.js');
var index$1 = require('../../../../utils/index.js');
var styles = require('./styles.js');
var index = require('../../../IconButton/index.js');
var dateUtils = require('../../dateUtils.js');

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

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

const previousMonthButton = 'previousMonthIconButton';
function MonthAndYearSelectionHeader({ viewType, locale, currentMonth, currentYear, minDate, maxDate, updateViewType, handlePrevYear, handleNextYear, handlePrevMonth, handleNextMonth, 'data-testid': dataTestId, }) {
    const appendTestId = index$1.getId(dataTestId);
    const onYearSelect = () => {
        updateViewType(viewType === 'year' ? 'calendar' : 'year');
    };
    const onMonthSelect = () => {
        updateViewType(viewType === 'month' ? 'calendar' : 'month');
    };
    return (React__default['default'].createElement(styles.SingleDateWrapper, { "data-testid": appendTestId('single-date') },
        React__default['default'].createElement(styles.RangeButtonsWrapper, null,
            React__default['default'].createElement(styles.MonthSelector, { "data-testid": appendTestId('month-selector'), "aria-live": "polite", variant: "ghost", size: "xSmall", icon: viewType === 'month' ? React__default['default'].createElement(ChevronUp['default'], null) : React__default['default'].createElement(ChevronDown['default'], null), iconPosition: "trailing", onClick: onMonthSelect }, dateUtils.getMonthName(currentMonth, locale)),
            React__default['default'].createElement(styles.YearSelector, { "data-testid": appendTestId('year-selector'), "aria-live": "polite", variant: "ghost", size: "xSmall", icon: viewType === 'year' ? React__default['default'].createElement(ChevronUp['default'], null) : React__default['default'].createElement(ChevronDown['default'], null), iconPosition: "trailing", onClick: onYearSelect }, currentYear)),
        viewType === 'calendar' && (React__default['default'].createElement(styles.ButtonsWrapper, { "data-testid": appendTestId('calendar-navigation') },
            React__default['default'].createElement(index.IconButton, { className: previousMonthButton, icon: React__default['default'].createElement(ChevronLeft['default'], null), variant: "ghost-tertiary", size: "x-small", onClick: handlePrevMonth, "aria-label": "previous month", "data-testid": appendTestId('previous-month') }),
            React__default['default'].createElement(index.IconButton, { icon: React__default['default'].createElement(ChevronRight['default'], null), variant: "ghost-tertiary", size: "x-small", onClick: handleNextMonth, "aria-label": "next month", "data-testid": appendTestId('next-month') }))),
        viewType === 'year' && (React__default['default'].createElement(styles.ButtonsWrapper, { "data-testid": appendTestId('year-navigation') },
            React__default['default'].createElement(index.IconButton, { icon: React__default['default'].createElement(ChevronLeft['default'], null), variant: "ghost-tertiary", size: "x-small", onClick: handlePrevYear, "aria-label": "previous year", "data-testid": appendTestId('previous-year'), disabled: minDate && currentYear - 1 < minDate.getFullYear() }),
            React__default['default'].createElement(index.IconButton, { icon: React__default['default'].createElement(ChevronRight['default'], null), variant: "ghost-tertiary", size: "x-small", onClick: handleNextYear, "aria-label": "next year", "data-testid": appendTestId('next-year'), disabled: maxDate && currentYear + dateUtils.YEARS_TO_DISPLAY > maxDate.getFullYear() })))));
}

exports.MonthAndYearSelectionHeader = MonthAndYearSelectionHeader;
exports.previousMonthButton = previousMonthButton;
