{"version":3,"file":"hexToRgb.cjs","names":["isValidHexString","hexString","includes","length","exports","rgbComponentsToString","rgbComponents","red","green","blue","hexToRgb","hexNumber","parseInt","slice","asFormattedString"],"sources":["../../src/hexToRgb.ts"],"sourcesContent":["/*!\n * Copyright (c) 2023-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\ntype RgbComponents = {\n  blue: number;\n  green: number;\n  red: number;\n};\n\nexport const isValidHexString = (hexString: string) =>\n  hexString.includes(\"#\") && (hexString.length === 4 || hexString.length === 7);\n\nexport const rgbComponentsToString = (rgbComponents: RgbComponents) => {\n  const { red, green, blue } = rgbComponents;\n\n  return `${red}, ${green}, ${blue}`;\n};\n\nexport const hexToRgb = (hexString: string) => {\n  const hexNumber = parseInt(hexString.slice(1), 16);\n\n  const red = (hexNumber >> 16) & 255;\n  const green = (hexNumber >> 8) & 255;\n  const blue = hexNumber & 255;\n\n  return {\n    red,\n    green,\n    blue,\n    asFormattedString: `rgb(${rgbComponentsToString({ red, green, blue })})`,\n  };\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAQO,MAAMA,gBAAgB,GAAIC,SAAiB,IAChDA,SAAS,CAACC,QAAQ,CAAC,GAAG,CAAC,KAAKD,SAAS,CAACE,MAAM,KAAK,CAAC,IAAIF,SAAS,CAACE,MAAM,KAAK,CAAC,CAAC;AAACC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA;AAEzE,MAAMK,qBAAqB,GAAIC,aAA4B,IAAK;EACrE,MAAM;IAAEC,GAAG;IAAEC,KAAK;IAAEC;EAAK,CAAC,GAAGH,aAAa;EAE1C,OAAO,GAAGC,GAAG,KAAKC,KAAK,KAAKC,IAAI,EAAE;AACpC,CAAC;AAACL,OAAA,CAAAC,qBAAA,GAAAA,qBAAA;AAEK,MAAMK,QAAQ,GAAIT,SAAiB,IAAK;EAC7C,MAAMU,SAAS,GAAGC,QAAQ,CAACX,SAAS,CAACY,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;EAElD,MAAMN,GAAG,GAAII,SAAS,IAAI,EAAE,GAAI,GAAG;EACnC,MAAMH,KAAK,GAAIG,SAAS,IAAI,CAAC,GAAI,GAAG;EACpC,MAAMF,IAAI,GAAGE,SAAS,GAAG,GAAG;EAE5B,OAAO;IACLJ,GAAG;IACHC,KAAK;IACLC,IAAI;IACJK,iBAAiB,EAAE,OAAOT,qBAAqB,CAAC;MAAEE,GAAG;MAAEC,KAAK;MAAEC;IAAK,CAAC,CAAC;EACvE,CAAC;AACH,CAAC;AAACL,OAAA,CAAAM,QAAA,GAAAA,QAAA","ignoreList":[]}