/**
 * @license
 * Copyright Endlessjs. All Rights Reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 */
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 { ChangeDetectionStrategy, Component, EventEmitter, HostBinding, Input, Output, Type, } from '@angular/core';
import { batch } from '../../helpers';
import { ElCalendarSize } from '../../model';
import { ElCalendarMonthCellComponent } from './calendar-month-cell.component';
import { ElDateService } from '../../services/date.service';
export var MONTHS_IN_VIEW = 12;
export var MONTHS_IN_COLUMN = 4;
var ElCalendarMonthPickerComponent = /** @class */ (function () {
    function ElCalendarMonthPickerComponent(dateService) {
        this.dateService = dateService;
        this.size = ElCalendarSize.MEDIUM;
        this.monthChange = new EventEmitter();
        this.cellComponent = ElCalendarMonthCellComponent;
    }
    Object.defineProperty(ElCalendarMonthPickerComponent.prototype, "_cellComponent", {
        set: function (cellComponent) {
            if (cellComponent) {
                this.cellComponent = cellComponent;
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElCalendarMonthPickerComponent.prototype, "medium", {
        get: function () {
            return this.size === ElCalendarSize.MEDIUM;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ElCalendarMonthPickerComponent.prototype, "large", {
        get: function () {
            return this.size === ElCalendarSize.LARGE;
        },
        enumerable: true,
        configurable: true
    });
    ElCalendarMonthPickerComponent.prototype.ngOnInit = function () {
        this.initMonths();
    };
    ElCalendarMonthPickerComponent.prototype.initMonths = function () {
        var date = this.dateService.getDate(this.month);
        var year = this.dateService.getYear(this.month);
        var firstMonth = this.dateService.createDate(year, 0, date);
        var months = [firstMonth];
        for (var monthIndex = 1; monthIndex < MONTHS_IN_VIEW; monthIndex++) {
            months.push(this.dateService.addMonth(firstMonth, monthIndex));
        }
        this.months = batch(months, MONTHS_IN_COLUMN);
    };
    ElCalendarMonthPickerComponent.prototype.onSelect = function (month) {
        this.monthChange.emit(month);
    };
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElCalendarMonthPickerComponent.prototype, "min", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElCalendarMonthPickerComponent.prototype, "max", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Function)
    ], ElCalendarMonthPickerComponent.prototype, "filter", void 0);
    __decorate([
        Input(),
        __metadata("design:type", String)
    ], ElCalendarMonthPickerComponent.prototype, "size", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Object)
    ], ElCalendarMonthPickerComponent.prototype, "month", void 0);
    __decorate([
        Output(),
        __metadata("design:type", EventEmitter)
    ], ElCalendarMonthPickerComponent.prototype, "monthChange", void 0);
    __decorate([
        Input('cellComponent'),
        __metadata("design:type", Type),
        __metadata("design:paramtypes", [Type])
    ], ElCalendarMonthPickerComponent.prototype, "_cellComponent", null);
    __decorate([
        HostBinding('class.medium'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], ElCalendarMonthPickerComponent.prototype, "medium", null);
    __decorate([
        HostBinding('class.large'),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], ElCalendarMonthPickerComponent.prototype, "large", null);
    ElCalendarMonthPickerComponent = __decorate([
        Component({
            selector: 'el-calendar-month-picker',
            template: "\n    <el-calendar-picker\n      [data]=\"months\"\n      [min]=\"min\"\n      [max]=\"max\"\n      [filter]=\"filter\"\n      [selectedValue]=\"month\"\n      [cellComponent]=\"cellComponent\"\n      (select)=\"onSelect($event)\">\n    </el-calendar-picker>\n  ",
            changeDetection: ChangeDetectionStrategy.OnPush
        }),
        __metadata("design:paramtypes", [ElDateService])
    ], ElCalendarMonthPickerComponent);
    return ElCalendarMonthPickerComponent;
}());
export { ElCalendarMonthPickerComponent };
//# sourceMappingURL=calendar-month-picker.component.js.map