import _extends from "@babel/runtime/helpers/esm/extends";
import { __rest } from "tslib";
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import Tooltip from '../tooltip';
import { getRenderPropValue } from '../_util/getRenderPropValue';
import { getTransitionName } from '../_util/motion';
var Popover = /*#__PURE__*/React.forwardRef(function (_a, ref) {
  var customizePrefixCls = _a.prefixCls,
      title = _a.title,
      content = _a.content,
      _overlay = _a._overlay,
      otherProps = __rest(_a, ["prefixCls", "title", "content", "_overlay"]);

  var _React$useContext = React.useContext(ConfigContext),
      getPrefixCls = _React$useContext.getPrefixCls;

  var getOverlay = function getOverlay(prefixCls) {
    if (!title && !content) return undefined;
    return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-title")
    }, getRenderPropValue(title)), /*#__PURE__*/React.createElement("div", {
      className: "".concat(prefixCls, "-inner-content")
    }, getRenderPropValue(content)));
  };

  var prefixCls = getPrefixCls('popover', customizePrefixCls);
  var rootPrefixCls = getPrefixCls();
  return /*#__PURE__*/React.createElement(Tooltip, _extends({}, otherProps, {
    prefixCls: prefixCls,
    ref: ref,
    overlay: _overlay || getOverlay(prefixCls),
    transitionName: getTransitionName(rootPrefixCls, 'zoom-big', otherProps.transitionName)
  }));
});

if (process.env.NODE_ENV !== 'production') {
  Popover.displayName = 'Popover';
}

Popover.defaultProps = {
  placement: 'top',
  trigger: 'hover',
  mouseEnterDelay: 0.1,
  mouseLeaveDelay: 0.1,
  overlayStyle: {}
};
export default Popover;