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);
};
import { DatePickerTranslations, Internationalization } from './../../constants/constants';
import { bindable, customElement } from "aurelia-framework";
import { isDisabled } from "./calendar-utils";
import { DateUtils } from '../../utils/date-utils';
export var DaysPage = (function () {
    function DaysPage(dateUtils) {
        this.dateUtils = dateUtils;
        this.displayWeek = false;
        this.translations = Internationalization.datePickerTranslationsEN;
        this.isAttached = false;
        this.weekStartsOn = 1;
    }
    DaysPage.prototype.attached = function () {
        this.isAttached = true;
        this.weekNumbers = new Array();
        for (var index = 0; index < 7; index++) {
            var weekNumber = index + this.weekStartsOn;
            if (weekNumber >= 7)
                weekNumber -= 7;
            this.weekNumbers.push(weekNumber);
        }
    };
    DaysPage.prototype.dateChanged = function (newDate) {
        this.date = newDate || new Date();
        this.pageStart = this.dateUtils.getStartOfWeek(newDate || this.dateUtils.getStartOfMonth(this.date));
    };
    DaysPage.prototype.weekNumber = function (week) {
        var _a;
        var date = this.dateUtils.addWeeks(this.pageStart, week);
        return { date: date, label: (_a = this.dateUtils.getNumOfWeek(date)) === null || _a === void 0 ? void 0 : _a.toLocaleString('fr-BE', { minimumIntegerDigits: 2, useGrouping: false }) };
    };
    DaysPage.prototype.getDate = function (week, day) {
        var date = this.dateUtils.addDays(this.dateUtils.addWeeks(this.pageStart, week), day);
        var classes = [];
        if (!this.dateUtils.isSameMonth(this.date, date)) {
            classes.push("date-other");
        }
        if (this.dateUtils.isSameDay(new Date(), date)) {
            classes.push("date-today");
        }
        if (this.config) {
            if (isArray(this.config.date)) {
                if (this.dateUtils.isAfter(this.dateUtils.getStartOfDay(date), this.config.date[0]) &&
                    this.dateUtils.isBefore(this.dateUtils.getStartOfDay(date), this.config.date[1])) {
                    classes.push("select-hilight");
                }
                if (this.dateUtils.isSameDay(this.config.date[0], date)) {
                    classes.push("select-start");
                }
                if (this.dateUtils.isSameDay(this.config.date[1], date)) {
                    classes.push("select-end");
                }
            }
            if (isDate(this.config.date) && this.dateUtils.isSameDay(this.config.date, date)) {
                classes.push("selected");
            }
            if (isDisabled(this.config, date, this.dateUtils)) {
                classes.push("disabled");
            }
        }
        if (date.getDay() == 0 || date.getDay() == 6) {
            classes.push("date-week-end");
        }
        return { date: date, label: date.getDate(), classes: classes.join(" ") };
    };
    __decorate([
        bindable(),
        __metadata("design:type", Date)
    ], DaysPage.prototype, "date", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", Object)
    ], DaysPage.prototype, "config", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", Boolean)
    ], DaysPage.prototype, "displayWeek", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", DatePickerTranslations)
    ], DaysPage.prototype, "translations", void 0);
    DaysPage = __decorate([
        customElement("days-page"),
        __metadata("design:paramtypes", [DateUtils])
    ], DaysPage);
    return DaysPage;
}());

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