/**
 * DevExtreme (esm/__internal/scheduler/r1/utils/week.js)
 * Version: 23.2.6 (build 24140-0112)
 * Build date: Sun May 19 2024
 *
 * Copyright (c) 2012 - 2024 Developer Express Inc. ALL RIGHTS RESERVED
 * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
 */
import dateUtils from "../../../../core/utils/date";
import dateLocalization from "../../../../localization/date";
import {
    getCalculatedFirstDayOfWeek,
    getValidCellDateForLocalTimeFormat,
    getViewStartByOptions,
    setOptionHour
} from "./base";
export var getTimePanelCellText = (rowIndex, date, startViewDate, cellDuration, startDayHour, viewOffset) => {
    if (rowIndex % 2 !== 0) {
        return ""
    }
    var validTimeDate = getValidCellDateForLocalTimeFormat(date, {
        startViewDate: startViewDate,
        startDayHour: startDayHour,
        cellIndexShift: Math.round(cellDuration) * rowIndex,
        viewOffset: viewOffset
    });
    return dateLocalization.format(validTimeDate, "shorttime")
};
export var getIntervalDuration = intervalCount => 7 * dateUtils.dateToMilliseconds("day") * intervalCount;
export var getValidStartDate = (startDate, firstDayOfWeek) => startDate ? dateUtils.getFirstWeekDate(startDate, firstDayOfWeek) : void 0;
export var calculateStartViewDate = (currentDate, startDayHour, startDate, intervalDuration, firstDayOfWeekOption) => {
    var firstDayOfWeek = getCalculatedFirstDayOfWeek(firstDayOfWeekOption);
    var viewStart = getViewStartByOptions(startDate, currentDate, intervalDuration, getValidStartDate(startDate, firstDayOfWeek));
    var firstViewDate = dateUtils.getFirstWeekDate(viewStart, firstDayOfWeek);
    return setOptionHour(firstViewDate, startDayHour)
};
export var calculateViewStartDate = (startDateOption, firstDayOfWeek) => {
    var validFirstDayOfWeek = null !== firstDayOfWeek && void 0 !== firstDayOfWeek ? firstDayOfWeek : dateLocalization.firstDayOfWeekIndex();
    return dateUtils.getFirstWeekDate(startDateOption, validFirstDayOfWeek)
};
