"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var commons_1 = require("@universal-login/commons");
var Notice_1 = require("../commons/Notice");
var classFor_1 = require("../utils/classFor");
require("./../styles/modal.sass");
require("./../styles/modalDefaults.sass");
require("./../styles/themes/UniLogin/modalThemeUniLogin.sass");
require("./../styles/themes/Legacy/modalThemeLegacy.sass");
require("./../styles/themes/Jarvis/modalThemeJarvis.sass");
exports.ModalWrapper = function (_a) {
    var children = _a.children, modalClassName = _a.modalClassName, hideModal = _a.hideModal, message = _a.message;
    var listenKeyboard = function (event) {
        if (commons_1.escapePressed(event) && hideModal) {
            hideModal();
        }
    };
    react_1.useEffect(function () {
        window.addEventListener('keydown', listenKeyboard, true);
        return function () {
            window.removeEventListener('keydown', listenKeyboard, true);
        };
    });
    return (react_1.default.createElement("div", { className: modalClassName ? "universal-login " + modalClassName : 'universal-login universal-login-default' },
        react_1.default.createElement("div", { className: "modal-overlay", onClick: hideModal }),
        react_1.default.createElement("div", { className: classFor_1.useThemeClassFor() + " modal-wrapper" },
            react_1.default.createElement("div", { className: "modal" },
                !!hideModal && react_1.default.createElement("button", { onClick: hideModal, className: "modal-close-btn" }),
                children),
            react_1.default.createElement(Notice_1.Notice, { message: message }))));
};
//# sourceMappingURL=ModalWrapper.js.map