var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  default: () => stdin_default
});
module.exports = __toCommonJS(stdin_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_popup = __toESM(require("../popup"));
var import_button = __toESM(require("../button"));
var import_action_bar = __toESM(require("../action-bar"));
var import_utils = require("../utils");
var import_constant = require("../utils/constant");
var import_ConfigProviderContext = __toESM(require("../config-provider/ConfigProviderContext"));
function _extends() {
  _extends = Object.assign ? Object.assign.bind() : function(target) {
    for (var i = 1; i < arguments.length; i++) {
      var source = arguments[i];
      for (var key in source) {
        if (Object.prototype.hasOwnProperty.call(source, key)) {
          target[key] = source[key];
        }
      }
    }
    return target;
  };
  return _extends.apply(this, arguments);
}
const Dialog = (props) => {
  const {
    prefixCls,
    createNamespace
  } = (0, import_react.useContext)(import_ConfigProviderContext.default);
  const [bem] = createNamespace("dialog", prefixCls);
  const _a = props, {
    width,
    title,
    theme,
    visible,
    message,
    className,
    messageAlign,
    closeOnClickOverlay,
    onClickCloseIcon
  } = _a, others = __objRest(_a, [
    "width",
    "title",
    "theme",
    "visible",
    "message",
    "className",
    "messageAlign",
    "closeOnClickOverlay",
    "onClickCloseIcon"
  ]);
  const renderTitle = () => {
    if (props.title) {
      return /* @__PURE__ */ import_react.default.createElement("div", {
        className: (0, import_classnames.default)(bem("header", {
          isolated: !props.message && !props.children
        }))
      }, title);
    }
    return null;
  };
  const renderContent = () => {
    if (props.children) {
      return /* @__PURE__ */ import_react.default.createElement("div", {
        className: (0, import_classnames.default)(bem("content"))
      }, props.children);
    }
    if (message) {
      return /* @__PURE__ */ import_react.default.createElement("div", {
        className: (0, import_classnames.default)(bem("content", {
          isolated: !title
        }))
      }, /* @__PURE__ */ import_react.default.createElement("div", {
        className: (0, import_classnames.default)(bem("message", {
          "has-title": title,
          [messageAlign]: messageAlign
        }))
      }, message));
    }
    return null;
  };
  const renderButtons = () => {
    var _a2, _b, _c, _d, _e, _f;
    return /* @__PURE__ */ import_react.default.createElement("div", {
      className: (0, import_classnames.default)(import_constant.BORDER_TOP, bem("footer"))
    }, props.showCancelButton && /* @__PURE__ */ import_react.default.createElement(import_button.default, {
      size: "large",
      text: props.cancelButtonText || "\u53D6\u6D88",
      className: (0, import_classnames.default)(bem("cancel")),
      style: {
        color: props.cancelButtonColor
      },
      loading: (_a2 = props.cancelProps) == null ? void 0 : _a2.loading,
      disabled: (_b = props.cancelProps) == null ? void 0 : _b.disabled,
      onClick: ((_c = props.cancelProps) == null ? void 0 : _c.loading) ? import_utils.noop : props.onCancel
    }), props.showConfirmButton && /* @__PURE__ */ import_react.default.createElement(import_button.default, {
      size: "large",
      text: props.confirmButtonText || "\u786E\u8BA4",
      className: (0, import_classnames.default)(bem("confirm"), {
        [import_constant.BORDER_LEFT]: props.showCancelButton
      }),
      round: theme === "round-button",
      style: {
        color: props.confirmButtonColor
      },
      loading: (_d = props.confirmProps) == null ? void 0 : _d.loading,
      disabled: (_e = props.confirmProps) == null ? void 0 : _e.disabled,
      onClick: ((_f = props.confirmProps) == null ? void 0 : _f.loading) ? import_utils.noop : props.onConfirm
    }));
  };
  const renderRoundButtons = () => {
    var _a2, _b, _c, _d, _e, _f;
    return /* @__PURE__ */ import_react.default.createElement(import_action_bar.default, {
      className: (0, import_classnames.default)(bem("footer"))
    }, props.showCancelButton && /* @__PURE__ */ import_react.default.createElement(import_action_bar.default.Button, {
      type: "warning",
      text: props.cancelButtonText || "\u53D6\u6D88",
      className: (0, import_classnames.default)(bem("cancel")),
      color: props.cancelButtonColor,
      loading: (_a2 = props.cancelProps) == null ? void 0 : _a2.loading,
      disabled: (_b = props.cancelProps) == null ? void 0 : _b.disabled,
      onClick: ((_c = props.cancelProps) == null ? void 0 : _c.loading) ? import_utils.noop : props.onCancel
    }), props.showConfirmButton && /* @__PURE__ */ import_react.default.createElement(import_action_bar.default.Button, {
      type: "danger",
      text: props.confirmButtonText || "\u786E\u8BA4",
      className: (0, import_classnames.default)(bem("confirm")),
      color: props.confirmButtonColor,
      loading: (_d = props.confirmProps) == null ? void 0 : _d.loading,
      disabled: (_e = props.confirmProps) == null ? void 0 : _e.disabled,
      onClick: ((_f = props.confirmProps) == null ? void 0 : _f.loading) ? import_utils.noop : props.onConfirm
    }));
  };
  const renderFooter = () => {
    if (props.footer)
      return props.footer;
    return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  };
  return /* @__PURE__ */ import_react.default.createElement(import_popup.default, _extends({}, others, {
    visible,
    className: (0, import_classnames.default)(bem([theme]), className),
    style: {
      width: (0, import_utils.addUnit)(width)
    },
    "aria-labelledby": title || message,
    closeOnClickOverlay,
    onOpen: props.onOpen,
    onOpened: props.onOpened,
    onClose: props.onClose,
    onClosed: props.onClosed
  }), renderTitle(), renderContent(), renderFooter());
};
Dialog.defaultProps = {
  transition: "rc-dialog-bounce",
  showConfirmButton: true,
  closeOnPopstate: true
};
var stdin_default = Dialog;
