import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop, Watch } from 'vue-property-decorator';
import { ModulVue } from '../../../utils/vue/vue';
import CalendarRangeDateState from './state/calendar-range-date-state';
import CalendarSingleDateState from './state/calendar-single-date-state';
export var CalendarMode;
(function (CalendarMode) {
    CalendarMode["SINGLE_DATE"] = "single-date";
    CalendarMode["DATE_RANGE"] = "date-range";
})(CalendarMode || (CalendarMode = {}));
var MCalendarStateMachine = /** @class */ (function (_super) {
    __extends(MCalendarStateMachine, _super);
    function MCalendarStateMachine() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.calendarState = {};
        return _this;
    }
    MCalendarStateMachine.prototype.refreshValue = function () {
        this.calendarState.updateState(this.value, this.minDate, this.maxDate);
    };
    MCalendarStateMachine.prototype.created = function () {
        switch (this.mode) {
            case CalendarMode.SINGLE_DATE:
                this.calendarState = new CalendarSingleDateState(this.value, this.minDate, this.maxDate);
                break;
            case CalendarMode.DATE_RANGE:
                this.calendarState = new CalendarRangeDateState(this.value, this.minDate, this.maxDate);
        }
        this.calendarState.onDateSelect(this.dateSelectCallBack);
    };
    MCalendarStateMachine.prototype.render = function () {
        if (this.$scopedSlots) {
            return this.$scopedSlots.default(this.calendarState.buildCurrentCalendar());
        }
    };
    MCalendarStateMachine.prototype.onInput = function (value) {
        this.calendarState.updateState(value, this.minDate, this.maxDate);
    };
    MCalendarStateMachine.prototype.dateSelectCallBack = function (date) { };
    __decorate([
        Prop({ default: '' })
    ], MCalendarStateMachine.prototype, "value", void 0);
    __decorate([
        Prop({ default: CalendarMode.SINGLE_DATE })
    ], MCalendarStateMachine.prototype, "mode", void 0);
    __decorate([
        Prop()
    ], MCalendarStateMachine.prototype, "minDate", void 0);
    __decorate([
        Prop()
    ], MCalendarStateMachine.prototype, "maxDate", void 0);
    __decorate([
        Watch('value'),
        Watch('minDate'),
        Watch('maxDate')
    ], MCalendarStateMachine.prototype, "refreshValue", null);
    __decorate([
        Emit('input')
    ], MCalendarStateMachine.prototype, "dateSelectCallBack", null);
    MCalendarStateMachine = __decorate([
        Component
    ], MCalendarStateMachine);
    return MCalendarStateMachine;
}(ModulVue));
export default MCalendarStateMachine;
//# sourceMappingURL=calendar-state-machine.js.map