/**
 * DevExtreme (cjs/__internal/scheduler/workspaces/view_model/m_view_data_generator_month.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/
 */
"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.ViewDataGeneratorMonth = void 0;
var _date = _interopRequireDefault(require("../../../../core/utils/date"));
var _date2 = _interopRequireDefault(require("../../../../localization/date"));
var _index = require("../../../scheduler/r1/utils/index");
var _m_utils_time_zone = _interopRequireDefault(require("../../m_utils_time_zone"));
var _m_utils = require("./m_utils");
var _m_view_data_generator = require("./m_view_data_generator");

function _interopRequireDefault(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    }
}

function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass)
}

function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
        o.__proto__ = p;
        return o
    };
    return _setPrototypeOf(o, p)
}
const toMs = _date.default.dateToMilliseconds;
const DAYS_IN_WEEK = 7;
let ViewDataGeneratorMonth = function(_ViewDataGenerator) {
    _inheritsLoose(ViewDataGeneratorMonth, _ViewDataGenerator);

    function ViewDataGeneratorMonth() {
        var _this;
        _this = _ViewDataGenerator.apply(this, arguments) || this;
        _this.tableAllDay = void 0;
        return _this
    }
    var _proto = ViewDataGeneratorMonth.prototype;
    _proto.getCellData = function(rowIndex, columnIndex, options, allDay) {
        const {
            indicatorTime: indicatorTime,
            timeZoneCalculator: timeZoneCalculator,
            intervalCount: intervalCount,
            viewOffset: viewOffset
        } = options;
        const data = _ViewDataGenerator.prototype.getCellData.call(this, rowIndex, columnIndex, options, false);
        const startDate = _m_utils_time_zone.default.addOffsetsWithoutDST(data.startDate, -viewOffset);
        data.today = this.isCurrentDate(startDate, indicatorTime, timeZoneCalculator);
        data.otherMonth = this.isOtherMonth(startDate, this._minVisibleDate, this._maxVisibleDate);
        data.firstDayOfMonth = (0, _index.isFirstCellInMonthWithIntervalCount)(startDate, intervalCount);
        data.text = _index.monthUtils.getCellText(startDate, intervalCount);
        return data
    };
    _proto.isCurrentDate = function(date, indicatorTime, timeZoneCalculator) {
        return _date.default.sameDate(date, (0, _index.getToday)(indicatorTime, timeZoneCalculator))
    };
    _proto.isOtherMonth = function(cellDate, minDate, maxDate) {
        return !_date.default.dateInRange(cellDate, minDate, maxDate, "date")
    };
    _proto._calculateCellIndex = function(rowIndex, columnIndex, rowCount, columnCount) {
        return _index.monthUtils.calculateCellIndex(rowIndex, columnIndex, rowCount, columnCount)
    };
    _proto.calculateEndDate = function(startDate, interval, endDayHour) {
        return (0, _index.setOptionHour)(startDate, endDayHour)
    };
    _proto.getInterval = function() {
        return toMs("day")
    };
    _proto._calculateStartViewDate = function(options) {
        return _index.monthUtils.calculateStartViewDate(options.currentDate, options.startDayHour, options.startDate, options.intervalCount, this.getFirstDayOfWeek(options.firstDayOfWeek))
    };
    _proto._setVisibilityDates = function(options) {
        const {
            intervalCount: intervalCount,
            startDate: startDate,
            currentDate: currentDate
        } = options;
        const firstMonthDate = _date.default.getFirstMonthDate(startDate);
        const viewStart = _index.monthUtils.getViewStartByOptions(startDate, currentDate, intervalCount, firstMonthDate);
        this._minVisibleDate = new Date(viewStart.setDate(1));
        const nextMonthDate = new Date(viewStart.setMonth(viewStart.getMonth() + intervalCount));
        this._maxVisibleDate = new Date(nextMonthDate.setDate(0))
    };
    _proto.getCellCount = function() {
        return 7
    };
    _proto.getRowCount = function(options) {
        var _a;
        const startDate = new Date(options.currentDate);
        startDate.setDate(1);
        const endDate = new Date(startDate);
        endDate.setMonth(endDate.getMonth() + options.intervalCount);
        endDate.setDate(0);
        return (0, _m_utils.calculateAlignedWeeksBetweenDates)(startDate, endDate, null !== (_a = options.firstDayOfWeek) && void 0 !== _a ? _a : _date2.default.firstDayOfWeekIndex())
    };
    _proto.getCellCountInDay = function() {
        return 1
    };
    _proto.setHiddenInterval = function() {
        this.hiddenInterval = 0
    };
    _proto.getCellEndDate = function(cellStartDate, options) {
        const {
            startDayHour: startDayHour,
            endDayHour: endDayHour
        } = options;
        const durationMs = (endDayHour - startDayHour) * toMs("hour");
        return _m_utils_time_zone.default.addOffsetsWithoutDST(cellStartDate, durationMs)
    };
    return ViewDataGeneratorMonth
}(_m_view_data_generator.ViewDataGenerator);
exports.ViewDataGeneratorMonth = ViewDataGeneratorMonth;
