🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@colordx/core

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@colordx/core - npm Package Compare versions

Comparing version
5.4.1
to
5.4.2
+2
dist/chunk-BXGFP5BN.mjs
import {f as f$2,e,a as a$2}from'./chunk-J6CH5YTL.mjs';import {j,e as e$1,k,d as d$1,l as l$1,b as b$1}from'./chunk-4LKLL3IS.mjs';import {a,b,d,c}from'./chunk-FXCFKFXK.mjs';import {h,i,f as f$1,a as a$1,g,l,k as k$1,d as d$2}from'./chunk-IOXRZECH.mjs';var er=.8224619687,or=.1775380313,br=.0331941989,tr=.9668058011,ar=.0170826307,ur=.0723974407,mr=.9105199286,Fr=1.2249401762805598,vr=-0.22494017628055996,Br=-0.04205695470968816,Er=1.042056954709688,$r=-0.019637554590334432,Dr=-0.07863604555063189,Or=1.0982736001409663,Rn=(e,r,n,o)=>{e[0]=er*r+or*n,e[1]=br*r+tr*n,e[2]=ar*r+ur*n+mr*o;},sr=(e,r,n)=>[er*e+or*r,br*e+tr*r,ar*e+ur*r+mr*n];var z=(e,r,n)=>[Fr*e+vr*r,Br*e+Er*r,$r*e+Dr*r+Or*n],fn=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=sr(a(e/255),a(r/255),a(n/255));return {r:b(b$1),g:b(t),b:b(u),alpha:o,colorSpace:"display-p3"}};var lr=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=z(a(e),a(r),a(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:o}},yn=e=>{if(!h(e)||e.colorSpace!=="display-p3"||!i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !f$1(r)||!f$1(n)||!f$1(o)||!f$1(b)?null:lr({r:g(r),g:g(n),b:g(o),alpha:a$1(g(b),0,1)})},jr=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),Sn=e=>{if(typeof e!="string")return null;let r=jr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),o=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return lr({r:n,g:o,b,alpha:a$1(t,0,1)})},xn=(e,r,n)=>sr(...f$2(e,r,n));var cr=.6274038959,pr=.3292830384,ir=.0433130657,dr=.0690972894,hr=.9195403951,gr=.0113623156,Rr=.0163914389,fr=.0880133079,yr=.8955952532,Xr=1.6604910021084345,Ur=-0.5876411387885495,Kr=-0.07284986331988488,qr=-0.12455047452159074,Hr=1.1328998971259603,Vr=-0.008349422604369477,Yr=-0.018150763354905303,Zr=-0.10057889800800739,Jr=1.1187296613629127,_n=(e,r,n,o)=>{e[0]=cr*r+pr*n+ir*o,e[1]=dr*r+hr*n+gr*o,e[2]=Rr*r+fr*n+yr*o;},Sr=(e,r,n)=>[cr*e+pr*r+ir*n,dr*e+hr*r+gr*n,Rr*e+fr*r+yr*n];var F=(e,r,n)=>[Xr*e+Ur*r+Kr*n,qr*e+Hr*r+Vr*n,Yr*e+Zr*r+Jr*n],kn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=Sr(a(e/255),a(r/255),a(n/255));return {r:d(b),g:d(t),b:d(u),alpha:o,colorSpace:"rec2020"}};var xr=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=F(c(e),c(r),c(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:o}},Mn=e=>{if(!h(e)||e.colorSpace!=="rec2020"||!i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !f$1(r)||!f$1(n)||!f$1(o)||!f$1(b)?null:xr({r:g(r),g:g(n),b:g(o),alpha:a$1(g(b),0,1)})},Qr=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),Pn=e=>{if(typeof e!="string")return null;let r=Qr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),o=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return xr({r:n,g:o,b,alpha:a$1(t,0,1)})},An=(e,r,n)=>Sr(...f$2(e,r,n));var Wr=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nn=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,en=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bn=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,A=(e,r,n)=>{let{x:o,y:b,z:t}=l$1({l:e,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,s,l]=e$1(o,b,t);return a$2(u,s,l)},Tr=(e,r,n)=>{let[o,b,t]=z(a(e),a(r),a(n));return a$2(o,b,t)},Cr=(e,r,n)=>{let[o,b,t]=F(c(e),c(r),c(n));return a$2(o,b,t)},Lr=(e,r,n)=>{let[o,b,t]=e$1(e,r,n);return a$2(o,b,t)},Nr=(e,r,n)=>{let[o,b,t]=b$1(e,r,n);return a$2(o,b,t)},G=e=>{if(typeof e=="object"&&e!==null){let r=e;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let o=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(o),b:n.c*Math.sin(o),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=e;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[o,b,t]=A(n.l,n.a,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=e;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let o=n.h*Math.PI/180,[b,t,u]=A(n.l,n.c*Math.cos(o),n.c*Math.sin(o));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Tr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Cr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Nr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Lr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof e=="string"){let r=Wr.exec(e);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o*Math.cos(u),b:o*Math.sin(u),alpha:s}}if(r=rn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o,b,alpha:t}}if(r=nn.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=A(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=en.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[l,x,T]=A(n,o*Math.cos(u),o*Math.sin(u));return {l,a:x,b:T,alpha:s}}if(r=on.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Tr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=bn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Cr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=tn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Lr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=an.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Nr(n,o,b);return {l:u,a:s,b:l,alpha:t}}return null}return null},S=5e-4,Pr=(e,r,n)=>e>=-S&&e<=1+S&&r>=-S&&r<=1+S&&n>=-S&&n<=1+S,_r=(e,r,n)=>e>=0&&e<=1&&r>=0&&r<=1&&n>=0&&n<=1,$n=e=>{let r=G(e);if(r===null)return true;let[n,o,b]=f$2(r.l,r.a,r.b);return Pr(n,o,b)},kr=.02,un=1e-4,Mr=(e,r)=>{let n=e[0]-r[0],o=e[1]-r[1],b=e[2]-r[2];return Math.sqrt(n*n+o*o+b*b)},Ar=(e,r,n,o,b)=>{if(e>=1)return [1,1,1];if(e<=0)return [0,0,0];let[t,u,s]=o(e,r,n);if(_r(t,u,s))return [t,u,s];let l=a$1(t,0,1),x=a$1(u,0,1),T=a$1(s,0,1);if(Mr(b(l,x,T),[e,r,n])<=kr)return [l,x,T];let E=Math.atan2(n,r),wr=Math.sqrt(r*r+n*n),N=0,I=wr,$=true,D=l,O=x,j=T;for(;I-N>un;){let C=(N+I)/2,X=C*Math.cos(E),U=C*Math.sin(E),[K,q,H]=o(e,X,U);if($&&_r(K,q,H)){N=C;continue}let V=a$1(K,0,1),Y=a$1(q,0,1),Z=a$1(H,0,1);D=V,O=Y,j=Z,Mr(b(V,Y,Z),[e,X,U])<=kr?(N=C,$=false):I=C;}return [D,O,j]},Dn=e=>{let r=G(e);return r===null?null:{linear:Ar(r.l,r.a,r.b,f$2,a$2),alpha:r.alpha}},On=(e,r)=>{let n=G(e);if(n===null)return true;let[o,b,t]=r(n.l,n.a,n.b);return Pr(o,b,t)},jn=(e,r,n)=>{let o=G(e);return o===null?null:{linear:Ar(o.l,o.a,o.b,r,n),alpha:o.alpha}};var f=Math.PI/180,Gr=(e,r,n)=>{let o=n*f;return f$2(e,r*Math.cos(o),r*Math.sin(o))},Ir=(e$1,r,n,o)=>{let b=o*f;e(e$1,r,n*Math.cos(b),n*Math.sin(b));},Vn=(e,r,n)=>{let[o,b$1,t]=Gr(e,r,n);return [b(o),b(b$1),b(t)]},Yn=(e,r,n,o)=>{Ir(e,r,n,o),e[0]=b(e[0]),e[1]=b(e[1]),e[2]=b(e[2]);},Zn=(e,r,n)=>{let[o,b$1,t]=Gr(e,r,n);return [[o,b$1,t],[b(o),b(b$1),b(t)]]},Jn=(e,r,n,o,b$1)=>{Ir(e,n,o,b$1),r[0]=b(e[0]),r[1]=b(e[1]),r[2]=b(e[2]);},Qn=(e,r,n)=>[a(e),a(r),a(n)],Wn=(e,r,n,o)=>{e[0]=a(r),e[1]=a(n),e[2]=a(o);},v=(e,r,n)=>{let[o,b,t]=j(e,r,n);return e$1(o,b,t)},B=(e,r,n,o)=>{k(e,r,n,o),d$1(e,e[0],e[1],e[2]);},re=(e,r,n)=>{let o=n*f;return v(e,r*Math.cos(o),r*Math.sin(o))},ne=(e,r,n,o)=>{let b=o*f;B(e,r,n*Math.cos(b),n*Math.sin(b));},mn=(e,r,n)=>{let[o,b$1,t]=v(e,r,n);return [b(o),b(b$1),b(t)]},sn=(e,r,n,o)=>{B(e,r,n,o),e[0]=b(e[0]),e[1]=b(e[1]),e[2]=b(e[2]);},ee=(e,r,n)=>{let o=n*f;return mn(e,r*Math.cos(o),r*Math.sin(o))},oe=(e,r,n,o)=>{let b=o*f;sn(e,r,n*Math.cos(b),n*Math.sin(b));},ln=(e,r,n)=>{let[o,b$1,t]=v(e,r,n);return [[o,b$1,t],[b(o),b(b$1),b(t)]]},cn=(e,r,n,o,b$1)=>{B(e,n,o,b$1),r[0]=b(e[0]),r[1]=b(e[1]),r[2]=b(e[2]);},be=(e,r,n)=>{let o=n*f;return ln(e,r*Math.cos(o),r*Math.sin(o))},te=(e,r,n,o,b)=>{let t=b*f;cn(e,r,n,o*Math.cos(t),o*Math.sin(t));};export{v as A,B,re as C,ne as D,mn as E,sn as F,ee as G,oe as H,ln as I,cn as J,be as K,te as L,Rn as a,sr as b,z as c,fn as d,yn as e,Sn as f,xn as g,_n as h,Sr as i,F as j,kn as k,Mn as l,Pn as m,An as n,$n as o,Dn as p,On as q,jn as r,Gr as s,Ir as t,Vn as u,Yn as v,Zn as w,Jn as x,Qn as y,Wn as z};//# sourceMappingURL=chunk-BXGFP5BN.mjs.map
//# sourceMappingURL=chunk-BXGFP5BN.mjs.map

Sorry, the diff of this file is too big to display

'use strict';var chunkGXECYURS_cjs=require('./chunk-GXECYURS.cjs'),chunkGU6TZJ4O_cjs=require('./chunk-GU6TZJ4O.cjs'),chunkX5FCFNQN_cjs=require('./chunk-X5FCFNQN.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var er=.8224619687,or=.1775380313,br=.0331941989,tr=.9668058011,ar=.0170826307,ur=.0723974407,mr=.9105199286,Fr=1.2249401762805598,vr=-0.22494017628055996,Br=-0.04205695470968816,Er=1.042056954709688,$r=-0.019637554590334432,Dr=-0.07863604555063189,Or=1.0982736001409663,Rn=(e,r,n,o)=>{e[0]=er*r+or*n,e[1]=br*r+tr*n,e[2]=ar*r+ur*n+mr*o;},sr=(e,r,n)=>[er*e+or*r,br*e+tr*r,ar*e+ur*r+mr*n];var z=(e,r,n)=>[Fr*e+vr*r,Br*e+Er*r,$r*e+Dr*r+Or*n],fn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=sr(chunkX5FCFNQN_cjs.a(e/255),chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(n/255));return {r:chunkX5FCFNQN_cjs.b(b),g:chunkX5FCFNQN_cjs.b(t),b:chunkX5FCFNQN_cjs.b(u),alpha:o,colorSpace:"display-p3"}};var lr=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=z(chunkX5FCFNQN_cjs.a(e),chunkX5FCFNQN_cjs.a(r),chunkX5FCFNQN_cjs.a(n));return {r:chunkX5FCFNQN_cjs.b(b)*255,g:chunkX5FCFNQN_cjs.b(t)*255,b:chunkX5FCFNQN_cjs.b(u)*255,alpha:o}},yn=e=>{if(!chunkYISEJCI6_cjs.h(e)||e.colorSpace!=="display-p3"||!chunkYISEJCI6_cjs.i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(b)?null:lr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(o),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},jr=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Sn=e=>{if(typeof e!="string")return null;let r=jr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),o=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return lr({r:n,g:o,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},xn=(e,r,n)=>sr(...chunkGXECYURS_cjs.f(e,r,n));var cr=.6274038959,pr=.3292830384,ir=.0433130657,dr=.0690972894,hr=.9195403951,gr=.0113623156,Rr=.0163914389,fr=.0880133079,yr=.8955952532,Xr=1.6604910021084345,Ur=-0.5876411387885495,Kr=-0.07284986331988488,qr=-0.12455047452159074,Hr=1.1328998971259603,Vr=-0.008349422604369477,Yr=-0.018150763354905303,Zr=-0.10057889800800739,Jr=1.1187296613629127,_n=(e,r,n,o)=>{e[0]=cr*r+pr*n+ir*o,e[1]=dr*r+hr*n+gr*o,e[2]=Rr*r+fr*n+yr*o;},Sr=(e,r,n)=>[cr*e+pr*r+ir*n,dr*e+hr*r+gr*n,Rr*e+fr*r+yr*n];var F=(e,r,n)=>[Xr*e+Ur*r+Kr*n,qr*e+Hr*r+Vr*n,Yr*e+Zr*r+Jr*n],kn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=Sr(chunkX5FCFNQN_cjs.a(e/255),chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(n/255));return {r:chunkX5FCFNQN_cjs.d(b),g:chunkX5FCFNQN_cjs.d(t),b:chunkX5FCFNQN_cjs.d(u),alpha:o,colorSpace:"rec2020"}};var xr=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=F(chunkX5FCFNQN_cjs.c(e),chunkX5FCFNQN_cjs.c(r),chunkX5FCFNQN_cjs.c(n));return {r:chunkX5FCFNQN_cjs.b(b)*255,g:chunkX5FCFNQN_cjs.b(t)*255,b:chunkX5FCFNQN_cjs.b(u)*255,alpha:o}},Mn=e=>{if(!chunkYISEJCI6_cjs.h(e)||e.colorSpace!=="rec2020"||!chunkYISEJCI6_cjs.i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(b)?null:xr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(o),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},Qr=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Pn=e=>{if(typeof e!="string")return null;let r=Qr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),o=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return xr({r:n,g:o,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},An=(e,r,n)=>Sr(...chunkGXECYURS_cjs.f(e,r,n));var Wr=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nn=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,en=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bn=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,A=(e,r,n)=>{let{x:o,y:b,z:t}=chunkGU6TZJ4O_cjs.l({l:e,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,s,l]=chunkGU6TZJ4O_cjs.e(o,b,t);return chunkGXECYURS_cjs.a(u,s,l)},Tr=(e,r,n)=>{let[o,b,t]=z(chunkX5FCFNQN_cjs.a(e),chunkX5FCFNQN_cjs.a(r),chunkX5FCFNQN_cjs.a(n));return chunkGXECYURS_cjs.a(o,b,t)},Cr=(e,r,n)=>{let[o,b,t]=F(chunkX5FCFNQN_cjs.c(e),chunkX5FCFNQN_cjs.c(r),chunkX5FCFNQN_cjs.c(n));return chunkGXECYURS_cjs.a(o,b,t)},Lr=(e,r,n)=>{let[o,b,t]=chunkGU6TZJ4O_cjs.e(e,r,n);return chunkGXECYURS_cjs.a(o,b,t)},Nr=(e,r,n)=>{let[o,b,t]=chunkGU6TZJ4O_cjs.b(e,r,n);return chunkGXECYURS_cjs.a(o,b,t)},G=e=>{if(typeof e=="object"&&e!==null){let r=e;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let o=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(o),b:n.c*Math.sin(o),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=e;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[o,b,t]=A(n.l,n.a,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=e;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let o=n.h*Math.PI/180,[b,t,u]=A(n.l,n.c*Math.cos(o),n.c*Math.sin(o));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Tr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Cr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Nr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Lr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof e=="string"){let r=Wr.exec(e);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o*Math.cos(u),b:o*Math.sin(u),alpha:s}}if(r=rn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o,b,alpha:t}}if(r=nn.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=A(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=en.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[l,x,T]=A(n,o*Math.cos(u),o*Math.sin(u));return {l,a:x,b:T,alpha:s}}if(r=on.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Tr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=bn.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Cr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=tn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Lr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=an.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Nr(n,o,b);return {l:u,a:s,b:l,alpha:t}}return null}return null},S=5e-4,Pr=(e,r,n)=>e>=-S&&e<=1+S&&r>=-S&&r<=1+S&&n>=-S&&n<=1+S,_r=(e,r,n)=>e>=0&&e<=1&&r>=0&&r<=1&&n>=0&&n<=1,$n=e=>{let r=G(e);if(r===null)return true;let[n,o,b]=chunkGXECYURS_cjs.f(r.l,r.a,r.b);return Pr(n,o,b)},kr=.02,un=1e-4,Mr=(e,r)=>{let n=e[0]-r[0],o=e[1]-r[1],b=e[2]-r[2];return Math.sqrt(n*n+o*o+b*b)},Ar=(e,r,n,o,b)=>{if(e>=1)return [1,1,1];if(e<=0)return [0,0,0];let[t,u,s]=o(e,r,n);if(_r(t,u,s))return [t,u,s];let l=chunkYISEJCI6_cjs.a(t,0,1),x=chunkYISEJCI6_cjs.a(u,0,1),T=chunkYISEJCI6_cjs.a(s,0,1);if(Mr(b(l,x,T),[e,r,n])<=kr)return [l,x,T];let E=Math.atan2(n,r),wr=Math.sqrt(r*r+n*n),N=0,I=wr,$=true,D=l,O=x,j=T;for(;I-N>un;){let C=(N+I)/2,X=C*Math.cos(E),U=C*Math.sin(E),[K,q,H]=o(e,X,U);if($&&_r(K,q,H)){N=C;continue}let V=chunkYISEJCI6_cjs.a(K,0,1),Y=chunkYISEJCI6_cjs.a(q,0,1),Z=chunkYISEJCI6_cjs.a(H,0,1);D=V,O=Y,j=Z,Mr(b(V,Y,Z),[e,X,U])<=kr?(N=C,$=false):I=C;}return [D,O,j]},Dn=e=>{let r=G(e);return r===null?null:{linear:Ar(r.l,r.a,r.b,chunkGXECYURS_cjs.f,chunkGXECYURS_cjs.a),alpha:r.alpha}},On=(e,r)=>{let n=G(e);if(n===null)return true;let[o,b,t]=r(n.l,n.a,n.b);return Pr(o,b,t)},jn=(e,r,n)=>{let o=G(e);return o===null?null:{linear:Ar(o.l,o.a,o.b,r,n),alpha:o.alpha}};var f=Math.PI/180,Gr=(e,r,n)=>{let o=n*f;return chunkGXECYURS_cjs.f(e,r*Math.cos(o),r*Math.sin(o))},Ir=(e,r,n,o)=>{let b=o*f;chunkGXECYURS_cjs.e(e,r,n*Math.cos(b),n*Math.sin(b));},Vn=(e,r,n)=>{let[o,b,t]=Gr(e,r,n);return [chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]},Yn=(e,r,n,o)=>{Ir(e,r,n,o),e[0]=chunkX5FCFNQN_cjs.b(e[0]),e[1]=chunkX5FCFNQN_cjs.b(e[1]),e[2]=chunkX5FCFNQN_cjs.b(e[2]);},Zn=(e,r,n)=>{let[o,b,t]=Gr(e,r,n);return [[o,b,t],[chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]]},Jn=(e,r,n,o,b)=>{Ir(e,n,o,b),r[0]=chunkX5FCFNQN_cjs.b(e[0]),r[1]=chunkX5FCFNQN_cjs.b(e[1]),r[2]=chunkX5FCFNQN_cjs.b(e[2]);},Qn=(e,r,n)=>[chunkX5FCFNQN_cjs.a(e),chunkX5FCFNQN_cjs.a(r),chunkX5FCFNQN_cjs.a(n)],Wn=(e,r,n,o)=>{e[0]=chunkX5FCFNQN_cjs.a(r),e[1]=chunkX5FCFNQN_cjs.a(n),e[2]=chunkX5FCFNQN_cjs.a(o);},v=(e,r,n)=>{let[o,b,t]=chunkGU6TZJ4O_cjs.j(e,r,n);return chunkGU6TZJ4O_cjs.e(o,b,t)},B=(e,r,n,o)=>{chunkGU6TZJ4O_cjs.k(e,r,n,o),chunkGU6TZJ4O_cjs.d(e,e[0],e[1],e[2]);},re=(e,r,n)=>{let o=n*f;return v(e,r*Math.cos(o),r*Math.sin(o))},ne=(e,r,n,o)=>{let b=o*f;B(e,r,n*Math.cos(b),n*Math.sin(b));},mn=(e,r,n)=>{let[o,b,t]=v(e,r,n);return [chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]},sn=(e,r,n,o)=>{B(e,r,n,o),e[0]=chunkX5FCFNQN_cjs.b(e[0]),e[1]=chunkX5FCFNQN_cjs.b(e[1]),e[2]=chunkX5FCFNQN_cjs.b(e[2]);},ee=(e,r,n)=>{let o=n*f;return mn(e,r*Math.cos(o),r*Math.sin(o))},oe=(e,r,n,o)=>{let b=o*f;sn(e,r,n*Math.cos(b),n*Math.sin(b));},ln=(e,r,n)=>{let[o,b,t]=v(e,r,n);return [[o,b,t],[chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]]},cn=(e,r,n,o,b)=>{B(e,n,o,b),r[0]=chunkX5FCFNQN_cjs.b(e[0]),r[1]=chunkX5FCFNQN_cjs.b(e[1]),r[2]=chunkX5FCFNQN_cjs.b(e[2]);},be=(e,r,n)=>{let o=n*f;return ln(e,r*Math.cos(o),r*Math.sin(o))},te=(e,r,n,o,b)=>{let t=b*f;cn(e,r,n,o*Math.cos(t),o*Math.sin(t));};exports.A=v;exports.B=B;exports.C=re;exports.D=ne;exports.E=mn;exports.F=sn;exports.G=ee;exports.H=oe;exports.I=ln;exports.J=cn;exports.K=be;exports.L=te;exports.a=Rn;exports.b=sr;exports.c=z;exports.d=fn;exports.e=yn;exports.f=Sn;exports.g=xn;exports.h=_n;exports.i=Sr;exports.j=F;exports.k=kn;exports.l=Mn;exports.m=Pn;exports.n=An;exports.o=$n;exports.p=Dn;exports.q=On;exports.r=jn;exports.s=Gr;exports.t=Ir;exports.u=Vn;exports.v=Yn;exports.w=Zn;exports.x=Jn;exports.y=Qn;exports.z=Wn;//# sourceMappingURL=chunk-JVG55LEC.cjs.map
//# sourceMappingURL=chunk-JVG55LEC.cjs.map

Sorry, the diff of this file is too big to display

interface RgbColor {
r: number;
g: number;
b: number;
alpha: number;
}
type RgbColorInput = Omit<RgbColor, 'alpha'> & {
alpha?: number;
};
interface HslColor {
h: number;
s: number;
l: number;
alpha: number;
}
type HslColorInput = Omit<HslColor, 'alpha'> & {
alpha?: number;
};
interface HsvColor {
h: number;
s: number;
v: number;
alpha: number;
}
type HsvColorInput = Omit<HsvColor, 'alpha'> & {
alpha?: number;
};
interface HwbColor {
h: number;
/** Whiteness [0, 100] */
w: number;
/** Blackness [0, 100] */
b: number;
alpha: number;
}
type HwbColorInput = Omit<HwbColor, 'alpha'> & {
alpha?: number;
};
/** CIE LAB (D50) */
interface LabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
readonly colorSpace: 'lab';
}
type LabColorInput = Omit<LabColor, 'alpha'> & {
alpha?: number;
};
/** CIE LCH (D50) */
interface LchColor {
l: number;
c: number;
h: number;
alpha: number;
readonly colorSpace: 'lch';
}
type LchColorInput = Omit<LchColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D50) */
interface XyzColor {
x: number;
y: number;
z: number;
alpha: number;
}
type XyzColorInput = Omit<XyzColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D65) */
interface XyzD65Color {
x: number;
y: number;
z: number;
alpha: number;
readonly colorSpace: 'xyz-d65';
}
type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & {
alpha?: number;
};
interface CmykColor {
c: number;
m: number;
y: number;
k: number;
alpha: number;
}
type CmykColorInput = Omit<CmykColor, 'alpha'> & {
alpha?: number;
};
/** Oklab — perceptually uniform, D65 */
interface OklabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
}
type OklabColorInput = Omit<OklabColor, 'alpha'> & {
alpha?: number;
};
/** Oklch — perceptually uniform, polar form of Oklab */
interface OklchColor {
l: number;
c: number;
h: number;
alpha: number;
}
type OklchColorInput = Omit<OklchColor, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Display-P3 */
interface P3Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'display-p3';
}
type P3ColorInput = Omit<P3Color, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Rec.2020 */
interface Rec2020Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'rec2020';
}
type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & {
alpha?: number;
};
type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput;
type ColorParser<T = AnyColor> = (input: T) => RgbColor | null;
type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'name';
declare const _SENTINEL: unique symbol;
declare class Colordx {
private readonly _rgb;
private readonly _valid;
constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor);
private static _make;
/**
* Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage.
* Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a
* color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored
* _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut
* channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.
*
* Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels
* directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP
* asymmetries on gamut-boundary colors.
*
* A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one
* channel exactly on 0 or 1 while the others sit where the input's hue landed, so an
* extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels
* (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all
* three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report
* phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary;
* the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab
* see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut
* (P3 / Rec.2020 targets) and pass through untouched.
*/
static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx;
isValid(): boolean;
toRgb(): RgbColor;
/** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */
_rawRgb(): RgbColor;
/**
* Format as a `rgb()` / `rgba()` CSS string.
* Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):
* `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`
* Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also
* switches the function name to `rgba()` when alpha < 1:
* `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`
*/
toRgbString(options?: {
legacy?: boolean;
}): string;
toHex(): string;
/** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */
toHex8(): string;
/** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */
toNumber(): number;
toHsl(precision?: number): HslColor;
toHslString(precision?: number): string;
toOklab(precision?: number): OklabColor;
toOklabString(precision?: number): string;
toOklch(precision?: number): OklchColor;
toOklchString(precision?: number): string;
brightness(): number;
isDark(): boolean;
isLight(): boolean;
alpha(): number;
alpha(value: number): Colordx;
hue(): number;
hue(value: number): Colordx;
lightness(): number;
lightness(value: number): Colordx;
chroma(): number;
chroma(value: number): Colordx;
lighten(amount?: number, options?: {
relative?: boolean;
}): Colordx;
darken(amount?: number, options?: {
relative?: boolean;
}): Colordx;
saturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
desaturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
grayscale(): Colordx;
invert(): Colordx;
rotate(amount?: number): Colordx;
isEqual(color: AnyColor): boolean;
toString(): string;
/**
* Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].
* Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.
* Hue and lightness may shift noticeably for colors far outside sRGB.
* Returns `this` when already in gamut.
*/
clampSrgb(): Colordx;
/**
* Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm
* (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.
* Useful when hue stability matters — design tokens, palettes, color pickers.
* Returns `this` when already in gamut.
*/
mapSrgb(): Colordx;
/**
* Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.
* Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.
*/
static toGamutSrgb: (input: AnyColor) => Colordx;
}
type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void;
declare const colordx: (input: AnyColor | Colordx) => Colordx;
/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */
declare const toHex8: (input: AnyColor | Colordx) => string;
declare const extend: (plugins: Plugin[]) => void;
declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T;
declare const random: () => Colordx;
export { type AnyColor as A, type XyzD65Color as B, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z };
interface RgbColor {
r: number;
g: number;
b: number;
alpha: number;
}
type RgbColorInput = Omit<RgbColor, 'alpha'> & {
alpha?: number;
};
interface HslColor {
h: number;
s: number;
l: number;
alpha: number;
}
type HslColorInput = Omit<HslColor, 'alpha'> & {
alpha?: number;
};
interface HsvColor {
h: number;
s: number;
v: number;
alpha: number;
}
type HsvColorInput = Omit<HsvColor, 'alpha'> & {
alpha?: number;
};
interface HwbColor {
h: number;
/** Whiteness [0, 100] */
w: number;
/** Blackness [0, 100] */
b: number;
alpha: number;
}
type HwbColorInput = Omit<HwbColor, 'alpha'> & {
alpha?: number;
};
/** CIE LAB (D50) */
interface LabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
readonly colorSpace: 'lab';
}
type LabColorInput = Omit<LabColor, 'alpha'> & {
alpha?: number;
};
/** CIE LCH (D50) */
interface LchColor {
l: number;
c: number;
h: number;
alpha: number;
readonly colorSpace: 'lch';
}
type LchColorInput = Omit<LchColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D50) */
interface XyzColor {
x: number;
y: number;
z: number;
alpha: number;
}
type XyzColorInput = Omit<XyzColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D65) */
interface XyzD65Color {
x: number;
y: number;
z: number;
alpha: number;
readonly colorSpace: 'xyz-d65';
}
type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & {
alpha?: number;
};
interface CmykColor {
c: number;
m: number;
y: number;
k: number;
alpha: number;
}
type CmykColorInput = Omit<CmykColor, 'alpha'> & {
alpha?: number;
};
/** Oklab — perceptually uniform, D65 */
interface OklabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
}
type OklabColorInput = Omit<OklabColor, 'alpha'> & {
alpha?: number;
};
/** Oklch — perceptually uniform, polar form of Oklab */
interface OklchColor {
l: number;
c: number;
h: number;
alpha: number;
}
type OklchColorInput = Omit<OklchColor, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Display-P3 */
interface P3Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'display-p3';
}
type P3ColorInput = Omit<P3Color, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Rec.2020 */
interface Rec2020Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'rec2020';
}
type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & {
alpha?: number;
};
type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput;
type ColorParser<T = AnyColor> = (input: T) => RgbColor | null;
type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'name';
declare const _SENTINEL: unique symbol;
declare class Colordx {
private readonly _rgb;
private readonly _valid;
constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor);
private static _make;
/**
* Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage.
* Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a
* color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored
* _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut
* channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.
*
* Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels
* directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP
* asymmetries on gamut-boundary colors.
*
* A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one
* channel exactly on 0 or 1 while the others sit where the input's hue landed, so an
* extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels
* (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all
* three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report
* phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary;
* the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab
* see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut
* (P3 / Rec.2020 targets) and pass through untouched.
*/
static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx;
isValid(): boolean;
toRgb(): RgbColor;
/** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */
_rawRgb(): RgbColor;
/**
* Format as a `rgb()` / `rgba()` CSS string.
* Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):
* `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`
* Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also
* switches the function name to `rgba()` when alpha < 1:
* `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`
*/
toRgbString(options?: {
legacy?: boolean;
}): string;
toHex(): string;
/** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */
toHex8(): string;
/** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */
toNumber(): number;
toHsl(precision?: number): HslColor;
toHslString(precision?: number): string;
toOklab(precision?: number): OklabColor;
toOklabString(precision?: number): string;
toOklch(precision?: number): OklchColor;
toOklchString(precision?: number): string;
brightness(): number;
isDark(): boolean;
isLight(): boolean;
alpha(): number;
alpha(value: number): Colordx;
hue(): number;
hue(value: number): Colordx;
lightness(): number;
lightness(value: number): Colordx;
chroma(): number;
chroma(value: number): Colordx;
lighten(amount?: number, options?: {
relative?: boolean;
}): Colordx;
darken(amount?: number, options?: {
relative?: boolean;
}): Colordx;
saturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
desaturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
grayscale(): Colordx;
invert(): Colordx;
rotate(amount?: number): Colordx;
isEqual(color: AnyColor): boolean;
toString(): string;
/**
* Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].
* Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.
* Hue and lightness may shift noticeably for colors far outside sRGB.
* Returns `this` when already in gamut.
*/
clampSrgb(): Colordx;
/**
* Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm
* (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.
* Useful when hue stability matters — design tokens, palettes, color pickers.
* Returns `this` when already in gamut.
*/
mapSrgb(): Colordx;
/**
* Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.
* Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.
*/
static toGamutSrgb: (input: AnyColor) => Colordx;
}
type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void;
declare const colordx: (input: AnyColor | Colordx) => Colordx;
/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */
declare const toHex8: (input: AnyColor | Colordx) => string;
declare const extend: (plugins: Plugin[]) => void;
declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T;
declare const random: () => Colordx;
export { type AnyColor as A, type XyzD65Color as B, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z };
+1
-1

@@ -1,2 +0,2 @@

'use strict';var chunkUAXI5JGL_cjs=require('./chunk-UAXI5JGL.cjs'),chunkB3CQY27M_cjs=require('./chunk-B3CQY27M.cjs'),chunkGXECYURS_cjs=require('./chunk-GXECYURS.cjs');require('./chunk-GU6TZJ4O.cjs');var chunkX5FCFNQN_cjs=require('./chunk-X5FCFNQN.cjs'),chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var V=l=>({h:chunkYISEJCI6_cjs.c(l.h),s:chunkYISEJCI6_cjs.a(l.s,0,100),l:chunkYISEJCI6_cjs.a(l.l,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(l.alpha,3),0,1)}),O={h:0,s:0,l:0,alpha:0},R=({r:l,g:r,b:o,alpha:t})=>{let n=l/255,e=r/255,s=o/255,a=Math.max(n,e,s),c=Math.min(n,e,s),C=(a+c)/2,d=0,x=0;if(a!==c){let _=a-c;switch(x=C>.5?_/(2-a-c):_/(a+c),a){case n:d=((e-s)/_+(e<s?6:0))/6;break;case e:d=((s-n)/_+2)/6;break;case s:d=((n-e)/_+4)/6;break}}let y=d*360;return O.h=y>=0&&y<360?y:(y%360+360)%360,O.s=chunkYISEJCI6_cjs.a(x*100,0,100),O.l=chunkYISEJCI6_cjs.a(C*100,0,100),O.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t,3),0,1),O};var v=(l,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?l+(r-l)*6*o:o<1/2?r:o<2/3?l+(r-l)*(2/3-o)*6:l),k=({h:l,s:r,l:o,alpha:t})=>{let n=r/100,e=o/100,s=e<.5?e*(1+n):e+n-e*n,a=2*e-s,c=(l%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},J=l=>{if(!chunkYISEJCI6_cjs.h(l)||!chunkYISEJCI6_cjs.i(l,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:n=1}=l;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)?null:k(V({h:chunkYISEJCI6_cjs.g(r),s:chunkYISEJCI6_cjs.g(o),l:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.g(n)}))},Ir=new RegExp(`^hsla?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<l_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<l_s>${chunkYISEJCI6_cjs.k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),Q=l=>{if(typeof l!="string")return null;let r=Ir.exec(l.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",n=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),e=chunkYISEJCI6_cjs.l(r.s_c??r.s_s),s=chunkYISEJCI6_cjs.l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let C=a===void 0?1:chunkYISEJCI6_cjs.l(a)/(c?100:1);return k(V({h:n,s:e,l:s,alpha:C}))};var W=({l,c:r,h:o,alpha:t})=>({l,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),Y=l=>{let{l:r,a:o,b:t,alpha:n}=chunkGXECYURS_cjs.b(l),e=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:e,h:e<4e-6?0:chunkYISEJCI6_cjs.c(s),alpha:n}},M=l=>chunkGXECYURS_cjs.d(W(l)),Z=l=>chunkGXECYURS_cjs.c(W(l)),rr=l=>{if(!chunkYISEJCI6_cjs.h(l)||l.colorSpace==="lch"||!chunkYISEJCI6_cjs.i(l,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:n=1}=l;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(n)||chunkYISEJCI6_cjs.g(r)>1?null:Z({l:chunkYISEJCI6_cjs.g(r),c:Math.max(0,chunkYISEJCI6_cjs.g(o)),h:chunkYISEJCI6_cjs.c(chunkYISEJCI6_cjs.g(t)),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(n),0,1)})},Pr=new RegExp(`^oklch\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<c>${chunkYISEJCI6_cjs.k})(?<cp>%?)\\s+(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),or=l=>{if(typeof l!="string")return null;let r=Pr.exec(l.trim())?.groups;if(!r)return null;let o=r.lp?chunkYISEJCI6_cjs.l(r.l)/100:chunkYISEJCI6_cjs.l(r.l),t=Math.max(0,r.cp?chunkYISEJCI6_cjs.l(r.c)*.004:chunkYISEJCI6_cjs.l(r.c)),n=r.hu?.toLowerCase()??"deg",e=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[n]??1),s=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Z({l:o,c:t,h:chunkYISEJCI6_cjs.c(e),alpha:chunkYISEJCI6_cjs.a(s,0,1)})};var tr=[[chunkUAXI5JGL_cjs.b,"hex"],[chunk3V4MONNR_cjs.c,"rgb"],[Q,"hsl"],[or,"oklch"],[chunkGXECYURS_cjs.h,"oklab"]],lr=[[chunk3V4MONNR_cjs.b,"rgb"],[J,"hsl"],[chunkGXECYURS_cjs.g,"oklab"],[rr,"oklch"]],nr=tr.map(([l])=>l),er=lr.map(([l])=>l),sr=[...nr,...er],P=[...sr],N=[],ar=l=>{if(l==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof l=="string"?nr:er;for(let o of r){let t=o(l);if(t)return t}for(let o=sr.length;o<P.length;o++){let t=P[o](l);if(t)return t}return null},Ar=l=>{if(l==="transparent")return "name";let r=typeof l=="string"?tr:lr;for(let[o,t]of r)if(o(l))return t;for(let[o,t]of N)if(o(l))return t};var br=Symbol(),u=class l{_rgb;_valid;constructor(r,o){if(r===br)this._valid=true,this._rgb=o;else if(r instanceof l){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=ar(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(this._rgb.alpha,3),0,1);}static _make(r){return new l(br,r)}static _makeFromOklab({l:r,a:o,b:t,alpha:n}){let[e,s,a]=chunkGXECYURS_cjs.f(r,o,t);return l._make({r:chunkX5FCFNQN_cjs.b(e)*255,g:chunkX5FCFNQN_cjs.b(s)*255,b:chunkX5FCFNQN_cjs.b(a)*255,alpha:n})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return {r:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),g:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),b:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),alpha:n}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:n,alpha:e}=this._rgb,s=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),a=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),c=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(n),0,255);return r?.legacy?e<1?`rgba(${s}, ${a}, ${c}, ${e})`:`rgb(${s}, ${a}, ${c})`:e<1?`rgb(${s} ${a} ${c} / ${e})`:`rgb(${s} ${a} ${c})`}toHex(){return chunkUAXI5JGL_cjs.c(this._rgb)}toHex8(){return chunkUAXI5JGL_cjs.d(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255)<<16|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255)<<8|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255)}toHsl(r=2){let{h:o,s:t,l:n,alpha:e}=R(this._rgb),s=chunkYISEJCI6_cjs.b(o,r);return {h:s>=360?0:s,s:chunkYISEJCI6_cjs.b(t,r),l:chunkYISEJCI6_cjs.b(n,r),alpha:e}}toHslString(r=2){let{h:o,s:t,l:n,alpha:e}=this.toHsl(r);return e<1?`hsl(${o} ${t}% ${n}% / ${e})`:`hsl(${o} ${t}% ${n}%)`}toOklab(r=4){let{l:o,a:t,b:n,alpha:e}=chunkGXECYURS_cjs.b(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),a:chunkYISEJCI6_cjs.b(t,r),b:chunkYISEJCI6_cjs.b(n,r),alpha:e}}toOklabString(r=4){let{l:o,a:t,b:n,alpha:e}=this.toOklab(r);return e<1?`oklab(${o} ${t} ${n} / ${e})`:`oklab(${o} ${t} ${n})`}toOklch(r=4){let{l:o,c:t,h:n,alpha:e}=Y(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),c:chunkYISEJCI6_cjs.b(t,r),h:chunkYISEJCI6_cjs.b(n,r),alpha:e}}toOklchString(r=4){let{l:o,c:t,h:n,alpha:e}=this.toOklch(r),s=t===0?"none":n;return e<1?`oklch(${o} ${t} ${s} / ${e})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.b((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:l._make({...this._rgb,alpha:chunkYISEJCI6_cjs.b(chunkYISEJCI6_cjs.a(r,0,1),3)})}hue(r){let{h:o,s:t,l:n,alpha:e}=R(this._rgb);if(r===void 0){let s=chunkYISEJCI6_cjs.b(o,2);return s>=360?0:s}return l._make(k({h:r,s:t,l:n,alpha:e}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:l._make(M({...o,l:chunkYISEJCI6_cjs.a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:l._make(M({...o,c:chunkYISEJCI6_cjs.a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?e*(1+r):e+r*100;return l._make(k({h:t,s:n,l:chunkYISEJCI6_cjs.a(a,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a=o?.relative?n*(1+r):n+r*100;return l._make(k({h:t,s:chunkYISEJCI6_cjs.a(a,0,100),l:e,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:n}=this._rgb;return l._make({r:255-r,g:255-o,b:255-t,alpha:n})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new l(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:l._make({r:chunkYISEJCI6_cjs.a(r,0,255),g:chunkYISEJCI6_cjs.a(o,0,255),b:chunkYISEJCI6_cjs.a(t,0,255),alpha:n})}mapSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[e,s,a]=chunkGXECYURS_cjs.a(chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(o/255),chunkX5FCFNQN_cjs.a(t/255)),c=e>1-1e-7?1:e<1e-7?0:e,C=chunkB3CQY27M_cjs.p({l:c,a:s,b:a,alpha:n});return C!==null?l._makeFromOklab(C):this}static toGamutSrgb},vr=l=>new u(l),Mr=l=>new u(l).toHex8(),Nr=l=>{l.forEach(r=>r(u,P,N));},Fr=(l,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:n}=new u(l).toOklab(),e=1/0,s=r[0];for(let a of r){let{l:c,a:C,b:d}=new u(a).toOklab(),x=(c-o)**2+(C-t)**2+(d-n)**2;x<e&&(e=x,s=a);}return s},jr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=l=>{let r=chunkB3CQY27M_cjs.p(l);return r!==null?u._makeFromOklab(r):new u(l)};Object.defineProperty(exports,"toHexByte",{enumerable:true,get:function(){return chunkUAXI5JGL_cjs.a}});Object.defineProperty(exports,"inGamutSrgb",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.o}});Object.defineProperty(exports,"labToLinearAndSrgb",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.I}});Object.defineProperty(exports,"labToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.J}});Object.defineProperty(exports,"labToLinearSrgb",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.A}});Object.defineProperty(exports,"labToLinearSrgbInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.B}});Object.defineProperty(exports,"labToRgbChannels",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.E}});Object.defineProperty(exports,"labToRgbChannelsInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.F}});Object.defineProperty(exports,"lchToLinearAndSrgb",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.K}});Object.defineProperty(exports,"lchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.L}});Object.defineProperty(exports,"lchToLinearSrgb",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.C}});Object.defineProperty(exports,"lchToLinearSrgbInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.D}});Object.defineProperty(exports,"lchToRgbChannels",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.G}});Object.defineProperty(exports,"lchToRgbChannelsInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.H}});Object.defineProperty(exports,"oklchToLinear",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.s}});Object.defineProperty(exports,"oklchToLinearAndSrgb",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.w}});Object.defineProperty(exports,"oklchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.x}});Object.defineProperty(exports,"oklchToLinearInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.t}});Object.defineProperty(exports,"oklchToRgbChannels",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.u}});Object.defineProperty(exports,"oklchToRgbChannelsInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.v}});Object.defineProperty(exports,"rgbToLinear",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.y}});Object.defineProperty(exports,"rgbToLinearInto",{enumerable:true,get:function(){return chunkB3CQY27M_cjs.z}});exports.Colordx=u;exports.colordx=vr;exports.extend=Nr;exports.getFormat=Ar;exports.nearest=Fr;exports.random=jr;exports.toHex8=Mr;//# sourceMappingURL=index.cjs.map
'use strict';var chunkUAXI5JGL_cjs=require('./chunk-UAXI5JGL.cjs'),chunkJVG55LEC_cjs=require('./chunk-JVG55LEC.cjs'),chunkGXECYURS_cjs=require('./chunk-GXECYURS.cjs');require('./chunk-GU6TZJ4O.cjs');var chunkX5FCFNQN_cjs=require('./chunk-X5FCFNQN.cjs'),chunk3V4MONNR_cjs=require('./chunk-3V4MONNR.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var X=n=>({h:chunkYISEJCI6_cjs.c(n.h),s:chunkYISEJCI6_cjs.a(n.s,0,100),l:chunkYISEJCI6_cjs.a(n.l,0,100),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(n.alpha,3),0,1)}),y={h:0,s:0,l:0,alpha:0},O=({r:n,g:r,b:o,alpha:t})=>{let e=n/255,l=r/255,s=o/255,a=Math.max(e,l,s),c=Math.min(e,l,s),p=(a+c)/2,d=0,f=0;if(a!==c){let R=a-c;switch(f=p>.5?R/(2-a-c):R/(a+c),a){case e:d=((l-s)/R+(l<s?6:0))/6;break;case l:d=((s-e)/R+2)/6;break;case s:d=((e-l)/R+4)/6;break}}let k=d*360;return y.h=k>=0&&k<360?k:(k%360+360)%360,y.s=chunkYISEJCI6_cjs.a(f*100,0,100),y.l=chunkYISEJCI6_cjs.a(p*100,0,100),y.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t,3),0,1),y};var v=(n,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?n+(r-n)*6*o:o<1/2?r:o<2/3?n+(r-n)*(2/3-o)*6:n),_=({h:n,s:r,l:o,alpha:t})=>{let e=r/100,l=o/100,s=l<.5?l*(1+e):l+e-l*e,a=2*l-s,c=(n%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},V=n=>{if(!chunkYISEJCI6_cjs.h(n)||!chunkYISEJCI6_cjs.i(n,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:e=1}=n;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(e)?null:_(X({h:chunkYISEJCI6_cjs.g(r),s:chunkYISEJCI6_cjs.g(o),l:chunkYISEJCI6_cjs.g(t),alpha:chunkYISEJCI6_cjs.g(e)}))},Lr=new RegExp(`^hsla?\\(\\s*(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${chunkYISEJCI6_cjs.j})%\\s*,\\s*(?<l_c>${chunkYISEJCI6_cjs.j})%(?:\\s*,\\s*(?<al_c>${chunkYISEJCI6_cjs.j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${chunkYISEJCI6_cjs.k})(?<sp_s>%?)\\s+(?<l_s>${chunkYISEJCI6_cjs.k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${chunkYISEJCI6_cjs.k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=n=>{if(typeof n!="string")return null;let r=Lr.exec(n.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",e=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[t]??1),l=chunkYISEJCI6_cjs.l(r.s_c??r.s_s),s=chunkYISEJCI6_cjs.l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let p=a===void 0?1:chunkYISEJCI6_cjs.l(a)/(c?100:1);return _(X({h:e,s:l,l:s,alpha:p}))};var Q=({l:n,c:r,h:o,alpha:t})=>({l:n,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=n=>{let{l:r,a:o,b:t,alpha:e}=chunkGXECYURS_cjs.b(n),l=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:l,h:l<4e-6?0:chunkYISEJCI6_cjs.c(s),alpha:e}},M=n=>chunkGXECYURS_cjs.d(Q(n)),Y=n=>chunkGXECYURS_cjs.c(Q(n)),Z=n=>{if(!chunkYISEJCI6_cjs.h(n)||n.colorSpace==="lch"||!chunkYISEJCI6_cjs.i(n,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:e=1}=n;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(t)||!chunkYISEJCI6_cjs.f(e)||chunkYISEJCI6_cjs.g(r)>1?null:Y({l:chunkYISEJCI6_cjs.g(r),c:Math.max(0,chunkYISEJCI6_cjs.g(o)),h:chunkYISEJCI6_cjs.c(chunkYISEJCI6_cjs.g(t)),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(e),0,1)})},Ir=new RegExp(`^oklch\\(\\s*(?<l>${chunkYISEJCI6_cjs.k})(?<lp>%?)\\s+(?<c>${chunkYISEJCI6_cjs.k})(?<cp>%?)\\s+(?<h>${chunkYISEJCI6_cjs.k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),rr=n=>{if(typeof n!="string")return null;let r=Ir.exec(n.trim())?.groups;if(!r)return null;let o=r.lp?chunkYISEJCI6_cjs.l(r.l)/100:chunkYISEJCI6_cjs.l(r.l),t=Math.max(0,r.cp?chunkYISEJCI6_cjs.l(r.c)*.004:chunkYISEJCI6_cjs.l(r.c)),e=r.hu?.toLowerCase()??"deg",l=chunkYISEJCI6_cjs.l(r.h)*(chunkYISEJCI6_cjs.d[e]??1),s=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:chunkYISEJCI6_cjs.c(l),alpha:chunkYISEJCI6_cjs.a(s,0,1)})};var or=[[chunkUAXI5JGL_cjs.b,"hex"],[chunk3V4MONNR_cjs.c,"rgb"],[J,"hsl"],[rr,"oklch"],[chunkGXECYURS_cjs.h,"oklab"]],tr=[[chunk3V4MONNR_cjs.b,"rgb"],[V,"hsl"],[chunkGXECYURS_cjs.g,"oklab"],[Z,"oklch"]],nr=or.map(([n])=>n),lr=tr.map(([n])=>n),er=[...nr,...lr],P=[...er],N=[],sr=n=>{if(n==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof n=="string"?nr:lr;for(let o of r){let t=o(n);if(t)return t}for(let o=er.length;o<P.length;o++){let t=P[o](n);if(t)return t}return null},Pr=n=>{if(n==="transparent")return "name";let r=typeof n=="string"?or:tr;for(let[o,t]of r)if(o(n))return t;for(let[o,t]of N)if(o(n))return t};var ar=Symbol(),u=class n{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof n){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(this._rgb.alpha,3),0,1);}static _make(r){return new n(ar,r)}static _makeFromLinearSrgb(r,o,t,e){let l=chunkX5FCFNQN_cjs.b(r)*255,s=chunkX5FCFNQN_cjs.b(o)*255,a=chunkX5FCFNQN_cjs.b(t)*255;return n._make({r:l>=0&&l<.5?0:l>254.5&&l<=255?255:l,g:s>=0&&s<.5?0:s>254.5&&s<=255?255:s,b:a>=0&&a<.5?0:a>254.5&&a<=255?255:a,alpha:e})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return {r:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255),g:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),b:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),alpha:e}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:e,alpha:l}=this._rgb,s=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255),a=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255),c=chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(e),0,255);return r?.legacy?l<1?`rgba(${s}, ${a}, ${c}, ${l})`:`rgb(${s}, ${a}, ${c})`:l<1?`rgb(${s} ${a} ${c} / ${l})`:`rgb(${s} ${a} ${c})`}toHex(){return chunkUAXI5JGL_cjs.c(this._rgb)}toHex8(){return chunkUAXI5JGL_cjs.d(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(r),0,255)<<16|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(o),0,255)<<8|chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.b(t),0,255)}toHsl(r=2){let{h:o,s:t,l:e,alpha:l}=O(this._rgb),s=chunkYISEJCI6_cjs.b(o,r);return {h:s>=360?0:s,s:chunkYISEJCI6_cjs.b(t,r),l:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toHslString(r=2){let{h:o,s:t,l:e,alpha:l}=this.toHsl(r);return l<1?`hsl(${o} ${t}% ${e}% / ${l})`:`hsl(${o} ${t}% ${e}%)`}toOklab(r=4){let{l:o,a:t,b:e,alpha:l}=chunkGXECYURS_cjs.b(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),a:chunkYISEJCI6_cjs.b(t,r),b:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toOklabString(r=4){let{l:o,a:t,b:e,alpha:l}=this.toOklab(r);return l<1?`oklab(${o} ${t} ${e} / ${l})`:`oklab(${o} ${t} ${e})`}toOklch(r=4){let{l:o,c:t,h:e,alpha:l}=W(this._rgb);return {l:chunkYISEJCI6_cjs.b(o,r),c:chunkYISEJCI6_cjs.b(t,r),h:chunkYISEJCI6_cjs.b(e,r),alpha:l}}toOklchString(r=4){let{l:o,c:t,h:e,alpha:l}=this.toOklch(r),s=t===0?"none":e;return l<1?`oklch(${o} ${t} ${s} / ${l})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return chunkYISEJCI6_cjs.b((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:n._make({...this._rgb,alpha:chunkYISEJCI6_cjs.b(chunkYISEJCI6_cjs.a(r,0,1),3)})}hue(r){let{h:o,s:t,l:e,alpha:l}=O(this._rgb);if(r===void 0){let s=chunkYISEJCI6_cjs.b(o,2);return s>=360?0:s}return n._make(_({h:r,s:t,l:e,alpha:l}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:n._make(M({...o,l:chunkYISEJCI6_cjs.a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:n._make(M({...o,c:chunkYISEJCI6_cjs.a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a=o?.relative?l*(1+r):l+r*100;return n._make(_({h:t,s:e,l:chunkYISEJCI6_cjs.a(a,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a=o?.relative?e*(1+r):e+r*100;return n._make(_({h:t,s:chunkYISEJCI6_cjs.a(a,0,100),l,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:e}=this._rgb;return n._make({r:255-r,g:255-o,b:255-t,alpha:e})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new n(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:n._make({r:chunkYISEJCI6_cjs.a(r,0,255),g:chunkYISEJCI6_cjs.a(o,0,255),b:chunkYISEJCI6_cjs.a(t,0,255),alpha:e})}mapSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[l,s,a]=chunkGXECYURS_cjs.a(chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(o/255),chunkX5FCFNQN_cjs.a(t/255)),c=l>1-1e-7?1:l<1e-7?0:l,p=chunkJVG55LEC_cjs.p({l:c,a:s,b:a,alpha:e});if(p===null)return this;let[d,f,k]=p.linear;return n._makeFromLinearSrgb(d,f,k,p.alpha)}static toGamutSrgb},Ar=n=>new u(n),vr=n=>new u(n).toHex8(),Mr=n=>{n.forEach(r=>r(u,P,N));},Nr=(n,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:e}=new u(n).toOklab(),l=1/0,s=r[0];for(let a of r){let{l:c,a:p,b:d}=new u(a).toOklab(),f=(c-o)**2+(p-t)**2+(d-e)**2;f<l&&(l=f,s=a);}return s},Fr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=n=>{let r=chunkJVG55LEC_cjs.p(n);if(r===null)return new u(n);let[o,t,e]=r.linear;return u._makeFromLinearSrgb(o,t,e,r.alpha)};Object.defineProperty(exports,"toHexByte",{enumerable:true,get:function(){return chunkUAXI5JGL_cjs.a}});Object.defineProperty(exports,"inGamutSrgb",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.o}});Object.defineProperty(exports,"labToLinearAndSrgb",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.I}});Object.defineProperty(exports,"labToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.J}});Object.defineProperty(exports,"labToLinearSrgb",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.A}});Object.defineProperty(exports,"labToLinearSrgbInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.B}});Object.defineProperty(exports,"labToRgbChannels",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.E}});Object.defineProperty(exports,"labToRgbChannelsInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.F}});Object.defineProperty(exports,"lchToLinearAndSrgb",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.K}});Object.defineProperty(exports,"lchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.L}});Object.defineProperty(exports,"lchToLinearSrgb",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.C}});Object.defineProperty(exports,"lchToLinearSrgbInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.D}});Object.defineProperty(exports,"lchToRgbChannels",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.G}});Object.defineProperty(exports,"lchToRgbChannelsInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.H}});Object.defineProperty(exports,"oklchToLinear",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.s}});Object.defineProperty(exports,"oklchToLinearAndSrgb",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.w}});Object.defineProperty(exports,"oklchToLinearAndSrgbInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.x}});Object.defineProperty(exports,"oklchToLinearInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.t}});Object.defineProperty(exports,"oklchToRgbChannels",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.u}});Object.defineProperty(exports,"oklchToRgbChannelsInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.v}});Object.defineProperty(exports,"rgbToLinear",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.y}});Object.defineProperty(exports,"rgbToLinearInto",{enumerable:true,get:function(){return chunkJVG55LEC_cjs.z}});exports.Colordx=u;exports.colordx=Ar;exports.extend=Mr;exports.getFormat=Pr;exports.nearest=Nr;exports.random=Fr;exports.toHex8=vr;//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","a","lr","lg","lb","oklabToLinear","srgbFromLinear","options","ri","gi","bi","rgbToHex","rgbToHex8","precision","hr","value","amount","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrgbRaw","colordx","toHex8","extend","plugins","plugin","nearest","candidates","l1","a1","b1","minDist","candidate","l2","a2","b2","dist","random"],"mappings":"iWAeO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,mBAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,EACtB,KAAA,CAAOE,mBAAAA,CAAMC,mBAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,CAAA,CAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAE1CC,CAAAA,CAAc,CAAC,CAAE,EAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,GAA0B,CACrE,IAAMC,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,CACbK,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,CACTK,CAAAA,CAAKJ,EAAI,GAAA,CACLK,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAIH,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAC7BE,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAIJ,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACrBG,CAAAA,CAAAA,CAAKF,EAAMC,CAAAA,EAAO,CAAA,CACpBE,CAAAA,CAAI,CAAA,CACNC,CAAAA,CAAI,CAAA,CAEN,GAAIJ,CAAAA,GAAQC,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AI,GAAG,CAAA,CACjC,KAAA,CAAO,CACT,CAAC,EAEHA,EAAQ,WAAA,CAAevD,CAAAA,EAA6B,CAClD,IAAMoF,CAAAA,CAASC,mBAAAA,CAAerF,CAAK,CAAA,CACnC,OAAOoF,CAAAA,GAAW,IAAA,CAAO7B,CAAAA,CAAQ,cAAA,CAAe6B,CAAM,CAAA,CAAI,IAAI7B,CAAAA,CAAQvD,CAAK,CAC7E,CAAA","file":"index.cjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex, rgbToHex8 } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, oklabToLinear, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.\n * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,\n * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.\n * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n */\n static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return Colordx._make({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n /**\n * Format as a `rgb()` / `rgba()` CSS string.\n * Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):\n * `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`\n * Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also\n * switches the function name to `rgba()` when alpha < 1:\n * `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`\n */\n toRgbString(options?: { legacy?: boolean }): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n if (options?.legacy) {\n return alpha < 1 ? `rgba(${ri}, ${gi}, ${bi}, ${alpha})` : `rgb(${ri}, ${gi}, ${bi})`;\n }\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */\n toHex8(): string {\n return rgbToHex8(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(precision = 4): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, precision), a: round(a, precision), b: round(b, precision), alpha };\n }\n\n toOklabString(precision = 4): string {\n const { l, a, b, alpha } = this.toOklab(precision);\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(precision = 4): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, precision), c: round(c, precision), h: round(h, precision), alpha };\n }\n\n toOklchString(precision = 4): string {\n const { l, c, h, alpha } = this.toOklch(precision);\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n return mapped !== null ? Colordx._makeFromOklab(mapped) : this;\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\n/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */\nexport const toHex8 = (input: AnyColor | Colordx): string => new Colordx(input).toHex8();\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n return mapped !== null ? Colordx._makeFromOklab(mapped) : new Colordx(input);\n};\n"]}
{"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","lr","lg","lb","rb","srgbFromLinear","gb","bb","options","ri","gi","bi","rgbToHex","rgbToHex8","precision","hr","a","value","amount","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrgbRaw","mr","mg","mb","colordx","toHex8","extend","plugins","plugin","nearest","candidates","l1","a1","b1","minDist","candidate","l2","a2","b2","dist","random"],"mappings":"iWAeO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,mBAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,mBAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,EACtB,KAAA,CAAOE,mBAAAA,CAAMC,mBAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,CAAA,CAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,EAAG,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAE1CC,CAAAA,CAAc,CAAC,CAAE,CAAA,CAAAC,EAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,GAA0B,CACrE,IAAMC,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,CACbK,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,CACTK,CAAAA,CAAKJ,CAAAA,CAAI,IACLK,CAAAA,CAAM,IAAA,CAAK,GAAA,CAAIH,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAC7BE,CAAAA,CAAM,KAAK,GAAA,CAAIJ,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACrBG,CAAAA,CAAAA,CAAKF,CAAAA,CAAMC,CAAAA,EAAO,EACpBE,CAAAA,CAAI,CAAA,CACNC,CAAAA,CAAI,CAAA,CAEN,GAAIJ,CAAAA,GAAQC,CAAAA,CAAK,CACf,IAAMI,CAAAA,CAAI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AAA,CAAS,IACpB,IAAIpD,CAAAA,CAAQ,CACV,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,EACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,MAAO,CACT,CAAC,EAEHA,CAAAA,CAAQ,WAAA,CAAevD,CAAAA,EAA6B,CAClD,IAAMsF,EAASC,mBAAAA,CAAevF,CAAK,CAAA,CACnC,GAAIsF,CAAAA,GAAW,IAAA,CAAM,OAAO,IAAI/B,EAAQvD,CAAK,CAAA,CAC7C,GAAM,CAACwF,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAAIJ,EAAO,MAAA,CAC5B,OAAO/B,CAAAA,CAAQ,mBAAA,CAAoBiC,CAAAA,CAAIC,CAAAA,CAAIC,CAAAA,CAAIJ,CAAAA,CAAO,KAAK,CAC7D,CAAA","file":"index.cjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex, rgbToHex8 } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage.\n * Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a\n * color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored\n * _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut\n * channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n *\n * Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels\n * directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP\n * asymmetries on gamut-boundary colors.\n *\n * A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one\n * channel exactly on 0 or 1 while the others sit where the input's hue landed, so an\n * extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels\n * (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all\n * three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report\n * phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary;\n * the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab\n * see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut\n * (P3 / Rec.2020 targets) and pass through untouched.\n */\n static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx {\n const rb = srgbFromLinear(lr) * 255;\n const gb = srgbFromLinear(lg) * 255;\n const bb = srgbFromLinear(lb) * 255;\n return Colordx._make({\n r: rb >= 0 && rb < 0.5 ? 0 : rb > 254.5 && rb <= 255 ? 255 : rb,\n g: gb >= 0 && gb < 0.5 ? 0 : gb > 254.5 && gb <= 255 ? 255 : gb,\n b: bb >= 0 && bb < 0.5 ? 0 : bb > 254.5 && bb <= 255 ? 255 : bb,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n /**\n * Format as a `rgb()` / `rgba()` CSS string.\n * Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):\n * `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`\n * Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also\n * switches the function name to `rgba()` when alpha < 1:\n * `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`\n */\n toRgbString(options?: { legacy?: boolean }): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n if (options?.legacy) {\n return alpha < 1 ? `rgba(${ri}, ${gi}, ${bi}, ${alpha})` : `rgb(${ri}, ${gi}, ${bi})`;\n }\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */\n toHex8(): string {\n return rgbToHex8(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(precision = 4): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, precision), a: round(a, precision), b: round(b, precision), alpha };\n }\n\n toOklabString(precision = 4): string {\n const { l, a, b, alpha } = this.toOklab(precision);\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(precision = 4): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, precision), c: round(c, precision), h: round(h, precision), alpha };\n }\n\n toOklchString(precision = 4): string {\n const { l, c, h, alpha } = this.toOklch(precision);\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n if (mapped === null) return this;\n const [mr, mg, mb] = mapped.linear;\n return Colordx._makeFromLinearSrgb(mr, mg, mb, mapped.alpha);\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\n/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */\nexport const toHex8 = (input: AnyColor | Colordx): string => new Colordx(input).toHex8();\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n if (mapped === null) return new Colordx(input);\n const [mr, mg, mb] = mapped.linear;\n return Colordx._makeFromLinearSrgb(mr, mg, mb, mapped.alpha);\n};\n"]}

@@ -1,3 +0,3 @@

import { A as AnyColor, C as ColorFormat } from './colordx-CQAwj4SM.cjs';
export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-CQAwj4SM.cjs';
import { A as AnyColor, C as ColorFormat } from './colordx-FkeB37IC.cjs';
export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-FkeB37IC.cjs';

@@ -4,0 +4,0 @@ /** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */

@@ -1,3 +0,3 @@

import { A as AnyColor, C as ColorFormat } from './colordx-CQAwj4SM.js';
export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-CQAwj4SM.js';
import { A as AnyColor, C as ColorFormat } from './colordx-FkeB37IC.js';
export { a as CmykColor, b as CmykColorInput, c as ColorParser, d as Colordx, H as HslColor, e as HslColorInput, f as HsvColor, g as HsvColorInput, h as HwbColor, i as HwbColorInput, L as LabColor, j as LabColorInput, k as LchColor, l as LchColorInput, O as OklabColor, m as OklabColorInput, n as OklchColor, o as OklchColorInput, P as P3Color, p as P3ColorInput, q as Plugin, R as Rec2020Color, r as Rec2020ColorInput, s as RgbColor, t as RgbColorInput, X as XyzColor, u as XyzColorInput, v as colordx, w as extend, x as nearest, y as random, z as toHex8 } from './colordx-FkeB37IC.js';

@@ -4,0 +4,0 @@ /** Convert a number in [0, 255] to a 2-char lowercase hex byte. Clamps and rounds out-of-range inputs. */

@@ -1,2 +0,2 @@

import {b,c as c$3,d as d$1}from'./chunk-RJNXPIQM.mjs';export{a as toHexByte}from'./chunk-RJNXPIQM.mjs';import {p}from'./chunk-DIWXRMTC.mjs';export{o as inGamutSrgb,I as labToLinearAndSrgb,J as labToLinearAndSrgbInto,A as labToLinearSrgb,B as labToLinearSrgbInto,E as labToRgbChannels,F as labToRgbChannelsInto,K as lchToLinearAndSrgb,L as lchToLinearAndSrgbInto,C as lchToLinearSrgb,D as lchToLinearSrgbInto,G as lchToRgbChannels,H as lchToRgbChannelsInto,s as oklchToLinear,w as oklchToLinearAndSrgb,x as oklchToLinearAndSrgbInto,t as oklchToLinearInto,u as oklchToRgbChannels,v as oklchToRgbChannelsInto,y as rgbToLinear,z as rgbToLinearInto}from'./chunk-DIWXRMTC.mjs';import {h,g,c as c$2,f as f$1,b as b$4,a as a$1,d as d$2}from'./chunk-J6CH5YTL.mjs';import'./chunk-4LKLL3IS.mjs';import {b as b$3,a as a$2}from'./chunk-FXCFKFXK.mjs';import {c,b as b$1}from'./chunk-Q3O3QQ4H.mjs';import {l,d,a,c as c$1,h as h$1,i,f,g as g$1,k as k$1,j,b as b$2}from'./chunk-IOXRZECH.mjs';var V=l=>({h:c$1(l.h),s:a(l.s,0,100),l:a(l.l,0,100),alpha:a(b$2(l.alpha,3),0,1)}),O={h:0,s:0,l:0,alpha:0},R=({r:l,g:r,b:o,alpha:t})=>{let n=l/255,e=r/255,s=o/255,a$1=Math.max(n,e,s),c=Math.min(n,e,s),C=(a$1+c)/2,d=0,x=0;if(a$1!==c){let _=a$1-c;switch(x=C>.5?_/(2-a$1-c):_/(a$1+c),a$1){case n:d=((e-s)/_+(e<s?6:0))/6;break;case e:d=((s-n)/_+2)/6;break;case s:d=((n-e)/_+4)/6;break}}let y=d*360;return O.h=y>=0&&y<360?y:(y%360+360)%360,O.s=a(x*100,0,100),O.l=a(C*100,0,100),O.alpha=a(b$2(t,3),0,1),O};var v=(l,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?l+(r-l)*6*o:o<1/2?r:o<2/3?l+(r-l)*(2/3-o)*6:l),k=({h:l,s:r,l:o,alpha:t})=>{let n=r/100,e=o/100,s=e<.5?e*(1+n):e+n-e*n,a=2*e-s,c=(l%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},J=l=>{if(!h$1(l)||!i(l,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:n=1}=l;return !f(r)||!f(o)||!f(t)||!f(n)?null:k(V({h:g$1(r),s:g$1(o),l:g$1(t),alpha:g$1(n)}))},Ir=new RegExp(`^hsla?\\(\\s*(?<h>${k$1})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j})%\\s*,\\s*(?<l_c>${j})%(?:\\s*,\\s*(?<al_c>${j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k$1})(?<sp_s>%?)\\s+(?<l_s>${k$1})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${k$1})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),Q=l$1=>{if(typeof l$1!="string")return null;let r=Ir.exec(l$1.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",n=l(r.h)*(d[t]??1),e=l(r.s_c??r.s_s),s=l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let C=a===void 0?1:l(a)/(c?100:1);return k(V({h:n,s:e,l:s,alpha:C}))};var W=({l,c:r,h:o,alpha:t})=>({l,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),Y=l=>{let{l:r,a:o,b:t,alpha:n}=b$4(l),e=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:e,h:e<4e-6?0:c$1(s),alpha:n}},M=l=>d$2(W(l)),Z=l=>c$2(W(l)),rr=l=>{if(!h$1(l)||l.colorSpace==="lch"||!i(l,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:n=1}=l;return !f(r)||!f(o)||!f(t)||!f(n)||g$1(r)>1?null:Z({l:g$1(r),c:Math.max(0,g$1(o)),h:c$1(g$1(t)),alpha:a(g$1(n),0,1)})},Pr=new RegExp(`^oklch\\(\\s*(?<l>${k$1})(?<lp>%?)\\s+(?<c>${k$1})(?<cp>%?)\\s+(?<h>${k$1})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),or=l$1=>{if(typeof l$1!="string")return null;let r=Pr.exec(l$1.trim())?.groups;if(!r)return null;let o=r.lp?l(r.l)/100:l(r.l),t=Math.max(0,r.cp?l(r.c)*.004:l(r.c)),n=r.hu?.toLowerCase()??"deg",e=l(r.h)*(d[n]??1),s=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Z({l:o,c:t,h:c$1(e),alpha:a(s,0,1)})};var tr=[[b,"hex"],[c,"rgb"],[Q,"hsl"],[or,"oklch"],[h,"oklab"]],lr=[[b$1,"rgb"],[J,"hsl"],[g,"oklab"],[rr,"oklch"]],nr=tr.map(([l])=>l),er=lr.map(([l])=>l),sr=[...nr,...er],P=[...sr],N=[],ar=l=>{if(l==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof l=="string"?nr:er;for(let o of r){let t=o(l);if(t)return t}for(let o=sr.length;o<P.length;o++){let t=P[o](l);if(t)return t}return null},Ar=l=>{if(l==="transparent")return "name";let r=typeof l=="string"?tr:lr;for(let[o,t]of r)if(o(l))return t;for(let[o,t]of N)if(o(l))return t};var br=Symbol(),u=class l{_rgb;_valid;constructor(r,o){if(r===br)this._valid=true,this._rgb=o;else if(r instanceof l){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=ar(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=a(b$2(this._rgb.alpha,3),0,1);}static _make(r){return new l(br,r)}static _makeFromOklab({l:r,a:o,b:t,alpha:n}){let[e,s,a]=f$1(r,o,t);return l._make({r:b$3(e)*255,g:b$3(s)*255,b:b$3(a)*255,alpha:n})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return {r:a(b$2(r),0,255),g:a(b$2(o),0,255),b:a(b$2(t),0,255),alpha:n}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:n,alpha:e}=this._rgb,s=a(b$2(o),0,255),a$1=a(b$2(t),0,255),c=a(b$2(n),0,255);return r?.legacy?e<1?`rgba(${s}, ${a$1}, ${c}, ${e})`:`rgb(${s}, ${a$1}, ${c})`:e<1?`rgb(${s} ${a$1} ${c} / ${e})`:`rgb(${s} ${a$1} ${c})`}toHex(){return c$3(this._rgb)}toHex8(){return d$1(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return a(b$2(r),0,255)<<16|a(b$2(o),0,255)<<8|a(b$2(t),0,255)}toHsl(r=2){let{h:o,s:t,l:n,alpha:e}=R(this._rgb),s=b$2(o,r);return {h:s>=360?0:s,s:b$2(t,r),l:b$2(n,r),alpha:e}}toHslString(r=2){let{h:o,s:t,l:n,alpha:e}=this.toHsl(r);return e<1?`hsl(${o} ${t}% ${n}% / ${e})`:`hsl(${o} ${t}% ${n}%)`}toOklab(r=4){let{l:o,a:t,b:n,alpha:e}=b$4(this._rgb);return {l:b$2(o,r),a:b$2(t,r),b:b$2(n,r),alpha:e}}toOklabString(r=4){let{l:o,a:t,b:n,alpha:e}=this.toOklab(r);return e<1?`oklab(${o} ${t} ${n} / ${e})`:`oklab(${o} ${t} ${n})`}toOklch(r=4){let{l:o,c:t,h:n,alpha:e}=Y(this._rgb);return {l:b$2(o,r),c:b$2(t,r),h:b$2(n,r),alpha:e}}toOklchString(r=4){let{l:o,c:t,h:n,alpha:e}=this.toOklch(r),s=t===0?"none":n;return e<1?`oklch(${o} ${t} ${s} / ${e})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return b$2((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:l._make({...this._rgb,alpha:b$2(a(r,0,1),3)})}hue(r){let{h:o,s:t,l:n,alpha:e}=R(this._rgb);if(r===void 0){let s=b$2(o,2);return s>=360?0:s}return l._make(k({h:r,s:t,l:n,alpha:e}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:l._make(M({...o,l:a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:l._make(M({...o,c:a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a$1=o?.relative?e*(1+r):e+r*100;return l._make(k({h:t,s:n,l:a(a$1,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:n,l:e,alpha:s}=R(this._rgb),a$1=o?.relative?n*(1+r):n+r*100;return l._make(k({h:t,s:a(a$1,0,100),l:e,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:n}=this._rgb;return l._make({r:255-r,g:255-o,b:255-t,alpha:n})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new l(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:l._make({r:a(r,0,255),g:a(o,0,255),b:a(t,0,255),alpha:n})}mapSrgb(){let{r,g:o,b:t,alpha:n}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[e,s,a]=a$1(a$2(r/255),a$2(o/255),a$2(t/255)),c=e>1-1e-7?1:e<1e-7?0:e,C=p({l:c,a:s,b:a,alpha:n});return C!==null?l._makeFromOklab(C):this}static toGamutSrgb},vr=l=>new u(l),Mr=l=>new u(l).toHex8(),Nr=l=>{l.forEach(r=>r(u,P,N));},Fr=(l,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:n}=new u(l).toOklab(),e=1/0,s=r[0];for(let a of r){let{l:c,a:C,b:d}=new u(a).toOklab(),x=(c-o)**2+(C-t)**2+(d-n)**2;x<e&&(e=x,s=a);}return s},jr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=l=>{let r=p(l);return r!==null?u._makeFromOklab(r):new u(l)};export{u as Colordx,vr as colordx,Nr as extend,Ar as getFormat,Fr as nearest,jr as random,Mr as toHex8};//# sourceMappingURL=index.mjs.map
import {b,c as c$3,d as d$1}from'./chunk-RJNXPIQM.mjs';export{a as toHexByte}from'./chunk-RJNXPIQM.mjs';import {p}from'./chunk-BXGFP5BN.mjs';export{o as inGamutSrgb,I as labToLinearAndSrgb,J as labToLinearAndSrgbInto,A as labToLinearSrgb,B as labToLinearSrgbInto,E as labToRgbChannels,F as labToRgbChannelsInto,K as lchToLinearAndSrgb,L as lchToLinearAndSrgbInto,C as lchToLinearSrgb,D as lchToLinearSrgbInto,G as lchToRgbChannels,H as lchToRgbChannelsInto,s as oklchToLinear,w as oklchToLinearAndSrgb,x as oklchToLinearAndSrgbInto,t as oklchToLinearInto,u as oklchToRgbChannels,v as oklchToRgbChannelsInto,y as rgbToLinear,z as rgbToLinearInto}from'./chunk-BXGFP5BN.mjs';import {h,g,c as c$2,b as b$4,a as a$1,d as d$2}from'./chunk-J6CH5YTL.mjs';import'./chunk-4LKLL3IS.mjs';import {b as b$3,a as a$2}from'./chunk-FXCFKFXK.mjs';import {c,b as b$1}from'./chunk-Q3O3QQ4H.mjs';import {l,d,a,c as c$1,h as h$1,i,f,g as g$1,k,j,b as b$2}from'./chunk-IOXRZECH.mjs';var X=n=>({h:c$1(n.h),s:a(n.s,0,100),l:a(n.l,0,100),alpha:a(b$2(n.alpha,3),0,1)}),y={h:0,s:0,l:0,alpha:0},O=({r:n,g:r,b:o,alpha:t})=>{let e=n/255,l=r/255,s=o/255,a$1=Math.max(e,l,s),c=Math.min(e,l,s),p=(a$1+c)/2,d=0,f=0;if(a$1!==c){let R=a$1-c;switch(f=p>.5?R/(2-a$1-c):R/(a$1+c),a$1){case e:d=((l-s)/R+(l<s?6:0))/6;break;case l:d=((s-e)/R+2)/6;break;case s:d=((e-l)/R+4)/6;break}}let k=d*360;return y.h=k>=0&&k<360?k:(k%360+360)%360,y.s=a(f*100,0,100),y.l=a(p*100,0,100),y.alpha=a(b$2(t,3),0,1),y};var v=(n,r,o)=>(o<0&&(o+=1),o>1&&(o-=1),o<1/6?n+(r-n)*6*o:o<1/2?r:o<2/3?n+(r-n)*(2/3-o)*6:n),_=({h:n,s:r,l:o,alpha:t})=>{let e=r/100,l=o/100,s=l<.5?l*(1+e):l+e-l*e,a=2*l-s,c=(n%360+360)%360/360;return {r:v(a,s,c+1/3)*255,g:v(a,s,c)*255,b:v(a,s,c-1/3)*255,alpha:t}},V=n=>{if(!h$1(n)||!i(n,["h","s","l"]))return null;let{h:r,s:o,l:t,alpha:e=1}=n;return !f(r)||!f(o)||!f(t)||!f(e)?null:_(X({h:g$1(r),s:g$1(o),l:g$1(t),alpha:g$1(e)}))},Lr=new RegExp(`^hsla?\\(\\s*(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:,\\s*(?<s_c>${j})%\\s*,\\s*(?<l_c>${j})%(?:\\s*,\\s*(?<al_c>${j})(?<alp_c>%?)?\\s*)?|\\s+(?<s_s>${k})(?<sp_s>%?)\\s+(?<l_s>${k})(?<lp_s>%?)(?:\\s*/\\s*(?<al_s>${k})(?<alp_s>%?)?\\s*)?)\\)$`,"i"),J=n=>{if(typeof n!="string")return null;let r=Lr.exec(n.trim())?.groups;if(!r)return null;let o=r.s_c!==void 0;if(o&&/^none$/i.test(r.h))return null;let t=r.hu?.toLowerCase()??"deg",e=l(r.h)*(d[t]??1),l$1=l(r.s_c??r.s_s),s=l(r.l_c??r.l_s),a=r.al_c??r.al_s,c=!!(r.alp_c??r.alp_s);if(o&&a!==void 0&&/^none$/i.test(a))return null;let p=a===void 0?1:l(a)/(c?100:1);return _(X({h:e,s:l$1,l:s,alpha:p}))};var Q=({l:n,c:r,h:o,alpha:t})=>({l:n,a:r*Math.cos(o*Math.PI/180),b:r*Math.sin(o*Math.PI/180),alpha:t}),W=n=>{let{l:r,a:o,b:t,alpha:e}=b$4(n),l=Math.sqrt(o*o+t*t),s=Math.atan2(t,o)*180/Math.PI;return {l:r,c:l,h:l<4e-6?0:c$1(s),alpha:e}},M=n=>d$2(Q(n)),Y=n=>c$2(Q(n)),Z=n=>{if(!h$1(n)||n.colorSpace==="lch"||!i(n,["l","c","h"]))return null;let{l:r,c:o,h:t,alpha:e=1}=n;return !f(r)||!f(o)||!f(t)||!f(e)||g$1(r)>1?null:Y({l:g$1(r),c:Math.max(0,g$1(o)),h:c$1(g$1(t)),alpha:a(g$1(e),0,1)})},Ir=new RegExp(`^oklch\\(\\s*(?<l>${k})(?<lp>%?)\\s+(?<c>${k})(?<cp>%?)\\s+(?<h>${k})(?<hu>deg|rad|grad|turn)?\\s*(?:/\\s*(?<al>${k})(?<alp>%?)\\s*)?\\)$`,"i"),rr=n=>{if(typeof n!="string")return null;let r=Ir.exec(n.trim())?.groups;if(!r)return null;let o=r.lp?l(r.l)/100:l(r.l),t=Math.max(0,r.cp?l(r.c)*.004:l(r.c)),e=r.hu?.toLowerCase()??"deg",l$1=l(r.h)*(d[e]??1),s=r.al===void 0?1:l(r.al)/(r.alp?100:1);return Y({l:o,c:t,h:c$1(l$1),alpha:a(s,0,1)})};var or=[[b,"hex"],[c,"rgb"],[J,"hsl"],[rr,"oklch"],[h,"oklab"]],tr=[[b$1,"rgb"],[V,"hsl"],[g,"oklab"],[Z,"oklch"]],nr=or.map(([n])=>n),lr=tr.map(([n])=>n),er=[...nr,...lr],P=[...er],N=[],sr=n=>{if(n==="transparent")return {r:0,g:0,b:0,alpha:0};let r=typeof n=="string"?nr:lr;for(let o of r){let t=o(n);if(t)return t}for(let o=er.length;o<P.length;o++){let t=P[o](n);if(t)return t}return null},Pr=n=>{if(n==="transparent")return "name";let r=typeof n=="string"?or:tr;for(let[o,t]of r)if(o(n))return t;for(let[o,t]of N)if(o(n))return t};var ar=Symbol(),u=class n{_rgb;_valid;constructor(r,o){if(r===ar)this._valid=true,this._rgb=o;else if(r instanceof n){this._valid=r._valid,this._rgb=r._rgb;return}else {let t=sr(r);this._valid=t!==null,this._rgb=t??{r:0,g:0,b:0,alpha:1};}this._rgb.alpha=a(b$2(this._rgb.alpha,3),0,1);}static _make(r){return new n(ar,r)}static _makeFromLinearSrgb(r,o,t,e){let l=b$3(r)*255,s=b$3(o)*255,a=b$3(t)*255;return n._make({r:l>=0&&l<.5?0:l>254.5&&l<=255?255:l,g:s>=0&&s<.5?0:s>254.5&&s<=255?255:s,b:a>=0&&a<.5?0:a>254.5&&a<=255?255:a,alpha:e})}isValid(){return this._valid}toRgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return {r:a(b$2(r),0,255),g:a(b$2(o),0,255),b:a(b$2(t),0,255),alpha:e}}_rawRgb(){return this._rgb}toRgbString(r){let{r:o,g:t,b:e,alpha:l}=this._rgb,s=a(b$2(o),0,255),a$1=a(b$2(t),0,255),c=a(b$2(e),0,255);return r?.legacy?l<1?`rgba(${s}, ${a$1}, ${c}, ${l})`:`rgb(${s}, ${a$1}, ${c})`:l<1?`rgb(${s} ${a$1} ${c} / ${l})`:`rgb(${s} ${a$1} ${c})`}toHex(){return c$3(this._rgb)}toHex8(){return d$1(this._rgb)}toNumber(){let{r,g:o,b:t}=this._rgb;return a(b$2(r),0,255)<<16|a(b$2(o),0,255)<<8|a(b$2(t),0,255)}toHsl(r=2){let{h:o,s:t,l:e,alpha:l}=O(this._rgb),s=b$2(o,r);return {h:s>=360?0:s,s:b$2(t,r),l:b$2(e,r),alpha:l}}toHslString(r=2){let{h:o,s:t,l:e,alpha:l}=this.toHsl(r);return l<1?`hsl(${o} ${t}% ${e}% / ${l})`:`hsl(${o} ${t}% ${e}%)`}toOklab(r=4){let{l:o,a:t,b:e,alpha:l}=b$4(this._rgb);return {l:b$2(o,r),a:b$2(t,r),b:b$2(e,r),alpha:l}}toOklabString(r=4){let{l:o,a:t,b:e,alpha:l}=this.toOklab(r);return l<1?`oklab(${o} ${t} ${e} / ${l})`:`oklab(${o} ${t} ${e})`}toOklch(r=4){let{l:o,c:t,h:e,alpha:l}=W(this._rgb);return {l:b$2(o,r),c:b$2(t,r),h:b$2(e,r),alpha:l}}toOklchString(r=4){let{l:o,c:t,h:e,alpha:l}=this.toOklch(r),s=t===0?"none":e;return l<1?`oklch(${o} ${t} ${s} / ${l})`:`oklch(${o} ${t} ${s})`}brightness(){let{r,g:o,b:t}=this._rgb;return b$2((r*299+o*587+t*114)/255e3,2)}isDark(){return this.brightness()<.5}isLight(){return this.brightness()>=.5}alpha(r){return r===void 0?this._rgb.alpha:n._make({...this._rgb,alpha:b$2(a(r,0,1),3)})}hue(r){let{h:o,s:t,l:e,alpha:l}=O(this._rgb);if(r===void 0){let s=b$2(o,2);return s>=360?0:s}return n._make(_({h:r,s:t,l:e,alpha:l}))}lightness(r){let o=this.toOklch();return r===void 0?o.l:n._make(M({...o,l:a(r,0,1)}))}chroma(r){let o=this.toOklch();return r===void 0?o.c:n._make(M({...o,c:a(r,0,.4)}))}lighten(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a$1=o?.relative?l*(1+r):l+r*100;return n._make(_({h:t,s:e,l:a(a$1,0,100),alpha:s}))}darken(r=.1,o){return this.lighten(-r,o)}saturate(r=.1,o){let{h:t,s:e,l,alpha:s}=O(this._rgb),a$1=o?.relative?e*(1+r):e+r*100;return n._make(_({h:t,s:a(a$1,0,100),l,alpha:s}))}desaturate(r=.1,o){return this.saturate(-r,o)}grayscale(){return this.desaturate(1)}invert(){let{r,g:o,b:t,alpha:e}=this._rgb;return n._make({r:255-r,g:255-o,b:255-t,alpha:e})}rotate(r=15){return this.hue(this.hue()+r)}isEqual(r){let o=new n(r).toRgb(),t=this.toRgb();return t.r===o.r&&t.g===o.g&&t.b===o.b&&t.alpha===o.alpha}toString(){return this.toHex()}clampSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;return r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255?this:n._make({r:a(r,0,255),g:a(o,0,255),b:a(t,0,255),alpha:e})}mapSrgb(){let{r,g:o,b:t,alpha:e}=this._rgb;if(r>=0&&r<=255&&o>=0&&o<=255&&t>=0&&t<=255)return this;let[l,s,a]=a$1(a$2(r/255),a$2(o/255),a$2(t/255)),c=l>1-1e-7?1:l<1e-7?0:l,p$1=p({l:c,a:s,b:a,alpha:e});if(p$1===null)return this;let[d,f,k]=p$1.linear;return n._makeFromLinearSrgb(d,f,k,p$1.alpha)}static toGamutSrgb},Ar=n=>new u(n),vr=n=>new u(n).toHex8(),Mr=n=>{n.forEach(r=>r(u,P,N));},Nr=(n,r)=>{if(r.length===0)throw new Error("nearest: candidates array must not be empty");let{l:o,a:t,b:e}=new u(n).toOklab(),l=1/0,s=r[0];for(let a of r){let{l:c,a:p,b:d}=new u(a).toOklab(),f=(c-o)**2+(p-t)**2+(d-e)**2;f<l&&(l=f,s=a);}return s},Fr=()=>new u({r:Math.round(Math.random()*255),g:Math.round(Math.random()*255),b:Math.round(Math.random()*255),alpha:1});u.toGamutSrgb=n=>{let r=p(n);if(r===null)return new u(n);let[o,t,e]=r.linear;return u._makeFromLinearSrgb(o,t,e,r.alpha)};export{u as Colordx,Ar as colordx,Mr as extend,Pr as getFormat,Nr as nearest,Fr as random,vr as toHex8};//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","a","lr","lg","lb","oklabToLinear","srgbFromLinear","options","ri","gi","bi","rgbToHex","rgbToHex8","precision","hr","value","amount","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrgbRaw","colordx","toHex8","extend","plugins","plugin","nearest","candidates","l1","a1","b1","minDist","candidate","l2","a2","b2","dist","random"],"mappings":"g9BAeO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,GAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,CAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,CAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,EACtB,KAAA,CAAOE,CAAAA,CAAMC,GAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,CAAA,CAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAE1CC,CAAAA,CAAc,CAAC,CAAE,EAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,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AAAA,EAEb,CACA,OAAOhD,CACT,CAAA,CAEaqD,EAAAA,CAAS,IACpB,IAAI/C,CAAAA,CAAQ,CACV,CAAA,CAAG,KAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,MAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,KAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,KAAA,CAAO,CACT,CAAC,EAEHA,EAAQ,WAAA,CAAevD,CAAAA,EAA6B,CAClD,IAAMoF,CAAAA,CAASC,CAAAA,CAAerF,CAAK,CAAA,CACnC,OAAOoF,CAAAA,GAAW,IAAA,CAAO7B,CAAAA,CAAQ,cAAA,CAAe6B,CAAM,CAAA,CAAI,IAAI7B,CAAAA,CAAQvD,CAAK,CAC7E,CAAA","file":"index.mjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex, rgbToHex8 } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, oklabToLinear, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.\n * Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,\n * so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.\n * sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n */\n static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx {\n const [lr, lg, lb] = oklabToLinear(l, a, b);\n return Colordx._make({\n r: srgbFromLinear(lr) * 255,\n g: srgbFromLinear(lg) * 255,\n b: srgbFromLinear(lb) * 255,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n /**\n * Format as a `rgb()` / `rgba()` CSS string.\n * Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):\n * `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`\n * Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also\n * switches the function name to `rgba()` when alpha < 1:\n * `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`\n */\n toRgbString(options?: { legacy?: boolean }): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n if (options?.legacy) {\n return alpha < 1 ? `rgba(${ri}, ${gi}, ${bi}, ${alpha})` : `rgb(${ri}, ${gi}, ${bi})`;\n }\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */\n toHex8(): string {\n return rgbToHex8(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(precision = 4): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, precision), a: round(a, precision), b: round(b, precision), alpha };\n }\n\n toOklabString(precision = 4): string {\n const { l, a, b, alpha } = this.toOklab(precision);\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(precision = 4): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, precision), c: round(c, precision), h: round(h, precision), alpha };\n }\n\n toOklchString(precision = 4): string {\n const { l, c, h, alpha } = this.toOklch(precision);\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n return mapped !== null ? Colordx._makeFromOklab(mapped) : this;\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\n/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */\nexport const toHex8 = (input: AnyColor | Colordx): string => new Colordx(input).toHex8();\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n return mapped !== null ? Colordx._makeFromOklab(mapped) : new Colordx(input);\n};\n"]}
{"version":3,"sources":["../src/colorModels/hsl.ts","../src/colorModels/oklch.ts","../src/parse.ts","../src/colordx.ts"],"names":["clampHsl","hsl","normalizeHue","clamp","round","_hslBuf","rgbToHslRaw","r","g","b","alpha","rn","gn","bn","max","min","l","h","s","d","hDeg","_hueToRgb","p","q","t","hslToRgb","sn","ln","hue","parseHslObject","input","isObject","hasKeys","isAnyNumber","sanitize","HSL_RE","NUM_OR_NONE","NUM","parseHslString","isComma","unit","parseNum","ANGLE_UNITS","rawA","isPercent","oklchToOklab","c","rgbToOklch","rgb","ol","oa","ob","rgbToOklab","C","H","oklchToRgb","oklch","oklabToRgb","oklchToRgbUnclamped","oklabToRgbUnclamped","parseOklchObject","OKLCH_RE","parseOklchString","L","stringFormatParsers","parseHex","parseRgbString","parseOklabString","objectFormatParsers","parseRgbObject","parseOklabObject","builtinStringParsers","builtinObjectParsers","defaultParsers","parsers","pluginFormatParsers","parse","builtins","parser","result","i","getFormat","typed","format","_SENTINEL","Colordx","_Colordx","_direct","parsed","lr","lg","lb","rb","srgbFromLinear","gb","bb","options","ri","gi","bi","rgbToHex","rgbToHex8","precision","hr","a","value","amount","newL","newS","color","other","self","lRaw","bv","linearSrgbToOklab","srgbToLinear","mapped","toGamutSrgbRaw","mr","mg","mb","colordx","toHex8","extend","plugins","plugin","nearest","candidates","l1","a1","b1","minDist","candidate","l2","a2","b2","dist","random"],"mappings":"g8BAeO,IAAMA,CAAAA,CAAYC,CAAAA,GAA6B,CACpD,CAAA,CAAGC,GAAAA,CAAaD,CAAAA,CAAI,CAAC,CAAA,CACrB,CAAA,CAAGE,CAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,EAAG,GAAG,CAAA,CACtB,CAAA,CAAGE,CAAAA,CAAMF,CAAAA,CAAI,CAAA,CAAG,CAAA,CAAG,GAAG,EACtB,KAAA,CAAOE,CAAAA,CAAMC,GAAAA,CAAMH,CAAAA,CAAI,KAAA,CAAO,CAAC,CAAA,CAAG,CAAA,CAAG,CAAC,CACxC,CAAA,CAAA,CAGMI,CAAAA,CAAoB,CAAE,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,CAAA,CAAG,EAAG,CAAA,CAAG,KAAA,CAAO,CAAE,CAAA,CAE1CC,CAAAA,CAAc,CAAC,CAAE,CAAA,CAAAC,EAAG,CAAA,CAAAC,CAAAA,CAAG,CAAA,CAAAC,CAAAA,CAAG,KAAA,CAAAC,CAAM,CAAA,GAA0B,CACrE,IAAMC,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,CACbK,CAAAA,CAAKJ,CAAAA,CAAI,GAAA,CACTK,CAAAA,CAAKJ,CAAAA,CAAI,IACLK,GAAAA,CAAM,IAAA,CAAK,GAAA,CAAIH,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AA,CAAKM,CAAAA,CAAKL,CAAAA,GAAO,CAAA,CACxDM,CAAAA,CAAOL,CAAAA,GACTA,CAAAA,CAAUK,EACVzD,CAAAA,CAASqD,CAAAA,EAEb,CACA,OAAOrD,CACT,CAAA,CAEa0D,EAAAA,CAAS,IACpB,IAAIpD,CAAAA,CAAQ,CACV,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,EACjC,CAAA,CAAG,IAAA,CAAK,KAAA,CAAM,IAAA,CAAK,MAAA,EAAO,CAAI,GAAG,CAAA,CACjC,MAAO,CACT,CAAC,EAEHA,CAAAA,CAAQ,WAAA,CAAevD,CAAAA,EAA6B,CAClD,IAAMsF,EAASC,CAAAA,CAAevF,CAAK,CAAA,CACnC,GAAIsF,CAAAA,GAAW,IAAA,CAAM,OAAO,IAAI/B,EAAQvD,CAAK,CAAA,CAC7C,GAAM,CAACwF,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAAIJ,EAAO,MAAA,CAC5B,OAAO/B,CAAAA,CAAQ,mBAAA,CAAoBiC,CAAAA,CAAIC,CAAAA,CAAIC,CAAAA,CAAIJ,CAAAA,CAAO,KAAK,CAC7D,CAAA","file":"index.mjs","sourcesContent":["import {\n ANGLE_UNITS,\n NUM,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n round,\n sanitize,\n} from '../helpers.js';\nimport type { HslColor, RgbColor } from '../types.js';\n\nexport const clampHsl = (hsl: HslColor): HslColor => ({\n h: normalizeHue(hsl.h),\n s: clamp(hsl.s, 0, 100),\n l: clamp(hsl.l, 0, 100),\n alpha: clamp(round(hsl.alpha, 3), 0, 1),\n});\n\n// Shared write buffer for rgbToHslRaw — callers must destructure immediately, never store the reference.\nconst _hslBuf: HslColor = { h: 0, s: 0, l: 0, alpha: 0 };\n\nexport const rgbToHslRaw = ({ r, g, b, alpha }: RgbColor): HslColor => {\n const rn = r / 255,\n gn = g / 255,\n bn = b / 255;\n const max = Math.max(rn, gn, bn),\n min = Math.min(rn, gn, bn);\n const l = (max + min) / 2;\n let h = 0,\n s = 0;\n\n if (max !== min) {\n const d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch (max) {\n case rn:\n h = ((gn - bn) / d + (gn < bn ? 6 : 0)) / 6;\n break;\n case gn:\n h = ((bn - rn) / d + 2) / 6;\n break;\n case bn:\n h = ((rn - gn) / d + 4) / 6;\n break;\n }\n }\n\n const hDeg = h * 360;\n _hslBuf.h = hDeg >= 0 && hDeg < 360 ? hDeg : ((hDeg % 360) + 360) % 360;\n _hslBuf.s = clamp(s * 100, 0, 100);\n _hslBuf.l = clamp(l * 100, 0, 100);\n _hslBuf.alpha = clamp(round(alpha, 3), 0, 1);\n return _hslBuf;\n};\n\nexport const rgbToHsl = (rgb: RgbColor): HslColor => {\n const { h, s, l, alpha } = rgbToHslRaw(rgb);\n const hr = round(h, 2);\n // round() can push a value just below 360 to 360.00 due to floating-point; clamp back to 0.\n return { h: hr >= 360 ? 0 : hr, s: round(s, 2), l: round(l, 2), alpha };\n};\n\nconst _hueToRgb = (p: number, q: number, t: number): number => {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n};\n\nexport const hslToRgb = ({ h, s, l, alpha }: HslColor): RgbColor => {\n const sn = s / 100,\n ln = l / 100;\n const q = ln < 0.5 ? ln * (1 + sn) : ln + sn - ln * sn;\n const p = 2 * ln - q;\n const hue = (((h % 360) + 360) % 360) / 360;\n return {\n r: _hueToRgb(p, q, hue + 1 / 3) * 255,\n g: _hueToRgb(p, q, hue) * 255,\n b: _hueToRgb(p, q, hue - 1 / 3) * 255,\n alpha,\n };\n};\n\nexport const parseHslObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n if (!hasKeys(input, ['h', 's', 'l'])) return null;\n const { h, s, l, alpha = 1 } = input as { h: unknown; s: unknown; l: unknown; alpha?: unknown };\n if (!isAnyNumber(h) || !isAnyNumber(s) || !isAnyNumber(l) || !isAnyNumber(alpha)) return null;\n return hslToRgb(clampHsl({ h: sanitize(h), s: sanitize(s), l: sanitize(l), alpha: sanitize(alpha) }));\n};\n\n// Legacy comma form requires `%` on s/l and disallows `none`. Modern space form\n// allows optional `%` and the CSS Color 4 `none` keyword on any channel.\n// Named groups: `_c` = comma/legacy branch, `_s` = space/modern branch.\nconst HSL_RE = new RegExp(\n `^hsla?\\\\(\\\\s*(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?\\\\s*(?:` +\n `,\\\\s*(?<s_c>${NUM})%\\\\s*,\\\\s*(?<l_c>${NUM})%` +\n `(?:\\\\s*,\\\\s*(?<al_c>${NUM})(?<alp_c>%?)?\\\\s*)?` +\n `|` +\n `\\\\s+(?<s_s>${NUM_OR_NONE})(?<sp_s>%?)\\\\s+(?<l_s>${NUM_OR_NONE})(?<lp_s>%?)` +\n `(?:\\\\s*/\\\\s*(?<al_s>${NUM_OR_NONE})(?<alp_s>%?)?\\\\s*)?` +\n `)\\\\)$`,\n 'i'\n);\n\nexport const parseHslString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = HSL_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const isComma = g.s_c !== undefined;\n if (isComma && /^none$/i.test(g.h!)) return null; // legacy syntax has no `none`\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const h = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const s = parseNum((g.s_c ?? g.s_s)!);\n const l = parseNum((g.l_c ?? g.l_s)!);\n const rawA = g.al_c ?? g.al_s;\n const isPercent = !!(g.alp_c ?? g.alp_s);\n if (isComma && rawA !== undefined && /^none$/i.test(rawA)) return null;\n const alpha = rawA === undefined ? 1 : parseNum(rawA) / (isPercent ? 100 : 1);\n return hslToRgb(clampHsl({ h, s, l, alpha }));\n};\n","import {\n ANGLE_UNITS,\n NUM_OR_NONE,\n clamp,\n hasKeys,\n isAnyNumber,\n isObject,\n normalizeHue,\n parseNum,\n sanitize,\n} from '../helpers.js';\nimport type { OklabColor, OklchColor, RgbColor } from '../types.js';\nimport { oklabToRgb, oklabToRgbUnclamped, rgbToOklab } from './oklab.js';\n\nconst oklchToOklab = ({ l, c, h, alpha }: OklchColor): OklabColor => ({\n l,\n a: c * Math.cos((h * Math.PI) / 180),\n b: c * Math.sin((h * Math.PI) / 180),\n alpha,\n});\n\nexport const rgbToOklch = (rgb: RgbColor): OklchColor => {\n const { l: ol, a: oa, b: ob, alpha } = rgbToOklab(rgb);\n const C = Math.sqrt(oa * oa + ob * ob);\n const H = (Math.atan2(ob, oa) * 180) / Math.PI;\n // Achromatic threshold on OKLCH scale (0–~0.4): proportionally equivalent to LCH's 0.0015 threshold.\n return { l: ol, c: C, h: C < 0.000004 ? 0 : normalizeHue(H), alpha };\n};\n\nexport const oklchToRgb = (oklch: OklchColor): RgbColor => oklabToRgb(oklchToOklab(oklch));\nconst oklchToRgbUnclamped = (oklch: OklchColor): RgbColor => oklabToRgbUnclamped(oklchToOklab(oklch));\n\nexport const parseOklchObject = (input: unknown): RgbColor | null => {\n if (!isObject(input)) return null;\n // Objects with colorSpace: 'lch' are CIE LCH, not OKLCH — let parseLchObject handle them.\n if ((input as { colorSpace?: unknown }).colorSpace === 'lch') return null;\n if (!hasKeys(input, ['l', 'c', 'h'])) return null;\n const { l, c, h, alpha = 1 } = input as { l: unknown; c: unknown; h: unknown; alpha?: unknown };\n if (!isAnyNumber(l) || !isAnyNumber(c) || !isAnyNumber(h) || !isAnyNumber(alpha)) return null;\n if (sanitize(l) > 1) return null; // OKLCH L is always [0, 1]; reject CIE LCH values passed without colorSpace branding\n return oklchToRgbUnclamped({\n l: sanitize(l),\n c: Math.max(0, sanitize(c)),\n h: normalizeHue(sanitize(h)),\n alpha: clamp(sanitize(alpha), 0, 1),\n });\n};\n\nconst OKLCH_RE = new RegExp(\n `^oklch\\\\(\\\\s*(?<l>${NUM_OR_NONE})(?<lp>%?)\\\\s+(?<c>${NUM_OR_NONE})(?<cp>%?)` +\n `\\\\s+(?<h>${NUM_OR_NONE})(?<hu>deg|rad|grad|turn)?` +\n `\\\\s*(?:/\\\\s*(?<al>${NUM_OR_NONE})(?<alp>%?)\\\\s*)?\\\\)$`,\n 'i'\n);\n\nexport const parseOklchString = (input: unknown): RgbColor | null => {\n if (typeof input !== 'string') return null;\n const g = OKLCH_RE.exec(input.trim())?.groups;\n if (!g) return null;\n const L = g.lp ? parseNum(g.l!) / 100 : parseNum(g.l!); // 100% = 1\n const C = Math.max(0, g.cp ? parseNum(g.c!) * 0.004 : parseNum(g.c!)); // 100% = 0.4\n const unit = g.hu?.toLowerCase() ?? 'deg';\n const H = parseNum(g.h!) * (ANGLE_UNITS[unit] ?? 1);\n const alpha = g.al === undefined ? 1 : parseNum(g.al) / (g.alp ? 100 : 1);\n return oklchToRgbUnclamped({\n l: L,\n c: C,\n h: normalizeHue(H),\n alpha: clamp(alpha, 0, 1),\n });\n};\n","import { parseHex } from './colorModels/hex.js';\nimport { parseHslObject, parseHslString } from './colorModels/hsl.js';\nimport { parseOklabObject, parseOklabString } from './colorModels/oklab.js';\nimport { parseOklchObject, parseOklchString } from './colorModels/oklch.js';\nimport { parseRgbObject, parseRgbString } from './colorModels/rgb.js';\nimport type { AnyColor, ColorFormat, ColorParser, RgbColor } from './types.js';\n\nconst stringFormatParsers: [ColorParser, ColorFormat][] = [\n [parseHex, 'hex'],\n [parseRgbString, 'rgb'],\n [parseHslString, 'hsl'],\n [parseOklchString, 'oklch'],\n [parseOklabString, 'oklab'],\n];\n\nconst objectFormatParsers: [ColorParser, ColorFormat][] = [\n [parseRgbObject, 'rgb'],\n [parseHslObject, 'hsl'],\n [parseOklabObject, 'oklab'],\n [parseOklchObject, 'oklch'],\n];\n\nconst builtinStringParsers: ColorParser[] = stringFormatParsers.map(([p]) => p);\nconst builtinObjectParsers: ColorParser[] = objectFormatParsers.map(([p]) => p);\n\nexport const defaultParsers: ColorParser[] = [...builtinStringParsers, ...builtinObjectParsers];\nexport const parsers: ColorParser[] = [...defaultParsers];\nexport const pluginFormatParsers: [ColorParser, ColorFormat][] = [];\n\nexport const parse = (input: AnyColor): RgbColor | null => {\n if (input === 'transparent') return { r: 0, g: 0, b: 0, alpha: 0 };\n const builtins = typeof input === 'string' ? builtinStringParsers : builtinObjectParsers;\n for (const parser of builtins) {\n const result = parser(input);\n if (result) return result;\n }\n for (let i = defaultParsers.length; i < parsers.length; i++) {\n const result = parsers[i]!(input);\n if (result) return result;\n }\n return null;\n};\n\nexport const getFormat = (input: AnyColor): ColorFormat | undefined => {\n if (input === 'transparent') return 'name';\n const typed = typeof input === 'string' ? stringFormatParsers : objectFormatParsers;\n for (const [parser, format] of typed) {\n if (parser(input)) return format;\n }\n for (const [parser, format] of pluginFormatParsers) {\n if (parser(input)) return format;\n }\n return undefined;\n};\n","import { rgbToHex, rgbToHex8 } from './colorModels/hex.js';\nimport { hslToRgb, rgbToHslRaw } from './colorModels/hsl.js';\nimport { linearSrgbToOklab, rgbToOklab } from './colorModels/oklab.js';\nimport { oklchToRgb, rgbToOklch } from './colorModels/oklch.js';\nimport { toGamutSrgbRaw } from './gamut.js';\nimport { clamp, round } from './helpers.js';\nimport { parse, parsers, pluginFormatParsers } from './parse.js';\nimport { srgbFromLinear, srgbToLinear } from './transfer.js';\nimport type { AnyColor, ColorFormat, ColorParser, HslColor, OklabColor, OklchColor, RgbColor } from './types.js';\n\nconst _SENTINEL: unique symbol = Symbol();\n\nexport class Colordx {\n private readonly _rgb: RgbColor;\n private readonly _valid: boolean;\n\n constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor) {\n if (input === _SENTINEL) {\n this._valid = true;\n this._rgb = _direct!;\n } else if (input instanceof Colordx) {\n this._valid = input._valid;\n this._rgb = input._rgb;\n return;\n } else {\n const parsed = parse(input);\n this._valid = parsed !== null;\n this._rgb = parsed ?? { r: 0, g: 0, b: 0, alpha: 1 };\n }\n // Single chokepoint for alpha precision: parsers and _make() callers may hand us\n // raw floats (e.g. 1/255, 0.1+0.2). Snapping here keeps every formatter consistent.\n this._rgb.alpha = clamp(round(this._rgb.alpha, 3), 0, 1);\n }\n\n private static _make(rgb: RgbColor): Colordx {\n return new Colordx(_SENTINEL, rgb);\n }\n\n /**\n * Construct a Colordx from linear-sRGB channels, gamma-encoding to the internal ×255 storage.\n * Channels may exceed [0, 1] — wide-gamut inputs (toGamutP3 / toGamutRec2020 applied to a\n * color outside sRGB) land here after the target-space → linear-sRGB matrix, and the stored\n * _rgb holds unclamped gamma-encoded ×255 so toP3() / toRec2020() can recover the wide-gamut\n * channels. sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.\n *\n * Replaces the prior _makeFromOklab: cssGamutMap hands back clipped linear-target channels\n * directly, so callers skip the OKLab → linear round-trip that used to reintroduce 1-ULP\n * asymmetries on gamut-boundary colors.\n *\n * A residual source of asymmetry remains — the clip itself. cssGamutMap's clip puts one\n * channel exactly on 0 or 1 while the others sit where the input's hue landed, so an\n * extreme-dark or extreme-light color ends up with genuinely asymmetric sub-byte channels\n * (e.g. clipped linear (3e-6, 0, 8e-10) from oklch(0.001 0.001 0)). Math.round collapses all\n * three to the same byte, but rgbToHslRaw / rgbToOklab read the raw floats and report\n * phantom hue/saturation. Snap values within half a byte of 0 or 255 to the exact boundary;\n * the band matches Math.round's own behavior so byte output is unchanged, while HSL / OKLab\n * see a consistent pure white / black / primary. Values outside [0, 255] are wide-gamut\n * (P3 / Rec.2020 targets) and pass through untouched.\n */\n static _makeFromLinearSrgb(lr: number, lg: number, lb: number, alpha: number): Colordx {\n const rb = srgbFromLinear(lr) * 255;\n const gb = srgbFromLinear(lg) * 255;\n const bb = srgbFromLinear(lb) * 255;\n return Colordx._make({\n r: rb >= 0 && rb < 0.5 ? 0 : rb > 254.5 && rb <= 255 ? 255 : rb,\n g: gb >= 0 && gb < 0.5 ? 0 : gb > 254.5 && gb <= 255 ? 255 : gb,\n b: bb >= 0 && bb < 0.5 ? 0 : bb > 254.5 && bb <= 255 ? 255 : bb,\n alpha,\n });\n }\n\n isValid(): boolean {\n return this._valid;\n }\n\n toRgb(): RgbColor {\n const { r, g, b, alpha } = this._rgb;\n return { r: clamp(round(r), 0, 255), g: clamp(round(g), 0, 255), b: clamp(round(b), 0, 255), alpha };\n }\n\n /** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */\n _rawRgb(): RgbColor {\n return this._rgb;\n }\n\n /**\n * Format as a `rgb()` / `rgba()` CSS string.\n * Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):\n * `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`\n * Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also\n * switches the function name to `rgba()` when alpha < 1:\n * `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`\n */\n toRgbString(options?: { legacy?: boolean }): string {\n const { r, g, b, alpha } = this._rgb;\n const ri = clamp(round(r), 0, 255),\n gi = clamp(round(g), 0, 255),\n bi = clamp(round(b), 0, 255);\n if (options?.legacy) {\n return alpha < 1 ? `rgba(${ri}, ${gi}, ${bi}, ${alpha})` : `rgb(${ri}, ${gi}, ${bi})`;\n }\n return alpha < 1 ? `rgb(${ri} ${gi} ${bi} / ${alpha})` : `rgb(${ri} ${gi} ${bi})`;\n }\n\n toHex(): string {\n return rgbToHex(this._rgb);\n }\n\n /** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */\n toHex8(): string {\n return rgbToHex8(this._rgb);\n }\n\n /** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */\n toNumber(): number {\n const { r, g, b } = this._rgb;\n return (clamp(round(r), 0, 255) << 16) | (clamp(round(g), 0, 255) << 8) | clamp(round(b), 0, 255);\n }\n\n toHsl(precision = 2): HslColor {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const hr = round(h, precision);\n return { h: hr >= 360 ? 0 : hr, s: round(s, precision), l: round(l, precision), alpha };\n }\n\n toHslString(precision = 2): string {\n const { h, s, l, alpha } = this.toHsl(precision);\n return alpha < 1 ? `hsl(${h} ${s}% ${l}% / ${alpha})` : `hsl(${h} ${s}% ${l}%)`;\n }\n\n toOklab(precision = 4): OklabColor {\n const { l, a, b, alpha } = rgbToOklab(this._rgb);\n return { l: round(l, precision), a: round(a, precision), b: round(b, precision), alpha };\n }\n\n toOklabString(precision = 4): string {\n const { l, a, b, alpha } = this.toOklab(precision);\n return alpha < 1 ? `oklab(${l} ${a} ${b} / ${alpha})` : `oklab(${l} ${a} ${b})`;\n }\n\n toOklch(precision = 4): OklchColor {\n const { l, c, h, alpha } = rgbToOklch(this._rgb);\n return { l: round(l, precision), c: round(c, precision), h: round(h, precision), alpha };\n }\n\n toOklchString(precision = 4): string {\n const { l, c, h, alpha } = this.toOklch(precision);\n const H = c === 0 ? 'none' : h;\n return alpha < 1 ? `oklch(${l} ${c} ${H} / ${alpha})` : `oklch(${l} ${c} ${H})`;\n }\n\n brightness(): number {\n const { r, g, b } = this._rgb;\n return round((r * 299 + g * 587 + b * 114) / 255000, 2);\n }\n\n isDark(): boolean {\n return this.brightness() < 0.5;\n }\n\n isLight(): boolean {\n return this.brightness() >= 0.5;\n }\n\n alpha(): number;\n alpha(value: number): Colordx;\n alpha(value?: number): number | Colordx {\n if (value === undefined) return this._rgb.alpha;\n return Colordx._make({ ...this._rgb, alpha: round(clamp(value, 0, 1), 3) });\n }\n\n hue(): number;\n hue(value: number): Colordx;\n hue(value?: number): number | Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n if (value === undefined) {\n const hr = round(h, 2);\n return hr >= 360 ? 0 : hr;\n }\n return Colordx._make(hslToRgb({ h: value, s, l, alpha }));\n }\n\n lightness(): number;\n lightness(value: number): Colordx;\n lightness(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.l;\n return Colordx._make(oklchToRgb({ ...oklch, l: clamp(value, 0, 1) }));\n }\n\n chroma(): number;\n chroma(value: number): Colordx;\n chroma(value?: number): number | Colordx {\n const oklch = this.toOklch();\n if (value === undefined) return oklch.c;\n return Colordx._make(oklchToRgb({ ...oklch, c: clamp(value, 0, 0.4) }));\n }\n\n lighten(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newL = options?.relative ? l * (1 + amount) : l + amount * 100;\n return Colordx._make(hslToRgb({ h, s, l: clamp(newL, 0, 100), alpha }));\n }\n\n darken(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.lighten(-amount, options);\n }\n\n saturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n const { h, s, l, alpha } = rgbToHslRaw(this._rgb);\n const newS = options?.relative ? s * (1 + amount) : s + amount * 100;\n return Colordx._make(hslToRgb({ h, s: clamp(newS, 0, 100), l, alpha }));\n }\n\n desaturate(amount = 0.1, options?: { relative?: boolean }): Colordx {\n return this.saturate(-amount, options);\n }\n\n grayscale(): Colordx {\n return this.desaturate(1);\n }\n\n invert(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n return Colordx._make({ r: 255 - r, g: 255 - g, b: 255 - b, alpha });\n }\n\n rotate(amount = 15): Colordx {\n return this.hue(this.hue() + amount);\n }\n\n isEqual(color: AnyColor): boolean {\n const other = new Colordx(color).toRgb();\n const self = this.toRgb();\n return self.r === other.r && self.g === other.g && self.b === other.b && self.alpha === other.alpha;\n }\n\n toString(): string {\n return this.toHex();\n }\n\n /**\n * Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].\n * Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.\n * Hue and lightness may shift noticeably for colors far outside sRGB.\n * Returns `this` when already in gamut.\n */\n clampSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n return Colordx._make({\n r: clamp(r, 0, 255),\n g: clamp(g, 0, 255),\n b: clamp(b, 0, 255),\n alpha,\n });\n }\n\n /**\n * Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm\n * (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.\n * Useful when hue stability matters — design tokens, palettes, color pickers.\n * Returns `this` when already in gamut.\n */\n mapSrgb(): Colordx {\n const { r, g, b, alpha } = this._rgb;\n if (r >= 0 && r <= 255 && g >= 0 && g <= 255 && b >= 0 && b <= 255) return this;\n const [lRaw, a, bv] = linearSrgbToOklab(srgbToLinear(r / 255), srgbToLinear(g / 255), srgbToLinear(b / 255));\n // The gamma-encoded round-trip drifts L by ~1e-9 at boundaries; snap so that inputs with\n // exact L=0 or L=1 hit the same white/black shortcut the static gamut map uses.\n const l = lRaw > 1 - 1e-7 ? 1 : lRaw < 1e-7 ? 0 : lRaw;\n const mapped = toGamutSrgbRaw({ l, a, b: bv, alpha });\n if (mapped === null) return this;\n const [mr, mg, mb] = mapped.linear;\n return Colordx._makeFromLinearSrgb(mr, mg, mb, mapped.alpha);\n }\n\n /**\n * Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.\n * Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.\n */\n static toGamutSrgb: (input: AnyColor) => Colordx;\n}\n\nexport type Plugin = (\n ColordxClass: typeof Colordx,\n parsers: ColorParser[],\n formatParsers: [ColorParser, ColorFormat][]\n) => void;\n\nexport const colordx = (input: AnyColor | Colordx): Colordx => new Colordx(input);\n\n/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */\nexport const toHex8 = (input: AnyColor | Colordx): string => new Colordx(input).toHex8();\n\nexport const extend = (plugins: Plugin[]): void => {\n plugins.forEach((plugin) => plugin(Colordx, parsers, pluginFormatParsers));\n};\n\nexport const nearest = <T extends AnyColor>(color: AnyColor, candidates: T[]): T => {\n if (candidates.length === 0) throw new Error('nearest: candidates array must not be empty');\n const { l: l1, a: a1, b: b1 } = new Colordx(color).toOklab();\n let minDist = Infinity;\n let result = candidates[0] as T;\n for (const candidate of candidates) {\n const { l: l2, a: a2, b: b2 } = new Colordx(candidate).toOklab();\n const dist = (l2 - l1) ** 2 + (a2 - a1) ** 2 + (b2 - b1) ** 2;\n if (dist < minDist) {\n minDist = dist;\n result = candidate;\n }\n }\n return result;\n};\n\nexport const random = (): Colordx =>\n new Colordx({\n r: Math.round(Math.random() * 255),\n g: Math.round(Math.random() * 255),\n b: Math.round(Math.random() * 255),\n alpha: 1,\n });\n\nColordx.toGamutSrgb = (input: AnyColor): Colordx => {\n const mapped = toGamutSrgbRaw(input);\n if (mapped === null) return new Colordx(input);\n const [mr, mg, mb] = mapped.linear;\n return Colordx._makeFromLinearSrgb(mr, mg, mb, mapped.alpha);\n};\n"]}

@@ -1,2 +0,2 @@

import { A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { a as CmykColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { a as CmykColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { a as CmykColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { a as CmykColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ type HarmonyType = 'complementary' | 'analogous' | 'triadic' | 'tetradic' | 'split-complementary' | 'double-split-complementary' | 'rectangle';

@@ -1,2 +0,2 @@

import { q as Plugin } from '../colordx-CQAwj4SM.js';
import { q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ type HarmonyType = 'complementary' | 'analogous' | 'triadic' | 'tetradic' | 'split-complementary' | 'double-split-complementary' | 'rectangle';

@@ -1,2 +0,2 @@

import { f as HsvColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { f as HsvColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { f as HsvColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { f as HsvColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { h as HwbColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { h as HwbColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { h as HwbColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { h as HwbColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { L as LabColor, X as XyzColor, B as XyzD65Color, A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { L as LabColor, X as XyzColor, B as XyzD65Color, A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { L as LabColor, X as XyzColor, B as XyzD65Color, A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { L as LabColor, X as XyzColor, B as XyzD65Color, A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { k as LchColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { k as LchColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { k as LchColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { k as LchColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ interface MinifyOptions {

@@ -1,2 +0,2 @@

import { q as Plugin } from '../colordx-CQAwj4SM.js';
import { q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ interface MinifyOptions {

@@ -1,2 +0,2 @@

import { A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { q as Plugin } from '../colordx-CQAwj4SM.js';
import { q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkB3CQY27M_cjs=require('../chunk-B3CQY27M.cjs'),chunkGXECYURS_cjs=require('../chunk-GXECYURS.cjs');require('../chunk-GU6TZJ4O.cjs');var chunkX5FCFNQN_cjs=require('../chunk-X5FCFNQN.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var S=(r,o,e)=>chunkGXECYURS_cjs.a(...chunkB3CQY27M_cjs.c(r,o,e)),A=(r,o,e)=>{let[n,m,b]=chunkB3CQY27M_cjs.b(r,o,e);return [chunkX5FCFNQN_cjs.b(n),chunkX5FCFNQN_cjs.b(m),chunkX5FCFNQN_cjs.b(b)]},k=(r,o,e,n)=>{chunkB3CQY27M_cjs.a(r,o,e,n),r[0]=chunkX5FCFNQN_cjs.b(r[0]),r[1]=chunkX5FCFNQN_cjs.b(r[1]),r[2]=chunkX5FCFNQN_cjs.b(r[2]);},w=(r,o,e)=>A(...chunkB3CQY27M_cjs.s(r,o,e)),D=(r,o,e,n)=>{chunkB3CQY27M_cjs.t(r,o,e,n),k(r,r[0],r[1],r[2]);},I=Math.PI/180,F=(r,o,e)=>A(...chunkB3CQY27M_cjs.A(r,o,e)),$=(r,o,e,n)=>{chunkB3CQY27M_cjs.B(r,o,e,n),k(r,r[0],r[1],r[2]);},E=(r,o,e)=>{let n=e*I;return F(r,o*Math.cos(n),o*Math.sin(n))},q=(r,o,e,n)=>{let m=n*I;$(r,o,e*Math.cos(m),e*Math.sin(m));},z=r=>chunkB3CQY27M_cjs.q(r,chunkB3CQY27M_cjs.g),G=(r,o,e)=>{r.toGamutP3=n=>{let m=chunkB3CQY27M_cjs.r(n,chunkB3CQY27M_cjs.g,S);return m!==null?r._makeFromOklab(m):new r(n)},r.prototype.toP3=function(n=4){let{r:m,g:b,b:a,alpha:u}=chunkB3CQY27M_cjs.d(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(m,n),g:chunkYISEJCI6_cjs.b(b,n),b:chunkYISEJCI6_cjs.b(a,n),alpha:u,colorSpace:"display-p3"}},r.prototype.toP3String=function(n=4){let{r:m,g:b,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${m} ${b} ${a} / ${u})`:`color(display-p3 ${m} ${b} ${a})`},o.push(chunkB3CQY27M_cjs.f,chunkB3CQY27M_cjs.e),e.push([chunkB3CQY27M_cjs.f,"p3"],[chunkB3CQY27M_cjs.e,"p3"]);},B=G;exports.default=B;exports.inGamutP3=z;exports.labToP3Channels=F;exports.labToP3ChannelsInto=$;exports.lchToP3Channels=E;exports.lchToP3ChannelsInto=q;exports.linearToP3Channels=A;exports.linearToP3ChannelsInto=k;exports.oklchToP3Channels=w;exports.oklchToP3ChannelsInto=D;//# sourceMappingURL=p3.cjs.map
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkJVG55LEC_cjs=require('../chunk-JVG55LEC.cjs'),chunkGXECYURS_cjs=require('../chunk-GXECYURS.cjs');require('../chunk-GU6TZJ4O.cjs');var chunkX5FCFNQN_cjs=require('../chunk-X5FCFNQN.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var $=(r,o,e)=>chunkGXECYURS_cjs.a(...chunkJVG55LEC_cjs.c(r,o,e)),A=(r,o,e)=>{let[n,t,m]=chunkJVG55LEC_cjs.b(r,o,e);return [chunkX5FCFNQN_cjs.b(n),chunkX5FCFNQN_cjs.b(t),chunkX5FCFNQN_cjs.b(m)]},S=(r,o,e,n)=>{chunkJVG55LEC_cjs.a(r,o,e,n),r[0]=chunkX5FCFNQN_cjs.b(r[0]),r[1]=chunkX5FCFNQN_cjs.b(r[1]),r[2]=chunkX5FCFNQN_cjs.b(r[2]);},E=(r,o,e)=>A(...chunkJVG55LEC_cjs.s(r,o,e)),q=(r,o,e,n)=>{chunkJVG55LEC_cjs.t(r,o,e,n),S(r,r[0],r[1],r[2]);},I=Math.PI/180,R=(r,o,e)=>A(...chunkJVG55LEC_cjs.A(r,o,e)),M=(r,o,e,n)=>{chunkJVG55LEC_cjs.B(r,o,e,n),S(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*I;return R(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*I;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>chunkJVG55LEC_cjs.q(r,chunkJVG55LEC_cjs.g),v=(r,o,e)=>{r.toGamutP3=n=>{let t=chunkJVG55LEC_cjs.r(n,chunkJVG55LEC_cjs.g,$);if(t===null)return new r(n);let[m,a,u]=t.linear,[k,F,G]=chunkJVG55LEC_cjs.c(m,a,u);return r._makeFromLinearSrgb(k,F,G,t.alpha)},r.prototype.toP3=function(n=4){let{r:t,g:m,b:a,alpha:u}=chunkJVG55LEC_cjs.d(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,n),g:chunkYISEJCI6_cjs.b(m,n),b:chunkYISEJCI6_cjs.b(a,n),alpha:u,colorSpace:"display-p3"}},r.prototype.toP3String=function(n=4){let{r:t,g:m,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${t} ${m} ${a} / ${u})`:`color(display-p3 ${t} ${m} ${a})`},o.push(chunkJVG55LEC_cjs.f,chunkJVG55LEC_cjs.e),e.push([chunkJVG55LEC_cjs.f,"p3"],[chunkJVG55LEC_cjs.e,"p3"]);},K=v;exports.default=K;exports.inGamutP3=J;exports.labToP3Channels=R;exports.labToP3ChannelsInto=M;exports.lchToP3Channels=z;exports.lchToP3ChannelsInto=H;exports.linearToP3Channels=A;exports.linearToP3ChannelsInto=S;exports.oklchToP3Channels=E;exports.oklchToP3ChannelsInto=q;//# sourceMappingURL=p3.cjs.map
//# sourceMappingURL=p3.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/plugins/p3.ts"],"names":["p3FromLinear","g","b","linearSrgbToOklab","linearP3ToSrgb","linearToP3Channels","lr","lg","lb","r","srgbLinearToP3Linear","srgbFromLinear","linearToP3ChannelsInto","out","srgbLinearToP3LinearInto","oklchToP3Channels","l","c","h","oklchToLinear","oklchToP3ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToP3Channels","a","labToLinearSrgb","labToP3ChannelsInto","labToLinearSrgbInto","lchToP3Channels","hRad","lchToP3ChannelsInto","inGamutP3","input","inGamutCustom","oklabToLinearP3","p3","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","precision","alpha","rgbToP3Raw","round","parseP3String","parseP3Object","p3_default"],"mappings":"gWAiBA,IAAMA,EAAe,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GAC1CC,mBAAAA,CAAkB,GAAGC,mBAAAA,CAAe,CAAA,CAAGH,CAAAA,CAAGC,CAAC,CAAC,CAAA,CAmBjCG,CAAAA,CAAqB,CAACC,CAAAA,CAAYC,CAAAA,CAAYC,IAAyC,CAClG,GAAM,CAACC,CAAAA,CAAGR,EAAG,CAAC,CAAA,CAAIS,oBAAqBJ,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACjD,OAAO,CAACG,mBAAAA,CAAeF,CAAC,CAAA,CAAGE,mBAAAA,CAAeV,CAAC,CAAA,CAAGU,mBAAAA,CAAe,CAAC,CAAC,CACjE,CAAA,CAGaC,CAAAA,CAAyB,CAACC,CAAAA,CAA8BP,CAAAA,CAAYC,EAAYC,CAAAA,GAAqB,CAChHM,oBAAyBD,CAAAA,CAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,EACxCK,CAAAA,CAAI,CAAC,EAAIF,mBAAAA,CAAeE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAC/BA,CAAAA,CAAI,CAAC,EAAIF,mBAAAA,CAAeE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAC/BA,EAAI,CAAC,CAAA,CAAIF,oBAAeE,CAAAA,CAAI,CAAC,CAAE,EACjC,CAAA,CAQaE,EAAoB,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GACtDb,CAAAA,CAAmB,GAAGc,mBAAAA,CAAcH,EAAGC,CAAAA,CAAGC,CAAC,CAAC,CAAA,CAGjCE,CAAAA,CAAwB,CAAC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,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,GACpG,CAAA,CACAmC,CAAAA,CAAQ,KAAKQ,mBAAAA,CAAeC,mBAAa,EACzCR,CAAAA,CAAc,IAAA,CAAK,CAACO,mBAAAA,CAAe,IAAI,EAAG,CAACC,mBAAAA,CAAe,IAAI,CAAC,EACjE,EAEOC,CAAAA,CAAQZ","file":"p3.cjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearP3ToSrgb,\n oklabToLinearP3,\n parseP3Object,\n parseP3String,\n rgbToP3Raw,\n srgbLinearToP3Linear,\n srgbLinearToP3LinearInto,\n} from '../colorModels/p3.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { srgbFromLinear } from '../transfer.js';\nimport type { AnyColor, P3Color } from '../types.js';\n\nconst p3FromLinear = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearP3ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toP3(precision?: number): P3Color;\n toP3String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutP3(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Display-P3 channels.\n * This is the cheap step — only a matrix multiply + gamma encoding, no cbrt.\n * Pair with oklchToLinear to convert one OKLCH color to multiple spaces without\n * repeating the expensive OKLab pipeline.\n */\nexport const linearToP3Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToP3Linear(lr, lg, lb);\n return [srgbFromLinear(r), srgbFromLinear(g), srgbFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToP3Channels — writes [pr, pg, pb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToP3ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToP3LinearInto(out, lr, lg, lb);\n out[0] = srgbFromLinear(out[0]!);\n out[1] = srgbFromLinear(out[1]!);\n out[2] = srgbFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the sRGB transfer function (P3 does not use DCI-P3 gamma 2.6).\n */\nexport const oklchToP3Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToP3Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const oklchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear P3 → gamma P3.\n */\nexport const labToP3Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToP3Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const labToP3ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma P3. Out-of-gamut channels may exceed [0, 1].\n */\nexport const lchToP3Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToP3Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const lchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToP3ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Display-P3 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ P3).\n */\nexport const inGamutP3 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearP3);\n\nconst p3: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutP3 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearP3, p3FromLinear);\n return mapped !== null ? ColordxClass._makeFromOklab(mapped) : new ColordxClass(input);\n };\n ColordxClass.prototype.toP3 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToP3Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'display-p3' as const,\n };\n };\n ColordxClass.prototype.toP3String = function (precision = 4) {\n const { r, g, b, alpha } = this.toP3(precision);\n return alpha < 1 ? `color(display-p3 ${r} ${g} ${b} / ${alpha})` : `color(display-p3 ${r} ${g} ${b})`;\n };\n parsers.push(parseP3String, parseP3Object);\n formatParsers.push([parseP3String, 'p3'], [parseP3Object, 'p3']);\n};\n\nexport default p3;\n"]}
{"version":3,"sources":["../../src/plugins/p3.ts"],"names":["p3FromLinear","g","b","linearSrgbToOklab","linearP3ToSrgb","linearToP3Channels","lr","lg","lb","r","srgbLinearToP3Linear","srgbFromLinear","linearToP3ChannelsInto","out","srgbLinearToP3LinearInto","oklchToP3Channels","l","c","h","oklchToLinear","oklchToP3ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToP3Channels","a","labToLinearSrgb","labToP3ChannelsInto","labToLinearSrgbInto","lchToP3Channels","hRad","lchToP3ChannelsInto","inGamutP3","input","inGamutCustom","oklabToLinearP3","p3","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lpR","lpG","lpB","precision","alpha","rgbToP3Raw","round","parseP3String","parseP3Object","p3_default"],"mappings":"gWAiBA,IAAMA,EAAe,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GAC1CC,mBAAAA,CAAkB,GAAGC,mBAAAA,CAAe,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAmBjCG,CAAAA,CAAqB,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CAClG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,mBAAAA,CAAqBJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACjD,OAAO,CAACG,mBAAAA,CAAeF,CAAC,CAAA,CAAGE,mBAAAA,CAAeV,CAAC,CAAA,CAAGU,mBAAAA,CAAeT,CAAC,CAAC,CACjE,EAGaU,CAAAA,CAAyB,CAACC,EAA8BP,CAAAA,CAAYC,CAAAA,CAAYC,IAAqB,CAChHM,mBAAAA,CAAyBD,EAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACxCK,CAAAA,CAAI,CAAC,CAAA,CAAIF,mBAAAA,CAAeE,EAAI,CAAC,CAAE,EAC/BA,CAAAA,CAAI,CAAC,EAAIF,mBAAAA,CAAeE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAC/BA,EAAI,CAAC,CAAA,CAAIF,oBAAeE,CAAAA,CAAI,CAAC,CAAE,EACjC,CAAA,CAQaE,EAAoB,CAACC,CAAAA,CAAWC,EAAWC,CAAAA,GACtDb,CAAAA,CAAmB,GAAGc,mBAAAA,CAAcH,CAAAA,CAAGC,EAAGC,CAAC,CAAC,EAGjCE,CAAAA,CAAwB,CAACP,EAA8BG,CAAAA,CAAWC,CAAAA,CAAWC,IAAoB,CAC5GG,mBAAAA,CAAkBR,EAAKG,CAAAA,CAAGC,CAAAA,CAAGC,CAAC,CAAA,CAC9BN,CAA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,CAAA,CAAA,CAAM,oBAAoBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,GACpG,CAAA,CACAmC,CAAAA,CAAQ,KAAKW,mBAAAA,CAAeC,mBAAa,EACzCX,CAAAA,CAAc,IAAA,CAAK,CAACU,mBAAAA,CAAe,IAAI,EAAG,CAACC,mBAAAA,CAAe,IAAI,CAAC,EACjE,EAEOC,CAAAA,CAAQf","file":"p3.cjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearP3ToSrgb,\n oklabToLinearP3,\n parseP3Object,\n parseP3String,\n rgbToP3Raw,\n srgbLinearToP3Linear,\n srgbLinearToP3LinearInto,\n} from '../colorModels/p3.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { srgbFromLinear } from '../transfer.js';\nimport type { AnyColor, P3Color } from '../types.js';\n\nconst p3FromLinear = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearP3ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toP3(precision?: number): P3Color;\n toP3String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutP3(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Display-P3 channels.\n * This is the cheap step — only a matrix multiply + gamma encoding, no cbrt.\n * Pair with oklchToLinear to convert one OKLCH color to multiple spaces without\n * repeating the expensive OKLab pipeline.\n */\nexport const linearToP3Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToP3Linear(lr, lg, lb);\n return [srgbFromLinear(r), srgbFromLinear(g), srgbFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToP3Channels — writes [pr, pg, pb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToP3ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToP3LinearInto(out, lr, lg, lb);\n out[0] = srgbFromLinear(out[0]!);\n out[1] = srgbFromLinear(out[1]!);\n out[2] = srgbFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the sRGB transfer function (P3 does not use DCI-P3 gamma 2.6).\n */\nexport const oklchToP3Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToP3Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const oklchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear P3 → gamma P3.\n */\nexport const labToP3Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToP3Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const labToP3ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma P3. Out-of-gamut channels may exceed [0, 1].\n */\nexport const lchToP3Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToP3Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const lchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToP3ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Display-P3 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ P3).\n */\nexport const inGamutP3 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearP3);\n\nconst p3: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutP3 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearP3, p3FromLinear);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-P3 → linear-sRGB (wide-gamut when the P3 color is outside sRGB),\n // then gamma-encode for storage. No round-trip through OKLab.\n const [lpR, lpG, lpB] = mapped.linear;\n const [lr, lg, lb] = linearP3ToSrgb(lpR, lpG, lpB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toP3 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToP3Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'display-p3' as const,\n };\n };\n ColordxClass.prototype.toP3String = function (precision = 4) {\n const { r, g, b, alpha } = this.toP3(precision);\n return alpha < 1 ? `color(display-p3 ${r} ${g} ${b} / ${alpha})` : `color(display-p3 ${r} ${g} ${b})`;\n };\n parsers.push(parseP3String, parseP3Object);\n formatParsers.push([parseP3String, 'p3'], [parseP3Object, 'p3']);\n};\n\nexport default p3;\n"]}

@@ -1,2 +0,2 @@

import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { P as P3Color, A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import {b,a,s,t,A as A$1,B as B$1,q as q$1,g,r,d,f,e,c}from'../chunk-DIWXRMTC.mjs';import {a as a$1}from'../chunk-J6CH5YTL.mjs';import'../chunk-4LKLL3IS.mjs';import {b as b$1}from'../chunk-FXCFKFXK.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b as b$2}from'../chunk-IOXRZECH.mjs';var S=(r,o,e)=>a$1(...c(r,o,e)),A=(r,o,e)=>{let[n,m,b$2]=b(r,o,e);return [b$1(n),b$1(m),b$1(b$2)]},k=(r,o,e,n)=>{a(r,o,e,n),r[0]=b$1(r[0]),r[1]=b$1(r[1]),r[2]=b$1(r[2]);},w=(r,o,e)=>A(...s(r,o,e)),D=(r,o,e,n)=>{t(r,o,e,n),k(r,r[0],r[1],r[2]);},I=Math.PI/180,F=(r,o,e)=>A(...A$1(r,o,e)),$=(r,o,e,n)=>{B$1(r,o,e,n),k(r,r[0],r[1],r[2]);},E=(r,o,e)=>{let n=e*I;return F(r,o*Math.cos(n),o*Math.sin(n))},q=(r,o,e,n)=>{let m=n*I;$(r,o,e*Math.cos(m),e*Math.sin(m));},z=r=>q$1(r,g),G=(r$1,o,e$1)=>{r$1.toGamutP3=n=>{let m=r(n,g,S);return m!==null?r$1._makeFromOklab(m):new r$1(n)},r$1.prototype.toP3=function(n=4){let{r:m,g:b,b:a,alpha:u}=d(this._rawRgb());return {r:b$2(m,n),g:b$2(b,n),b:b$2(a,n),alpha:u,colorSpace:"display-p3"}},r$1.prototype.toP3String=function(n=4){let{r:m,g:b,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${m} ${b} ${a} / ${u})`:`color(display-p3 ${m} ${b} ${a})`},o.push(f,e),e$1.push([f,"p3"],[e,"p3"]);},B=G;export{B as default,z as inGamutP3,F as labToP3Channels,$ as labToP3ChannelsInto,E as lchToP3Channels,q as lchToP3ChannelsInto,A as linearToP3Channels,k as linearToP3ChannelsInto,w as oklchToP3Channels,D as oklchToP3ChannelsInto};//# sourceMappingURL=p3.mjs.map
import {b,a,s,t,A as A$1,B,q as q$1,g,r,c,d,f,e}from'../chunk-BXGFP5BN.mjs';import {a as a$1}from'../chunk-J6CH5YTL.mjs';import'../chunk-4LKLL3IS.mjs';import {b as b$1}from'../chunk-FXCFKFXK.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b as b$2}from'../chunk-IOXRZECH.mjs';var $=(r,o,e)=>a$1(...c(r,o,e)),A=(r,o,e)=>{let[n,t,m]=b(r,o,e);return [b$1(n),b$1(t),b$1(m)]},S=(r,o,e,n)=>{a(r,o,e,n),r[0]=b$1(r[0]),r[1]=b$1(r[1]),r[2]=b$1(r[2]);},E=(r,o,e)=>A(...s(r,o,e)),q=(r,o,e,n)=>{t(r,o,e,n),S(r,r[0],r[1],r[2]);},I=Math.PI/180,R=(r,o,e)=>A(...A$1(r,o,e)),M=(r,o,e,n)=>{B(r,o,e,n),S(r,r[0],r[1],r[2]);},z=(r,o,e)=>{let n=e*I;return R(r,o*Math.cos(n),o*Math.sin(n))},H=(r,o,e,n)=>{let t=n*I;M(r,o,e*Math.cos(t),e*Math.sin(t));},J=r=>q$1(r,g),v=(r$1,o,e$1)=>{r$1.toGamutP3=n=>{let t=r(n,g,$);if(t===null)return new r$1(n);let[m,a,u]=t.linear,[k,F,G]=c(m,a,u);return r$1._makeFromLinearSrgb(k,F,G,t.alpha)},r$1.prototype.toP3=function(n=4){let{r:t,g:m,b:a,alpha:u}=d(this._rawRgb());return {r:b$2(t,n),g:b$2(m,n),b:b$2(a,n),alpha:u,colorSpace:"display-p3"}},r$1.prototype.toP3String=function(n=4){let{r:t,g:m,b:a,alpha:u}=this.toP3(n);return u<1?`color(display-p3 ${t} ${m} ${a} / ${u})`:`color(display-p3 ${t} ${m} ${a})`},o.push(f,e),e$1.push([f,"p3"],[e,"p3"]);},K=v;export{K as default,J as inGamutP3,R as labToP3Channels,M as labToP3ChannelsInto,z as lchToP3Channels,H as lchToP3ChannelsInto,A as linearToP3Channels,S as linearToP3ChannelsInto,E as oklchToP3Channels,q as oklchToP3ChannelsInto};//# sourceMappingURL=p3.mjs.map
//# sourceMappingURL=p3.mjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/plugins/p3.ts"],"names":["p3FromLinear","g","b","linearSrgbToOklab","linearP3ToSrgb","linearToP3Channels","lr","lg","lb","r","srgbLinearToP3Linear","srgbFromLinear","linearToP3ChannelsInto","out","srgbLinearToP3LinearInto","oklchToP3Channels","l","c","h","oklchToLinear","oklchToP3ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToP3Channels","a","labToLinearSrgb","labToP3ChannelsInto","labToLinearSrgbInto","lchToP3Channels","hRad","lchToP3ChannelsInto","inGamutP3","input","inGamutCustom","oklabToLinearP3","p3","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","precision","alpha","rgbToP3Raw","round","parseP3String","parseP3Object","p3_default"],"mappings":"sRAiBA,IAAMA,EAAe,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GAC1CC,GAAAA,CAAkB,GAAGC,CAAAA,CAAe,CAAA,CAAGH,CAAAA,CAAGC,CAAC,CAAC,CAAA,CAmBjCG,CAAAA,CAAqB,CAACC,CAAAA,CAAYC,CAAAA,CAAYC,IAAyC,CAClG,GAAM,CAACC,CAAAA,CAAGR,EAAGC,GAAC,CAAA,CAAIQ,EAAqBJ,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACjD,OAAO,CAACG,GAAAA,CAAeF,CAAC,CAAA,CAAGE,GAAAA,CAAeV,CAAC,CAAA,CAAGU,GAAAA,CAAeT,GAAC,CAAC,CACjE,CAAA,C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CAAGwC,CAAS,CAAA,CACrB,CAAA,CAAGG,IAAM1C,CAAAA,CAAGuC,CAAS,CAAA,CACrB,KAAA,CAAAC,EACA,UAAA,CAAY,YACd,CACF,CAAA,CACAN,GAAAA,CAAa,UAAU,UAAA,CAAa,SAAUK,EAAY,CAAA,CAAG,CAC3D,GAAM,CAAE,CAAA,CAAAhC,EAAG,CAAA,CAAAR,CAAAA,CAAG,EAAAC,CAAAA,CAAG,KAAA,CAAAwC,CAAM,CAAA,CAAI,KAAK,IAAA,CAAKD,CAAS,EAC9C,OAAOC,CAAAA,CAAQ,EAAI,CAAA,iBAAA,EAAoBjC,CAAC,CAAA,CAAA,EAAIR,CAAC,IAAIC,CAAC,CAAA,GAAA,EAAMwC,CAAK,CAAA,CAAA,CAAA,CAAM,CAAA,iBAAA,EAAoBjC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,GACpG,CAAA,CACAmC,CAAAA,CAAQ,KAAKQ,CAAAA,CAAeC,CAAa,EACzCR,GAAAA,CAAc,IAAA,CAAK,CAACO,CAAAA,CAAe,IAAI,EAAG,CAACC,CAAAA,CAAe,IAAI,CAAC,EACjE,EAEOC,CAAAA,CAAQZ","file":"p3.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearP3ToSrgb,\n oklabToLinearP3,\n parseP3Object,\n parseP3String,\n rgbToP3Raw,\n srgbLinearToP3Linear,\n srgbLinearToP3LinearInto,\n} from '../colorModels/p3.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { srgbFromLinear } from '../transfer.js';\nimport type { AnyColor, P3Color } from '../types.js';\n\nconst p3FromLinear = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearP3ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toP3(precision?: number): P3Color;\n toP3String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutP3(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Display-P3 channels.\n * This is the cheap step — only a matrix multiply + gamma encoding, no cbrt.\n * Pair with oklchToLinear to convert one OKLCH color to multiple spaces without\n * repeating the expensive OKLab pipeline.\n */\nexport const linearToP3Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToP3Linear(lr, lg, lb);\n return [srgbFromLinear(r), srgbFromLinear(g), srgbFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToP3Channels — writes [pr, pg, pb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToP3ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToP3LinearInto(out, lr, lg, lb);\n out[0] = srgbFromLinear(out[0]!);\n out[1] = srgbFromLinear(out[1]!);\n out[2] = srgbFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the sRGB transfer function (P3 does not use DCI-P3 gamma 2.6).\n */\nexport const oklchToP3Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToP3Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const oklchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear P3 → gamma P3.\n */\nexport const labToP3Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToP3Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const labToP3ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma P3. Out-of-gamut channels may exceed [0, 1].\n */\nexport const lchToP3Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToP3Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const lchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToP3ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Display-P3 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ P3).\n */\nexport const inGamutP3 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearP3);\n\nconst p3: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutP3 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearP3, p3FromLinear);\n return mapped !== null ? ColordxClass._makeFromOklab(mapped) : new ColordxClass(input);\n };\n ColordxClass.prototype.toP3 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToP3Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'display-p3' as const,\n };\n };\n ColordxClass.prototype.toP3String = function (precision = 4) {\n const { r, g, b, alpha } = this.toP3(precision);\n return alpha < 1 ? `color(display-p3 ${r} ${g} ${b} / ${alpha})` : `color(display-p3 ${r} ${g} ${b})`;\n };\n parsers.push(parseP3String, parseP3Object);\n formatParsers.push([parseP3String, 'p3'], [parseP3Object, 'p3']);\n};\n\nexport default p3;\n"]}
{"version":3,"sources":["../../src/plugins/p3.ts"],"names":["p3FromLinear","g","b","linearSrgbToOklab","linearP3ToSrgb","linearToP3Channels","lr","lg","lb","r","srgbLinearToP3Linear","srgbFromLinear","linearToP3ChannelsInto","out","srgbLinearToP3LinearInto","oklchToP3Channels","l","c","h","oklchToLinear","oklchToP3ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToP3Channels","a","labToLinearSrgb","labToP3ChannelsInto","labToLinearSrgbInto","lchToP3Channels","hRad","lchToP3ChannelsInto","inGamutP3","input","inGamutCustom","oklabToLinearP3","p3","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lpR","lpG","lpB","precision","alpha","rgbToP3Raw","round","parseP3String","parseP3Object","p3_default"],"mappings":"+QAiBA,IAAMA,EAAe,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GAC1CC,GAAAA,CAAkB,GAAGC,CAAAA,CAAe,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAmBjCG,CAAAA,CAAqB,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CAClG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,CAAAA,CAAqBJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACjD,OAAO,CAACG,GAAAA,CAAeF,CAAC,CAAA,CAAGE,GAAAA,CAAeV,CAAC,CAAA,CAAGU,GAAAA,CAAeT,CAAC,CAAC,CACjE,EAGaU,CAAAA,CAAyB,CAACC,EAA8BP,CAAAA,CAAYC,CAAAA,CAAYC,IAAqB,CAChHM,CAAAA,CAAyBD,EAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACxCK,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,CAAGG,GAAAA,CAAM9C,EAAG2C,CAAS,CAAA,CACrB,EAAGG,GAAAA,CAAM7C,CAAAA,CAAG0C,CAAS,CAAA,CACrB,KAAA,CAAAC,EACA,UAAA,CAAY,YACd,CACF,CAAA,CACAT,GAAAA,CAAa,UAAU,UAAA,CAAa,SAAUQ,EAAY,CAAA,CAAG,CAC3D,GAAM,CAAE,CAAA,CAAAnC,EAAG,CAAA,CAAAR,CAAAA,CAAG,EAAAC,CAAAA,CAAG,KAAA,CAAA2C,CAAM,CAAA,CAAI,IAAA,CAAK,KAAKD,CAAS,CAAA,CAC9C,OAAOC,CAAAA,CAAQ,CAAA,CAAI,oBAAoBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,MAAM2C,CAAK,CAAA,CAAA,CAAA,CAAM,oBAAoBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAIC,CAAC,GACpG,CAAA,CACAmC,CAAAA,CAAQ,KAAKW,CAAAA,CAAeC,CAAa,EACzCX,GAAAA,CAAc,IAAA,CAAK,CAACU,CAAAA,CAAe,IAAI,EAAG,CAACC,CAAAA,CAAe,IAAI,CAAC,EACjE,EAEOC,CAAAA,CAAQf","file":"p3.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearP3ToSrgb,\n oklabToLinearP3,\n parseP3Object,\n parseP3String,\n rgbToP3Raw,\n srgbLinearToP3Linear,\n srgbLinearToP3LinearInto,\n} from '../colorModels/p3.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { srgbFromLinear } from '../transfer.js';\nimport type { AnyColor, P3Color } from '../types.js';\n\nconst p3FromLinear = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearP3ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toP3(precision?: number): P3Color;\n toP3String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutP3(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Display-P3 channels.\n * This is the cheap step — only a matrix multiply + gamma encoding, no cbrt.\n * Pair with oklchToLinear to convert one OKLCH color to multiple spaces without\n * repeating the expensive OKLab pipeline.\n */\nexport const linearToP3Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToP3Linear(lr, lg, lb);\n return [srgbFromLinear(r), srgbFromLinear(g), srgbFromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToP3Channels — writes [pr, pg, pb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToP3ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToP3LinearInto(out, lr, lg, lb);\n out[0] = srgbFromLinear(out[0]!);\n out[1] = srgbFromLinear(out[1]!);\n out[2] = srgbFromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the sRGB transfer function (P3 does not use DCI-P3 gamma 2.6).\n */\nexport const oklchToP3Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToP3Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const oklchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear P3 → gamma P3.\n */\nexport const labToP3Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToP3Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const labToP3ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToP3ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Display-P3 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma P3. Out-of-gamut channels may exceed [0, 1].\n */\nexport const lchToP3Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToP3Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToP3Channels — writes [pr, pg, pb] into `out`. */\nexport const lchToP3ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToP3ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Display-P3 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ P3).\n */\nexport const inGamutP3 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearP3);\n\nconst p3: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutP3 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearP3, p3FromLinear);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-P3 → linear-sRGB (wide-gamut when the P3 color is outside sRGB),\n // then gamma-encode for storage. No round-trip through OKLab.\n const [lpR, lpG, lpB] = mapped.linear;\n const [lr, lg, lb] = linearP3ToSrgb(lpR, lpG, lpB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toP3 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToP3Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'display-p3' as const,\n };\n };\n ColordxClass.prototype.toP3String = function (precision = 4) {\n const { r, g, b, alpha } = this.toP3(precision);\n return alpha < 1 ? `color(display-p3 ${r} ${g} ${b} / ${alpha})` : `color(display-p3 ${r} ${g} ${b})`;\n };\n parsers.push(parseP3String, parseP3Object);\n formatParsers.push([parseP3String, 'p3'], [parseP3Object, 'p3']);\n};\n\nexport default p3;\n"]}

@@ -1,2 +0,2 @@

'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkB3CQY27M_cjs=require('../chunk-B3CQY27M.cjs'),chunkGXECYURS_cjs=require('../chunk-GXECYURS.cjs');require('../chunk-GU6TZJ4O.cjs');var chunkX5FCFNQN_cjs=require('../chunk-X5FCFNQN.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var S=(r,n,o)=>chunkGXECYURS_cjs.a(...chunkB3CQY27M_cjs.j(r,n,o)),A=(r,n,o)=>{let[e,t,c]=chunkB3CQY27M_cjs.i(r,n,o);return [chunkX5FCFNQN_cjs.d(e),chunkX5FCFNQN_cjs.d(t),chunkX5FCFNQN_cjs.d(c)]},k=(r,n,o,e)=>{chunkB3CQY27M_cjs.h(r,n,o,e),r[0]=chunkX5FCFNQN_cjs.d(r[0]),r[1]=chunkX5FCFNQN_cjs.d(r[1]),r[2]=chunkX5FCFNQN_cjs.d(r[2]);},P=(r,n,o)=>A(...chunkB3CQY27M_cjs.s(r,n,o)),D=(r,n,o,e)=>{chunkB3CQY27M_cjs.t(r,n,o,e),k(r,r[0],r[1],r[2]);},I=Math.PI/180,F=(r,n,o)=>A(...chunkB3CQY27M_cjs.A(r,n,o)),$=(r,n,o,e)=>{chunkB3CQY27M_cjs.B(r,n,o,e),k(r,r[0],r[1],r[2]);},E=(r,n,o)=>{let e=o*I;return F(r,n*Math.cos(e),n*Math.sin(e))},q=(r,n,o,e)=>{let t=e*I;$(r,n,o*Math.cos(t),o*Math.sin(t));},z=r=>chunkB3CQY27M_cjs.q(r,chunkB3CQY27M_cjs.n),G=(r,n,o)=>{r.toGamutRec2020=e=>{let t=chunkB3CQY27M_cjs.r(e,chunkB3CQY27M_cjs.n,S);return t!==null?r._makeFromOklab(t):new r(e)},r.prototype.toRec2020=function(e=4){let{r:t,g:c,b,alpha:a}=chunkB3CQY27M_cjs.k(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,e),g:chunkYISEJCI6_cjs.b(c,e),b:chunkYISEJCI6_cjs.b(b,e),alpha:a,colorSpace:"rec2020"}},r.prototype.toRec2020String=function(e=4){let{r:t,g:c,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${c} ${b} / ${a})`:`color(rec2020 ${t} ${c} ${b})`},n.push(chunkB3CQY27M_cjs.m,chunkB3CQY27M_cjs.l),o.push([chunkB3CQY27M_cjs.m,"rec2020"],[chunkB3CQY27M_cjs.l,"rec2020"]);},B=G;exports.default=B;exports.inGamutRec2020=z;exports.labToRec2020Channels=F;exports.labToRec2020ChannelsInto=$;exports.lchToRec2020Channels=E;exports.lchToRec2020ChannelsInto=q;exports.linearToRec2020Channels=A;exports.linearToRec2020ChannelsInto=k;exports.oklchToRec2020Channels=P;exports.oklchToRec2020ChannelsInto=D;//# sourceMappingURL=rec2020.cjs.map
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var chunkJVG55LEC_cjs=require('../chunk-JVG55LEC.cjs'),chunkGXECYURS_cjs=require('../chunk-GXECYURS.cjs');require('../chunk-GU6TZJ4O.cjs');var chunkX5FCFNQN_cjs=require('../chunk-X5FCFNQN.cjs');require('../chunk-3V4MONNR.cjs');var chunkYISEJCI6_cjs=require('../chunk-YISEJCI6.cjs');var $=(r,n,o)=>chunkGXECYURS_cjs.a(...chunkJVG55LEC_cjs.j(r,n,o)),A=(r,n,o)=>{let[e,t,m]=chunkJVG55LEC_cjs.i(r,n,o);return [chunkX5FCFNQN_cjs.d(e),chunkX5FCFNQN_cjs.d(t),chunkX5FCFNQN_cjs.d(m)]},S=(r,n,o,e)=>{chunkJVG55LEC_cjs.h(r,n,o,e),r[0]=chunkX5FCFNQN_cjs.d(r[0]),r[1]=chunkX5FCFNQN_cjs.d(r[1]),r[2]=chunkX5FCFNQN_cjs.d(r[2]);},E=(r,n,o)=>A(...chunkJVG55LEC_cjs.s(r,n,o)),q=(r,n,o,e)=>{chunkJVG55LEC_cjs.t(r,n,o,e),S(r,r[0],r[1],r[2]);},I=Math.PI/180,v=(r,n,o)=>A(...chunkJVG55LEC_cjs.A(r,n,o)),M=(r,n,o,e)=>{chunkJVG55LEC_cjs.B(r,n,o,e),S(r,r[0],r[1],r[2]);},z=(r,n,o)=>{let e=o*I;return v(r,n*Math.cos(e),n*Math.sin(e))},H=(r,n,o,e)=>{let t=e*I;M(r,n,o*Math.cos(t),o*Math.sin(t));},J=r=>chunkJVG55LEC_cjs.q(r,chunkJVG55LEC_cjs.n),_=(r,n,o)=>{r.toGamutRec2020=e=>{let t=chunkJVG55LEC_cjs.r(e,chunkJVG55LEC_cjs.n,$);if(t===null)return new r(e);let[m,b,a]=t.linear,[k,F,G]=chunkJVG55LEC_cjs.j(m,b,a);return r._makeFromLinearSrgb(k,F,G,t.alpha)},r.prototype.toRec2020=function(e=4){let{r:t,g:m,b,alpha:a}=chunkJVG55LEC_cjs.k(this._rawRgb());return {r:chunkYISEJCI6_cjs.b(t,e),g:chunkYISEJCI6_cjs.b(m,e),b:chunkYISEJCI6_cjs.b(b,e),alpha:a,colorSpace:"rec2020"}},r.prototype.toRec2020String=function(e=4){let{r:t,g:m,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${m} ${b} / ${a})`:`color(rec2020 ${t} ${m} ${b})`},n.push(chunkJVG55LEC_cjs.m,chunkJVG55LEC_cjs.l),o.push([chunkJVG55LEC_cjs.m,"rec2020"],[chunkJVG55LEC_cjs.l,"rec2020"]);},K=_;exports.default=K;exports.inGamutRec2020=J;exports.labToRec2020Channels=v;exports.labToRec2020ChannelsInto=M;exports.lchToRec2020Channels=z;exports.lchToRec2020ChannelsInto=H;exports.linearToRec2020Channels=A;exports.linearToRec2020ChannelsInto=S;exports.oklchToRec2020Channels=E;exports.oklchToRec2020ChannelsInto=q;//# sourceMappingURL=rec2020.cjs.map
//# sourceMappingURL=rec2020.cjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/plugins/rec2020.ts"],"names":["rec2020FromLinearConverter","g","b","linearSrgbToOklab","linearRec2020ToSrgb","linearToRec2020Channels","lr","lg","lb","r","srgbLinearToRec2020Linear","rec2020FromLinear","linearToRec2020ChannelsInto","out","srgbLinearToRec2020LinearInto","oklchToRec2020Channels","l","c","h","oklchToLinear","oklchToRec2020ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToRec2020Channels","a","labToLinearSrgb","labToRec2020ChannelsInto","labToLinearSrgbInto","lchToRec2020Channels","hRad","lchToRec2020ChannelsInto","inGamutRec2020","input","inGamutCustom","oklabToLinearRec2020","rec2020","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","precision","alpha","rgbToRec2020Raw","round","parseRec2020String","parseRec2020Object","rec2020_default"],"mappings":"gWAiBA,IAAMA,EAA6B,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GACxDC,mBAAAA,CAAkB,GAAGC,mBAAAA,CAAoB,CAAA,CAAGH,CAAAA,CAAGC,CAAC,CAAC,CAAA,CAiBtCG,CAAAA,CAA0B,CAACC,CAAAA,CAAYC,CAAAA,CAAYC,IAAyC,CACvG,GAAM,CAACC,CAAAA,CAAGR,EAAGC,CAAC,CAAA,CAAIQ,oBAA0BJ,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACtD,OAAO,CAACG,mBAAAA,CAAkBF,CAAC,CAAA,CAAGE,mBAAAA,CAA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,EAAGC,mBAAAA,CAAMnC,CAAAA,CAAGgC,CAAS,CAAA,CACrB,EAAGG,mBAAAA,CAAM3C,CAAAA,CAAGwC,CAAS,CAAA,CACrB,CAAA,CAAGG,oBAAM,CAAA,CAAGH,CAAS,CAAA,CACrB,KAAA,CAAAC,EACA,UAAA,CAAY,SACd,CACF,CAAA,CACAN,CAAAA,CAAa,UAAU,eAAA,CAAkB,SAAUK,CAAAA,CAAY,CAAA,CAAG,CAChE,GAAM,CAAE,EAAAhC,CAAAA,CAAG,CAAA,CAAAR,EAAG,CAAA,CAAG,KAAA,CAAAyC,CAAM,CAAA,CAAI,KAAK,SAAA,CAAUD,CAAS,EACnD,OAAOC,CAAAA,CAAQ,EAAI,CAAA,cAAA,EAAiBjC,CAAC,CAAA,CAAA,EAAIR,CAAC,IAAI,CAAC,CAAA,GAAA,EAAMyC,CAAK,CAAA,CAAA,CAAA,CAAM,CAAA,cAAA,EAAiBjC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,GAC9F,CAAA,CACAoC,CAAAA,CAAQ,KAAKQ,mBAAAA,CAAoBC,mBAAkB,EACnDR,CAAAA,CAAc,IAAA,CAAK,CAACO,mBAAAA,CAAoB,SAAS,EAAG,CAACC,mBAAAA,CAAoB,SAAS,CAAC,EACrF,EAEOC,CAAAA,CAAQZ","file":"rec2020.cjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearRec2020ToSrgb,\n oklabToLinearRec2020,\n parseRec2020Object,\n parseRec2020String,\n rgbToRec2020Raw,\n srgbLinearToRec2020Linear,\n srgbLinearToRec2020LinearInto,\n} from '../colorModels/rec2020.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { rec2020FromLinear } from '../transfer.js';\nimport type { AnyColor, Rec2020Color } from '../types.js';\n\nconst rec2020FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearRec2020ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toRec2020(precision?: number): Rec2020Color;\n toRec2020String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutRec2020(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Rec.2020 channels.\n * This is the cheap step — only a matrix multiply + BT.2020 gamma, no cbrt.\n */\nexport const linearToRec2020Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToRec2020Linear(lr, lg, lb);\n return [rec2020FromLinear(r), rec2020FromLinear(g), rec2020FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToRec2020Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToRec2020ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToRec2020LinearInto(out, lr, lg, lb);\n out[0] = rec2020FromLinear(out[0]!);\n out[1] = rec2020FromLinear(out[1]!);\n out[2] = rec2020FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the BT.2020 transfer function (exponent 0.45, distinct from sRGB 1/2.4).\n */\nexport const oklchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToRec2020Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear Rec.2020 → BT.2020 gamma.\n */\nexport const labToRec2020Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToRec2020Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const labToRec2020ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma Rec.2020.\n */\nexport const lchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToRec2020Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToRec2020ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Rec.2020 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ Rec.2020).\n */\nexport const inGamutRec2020 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearRec2020);\n\nconst rec2020: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutRec2020 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearRec2020, rec2020FromLinearConverter);\n return mapped !== null ? ColordxClass._makeFromOklab(mapped) : new ColordxClass(input);\n };\n ColordxClass.prototype.toRec2020 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToRec2020Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'rec2020' as const,\n };\n };\n ColordxClass.prototype.toRec2020String = function (precision = 4) {\n const { r, g, b, alpha } = this.toRec2020(precision);\n return alpha < 1 ? `color(rec2020 ${r} ${g} ${b} / ${alpha})` : `color(rec2020 ${r} ${g} ${b})`;\n };\n parsers.push(parseRec2020String, parseRec2020Object);\n formatParsers.push([parseRec2020String, 'rec2020'], [parseRec2020Object, 'rec2020']);\n};\n\nexport default rec2020;\n"]}
{"version":3,"sources":["../../src/plugins/rec2020.ts"],"names":["rec2020FromLinearConverter","g","b","linearSrgbToOklab","linearRec2020ToSrgb","linearToRec2020Channels","lr","lg","lb","r","srgbLinearToRec2020Linear","rec2020FromLinear","linearToRec2020ChannelsInto","out","srgbLinearToRec2020LinearInto","oklchToRec2020Channels","l","c","h","oklchToLinear","oklchToRec2020ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToRec2020Channels","a","labToLinearSrgb","labToRec2020ChannelsInto","labToLinearSrgbInto","lchToRec2020Channels","hRad","lchToRec2020ChannelsInto","inGamutRec2020","input","inGamutCustom","oklabToLinearRec2020","rec2020","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lrR","lrG","lrB","precision","alpha","rgbToRec2020Raw","round","parseRec2020String","parseRec2020Object","rec2020_default"],"mappings":"gWAiBA,IAAMA,EAA6B,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GACxDC,mBAAAA,CAAkB,GAAGC,mBAAAA,CAAoB,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAiBtCG,CAAAA,CAA0B,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CACvG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,mBAAAA,CAA0BJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACtD,OAAO,CAACG,mBAAAA,CAAkBF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ClE,CAAA,CACAH,CAAAA,CAAa,UAAU,SAAA,CAAY,SAAUQ,EAAY,CAAA,CAAG,CAC1D,GAAM,CAAE,CAAA,CAAAnC,CAAAA,CAAG,CAAA,CAAAR,EAAG,CAAA,CAAG,KAAA,CAAA4C,CAAM,CAAA,CAAIC,mBAAAA,CAAgB,KAAK,OAAA,EAAS,EACzD,OAAO,CACL,EAAGC,mBAAAA,CAAMtC,CAAAA,CAAGmC,CAAS,CAAA,CACrB,CAAA,CAAGG,oBAAM9C,CAAAA,CAAG2C,CAAS,EACrB,CAAA,CAAGG,mBAAAA,CAAM,EAAGH,CAAS,CAAA,CACrB,MAAAC,CAAAA,CACA,UAAA,CAAY,SACd,CACF,CAAA,CACAT,EAAa,SAAA,CAAU,eAAA,CAAkB,SAAUQ,CAAAA,CAAY,CAAA,CAAG,CAChE,GAAM,CAAE,EAAAnC,CAAAA,CAAG,CAAA,CAAAR,EAAG,CAAA,CAAG,KAAA,CAAA4C,CAAM,CAAA,CAAI,IAAA,CAAK,UAAUD,CAAS,CAAA,CACnD,OAAOC,CAAAA,CAAQ,CAAA,CAAI,iBAAiBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,MAAM4C,CAAK,CAAA,CAAA,CAAA,CAAM,iBAAiBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,GAC9F,CAAA,CACAoC,CAAAA,CAAQ,KAAKW,mBAAAA,CAAoBC,mBAAkB,EACnDX,CAAAA,CAAc,IAAA,CAAK,CAACU,mBAAAA,CAAoB,SAAS,EAAG,CAACC,mBAAAA,CAAoB,SAAS,CAAC,EACrF,EAEOC,CAAAA,CAAQf","file":"rec2020.cjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearRec2020ToSrgb,\n oklabToLinearRec2020,\n parseRec2020Object,\n parseRec2020String,\n rgbToRec2020Raw,\n srgbLinearToRec2020Linear,\n srgbLinearToRec2020LinearInto,\n} from '../colorModels/rec2020.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { rec2020FromLinear } from '../transfer.js';\nimport type { AnyColor, Rec2020Color } from '../types.js';\n\nconst rec2020FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearRec2020ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toRec2020(precision?: number): Rec2020Color;\n toRec2020String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutRec2020(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Rec.2020 channels.\n * This is the cheap step — only a matrix multiply + BT.2020 gamma, no cbrt.\n */\nexport const linearToRec2020Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToRec2020Linear(lr, lg, lb);\n return [rec2020FromLinear(r), rec2020FromLinear(g), rec2020FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToRec2020Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToRec2020ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToRec2020LinearInto(out, lr, lg, lb);\n out[0] = rec2020FromLinear(out[0]!);\n out[1] = rec2020FromLinear(out[1]!);\n out[2] = rec2020FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the BT.2020 transfer function (exponent 0.45, distinct from sRGB 1/2.4).\n */\nexport const oklchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToRec2020Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear Rec.2020 → BT.2020 gamma.\n */\nexport const labToRec2020Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToRec2020Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const labToRec2020ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma Rec.2020.\n */\nexport const lchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToRec2020Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToRec2020ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Rec.2020 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ Rec.2020).\n */\nexport const inGamutRec2020 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearRec2020);\n\nconst rec2020: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutRec2020 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearRec2020, rec2020FromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-Rec.2020 → linear-sRGB (wide-gamut when the Rec.2020 color is outside\n // sRGB), then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearRec2020ToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toRec2020 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToRec2020Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'rec2020' as const,\n };\n };\n ColordxClass.prototype.toRec2020String = function (precision = 4) {\n const { r, g, b, alpha } = this.toRec2020(precision);\n return alpha < 1 ? `color(rec2020 ${r} ${g} ${b} / ${alpha})` : `color(rec2020 ${r} ${g} ${b})`;\n };\n parsers.push(parseRec2020String, parseRec2020Object);\n formatParsers.push([parseRec2020String, 'rec2020'], [parseRec2020Object, 'rec2020']);\n};\n\nexport default rec2020;\n"]}

@@ -1,2 +0,2 @@

import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.cjs';
import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.cjs';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-CQAwj4SM.js';
import { R as Rec2020Color, A as AnyColor, q as Plugin } from '../colordx-FkeB37IC.js';

@@ -3,0 +3,0 @@ declare module '@colordx/core' {

@@ -1,2 +0,2 @@

import {i,h,s,t,A as A$1,B as B$1,q as q$1,n,r,k as k$1,m,l,j}from'../chunk-DIWXRMTC.mjs';import {a}from'../chunk-J6CH5YTL.mjs';import'../chunk-4LKLL3IS.mjs';import {d}from'../chunk-FXCFKFXK.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b}from'../chunk-IOXRZECH.mjs';var S=(r,n,o)=>a(...j(r,n,o)),A=(r,n,o)=>{let[e,t,c]=i(r,n,o);return [d(e),d(t),d(c)]},k=(r,n,o,e)=>{h(r,n,o,e),r[0]=d(r[0]),r[1]=d(r[1]),r[2]=d(r[2]);},P=(r,n,o)=>A(...s(r,n,o)),D=(r,n,o,e)=>{t(r,n,o,e),k(r,r[0],r[1],r[2]);},I=Math.PI/180,F=(r,n,o)=>A(...A$1(r,n,o)),$=(r,n,o,e)=>{B$1(r,n,o,e),k(r,r[0],r[1],r[2]);},E=(r,n,o)=>{let e=o*I;return F(r,n*Math.cos(e),n*Math.sin(e))},q=(r,n,o,e)=>{let t=e*I;$(r,n,o*Math.cos(t),o*Math.sin(t));},z=r=>q$1(r,n),G=(r$1,n$1,o)=>{r$1.toGamutRec2020=e=>{let t=r(e,n,S);return t!==null?r$1._makeFromOklab(t):new r$1(e)},r$1.prototype.toRec2020=function(e=4){let{r:t,g:c,b: b$1,alpha:a}=k$1(this._rawRgb());return {r:b(t,e),g:b(c,e),b:b(b$1,e),alpha:a,colorSpace:"rec2020"}},r$1.prototype.toRec2020String=function(e=4){let{r:t,g:c,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${c} ${b} / ${a})`:`color(rec2020 ${t} ${c} ${b})`},n$1.push(m,l),o.push([m,"rec2020"],[l,"rec2020"]);},B=G;export{B as default,z as inGamutRec2020,F as labToRec2020Channels,$ as labToRec2020ChannelsInto,E as lchToRec2020Channels,q as lchToRec2020ChannelsInto,A as linearToRec2020Channels,k as linearToRec2020ChannelsInto,P as oklchToRec2020Channels,D as oklchToRec2020ChannelsInto};//# sourceMappingURL=rec2020.mjs.map
import {i,h,s,t,A as A$1,B,q as q$1,n,r,j,k,m,l}from'../chunk-BXGFP5BN.mjs';import {a}from'../chunk-J6CH5YTL.mjs';import'../chunk-4LKLL3IS.mjs';import {d}from'../chunk-FXCFKFXK.mjs';import'../chunk-Q3O3QQ4H.mjs';import {b}from'../chunk-IOXRZECH.mjs';var $=(r,n,o)=>a(...j(r,n,o)),A=(r,n,o)=>{let[e,t,m]=i(r,n,o);return [d(e),d(t),d(m)]},S=(r,n,o,e)=>{h(r,n,o,e),r[0]=d(r[0]),r[1]=d(r[1]),r[2]=d(r[2]);},E=(r,n,o)=>A(...s(r,n,o)),q=(r,n,o,e)=>{t(r,n,o,e),S(r,r[0],r[1],r[2]);},I=Math.PI/180,v=(r,n,o)=>A(...A$1(r,n,o)),M=(r,n,o,e)=>{B(r,n,o,e),S(r,r[0],r[1],r[2]);},z=(r,n,o)=>{let e=o*I;return v(r,n*Math.cos(e),n*Math.sin(e))},H=(r,n,o,e)=>{let t=e*I;M(r,n,o*Math.cos(t),o*Math.sin(t));},J=r=>q$1(r,n),_=(r$1,n$1,o)=>{r$1.toGamutRec2020=e=>{let t=r(e,n,$);if(t===null)return new r$1(e);let[m,b,a]=t.linear,[k,F,G]=j(m,b,a);return r$1._makeFromLinearSrgb(k,F,G,t.alpha)},r$1.prototype.toRec2020=function(e=4){let{r:t,g:m,b: b$1,alpha:a}=k(this._rawRgb());return {r:b(t,e),g:b(m,e),b:b(b$1,e),alpha:a,colorSpace:"rec2020"}},r$1.prototype.toRec2020String=function(e=4){let{r:t,g:m,b,alpha:a}=this.toRec2020(e);return a<1?`color(rec2020 ${t} ${m} ${b} / ${a})`:`color(rec2020 ${t} ${m} ${b})`},n$1.push(m,l),o.push([m,"rec2020"],[l,"rec2020"]);},K=_;export{K as default,J as inGamutRec2020,v as labToRec2020Channels,M as labToRec2020ChannelsInto,z as lchToRec2020Channels,H as lchToRec2020ChannelsInto,A as linearToRec2020Channels,S as linearToRec2020ChannelsInto,E as oklchToRec2020Channels,q as oklchToRec2020ChannelsInto};//# sourceMappingURL=rec2020.mjs.map
//# sourceMappingURL=rec2020.mjs.map

@@ -1,1 +0,1 @@

{"version":3,"sources":["../../src/plugins/rec2020.ts"],"names":["rec2020FromLinearConverter","g","b","linearSrgbToOklab","linearRec2020ToSrgb","linearToRec2020Channels","lr","lg","lb","r","srgbLinearToRec2020Linear","rec2020FromLinear","linearToRec2020ChannelsInto","out","srgbLinearToRec2020LinearInto","oklchToRec2020Channels","l","c","h","oklchToLinear","oklchToRec2020ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToRec2020Channels","a","labToLinearSrgb","labToRec2020ChannelsInto","labToLinearSrgbInto","lchToRec2020Channels","hRad","lchToRec2020ChannelsInto","inGamutRec2020","input","inGamutCustom","oklabToLinearRec2020","rec2020","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","precision","alpha","rgbToRec2020Raw","round","parseRec2020String","parseRec2020Object","rec2020_default"],"mappings":"wQAiBA,IAAMA,EAA6B,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GACxDC,CAAAA,CAAkB,GAAGC,CAAAA,CAAoB,CAAA,CAAGH,CAAAA,CAAGC,CAAC,CAAC,CAAA,CAiBtCG,CAAAA,CAA0B,CAACC,CAAAA,CAAYC,CAAAA,CAAYC,IAAyC,CACvG,GAAM,CAACC,CAAAA,CAAGR,EAAGC,CAAC,CAAA,CAAIQ,EAA0BJ,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CACtD,OAAO,CAACG,CAAAA,CAAkBF,CAAC,CAAA,CAAGE,CAAAA,CAAkBV,CAAC,CAAA,CAAGU,CAAAA,CAAkBT,CAAC,CAAC,CAC1E,CAAA,CAGaU,CAAAA,CAA8B,CAACC,CAAAA,CAA8BP,CAAAA,CAAYC,EAAYC,CAAAA,GAAqB,CACrHM,EAA8BD,CAAAA,CAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,EAC7CK,CAAAA,CAAI,CAAC,EAAIF,CAAAA,CAAkBE,CAAAA,CAAI,CAAC,CAAE,CAAA,CAClCA,CAAAA,CAAI,CAAC,EAAIF,CAAAA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AA,CAAG,KAAA,CAAAyC,CAAM,CAAA,CAAI,KAAK,SAAA,CAAUD,CAAS,EACnD,OAAOC,CAAAA,CAAQ,EAAI,CAAA,cAAA,EAAiBjC,CAAC,CAAA,CAAA,EAAIR,CAAC,IAAI,CAAC,CAAA,GAAA,EAAMyC,CAAK,CAAA,CAAA,CAAA,CAAM,CAAA,cAAA,EAAiBjC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,GAC9F,CAAA,CACAoC,GAAAA,CAAQ,KAAKQ,CAAAA,CAAoBC,CAAkB,EACnDR,CAAAA,CAAc,IAAA,CAAK,CAACO,CAAAA,CAAoB,SAAS,EAAG,CAACC,CAAAA,CAAoB,SAAS,CAAC,EACrF,EAEOC,CAAAA,CAAQZ","file":"rec2020.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearRec2020ToSrgb,\n oklabToLinearRec2020,\n parseRec2020Object,\n parseRec2020String,\n rgbToRec2020Raw,\n srgbLinearToRec2020Linear,\n srgbLinearToRec2020LinearInto,\n} from '../colorModels/rec2020.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { rec2020FromLinear } from '../transfer.js';\nimport type { AnyColor, Rec2020Color } from '../types.js';\n\nconst rec2020FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearRec2020ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toRec2020(precision?: number): Rec2020Color;\n toRec2020String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutRec2020(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Rec.2020 channels.\n * This is the cheap step — only a matrix multiply + BT.2020 gamma, no cbrt.\n */\nexport const linearToRec2020Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToRec2020Linear(lr, lg, lb);\n return [rec2020FromLinear(r), rec2020FromLinear(g), rec2020FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToRec2020Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToRec2020ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToRec2020LinearInto(out, lr, lg, lb);\n out[0] = rec2020FromLinear(out[0]!);\n out[1] = rec2020FromLinear(out[1]!);\n out[2] = rec2020FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the BT.2020 transfer function (exponent 0.45, distinct from sRGB 1/2.4).\n */\nexport const oklchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToRec2020Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear Rec.2020 → BT.2020 gamma.\n */\nexport const labToRec2020Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToRec2020Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const labToRec2020ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma Rec.2020.\n */\nexport const lchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToRec2020Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToRec2020ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Rec.2020 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ Rec.2020).\n */\nexport const inGamutRec2020 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearRec2020);\n\nconst rec2020: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutRec2020 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearRec2020, rec2020FromLinearConverter);\n return mapped !== null ? ColordxClass._makeFromOklab(mapped) : new ColordxClass(input);\n };\n ColordxClass.prototype.toRec2020 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToRec2020Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'rec2020' as const,\n };\n };\n ColordxClass.prototype.toRec2020String = function (precision = 4) {\n const { r, g, b, alpha } = this.toRec2020(precision);\n return alpha < 1 ? `color(rec2020 ${r} ${g} ${b} / ${alpha})` : `color(rec2020 ${r} ${g} ${b})`;\n };\n parsers.push(parseRec2020String, parseRec2020Object);\n formatParsers.push([parseRec2020String, 'rec2020'], [parseRec2020Object, 'rec2020']);\n};\n\nexport default rec2020;\n"]}
{"version":3,"sources":["../../src/plugins/rec2020.ts"],"names":["rec2020FromLinearConverter","g","b","linearSrgbToOklab","linearRec2020ToSrgb","linearToRec2020Channels","lr","lg","lb","r","srgbLinearToRec2020Linear","rec2020FromLinear","linearToRec2020ChannelsInto","out","srgbLinearToRec2020LinearInto","oklchToRec2020Channels","l","c","h","oklchToLinear","oklchToRec2020ChannelsInto","oklchToLinearInto","DEG_TO_RAD","labToRec2020Channels","a","labToLinearSrgb","labToRec2020ChannelsInto","labToLinearSrgbInto","lchToRec2020Channels","hRad","lchToRec2020ChannelsInto","inGamutRec2020","input","inGamutCustom","oklabToLinearRec2020","rec2020","ColordxClass","parsers","formatParsers","mapped","toGamutCustom","lrR","lrG","lrB","precision","alpha","rgbToRec2020Raw","round","parseRec2020String","parseRec2020Object","rec2020_default"],"mappings":"0PAiBA,IAAMA,EAA6B,CAAC,CAAA,CAAWC,EAAWC,CAAAA,GACxDC,CAAAA,CAAkB,GAAGC,CAAAA,CAAoB,CAAA,CAAGH,EAAGC,CAAC,CAAC,EAiBtCG,CAAAA,CAA0B,CAACC,EAAYC,CAAAA,CAAYC,CAAAA,GAAyC,CACvG,GAAM,CAACC,EAAGR,CAAAA,CAAGC,CAAC,EAAIQ,CAAAA,CAA0BJ,CAAAA,CAAIC,EAAIC,CAAE,CAAA,CACtD,OAAO,CAACG,CAAAA,CAAkBF,CAAC,CAAA,CAAGE,CAAAA,CAAkBV,CAAC,CAAA,CAAGU,CAAAA,CAAkBT,CAAC,CAAC,CAC1E,EAGaU,CAAAA,CAA8B,CAACC,EAA8BP,CAAAA,CAAYC,CAAAA,CAAYC,IAAqB,CACrHM,CAAAA,CAA8BD,EAAKP,CAAAA,CAAIC,CAAAA,CAAIC,CAAE,CAAA,CAC7CK,CAAAA,CAAI,CAAC,CAAA,CAAIF,CAAAA,CAAkBE,EAAI,CAAC,CAAE,EAClCA,CAAAA,CAAI,CAAC,EAAIF,CAAAA,CAAkBE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G0C,CAAS,CAAA,CACrB,MAAAC,CAAAA,CACA,UAAA,CAAY,SACd,CACF,CAAA,CACAT,IAAa,SAAA,CAAU,eAAA,CAAkB,SAAUQ,CAAAA,CAAY,CAAA,CAAG,CAChE,GAAM,CAAE,EAAAnC,CAAAA,CAAG,CAAA,CAAAR,EAAG,CAAA,CAAG,KAAA,CAAA4C,CAAM,CAAA,CAAI,IAAA,CAAK,UAAUD,CAAS,CAAA,CACnD,OAAOC,CAAAA,CAAQ,CAAA,CAAI,iBAAiBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,MAAM4C,CAAK,CAAA,CAAA,CAAA,CAAM,iBAAiBpC,CAAC,CAAA,CAAA,EAAIR,CAAC,CAAA,CAAA,EAAI,CAAC,GAC9F,CAAA,CACAoC,GAAAA,CAAQ,KAAKW,CAAAA,CAAoBC,CAAkB,EACnDX,CAAAA,CAAc,IAAA,CAAK,CAACU,CAAAA,CAAoB,SAAS,EAAG,CAACC,CAAAA,CAAoB,SAAS,CAAC,EACrF,EAEOC,CAAAA,CAAQf","file":"rec2020.mjs","sourcesContent":["import { labToLinearSrgb, labToLinearSrgbInto, oklchToLinear, oklchToLinearInto } from '../channels.js';\nimport { linearSrgbToOklab } from '../colorModels/oklab.js';\nimport {\n linearRec2020ToSrgb,\n oklabToLinearRec2020,\n parseRec2020Object,\n parseRec2020String,\n rgbToRec2020Raw,\n srgbLinearToRec2020Linear,\n srgbLinearToRec2020LinearInto,\n} from '../colorModels/rec2020.js';\nimport type { Plugin } from '../colordx.js';\nimport { inGamutCustom, toGamutCustom } from '../gamut.js';\nimport { round } from '../helpers.js';\nimport { rec2020FromLinear } from '../transfer.js';\nimport type { AnyColor, Rec2020Color } from '../types.js';\n\nconst rec2020FromLinearConverter = (r: number, g: number, b: number): [number, number, number] =>\n linearSrgbToOklab(...linearRec2020ToSrgb(r, g, b));\n\ndeclare module '@colordx/core' {\n interface Colordx {\n toRec2020(precision?: number): Rec2020Color;\n toRec2020String(precision?: number): string;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace Colordx {\n function toGamutRec2020(input: AnyColor): Colordx;\n }\n}\n\n/**\n * Convert linear sRGB channels (from oklchToLinear) to gamma-encoded Rec.2020 channels.\n * This is the cheap step — only a matrix multiply + BT.2020 gamma, no cbrt.\n */\nexport const linearToRec2020Channels = (lr: number, lg: number, lb: number): [number, number, number] => {\n const [r, g, b] = srgbLinearToRec2020Linear(lr, lg, lb);\n return [rec2020FromLinear(r), rec2020FromLinear(g), rec2020FromLinear(b)];\n};\n\n/** Zero-allocation sibling of linearToRec2020Channels — writes [rr, rg, rb] (gamma-encoded, 0–1) into `out`. */\nexport const linearToRec2020ChannelsInto = (out: Float64Array | number[], lr: number, lg: number, lb: number): void => {\n srgbLinearToRec2020LinearInto(out, lr, lg, lb);\n out[0] = rec2020FromLinear(out[0]!);\n out[1] = rec2020FromLinear(out[1]!);\n out[2] = rec2020FromLinear(out[2]!);\n};\n\n/**\n * Convert OKLCH to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors. Out-of-gamut channels may\n * exceed this range — callers are responsible for clamping before byte encoding.\n * Uses the BT.2020 transfer function (exponent 0.45, distinct from sRGB 1/2.4).\n */\nexport const oklchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] =>\n linearToRec2020Channels(...oklchToLinear(l, c, h));\n\n/** Zero-allocation sibling of oklchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const oklchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n oklchToLinearInto(out, l, c, h);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**\n * Convert CIE Lab (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Returns [r, g, b] in [0, 1] for in-gamut colors; out-of-gamut channels may exceed [0, 1].\n * Goes Lab → XYZ D50 → linear sRGB → linear Rec.2020 → BT.2020 gamma.\n */\nexport const labToRec2020Channels = (l: number, a: number, b: number): [number, number, number] =>\n linearToRec2020Channels(...labToLinearSrgb(l, a, b));\n\n/** Zero-allocation sibling of labToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const labToRec2020ChannelsInto = (out: Float64Array | number[], l: number, a: number, b: number): void => {\n labToLinearSrgbInto(out, l, a, b);\n linearToRec2020ChannelsInto(out, out[0]!, out[1]!, out[2]!);\n};\n\n/**\n * Convert CIE LCH (D50) to gamma-encoded Rec.2020 channels without object allocation.\n * Polar-to-rectangular to Lab, then Lab → gamma Rec.2020.\n */\nexport const lchToRec2020Channels = (l: number, c: number, h: number): [number, number, number] => {\n const hRad = h * DEG_TO_RAD;\n return labToRec2020Channels(l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/** Zero-allocation sibling of lchToRec2020Channels — writes [rr, rg, rb] into `out`. */\nexport const lchToRec2020ChannelsInto = (out: Float64Array | number[], l: number, c: number, h: number): void => {\n const hRad = h * DEG_TO_RAD;\n labToRec2020ChannelsInto(out, l, c * Math.cos(hRad), c * Math.sin(hRad));\n};\n\n/**\n * Returns true if the color is within the Rec.2020 gamut.\n * sRGB inputs (hex, rgb, hsl, etc.) always return true (sRGB ⊂ Rec.2020).\n */\nexport const inGamutRec2020 = (input: AnyColor): boolean => inGamutCustom(input, oklabToLinearRec2020);\n\nconst rec2020: Plugin = (ColordxClass, parsers, formatParsers) => {\n ColordxClass.toGamutRec2020 = (input: AnyColor) => {\n const mapped = toGamutCustom(input, oklabToLinearRec2020, rec2020FromLinearConverter);\n if (mapped === null) return new ColordxClass(input);\n // Clipped linear-Rec.2020 → linear-sRGB (wide-gamut when the Rec.2020 color is outside\n // sRGB), then gamma-encode for storage. No round-trip through OKLab.\n const [lrR, lrG, lrB] = mapped.linear;\n const [lr, lg, lb] = linearRec2020ToSrgb(lrR, lrG, lrB);\n return ColordxClass._makeFromLinearSrgb(lr, lg, lb, mapped.alpha);\n };\n ColordxClass.prototype.toRec2020 = function (precision = 4) {\n const { r, g, b, alpha } = rgbToRec2020Raw(this._rawRgb());\n return {\n r: round(r, precision),\n g: round(g, precision),\n b: round(b, precision),\n alpha,\n colorSpace: 'rec2020' as const,\n };\n };\n ColordxClass.prototype.toRec2020String = function (precision = 4) {\n const { r, g, b, alpha } = this.toRec2020(precision);\n return alpha < 1 ? `color(rec2020 ${r} ${g} ${b} / ${alpha})` : `color(rec2020 ${r} ${g} ${b})`;\n };\n parsers.push(parseRec2020String, parseRec2020Object);\n formatParsers.push([parseRec2020String, 'rec2020'], [parseRec2020Object, 'rec2020']);\n};\n\nexport default rec2020;\n"]}
{
"name": "@colordx/core",
"version": "5.4.1",
"version": "5.4.2",
"description": "A high-performance color library with extended support for modern color spaces including OKLCH, OKLAB, Display-P3, and more",

@@ -5,0 +5,0 @@ "author": "Dmitrii Kriaklin",

'use strict';var chunkGXECYURS_cjs=require('./chunk-GXECYURS.cjs'),chunkGU6TZJ4O_cjs=require('./chunk-GU6TZJ4O.cjs'),chunkX5FCFNQN_cjs=require('./chunk-X5FCFNQN.cjs'),chunkYISEJCI6_cjs=require('./chunk-YISEJCI6.cjs');var J=.8224619687,Q=.1775380313,W=.0331941989,rr=.9668058011,nr=.0170826307,er=.0723974407,or=.9105199286,Mr=1.2249401762805598,Gr=-0.22494017628055996,Ir=-0.04205695470968816,wr=1.042056954709688,zr=-0.019637554590334432,Fr=-0.07863604555063189,vr=1.0982736001409663,cn=(e,r,n,o)=>{e[0]=J*r+Q*n,e[1]=W*r+rr*n,e[2]=nr*r+er*n+or*o;},br=(e,r,n)=>[J*e+Q*r,W*e+rr*r,nr*e+er*r+or*n];var F=(e,r,n)=>[Mr*e+Gr*r,Ir*e+wr*r,zr*e+Fr*r+vr*n],pn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=br(chunkX5FCFNQN_cjs.a(e/255),chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(n/255));return {r:chunkX5FCFNQN_cjs.b(b),g:chunkX5FCFNQN_cjs.b(t),b:chunkX5FCFNQN_cjs.b(u),alpha:o,colorSpace:"display-p3"}};var tr=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=F(chunkX5FCFNQN_cjs.a(e),chunkX5FCFNQN_cjs.a(r),chunkX5FCFNQN_cjs.a(n));return {r:chunkX5FCFNQN_cjs.b(b)*255,g:chunkX5FCFNQN_cjs.b(t)*255,b:chunkX5FCFNQN_cjs.b(u)*255,alpha:o}},dn=e=>{if(!chunkYISEJCI6_cjs.h(e)||e.colorSpace!=="display-p3"||!chunkYISEJCI6_cjs.i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(b)?null:tr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(o),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},Er=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),hn=e=>{if(typeof e!="string")return null;let r=Er.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),o=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return tr({r:n,g:o,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},gn=(e,r,n)=>br(...chunkGXECYURS_cjs.f(e,r,n));var ar=.6274038959,ur=.3292830384,mr=.0433130657,sr=.0690972894,lr=.9195403951,cr=.0113623156,pr=.0163914389,ir=.0880133079,dr=.8955952532,Br=1.6604910021084345,Or=-0.5876411387885495,$r=-0.07284986331988488,Dr=-0.12455047452159074,jr=1.1328998971259603,Xr=-0.008349422604369477,Ur=-0.018150763354905303,Kr=-0.10057889800800739,qr=1.1187296613629127,xn=(e,r,n,o)=>{e[0]=ar*r+ur*n+mr*o,e[1]=sr*r+lr*n+cr*o,e[2]=pr*r+ir*n+dr*o;},hr=(e,r,n)=>[ar*e+ur*r+mr*n,sr*e+lr*r+cr*n,pr*e+ir*r+dr*n];var v=(e,r,n)=>[Br*e+Or*r+$r*n,Dr*e+jr*r+Xr*n,Ur*e+Kr*r+qr*n],Tn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=hr(chunkX5FCFNQN_cjs.a(e/255),chunkX5FCFNQN_cjs.a(r/255),chunkX5FCFNQN_cjs.a(n/255));return {r:chunkX5FCFNQN_cjs.d(b),g:chunkX5FCFNQN_cjs.d(t),b:chunkX5FCFNQN_cjs.d(u),alpha:o,colorSpace:"rec2020"}};var gr=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=v(chunkX5FCFNQN_cjs.c(e),chunkX5FCFNQN_cjs.c(r),chunkX5FCFNQN_cjs.c(n));return {r:chunkX5FCFNQN_cjs.b(b)*255,g:chunkX5FCFNQN_cjs.b(t)*255,b:chunkX5FCFNQN_cjs.b(u)*255,alpha:o}},Cn=e=>{if(!chunkYISEJCI6_cjs.h(e)||e.colorSpace!=="rec2020"||!chunkYISEJCI6_cjs.i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !chunkYISEJCI6_cjs.f(r)||!chunkYISEJCI6_cjs.f(n)||!chunkYISEJCI6_cjs.f(o)||!chunkYISEJCI6_cjs.f(b)?null:gr({r:chunkYISEJCI6_cjs.g(r),g:chunkYISEJCI6_cjs.g(n),b:chunkYISEJCI6_cjs.g(o),alpha:chunkYISEJCI6_cjs.a(chunkYISEJCI6_cjs.g(b),0,1)})},Hr=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${chunkYISEJCI6_cjs.k})(?<rp>%?)\\s+(?<g>${chunkYISEJCI6_cjs.k})(?<gp>%?)\\s+(?<b>${chunkYISEJCI6_cjs.k})(?<bp>%?)\\s*(?:/\\s*(?<al>${chunkYISEJCI6_cjs.k})(?<alp>%?)\\s*)?\\)$`,"i"),Ln=e=>{if(typeof e!="string")return null;let r=Hr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?chunkYISEJCI6_cjs.l(r.r)/100:chunkYISEJCI6_cjs.l(r.r),o=r.gp?chunkYISEJCI6_cjs.l(r.g)/100:chunkYISEJCI6_cjs.l(r.g),b=r.bp?chunkYISEJCI6_cjs.l(r.b)/100:chunkYISEJCI6_cjs.l(r.b),t=r.al===void 0?1:chunkYISEJCI6_cjs.l(r.al)/(r.alp?100:1);return gr({r:n,g:o,b,alpha:chunkYISEJCI6_cjs.a(t,0,1)})},Nn=(e,r,n)=>hr(...chunkGXECYURS_cjs.f(e,r,n));var Vr=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yr=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zr=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jr=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qr=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wr=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nn=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,G=(e,r,n)=>{let{x:o,y:b,z:t}=chunkGU6TZJ4O_cjs.l({l:e,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,s,l]=chunkGU6TZJ4O_cjs.e(o,b,t);return chunkGXECYURS_cjs.a(u,s,l)},Rr=(e,r,n)=>{let[o,b,t]=F(chunkX5FCFNQN_cjs.a(e),chunkX5FCFNQN_cjs.a(r),chunkX5FCFNQN_cjs.a(n));return chunkGXECYURS_cjs.a(o,b,t)},fr=(e,r,n)=>{let[o,b,t]=v(chunkX5FCFNQN_cjs.c(e),chunkX5FCFNQN_cjs.c(r),chunkX5FCFNQN_cjs.c(n));return chunkGXECYURS_cjs.a(o,b,t)},yr=(e,r,n)=>{let[o,b,t]=chunkGU6TZJ4O_cjs.e(e,r,n);return chunkGXECYURS_cjs.a(o,b,t)},Sr=(e,r,n)=>{let[o,b,t]=chunkGU6TZJ4O_cjs.b(e,r,n);return chunkGXECYURS_cjs.a(o,b,t)},I=e=>{if(typeof e=="object"&&e!==null){let r=e;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let o=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(o),b:n.c*Math.sin(o),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=e;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[o,b,t]=G(n.l,n.a,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=e;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let o=n.h*Math.PI/180,[b,t,u]=G(n.l,n.c*Math.cos(o),n.c*Math.sin(o));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Rr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=fr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Sr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=yr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof e=="string"){let r=Vr.exec(e);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o*Math.cos(u),b:o*Math.sin(u),alpha:s}}if(r=Yr.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o,b,alpha:t}}if(r=Zr.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=G(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=Jr.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(chunkYISEJCI6_cjs.d[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[l,y,L]=G(n,o*Math.cos(u),o*Math.sin(u));return {l,a:y,b:L,alpha:s}}if(r=Qr.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Rr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=Wr.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=fr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=rn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=yr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=nn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Sr(n,o,b);return {l:u,a:s,b:l,alpha:t}}return null}return null},x=5e-4,Lr=(e,r,n)=>e>=-x&&e<=1+x&&r>=-x&&r<=1+x&&n>=-x&&n<=1+x,xr=(e,r,n)=>e>=0&&e<=1&&r>=0&&r<=1&&n>=0&&n<=1,zn=e=>{let r=I(e);if(r===null)return true;let[n,o,b]=chunkGXECYURS_cjs.f(r.l,r.a,r.b);return Lr(n,o,b)},Tr=.02,en=1e-4,Cr=(e,r)=>{let n=e[0]-r[0],o=e[1]-r[1],b=e[2]-r[2];return Math.sqrt(n*n+o*o+b*b)},Nr=(e,r,n,o,b,t)=>{if(e>=1)return {l:1,a:0,b:0,alpha:o};if(e<=0)return {l:0,a:0,b:0,alpha:o};let[u,s,l]=b(e,r,n);if(xr(u,s,l))return {l:e,a:r,b:n,alpha:o};let y=t(chunkYISEJCI6_cjs.a(u,0,1),chunkYISEJCI6_cjs.a(s,0,1),chunkYISEJCI6_cjs.a(l,0,1));if(Cr(y,[e,r,n])<=Tr)return {l:y[0],a:y[1],b:y[2],alpha:o};let L=Math.atan2(n,r),Pr=Math.sqrt(r*r+n*n),N=0,w=Pr,O=true,_=y;for(;w-N>en;){let T=(N+w)/2,$=T*Math.cos(L),D=T*Math.sin(L),[j,X,U]=b(e,$,D);if(O&&xr(j,X,U)){N=T;continue}let K=t(chunkYISEJCI6_cjs.a(j,0,1),chunkYISEJCI6_cjs.a(X,0,1),chunkYISEJCI6_cjs.a(U,0,1));_=K,Cr(K,[e,$,D])<=Tr?(N=T,O=false):w=T;}return {l:_[0],a:_[1],b:_[2],alpha:o}},Fn=e=>{let r=I(e);if(r===null)return null;let{l:n,a:o,b,alpha:t}=r;return Nr(n,o,b,t,chunkGXECYURS_cjs.f,chunkGXECYURS_cjs.a)},vn=(e,r)=>{let n=I(e);if(n===null)return true;let[o,b,t]=r(n.l,n.a,n.b);return Lr(o,b,t)},En=(e,r,n)=>{let o=I(e);if(o===null)return null;let{l:b,a:t,b:u,alpha:s}=o;return Nr(b,t,u,s,r,n)};var f=Math.PI/180,_r=(e,r,n)=>{let o=n*f;return chunkGXECYURS_cjs.f(e,r*Math.cos(o),r*Math.sin(o))},kr=(e,r,n,o)=>{let b=o*f;chunkGXECYURS_cjs.e(e,r,n*Math.cos(b),n*Math.sin(b));},Xn=(e,r,n)=>{let[o,b,t]=_r(e,r,n);return [chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]},Un=(e,r,n,o)=>{kr(e,r,n,o),e[0]=chunkX5FCFNQN_cjs.b(e[0]),e[1]=chunkX5FCFNQN_cjs.b(e[1]),e[2]=chunkX5FCFNQN_cjs.b(e[2]);},Kn=(e,r,n)=>{let[o,b,t]=_r(e,r,n);return [[o,b,t],[chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]]},qn=(e,r,n,o,b)=>{kr(e,n,o,b),r[0]=chunkX5FCFNQN_cjs.b(e[0]),r[1]=chunkX5FCFNQN_cjs.b(e[1]),r[2]=chunkX5FCFNQN_cjs.b(e[2]);},Hn=(e,r,n)=>[chunkX5FCFNQN_cjs.a(e),chunkX5FCFNQN_cjs.a(r),chunkX5FCFNQN_cjs.a(n)],Vn=(e,r,n,o)=>{e[0]=chunkX5FCFNQN_cjs.a(r),e[1]=chunkX5FCFNQN_cjs.a(n),e[2]=chunkX5FCFNQN_cjs.a(o);},E=(e,r,n)=>{let[o,b,t]=chunkGU6TZJ4O_cjs.j(e,r,n);return chunkGU6TZJ4O_cjs.e(o,b,t)},B=(e,r,n,o)=>{chunkGU6TZJ4O_cjs.k(e,r,n,o),chunkGU6TZJ4O_cjs.d(e,e[0],e[1],e[2]);},Yn=(e,r,n)=>{let o=n*f;return E(e,r*Math.cos(o),r*Math.sin(o))},Zn=(e,r,n,o)=>{let b=o*f;B(e,r,n*Math.cos(b),n*Math.sin(b));},on=(e,r,n)=>{let[o,b,t]=E(e,r,n);return [chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]},bn=(e,r,n,o)=>{B(e,r,n,o),e[0]=chunkX5FCFNQN_cjs.b(e[0]),e[1]=chunkX5FCFNQN_cjs.b(e[1]),e[2]=chunkX5FCFNQN_cjs.b(e[2]);},Jn=(e,r,n)=>{let o=n*f;return on(e,r*Math.cos(o),r*Math.sin(o))},Qn=(e,r,n,o)=>{let b=o*f;bn(e,r,n*Math.cos(b),n*Math.sin(b));},tn=(e,r,n)=>{let[o,b,t]=E(e,r,n);return [[o,b,t],[chunkX5FCFNQN_cjs.b(o),chunkX5FCFNQN_cjs.b(b),chunkX5FCFNQN_cjs.b(t)]]},an=(e,r,n,o,b)=>{B(e,n,o,b),r[0]=chunkX5FCFNQN_cjs.b(e[0]),r[1]=chunkX5FCFNQN_cjs.b(e[1]),r[2]=chunkX5FCFNQN_cjs.b(e[2]);},Wn=(e,r,n)=>{let o=n*f;return tn(e,r*Math.cos(o),r*Math.sin(o))},re=(e,r,n,o,b)=>{let t=b*f;an(e,r,n,o*Math.cos(t),o*Math.sin(t));};exports.A=E;exports.B=B;exports.C=Yn;exports.D=Zn;exports.E=on;exports.F=bn;exports.G=Jn;exports.H=Qn;exports.I=tn;exports.J=an;exports.K=Wn;exports.L=re;exports.a=cn;exports.b=br;exports.c=F;exports.d=pn;exports.e=dn;exports.f=hn;exports.g=gn;exports.h=xn;exports.i=hr;exports.j=v;exports.k=Tn;exports.l=Cn;exports.m=Ln;exports.n=Nn;exports.o=zn;exports.p=Fn;exports.q=vn;exports.r=En;exports.s=_r;exports.t=kr;exports.u=Xn;exports.v=Un;exports.w=Kn;exports.x=qn;exports.y=Hn;exports.z=Vn;//# sourceMappingURL=chunk-B3CQY27M.cjs.map
//# sourceMappingURL=chunk-B3CQY27M.cjs.map

Sorry, the diff of this file is too big to display

import {f as f$2,e,a as a$2}from'./chunk-J6CH5YTL.mjs';import {j,e as e$1,k,d as d$1,l as l$1,b as b$1}from'./chunk-4LKLL3IS.mjs';import {a,b,d,c}from'./chunk-FXCFKFXK.mjs';import {h,i,f as f$1,a as a$1,g,l,k as k$1,d as d$2}from'./chunk-IOXRZECH.mjs';var J=.8224619687,Q=.1775380313,W=.0331941989,rr=.9668058011,nr=.0170826307,er=.0723974407,or=.9105199286,Mr=1.2249401762805598,Gr=-0.22494017628055996,Ir=-0.04205695470968816,wr=1.042056954709688,zr=-0.019637554590334432,Fr=-0.07863604555063189,vr=1.0982736001409663,cn=(e,r,n,o)=>{e[0]=J*r+Q*n,e[1]=W*r+rr*n,e[2]=nr*r+er*n+or*o;},br=(e,r,n)=>[J*e+Q*r,W*e+rr*r,nr*e+er*r+or*n];var F=(e,r,n)=>[Mr*e+Gr*r,Ir*e+wr*r,zr*e+Fr*r+vr*n],pn=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=br(a(e/255),a(r/255),a(n/255));return {r:b(b$1),g:b(t),b:b(u),alpha:o,colorSpace:"display-p3"}};var tr=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=F(a(e),a(r),a(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:o}},dn=e=>{if(!h(e)||e.colorSpace!=="display-p3"||!i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !f$1(r)||!f$1(n)||!f$1(o)||!f$1(b)?null:tr({r:g(r),g:g(n),b:g(o),alpha:a$1(g(b),0,1)})},Er=new RegExp(`^color\\(\\s*display-p3\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),hn=e=>{if(typeof e!="string")return null;let r=Er.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),o=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return tr({r:n,g:o,b,alpha:a$1(t,0,1)})},gn=(e,r,n)=>br(...f$2(e,r,n));var ar=.6274038959,ur=.3292830384,mr=.0433130657,sr=.0690972894,lr=.9195403951,cr=.0113623156,pr=.0163914389,ir=.0880133079,dr=.8955952532,Br=1.6604910021084345,Or=-0.5876411387885495,$r=-0.07284986331988488,Dr=-0.12455047452159074,jr=1.1328998971259603,Xr=-0.008349422604369477,Ur=-0.018150763354905303,Kr=-0.10057889800800739,qr=1.1187296613629127,xn=(e,r,n,o)=>{e[0]=ar*r+ur*n+mr*o,e[1]=sr*r+lr*n+cr*o,e[2]=pr*r+ir*n+dr*o;},hr=(e,r,n)=>[ar*e+ur*r+mr*n,sr*e+lr*r+cr*n,pr*e+ir*r+dr*n];var v=(e,r,n)=>[Br*e+Or*r+$r*n,Dr*e+jr*r+Xr*n,Ur*e+Kr*r+qr*n],Tn=({r:e,g:r,b:n,alpha:o})=>{let[b,t,u]=hr(a(e/255),a(r/255),a(n/255));return {r:d(b),g:d(t),b:d(u),alpha:o,colorSpace:"rec2020"}};var gr=({r:e,g:r,b:n,alpha:o})=>{let[b$1,t,u]=v(c(e),c(r),c(n));return {r:b(b$1)*255,g:b(t)*255,b:b(u)*255,alpha:o}},Cn=e=>{if(!h(e)||e.colorSpace!=="rec2020"||!i(e,["r","g","b"]))return null;let{r,g:n,b:o,alpha:b=1}=e;return !f$1(r)||!f$1(n)||!f$1(o)||!f$1(b)?null:gr({r:g(r),g:g(n),b:g(o),alpha:a$1(g(b),0,1)})},Hr=new RegExp(`^color\\(\\s*rec2020\\s+(?<r>${k$1})(?<rp>%?)\\s+(?<g>${k$1})(?<gp>%?)\\s+(?<b>${k$1})(?<bp>%?)\\s*(?:/\\s*(?<al>${k$1})(?<alp>%?)\\s*)?\\)$`,"i"),Ln=e=>{if(typeof e!="string")return null;let r=Hr.exec(e.trim())?.groups;if(!r)return null;let n=r.rp?l(r.r)/100:l(r.r),o=r.gp?l(r.g)/100:l(r.g),b=r.bp?l(r.b)/100:l(r.b),t=r.al===void 0?1:l(r.al)/(r.alp?100:1);return gr({r:n,g:o,b,alpha:a$1(t,0,1)})},Nn=(e,r,n)=>hr(...f$2(e,r,n));var Vr=/^oklch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Yr=/^oklab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zr=/^lab\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jr=/^lch\(\s*([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qr=/^color\(\s*display-p3\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Wr=/^color\(\s*rec2020\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s+([+-]?\d*\.?\d+)(%?)\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^color\(\s*xyz-d50\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,nn=/^color\(\s*xyz-d65\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s+([+-]?\d*\.?\d+)%?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,G=(e,r,n)=>{let{x:o,y:b,z:t}=l$1({l:e,a:r,b:n,alpha:1,colorSpace:"lab"}),[u,s,l]=e$1(o,b,t);return a$2(u,s,l)},Rr=(e,r,n)=>{let[o,b,t]=F(a(e),a(r),a(n));return a$2(o,b,t)},fr=(e,r,n)=>{let[o,b,t]=v(c(e),c(r),c(n));return a$2(o,b,t)},yr=(e,r,n)=>{let[o,b,t]=e$1(e,r,n);return a$2(o,b,t)},Sr=(e,r,n)=>{let[o,b,t]=b$1(e,r,n);return a$2(o,b,t)},I=e=>{if(typeof e=="object"&&e!==null){let r=e;if("l"in r&&"a"in r&&"b"in r&&r.colorSpace!=="lab"&&!("c"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.a=="number"&&typeof n.b=="number"&&typeof n.alpha=="number")return {l:n.l,a:n.a,b:n.b,alpha:n.alpha}}if("l"in r&&"c"in r&&"h"in r&&r.colorSpace!=="lch"&&!("a"in r)&&!("r"in r)){let n=e;if(typeof n.l=="number"&&typeof n.c=="number"&&typeof n.h=="number"){let o=n.h*Math.PI/180;return {l:n.l,a:n.c*Math.cos(o),b:n.c*Math.sin(o),alpha:n.alpha}}}if(r.colorSpace==="lab"){let n=e;if(typeof n.l!="number"||typeof n.a!="number"||typeof n.b!="number")return null;let[o,b,t]=G(n.l,n.a,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="lch"){let n=e;if(typeof n.l!="number"||typeof n.c!="number"||typeof n.h!="number")return null;let o=n.h*Math.PI/180,[b,t,u]=G(n.l,n.c*Math.cos(o),n.c*Math.sin(o));return {l:b,a:t,b:u,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="display-p3"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=Rr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="rec2020"){let n=e;if(typeof n.r!="number"||typeof n.g!="number"||typeof n.b!="number")return null;let[o,b,t]=fr(n.r,n.g,n.b);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if(r.colorSpace==="xyz-d65"){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=Sr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}if("x"in r&&"y"in r&&"z"in r){let n=e;if(typeof n.x!="number"||typeof n.y!="number"||typeof n.z!="number")return null;let[o,b,t]=yr(n.x,n.y,n.z);return {l:o,a:b,b:t,alpha:typeof n.alpha=="number"?n.alpha:1}}return null}if(typeof e=="string"){let r=Vr.exec(e);if(r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o*Math.cos(u),b:o*Math.sin(u),alpha:s}}if(r=Yr.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])*.004:Number(r[3]),b=r[6]?Number(r[5])*.004:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1);return {l:n,a:o,b,alpha:t}}if(r=Zr.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.25:Number(r[3]),b=r[6]?Number(r[5])*1.25:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=G(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=Jr.exec(e),r){let n=Number(r[1]),o=r[4]?Number(r[3])*1.5:Number(r[3]),b=r[6]?.toLowerCase()??"deg",u=Number(r[5])*(d$2[b]??1)*Math.PI/180,s=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[l,y,L]=G(n,o*Math.cos(u),o*Math.sin(u));return {l,a:y,b:L,alpha:s}}if(r=Qr.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=Rr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=Wr.exec(e),r){let n=r[2]?Number(r[1])/100:Number(r[1]),o=r[4]?Number(r[3])/100:Number(r[3]),b=r[6]?Number(r[5])/100:Number(r[5]),t=r[7]===void 0?1:Number(r[7])/(r[8]?100:1),[u,s,l]=fr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=rn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=yr(n,o,b);return {l:u,a:s,b:l,alpha:t}}if(r=nn.exec(e),r){let n=Number(r[1]),o=Number(r[2]),b=Number(r[3]),t=r[4]===void 0?1:Number(r[4])/(r[5]?100:1),[u,s,l]=Sr(n,o,b);return {l:u,a:s,b:l,alpha:t}}return null}return null},x=5e-4,Lr=(e,r,n)=>e>=-x&&e<=1+x&&r>=-x&&r<=1+x&&n>=-x&&n<=1+x,xr=(e,r,n)=>e>=0&&e<=1&&r>=0&&r<=1&&n>=0&&n<=1,zn=e=>{let r=I(e);if(r===null)return true;let[n,o,b]=f$2(r.l,r.a,r.b);return Lr(n,o,b)},Tr=.02,en=1e-4,Cr=(e,r)=>{let n=e[0]-r[0],o=e[1]-r[1],b=e[2]-r[2];return Math.sqrt(n*n+o*o+b*b)},Nr=(e,r,n,o,b,t)=>{if(e>=1)return {l:1,a:0,b:0,alpha:o};if(e<=0)return {l:0,a:0,b:0,alpha:o};let[u,s,l]=b(e,r,n);if(xr(u,s,l))return {l:e,a:r,b:n,alpha:o};let y=t(a$1(u,0,1),a$1(s,0,1),a$1(l,0,1));if(Cr(y,[e,r,n])<=Tr)return {l:y[0],a:y[1],b:y[2],alpha:o};let L=Math.atan2(n,r),Pr=Math.sqrt(r*r+n*n),N=0,w=Pr,O=true,_=y;for(;w-N>en;){let T=(N+w)/2,$=T*Math.cos(L),D=T*Math.sin(L),[j,X,U]=b(e,$,D);if(O&&xr(j,X,U)){N=T;continue}let K=t(a$1(j,0,1),a$1(X,0,1),a$1(U,0,1));_=K,Cr(K,[e,$,D])<=Tr?(N=T,O=false):w=T;}return {l:_[0],a:_[1],b:_[2],alpha:o}},Fn=e=>{let r=I(e);if(r===null)return null;let{l:n,a:o,b,alpha:t}=r;return Nr(n,o,b,t,f$2,a$2)},vn=(e,r)=>{let n=I(e);if(n===null)return true;let[o,b,t]=r(n.l,n.a,n.b);return Lr(o,b,t)},En=(e,r,n)=>{let o=I(e);if(o===null)return null;let{l:b,a:t,b:u,alpha:s}=o;return Nr(b,t,u,s,r,n)};var f=Math.PI/180,_r=(e,r,n)=>{let o=n*f;return f$2(e,r*Math.cos(o),r*Math.sin(o))},kr=(e$1,r,n,o)=>{let b=o*f;e(e$1,r,n*Math.cos(b),n*Math.sin(b));},Xn=(e,r,n)=>{let[o,b$1,t]=_r(e,r,n);return [b(o),b(b$1),b(t)]},Un=(e,r,n,o)=>{kr(e,r,n,o),e[0]=b(e[0]),e[1]=b(e[1]),e[2]=b(e[2]);},Kn=(e,r,n)=>{let[o,b$1,t]=_r(e,r,n);return [[o,b$1,t],[b(o),b(b$1),b(t)]]},qn=(e,r,n,o,b$1)=>{kr(e,n,o,b$1),r[0]=b(e[0]),r[1]=b(e[1]),r[2]=b(e[2]);},Hn=(e,r,n)=>[a(e),a(r),a(n)],Vn=(e,r,n,o)=>{e[0]=a(r),e[1]=a(n),e[2]=a(o);},E=(e,r,n)=>{let[o,b,t]=j(e,r,n);return e$1(o,b,t)},B=(e,r,n,o)=>{k(e,r,n,o),d$1(e,e[0],e[1],e[2]);},Yn=(e,r,n)=>{let o=n*f;return E(e,r*Math.cos(o),r*Math.sin(o))},Zn=(e,r,n,o)=>{let b=o*f;B(e,r,n*Math.cos(b),n*Math.sin(b));},on=(e,r,n)=>{let[o,b$1,t]=E(e,r,n);return [b(o),b(b$1),b(t)]},bn=(e,r,n,o)=>{B(e,r,n,o),e[0]=b(e[0]),e[1]=b(e[1]),e[2]=b(e[2]);},Jn=(e,r,n)=>{let o=n*f;return on(e,r*Math.cos(o),r*Math.sin(o))},Qn=(e,r,n,o)=>{let b=o*f;bn(e,r,n*Math.cos(b),n*Math.sin(b));},tn=(e,r,n)=>{let[o,b$1,t]=E(e,r,n);return [[o,b$1,t],[b(o),b(b$1),b(t)]]},an=(e,r,n,o,b$1)=>{B(e,n,o,b$1),r[0]=b(e[0]),r[1]=b(e[1]),r[2]=b(e[2]);},Wn=(e,r,n)=>{let o=n*f;return tn(e,r*Math.cos(o),r*Math.sin(o))},re=(e,r,n,o,b)=>{let t=b*f;an(e,r,n,o*Math.cos(t),o*Math.sin(t));};export{E as A,B,Yn as C,Zn as D,on as E,bn as F,Jn as G,Qn as H,tn as I,an as J,Wn as K,re as L,cn as a,br as b,F as c,pn as d,dn as e,hn as f,gn as g,xn as h,hr as i,v as j,Tn as k,Cn as l,Ln as m,Nn as n,zn as o,Fn as p,vn as q,En as r,_r as s,kr as t,Xn as u,Un as v,Kn as w,qn as x,Hn as y,Vn as z};//# sourceMappingURL=chunk-DIWXRMTC.mjs.map
//# sourceMappingURL=chunk-DIWXRMTC.mjs.map

Sorry, the diff of this file is too big to display

interface RgbColor {
r: number;
g: number;
b: number;
alpha: number;
}
type RgbColorInput = Omit<RgbColor, 'alpha'> & {
alpha?: number;
};
interface HslColor {
h: number;
s: number;
l: number;
alpha: number;
}
type HslColorInput = Omit<HslColor, 'alpha'> & {
alpha?: number;
};
interface HsvColor {
h: number;
s: number;
v: number;
alpha: number;
}
type HsvColorInput = Omit<HsvColor, 'alpha'> & {
alpha?: number;
};
interface HwbColor {
h: number;
/** Whiteness [0, 100] */
w: number;
/** Blackness [0, 100] */
b: number;
alpha: number;
}
type HwbColorInput = Omit<HwbColor, 'alpha'> & {
alpha?: number;
};
/** CIE LAB (D50) */
interface LabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
readonly colorSpace: 'lab';
}
type LabColorInput = Omit<LabColor, 'alpha'> & {
alpha?: number;
};
/** CIE LCH (D50) */
interface LchColor {
l: number;
c: number;
h: number;
alpha: number;
readonly colorSpace: 'lch';
}
type LchColorInput = Omit<LchColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D50) */
interface XyzColor {
x: number;
y: number;
z: number;
alpha: number;
}
type XyzColorInput = Omit<XyzColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D65) */
interface XyzD65Color {
x: number;
y: number;
z: number;
alpha: number;
readonly colorSpace: 'xyz-d65';
}
type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & {
alpha?: number;
};
interface CmykColor {
c: number;
m: number;
y: number;
k: number;
alpha: number;
}
type CmykColorInput = Omit<CmykColor, 'alpha'> & {
alpha?: number;
};
/** Oklab — perceptually uniform, D65 */
interface OklabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
}
type OklabColorInput = Omit<OklabColor, 'alpha'> & {
alpha?: number;
};
/** Oklch — perceptually uniform, polar form of Oklab */
interface OklchColor {
l: number;
c: number;
h: number;
alpha: number;
}
type OklchColorInput = Omit<OklchColor, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Display-P3 */
interface P3Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'display-p3';
}
type P3ColorInput = Omit<P3Color, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Rec.2020 */
interface Rec2020Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'rec2020';
}
type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & {
alpha?: number;
};
type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput;
type ColorParser<T = AnyColor> = (input: T) => RgbColor | null;
type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'name';
declare const _SENTINEL: unique symbol;
declare class Colordx {
private readonly _rgb;
private readonly _valid;
constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor);
private static _make;
/**
* Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.
* Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,
* so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.
* sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.
*/
static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx;
isValid(): boolean;
toRgb(): RgbColor;
/** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */
_rawRgb(): RgbColor;
/**
* Format as a `rgb()` / `rgba()` CSS string.
* Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):
* `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`
* Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also
* switches the function name to `rgba()` when alpha < 1:
* `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`
*/
toRgbString(options?: {
legacy?: boolean;
}): string;
toHex(): string;
/** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */
toHex8(): string;
/** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */
toNumber(): number;
toHsl(precision?: number): HslColor;
toHslString(precision?: number): string;
toOklab(precision?: number): OklabColor;
toOklabString(precision?: number): string;
toOklch(precision?: number): OklchColor;
toOklchString(precision?: number): string;
brightness(): number;
isDark(): boolean;
isLight(): boolean;
alpha(): number;
alpha(value: number): Colordx;
hue(): number;
hue(value: number): Colordx;
lightness(): number;
lightness(value: number): Colordx;
chroma(): number;
chroma(value: number): Colordx;
lighten(amount?: number, options?: {
relative?: boolean;
}): Colordx;
darken(amount?: number, options?: {
relative?: boolean;
}): Colordx;
saturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
desaturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
grayscale(): Colordx;
invert(): Colordx;
rotate(amount?: number): Colordx;
isEqual(color: AnyColor): boolean;
toString(): string;
/**
* Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].
* Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.
* Hue and lightness may shift noticeably for colors far outside sRGB.
* Returns `this` when already in gamut.
*/
clampSrgb(): Colordx;
/**
* Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm
* (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.
* Useful when hue stability matters — design tokens, palettes, color pickers.
* Returns `this` when already in gamut.
*/
mapSrgb(): Colordx;
/**
* Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.
* Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.
*/
static toGamutSrgb: (input: AnyColor) => Colordx;
}
type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void;
declare const colordx: (input: AnyColor | Colordx) => Colordx;
/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */
declare const toHex8: (input: AnyColor | Colordx) => string;
declare const extend: (plugins: Plugin[]) => void;
declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T;
declare const random: () => Colordx;
export { type AnyColor as A, type XyzD65Color as B, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z };
interface RgbColor {
r: number;
g: number;
b: number;
alpha: number;
}
type RgbColorInput = Omit<RgbColor, 'alpha'> & {
alpha?: number;
};
interface HslColor {
h: number;
s: number;
l: number;
alpha: number;
}
type HslColorInput = Omit<HslColor, 'alpha'> & {
alpha?: number;
};
interface HsvColor {
h: number;
s: number;
v: number;
alpha: number;
}
type HsvColorInput = Omit<HsvColor, 'alpha'> & {
alpha?: number;
};
interface HwbColor {
h: number;
/** Whiteness [0, 100] */
w: number;
/** Blackness [0, 100] */
b: number;
alpha: number;
}
type HwbColorInput = Omit<HwbColor, 'alpha'> & {
alpha?: number;
};
/** CIE LAB (D50) */
interface LabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
readonly colorSpace: 'lab';
}
type LabColorInput = Omit<LabColor, 'alpha'> & {
alpha?: number;
};
/** CIE LCH (D50) */
interface LchColor {
l: number;
c: number;
h: number;
alpha: number;
readonly colorSpace: 'lch';
}
type LchColorInput = Omit<LchColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D50) */
interface XyzColor {
x: number;
y: number;
z: number;
alpha: number;
}
type XyzColorInput = Omit<XyzColor, 'alpha'> & {
alpha?: number;
};
/** CIE XYZ (D65) */
interface XyzD65Color {
x: number;
y: number;
z: number;
alpha: number;
readonly colorSpace: 'xyz-d65';
}
type XyzD65ColorInput = Omit<XyzD65Color, 'alpha'> & {
alpha?: number;
};
interface CmykColor {
c: number;
m: number;
y: number;
k: number;
alpha: number;
}
type CmykColorInput = Omit<CmykColor, 'alpha'> & {
alpha?: number;
};
/** Oklab — perceptually uniform, D65 */
interface OklabColor {
l: number;
/** Green–red axis */
a: number;
/** Blue–yellow axis */
b: number;
alpha: number;
}
type OklabColorInput = Omit<OklabColor, 'alpha'> & {
alpha?: number;
};
/** Oklch — perceptually uniform, polar form of Oklab */
interface OklchColor {
l: number;
c: number;
h: number;
alpha: number;
}
type OklchColorInput = Omit<OklchColor, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Display-P3 */
interface P3Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'display-p3';
}
type P3ColorInput = Omit<P3Color, 'alpha'> & {
alpha?: number;
};
/** CSS Color 4 Rec.2020 */
interface Rec2020Color {
r: number;
g: number;
b: number;
alpha: number;
readonly colorSpace: 'rec2020';
}
type Rec2020ColorInput = Omit<Rec2020Color, 'alpha'> & {
alpha?: number;
};
type AnyColor = string | RgbColorInput | HslColorInput | HsvColorInput | HwbColorInput | LabColorInput | LchColorInput | XyzColorInput | XyzD65ColorInput | CmykColorInput | OklabColorInput | OklchColorInput | P3ColorInput | Rec2020ColorInput;
type ColorParser<T = AnyColor> = (input: T) => RgbColor | null;
type ColorFormat = 'hex' | 'rgb' | 'hsl' | 'hsv' | 'hwb' | 'oklab' | 'oklch' | 'lab' | 'lch' | 'xyz' | 'xyz-d65' | 'cmyk' | 'p3' | 'rec2020' | 'name';
declare const _SENTINEL: unique symbol;
declare class Colordx {
private readonly _rgb;
private readonly _valid;
constructor(input: AnyColor | Colordx | typeof _SENTINEL, _direct?: RgbColor);
private static _make;
/**
* Construct a Colordx from OKLab values, storing unclamped gamma-encoded sRGB internally.
* Unlike new Colordx(oklabObject), this does NOT clamp channels to [0, 1] before gamma encoding,
* so wide-gamut P3/Rec2020 colors are preserved accurately for toP3() / toRec2020() output.
* sRGB output methods (toRgb, toHex, etc.) clamp to [0, 255] before returning.
*/
static _makeFromOklab({ l, a, b, alpha }: OklabColor): Colordx;
isValid(): boolean;
toRgb(): RgbColor;
/** Returns the internal unrounded RGB. Intended for plugin use where deferred rounding matters. */
_rawRgb(): RgbColor;
/**
* Format as a `rgb()` / `rgba()` CSS string.
* Default is CSS Color 4 modern syntax (space-separated, slash-delimited alpha):
* `rgb(255 0 0)` / `rgb(255 0 0 / 0.5)`
* Pass `{ legacy: true }` for CSS Color 3 comma-separated syntax, which also
* switches the function name to `rgba()` when alpha < 1:
* `rgb(255, 0, 0)` / `rgba(255, 0, 0, 0.5)`
*/
toRgbString(options?: {
legacy?: boolean;
}): string;
toHex(): string;
/** Always returns an 8-digit `#rrggbbaa`, even when alpha is 1. */
toHex8(): string;
/** Returns a 24-bit RGB integer (0x000000–0xFFFFFF). Alpha is not included. */
toNumber(): number;
toHsl(precision?: number): HslColor;
toHslString(precision?: number): string;
toOklab(precision?: number): OklabColor;
toOklabString(precision?: number): string;
toOklch(precision?: number): OklchColor;
toOklchString(precision?: number): string;
brightness(): number;
isDark(): boolean;
isLight(): boolean;
alpha(): number;
alpha(value: number): Colordx;
hue(): number;
hue(value: number): Colordx;
lightness(): number;
lightness(value: number): Colordx;
chroma(): number;
chroma(value: number): Colordx;
lighten(amount?: number, options?: {
relative?: boolean;
}): Colordx;
darken(amount?: number, options?: {
relative?: boolean;
}): Colordx;
saturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
desaturate(amount?: number, options?: {
relative?: boolean;
}): Colordx;
grayscale(): Colordx;
invert(): Colordx;
rotate(amount?: number): Colordx;
isEqual(color: AnyColor): boolean;
toString(): string;
/**
* Clips this color into the sRGB gamut by clamping out-of-range channels to [0, 255].
* Matches the naive-clip strategy browsers use when rendering out-of-gamut `oklch()` / `oklab()`.
* Hue and lightness may shift noticeably for colors far outside sRGB.
* Returns `this` when already in gamut.
*/
clampSrgb(): Colordx;
/**
* Maps this color into the sRGB gamut using the CSS Color 4 gamut mapping algorithm
* (chroma-reduction binary search). Preserves lightness and hue; sacrifices chroma.
* Useful when hue stability matters — design tokens, palettes, color pickers.
* Returns `this` when already in gamut.
*/
mapSrgb(): Colordx;
/**
* Maps an out-of-sRGB-gamut color into sRGB using the CSS Color 4 gamut mapping algorithm.
* Colors already in gamut are returned as-is. sRGB inputs (hex, rgb, hsl, etc.) are passed through.
*/
static toGamutSrgb: (input: AnyColor) => Colordx;
}
type Plugin = (ColordxClass: typeof Colordx, parsers: ColorParser[], formatParsers: [ColorParser, ColorFormat][]) => void;
declare const colordx: (input: AnyColor | Colordx) => Colordx;
/** Emit an 8-digit `#rrggbbaa` hex for any color input. Convenience over `colordx(c).toHex8()`. */
declare const toHex8: (input: AnyColor | Colordx) => string;
declare const extend: (plugins: Plugin[]) => void;
declare const nearest: <T extends AnyColor>(color: AnyColor, candidates: T[]) => T;
declare const random: () => Colordx;
export { type AnyColor as A, type XyzD65Color as B, type ColorFormat as C, type HslColor as H, type LabColor as L, type OklabColor as O, type P3Color as P, type Rec2020Color as R, type XyzColor as X, type CmykColor as a, type CmykColorInput as b, type ColorParser as c, Colordx as d, type HslColorInput as e, type HsvColor as f, type HsvColorInput as g, type HwbColor as h, type HwbColorInput as i, type LabColorInput as j, type LchColor as k, type LchColorInput as l, type OklabColorInput as m, type OklchColor as n, type OklchColorInput as o, type P3ColorInput as p, type Plugin as q, type Rec2020ColorInput as r, type RgbColor as s, type RgbColorInput as t, type XyzColorInput as u, colordx as v, extend as w, nearest as x, random as y, toHex8 as z };