import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Model, Prop, Watch } from 'vue-property-decorator';
import { InputState } from '../../mixins/input-state/input-state';
import { Enums } from '../../utils/enums/enums';
import uuid from '../../utils/uuid/uuid';
import { ModulVue } from '../../utils/vue/vue';
import { SWITCH_NAME } from '../component-names';
import { MValidationMessage } from '../validation-message/validation-message';
import WithRender from './switch.html?style=./switch.scss';
export var MSwitchPosition;
(function (MSwitchPosition) {
    MSwitchPosition["Left"] = "left";
    MSwitchPosition["Right"] = "right";
})(MSwitchPosition || (MSwitchPosition = {}));
var MSwitch = /** @class */ (function (_super) {
    __extends(MSwitch, _super);
    function MSwitch() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.isFocus = false;
        _this.id = "switch" + uuid.generate();
        _this.internalValue = false;
        return _this;
    }
    MSwitch.prototype.onValueChange = function (value) {
        this.internalValue = value;
    };
    Object.defineProperty(MSwitch.prototype, "propChecked", {
        get: function () {
            return this.value !== undefined ? this.value : this.internalValue;
        },
        set: function (value) {
            this.$emit('change', value);
            this.internalValue = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MSwitch.prototype, "hasSwitchLeft", {
        get: function () {
            return ((this.position === MSwitchPosition.Right) ? false : true);
        },
        enumerable: false,
        configurable: true
    });
    MSwitch.prototype.onClick = function (event) {
        this.$emit('click', event);
    };
    __decorate([
        Model('change'),
        Prop()
    ], MSwitch.prototype, "value", void 0);
    __decorate([
        Prop({
            default: MSwitchPosition.Left,
            validator: function (value) { return Enums.toValueArray(MSwitchPosition).includes(value); }
        })
    ], MSwitch.prototype, "position", void 0);
    __decorate([
        Prop({ default: true })
    ], MSwitch.prototype, "stateText", void 0);
    __decorate([
        Watch('value')
    ], MSwitch.prototype, "onValueChange", null);
    MSwitch = __decorate([
        WithRender,
        Component({
            components: {
                MValidationMessage: MValidationMessage
            },
            mixins: [InputState]
        })
    ], MSwitch);
    return MSwitch;
}(ModulVue));
export { MSwitch };
var SwitchPlugin = {
    install: function (v, options) {
        v.component(SWITCH_NAME, MSwitch);
    }
};
export default SwitchPlugin;
//# sourceMappingURL=switch.js.map