"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.convertDatesWithRangeDatePickerFeatures = void 0;
const types_1 = require("../../../../types");
const index_util_1 = require("../../BaseDatePicker/hooks/index.util");
const convertDatesWithRangeDatePickerFeatures = ({ dates, disabledDates, selectedStartDate, selectedEndDate, colorType, handleClickDate, }) => {
    return dates.map((week) => week.map((d) => {
        if (d === types_1.EMPTY_DATE) {
            return {
                type: '빈값',
                date: types_1.EMPTY_DATE,
            };
        }
        else {
            const isToday = d.isToday();
            const isInRange = (0, index_util_1.checkIsInRange)({
                from: selectedStartDate,
                to: selectedEndDate,
                target: d,
            });
            const commonResult = {
                date: d,
                colorType,
                isToday,
                isInRange,
            };
            // check1) 비활성화 item
            for (let row = 0; row < disabledDates.length; row++) {
                const [startDisabledDate, endDisabledDate] = disabledDates[row];
                const isDisabled = (0, index_util_1.checkIsInRange)({
                    from: startDisabledDate || types_1.START_DATE,
                    to: endDisabledDate || types_1.END_DATE,
                    target: d,
                });
                if (isDisabled) {
                    return Object.assign(Object.assign({}, commonResult), { type: '비활성화' });
                }
            }
            // check2) 포커스 item
            if (selectedStartDate && d.toDateString() === selectedStartDate.toDateString()) {
                return Object.assign(Object.assign({}, commonResult), { isInRange: true, type: '포커스시작일' });
            }
            else if (selectedEndDate && d.toDateString() === selectedEndDate.toDateString()) {
                return Object.assign(Object.assign({}, commonResult), { isInRange: true, type: '포커스종료일' });
            }
            else {
                return Object.assign(Object.assign({}, commonResult), { type: '활성화', onClickDate: handleClickDate });
            }
        }
    }));
};
exports.convertDatesWithRangeDatePickerFeatures = convertDatesWithRangeDatePickerFeatures;
