import { __assign, __decorate, __extends } from "tslib";
import Vue from 'vue';
import Component from 'vue-class-component';
import { Emit, Model, Prop } from 'vue-property-decorator';
import { MButton, MButtonSkin } from '../button/button';
import { TOGGLE_BUTTONS_NAME } from '../component-names';
import WithRender from './toggle-buttons.html?style=./toggle-buttons.scss';
export var MToggleButtonSkin;
(function (MToggleButtonSkin) {
    MToggleButtonSkin["SQUARED"] = "default";
    MToggleButtonSkin["ROUNDED"] = "rounded";
})(MToggleButtonSkin || (MToggleButtonSkin = {}));
var MToggleButtons = /** @class */ (function (_super) {
    __extends(MToggleButtons, _super);
    function MToggleButtons() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MToggleButtons.prototype.toggle = function (button) {
        var _this = this;
        this.$emit('change', this.buttons.map(function (b) { return b.id !== button.id ?
            _this.multiple ? b : __assign(__assign({}, b), { pressed: false }) : __assign(__assign({}, b), { pressed: !b.pressed }); }));
        this.onClick(__assign(__assign({}, button), { pressed: !button.pressed }));
    };
    MToggleButtons.prototype.onClick = function (button) { };
    MToggleButtons.prototype.getSkin = function (button) {
        return !button.pressed ? MButtonSkin.Secondary : MButtonSkin.Primary;
    };
    Object.defineProperty(MToggleButtons.prototype, "skinButtons", {
        get: function () {
            return {
                'm--is-default': this.skin === MToggleButtonSkin.SQUARED,
                'm--is-rounded': this.skin === MToggleButtonSkin.ROUNDED
            };
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        Model('change'),
        Prop({ default: function () { return []; } })
    ], MToggleButtons.prototype, "buttons", void 0);
    __decorate([
        Prop({ default: true })
    ], MToggleButtons.prototype, "multiple", void 0);
    __decorate([
        Prop({ default: false })
    ], MToggleButtons.prototype, "disabled", void 0);
    __decorate([
        Prop({
            default: MToggleButtonSkin.SQUARED,
            validator: function (value) {
                return value === MToggleButtonSkin.SQUARED ||
                    value === MToggleButtonSkin.ROUNDED;
            }
        })
    ], MToggleButtons.prototype, "skin", void 0);
    __decorate([
        Emit('click')
    ], MToggleButtons.prototype, "onClick", null);
    MToggleButtons = __decorate([
        WithRender,
        Component({
            components: {
                MButton: MButton
            }
        })
    ], MToggleButtons);
    return MToggleButtons;
}(Vue));
export { MToggleButtons };
var ToggleButtonsPlugin = {
    install: function (v, options) {
        v.prototype.$log.debug(TOGGLE_BUTTONS_NAME, 'plugin.install');
        v.component(TOGGLE_BUTTONS_NAME, MToggleButtons);
    }
};
export default ToggleButtonsPlugin;
//# sourceMappingURL=toggle-buttons.js.map