import { _ as _extends } from '../_rollupPluginBabelHelpers-736b301a.js';
import React__default from 'react';
import { SocketEmitter } from '@zenview/micro-utils';

function registerIconFont(scriptUrl) {
  if (!window._ICON_IS_INIT_) {
    window._ICON_SCRIPT_URL = scriptUrl;
    window._ICON_IS_INIT_ = true;
    loadScript(scriptUrl).then(() => {
      SocketEmitter.emit('update-iconfont');
    }).catch(e => {
      console.error(e);
      window._ICON_IS_INIT_ = false;
    });
  }
}
function loadScript(url) {
  return new Promise((resolve, reject) => {
    const script = document.createElement('script');
    script.src = url;
    document.body.appendChild(script);
    script.addEventListener('load', () => {
      resolve();
    });
    script.addEventListener('error', err => {
      reject(err);
    });
  });
}
function IconFont({
  type,
  className = '',
  ...props
}) {
  return /*#__PURE__*/React__default.createElement("i", _extends({
    className: `anticon ${className}`
  }, props), /*#__PURE__*/React__default.createElement("svg", {
    width: "1em",
    height: "1em",
    fill: "currentColor",
    "aria-hidden": "true",
    focusable: "false"
  }, /*#__PURE__*/React__default.createElement("use", {
    xlinkHref: `#${type}`
  })));
}
IconFont.registerIconFont = registerIconFont;

export { IconFont as default };
//# sourceMappingURL=index.js.map
