var _ToastStatic;
import React from 'react';
import ReactDOM from 'react-dom';
import { globalObject } from '@skbkontur/global-object';
import { Toast, ToastDataTids } from "../Toast";
export var ToastStatic = function ToastStatic() {};
_ToastStatic = ToastStatic;
ToastStatic.push = function (notification, action, showTime, showCloseIcon) {
  if (!_ToastStatic.node && globalObject.document) {
    _ToastStatic.node = globalObject.document.createElement('div');
    var body = globalObject.document.body;
    if (!body) {
      throw Error('There is no "body" element in "document"');
    }
    body.appendChild(_ToastStatic.node);
    ReactDOM.render( /*#__PURE__*/
    React.createElement(Toast, {
      "data-tid": ToastDataTids.toastStatic,
      ref: function ref(el) {
        return _ToastStatic.instance = el;
      }
    }), _ToastStatic.node, function () {
      return _ToastStatic._push(notification, action, showTime, showCloseIcon);
    });
  } else {
    _ToastStatic._push(notification, action, showTime, showCloseIcon);
  }
};
ToastStatic._push = function (notification, action, showTime, showCloseIcon) {
  if (_ToastStatic.instance) {
    _ToastStatic.instance.push(notification, action, showTime, showCloseIcon);
  }
};
ToastStatic.close = function () {
  if (_ToastStatic.instance) {
    _ToastStatic.instance.close();
  }
};
ToastStatic.instance = null;