"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MonthsPage = void 0;
var constants_1 = require("./../../constants/constants");
var aurelia_framework_1 = require("aurelia-framework");
var aurelia_i18n_1 = require("aurelia-i18n");
var calendar_utils_1 = require("./calendar-utils");
var date_utils_1 = require("../../utils/date-utils");
var ui_range_picker_1 = require("./ui-range-picker");
var MonthsPage = exports.MonthsPage = (function () {
    function MonthsPage(i18n, dateUtils) {
        this.i18n = i18n;
        this.dateUtils = dateUtils;
        this.selection = ui_range_picker_1.UIRangePickerSelectionMode.Day;
        this.translations = constants_1.Internationalization.datePickerTranslationsEN;
        this.isAttached = false;
    }
    MonthsPage.prototype.attached = function () {
        this.isAttached = true;
    };
    MonthsPage.prototype.getMonth = function (month) {
        var newDate = this.dateUtils.setMonths(this.date, month);
        var classes = [];
        if (this.config) {
            if (this.selection == ui_range_picker_1.UIRangePickerSelectionMode.MonthToMonth) {
                if (isArray(this.config.date)) {
                    if (this.dateUtils.isAfter(this.dateUtils.getStartOfDay(this.dateUtils.getStartOfMonth(newDate)), this.dateUtils.getStartOfDay(this.dateUtils.getStartOfMonth(this.config.date[0]))) &&
                        this.dateUtils.isBefore(this.dateUtils.getStartOfDay(this.dateUtils.getStartOfMonth(newDate)), this.dateUtils.getStartOfDay(this.dateUtils.getStartOfMonth(this.config.date[1])))) {
                        classes.push("select-hilight");
                    }
                    if (this.dateUtils.isSameMonth(this.config.date[0], newDate)) {
                        classes.push("select-start");
                    }
                    if (this.dateUtils.isSameMonth(this.config.date[1], newDate)) {
                        classes.push("select-end");
                    }
                }
            }
            else {
                if ((isDate(this.config.date) && this.dateUtils.isSameMonth(newDate, this.config.date)) ||
                    (isArray(this.config.date) && this.dateUtils.isSameMonth(newDate, this.config.date[0]))) {
                    classes.push("selected");
                }
            }
            if ((0, calendar_utils_1.isDisabled)(__assign({ disabled: [] }, this.config), newDate, this.dateUtils)) {
                classes.push("disabled");
            }
        }
        return { date: newDate, classes: classes.join(" ") };
    };
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Date)
    ], MonthsPage.prototype, "date", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Object)
    ], MonthsPage.prototype, "config", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.oneTime }),
        __metadata("design:type", String)
    ], MonthsPage.prototype, "selection", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", constants_1.DatePickerTranslations)
    ], MonthsPage.prototype, "translations", void 0);
    MonthsPage = __decorate([
        (0, aurelia_framework_1.customElement)("months-page"),
        __metadata("design:paramtypes", [aurelia_i18n_1.I18N, date_utils_1.DateUtils])
    ], MonthsPage);
    return MonthsPage;
}());

//# sourceMappingURL=months-page.js.map
