"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.YearsPage = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var calendar_utils_1 = require("./calendar-utils");
var date_utils_1 = require("../../utils/date-utils");
var YearsPage = exports.YearsPage = (function () {
    function YearsPage(dateUtils) {
        this.dateUtils = dateUtils;
        this.isAttached = false;
    }
    YearsPage.prototype.attached = function () {
        this.isAttached = true;
    };
    YearsPage.prototype.dateChanged = function (newMonth) {
        this.date = newMonth || new Date();
        this.pageStart = this.dateUtils.addYears(this.dateUtils.getStartOfDecade(this.date), -1);
    };
    YearsPage.prototype.getYear = function (year) {
        var date = this.dateUtils.addYears(this.pageStart, year);
        var classes = [];
        if (year === 0 || year === 11) {
            classes.push("date-other");
        }
        if (this.config) {
            if ((isDate(this.config.date) && this.dateUtils.isSameYear(date, this.config.date)) ||
                (isArray(this.config.date) && this.dateUtils.isSameYear(date, this.config.date[0]))) {
                classes.push("selected");
            }
            if ((0, calendar_utils_1.isDisabled)(__assign({ disabled: [] }, this.config), date, this.dateUtils)) {
                classes.push("disabled");
            }
        }
        return { date: date, label: this.dateUtils.format(date, "yyyy"), classes: classes.join(" ") };
    };
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Date)
    ], YearsPage.prototype, "date", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Object)
    ], YearsPage.prototype, "config", void 0);
    YearsPage = __decorate([
        (0, aurelia_framework_1.customElement)("years-page"),
        __metadata("design:paramtypes", [date_utils_1.DateUtils])
    ], YearsPage);
    return YearsPage;
}());

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