"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "getFormattedDateTime", {
    enumerable: true,
    get: function() {
        return getFormattedDateTime;
    }
});
const _dateHelper = require("../../DatePicker/utils/dateHelper");
const _getOriginalDateTime = require("./getOriginalDateTime");
const _normalizeDateTime = require("./normalizeDateTime");
const getFormattedDateTime = ({ value, lang, format, dateFormat, timeFormat, includeEdgeDates, min, max })=>{
    const withFullMonth = (0, _dateHelper.needFullMonth)(format || '');
    const { formattedDate, isoDate, originalDate, timeValue, dateValue } = (0, _getOriginalDateTime.getOriginalDateTime)({
        value,
        lang,
        fullFormat: format,
        dateFormat,
        timeFormat,
        needFullMonth: withFullMonth
    });
    if (!originalDate) {
        const innerValue = format && ((0, _dateHelper.needFullMonth)(format) ? formattedDate : formattedDate.slice(0, format.length));
        const result = {
            formattedDate: innerValue || '',
            isoDate,
            originalDate,
            timeValue,
            dateValue
        };
        if (dateValue && !timeValue) {
            const { normalizedDate, formattedNormalizedDate } = (0, _normalizeDateTime.normalizeDateTime)({
                originalDate: dateValue,
                lang,
                format: dateFormat,
                includeEdgeDates,
                min,
                max
            });
            const parsedNormalizedDate = formattedNormalizedDate + innerValue?.slice(formattedNormalizedDate.length);
            return {
                ...result,
                formattedDate: parsedNormalizedDate,
                dateValue: normalizedDate
            };
        }
        return result;
    }
    const { normalizedDate, formattedNormalizedDate } = (0, _normalizeDateTime.normalizeDateTime)({
        originalDate,
        lang,
        format,
        includeEdgeDates,
        min,
        max
    });
    return {
        formattedDate: formattedNormalizedDate,
        isoDate: normalizedDate.toISOString(),
        originalDate: normalizedDate,
        timeValue: normalizedDate,
        dateValue: normalizedDate
    };
};
