"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "normalizeDates", {
    enumerable: true,
    get: function() {
        return normalizeDates;
    }
});
var _datejs = require("../../../utils/datejs");
var normalizeDates = function normalizeDates(param) {
    var originalDate = param.originalDate, lang = param.lang, format = param.format, includeEdgeDates = param.includeEdgeDates, min = param.min, max = param.max;
    var 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();
    }
    var formattedDateCandidate = format ? (0, _datejs.customDayjs)(dateCandidate).format(format) : dateCandidate.toString();
    return {
        normalizedDate: dateCandidate,
        formattedNormalizedDate: formattedDateCandidate
    };
};
