import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import React from 'react';
import classNames from 'classnames';
import { ConfigContext } from '../config-provider/context';
import Tooltip from '../tooltip';
var Popover = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var customPrefix = props.prefixCls,
      overlayClassName = props.overlayClassName,
      size = props.size,
      title = props.title,
      content = props.content,
      width = props.width,
      overlayInnerStyle = props.overlayInnerStyle,
      resetProps = _objectWithoutProperties(props, ["prefixCls", "overlayClassName", "size", "title", "content", "width", "overlayInnerStyle"]);

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

  var popOverCls = getPrefixClassName('popover', customPrefix);
  var overlayCls = classNames(overlayClassName, _defineProperty({}, "".concat(popOverCls, "-").concat(size), size));

  var renderTitle = function renderTitle(overlayPrefix) {
    return title && /*#__PURE__*/React.createElement("div", {
      className: "".concat(overlayPrefix, "-title")
    }, /*#__PURE__*/React.createElement("span", null, title));
  };

  var renderCustomOverlay = function renderCustomOverlay() {
    var overlayPrefix = "".concat(popOverCls, "-customOverlay");
    return /*#__PURE__*/React.createElement("div", {
      className: overlayPrefix
    }, renderTitle(overlayPrefix), /*#__PURE__*/React.createElement("div", {
      className: "".concat(overlayPrefix, "-content")
    }, /*#__PURE__*/React.createElement("span", null, content)));
  };

  return /*#__PURE__*/React.createElement(Tooltip, Object.assign({
    ref: ref,
    prefixCls: popOverCls,
    overlayClassName: overlayCls,
    overlayInnerStyle: typeof width !== 'undefined' ? _objectSpread({
      width: width,
      maxWidth: 'none'
    }, overlayInnerStyle) : overlayInnerStyle,
    overlay: renderCustomOverlay()
  }, resetProps));
});
Popover.defaultProps = {
  white: true
};
export default Popover;