/**
 * DevExtreme (esm/renovation/ui/scheduler/appointment/utils/getAppointmentTakesAllDay.js)
 * Version: 22.1.3 (build 22180-0310)
 * Build date: Wed Jun 29 2022
 *
 * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import {
    isDefined
} from "../../../../../core/utils/type";
import dateUtils from "../../../../../core/utils/date";
var getAppointmentDurationInHours = (startDate, endDate) => (endDate.getTime() - startDate.getTime()) / dateUtils.dateToMilliseconds("hour");
var appointmentHasShortDayDuration = (startDate, endDate, viewStartDayHour, viewEndDayHour) => {
    var appointmentDurationInHours = getAppointmentDurationInHours(startDate, endDate);
    var viewDurationInHours = viewEndDayHour - viewStartDayHour;
    var startDateHours = startDate.getHours();
    var endDateHours = endDate.getHours();
    return appointmentDurationInHours >= viewDurationInHours && startDateHours === viewStartDayHour && endDateHours === viewEndDayHour
};
export var getAppointmentTakesAllDay = (appointmentAdapter, viewStartDayHour, viewEndDayHour, allDayPanelMode) => {
    var hasAllDay = () => appointmentAdapter.allDay;
    switch (allDayPanelMode) {
        case "hidden":
            return false;
        case "allDay":
            return hasAllDay();
        case "all":
        default:
            if (hasAllDay()) {
                return true
            }
            var {
                endDate: endDate, startDate: startDate
            } = appointmentAdapter;
            if (!isDefined(endDate)) {
                return false
            }
            var appointmentDurationInHours = getAppointmentDurationInHours(startDate, endDate);
            return appointmentDurationInHours >= 24 || appointmentHasShortDayDuration(startDate, endDate, viewStartDayHour, viewEndDayHour)
    }
};
