var _a;
import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Prop } from 'vue-property-decorator';
import { BackdropMode, Portal, PortalTransitionDuration } from '../../mixins/portal/portal';
import { Enums } from '../../utils/enums/enums';
import { ModulVue } from '../../utils/vue/vue';
import { I18N_NAME, ICON_BUTTON_NAME, SIDEBAR_NAME } from '../component-names';
import { MI18n } from '../i18n/i18n';
import { MIconButton } from '../icon-button/icon-button';
import WithRender from './sidebar.html?style=./sidebar.scss';
export var MSidebarOrigin;
(function (MSidebarOrigin) {
    MSidebarOrigin["Top"] = "top";
    MSidebarOrigin["Right"] = "right";
    MSidebarOrigin["Bottom"] = "bottom";
    MSidebarOrigin["Left"] = "left";
})(MSidebarOrigin || (MSidebarOrigin = {}));
export var MSidebarCloseButtonPosition;
(function (MSidebarCloseButtonPosition) {
    MSidebarCloseButtonPosition["Left"] = "left";
    MSidebarCloseButtonPosition["Right"] = "right";
})(MSidebarCloseButtonPosition || (MSidebarCloseButtonPosition = {}));
var MSidebar = /** @class */ (function (_super) {
    __extends(MSidebar, _super);
    function MSidebar() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(MSidebar.prototype, "popupBody", {
        get: function () {
            return this.$refs.article.querySelector('.m-popup__body');
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MSidebar.prototype, "hasHeader", {
        get: function () {
            return Boolean(this.title) || (this.closeButton && this.origin !== MSidebarOrigin.Bottom);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MSidebar.prototype, "marginLeft", {
        get: function () {
            return this.origin === MSidebarOrigin.Right ? 'calc(100% - ' + this.propWidth + ')' : '';
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MSidebar.prototype, "propWidth", {
        get: function () {
            if (this.origin === MSidebarOrigin.Left || this.origin === MSidebarOrigin.Right) {
                return this.width ? this.width : '50%';
            }
            else {
                return '100%';
            }
        },
        enumerable: false,
        configurable: true
    });
    MSidebar.prototype.handlesFocus = function () {
        return this.focusManagement;
    };
    MSidebar.prototype.doCustomPropOpen = function (value) {
        return false;
    };
    MSidebar.prototype.getBackdropMode = function () {
        return BackdropMode.BackdropFast;
    };
    MSidebar.prototype.getPortalElement = function () {
        return this.$refs.article;
    };
    MSidebar.prototype.closeModal = function () {
        this.as().tryClose();
    };
    MSidebar.prototype.backdropClick = function () {
        if (this.closeOnBackdrop) {
            this.as().tryClose();
        }
    };
    MSidebar.prototype.mounted = function () {
        this.as().transitionDuration = PortalTransitionDuration.Slow;
    };
    __decorate([
        Prop({
            default: MSidebarOrigin.Bottom,
            validator: function (value) { return Enums.toValueArray(MSidebarOrigin).includes(value); }
        })
    ], MSidebar.prototype, "origin", void 0);
    __decorate([
        Prop()
    ], MSidebar.prototype, "width", void 0);
    __decorate([
        Prop()
    ], MSidebar.prototype, "title", void 0);
    __decorate([
        Prop({ default: true })
    ], MSidebar.prototype, "closeButton", void 0);
    __decorate([
        Prop({
            default: MSidebarCloseButtonPosition.Right,
            validator: function (value) { return Enums.toValueArray(MSidebarCloseButtonPosition).includes(value); }
        })
    ], MSidebar.prototype, "closeButtonPosition", void 0);
    __decorate([
        Prop({ default: true })
    ], MSidebar.prototype, "focusManagement", void 0);
    __decorate([
        Prop({ default: true })
    ], MSidebar.prototype, "closeOnBackdrop", void 0);
    __decorate([
        Prop({ default: true })
    ], MSidebar.prototype, "padding", void 0);
    __decorate([
        Prop({ default: true })
    ], MSidebar.prototype, "paddingHeader", void 0);
    __decorate([
        Prop({ default: true })
    ], MSidebar.prototype, "paddingBody", void 0);
    __decorate([
        Prop({ default: true })
    ], MSidebar.prototype, "paddingFooter", void 0);
    __decorate([
        Prop({ default: false })
    ], MSidebar.prototype, "fullHeight", void 0);
    MSidebar = __decorate([
        WithRender,
        Component({
            components: (_a = {},
                _a[I18N_NAME] = MI18n,
                _a[ICON_BUTTON_NAME] = MIconButton,
                _a),
            mixins: [Portal]
        })
    ], MSidebar);
    return MSidebar;
}(ModulVue));
export { MSidebar };
var SidebarPlugin = {
    install: function (v, options) {
        v.component(SIDEBAR_NAME, MSidebar);
    }
};
export default SidebarPlugin;
//# sourceMappingURL=sidebar.js.map