/**
 * DevExtreme (cjs/ui/calendar/ui.calendar.multiple.selection.strategy.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";
exports.default = void 0;
var _uiCalendarSelection = _interopRequireDefault(require("./ui.calendar.selection.strategy"));

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)
}
let CalendarMultiSelectionStrategy = function(_CalendarSelectionStr) {
    _inheritsLoose(CalendarMultiSelectionStrategy, _CalendarSelectionStr);

    function CalendarMultiSelectionStrategy(component) {
        var _this;
        _this = _CalendarSelectionStr.call(this, component) || this;
        _this.NAME = "MultiSelection";
        return _this
    }
    var _proto = CalendarMultiSelectionStrategy.prototype;
    _proto.getViewOptions = function() {
        return {
            value: this.dateOption("value"),
            range: [],
            selectionMode: "multi",
            onWeekNumberClick: this._shouldHandleWeekNumberClick() ? this._weekNumberClickHandler.bind(this) : null
        }
    };
    _proto.selectValue = function(selectedValue, e) {
        const value = [...this.dateOption("value")];
        const alreadySelectedIndex = value.findIndex(date => (null === date || void 0 === date ? void 0 : date.toDateString()) === selectedValue.toDateString());
        if (alreadySelectedIndex > -1) {
            value.splice(alreadySelectedIndex, 1)
        } else {
            value.push(selectedValue)
        }
        this.skipNavigate();
        this._updateCurrentDate(selectedValue);
        this._currentDateChanged = true;
        this.dateValue(value, e)
    };
    _proto.updateAriaSelected = function(value, previousValue) {
        var _value, _previousValue;
        null !== (_value = value) && void 0 !== _value ? _value : value = this.dateOption("value");
        null !== (_previousValue = previousValue) && void 0 !== _previousValue ? _previousValue : previousValue = [];
        _CalendarSelectionStr.prototype.updateAriaSelected.call(this, value, previousValue)
    };
    _proto.getDefaultCurrentDate = function() {
        const dates = this.dateOption("value").filter(value => value);
        return this._getLowestDateInArray(dates)
    };
    _proto.restoreValue = function() {
        this.calendar.option("value", [])
    };
    _proto._weekNumberClickHandler = function(_ref) {
        let {
            rowDates: rowDates,
            event: event
        } = _ref;
        const selectedDates = rowDates.filter(date => !this._isDateDisabled(date));
        this.dateValue(selectedDates, event)
    };
    return CalendarMultiSelectionStrategy
}(_uiCalendarSelection.default);
var _default = CalendarMultiSelectionStrategy;
exports.default = _default;
module.exports = exports.default;
module.exports.default = exports.default;
