"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 _vue = _interopRequireWildcard(require("vue"));

var _classNames2 = _interopRequireDefault(require("../_util/classNames"));

var _Modal = _interopRequireDefault(require("./Modal"));

var _ActionButton = _interopRequireDefault(require("./ActionButton"));

var _locale = require("./locale");

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

var ConfirmDialog = function ConfirmDialog(_, _ref) {
  var attrs = _ref.attrs;
  var icon = attrs.icon,
      onCancel = attrs.onCancel,
      onOk = attrs.onOk,
      close = attrs.close,
      zIndex = attrs.zIndex,
      afterClose = attrs.afterClose,
      visible = attrs.visible,
      keyboard = attrs.keyboard,
      centered = attrs.centered,
      getContainer = attrs.getContainer,
      maskStyle = attrs.maskStyle,
      okButtonProps = attrs.okButtonProps,
      cancelButtonProps = attrs.cancelButtonProps,
      _attrs$closable = attrs.closable,
      closable = _attrs$closable === void 0 ? false : _attrs$closable;
  var okType = attrs.okType || 'primary';
  var prefixCls = attrs.prefixCls || 'ant-modal';
  var contentPrefixCls = "".concat(prefixCls, "-confirm"); // 默认为 true，保持向下兼容

  var okCancel = 'okCancel' in attrs ? attrs.okCancel : true;
  var width = attrs.width || 416;
  var style = attrs.style || {};
  var mask = attrs.mask === undefined ? true : attrs.mask; // 默认为 false，保持旧版默认行为

  var maskClosable = attrs.maskClosable === undefined ? false : attrs.maskClosable;
  var runtimeLocale = (0, _locale.getConfirmLocale)();
  var okText = attrs.okText || (okCancel ? runtimeLocale.okText : runtimeLocale.justOkText);
  var cancelText = attrs.cancelText || runtimeLocale.cancelText;
  var autoFocusButton = attrs.autoFocusButton === null ? false : attrs.autoFocusButton || 'ok';
  var transitionName = attrs.transitionName || 'zoom';
  var maskTransitionName = attrs.maskTransitionName || 'fade';
  var classString = (0, _classNames2.default)(contentPrefixCls, "".concat(contentPrefixCls, "-").concat(attrs.type), "".concat(prefixCls, "-").concat(attrs.type), attrs.class);

  var cancelButton = okCancel && _vue.createVNode(_ActionButton.default, {
    "actionFn": onCancel,
    "closeModal": close,
    "autofocus": autoFocusButton === 'cancel',
    "buttonProps": cancelButtonProps
  }, {
    default: function _default() {
      return [cancelText];
    }
  });

  return _vue.createVNode(_Modal.default, {
    "prefixCls": prefixCls,
    "class": classString,
    "wrapClassName": (0, _classNames2.default)(_defineProperty({}, "".concat(contentPrefixCls, "-centered"), !!centered)),
    "onCancel": function onCancel(e) {
      return close({
        triggerCancel: true
      }, e);
    },
    "visible": visible,
    "closable": closable,
    "title": "",
    "transitionName": transitionName,
    "footer": "",
    "maskTransitionName": maskTransitionName,
    "mask": mask,
    "maskClosable": maskClosable,
    "maskStyle": maskStyle,
    "style": style,
    "width": width,
    "zIndex": zIndex,
    "afterClose": afterClose,
    "keyboard": keyboard,
    "centered": centered,
    "getContainer": getContainer
  }, {
    default: function _default() {
      return [_vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-body-wrapper")
      }, [_vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-body")
      }, [typeof icon === 'function' ? icon() : icon, attrs.title === undefined ? null : _vue.createVNode("span", {
        "class": "".concat(contentPrefixCls, "-title")
      }, [attrs.title]), _vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-content")
      }, [typeof attrs.content === 'function' ? attrs.content() : attrs.content])]), _vue.createVNode("div", {
        "class": "".concat(contentPrefixCls, "-btns")
      }, [cancelButton, _vue.createVNode(_ActionButton.default, {
        "type": okType,
        "actionFn": onOk,
        "closeModal": close,
        "autofocus": autoFocusButton === 'ok',
        "buttonProps": okButtonProps
      }, {
        default: function _default() {
          return [okText];
        }
      })])])];
    }
  });
};

ConfirmDialog.inheritAttrs = false;
var _default2 = ConfirmDialog;
exports.default = _default2;