import React, { useMemo } from 'react';
import { View, StyleSheet, Pressable, Text } from 'react-native';
import { useCalendarContext } from '../calendar-context';
import { getParsedDate, getMonthsArray, cn, isMonthDisabled } from '../utils';
import { CONTAINER_HEIGHT } from '../enums';
const Months = () => {
  var _getMonthsArray;
  const {
    currentDate,
    onSelectMonth,
    styles = {},
    classNames = {},
    components = {},
    containerHeight = CONTAINER_HEIGHT,
    monthsFormat = 'full',
    minDate,
    maxDate
  } = useCalendarContext();
  const style = useMemo(() => createDefaultStyles(containerHeight), [containerHeight]);
  const {
    month
  } = getParsedDate(currentDate);
  const containerStyle = StyleSheet.flatten([defaultStyles.container, styles === null || styles === void 0 ? void 0 : styles.months]);
  return /*#__PURE__*/React.createElement(View, {
    style: containerStyle,
    testID: "month-selector"
  }, /*#__PURE__*/React.createElement(View, {
    style: defaultStyles.months
  }, (_getMonthsArray = getMonthsArray()) === null || _getMonthsArray === void 0 ? void 0 : _getMonthsArray.map((item, index) => {
    const isSelected = index === month;
    const isDisabled = isMonthDisabled(index, currentDate, {
      minDate,
      maxDate
    });
    const itemStyle = StyleSheet.flatten([defaultStyles.month, styles.month, isSelected && styles.selected_month, isDisabled && styles.disabled]);
    const textStyle = StyleSheet.flatten([styles.month_label, isSelected && styles.selected_month_label, isDisabled && styles.disabled_label]);
    const containerClassName = cn(classNames.month, isSelected && classNames.selected_month, isDisabled && classNames.disabled);
    const textClassName = cn(classNames.month_label, isSelected && classNames.selected_month_label, isDisabled && classNames.disabled_label);
    return /*#__PURE__*/React.createElement(View, {
      key: index,
      style: style.monthCell
    }, components.Month ? /*#__PURE__*/React.createElement(Pressable, {
      disabled: isDisabled,
      onPress: () => onSelectMonth(index),
      accessibilityRole: "button",
      accessibilityLabel: item.name.full,
      style: defaultStyles.month
    }, components.Month({
      ...item,
      isSelected
    })) : /*#__PURE__*/React.createElement(Pressable, {
      disabled: isDisabled,
      onPress: () => onSelectMonth(index),
      accessibilityRole: "button",
      accessibilityLabel: item.name.full,
      style: itemStyle,
      className: containerClassName
    }, /*#__PURE__*/React.createElement(Text, {
      key: index,
      style: textStyle,
      className: textClassName
    }, item.name[monthsFormat])));
  })));
};
const defaultStyles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center'
  },
  months: {
    flexDirection: 'row',
    flexWrap: 'wrap'
  },
  month: {
    flex: 1,
    margin: 2,
    alignItems: 'center',
    justifyContent: 'center'
  }
});
const createDefaultStyles = containerHeight => StyleSheet.create({
  monthCell: {
    width: `${100 / 3}%`,
    height: containerHeight / 6
  }
});
export default Months;
//# sourceMappingURL=months.js.map