import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import * as React from 'react';
import { renderImperatively } from '../utils/dom';
import Popup from './Popup';
var closeFn = new Set();
export var show = function show(props) {
  var content = props.content,
      rest = _objectWithoutProperties(props, ["content"]);

  var handler = renderImperatively( /*#__PURE__*/React.createElement(Popup, _extends({}, rest, {
    afterClose: function afterClose() {
      var _props$afterClose;

      closeFn.delete(handler.close);
      (_props$afterClose = props.afterClose) === null || _props$afterClose === void 0 ? void 0 : _props$afterClose.call(props);
    }
  }), content));
  closeFn.add(handler.close);
  return handler;
};
export var clear = function clear() {
  closeFn.forEach(function (close) {
    return close();
  });
};