"use strict";

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

var _configProvider = _interopRequireDefault(require("../config-provider"));

var _balloon = _interopRequireDefault(require("./balloon"));

var _popConfirm = _interopRequireDefault(require("./pop-confirm"));

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

var _inner = _interopRequireDefault(require("./inner"));

var _util = require("../util");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }

function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

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 _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

_balloon["default"].Tooltip = _configProvider["default"].config(_tooltip["default"], {
  transform:
  /* istanbul ignore next */
  function transform(props, deprecated) {
    if ('text' in props) {
      deprecated('text', 'children', 'Tooltip');

      var _props = props,
          text = _props.text,
          others = _objectWithoutProperties(_props, ["text"]);

      props = _objectSpread({
        children: text
      }, others);
    }

    return props;
  }
});
_balloon["default"].Inner = _inner["default"];
_balloon["default"].PopConfirm = _popConfirm["default"];

var _default = _configProvider["default"].config(_balloon["default"], {
  transform:
  /* istanbul ignore next */
  function transform(props, deprecated) {
    if (props.alignment) {
      deprecated('alignment', 'alignEdge', 'Balloon');

      var _props2 = props,
          alignment = _props2.alignment,
          others = _objectWithoutProperties(_props2, ["alignment"]);

      props = _objectSpread({
        alignEdge: alignment === 'edge'
      }, others);
    }

    if (props.onCloseClick) {
      deprecated('onCloseClick', 'onVisibleChange(visible, [type = "closeClick"])', 'Balloon');

      var _props3 = props,
          onCloseClick = _props3.onCloseClick,
          onVisibleChange = _props3.onVisibleChange,
          _others = _objectWithoutProperties(_props3, ["onCloseClick", "onVisibleChange"]);

      var newOnVisibleChange = function newOnVisibleChange(visible, type) {
        if (type === 'closeClick') {
          onCloseClick();
        }

        if (onVisibleChange) {
          onVisibleChange(visible, type);
        }
      };

      props = _objectSpread({
        onVisibleChange: newOnVisibleChange
      }, _others);
    }

    if ('triggerType' in props) {
      var triggerType = Array.isArray(props.triggerType) ? _toConsumableArray(props.triggerType) : [props.triggerType];

      if (triggerType.indexOf('focus') > -1) {
        _util.log.warning('triggerType[focus] is deprecated at [Balloon], use triggerType[hover, click] instead of it. If focus is desired maybe you should use [Balloon.Tooltip]');
      }
    }

    return props;
  }
});

exports["default"] = _default;