"use strict";
const React = require("react");
const ReactDOM = require("react-dom");
const dom = require("../_util/dom.js");
const useIsFirstRender = require("../_util/hooks/useIsFirstRender.js");
const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
const ReactDOM__default = /* @__PURE__ */ _interopDefaultLegacy(ReactDOM);
var Portal = function(props) {
  var getContainer = props.getContainer, children = props.children;
  var containerRef = React.useRef();
  var isFirstRender = useIsFirstRender();
  if ((isFirstRender || containerRef.current === null) && !dom.isServerRendering) {
    containerRef.current = getContainer();
  }
  React.useEffect(function() {
    return function() {
      var container = containerRef.current;
      if (container && container.parentNode) {
        container.parentNode.removeChild(container);
        containerRef.current = null;
      }
    };
  }, []);
  return containerRef.current ? ReactDOM__default.default.createPortal(children, containerRef.current) : null;
};
const Portal$1 = Portal;
module.exports = Portal$1;
//# sourceMappingURL=portal.js.map
