"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    DialogWrap: function() {
        return DialogWrap;
    },
    defaultDialogWrapProps: function() {
        return defaultDialogWrapProps;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _react = /*#__PURE__*/ _interop_require_default._(require("react"));
var _reacttransitiongroup = require("react-transition-group");
var _content = require("./content");
var _overlay = require("../overlay/overlay");
var _overlay1 = /*#__PURE__*/ _interop_require_default._(require("../overlay"));
var defaultDialogWrapProps = (0, _object_spread_props._)((0, _object_spread._)({}, _overlay.defaultOverlayProps, _content.defaultContentProps), {
    overlay: true,
    overlayStyle: {},
    overlayClassName: 'nut-dialog-overlay',
    onCancel: function onCancel() {},
    onClose: function onClose() {},
    onOverlayClick: function onOverlayClick() {
        return true;
    }
});
var DialogWrap = function DialogWrap(props) {
    var _ref = (0, _object_spread._)({}, defaultDialogWrapProps, props), visible = _ref.visible, overlay = _ref.overlay, overlayStyle = _ref.overlayStyle, overlayClassName = _ref.overlayClassName, closeOnOverlayClick = _ref.closeOnOverlayClick, lockScroll = _ref.lockScroll, zIndex = _ref.zIndex, onClose = _ref.onClose, onCancel = _ref.onCancel, onOverlayClick = _ref.onOverlayClick, restProps = (0, _object_without_properties._)(_ref, [
        "visible",
        "overlay",
        "overlayStyle",
        "overlayClassName",
        "closeOnOverlayClick",
        "lockScroll",
        "zIndex",
        "onClose",
        "onCancel",
        "onOverlayClick"
    ]);
    var onHandleClickOverlay = function onHandleClickOverlay(e) {
        if (closeOnOverlayClick && visible && e.target === e.currentTarget) {
            var closed = onOverlayClick && onOverlayClick(e);
            closed && (onClose === null || onClose === void 0 ? void 0 : onClose());
            closed && (onCancel === null || onCancel === void 0 ? void 0 : onCancel());
        }
    };
    return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, overlay && /*#__PURE__*/ _react.default.createElement(_overlay1.default, {
        zIndex: zIndex,
        style: overlayStyle,
        className: overlayClassName,
        visible: visible,
        closeOnOverlayClick: closeOnOverlayClick,
        lockScroll: lockScroll,
        onClick: onHandleClickOverlay
    }), /*#__PURE__*/ _react.default.createElement(_reacttransitiongroup.CSSTransition, {
        in: visible,
        timeout: 300,
        classNames: "fadeDialog",
        unmountOnExit: true,
        appear: true
    }, /*#__PURE__*/ _react.default.createElement(_content.Content, (0, _object_spread_props._)((0, _object_spread._)({}, restProps), {
        visible: visible
    }))));
};
DialogWrap.displayName = 'NutDialogWrap';
