text: "use strict";
  
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports["default"] = void 0;
  
  var React = _interopRequireWildcard(require("react"));
  
  var _rcTooltip = _interopRequireDefault(require("rc-tooltip"));
  
  var _classnames = _interopRequireDefault(require("classnames"));
  
  var _placements = _interopRequireDefault(require("./placements"));
  
  var _reactNode = require("../_util/reactNode");
  
  var _configProvider = require("../config-provider");
  
  var _colors = require("../_util/colors");
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  
  function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  
  var splitObject = function splitObject(obj, keys) {
    var picked = {};
  
    var omitted = _extends({}, obj);
  
    keys.forEach(function (key) {
      if (obj && key in obj) {
        picked[key] = obj[key];
        delete omitted[key];
      }
    });
    return {
      picked: picked,
      omitted: omitted
    };
  };
  
  var PresetColorRegex = new RegExp("^(".concat(_colors.PresetColorTypes.join('|'), ")(-inverse)?$")); // Fix Tooltip won't hide at disabled button
  // mouse events don't trigger at disabled button in Chrome
  // https://github.com/react-component/tooltip/issues/18
  
  function getDisabledCompatibleChildren(element, prefixCls) {
    var elementType = element.type;
  
    if ((elementType.__ANT_BUTTON === true || elementType.__ANT_SWITCH === true || elementType.__ANT_CHECKBOX === true || element.type === 'button') && element.props.disabled) {
      // Pick some layout related style properties up to span
      // Prevent layout bugs like https://github.com/ant-design/ant-design/issues/5254
      var _splitObject = splitObject(element.props.style, ['position', 'left', 'right', 'top', 'bottom', 'float', 'display', 'zIndex']),
          picked = _splitObject.picked,
          omitted = _splitObject.omitted;
  
      var spanStyle = _extends(_extends({
        display: 'inline-block'
      }, picked), {
        cursor: 'not-allowed',
        width: element.props.block ? '100%' : null
      });
  
      var buttonStyle = _extends(_extends({}, omitted), {
        pointerEvents: 'none'
      });
  
      var child = (0, _reactNode.cloneElement)(element, {
        style: buttonStyle,
        className: null
      });
      return /*#__PURE__*/React.createElement("span", {
        style: spanStyle,
        className: (0, _classnames["default"])(element.props.className, "".concat(prefixCls, "-disabled-compatible-wrapper"))
      }, child);
    }
  
    return element;
  }
  
  var Tooltip = /*#__PURE__*/React.forwardRef(function (props, ref) {
    var _classNames2;
  
    var _React$useContext = React.useContext(_configProvider.ConfigContext),
        getContextPopupContainer = _React$useContext.getPopupContainer,
        getPrefixCls = _React$useContext.getPrefixCls,
        direction = _React$useContext.direction;
  
    var _React$useState = React.useState(!!props.visible || !!props.defaultVisible),
        _React$useState2 = _slicedToArray(_React$useState, 2),
        visible = _React$useState2[0],
        setVisible = _React$useState2[1];
  
    React.useEffect(function () {
      if ('visible' in props) {
        setVisible(props.visible);
      }
    }, [props.visible]);
  
    var isNoTitle = function isNoTitle() {
      var title = props.title,
          overlay = props.overlay;
      return !title && !overlay && title !== 0; // overlay for old version compatibility
    };
  
    var onVisibleChange = function onVisibleChange(vis) {
      if (!('visible' in props)) {
        setVisible(isNoTitle() ? false : vis);
      }
  
      if (props.onVisibleChange && !isNoTitle()) {
        props.onVisibleChange(vis);
      }
    };
  
    var getTooltipPlacements = function getTooltipPlacements() {
      var builtinPlacements = props.builtinPlacements,
          arrowPointAtCenter = props.arrowPointAtCenter,
          autoAdjustOverflow = props.autoAdjustOverflow;
      return builtinPlacements || (0, _placements["default"])({
        arrowPointAtCenter: arrowPointAtCenter,
        autoAdjustOverflow: autoAdjustOverflow
      });
    }; // 动态设置动画点
  
  
    var onPopupAlign = function onPopupAlign(domNode, align) {
      var placements = getTooltipPlacements(); // 当前返回的位置
  
      var placement = Object.keys(placements).filter(function (key) {
        return placements[key].points[0] === align.points[0] && placements[key].points[1] === align.points[1];
      })[0];
  
      if (!placement) {
        return;
      } // 根据当前坐标设置动画点
  
  
      var rect = domNode.getBoundingClientRect();
      var transformOrigin = {
        top: '50%',
        left: '50%'
      };
  
      if (placement.indexOf('top') >= 0 || placement.indexOf('Bottom') >= 0) {
        transformOrigin.top = "".concat(rect.height - align.offset[1], "px");
      } else if (placement.indexOf('Top') >= 0 || placement.indexOf('bottom') >= 0) {
        transformOrigin.top = "".concat(-align.offset[1], "px");
      }
  
      if (placement.indexOf('left') >= 0 || placement.indexOf('Right') >= 0) {
        transformOrigin.left = "".concat(rect.width - align.offset[0], "px");
      } else if (placement.indexOf('right') >= 0 || placement.indexOf('Left') >= 0) {
        transformOrigin.left = "".concat(-align.offset[0], "px");
      }
  
      domNode.style.transformOrigin = "".concat(transformOrigin.left, " ").concat(transformOrigin.top);
    };
  
    var getOverlay = function getOverlay() {
      var title = props.title,
          overlay = props.overlay;
  
      if (title === 0) {
        return title;
      }
  
      return overlay || title || '';
    };
  
    var customizePrefixCls = props.prefixCls,
        openClassName = props.openClassName,
        getPopupContainer = props.getPopupContainer,
        getTooltipContainer = props.getTooltipContainer,
        overlayClassName = props.overlayClassName,
        color = props.color,
        overlayInnerStyle = props.overlayInnerStyle;
    var children = props.children;
    var prefixCls = getPrefixCls('tooltip', customizePrefixCls);
    var tempVisible = visible; // Hide tooltip when there is no title
  
    if (!('visible' in props) && isNoTitle()) {
      tempVisible = false;
    }
  
    var child = getDisabledCompatibleChildren((0, _reactNode.isValidElement)(children) ? children : /*#__PURE__*/React.createElement("span", null, children), prefixCls);
    var childProps = child.props;
    var childCls = (0, _classnames["default"])(childProps.className, _defineProperty({}, openClassName || "".concat(prefixCls, "-open"), true));
    var customOverlayClassName = (0, _classnames["default"])(overlayClassName, (_classNames2 = {}, _defineProperty(_classNames2, "".concat(prefixCls, "-rtl"), direction === 'rtl'), _defineProperty(_classNames2, "".concat(prefixCls, "-").concat(color), color && PresetColorRegex.test(color)), _classNames2));
    var formattedOverlayInnerStyle;
    var arrowContentStyle;
  
    if (color && !PresetColorRegex.test(color)) {
      formattedOverlayInnerStyle = _extends(_extends({}, overlayInnerStyle), {
        background: color
      });
      arrowContentStyle = {
        background: color
      };
    }
  
    return /*#__PURE__*/React.createElement(_rcTooltip["default"], _extends({}, props, {
      prefixCls: prefixCls,
      overlayClassName: customOverlayClassName,
      getTooltipContainer: getPopupContainer || getTooltipContainer || getContextPopupContainer,
      ref: ref,
      builtinPlacements: getTooltipPlacements(),
      overlay: getOverlay(),
      visible: tempVisible,
      onVisibleChange: onVisibleChange,
      onPopupAlign: onPopupAlign,
      overlayInnerStyle: formattedOverlayInnerStyle,
      arrowContent: /*#__PURE__*/React.createElement("span", {
        className: "".concat(prefixCls, "-arrow-content"),
        style: arrowContentStyle
      })
    }), tempVisible ? (0, _reactNode.cloneElement)(child, {
      className: childCls
    }) : child);
  });
  Tooltip.displayName = 'Tooltip';
  Tooltip.defaultProps = {
    placement: 'top',
    transitionName: 'zoom-big-fast',
    mouseEnterDelay: 0.1,
    mouseLeaveDelay: 0.1,
    arrowPointAtCenter: false,
    autoAdjustOverflow: true
  };
  var _default = Tooltip;
  exports["default"] = _default;