'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var CloseOutlined = require('@ant-design/icons-vue');
var ActionButton = require('../_util/components/ActionButton.js');
var classNames = require('../_util/classNames.js');
var LocaleReceiver = require('../locale-provider/LocaleReceiver.js');
var transition = require('../_util/components/transition.js');
var warning = require('../_util/warning.js');
var Modal = require('./Modal.js');

function _isSlot(s) {
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !vue.isVNode(s);
}
function renderSomeContent(someContent) {
  if (typeof someContent === "function")
    return someContent();
  return someContent;
}
var ConfirmDialog = /* @__PURE__ */ vue.defineComponent({
  name: "ConfirmDialog",
  inheritAttrs: false,
  props: ["icon", "onCancel", "onOk", "close", "closable", "zIndex", "afterClose", "visible", "open", "keyboard", "centered", "getContainer", "maskStyle", "okButtonProps", "cancelButtonProps", "okType", "prefixCls", "okCancel", "width", "mask", "maskClosable", "okText", "cancelText", "autoFocusButton", "transitionName", "maskTransitionName", "type", "title", "content", "direction", "rootPrefixCls", "bodyStyle", "closeIcon", "modalRender", "focusTriggerAfterClose", "wrapClassName", "confirmPrefixCls", "footer"],
  setup(props, {
    attrs
  }) {
    const [locale] = LocaleReceiver.useLocaleReceiver("Modal");
    if (process.env.NODE_ENV !== "production") {
      warning.default(props.visible === void 0, "Modal", "`visible` is deprecated, please use `open` instead.");
    }
    return () => {
      const {
        icon,
        onCancel,
        onOk,
        close,
        closable = false,
        zIndex,
        afterClose,
        keyboard,
        centered,
        getContainer,
        maskStyle,
        okButtonProps,
        cancelButtonProps,
        okCancel,
        width = 416,
        mask = true,
        maskClosable = false,
        type,
        open,
        title,
        content,
        direction,
        closeIcon,
        modalRender,
        focusTriggerAfterClose,
        rootPrefixCls,
        bodyStyle,
        wrapClassName,
        footer
      } = props;
      let mergedIcon = icon;
      if (!icon && icon !== null) {
        switch (type) {
          case "info":
            mergedIcon = vue.createVNode(CloseOutlined.InfoCircleFilled, null, null);
            break;
          case "success":
            mergedIcon = vue.createVNode(CloseOutlined.CheckCircleFilled, null, null);
            break;
          case "error":
            mergedIcon = vue.createVNode(CloseOutlined.CloseCircleFilled, null, null);
            break;
          default:
            mergedIcon = vue.createVNode(CloseOutlined.ExclamationCircleFilled, null, null);
        }
      }
      const okType = props.okType || "primary";
      const prefixCls = props.prefixCls || "ant-modal";
      const contentPrefixCls = `${prefixCls}-confirm`;
      const style = attrs.style || {};
      const okText = renderSomeContent(props.okText) || (okCancel ? locale.value.okText : locale.value.justOkText);
      const mergedOkCancel = okCancel != null ? okCancel : type === "confirm";
      const autoFocusButton = props.autoFocusButton === null ? false : props.autoFocusButton || "ok";
      const confirmPrefixCls = `${prefixCls}-confirm`;
      const classString = classNames.default(confirmPrefixCls, `${confirmPrefixCls}-${props.type}`, {
        [`${confirmPrefixCls}-rtl`]: direction === "rtl"
      }, attrs.class);
      const cancelButton = mergedOkCancel && vue.createVNode(ActionButton.default, {
        "actionFn": onCancel,
        "close": close,
        "autofocus": autoFocusButton === "cancel",
        "buttonProps": cancelButtonProps,
        "prefixCls": `${rootPrefixCls}-btn`
      }, {
        default: () => [renderSomeContent(props.cancelText) || locale.value.cancelText]
      });
      return vue.createVNode(Modal.default, {
        "prefixCls": prefixCls,
        "class": classString,
        "wrapClassName": classNames.default({
          [`${confirmPrefixCls}-centered`]: !!centered
        }, wrapClassName),
        "onCancel": (e) => close == null ? void 0 : close({
          triggerCancel: true
        }, e),
        "open": open,
        "title": "",
        "footer": "",
        "transitionName": transition.getTransitionName(rootPrefixCls, "zoom", props.transitionName),
        "maskTransitionName": transition.getTransitionName(rootPrefixCls, "fade", props.maskTransitionName),
        "mask": mask,
        "maskClosable": maskClosable,
        "maskStyle": maskStyle,
        "style": style,
        "bodyStyle": bodyStyle,
        "width": width,
        "zIndex": zIndex,
        "afterClose": afterClose,
        "keyboard": keyboard,
        "centered": centered,
        "getContainer": getContainer,
        "closable": closable,
        "closeIcon": closeIcon,
        "modalRender": modalRender,
        "focusTriggerAfterClose": focusTriggerAfterClose
      }, {
        default: () => [vue.createVNode("div", {
          "class": `${contentPrefixCls}-body-wrapper`
        }, [vue.createVNode("div", {
          "class": `${contentPrefixCls}-body`
        }, [renderSomeContent(mergedIcon), title === void 0 ? null : vue.createVNode("span", {
          "class": `${contentPrefixCls}-title`
        }, [renderSomeContent(title)]), vue.createVNode("div", {
          "class": `${contentPrefixCls}-content`
        }, [renderSomeContent(content)])]), footer !== void 0 ? renderSomeContent(footer) : vue.createVNode("div", {
          "class": `${contentPrefixCls}-btns`
        }, [cancelButton, vue.createVNode(ActionButton.default, {
          "type": okType,
          "actionFn": onOk,
          "close": close,
          "autofocus": autoFocusButton === "ok",
          "buttonProps": okButtonProps,
          "prefixCls": `${rootPrefixCls}-btn`
        }, _isSlot(okText) ? okText : {
          default: () => [okText]
        })])])]
      });
    };
  }
});

exports.default = ConfirmDialog;
//# sourceMappingURL=ConfirmDialog.js.map
