text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var tslib_1 = require("tslib");
  var react_1 = tslib_1.__importDefault(require("react"));
  var react_dom_1 = tslib_1.__importDefault(require("react-dom"));
  function RootContainer(props) {
    return react_1["default"].Children.only(props.children);
  }
  exports.RootContainer = RootContainer;
  var Portal = /** @class */function (_super) {
    tslib_1.__extends(Portal, _super);
    function Portal() {
      return _super !== null && _super.apply(this, arguments) || this;
    }
    Portal.prototype.componentDidMount = function () {
      if (!this.props.children) {
        return;
      }
      var element = react_dom_1["default"].findDOMNode(this);
      if (element && element instanceof Element) {
        var rootId = element.getAttribute('data-render-container-id');
        var rootIdAttribute = rootId ? rootId + " " + this.props.rt_rootID : "" + this.props.rt_rootID;
        element.setAttribute('data-render-container-id', rootIdAttribute);
      }
    };
    Portal.prototype.render = function () {
      return this.props.children || react_1["default"].createElement("noscript", { "data-render-container-id": this.props.rt_rootID });
    };
    Portal.__KONTUR_REACT_UI__ = 'RenderContainerFallback';
    return Portal;
  }(react_1["default"].Component);
  exports.Portal = Portal;
  var RenderInnerContainer = /** @class */function (_super) {
    tslib_1.__extends(RenderInnerContainer, _super);
    function RenderInnerContainer() {
      return _super !== null && _super.apply(this, arguments) || this;
    }
    RenderInnerContainer.prototype.render = function () {
      return react_1["default"].createElement(Portal, { rt_rootID: this.props.rootId }, this.props.anchor);
    };
    RenderInnerContainer.prototype.componentDidMount = function () {
      this.renderChildren();
    };
    RenderInnerContainer.prototype.componentDidUpdate = function () {
      this.renderChildren();
    };
    RenderInnerContainer.prototype.componentWillUnmount = function () {
      this.unmountChildren();
    };
    RenderInnerContainer.prototype.renderChildren = function () {
      if (this.props.children) {
        this.mountChildren();
      } else
      {
        this.unmountChildren();
      }
    };
    RenderInnerContainer.prototype.mountChildren = function () {
      if (!this.props.domContainer) {
        throw Error('There is no "this.domContainer"');
      }
      react_dom_1["default"].unstable_renderSubtreeIntoContainer(this, react_1["default"].createElement(RootContainer, { rt_portalID: this.props.rootId }, this.props.children), this.props.domContainer);
    };
    RenderInnerContainer.prototype.unmountChildren = function () {
      if (this.props.domContainer) {
        react_dom_1["default"].unmountComponentAtNode(this.props.domContainer);
      }
    };
    return RenderInnerContainer;
  }(react_1["default"].Component);
  exports.RenderInnerContainer = RenderInnerContainer;