"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ModalBase = exports.ModalBaseComponent = void 0;
const react_1 = __importDefault(require("react"));
// TODO @grsmto: might be worth migrating to react-pose once https://github.com/reach/reach-ui/issues/126 is fixed
const renderprops_cjs_1 = require("react-spring/renderprops.cjs");
const polished_1 = require("polished");
const styles_1 = require("../../styles");
const sc = __importStar(require("./styles"));
exports.ModalBaseComponent = ({ children, isOpen: isOpenProps, isCloseable, isCentered, onClose, theme, }) => {
    const handleCloseRequest = () => {
        if (!isCloseable) {
            return;
        }
        if (onClose) {
            onClose();
        }
    };
    return (react_1.default.createElement(renderprops_cjs_1.Transition, { items: isOpenProps, from: { background: polished_1.transparentize(1, theme.colors.gray[1]) }, enter: { background: polished_1.transparentize(0.7, theme.colors.gray[1]) }, leave: { background: polished_1.transparentize(1, theme.colors.gray[1]) } }, (isOpen) => isOpen &&
        ((styles) => (react_1.default.createElement(sc.Overlay, { style: styles, onDismiss: handleCloseRequest, isCentered: isCentered }, children)))));
};
exports.ModalBase = styles_1.withTheme(exports.ModalBaseComponent);
exports.ModalBase.defaultProps = {
    isOpen: false,
    isCloseable: true,
    isCentered: true,
};
//# sourceMappingURL=ModalBase.js.map