|
|
|
(()=>{var e,t,i={5030:(e,t,i)=>{const o=i(1835),n={};for(const e of Object.keys(o))n[o[e]]=e;const r={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};e.exports=r;for(const e of Object.keys(r)){if(!("channels"in r[e]))throw new Error("missing channels property: "+e);if(!("labels"in r[e]))throw new Error("missing channel labels property: "+e);if(r[e].labels.length!==r[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=r[e];delete r[e].channels,delete r[e].labels,Object.defineProperty(r[e],"channels",{value:t}),Object.defineProperty(r[e],"labels",{value:i})}r.rgb.hsl=function(e){const t=e[0]/255,i=e[1]/255,o=e[2]/255,n=Math.min(t,i,o),r=Math.max(t,i,o),s=r-n;let a,c;r===n?a=0:t===r?a=(i-o)/s:i===r?a=2+(o-t)/s:o===r&&(a=4+(t-i)/s),a=Math.min(60*a,360),a<0&&(a+=360);const l=(n+r)/2;return c=r===n?0:l<=.5?s/(r+n):s/(2-r-n),[a,100*c,100*l]},r.rgb.hsv=function(e){let t,i,o,n,r;const s=e[0]/255,a=e[1]/255,c=e[2]/255,l=Math.max(s,a,c),d=l-Math.min(s,a,c),u=function(e){return(l-e)/6/d+.5};return 0===d?(n=0,r=0):(r=d/l,t=u(s),i=u(a),o=u(c),s===l?n=o-i:a===l?n=1/3+t-o:c===l&&(n=2/3+i-t),n<0?n+=1:n>1&&(n-=1)),[360*n,100*r,100*l]},r.rgb.hwb=function(e){const t=e[0],i=e[1];let o=e[2];const n=r.rgb.hsl(e)[0],s=1/255*Math.min(t,Math.min(i,o));return o=1-1/255*Math.max(t,Math.max(i,o)),[n,100*s,100*o]},r.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,o=e[2]/255,n=Math.min(1-t,1-i,1-o);return[100*((1-t-n)/(1-n)||0),100*((1-i-n)/(1-n)||0),100*((1-o-n)/(1-n)||0),100*n]},r.rgb.keyword=function(e){const t=n[e];if(t)return t;let i,r=1/0;for(const t of Object.keys(o)){const n=(a=o[t],((s=e)[0]-a[0])**2+(s[1]-a[1])**2+(s[2]-a[2])**2);n<r&&(r=n,i=t)}var s,a;return i},r.keyword.rgb=function(e){return o[e]},r.rgb.xyz=function(e){let t=e[0]/255,i=e[1]/255,o=e[2]/255;return t=t>.04045?((t+.055)/1.055)**2.4:t/12.92,i=i>.04045?((i+.055)/1.055)**2.4:i/12.92,o=o>.04045?((o+.055)/1.055)**2.4:o/12.92,[100*(.4124*t+.3576*i+.1805*o),100*(.2126*t+.7152*i+.0722*o),100*(.0193*t+.1192*i+.9505*o)]},r.rgb.lab=function(e){const t=r.rgb.xyz(e);let i=t[0],o=t[1],n=t[2];return i/=95.047,o/=100,n/=108.883,i=i>.008856?i**(1/3):7.787*i+16/116,o=o>.008856?o**(1/3):7.787*o+16/116,n=n>.008856?n**(1/3):7.787*n+16/116,[116*o-16,500*(i-o),200*(o-n)]},r.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,o=e[2]/100;let n,r,s;if(0===i)return s=255*o,[s,s,s];n=o<.5?o*(1+i):o+i-o*i;const a=2*o-n,c=[0,0,0];for(let e=0;e<3;e++)r=t+1/3*-(e-1),r<0&&r++,r>1&&r--,s=6*r<1?a+6*(n-a)*r:2*r<1?n:3*r<2?a+(n-a)*(2/3-r)*6:a,c[e]=255*s;return c},r.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,o=e[2]/100,n=i;const r=Math.max(o,.01);return o*=2,i*=o<=1?o:2-o,n*=r<=1?r:2-r,[t,100*(0===o?2*n/(r+n):2*i/(o+i)),(o+i)/2*100]},r.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let o=e[2]/100;const n=Math.floor(t)%6,r=t-Math.floor(t),s=255*o*(1-i),a=255*o*(1-i*r),c=255*o*(1-i*(1-r));switch(o*=255,n){case 0:return[o,c,s];case 1:return[a,o,s];case 2:return[s,o,c];case 3:return[s,a,o];case 4:return[c,s,o];case 5:return[o,s,a]}},r.hsv.hsl=function(e){const t=e[0],i=e[1]/100,o=e[2]/100,n=Math.max(o,.01);let r,s;s=(2-i)*o;const a=(2-i)*n;return r=i*n,r/=a<=1?a:2-a,r=r||0,s/=2,[t,100*r,100*s]},r.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,o=e[2]/100;const n=i+o;let r;n>1&&(i/=n,o/=n);const s=Math.floor(6*t),a=1-o;r=6*t-s,1&s&&(r=1-r);const c=i+r*(a-i);let l,d,u;switch(s){default:case 6:case 0:l=a,d=c,u=i;break;case 1:l=c,d=a,u=i;break;case 2:l=i,d=a,u=c;break;case 3:l=i,d=c,u=a;break;case 4:l=c,d=i,u=a;break;case 5:l=a,d=i,u=c}return[255*l,255*d,255*u]},r.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,o=e[2
|