import T from "../../../@babel/runtime/helpers/esm/toConsumableArray.mjs";
import { unmount as E, render as N } from "../../../rc-util/es/React/render.mjs";
import * as D from "react";
import b from "../_util/warning.mjs";
import { warnContext as I, globalConfig as M } from "../config-provider/index.mjs";
import S from "./ConfirmDialog.mjs";
import f from "./destroyFns.mjs";
import { getConfirmLocale as V } from "./locale.mjs";
var A = globalThis && globalThis.__rest || function(e, a) {
  var t = {};
  for (var n in e)
    Object.prototype.hasOwnProperty.call(e, n) && a.indexOf(n) < 0 && (t[n] = e[n]);
  if (e != null && typeof Object.getOwnPropertySymbols == "function")
    for (var s = 0, n = Object.getOwnPropertySymbols(e); s < n.length; s++)
      a.indexOf(n[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, n[s]) && (t[n[s]] = e[n[s]]);
  return t;
};
let O = "";
function R() {
  return O;
}
function B(e) {
  process.env.NODE_ENV !== "production" && I("Modal");
  const a = document.createDocumentFragment();
  let t = Object.assign(Object.assign({}, e), {
    close: l,
    open: !0
  }), n;
  function s() {
    for (var o = arguments.length, c = new Array(o), r = 0; r < o; r++)
      c[r] = arguments[r];
    const p = c.some((i) => i && i.triggerCancel);
    e.onCancel && p && e.onCancel.apply(e, [() => {
    }].concat(T(c.slice(1))));
    for (let i = 0; i < f.length; i++)
      if (f[i] === l) {
        f.splice(i, 1);
        break;
      }
    E(a);
  }
  function u(o) {
    var {
      okText: c,
      cancelText: r,
      prefixCls: p,
      getContainer: i
    } = o, g = A(o, ["okText", "cancelText", "prefixCls", "getContainer"]);
    clearTimeout(n), n = setTimeout(() => {
      const C = V(), {
        getPrefixCls: j,
        getIconPrefixCls: h,
        getTheme: v
      } = M(), d = j(void 0, R()), y = p || `${d}-modal`, P = h(), w = v();
      let m = i;
      m === !1 && (m = void 0, process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "production" && b(!1, "Modal", "Static method not support `getContainer` to be `false` since it do not have context env.")), N(/* @__PURE__ */ D.createElement(S, Object.assign({}, g, {
        getContainer: m,
        prefixCls: y,
        rootPrefixCls: d,
        iconPrefixCls: P,
        okText: c,
        locale: C,
        theme: w,
        cancelText: r || C.cancelText
      })), a);
    });
  }
  function l() {
    for (var o = arguments.length, c = new Array(o), r = 0; r < o; r++)
      c[r] = arguments[r];
    t = Object.assign(Object.assign({}, t), {
      open: !1,
      afterClose: () => {
        typeof e.afterClose == "function" && e.afterClose(), s.apply(this, c);
      }
    }), t.visible && delete t.visible, u(t);
  }
  function x(o) {
    typeof o == "function" ? t = o(t) : t = Object.assign(Object.assign({}, t), o), u(t);
  }
  return u(t), f.push(l), {
    destroy: l,
    update: x
  };
}
function H(e) {
  return Object.assign(Object.assign({}, e), {
    type: "warning"
  });
}
function J(e) {
  return Object.assign(Object.assign({}, e), {
    type: "info"
  });
}
function K(e) {
  return Object.assign(Object.assign({}, e), {
    type: "success"
  });
}
function Q(e) {
  return Object.assign(Object.assign({}, e), {
    type: "error"
  });
}
function X(e) {
  return Object.assign(Object.assign({}, e), {
    type: "confirm"
  });
}
function Y(e) {
  let {
    rootPrefixCls: a
  } = e;
  process.env.NODE_ENV !== "production" && b(!1, "Modal", "Modal.config is deprecated. Please use ConfigProvider.config instead."), O = a;
}
export {
  B as default,
  Y as modalGlobalConfig,
  X as withConfirm,
  Q as withError,
  J as withInfo,
  K as withSuccess,
  H as withWarn
};
