import { Component } from "react";
import ReactDOM from "react-dom";
var __extends = globalThis && globalThis.__extends || function() {
  var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
      d2.__proto__ = b2;
    } || function(d2, b2) {
      for (var p in b2)
        if (Object.prototype.hasOwnProperty.call(b2, p))
          d2[p] = b2[p];
    };
    return extendStatics(d, b);
  };
  return function(d, b) {
    if (typeof b !== "function" && b !== null)
      throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
    extendStatics(d, b);
    function __() {
      this.constructor = d;
    }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  };
}();
var Portal = function(_super) {
  __extends(Portal2, _super);
  function Portal2() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.container = null;
    return _this;
  }
  Portal2.prototype.componentDidMount = function() {
    var _this = this;
    this.createContainer();
    this.timer = setTimeout(function() {
      if (!_this.container) {
        _this.createContainer();
      }
    });
  };
  Portal2.prototype.componentWillUnmount = function() {
    clearTimeout(this.timer);
  };
  Portal2.prototype.createContainer = function() {
    var getContainer = this.props.getContainer;
    this.container = getContainer && getContainer();
    this.forceUpdate();
  };
  Portal2.prototype.render = function() {
    var children = this.props.children;
    if (this.container) {
      return ReactDOM.createPortal(children, this.container);
    }
    return null;
  };
  return Portal2;
}(Component);
const Portal$1 = Portal;
export {
  Portal$1 as default
};
//# sourceMappingURL=Portal.js.map
