import React from "react";
export const GradientDefs = _ref => {
  var _match$1$match, _parts$find;
  let {
    gradient
  } = _ref;
  if (!gradient) return null;
  const match = gradient.match(/linear-gradient\((.*)\)$/);
  if (!match) return null;
  const parts = (_match$1$match = match[1].match(/(#[0-9a-fA-F]{3,6}|rgba?\([^)]*\)|[0-9.]+deg)/g)) != null ? _match$1$match : [];
  const anglePart = (_parts$find = parts.find(p => /\d+deg/.test(p))) != null ? _parts$find : "0deg";
  const angle = Number(anglePart.replace("deg", "")) || 0;
  const colors = parts.filter(p => /^#|rgb/.test(p));
  if (colors.length < 2) return null;
  return /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
    id: "icon-gradient",
    "data-testid": "icon-gradient",
    gradientTransform: "rotate(" + angle + ")"
  }, colors.map((color, i) => /*#__PURE__*/React.createElement("stop", {
    key: i,
    offset: i / (colors.length - 1) * 100 + "%",
    stopColor: color
  }))));
};
export default GradientDefs;
//# sourceMappingURL=GradientDefs.js.map