import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["type", "customFontName", "height", "width", "className", "scriptUrl"];
import React, { useContext } from 'react';
import classNames from 'classnames';
import createFromIconfontCN from './IconFont';
import ConfigContext from '../config-provider/ConfigContext';

var Icon = function Icon(props) {
  var _useContext = useContext(ConfigContext),
      getConfig = _useContext.getConfig;

  var iconfontPrefix = getConfig('iconfontPrefix');

  var type = props.type,
      customFontName = props.customFontName,
      height = props.height,
      width = props.width,
      _props$className = props.className,
      className = _props$className === void 0 ? '' : _props$className,
      scriptUrl = props.scriptUrl,
      otherProps = _objectWithoutProperties(props, _excluded);

  var classString = classNames(iconfontPrefix, customFontName, "".concat(iconfontPrefix, "-").concat(type), className);

  if (scriptUrl && typeof document !== 'undefined' && typeof window !== 'undefined' && typeof document.createElement === 'function') {
    var SvgIcon = createFromIconfontCN({
      scriptUrl: scriptUrl
    });

    if (SvgIcon) {
      return /*#__PURE__*/React.createElement(SvgIcon, {
        type: type,
        width: width,
        height: height
      });
    }
  }

  return /*#__PURE__*/React.createElement("i", _extends({}, otherProps, {
    className: classString
  }));
};

Icon.displayName = 'Icon';
Icon.createFromIconfontCN = createFromIconfontCN;
Icon.__C7N_ICON = true;
export default Icon;
//# sourceMappingURL=index.js.map
