"use strict";

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

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

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

var _dialog = _interopRequireDefault(require("./dialog"));

var _stepDialog = _interopRequireDefault(require("./step-dialog"));

var _stepView = _interopRequireDefault(require("./step-view"));

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

var _show = require("./show");

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

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; }

_dialog["default"].Inner = _configProvider["default"].config(_inner["default"]);
_dialog["default"].StepDialog = _stepDialog["default"];
_dialog["default"].StepView = _stepView["default"];

_dialog["default"].show = function (config) {
  var _ConfigProvider$getCo = _configProvider["default"].getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo.warning;

  if (ctxWarning !== false) {
    config = processProps(config, _util.log.deprecated);
  }

  return (0, _show.show)(config);
};

_dialog["default"].notice = function (config) {
  var _ConfigProvider$getCo2 = _configProvider["default"].getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo2.warning;

  if (ctxWarning !== false) {
    config = processProps(config, _util.log.deprecated);
  }

  return (0, _show.notice)(config);
};

_dialog["default"].warning = function (config) {
  var _ConfigProvider$getCo3 = _configProvider["default"].getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo3.warning;

  if (ctxWarning !== false) {
    config = processProps(config, _util.log.deprecated);
  }

  return (0, _show.warning)(config);
};

_dialog["default"].error = function (config) {
  var _ConfigProvider$getCo4 = _configProvider["default"].getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo4.warning;

  if (ctxWarning !== false) {
    config = processProps(config, _util.log.deprecated);
  }

  return (0, _show.error)(config);
};

_dialog["default"].success = function (config) {
  var _ConfigProvider$getCo5 = _configProvider["default"].getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo5.warning;

  if (ctxWarning !== false) {
    config = processProps(config, _util.log.deprecated);
  }

  return (0, _show.success)(config);
};
/* istanbul ignore next */


function processProps(props, deprecated) {
  if ('closable' in props) {
    deprecated('closable', 'closeable', 'Dialog');

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

    props = _objectSpread({
      closeable: closable
    }, others);
  }

  var overlayPropNames = ['target', 'offset', 'beforeOpen', 'onOpen', 'afterOpen', 'beforePosition', 'onPosition', 'cache', 'safeNode', 'wrapperClassName', 'container'];
  overlayPropNames.forEach(function (name) {
    if (name in props) {
      deprecated(name, "overlayProps.".concat(name), 'Dialog');

      var _props2 = props,
          overlayProps = _props2.overlayProps,
          _others = _objectWithoutProperties(_props2, ["overlayProps"]);

      var newOverlayProps = _objectSpread(_defineProperty({}, name, props[name]), overlayProps || {});

      delete _others[name];
      props = _objectSpread({
        overlayProps: newOverlayProps
      }, _others);
    }
  });
  return props;
}

var _default = _configProvider["default"].config(_dialog["default"], {
  transform: function transform(props, deprecated) {
    return processProps(props, deprecated);
  }
});

exports["default"] = _default;