var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
import React, { useContext, useRef } from "react";
import { CSSTransition } from "react-transition-group";
import classnames from "classnames";
import { useLockScroll } from "../hooks/use-lock-scroll";
import { isDef } from "../utils";
import ConfigProviderContext from "../config-provider/ConfigProviderContext";
const Overlay = (props) => {
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace("overlay", prefixCls);
  const nodeRef = useRef(null);
  useLockScroll(nodeRef, props.visible && props.lockScroll);
  const {
    visible,
    duration,
    customStyle,
    children
  } = props;
  const renderOverlay = () => {
    const style = __spreadValues(__spreadValues({
      zIndex: props.zIndex !== void 0 ? +props.zIndex : void 0
    }, props.style), customStyle);
    if (isDef(duration)) {
      style.animationDuration = `${duration}ms`;
    }
    return /* @__PURE__ */ React.createElement("div", {
      ref: nodeRef,
      style,
      onClick: props.onClick,
      className: classnames(bem(), props.className)
    }, children);
  };
  return /* @__PURE__ */ React.createElement(CSSTransition, {
    nodeRef,
    mountOnEnter: true,
    unmountOnExit: true,
    in: visible,
    timeout: duration,
    classNames: "rc-fade"
  }, renderOverlay());
};
Overlay.defaultProps = {
  lockScroll: true,
  duration: 300
};
var stdin_default = Overlay;
export {
  stdin_default as default
};
