import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Prop } 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_PAGE_NAME } from '../component-names';
import { MLink } from '../link/link';
import { MSvg } from './../svg/svg';
import WithRender from './message-page.html?style=./message-page.scss';
/**
 * Utility class to manage the properties related to the link displayed in the error pages.
 */
var Link = /** @class */ (function () {
    /**
     * Constructor
     * @param label Label for the url link to display.
     * @param url Target for the location to navigate to, can be relative.
     * @param external Defines to the target is external (opens in new tab), or internal (opens in same tab) to the application.
     */
    function Link(label, url, external) {
        if (external === void 0) { external = false; }
        this.label = label;
        this.url = url;
        this.external = external;
    }
    return Link;
}());
export { Link };
export var MMessagePageSkin;
(function (MMessagePageSkin) {
    MMessagePageSkin["Default"] = "default";
    MMessagePageSkin["Light"] = "light";
})(MMessagePageSkin || (MMessagePageSkin = {}));
export var MMessagePageImageSize;
(function (MMessagePageImageSize) {
    MMessagePageImageSize["Default"] = "130px";
    MMessagePageImageSize["Small"] = "76px";
})(MMessagePageImageSize || (MMessagePageImageSize = {}));
export var MMessagePageState;
(function (MMessagePageState) {
    MMessagePageState["Information"] = "information";
    MMessagePageState["Warning"] = "warning";
    MMessagePageState["Confirmation"] = "confirmation";
    MMessagePageState["Error"] = "error";
})(MMessagePageState || (MMessagePageState = {}));
var MMessagePage = /** @class */ (function (_super) {
    __extends(MMessagePage, _super);
    function MMessagePage() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MMessagePage.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'));
    };
    Object.defineProperty(MMessagePage.prototype, "hasHints", {
        get: function () {
            return this.hints.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "hasLinks", {
        get: function () {
            return this.links.length > 0;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "propImageSize", {
        get: function () {
            if (this.imageSize) {
                return this.imageSize;
            }
            return this.isSkinLight ? MMessagePageImageSize.Small : MMessagePageImageSize.Default;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "hasLinksAndSlot", {
        get: function () {
            return this.hasLinks || !!this.$slots.default;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "hasBody", {
        get: function () {
            return this.hasHints || this.hasLinks || !!this.$slots.default;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "isSkinDefault", {
        get: function () {
            return this.skin === MMessagePageSkin.Default;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "isSkinLight", {
        get: function () {
            return this.skin === MMessagePageSkin.Light;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "isStateInformation", {
        get: function () {
            return this.state === MMessagePageState.Information;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "isStateWarning", {
        get: function () {
            return this.state === MMessagePageState.Warning;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "isStateError", {
        get: function () {
            return this.state === MMessagePageState.Error;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "isStateConfirmation", {
        get: function () {
            return this.state === MMessagePageState.Confirmation;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MMessagePage.prototype, "iconNameProp", {
        get: function () {
            if (this.iconName) {
                return this.iconName;
            }
            switch (this.state) {
                case MMessagePageState.Confirmation:
                    return ModulIconName.ConfirmationWhiteFilled;
                case MMessagePageState.Information:
                    return ModulIconName.InformationWhiteFilled;
                case MMessagePageState.Warning:
                    return ModulIconName.WarningWhiteFilled;
                default:
                    return ModulIconName.ErrorWhiteFilled;
            }
        },
        enumerable: false,
        configurable: true
    });
    MMessagePage.prototype.isTargetExternal = function (isExternal) {
        return isExternal ? '_blank' : '';
    };
    __decorate([
        Prop({
            default: 'error',
            validator: function (value) { return Enums.toValueArray(MMessagePageState).includes(value); }
        })
    ], MMessagePage.prototype, "state", void 0);
    __decorate([
        Prop({
            default: MMessagePageSkin.Default,
            validator: function (value) { return Enums.toValueArray(MMessagePageSkin).includes(value); }
        })
    ], MMessagePage.prototype, "skin", void 0);
    __decorate([
        Prop()
    ], MMessagePage.prototype, "iconName", void 0);
    __decorate([
        Prop()
    ], MMessagePage.prototype, "svgName", void 0);
    __decorate([
        Prop()
    ], MMessagePage.prototype, "imageSize", void 0);
    __decorate([
        Prop()
    ], MMessagePage.prototype, "title", void 0);
    __decorate([
        Prop({ default: function () { return []; } })
    ], MMessagePage.prototype, "hints", void 0);
    __decorate([
        Prop({ default: function () { return []; } })
    ], MMessagePage.prototype, "links", void 0);
    MMessagePage = __decorate([
        WithRender,
        Component({
            components: {
                MLink: MLink,
                MSvg: MSvg
            }
        })
    ], MMessagePage);
    return MMessagePage;
}(ModulVue));
export { MMessagePage };
var MessagePagePlugin = {
    install: function (v) {
        v.prototype.$log.debug(MESSAGE_PAGE_NAME, 'plugin.install');
        v.component(MESSAGE_PAGE_NAME, MMessagePage);
    }
};
export default MessagePagePlugin;
//# sourceMappingURL=message-page.js.map