/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes} checked by tsc
 */
import { Component, EventEmitter } from '@angular/core';
import { BsDatepickerAbstractComponent } from '../../base/bs-datepicker-container';
import { BsDatepickerConfig } from '../../bs-datepicker.config';
import { BsDatepickerActions } from '../../reducer/bs-datepicker.actions';
import { BsDatepickerEffects } from '../../reducer/bs-datepicker.effects';
import { BsDatepickerStore } from '../../reducer/bs-datepicker.store';
export class BsDatepickerContainerComponent extends BsDatepickerAbstractComponent {
    /**
     * @param {?} _config
     * @param {?} _store
     * @param {?} _actions
     * @param {?} _effects
     */
    constructor(_config, _store, _actions, _effects) {
        super();
        this._config = _config;
        this._store = _store;
        this._actions = _actions;
        this.valueChange = new EventEmitter();
        this._subs = [];
        this._effects = _effects;
    }
    /**
     * @param {?} value
     * @return {?}
     */
    set value(value) {
        this._effects.setValue(value);
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.containerClass = this._config.containerClass;
        this._effects
            .init(this._store)
            .setOptions(this._config)
            .setBindings(this)
            .setEventHandlers(this)
            .registerDatepickerSideEffects();
        // todo: move it somewhere else
        // on selected date change
        this._subs.push(this._store
            .select((state) => state.selectedDate)
            .subscribe((date) => this.valueChange.emit(date)));
    }
    /**
     * @param {?} day
     * @return {?}
     */
    daySelectHandler(day) {
        if (day.isOtherMonth || day.isDisabled) {
            return;
        }
        this._store.dispatch(this._actions.select(day.date));
    }
    /**
     * @return {?}
     */
    ngOnDestroy() {
        for (const /** @type {?} */ sub of this._subs) {
            sub.unsubscribe();
        }
        this._effects.destroy();
    }
}
BsDatepickerContainerComponent.decorators = [
    { type: Component, args: [{
                selector: 'bs-datepicker-container',
                providers: [BsDatepickerStore, BsDatepickerEffects],
                template: "<!-- days calendar view mode -->\r\n<div class=\"bs-datepicker\" [ngClass]=\"containerClass\" *ngIf=\"viewMode | async\">\r\n  <div class=\"bs-datepicker-container\">\r\n\r\n    <!--calendars-->\r\n    <div class=\"bs-calendar-container\" [ngSwitch]=\"viewMode | async\" role=\"application\">\r\n      <!--days calendar-->\r\n      <div *ngSwitchCase=\"'day'\">\r\n        <bs-days-calendar-view\r\n          *ngFor=\"let calendar of (daysCalendar | async)\"\r\n          [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\r\n          [calendar]=\"calendar\"\r\n          [options]=\"options | async\"\r\n          (onNavigate)=\"navigateTo($event)\"\r\n          (onViewMode)=\"setViewMode($event)\"\r\n          (onHover)=\"dayHoverHandler($event)\"\r\n          (onSelect)=\"daySelectHandler($event)\"\r\n        ></bs-days-calendar-view>\r\n      </div>\r\n\r\n      <!--months calendar-->\r\n      <div *ngSwitchCase=\"'month'\">\r\n        <bs-month-calendar-view\r\n          *ngFor=\"let calendar of (monthsCalendar | async)\"\r\n          [class.bs-datepicker-multiple]=\"(daysCalendar | async)?.length > 1\"\r\n          [calendar]=\"calendar\"\r\n          (onNavigate)=\"navigateTo($event)\"\r\n          (onViewMode)=\"setViewMode($event)\"\r\n          (onHover)=\"monthHoverHandler($event)\"\r\n          (onSelect)=\"monthSelectHandler($event)\"\r\n        ></bs-month-calendar-view>\r\n      </div>\r\n\r\n      <!--years calendar-->\r\n      <div *ngSwitchCase=\"'year'\">\r\n        <bs-years-calendar-view\r\n        *ngFor=\"let calendar of (yearsCalendar | async)\"\r\n        [class.bs-datepicker-multiple]=\"(daysCalendar | async )?.length > 1\"\r\n        [calendar]=\"calendar\"\r\n        (onNavigate)=\"navigateTo($event)\"\r\n        (onViewMode)=\"setViewMode($event)\"\r\n        (onHover)=\"yearHoverHandler($event)\"\r\n        (onSelect)=\"yearSelectHandler($event)\"\r\n      ></bs-years-calendar-view>\r\n    </div>\r\n\r\n  </div>\r\n\r\n  <!--applycancel buttons-->\r\n    <div class=\"bs-datepicker-buttons\" *ngIf=\"false\">\r\n      <button class=\"btn btn-success\">Apply</button>\r\n      <button class=\"btn btn-default\">Cancel</button>\r\n    </div>\r\n\r\n  </div>\r\n\r\n  <!--custom dates or date ranges picker-->\r\n  <div class=\"bs-datepicker-custom-range\" *ngIf=\"false\">\r\n    <bs-custom-date-view [ranges]=\"_customRangesFish\"></bs-custom-date-view>\r\n  </div>\r\n</div>\r\n",
                host: {
                    '(click)': '_stopPropagation($event)',
                    style: 'position: absolute; display: block;',
                    role: 'dialog',
                    'aria-label': 'calendar'
                }
            }] }
];
/** @nocollapse */
BsDatepickerContainerComponent.ctorParameters = () => [
    { type: BsDatepickerConfig, },
    { type: BsDatepickerStore, },
    { type: BsDatepickerActions, },
    { type: BsDatepickerEffects, },
];
function BsDatepickerContainerComponent_tsickle_Closure_declarations() {
    /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
    BsDatepickerContainerComponent.decorators;
    /**
     * @nocollapse
     * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>}
     */
    BsDatepickerContainerComponent.ctorParameters;
    /** @type {?} */
    BsDatepickerContainerComponent.prototype.valueChange;
    /** @type {?} */
    BsDatepickerContainerComponent.prototype._subs;
    /** @type {?} */
    BsDatepickerContainerComponent.prototype._config;
    /** @type {?} */
    BsDatepickerContainerComponent.prototype._store;
    /** @type {?} */
    BsDatepickerContainerComponent.prototype._actions;
}

//# sourceMappingURL=data:application/json;base64, 