import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop, Watch } from 'vue-property-decorator';
import { Enums } from '../../utils/enums/enums';
import { ModulIconName } from '../../utils/modul-icons/modul-icons';
import { ModulVue } from '../../utils/vue/vue';
import { MESSAGE_NAME } from '../component-names';
import { MIconButton } from '../icon-button/icon-button';
import { MMessagePage, MMessagePageSkin } from '../message-page/message-page';
import { MSvg } from '../svg/svg';
import WithRender from './message.html?style=./message.scss';
export var MMessageState;
(function (MMessageState) {
    MMessageState["Confirmation"] = "confirmation";
    MMessageState["Information"] = "information";
    MMessageState["Warning"] = "warning";
    MMessageState["Error"] = "error";
})(MMessageState || (MMessageState = {}));
export var MMessageSkin;
(function (MMessageSkin) {
    MMessageSkin["Default"] = "default";
    MMessageSkin["Light"] = "light";
    MMessageSkin["PageLight"] = "page-light";
    MMessageSkin["Page"] = "page";
})(MMessageSkin || (MMessageSkin = {}));
var MMessage = /** @class */ (function (_super) {
    __extends(MMessage, _super);
    function MMessage() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.animReady = false;
        _this.internalVisible = true;
        return _this;
    }
    MMessage.prototype.emitClose = function (_event) {
        this.propVisible = false;
    };
    MMessage.prototype.emitUpdateVisible = function (_isVisible) { };
    MMessage.prototype.beforeCreate = function () {
        if (!this.$svgSprite) {
            return;
        }
        this.$svgSprite.addSvg(ModulIconName.ConfirmationWhiteFilled, require('../../assets/icons/svg/confirmation-white-filled.svg'));
        this.$svgSprite.addSvg(ModulIconName.InformationWhiteFilled, require('../../assets/icons/svg/information-white-filled.svg'));
        this.$svgSprite.addSvg(ModulIconName.WarningWhiteFilled, require('../../assets/icons/svg/warning-white-filled.svg'));
        this.$svgSprite.addSvg(ModulIconName.ErrorWhiteFilled, require('../../assets/icons/svg/error-white-filled.svg'));
    };
    MMessage.prototype.mounted = function () {
        var _this = this;
        this.propVisible = this.visible;
        setTimeout(function () {
            _this.animReady = true;
        });
    };
    MMessage.prototype.onVisibleChange = function (value) {
        this.propVisible = value;
    };
    Object.defineProperty(MMessage.prototype, "propVisible", {
        get: function () {
            return this.internalVisible;
        },
        set: function (visible) {
            this.internalVisible = visible === undefined ? true : visible;
            this.emitUpdateVisible(this.internalVisible);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isSkinDefault", {
        get: function () {
            return this.skin === MMessageSkin.Default;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isSkinLight", {
        get: function () {
            return this.skin === MMessageSkin.Light;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isNotSkinPage", {
        get: function () {
            return !this.isSkinPage && !this.isSkinPageLight;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "skinPageValue", {
        get: function () {
            return this.isSkinPage ? MMessagePageSkin.Default : MMessagePageSkin.Light;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isSkinPage", {
        get: function () {
            return this.skin === MMessageSkin.Page;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isSkinPageLight", {
        get: function () {
            return this.skin === MMessageSkin.PageLight;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isStateInformation", {
        get: function () {
            return this.state === MMessageState.Information;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isStateWarning", {
        get: function () {
            return this.state === MMessageState.Warning;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isStateError", {
        get: function () {
            return this.state === MMessageState.Error;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "isStateConfirmation", {
        get: function () {
            return this.state === MMessageState.Confirmation;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessage.prototype, "showCloseButton", {
        get: function () {
            return this.skin === MMessageSkin.Default && this.closeButton;
        },
        enumerable: false,
        configurable: true
    });
    MMessage.prototype.getIcon = function () {
        switch (this.state) {
            case MMessageState.Confirmation:
                return ModulIconName.ConfirmationWhiteFilled;
            case MMessageState.Information:
                return ModulIconName.InformationWhiteFilled;
            case MMessageState.Warning:
                return ModulIconName.WarningWhiteFilled;
            case MMessageState.Error:
                return ModulIconName.ErrorWhiteFilled;
            default:
                return '';
        }
    };
    __decorate([
        Prop({
            default: MMessageState.Confirmation,
            validator: function (value) { return Enums.toValueArray(MMessageState).includes(value); }
        })
    ], MMessage.prototype, "state", void 0);
    __decorate([
        Prop({
            default: MMessageSkin.Default,
            validator: function (value) { return Enums.toValueArray(MMessageSkin).includes(value); }
        })
    ], MMessage.prototype, "skin", void 0);
    __decorate([
        Prop({ default: true })
    ], MMessage.prototype, "icon", void 0);
    __decorate([
        Prop()
    ], MMessage.prototype, "title", void 0);
    __decorate([
        Prop()
    ], MMessage.prototype, "closeButton", void 0);
    __decorate([
        Prop({ default: true })
    ], MMessage.prototype, "visible", void 0);
    __decorate([
        Emit('close')
    ], MMessage.prototype, "emitClose", null);
    __decorate([
        Emit('update:visible')
    ], MMessage.prototype, "emitUpdateVisible", null);
    __decorate([
        Watch('visible')
    ], MMessage.prototype, "onVisibleChange", null);
    MMessage = __decorate([
        WithRender,
        Component({
            components: {
                MSvg: MSvg,
                MIconButton: MIconButton,
                MMessagePage: MMessagePage
            }
        })
    ], MMessage);
    return MMessage;
}(ModulVue));
export { MMessage };
var MessagePlugin = {
    install: function (v, options) {
        v.component(MESSAGE_NAME, MMessage);
    }
};
export default MessagePlugin;
//# sourceMappingURL=message.js.map