import{clamp}from"../base/helpers.mjs";class ColorScale{constructor(o){this.colors=o,this.length=o.length}get(o){if(0===(o=clamp(o)))return this.colors[0];if(1===o)return this.colors[this.length-1];let t=(this.length-1)*o,r=Math.floor(t),l=Math.ceil(t),e=t-r,[s,c,h]=this.colors[r],[a,n,i]=this.colors[l],[g,u,m]=[s+(a-s)*e,c+(n-c)*e,h+(i-h)*e];return[clamp(Math.round(g),0,255),clamp(Math.round(u),0,255),clamp(Math.round(m),0,255)]}}const getTextColorForBackground=(o,t,r)=>.299*o+.587*t+.114*r>186?"#000000":"#FFFFFF";export{ColorScale,getTextColorForBackground};
