var _excluded = ["name", "size", "ref"];
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import React from "react";
import { iconsList } from "./iconsList";
import { StyledIcon } from "./styled";
var getSize = function getSize(filename) {
  if (filename.endsWith("_s")) {
    return "small";
  }
  if (filename.endsWith("_l")) {
    return "large";
  }
  return "medium";
};
export var Icon = function Icon(_ref) {
  var name = _ref.name,
    size = _ref.size,
    ref = _ref.ref,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var iconSymbol = iconsList[name];
  if (!iconSymbol) {
    return null;
  }
  var iconSize = size || getSize(name);
  return /*#__PURE__*/React.createElement(StyledIcon, _extends({
    viewBox: iconSymbol.viewBox
  }, rest, {
    size: iconSize,
    ref: ref
  }), /*#__PURE__*/React.createElement("use", {
    xlinkHref: "#" + iconSymbol.id
  }));
};