function l(e,t,s){return Math.min(Math.max(e,s),t)}class m extends Error{constructor(t){super(`Failed to parse color: "${t}"`)}}var f=m;function p(e){if(typeof e!="string")throw new f(e);if(e.trim().toLowerCase()==="transparent")return[0,0,0,0];let t=e.trim();t=M.test(e)?k(e):e;const s=j.exec(t);if(s){const _=Array.from(s).slice(1);return[..._.slice(0,3).map(o=>parseInt(h(o,2),16)),parseInt(h(_[3]||"f",2),16)/255]}const a=v.exec(t);if(a){const _=Array.from(a).slice(1);return[..._.slice(0,3).map(o=>parseInt(o,16)),parseInt(_[3]||"ff",16)/255]}const r=$.exec(t);if(r){const _=Array.from(r).slice(1);return[..._.slice(0,3).map(o=>parseInt(o,10)),parseFloat(_[3]||"1")]}const n=q.exec(t);if(n){const[_,o,i,c]=Array.from(n).slice(1).map(parseFloat);if(l(0,100,o)!==o)throw new f(e);if(l(0,100,i)!==i)throw new f(e);return[...C(_,o,i),Number.isNaN(c)?1:c]}throw new f(e)}function w(e){let t=5381,s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return(t>>>0)%2341}const g=e=>parseInt(e.replace(/_/g,""),36),y="1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((e,t)=>{const s=g(t.substring(0,3)),a=g(t.substring(3)).toString(16);let r="";for(let n=0;n<6-a.length;n++)r+="0";return e[s]=`${r}${a}`,e},{});function k(e){const t=e.toLowerCase().trim(),s=y[w(t)];if(!s)throw new f(e);return`#${s}`}const h=(e,t)=>Array.from(Array(t)).map(()=>e).join(""),j=new RegExp(`^#${h("([a-f0-9])",3)}([a-f0-9])?$`,"i"),v=new RegExp(`^#${h("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),$=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${h(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),q=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,M=/^[a-z]+$/i,d=e=>Math.round(e*255),C=(e,t,s)=>{let a=s/100;if(t===0)return[a,a,a].map(d);const r=(e%360+360)%360/60,n=(1-Math.abs(2*a-1))*(t/100),_=n*(1-Math.abs(r%2-1));let o=0,i=0,c=0;r>=0&&r<1?(o=n,i=_):r>=1&&r<2?(o=_,i=n):r>=2&&r<3?(i=n,c=_):r>=3&&r<4?(i=_,c=n):r>=4&&r<5?(o=_,c=n):r>=5&&r<6&&(o=n,c=_);const u=a-n/2,z=o+u,x=i+u,b=c+u;return[z,x,b].map(d)};function R(e,t,s,a){return`rgba(${l(0,255,e).toFixed()}, ${l(0,255,t).toFixed()}, ${l(0,255,s).toFixed()}, ${parseFloat(l(0,1,a).toFixed(3))})`}function F(e,t){const[s,a,r,n]=p(e);return R(s,a,r,n-t)}function A(e){const[t,s,a,r]=p(e);let n=_=>{const o=l(0,255,_).toString(16);return o.length===1?`0${o}`:o};return`#${n(t)}${n(s)}${n(a)}${r<1?n(Math.round(r*255)):""}`}export{F as a,p,A as t};
