var _a, _b;
import { __decorate, __extends } from "tslib";
import Vue from 'vue';
import Component from 'vue-class-component';
import { Emit, Prop, Watch } from 'vue-property-decorator';
import { I18N_NAME } from '../../filters/filter-names';
import { i18nFilter } from '../../filters/i18n/i18n';
import { ICON_BUTTON_NAME, ICON_NAME, MESSAGE_NAME, MESSAGE_PAGE_NAME } from '../component-names';
import { MIconButton } from '../icon-button/icon-button';
import { MIcon } from '../icon/icon';
import { MMessagePage, MMessagePageSkin } from '../message-page/message-page';
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.internalVisible = true;
        _this.animReady = false;
        return _this;
    }
    MMessage.prototype.onClose = function (event) {
        this.propVisible = false;
    };
    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.$emit('update:visible', this.internalVisible);
        },
        enumerable: false,
        configurable: true
    });
    MMessage.prototype.getIcon = function () {
        var icon = '';
        switch (this.state) {
            case MMessageState.Confirmation:
                icon = 'm-svg__confirmation';
                break;
            case MMessageState.Information:
                icon = 'm-svg__information';
                break;
            case MMessageState.Warning:
                icon = 'm-svg__warning';
                break;
            case MMessageState.Error:
                icon = 'm-svg__error';
                break;
            default:
                break;
        }
        return icon;
    };
    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
    });
    __decorate([
        Prop({
            default: MMessageState.Confirmation,
            validator: function (value) {
                return value === MMessageState.Confirmation ||
                    value === MMessageState.Information ||
                    value === MMessageState.Warning ||
                    value === MMessageState.Error;
            }
        })
    ], MMessage.prototype, "state", void 0);
    __decorate([
        Prop({
            default: MMessageSkin.Default,
            validator: function (value) {
                return value === MMessageSkin.Default ||
                    value === MMessageSkin.Light ||
                    value === MMessageSkin.PageLight ||
                    value === MMessageSkin.Page;
            }
        })
    ], 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, "onClose", null);
    __decorate([
        Watch('visible')
    ], MMessage.prototype, "onVisibleChange", null);
    MMessage = __decorate([
        WithRender,
        Component({
            components: (_a = {},
                _a[ICON_NAME] = MIcon,
                _a[ICON_BUTTON_NAME] = MIconButton,
                _a[MESSAGE_PAGE_NAME] = MMessagePage,
                _a),
            filters: (_b = {},
                _b[I18N_NAME] = i18nFilter,
                _b)
        })
    ], MMessage);
    return MMessage;
}(Vue));
export { MMessage };
var MessagePlugin = {
    install: function (v, options) {
        v.component(MESSAGE_NAME, MMessage);
    }
};
export default MessagePlugin;
//# sourceMappingURL=message.js.map