"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _context = require("../config-provider/context");

var _tooltip = _interopRequireDefault(require("../tooltip"));

var Popover = /*#__PURE__*/_react.default.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 = (0, _objectWithoutProperties2.default)(props, ["prefixCls", "overlayClassName", "size", "title", "content", "width", "overlayInnerStyle"]);

  var _React$useContext = _react.default.useContext(_context.ConfigContext),
      getPrefixClassName = _React$useContext.getPrefixClassName;

  var popOverCls = getPrefixClassName('popover', customPrefix);
  var overlayCls = (0, _classnames.default)(overlayClassName, (0, _defineProperty2.default)({}, "".concat(popOverCls, "-").concat(size), size));

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

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

  return /*#__PURE__*/_react.default.createElement(_tooltip.default, Object.assign({
    ref: ref,
    prefixCls: popOverCls,
    overlayClassName: overlayCls,
    overlayInnerStyle: typeof width !== 'undefined' ? (0, _objectSpread2.default)({
      width: width,
      maxWidth: 'none'
    }, overlayInnerStyle) : overlayInnerStyle,
    overlay: renderCustomOverlay()
  }, resetProps));
});

Popover.defaultProps = {
  white: true
};
var _default = Popover;
exports.default = _default;