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

import ConfigProvider from '../config-provider';
import { log } from '../util';
import Dialog from './dialog';
import StepDialog from './step-dialog';
import StepView from './step-view';
import Inner from './inner';
import { show, notice, warning, error, success } from './show';
Dialog.Inner = ConfigProvider.config(Inner);
Dialog.StepDialog = StepDialog;
Dialog.StepView = StepView;

Dialog.show = function (config) {
  var _ConfigProvider$getCo = ConfigProvider.getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo.warning;

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

  return show(config);
};

Dialog.notice = function (config) {
  var _ConfigProvider$getCo2 = ConfigProvider.getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo2.warning;

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

  return notice(config);
};

Dialog.warning = function (config) {
  var _ConfigProvider$getCo3 = ConfigProvider.getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo3.warning;

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

  return warning(config);
};

Dialog.error = function (config) {
  var _ConfigProvider$getCo4 = ConfigProvider.getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo4.warning;

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

  return error(config);
};

Dialog.success = function (config) {
  var _ConfigProvider$getCo5 = ConfigProvider.getContextProps(config, 'Dialog'),
      ctxWarning = _ConfigProvider$getCo5.warning;

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

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

export default ConfigProvider.config(Dialog, {
  transform: function transform(props, deprecated) {
    return processProps(props, deprecated);
  }
});