"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "normalizeDates", {
    enumerable: true,
    get: function() {
        return normalizeDates;
    }
});
const _datejs = require("../../../utils/datejs");
const normalizeDates = ({ originalDate, lang, format, includeEdgeDates, min, max })=>{
    let dateCandidate = originalDate;
    _datejs.customDayjs.locale(lang);
    if (min && includeEdgeDates && min > originalDate) {
        dateCandidate = min;
    } else if (min && !includeEdgeDates && min >= originalDate) {
        dateCandidate = (0, _datejs.customDayjs)(min).add(1, 'd').toDate();
    } else if (max && includeEdgeDates && max < originalDate) {
        dateCandidate = max;
    } else if (max && !includeEdgeDates && max <= originalDate) {
        dateCandidate = (0, _datejs.customDayjs)(max).subtract(1, 'd').toDate();
    }
    const formattedDateCandidate = format ? (0, _datejs.customDayjs)(dateCandidate).format(format) : dateCandidate.toString();
    return {
        normalizedDate: dateCandidate,
        formattedNormalizedDate: formattedDateCandidate
    };
};
