import C from "../../@babel/runtime/helpers/esm/extends.mjs";
import v from "../../@babel/runtime/helpers/esm/slicedToArray.mjs";
import R from "../../@rc-component/portal/es/Portal.mjs";
import * as t from "react";
import { RefContext as g } from "./context.mjs";
import y from "./Dialog/index.mjs";
var _ = function(e) {
  var o = e.visible, u = e.getContainer, n = e.forceRender, i = e.destroyOnClose, l = i === void 0 ? !1 : i, r = e.afterClose, f = e.panelRef, c = t.useState(o), s = v(c, 2), a = s[0], m = s[1], d = t.useMemo(function() {
    return {
      panel: f
    };
  }, [f]);
  return t.useEffect(function() {
    o && m(!0);
  }, [o]), !n && l && !a ? null : /* @__PURE__ */ t.createElement(g.Provider, {
    value: d
  }, /* @__PURE__ */ t.createElement(R, {
    open: o || n || a,
    autoDestroy: !1,
    getContainer: u,
    autoLock: o || a
  }, /* @__PURE__ */ t.createElement(y, C({}, e, {
    destroyOnClose: l,
    afterClose: function() {
      r == null || r(), m(!1);
    }
  }))));
};
_.displayName = "Dialog";
export {
  _ as default
};
