"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.initDefaultColor = void 0;
/**
 * Sets a default color to the svg if it does not contain any
 * @param {string} svgStr
 * @return {string}
 */
var initDefaultColor = exports.initDefaultColor = function initDefaultColor(svgStr) {
  if (!/#[0-9a-f]{3,6}/i.test(svgStr)) {
    var styleFix = 'fill: #000000;';
    return svgStr.replace(/<svg((?!style)[^>])*(style="([^"]+)")?[^>]*>/, function insertDefaultColor() {
      // appends it to the current style if exists, otherwise in a style attribute
      var svgTag = arguments[0];
      var currentStyle = arguments[3];
      return currentStyle ? svgTag.replace(currentStyle, currentStyle + ' ' + styleFix) : svgTag.replace('>', " style=\"".concat(styleFix, "\">"));
    });
  }
  return svgStr;
};