import { getTokens } from "tamagui";
function rgbToRgba(token) {
  var opacity = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1,
    tokens = getTokens(),
    val = tokens.color[token].val;
  val.startsWith("#") && (val = hexToRgb(val));
  var match = val.match(/\d+/g);
  if (!match) throw new Error("Invalid RGB format");
  var red = parseInt(match[0], 10),
    green = parseInt(match[1], 10),
    blue = parseInt(match[2], 10);
  if (opacity < 0 || opacity > 1) throw new Error("Opacity must be a value between 0 and 1");
  return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
}
function convertRgbToRgba(rgb) {
  var opacity = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 1,
    rgbValues = rgb.match(/\d+/g);
  if (rgbValues && rgbValues.length === 3) {
    var [r, g, b] = rgbValues.map(Number);
    return `rgba(${r}, ${g}, ${b}, ${opacity})`;
  } else return rgb;
}
function rgbToHex(rgb) {
  var result = rgb.match(/\d+/g);
  if (!result || result.length !== 3) throw new Error("Invalid RGB format");
  var hex = result.map(function (value) {
    var hexValue = parseInt(value).toString(16);
    return hexValue.padStart(2, "0");
  }).join("");
  return `#${hex}`;
}
function hexToRgb(hex) {
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  return `rgb(${parseInt(result[1], 16)}, ${parseInt(result[2], 16)}, ${parseInt(result[3], 16)})`;
}
export { convertRgbToRgba, hexToRgb, rgbToHex, rgbToRgba };
//# sourceMappingURL=color.native.js.map
