const removeHash=e=>"#"===e.charAt(0)?e.slice(1):e,parseHex=e=>{const s=3===e.length||4===e.length;return{r:s?`${e.slice(0,1)}${e.slice(0,1)}`:e.slice(0,2),g:s?`${e.slice(1,2)}${e.slice(1,2)}`:e.slice(2,4),b:s?`${e.slice(2,3)}${e.slice(2,3)}`:e.slice(4,6),a:(s?`${e.slice(3,4)}${e.slice(3,4)}`:e.slice(6,8))||"ff"}},hexToDecimal=e=>parseInt(e,16),hexesToDecimals=({r:e,g:s,b:i,a:a})=>({r:hexToDecimal(e),g:hexToDecimal(s),b:hexToDecimal(i),a:+(hexToDecimal(a)/255).toFixed(2)}),isNumeric=e=>!isNaN(parseFloat(e))&&isFinite(e),formatRgb=(e,s)=>{const{r:i,g:a,b:c,a:l}=e;var r;return`rgba(${i}, ${a}, ${c}, ${r=s,!isNaN(parseFloat(r))&&isFinite(r)?s:l})`},hexToRgba=(e,s)=>{const i=removeHash(e),a=parseHex(i),c=hexesToDecimals(a);return formatRgb(c,s)};export default hexToRgba;