var _a, _b;
import { __decorate, __extends } from "tslib";
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { I18N_NAME as I18N_FILTER_NAME } from '../../filters/filter-names';
import { i18nFilter } from '../../filters/i18n/i18n';
import { BackdropMode, Portal, PortalTransitionDuration } from '../../mixins/portal/portal';
import UserAgentUtil from '../../utils/user-agent/user-agent';
import { ModulVue } from '../../utils/vue/vue';
import { MButton } from '../button/button';
import { BUTTON_NAME, I18N_NAME, OVERLAY_NAME } from '../component-names';
import { MI18n } from '../i18n/i18n';
import WithRender from './overlay.html?style=./overlay.scss';
var MOverlay = /** @class */ (function (_super) {
    __extends(MOverlay, _super);
    function MOverlay() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.hasKeyboard = false;
        return _this;
    }
    MOverlay.prototype.emitSave = function (event) { };
    MOverlay.prototype.emitCancel = function (event) { };
    MOverlay.prototype.mounted = function () {
        this.as().transitionDuration = PortalTransitionDuration.Regular + PortalTransitionDuration.XSlow;
    };
    Object.defineProperty(MOverlay.prototype, "popupBody", {
        get: function () {
            return (this.$refs.article).querySelector('.m-popup__body');
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MOverlay.prototype, "isAndroid", {
        get: function () {
            return UserAgentUtil.isAndroid();
        },
        enumerable: false,
        configurable: true
    });
    MOverlay.prototype.isFocusableTextBox = function (element) {
        var type = element.getAttribute('type');
        return (element.tagName === 'INPUT'
            && type !== 'checkbox'
            && type !== 'radio'
            && type !== 'button'
            && type !== 'reset'
            && type !== 'file') || element.tagName === 'TEXTAREA';
    };
    MOverlay.prototype.onFocusIn = function (event) {
        if (this.isAndroid
            && this.isFocusableTextBox(event.target)) {
            this.hasKeyboard = true;
        }
    };
    MOverlay.prototype.onFocusOut = function (event) {
        if (!this.isAndroid) {
            return;
        }
        this.hasKeyboard = false;
    };
    MOverlay.prototype.handlesFocus = function () {
        return this.focusManagement;
    };
    MOverlay.prototype.doCustomPropOpen = function (value) {
        return false;
    };
    MOverlay.prototype.getBackdropMode = function () {
        return BackdropMode.ScrollOnly;
    };
    MOverlay.prototype.getPortalElement = function () {
        return this.$refs.article;
    };
    Object.defineProperty(MOverlay.prototype, "isSaveButtonDisabled", {
        get: function () {
            return this.disableSaveButton;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MOverlay.prototype, "isWaiting", {
        get: function () {
            return this.waiting;
        },
        enumerable: false,
        configurable: true
    });
    MOverlay.prototype.save = function (event) {
        this.emitSave(event);
    };
    MOverlay.prototype.cancel = function (event) {
        this.emitCancel(event);
        this.close();
    };
    MOverlay.prototype.close = function () {
        this.as().tryClose();
    };
    __decorate([
        Prop({ default: true })
    ], MOverlay.prototype, "focusManagement", void 0);
    __decorate([
        Prop({ default: true })
    ], MOverlay.prototype, "padding", void 0);
    __decorate([
        Prop({ default: true })
    ], MOverlay.prototype, "paddingHeader", void 0);
    __decorate([
        Prop({ default: true })
    ], MOverlay.prototype, "paddingBody", void 0);
    __decorate([
        Prop({ default: true })
    ], MOverlay.prototype, "paddingFooter", void 0);
    __decorate([
        Prop({ default: false })
    ], MOverlay.prototype, "disableSaveButton", void 0);
    __decorate([
        Prop({ default: false })
    ], MOverlay.prototype, "waiting", void 0);
    __decorate([
        Prop({ default: false })
    ], MOverlay.prototype, "hideFooter", void 0);
    __decorate([
        Emit('save')
    ], MOverlay.prototype, "emitSave", null);
    __decorate([
        Emit('cancel')
    ], MOverlay.prototype, "emitCancel", null);
    MOverlay = __decorate([
        WithRender,
        Component({
            components: (_a = {},
                _a[BUTTON_NAME] = MButton,
                _a[I18N_NAME] = MI18n,
                _a),
            filters: (_b = {},
                _b[I18N_FILTER_NAME] = i18nFilter,
                _b),
            mixins: [Portal]
        })
    ], MOverlay);
    return MOverlay;
}(ModulVue));
export { MOverlay };
var OverlayPlugin = {
    install: function (v, options) {
        v.component(OVERLAY_NAME, MOverlay);
    }
};
export default OverlayPlugin;
//# sourceMappingURL=overlay.js.map