var _a;
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 uuid from '../../utils/uuid/uuid';
import { ModulVue } from '../../utils/vue/vue';
import { I18N_NAME, SWITCH_NAME, VALIDATION_MESSAGE_NAME } from '../component-names';
import { MI18n } from '../i18n/i18n';
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.internalValue = false;
        _this.isFocus = false;
        _this.id = "switch" + uuid.generate();
        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
    });
    MSwitch.prototype.onClick = function (event) {
        this.$emit('click', event);
        this.$refs['switch']['blur']();
    };
    Object.defineProperty(MSwitch.prototype, "hasSwitchLeft", {
        get: function () {
            return ((this.position === MSwitchPosition.Right) ? false : true);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MSwitch.prototype, "label", {
        get: function () {
            return !!this.$slots.default;
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        Model('change'),
        Prop()
    ], MSwitch.prototype, "value", void 0);
    __decorate([
        Prop({
            default: MSwitchPosition.Left,
            validator: function (value) {
                return value === MSwitchPosition.Left ||
                    value === MSwitchPosition.Right;
            }
        })
    ], 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: (_a = {},
                _a[VALIDATION_MESSAGE_NAME] = MValidationMessage,
                _a[I18N_NAME] = MI18n,
                _a),
            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