export function blendColors(t,n){const o=t[3];return[(1-o)*n[0]+o*t[0],(1-o)*n[1]+o*t[1],(1-o)*n[2]+o*t[2],o+n[3]*(1-o)]}export function rgbaToHsla([t,n,o,a]){const r=Math.max(t,n,o),e=Math.min(t,n,o),c=r-e,l=r+e;let s;s=e===r?0:t===r?(1/6*(n-o)/c+1)%1:n===r?1/6*(o-t)/c+1/3:1/6*(t-n)/c+2/3;const u=.5*l;let p;return p=0===u||1===u?0:u<=.5?c/l:c/(2-l),[s,p,u,a]}export function luminance([t,n,o]){return.2126*(t<=.03928?t/12.92:Math.pow((t+.055)/1.055,2.4))+.7152*(n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4))+.0722*(o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4))}export function contrastRatio(t,n){const o=luminance(blendColors(t,n)),a=luminance(n);return(Math.max(o,a)+.05)/(Math.min(o,a)+.05)}const mainTRC=2.4,normBgExp=.55,normFgExp=.58,revBgExp=.62,revFgExp=.57,blkThrs=.03,blkClmp=1.45,scaleBoW=1.25,scaleWoB=1.25,deltaLuminanceMin=5e-4,loConThresh=.078,loConFactor=12.82051282051282,loConOffset=.06,loClip=.001;export function luminanceAPCA([t,n,o]){return.2126729*Math.pow(t,2.4)+.7151522*Math.pow(n,2.4)+.072175*Math.pow(o,2.4)}export function contrastRatioAPCA(t,n){return contrastRatioByLuminanceAPCA(luminanceAPCA(t),luminanceAPCA(n))}function clampLuminance(t){return t>.03?t:t+Math.pow(.03-t,1.45)}export function contrastRatioByLuminanceAPCA(t,n){if(t=clampLuminance(t),n=clampLuminance(n),Math.abs(t-n)<5e-4)return 0;let o=0;return n>=t?(o=1.25*(Math.pow(n,.55)-Math.pow(t,.58)),o=o<.001?0:o<.078?o-o*loConFactor*.06:o-.06):(o=1.25*(Math.pow(n,.62)-Math.pow(t,.57)),o=o>-.001?0:o>-.078?o-o*loConFactor*.06:o+.06),100*o}export function desiredLuminanceAPCA(t,n,o){function a(){return o?Math.pow(Math.abs(Math.pow(t,.62)-(-n-.06)/1.25),1/.57):Math.pow(Math.abs(Math.pow(t,.55)-(n+.06)/1.25),1/.58)}t=clampLuminance(t),n/=100;let r=a();return(r<0||r>1)&&(o=!o,r=a()),r}const contrastAPCALookupTable=[[12,-1,-1,-1,-1,100,90,80,-1,-1],[14,-1,-1,-1,100,90,80,60,60,-1],[16,-1,-1,100,90,80,60,55,50,50],[18,-1,-1,90,80,60,55,50,40,40],[24,-1,100,80,60,55,50,40,38,35],[30,-1,90,70,55,50,40,38,35,40],[36,-1,80,60,50,40,38,35,30,25],[48,100,70,55,40,38,35,30,25,20],[60,90,60,50,38,35,30,25,20,20],[72,80,55,40,35,30,25,20,20,20],[96,70,50,35,30,25,20,20,20,20],[120,60,40,30,25,20,20,20,20,20]];contrastAPCALookupTable.reverse();export function getAPCAThreshold(t,n){const o=parseFloat(t.replace("px","")),a=parseFloat(n);for(const[r,...e]of contrastAPCALookupTable)if(o>=r)for(const[t,n]of[900,800,700,600,500,400,300,200,100].entries())if(a>=n){const n=e[e.length-1-t];return-1===n?null:n}return null}export function isLargeFont(t,n){const o=72*parseFloat(t.replace("px",""))/96;return-1!==["bold","bolder","600","700","800","900"].indexOf(n)?o>=14:o>=18}const contrastThresholds={largeFont:{aa:3,aaa:4.5},normalFont:{aa:4.5,aaa:7}};export function getContrastThreshold(t,n){return isLargeFont(t,n)?contrastThresholds.largeFont:contrastThresholds.normalFont}