saturon 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +5 -4
- package/dist/Color.d.ts +50 -47
- package/dist/Color.js +122 -229
- package/dist/converters.d.ts +35 -141
- package/dist/converters.js +8 -422
- package/dist/engine.d.ts +148 -0
- package/dist/engine.js +1900 -0
- package/dist/index.umd.js +1774 -1300
- package/dist/index.umd.min.js +143 -1
- package/dist/math.d.ts +2 -12
- package/dist/math.js +1 -11
- package/dist/tests/Color.test.d.ts +17 -0
- package/dist/tests/Color.test.js +1062 -0
- package/dist/tests/wpt.test.js +2129 -0
- package/dist/types.d.ts +62 -72
- package/dist/utils.d.ts +10 -141
- package/dist/utils.js +108 -1052
- package/package.json +10 -11
- package/dist/temp.js +0 -3
- /package/dist/{temp.d.ts → tests/wpt.test.d.ts} +0 -0
package/dist/index.umd.min.js
CHANGED
|
@@ -1 +1,143 @@
|
|
|
1
|
-
"use strict";var Saturon=(()=>{var Ae=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var et=(e,t)=>{for(var r in t)Ae(e,r,{get:t[r],enumerable:!0})},tt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Je(t))!Qe.call(e,n)&&n!==r&&Ae(e,n,{get:()=>t[n],enumerable:!(o=We(t,n))||o.enumerable});return e};var rt=e=>tt(Ae({},"__esModule",{value:!0}),e);var nt={};et(nt,{Color:()=>Y});var Oe={AccentColor:[[0,120,215],[10,132,255]],AccentColorText:[[255,255,255],[255,255,255]],ActiveText:[[255,0,0],[255,100,100]],ButtonBorder:[[169,169,169],[90,90,90]],ButtonFace:[[240,240,240],[60,60,60]],ButtonText:[[0,0,0],[255,255,255]],Canvas:[[255,255,255],[30,30,30]],CanvasText:[[0,0,0],[255,255,255]],Field:[[255,255,255],[45,45,45]],FieldText:[[0,0,0],[255,255,255]],GrayText:[[128,128,128],[169,169,169]],Highlight:[[0,120,215],[80,80,80]],HighlightText:[[255,255,255],[0,0,0]],LinkText:[[0,0,255],[0,128,255]],Mark:[[255,255,0],[255,200,0]],MarkText:[[0,0,0],[0,0,0]],SelectedItem:[[0,120,215],[0,120,215]],SelectedItemText:[[255,255,255],[255,255,255]],VisitedText:[[128,0,128],[200,120,255]]},te={theme:"light",systemColors:Oe,defaults:{fit:"clip"}};var we=new Map;function de(e,t){let r=Array.isArray(e[0])?e.length:1,o=Array.isArray(e[0])?e:[e],n=Array.isArray(t[0])?t:t.map(c=>[c]),i=n[0].length,s=n[0].map((c,f)=>n.map(d=>d[f])),a=o.map(c=>s.map(f=>c.reduce((d,l,h)=>d+l*(f[h]||0),0)));return r===1?a[0]:i===1?a.map(c=>c[0]):a}function Me(e){return e.trim().replace(/\s+/g," ").replace(/\( /g,"(").replace(/ \)/g,")").replace(/\s*,\s*/g,", ").replace(/ ,/g,",").replace(/calc\(NaN\)/g,"0").replace(/[A-Z]/g,t=>String.fromCharCode(t.charCodeAt(0)+32))}function le(e,t){let r=t,o="",n=0;if(e[r]!=="(")for(;r<e.length&&/[a-zA-Z0-9-%#]/.test(e[r]);)o+=e[r],r++;if(e[r]==="("){for(o+="(",r++,n=1;r<e.length&&n>0;){let i=e[r];i==="("?n++:i===")"&&n--,n>0&&(o+=i),r++}o+=")"}return{expression:o,end:r}}function pe(e,t,r={}){let{method:o=te.defaults.fit,precision:n}=r,{components:i}=T[t],s=Object.values(i).reduce((c,f)=>(c[f.index]=f,c),[]),a;if(o==="none")a=e;else if(o==="clip")a=e.map((c,f)=>{let d=s[f];if(!d)throw new Error(`Missing component properties for index ${f}.`);if(d.value==="hue")return(c%360+360)%360;let[l,h]=Array.isArray(d.value)?d.value:[0,100];return Math.min(h,Math.max(l,c))});else{let c=_e[o];if(!c)throw new Error(`Invalid gamut clipping method: must be ${Object.keys(_e).join(", ")} or "none".`);a=c(e,t)}return a.map((c,f)=>{let d;if(typeof n=="number"||n===null)d=n;else if(typeof n>"u")d=s[f]?.precision??3;else throw new TypeError(`Invalid precision value: ${n}.`);return d===null?c:Number(c.toFixed(d))})}function je(e,t){let r=(u,B,p={},k=!1,H=!1)=>{let w=(A,v,J)=>{let ce=parseFloat(A);if(isNaN(ce))throw new Error(`Invalid percentage value: '${A}'.`);return B==="percentage"?ce:v<0&&J>0?ce/100*(J-v)/2:ce/100*(J-v)+v},Z=A=>{let v=parseFloat(A);if(isNaN(v))throw new Error(`Invalid hue value: '${A}'.`);return A.slice(-3)==="deg"?v:A.slice(-3)==="rad"?v*(180/m):A.slice(-4)==="grad"?v*.9:A.slice(-4)==="turn"?v*360:v},G=(A,v,J)=>{let ce=E=>{let D=[];for(let g=0;g<E.length;){let I=E[g];if(/\s/.test(I)){g++;continue}if(E.slice(g,g+2)==="**"){D.push({type:"operator",value:"**"}),g+=2;continue}if(/[0-9]/.test(I)||I==="."&&/[0-9]/.test(E[g+1]||"")){let ue="";for(;g<E.length&&/[0-9.]/.test(E[g]);)ue+=E[g++];if(g<E.length&&/[eE]/.test(E[g]))for(ue+=E[g++],/[+-]/.test(E[g])&&(ue+=E[g++]);g<E.length&&/[0-9]/.test(E[g]);)ue+=E[g++];D.push({type:"number",value:parseFloat(ue)});continue}if(/[a-zA-Z_]/.test(I)){let ue="";for(;g<E.length&&/[a-zA-Z0-9_]/.test(E[g]);)ue+=E[g++];D.push({type:"identifier",value:ue});continue}if("+-*/%(),".includes(I)){D.push({type:"operator",value:I}),g++;continue}throw new Error(`Unexpected character: ${I}`)}return D},Q=E=>{let D=0,g=()=>D<E.length?E[D]:null,I=()=>{if(D>=E.length)throw new Error("Unexpected end of input");return E[D++]},ue=R=>{let ie=g();if(!ie||ie.value!==R)throw new Error(`Expected "${R}" but got "${ie?ie.value:"end of input"}`);I()},Ke=()=>{let R=g();if(!R)throw new Error("Unexpected end of input");if(R.type==="number")return I(),{type:"number",value:R.value};if(R.type==="identifier"){if(I(),g()&&g().value==="("){I();let ie=[];if(g()&&g().value!==")")for(ie.push(xe());g()&&g().value===",";)I(),ie.push(xe());return ue(")"),{type:"call",func:R.value,args:ie}}return{type:"var",name:R.value}}if(R.value==="("){I();let ie=xe();return ue(")"),ie}throw new Error(`Unexpected token: ${R.value}`)},Ce=()=>g()&&(g().value==="+"||g().value==="-")?{type:"unary",op:I().value,arg:Ce()}:Ke(),Se=()=>{let R=Ce();for(;g()&&g().value==="**";)R={type:"binary",op:I().value,left:R,right:Ce()};return R},Ne=()=>{let R=Se();for(;g()&&["*","/","%"].includes(String(g().value));)R={type:"binary",op:I().value,left:R,right:Se()};return R},xe=()=>{let R=Ne();for(;g()&&(g().value==="+"||g().value==="-");)R={type:"binary",op:I().value,left:R,right:Ne()};return R},Ue=xe();if(D<E.length)throw new Error(`Extra tokens after expression: ${E.slice(D).map(R=>R.value).join(" ")}`);return Ue},ee=(E,D)=>{switch(E.type){case"number":return E.value;case"var":{let g=D[E.name];if(g===void 0)throw new Error(`Unknown variable: ${E.name}`);if(typeof g=="function")throw new Error(`Expected variable but found function: ${E.name}`);return g}case"binary":{let g=ee(E.left,D),I=ee(E.right,D);switch(E.op){case"+":return g+I;case"-":return g-I;case"*":return g*I;case"/":return g/I;case"%":return g%I;case"**":return g**I;default:throw new Error(`Unknown binary operator: ${E.op}`)}}case"unary":{let g=ee(E.arg,D);switch(E.op){case"+":return+g;case"-":return-g;default:throw new Error(`Unknown unary operator: ${E.op}`)}}case"call":{let g=D[E.func];if(typeof g!="function")throw new Error(`Unknown function: ${E.func}`);return g(...E.args.map(I=>ee(I,D)))}default:throw new Error(`Unknown AST node type: ${E.type}`)}},q=A.slice(5,-1).trim();if(q==="infinity")return 1/0;if(q==="-infinity")return-1/0;if(q==="NaN")return NaN;q=q.replace(/(\d+(\.\d+)?)%/g,E=>{if(H===!0)throw new Error("<hue> and <percentage> values are converted to <number> in relative syntax.");let D=w(E,v,J);return D!==void 0?String(D):"0"}),q=q.replace(/(\d+(\.\d+)?)(deg|rad|grad|turn)/g,(E,D,g,I)=>{if(H===!0)throw new Error("<hue> and <percentage> values are converted to <number> in relative syntax.");return String(Z(`${parseFloat(D)}${I}`))});let Be={...p,pi:m,e:x,tau:m*2,pow:S,sqrt:N,sin:j,cos:C,tan:y,asin:_,acos:L,atan:$,atan2:K,exp:re,log:X,log10:se,log2:b,abs:M,min:O,max:P,hypot:U,round:ae,ceil:ne,floor:V,sign:me,trunc:Ee,random:be};try{let E=ce(q),D=Q(E);return ee(D,Be)}catch(E){throw new Error(`Evaluation error: ${E}`)}},z=()=>{if(/^-?(?:\d+|\d*\.\d+)(?:deg|rad|grad|turn)$/.test(u))return Z(u);if(/^-?(?:\d+|\d*\.\d+)$/.test(u))return parseFloat(u);let[A,v]=[0,360];if(u.slice(0,5)==="calc(")return G(u,A,v);throw new Error(`Invalid hue value: '${u}'. Must be a number, or a number with a unit (deg, rad, grad, turn).`)},oe=()=>{if(/^-?(?:\d+|\d*\.\d+)$/.test(u)){if(k&&h===!0)throw new Error("The legacy color syntax does not allow numbers for <percentage> components.");return parseFloat(u)}let[A,v]=[0,100];if(u[u.length-1]==="%")return w(u,A,v);if(u.slice(0,5)==="calc(")return G(u,A,v);throw new Error(`Invalid percentage value: '${u}'. Must be a percentage or a number.`)},W=()=>{if(/^-?(?:\d+|\d*\.\d+)$/.test(u))return parseFloat(u);let[A,v]=B;if(u[u.length-1]==="%")return w(u,A,v);if(u.slice(0,5)==="calc(")return G(u,A,v);throw new Error(`Invalid number value: '${u}'. Must be a number${H===!1?" or a percentage":""}.`)};if(u==="none")return NaN;if(u in p)return p[u];if(B==="hue")return z();if(B==="percentage")return oe();if(Array.isArray(B))return W();throw new Error(`Unable to parse component token: ${u}`)},o=u=>{let{fn:B,space:p,fromOrigin:k,c1:H,c2:w,c3:Z,alpha:G,commaSeparated:z}=u,{components:oe,supportsLegacy:W}=t;if(oe.alpha={index:3,value:[0,1],precision:3},z&&W!==!0)throw new Error(`<${B}()> does not support comma-separated syntax.`);let A=Object.entries(oe).sort((v,J)=>v[1].index-J[1].index);if(k){let v;if(B==="color")v=p;else if(B in T)v=B;else for(let Q in T)if(T[Q].alphaVariant===B){v=Q;break}let J=Y.from(k).in(v).toObject({fit:"none",precision:null});return[H,w,Z,G].map((Q,ee)=>{let[,q]=A[ee];return r(Q,q.value,J,z,!0)}).slice(0,4)}else{let v=[],J=[],ce=[H,w,Z,G];for(let Q=0;Q<A.length;Q++){let[,ee]=A[Q],q=ce[Q];if(z&&q==="none")throw new Error(`${B}() cannot use "none" in comma-separated syntax.`);if(ee.index!==3&&ee.value!=="hue"&&ee.value!=="percentage"&&q.slice(0,5)!=="calc("&&J.push(q.trim()[q.length-1]==="%"),q){let Be=r(q,ee.value,{},z);v[ee.index]=Be}}if(z&&J.length>1){let Q=J.every(Boolean),ee=J.every(q=>!q);if(!Q&&!ee)throw new Error(`${B}()'s <number> components must all be numbers or all percentages.`)}return v.slice(0,4)}},n=u=>{let B=(A,v="/")=>{if(u[A]!==void 0){if(u[A]===v)return{value:u[A+1],hasAlpha:!0};throw new Error("Invalid alpha separator")}return{value:"1",hasAlpha:!1}},p,k,H,w,Z,G,z,oe=!1,W;if(u[0]==="color")if(p="color",u[1]==="from"){k=u[3],H=u[2],w=u[4],Z=u[5],G=u[6];let{value:A,hasAlpha:v}=B(7);W=v?9:7,z=A}else{k=u[1],H=null,w=u[2],Z=u[3],G=u[4];let{value:A,hasAlpha:v}=B(5);W=v?7:5,z=A}else if(p=u[0],k=null,u[1]==="from"){H=u[2],w=u[3],Z=u[4],G=u[5];let{value:A,hasAlpha:v}=B(6);W=v?8:6,z=A}else if(H=null,w=u[1],u[2]===","&&u[4]===","){oe=!0,Z=u[3],G=u[5];let{value:A,hasAlpha:v}=B(6,",");if(W=v?8:6,v&&u[6]!==",")throw new Error("Comma optional syntax requires no commas at all.");z=A}else{Z=u[2],G=u[3];let{value:A,hasAlpha:v}=B(4);W=v?6:4,z=A}if(u.length!==W)throw new Error(`Invalid number of tokens for ${p}(): expected ${W} but got ${u.length}.`);return{fn:p,space:k,fromOrigin:H,c1:w,c2:Z,c3:G,alpha:z,commaSeparated:oe}},i=u=>{let B=[],p=0,k="";for(;p<u.length&&u[p]!=="(";)k+=u[p],p++;k=k.trim(),B.push(k);let H=u.indexOf("(")+1,w=u.slice(H,-1).trim();if(p=0,w.slice(0,5)==="from "){for(B.push("from"),p+=5;p<w.length&&w[p]===" ";)p++;let Z=p;for(;p<w.length&&w[p]!==" ";)p++;let G=w.slice(Z,p);if(G.includes("(")){let{expression:z,end:oe}=le(w,Z);B.push(z),p=oe}else B.push(G);for(;p<w.length&&w[p]===" ";)p++}if(B[0]==="color"&&p<w.length){let Z=p;for(;p<w.length&&w[p]!==" ";)p++;for(B.push(w.slice(Z,p));p<w.length&&w[p]===" ";)p++}for(;p<w.length;){let Z=w[p];if(Z===",")B.push(","),p++,w[p]===" "&&p++;else if(Z==="/")B.push("/"),p++,w[p]===" "&&p++;else if(Z===" ")p++;else if(/[a-zA-Z#]/.test(Z)){let G=p,z="";for(;p<w.length&&/[a-zA-Z0-9-%#]/.test(w[p]);)z+=w[p],p++;if(p<w.length&&w[p]==="("){let{expression:oe,end:W}=le(w,G);B.push(oe),p=W}else B.push(z)}else if(/[\d.-]/.test(Z)){let G="";for(;p<w.length&&/[\d.eE+-]/.test(w[p]);)G+=w[p],p++;if(p<w.length&&w[p]==="%")G+="%",p++,B.push(G);else if(p<w.length&&/[a-zA-Z]/.test(w[p])){let z="";for(;p<w.length&&/[a-zA-Z]/.test(w[p]);)z+=w[p],p++;B.push(G+z)}else B.push(G)}else throw new Error(`Unexpected character: ${Z}`)}return B},s=(u,B)=>{let p="color(from ";if(u.slice(0,11)!==p||u[u.length-1]!==")")return!1;let k=u.slice(p.length,-1).trim(),{expression:H,end:w}=le(k,0);if(!H)return!1;let G=k.slice(w).trim().split(/\s+/);return G.length<1?!1:G[0]===B},{components:a,bridge:c,fromBridge:f,toBridge:d,alphaVariant:l,supportsLegacy:h}=t,{PI:m,E:x,pow:S,sqrt:N,sin:j,cos:C,tan:y,asin:_,acos:L,atan:$,atan2:K,exp:re,log:X,log10:se,log2:b,abs:M,min:O,max:P,hypot:U,round:ae,ceil:ne,floor:V,sign:me,trunc:Ee,random:be}=Math;return{isValid:u=>{let{alphaVariant:B=e}=t;if(e in ge){let p=u.slice(0,`color(${e} `.length)===`color(${e} `,k=u.slice(0,10)==="color(from"&&s(u,e);return(p||k)&&u[u.length-1]===")"}return(u.slice(0,`${e}(`.length)===`${e}(`||u.slice(0,`${B}(`.length)===`${B}(`)&&u[u.length-1]===")"},bridge:c,toBridge:u=>[...d(u.slice(0,3)),u[3]??1],parse:u=>{let B=i(u),p=n(B),k=o(p);return[...k.slice(0,3),k[3]??1]},fromBridge:u=>[...f(u),u[3]??1],format:([u,B,p,k=1],H={})=>{let{legacy:w=!1,fit:Z=te.defaults.fit,precision:G,units:z=!1}=H,oe=pe([u,B,p],e,{method:Z,precision:G}),W=Number(O(P(k,0),1).toFixed(3)).toString(),A=oe.map((v,J)=>{if(v=isNaN(v)?0:v,(z||w)&&a){let ce=Object.values(a).find(Q=>Q.index===J);if(ce?.value==="percentage")return`${v}%`;if(ce?.value==="hue"&&z)return`${v}deg`}return v.toString()});return e in ge?`color(${e} ${A.join(" ")}${k!==1?` / ${W}`:""})`:w&&h?k===1?`${e}(${A.join(", ")})`:`${l||e}(${A.join(", ")}, ${W})`:`${e}(${A.join(" ")}${k!==1?` / ${W}`:""})`}}}function fe(e,t){let{fromLinear:r=s=>s,toLinear:o=s=>s,toBridgeMatrix:n,fromBridgeMatrix:i}=t;return{supportsLegacy:!1,targetGamut:t.targetGamut===null?null:e,components:Object.fromEntries(t.components.map((s,a)=>[s,{index:a,value:[0,1],precision:5}])),bridge:t.bridge,toBridge:s=>de(n,s.map(a=>o(a))),fromBridge:s=>de(i,s).map(a=>r(a))}}var ye=1e-5,F={D50_to_D65:[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]],D65_to_d50:[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]],SRGB_to_XYZD65:[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],XYZD65_to_SRGB:[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],P3_to_XYZD65:[[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0/1,32229/714400,5220557/5000800]],XYZD65_to_P3:[[446124/178915,-333277/357830,-72051/178915],[-14852/17905,63121/35810,423/17905],[11844/330415,-50337/660830,316169/330415]],REC2020_to_XYZD65:[[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,472592308/697040785,8267143/139408157],[0/1,19567812/697040785,295819943/278816314]],XYZD65_to_REC2020:[[30757411/17917100,-6372589/17917100,-4539589/17917100],[-19765991/29648200,47925759/29648200,467509/29648200],[792561/44930125,-1921689/44930125,42328811/44930125]],A98_to_XYZD65:[[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],ProPhoto_to_XYZD50:[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],XYZD50_to_ProPhoto:[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]],XYZD65_to_A98:[[1829569/896150,-506331/896150,-308931/896150],[-851781/878810,1648619/878810,36519/878810],[16779/1248040,-147721/1248040,1266979/1248040]],LMS_to_XYZD65:[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],XYZD65_to_LMS:[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],LMS_to_OKLAB:[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],OKLAB_to_LMS:[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]]},Ge={linear:e=>e,"ease-in":e=>e*e,"ease-out":e=>e*(2-e),"ease-in-out":e=>e<.5?2*e*e:-1+(4-2*e)*e,"ease-in-cubic":e=>e*e*e,"ease-out-cubic":e=>--e*e*e+1,"ease-in-out-cubic":e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2},_e={"chroma-reduction":(e,t)=>{let r=new Y(t,e),{targetGamut:o}=T[t];if(o===null||(o===void 0&&(o="srgb"),r.inGamut(o,1e-5)))return e;let[n,,i]=r.in("oklch").toArray({fit:"none",precision:null}),s=Math.min(1,Math.max(0,n)),a=0,c=1,f=1e-6,d=[];for(;c-a>f;){let h=(a+c)/2,m=new Y("oklch",[s,h,i]);if(m.inGamut(o,1e-5))a=h;else{let x=pe(m.toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"}),S=new Y(t,x);if(m.deltaEOK(S)<2)return d=x,d;c=h}}return d=new Y("oklch",[s,a,i]).in(t).toArray({fit:"none",precision:null}),d},"css-gamut-map":(e,t)=>{let{targetGamut:r}=T[t];if(r===null)return e;r===void 0&&(r="srgb");let o=new Y(t,e),[n,i,s]=o.in("oklch").toArray({fit:"none",precision:null});if(n>=1)return new Y("oklab",[1,0,0]).in(t).toArray({fit:"none",precision:null});if(n<=0)return new Y("oklab",[0,0,0]).in(t).toArray({fit:"none",precision:null});if(o.inGamut(r,1e-5))return e;let a=.02,c=1e-4,f=new Y("oklch",[n,i,s]),d=pe(f.in(t).toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"}),l=new Y(t,d);if(f.deltaEOK(l)<a)return d;let m=0,x=i,S=!0;for(;x-m>c;){let N=(m+x)/2,j=new Y("oklch",[n,N,s]);if(S&&j.inGamut(r,1e-5))m=N;else{let C=pe(j.in(t).toArray({fit:"none",precision:null}).slice(0,3),t,{method:"clip"});d=C;let y=new Y(t,C),_=j.deltaEOK(y);if(_<a){if(a-_<c)return d;S=!1,m=N}else x=N}}return d}};function Ie(e){let t=e.map(r=>{let o=r/255,n=o<0?-1:1,i=Math.abs(o);return i<=.04045?o/12.92:n*((i+.055)/1.055)**2.4});return de(F.SRGB_to_XYZD65,t)}function Te(e){return de(F.XYZD65_to_SRGB,e).map(o=>{let n=o<0?-1:1,i=Math.abs(o);return i>.0031308?n*(1.055*i**(1/2.4)-.055):12.92*o}).map(o=>o*255)}function Le([e,t,r]){t/=100,r/=100;let o=n=>{let i=(n+e/30)%12,s=t*Math.min(r,1-r);return r-s*Math.max(-1,Math.min(i-3,9-i,1))};return[o(0)*255,o(8)*255,o(4)*255]}function Ze(e){let[t,r,o]=e.map(m=>m/255),n=Math.max(t,r,o),i=Math.min(t,r,o),s=(n+i)/2,a=n-i,c=NaN,f=0;a>0&&(f=a/(1-Math.abs(2*s-1)),c=n===t?(r-o)/a+(r<o?6:0):n===r?(o-t)/a+2:(t-r)/a+4,c=c*60%360);let d=f*100,l=s*100;return[l<=ye||100-l<=ye||d<=ye?NaN:c,d,l]}function ze([e,t,r]){if(t/=100,r/=100,t+r>=1){let n=t/(t+r)*255;return[n,n,n]}return Le([e,100,50]).map(n=>n/255).map(n=>(n*(1-t-r)+t)*255)}function De(e){let[t,r,o]=e.map(c=>c/255),n=Math.max(t,r,o),i=Math.min(t,r,o),s=n-i,a=NaN;return s>ye&&(a=n===t?(r-o)/s+(r<o?6:0):n===r?(o-t)/s+2:(t-r)/s+4,a=a*60%360),[a,i*100,(1-n)*100]}function Re([e,t,r]){let o=[.9642956764295677,1,.8251046025104602],n=24389/27,i=216/24389,s=(e+16)/116,a=t/500+s,c=s-r/200;return[a**3>i?a**3:(116*a-16)/n,e>n*i?s**3:e/n,c**3>i?c**3:(116*c-16)/n].map((d,l)=>d*o[l])}function Xe(e){let t=[.9642956764295677,1,.8251046025104602],r=24389/27,o=216/24389,n=e.map((c,f)=>c/t[f]),[i,s,a]=n.map(c=>c>o?Math.cbrt(c):(r*c+16)/116);return[116*s-16,500*(i-s),200*(s-a)]}function Ye([e,t,r]){return[e,t*Math.cos(r*Math.PI/180),t*Math.sin(r*Math.PI/180)]}function Pe([e,t,r]){let o=Math.hypot(t,r),n=Math.atan2(r,t)*180/Math.PI;return n<0&&(n+=360),[e,o,o<=ye?NaN:n]}function He(e){let{LMS_to_XYZD65:t,OKLAB_to_LMS:r}=F,o=de(r,e);return de(t,o.map(n=>n**3))}function qe(e){let{XYZD65_to_LMS:t,LMS_to_OKLAB:r}=F,o=de(t,e);return de(r,o.map(Math.cbrt))}function Fe([e,t,r]){return[e,t*Math.cos(r*Math.PI/180),t*Math.sin(r*Math.PI/180)]}function Ve([e,t,r]){let o=Math.hypot(t,r),n=Math.atan2(r,t)*180/Math.PI;return n<0&&(n+=360),[e,o,o<=ye?NaN:n]}var ve={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},ge={srgb:fe("srgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r<=.04045?t*(r/12.92):t*Math.pow((r+.055)/1.055,2.4)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r>.0031308?t*(1.055*Math.pow(r,1/2.4)-.055):t*(12.92*r)},toBridgeMatrix:F.SRGB_to_XYZD65,fromBridgeMatrix:F.XYZD65_to_SRGB}),"srgb-linear":fe("srgb-linear",{components:["r","g","b"],bridge:"xyz-d65",toBridgeMatrix:F.SRGB_to_XYZD65,fromBridgeMatrix:F.XYZD65_to_SRGB}),"display-p3":fe("display-p3",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r<=.04045?t*(r/12.92):t*Math.pow((r+.055)/1.055,2.4)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return r>.0031308?t*(1.055*Math.pow(r,1/2.4)-.055):t*(12.92*r)},toBridgeMatrix:F.P3_to_XYZD65,fromBridgeMatrix:F.XYZD65_to_P3}),rec2020:fe("rec2020",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=1.09929682680944,r=.018053968510807,o=e<0?-1:1,n=Math.abs(e);return n<r*4.5?o*(n/4.5):o*Math.pow((n+t-1)/t,1/.45)},fromLinear:e=>{let t=1.09929682680944,r=.018053968510807,o=e<0?-1:1,n=Math.abs(e);return n>r?o*(t*Math.pow(n,.45)-(t-1)):o*(4.5*n)},toBridgeMatrix:F.REC2020_to_XYZD65,fromBridgeMatrix:F.XYZD65_to_REC2020}),"a98-rgb":fe("a98-rgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,563/256)},fromLinear:e=>{let t=e<0?-1:1,r=Math.abs(e);return t*Math.pow(r,256/563)},toBridgeMatrix:F.A98_to_XYZD65,fromBridgeMatrix:F.XYZD65_to_A98}),"prophoto-rgb":fe("prophoto-rgb",{components:["r","g","b"],bridge:"xyz-d50",toLinear:e=>{let r=e<0?-1:1,o=Math.abs(e);return o<=.03125?r*(o/16):r*Math.pow(o,1.8)},fromLinear:e=>{let t=.001953125,r=e<0?-1:1,o=Math.abs(e);return o>=t?r*Math.pow(o,1/1.8):r*(16*o)},toBridgeMatrix:F.ProPhoto_to_XYZD50,fromBridgeMatrix:F.XYZD50_to_ProPhoto}),"xyz-d65":fe("xyz-d65",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]}),"xyz-d50":fe("xyz-d50",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:F.D50_to_D65,fromBridgeMatrix:F.D65_to_d50}),xyz:fe("xyz",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]})},T={rgb:{supportsLegacy:!0,alphaVariant:"rgba",components:{r:{index:0,value:[0,255],precision:0},g:{index:1,value:[0,255],precision:0},b:{index:2,value:[0,255],precision:0}},bridge:"xyz-d65",toBridge:Ie,fromBridge:Te},hsl:{supportsLegacy:!0,alphaVariant:"hsla",components:{h:{index:0,value:"hue",precision:0},s:{index:1,value:"percentage",precision:0},l:{index:2,value:"percentage",precision:0}},bridge:"rgb",toBridge:Le,fromBridge:Ze},hwb:{components:{h:{index:0,value:"hue",precision:0},w:{index:1,value:"percentage",precision:0},b:{index:2,value:"percentage",precision:0}},bridge:"rgb",toBridge:ze,fromBridge:De},lab:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},a:{index:1,value:[-125,125],precision:5},b:{index:2,value:[-125,125],precision:5}},bridge:"xyz-d50",toBridge:Re,fromBridge:Xe},lch:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},c:{index:1,value:[0,150],precision:5},h:{index:2,value:"hue",precision:5}},bridge:"lab",toBridge:Ye,fromBridge:Pe},oklab:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},a:{index:1,value:[-.4,.4],precision:5},b:{index:2,value:[-.4,.4],precision:5}},bridge:"xyz-d65",toBridge:He,fromBridge:qe},oklch:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},c:{index:1,value:[0,.4],precision:5},h:{index:2,value:"hue",precision:5}},bridge:"oklab",toBridge:Fe,fromBridge:Ve},...ge},$e=Object.fromEntries(Object.entries(T).map(([e,t])=>[e,je(e,t)])),ke={"hex-color":{isValid:e=>e[0]==="#",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=e.slice(1);if(![3,4,6,8].includes(t.length))throw new Error("Invalid hex color length.");for(let a of t)if(!/^[0-9a-fA-F]$/.test(a))throw new Error("Invalid hex color character.");let r=a=>parseInt(a.length===1?a+a:a,16),[o,n,i,s=255]=t.length<=4?t.split("").map(r):[t.slice(0,2),t.slice(2,4),t.slice(4,6),t.slice(6,8)].map(a=>parseInt(a||"ff",16));return[o,n,i,s/255]},fromBridge:e=>e,format:([e,t,r,o=1])=>{let n=s=>s.toString(16).padStart(2,"0");return`#${[e,t,r].map(s=>n(Math.round(Math.max(0,Math.min(255,s))))).join("")}${o<1?n(Math.round(o*255)):""}`}},...$e,"named-color":{isValid:e=>Object.keys(ve).some(t=>t===e),bridge:"rgb",toBridge:e=>e,parse:e=>{let t=ve[e];if(!t)throw new Error(`Invalid named-color: ${e}.`);return[...t,1]},fromBridge:e=>e,format:e=>{let[t,r,o]=e.map((n,i)=>i<3?Math.round(Math.min(255,Math.max(0,n))):n);for(let[n,[i,s,a]]of Object.entries(ve))if(t===i&&r===s&&o===a)return n}},"color-mix":{isValid:e=>e.slice(0,10)==="color-mix("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=y=>{let _=y.trim(),L,$=_,K=$.match(/^(\d+)%\s+/);if(K){let b=parseInt(K[1],10);L=Math.min(1,Math.max(0,b/100)),$=$.slice(K[0].length).trim()}let re="",X="";if(/^[a-z]/i.test($)){let{expression:b,end:M}=le($,0);if(b)re=b,X=$.slice(M).trim();else{let O=$.match(/^([^\s]+)(.*)$/);re=O?O[1]:$,X=O?O[2].trim():""}}else{let b=$.match(/^([^\s]+)(.*)$/);re=b?b[1]:$,X=b?b[2].trim():""}if(L===void 0){let b=X.match(/^(-?(?:\d+\.?\d*|\.\d+))%/);if(b){if(L=parseInt(b[1],10)/100,X=X.slice(b[0].length).trim(),L<0)throw new Error("Percentages less than 0 are not valid.");if(L>1)throw new Error("Percentages greater than 100 are not valid.")}else if(X.slice(0,5)==="calc("){let{expression:M,end:O}=le(X,0);if(!M)throw new Error("Malformed calc() weight expression.");X=X.slice(O).trim()}}if(X.length>0)throw new Error(`Unexpected extra tokens after color: '${X}'.`);return{color:Y.from(re),weight:L}},r=(y,_)=>{if(y===void 0&&typeof _=="number")y=1-_;else if(typeof y=="number"&&_===void 0)_=1-y;else if(y===void 0&&_===void 0)y=_=.5;else if(y=y,_=_,y+_<=0)throw new Error("Sum of percengates cannot be 0%.");let L=y+_,$;return L>1?(y/=L,_/=L):(y/=L,_/=L,$=L),{amount:_,alphaMultiplier:$}},o="color-mix",{expression:n}=le(e,o.length);if(!n)throw new Error("Malformed color-mix expression.");let i=n.slice(1,-1).trim(),s=[],a=0,c="";for(;a<i.length;){let y=i[a];if(y===","){s.push(c.trim()),c="",a++;continue}if(y==="("||/[a-zA-Z]/.test(y)){let{expression:_,end:L}=le(i,a);if(_){c+=_,a=L;continue}}c+=y,a++}if(s.push(c.trim()),s.length!==3)throw new Error("color-mix must have three comma-separated parts.");let d=s[0].match(/^in\s+([a-z0-9-]+)(?:\s+(shorter|longer|increasing|decreasing)\s+hue)?$/);if(!d)throw new Error("Invalid model and hue format.");let l=d[1],h=d[2];if(l==="rgb")throw new Error('RGB model is not allowed in color-mix(). Use "srgb" instead.');if(h){let y=T[l].components;if(!y)throw new Error(`Unknown color model: ${l}.`);if(!Object.values(y).some(L=>L.value==="hue"))throw new Error(`Hue interpolation not supported in ${l} space.`)}else h="shorter";let{color:m,weight:x}=t(s[1]),{color:S,weight:N}=t(s[2]),{amount:j,alphaMultiplier:C=1}=r(x,N);return m.with({alpha:y=>isNaN(y)?y:y*C},!1).in(l).mix(S.with({alpha:y=>isNaN(y)?y:y*C},!1),{amount:j,hue:h}).in("rgb").coords}},transparent:{isValid:e=>e==="transparent",bridge:"rgb",toBridge:e=>e,parse:e=>[NaN,NaN,NaN,0]}},he={...ke,currentColor:{isValid:e=>e==="currentcolor",bridge:"rgb",toBridge:e=>e,parse:e=>[0,0,0,1]},"system-color":{isValid:e=>Object.keys(te.systemColors).some(t=>t.toLowerCase()===e),bridge:"rgb",toBridge:e=>e,parse:e=>{let{systemColors:t}=te,r=Object.keys(t).find(n=>n.toLowerCase()===e);return[...t[r][te.theme==="light"?0:1],1]}},"contrast-color":{isValid:e=>e.slice(0,15)==="contrast-color("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t=e.slice(15,-1),[,r]=Y.from(t).in("xyz-d65").coords;return r>.5?[0,0,0,1]:[255,255,255,1]}},"device-cmyk":{isValid:e=>e.slice(0,12)==="device-cmyk("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t="device-cmyk",r=e.indexOf(t);if(r===-1)throw new Error("Invalid device-cmyk syntax");let{expression:o}=le(e,r+t.length);if(!o)throw new Error("Malformed device-cmyk expression");let n=o.slice(1,-1).trim(),i=[],s=0;for(;s<n.length;){let C=n[s];if(C===" "){s++;continue}if(C==="("||/[a-zA-Z-]/.test(C)){let{expression:y,end:_}=le(n,s);if(y){i.push(y),s=_;continue}}if(/[\d.+-]/.test(C)){let y="";for(;s<n.length&&/[\d.eE+-]/.test(n[s]);)y+=n[s],s++;if(s<n.length&&n[s]==="%")y+="%",s++;else if(s<n.length&&/[a-zA-Z]/.test(n[s]))for(;s<n.length&&/[a-zA-Z]/.test(n[s]);)y+=n[s],s++;i.push(y);continue}if(C===","||C==="/"){i.push(C),s++;continue}throw new Error(`Unexpected character: ${C}`)}let a=C=>C[C.length-1]==="%"?parseFloat(C)/100:parseFloat(C);if(i.length>=2&&i[1]===","){let C=i.filter(y=>y!==",");if(C.length===4||C.length===5){let[y,_,L,$,K=1]=C.map(a),re=1-Math.min(1,y*(1-$)+$),X=1-Math.min(1,_*(1-$)+$),se=1-Math.min(1,L*(1-$)+$);return[re*255,X*255,se*255,K]}throw new Error("Invalid number of components for comma-separated device-cmyk")}let c=0,f=[];for(;c<i.length&&f.length<4&&i[c]!=="/"&&i[c]!==",";)f.push(i[c]),c++;if(f.length!==4)throw new Error("Invalid number of components for space-separated device-cmyk");let[d,l,h,m]=f.map(a),x=1;if(c<i.length&&i[c]==="/"){if(c++,c>=i.length)throw new Error("Missing alpha value");x=a(i[c]),c++}if(c<i.length&&i[c]===","){c++;let C=i.slice(c).join(" ");return Y.from(C).in("rgb").coords}let S=1-Math.min(1,d*(1-m)+m),N=1-Math.min(1,l*(1-m)+m),j=1-Math.min(1,h*(1-m)+m);return[S*255,N*255,j*255,x]},fromBridge:e=>e,format:([e,t,r,o=1],n={})=>{let{legacy:i=!1,precision:s=3,fit:a=te.defaults.fit}=n,[c,f,d]=pe([e,t,r],"rgb",{method:a}),l=c/255,h=f/255,m=d/255,x=1-Math.max(l,h,m),S=$=>Number(s===null?$:$.toFixed(s)).toString(),N=S(x===1?0:(1-l-x)/(1-x)),j=S(x===1?0:(1-h-x)/(1-x)),C=S(x===1?0:(1-m-x)/(1-x)),y=S(x),_=Number(o.toFixed(3)).toString();if(i)return`device-cmyk(${N}, ${j}, ${C}, ${y}${o<1?`, ${_}`:""})`;let L=$e.rgb.format?.([c,f,d,o],n);return`device-cmyk(${N} ${j} ${C} ${y}${o<1?` / ${_}`:""}, ${L})`}},"light-dark":{isValid:e=>e.slice(0,11)==="light-dark("&&e[e.length-1]===")",bridge:"rgb",toBridge:e=>e,parse:e=>{let t="light-dark",r=e.indexOf(t);if(r===-1)throw new Error("Not a <light-dark()> expression");let{expression:o}=le(e,r+t.length);if(!o)throw new Error("Malformed <light-dark()> expression");let n=o.slice(1,-1).trim(),i=[],s="",a=0;for(;a<n.length;){let l=n[a];if(l===","){i.push(s.trim()),s="",a++;continue}if(l==="("||/[a-zA-Z]/.test(l)){let{expression:h,end:m}=le(n,a);if(h){s+=h,a=m;continue}}s+=l,a++}if(i.push(s.trim()),i.length!==2)throw new Error("Invalid light-dark format");let[c,f]=i,{theme:d}=te;return Y.from(d==="light"?c:f).coords}}};var Y=class e{model;coords;constructor(t,r=[0,0,0,0]){if(!(t in T))throw new Error(`Unsupported color model: '${t}'`);if([3,4].includes(r.length)===!1)throw new Error("Coordinates array must have 3 or 4 elements.");let o=r.slice();o.length===3&&o.push(1),this.model=t,this.coords=o}static from(t){let r=Me(t);for(let o in he){let n=o,{parse:i,bridge:s,toBridge:a,isValid:c}=he[n];if(!c(r))continue;let f=i(r),d=n in T?f:a(f),l=n in T?n:s;return new e(l,d)}throw new Error(`Unsupported or invalid color format: '${t}'.`)}static type(t,r=!1){let o=Me(t);for(let n in he){let i=n,{isValid:s,bridge:a,parse:c,toBridge:f}=he[i];if(s(o)){if(!r)return i;try{let d=c(o),l=i in T?d:f(d),h=n in T?n:a;return typeof new e(h,l)=="object"?i:void 0}catch{return}}}}static isValid(t,r){try{if(r){let o=r?.trim().toLowerCase(),n=Me(t),{isValid:i,bridge:s,parse:a,toBridge:c}=he[o];if(!i(n))return!1;let f=a(n),d=o in T?f:c(f),l=o in T?o:s;return!!new e(l,d)}return!!e.from(t)}catch{return!1}}static random(t={}){let r=Object.keys(T),o=t.model??r[Math.floor(Math.random()*r.length)],{components:n}=T[o],i=new Set([...Object.keys(n),"alpha"]);for(let a of["limits","bias","base","deviation"]){let c=t[a];if(c){for(let f of Object.keys(c))if(!i.has(f))throw new Error(`Invalid component "${f}" for model "${o}". Valid components: ${[...i].join(", ")}`)}}let s=[];for(let[a,c]of Object.entries(n)){let f=t.base?.[a],d=t.deviation?.[a],l;if(f!=null&&d!=null){let h=Math.random()||1e-9,m=Math.random()||1e-9;l=f+Math.sqrt(-2*Math.log(h))*Math.cos(2*Math.PI*m)*d}else{let[h,m]=c.value==="hue"?[0,360]:c.value==="percentage"?[0,100]:c.value,x=t.limits?.[a];if(x){let[j,C]=x;h=Math.max(h,j),m=Math.min(m,C)}let S=Math.random(),N=t.bias?.[a];N&&(S=N(S)),l=h+S*(m-h)}if(c.value==="hue")l=(l%360+360)%360;else if(c.value==="percentage")l=Math.min(100,Math.max(0,l));else if(Array.isArray(c.value)){let[h,m]=c.value;l=Math.min(m,Math.max(h,l))}else throw new Error(`Invalid component value definition for "${a}".`);s[c.index]=l}return new e(o,s)}to(t,r={}){let o=t.toLowerCase(),{legacy:n=!1,fit:i=te.defaults.fit,precision:s,units:a=!1}=r,c=he[o];if(!c)throw new Error(`Unsupported color type: '${o}'.`);let{fromBridge:f,bridge:d,format:l}=c;if(!f||!l)throw new Error(`Invalid output type: '${o}'.`);let h=m=>l(m,{legacy:n,fit:i,precision:s,units:a});return o===this.model?h(this.coords):o in T?h(this.in(o).toArray({fit:"none",precision:null})):h(f(this.in(d).toArray({fit:"none",precision:null})))}in(t){let r=this.model,o=t.trim().toLowerCase();if(o===r)return new e(o,[...this.coords]);let n=we.get("graph"),i=we.get("paths");if(!n){n={};for(let[f,d]of Object.entries(T)){let{bridge:l}=d;n[f]=[...n[f]||[],l],n[l]=[...n[l]||[],f]}we.set("graph",n)}i||(i=new Map,we.set("paths",i));let s=`${r}-${o}`;if(!i.has(s)){let f=[r],d={[r]:null};for(let h=0;h<f.length;h++){let m=f[h];if(m===o)break;for(let x of n[m]||[])x in d||(d[x]=m,f.push(x))}let l=[];for(let h=o;h;h=d[h])l.push(h);if(l.reverse(),!l.length||l[0]!==r)throw new Error(`Cannot convert from ${r} to ${o}. No path found.`);i.set(s,l)}let a=[...this.coords.map(f=>isNaN(f)?0:f)],c=i.get(s);for(let f=0;f<c.length-1;f++){let d=c[f],l=c[f+1],h=T[d],m=T[l];if(h.toBridge&&h.bridge===l)a=h.toBridge(a);else if(m.fromBridge&&m.bridge===d)a=m.fromBridge(a);else throw new Error(`No conversion found between ${d} and ${l}.`)}return new e(o,[...a.slice(0,3),this.coords[3]??1])}toString(t={}){let{format:r}=he[this.model],{legacy:o=!1,fit:n=te.defaults.fit,precision:i,units:s=!1}=t;return r?.(this.coords,{legacy:o,fit:n,precision:i,units:s})}toObject(t={}){let r=this.toArray(t),{components:o}=T[this.model];if(!o)throw new Error(`Model ${this.model} does not have defined components.`);let n={...o,alpha:{index:3,value:[0,1],precision:3}},i={};for(let[s,{index:a}]of Object.entries(n))i[s]=r[a];return i}toArray(t={}){let{fit:r=te.defaults.fit,precision:o}=t,{model:n,coords:i}=this,{components:s}=T[n];if(!s)throw new Error(`Model ${n} does not have defined components.`);let a={...s,alpha:{index:3,value:[0,1],precision:3}},c=(l,h)=>{let m=Object.values(a)[h]?.value,[x,S]=Array.isArray(m)?m:m==="hue"?[0,360]:[0,100];return Number.isNaN(l)?0:l===1/0?S:l===-1/0?x:typeof l=="number"?l:0},f=i.slice(0,3).map(c);return[...pe(f,n,{method:r,precision:o}),i[3]]}with(t,r=!0){let o=l=>Array.isArray(l)?l:l==="hue"?[0,360]:[0,100],n=(l,h)=>{if(r===!1)return l;let[m,x]=o(h);return Number.isNaN(l)?0:l===1/0?x:l===-1/0?m:l},{model:i}=this,s=this.coords.slice(),a={...T[i].components,alpha:{index:3,value:[0,1],precision:3}},c=Object.keys(a),f=typeof t=="function"?t(Object.fromEntries(c.map(l=>{let h=a[l];return[l,n(s[h.index],h.value)]}))):t;if(Array.isArray(f)){let l=s.map((h,m)=>{let x=f[m];if(typeof x!="number")return h;let S=Object.values(a).find(N=>N.index===m);return n(x,S.value)});return new e(i,[...l.slice(0,3),s[3]??1])}let d=[...s];for(let l of c){if(!(l in f))continue;let{index:h,value:m}=a[l],x=f[l],S=n(s[h],m),N=typeof x=="function"?n(x(S),m):typeof x=="number"?n(x,m):s[h];d[h]=N}return new e(i,[...d.slice(0,3),d[3]??s[3]])}mix(t,r={}){let{model:o}=this,n=this.coords.slice(),i=(typeof t=="string"?e.from(t):t).in(o).coords.slice(),{components:s}=T[o];if(!s)throw new Error(`Model ${o} does not have defined components.`);let a={...s,alpha:{index:3,value:[0,1],precision:3}},c=b=>Array.isArray(b)?b:b==="hue"?[0,360]:[0,100],f=(b,M,O)=>{let[P,U]=c(O),ae=me=>me===1/0?U:me===-1/0?P:me;b=ae(b),M=ae(M);let ne=Number.isNaN(b),V=Number.isNaN(M);return ne&&V?{a:0,b:0}:ne?{a:M,b:M}:V?{a:b,b}:{a:b,b:M,ok:!0}},d=a.h?.index??-1;for(let b in a){let{index:M,value:O}=a[b];if(M>3)continue;let P=f(n[M],i[M],O);if(P.ok){let[U,ae]=c(O),ne=V=>V===1/0?ae:V===-1/0?U:V;n[M]=ne(n[M]),i[M]=ne(i[M])}else n[M]=P.a,i[M]=P.b}let{hue:l="shorter",amount:h=.5,easing:m="linear",gamma:x=1}=r,N=(typeof m=="function"?m:Ge[m])(Math.min(1,Math.max(0,h))),j=Math.pow(N,1/x),C=b=>(b%360+360)%360,y=(b,M)=>{let O=C(M-b);return O>180?O-360:O},_=(b,M)=>y(b,M)>=0?y(b,M)-360:y(b,M)+360,L=(b,M,O,P)=>{switch(P){case"shorter":return C(b+O*y(b,M));case"longer":return C(b+O*_(b,M));case"increasing":return C(b*(1-O)+(M<b?M+360:M)*O);case"decreasing":return C(b*(1-O)+(M>b?M-360:M)*O)}throw new Error(`Invalid hue interpolation: ${P}`)};if(j===0)return new e(o,[...n]);if(j===1)return new e(o,[...i]);let $=n[3],K=i[3],re=n.slice(0,3),X=i.slice(0,3);if($<1||K<1){let b=re.map((P,U)=>{let ae=X[U];return U===d?L(P,ae,j,l):P*$*(1-j)+ae*K*j}),M=$*(1-j)+K*j,O=M>0?b.map((P,U)=>U===d?P:P/M):re.map((P,U)=>U===d?b[U]:0);return new e(o,[...O,M])}let se=re.map((b,M)=>M===d?L(b,X[M],j,l):b+(X[M]-b)*j);return new e(o,[...se,1])}within(t,r=te.defaults.fit){let o=t.trim().toLowerCase();if(!(o in ge))throw new Error(`Unsupported color gamut: '${o}'.`);let n=this.in(o).toArray({fit:r,precision:null});return new e(o,n).in(this.model)}fit(t={}){let{fit:r=te.defaults.fit,precision:o}=t,n=this.toArray({fit:r,precision:o});return new e(this.model,n)}contrast(t){let r=typeof t=="string"?e.from(t):t,[,o]=this.in("xyz-d65").toArray({fit:"none",precision:null}),[,n]=r.in("xyz-d65").toArray({fit:"none",precision:null});return(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}deltaEOK(t){let r={fit:"none",precision:null},[o,n,i]=this.in("oklab").toArray(r),[s,a,c]=(typeof t=="string"?e.from(t):t).in("oklab").toArray(r),f=o-s,d=n-a,l=i-c;return Math.sqrt(f**2+d**2+l**2)*100}deltaE76(t){let r={fit:"none",precision:null},[o,n,i]=this.in("lab").toArray(r),[s,a,c]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),f=o-s,d=n-a,l=i-c;return Math.hypot(f,d,l)}deltaE94(t){let r={fit:"none",precision:null},[o,n,i]=this.in("lab").toArray(r),[s,a,c]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),f=o-s,d=n-a,l=i-c,h=Math.sqrt(n*n+i*i),m=Math.sqrt(a*a+c*c),x=h-m,S=Math.sqrt(Math.max(0,d*d+l*l-x*x)),N=1,j=1,C=1,y=.045,_=.015,L=1+y*h,$=1+_*h;return Math.sqrt((f/N)**2+(x/(j*L))**2+(S/(C*$))**2)}deltaE2000(t){let r={fit:"none",precision:null},[o,n,i]=this.in("lab").toArray(r),[s,a,c]=(typeof t=="string"?e.from(t):t).in("lab").toArray(r),f=Math.PI,d=f/180,l=180/f,h=Math.sqrt(n**2+i**2),m=Math.sqrt(a**2+c**2),x=(h+m)/2,S=Math.pow(25,7),N=Math.pow(x,7),j=.5*(1-Math.sqrt(N/(N+S))),C=(1+j)*n,y=(1+j)*a,_=Math.sqrt(C**2+i**2),L=Math.sqrt(y**2+c**2),$=Math.atan2(i,C),K=Math.atan2(c,y);$<0&&($+=2*f),K<0&&(K+=2*f),$*=l,K*=l;let re=s-o,X=L-_,se=K-$,b=Math.abs(se),M=0;_*L!==0&&(b<=180?M=se:se>180?M=se-360:M=se+360);let O=2*Math.sqrt(_*L)*Math.sin(M*d/2),P=(o+s)/2,U=(_+L)/2,ae=Math.pow(U,7),ne=$+K,V=0;_===0&&L===0?V=ne:b<=180?V=ne/2:ne<360?V=(ne+360)/2:V=(ne-360)/2;let me=(P-50)**2,Ee=1+.015*me/Math.sqrt(20+me),be=1+.045*U,u=1;u-=.17*Math.cos((V-30)*d),u+=.24*Math.cos(2*V*d),u+=.32*Math.cos((3*V+6)*d),u-=.2*Math.cos((4*V-63)*d);let B=1+.015*U*u,p=30*Math.exp(-1*((V-275)/25)**2),k=2*Math.sqrt(ae/(ae+S)),H=-1*Math.sin(2*p*d)*k,w=(re/Ee)**2;return w+=(X/be)**2,w+=(O/B)**2,w+=H*(X/be)*(O/B),Math.sqrt(w)}equals(t,r=1e-5){let o=typeof t=="string"?e.from(t):t,n=this.toArray({fit:"none",precision:null}),i=o.toArray({fit:"none",precision:null});if(o.model===this.model)return n.every((c,f)=>Math.abs(c-i[f])<=r);let s=this.in("xyz-d65").toArray({fit:"none",precision:null}),a=o.in("xyz-d65").toArray({fit:"none",precision:null});return s.every((c,f)=>Math.abs(c-a[f])<=r)}inGamut(t,r=1e-5){let o=t.trim().toLowerCase();if(!(o in ge))throw new Error(`Unsupported color gamut: '${o}'.`);let{components:n,targetGamut:i}=T[o];if(!i)return!0;let s=this.in(o).toArray({fit:"none",precision:null});return Object.values(n).every(({index:a,value:c})=>{let f=s[a],[d,l]=Array.isArray(c)?c:c==="hue"?[0,360]:[0,100];return f>=d-r&&f<=l+r})}};return rt(nt);})();
|
|
1
|
+
"use strict";var Saturon=(()=>{var ne=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var We=(o,e)=>{for(var n in e)ne(o,n,{get:e[n],enumerable:!0})},Je=(o,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ve(e))!Ke.call(o,r)&&r!==n&&ne(o,r,{get:()=>e[r],enumerable:!(t=Ue(e,r))||t.enumerable});return o};var Qe=o=>Je(ne({},"__esModule",{value:!0}),o);var Tt={};We(Tt,{Color:()=>M});var q={AccentColor:[[0,120,215],[10,132,255]],AccentColorText:[[255,255,255],[255,255,255]],ActiveText:[[255,0,0],[255,100,100]],ButtonBorder:[[169,169,169],[90,90,90]],ButtonFace:[[240,240,240],[60,60,60]],ButtonText:[[0,0,0],[255,255,255]],Canvas:[[255,255,255],[30,30,30]],CanvasText:[[0,0,0],[255,255,255]],Field:[[255,255,255],[45,45,45]],FieldText:[[0,0,0],[255,255,255]],GrayText:[[128,128,128],[169,169,169]],Highlight:[[0,120,215],[80,80,80]],HighlightText:[[255,255,255],[0,0,0]],LinkText:[[0,0,255],[0,128,255]],Mark:[[255,255,0],[255,200,0]],MarkText:[[0,0,0],[0,0,0]],SelectedItem:[[0,120,215],[0,120,215]],SelectedItemText:[[255,255,255],[255,255,255]],VisitedText:[[128,0,128],[200,120,255]]},N={theme:"light",systemColors:q,defaults:{fit:"clip"}};var X=new Map;function R(o,e){let n=Array.isArray(o[0])?o.length:1,t=Array.isArray(o[0])?o:[o],r=Array.isArray(e[0])?e:e.map(i=>[i]),l=r[0].length,a=r[0].map((i,c)=>r.map(h=>h[c])),s=t.map(i=>a.map(c=>i.reduce((h,u,d)=>h+u*(c[d]||0),0)));return n===1?s[0]:l===1?s.map(i=>i[0]):s}function S(o,e){let[n,t]=Array.isArray(e)?e:e==="hue"?[0,360]:[0,100];return Number.isNaN(o)?0:o===1/0?t:o===-1/0?n:typeof o=="number"?o:0}function O(o,e,n={}){let{method:t=N.defaults.fit,precision:r}=n,{components:l}=E[e],a=Object.values(l).reduce((i,c)=>(i[c.index]=c,i),[]),s;if(t==="none")s=o;else if(t==="clip")s=o.map((i,c)=>{let h=a[c];if(!h)throw new Error(`Missing component properties for index ${c}.`);if(h.value==="hue")return(i%360+360)%360;let[u,d]=Array.isArray(h.value)?h.value:[0,100];return Math.min(d,Math.max(u,i))});else{let i=oe[t];if(!i)throw new Error(`Invalid gamut clipping method: must be ${Object.keys(oe).join(", ")} or "none".`);s=i(o,e)}return s.map((i,c)=>{let h;if(typeof r=="number"||r===null)h=r;else if(typeof r>"u")h=a[c]?.precision??3;else throw new TypeError(`Invalid precision value: ${r}.`);return h===null?i:Number(i.toFixed(h))})}function I(o,e){let{fromLinear:n=a=>a,toLinear:t=a=>a,toBridgeMatrix:r,fromBridgeMatrix:l}=e;return{supportsLegacy:!1,targetGamut:e.targetGamut===null?null:o,components:{...Object.fromEntries(e.components.map((a,s)=>[a,{index:s,value:[0,1],precision:5}])),alpha:{index:3,value:[0,1],precision:3}},bridge:e.bridge,toBridge:a=>R(r,a.map(s=>t(s))),fromBridge:a=>R(l,a).map(s=>n(s))}}function xe(o,e){let n=((e-o)%360+360)%360;return n>180?n-360:n}function et(o,e){let n=xe(o,e);return n>=0?n-360:n+360}function be(o,e,n,t){if(Number.isNaN(o)||Number.isNaN(e))return NaN;switch(t){case"shorter":return((o+n*xe(o,e))%360+360)%360;case"longer":return((o+n*et(o,e))%360+360)%360;case"increasing":return((o*(1-n)+(e<o?e+360:e)*n)%360+360)%360;case"decreasing":return((o*(1-n)+(e>o?e-360:e)*n)%360+360)%360}throw new Error(`Invalid hue interpolation: ${t}`)}function ve(o,e,n,t="oklab",r="shorter"){let l=o.in(t).coords.slice(),a=e.in(t).coords.slice(),{components:s}=E[t];if(!s)throw new Error(`Model ${t} does not have defined components.`);let i=m=>Array.isArray(m)?m:m==="hue"?[0,360]:[0,100],c=(m,y,b)=>{let[v,x]=i(b),C=w=>w===1/0?x:w===-1/0?v:w;m=C(m),y=C(y);let k=Number.isNaN(m),$=Number.isNaN(y);return k&&$?{a:NaN,b:NaN}:k?{a:y,b:y}:$?{a:m,b:m}:{a:m,b:y,ok:!0}},h=s.h?.index??-1;for(let m in s){let{index:y,value:b}=s[m];if(y>3)continue;let v=c(l[y],a[y],b);if(v.ok){let[x,C]=i(b),k=$=>$===1/0?C:$===-1/0?x:$;l[y]=k(l[y]),a[y]=k(a[y])}else l[y]=v.a,a[y]=v.b}if(n=Math.min(1,Math.max(0,n)),n===0)return new M(t,[...l]);if(n===1)return new M(t,[...a]);let u=l[3]??1,d=a[3]??1,p=l.slice(0,3),g=a.slice(0,3);if(u<1||d<1){let m=p.map((v,x)=>{let C=g[x];return x===h?be(v,C,n,r):v*u*(1-n)+C*d*n}),y=u*(1-n)+d*n,b=y>0?m.map((v,x)=>x===h?v:v/y):p.map((v,x)=>x===h?m[x]:0);return new M(t,[...b,y])}let f=p.map((m,y)=>y===h?be(m,g[y],n,r):m+(g[y]-m)*n);return new M(t,[...f,1])}var T=1e-5,L={D50_to_D65:[[.955473421488075,-.02309845494876471,.06325924320057072],[-.0283697093338637,1.0099953980813041,.021041441191917323],[.012314014864481998,-.020507649298898964,1.330365926242124]],D65_to_d50:[[1.0479297925449969,.022946870601609652,-.05019226628920524],[.02962780877005599,.9904344267538799,-.017073799063418826],[-.009243040646204504,.015055191490298152,.7518742814281371]],SRGB_to_XYZD65:[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],XYZD65_to_SRGB:[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],P3_to_XYZD65:[[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0/1,32229/714400,5220557/5000800]],XYZD65_to_P3:[[446124/178915,-333277/357830,-72051/178915],[-14852/17905,63121/35810,423/17905],[11844/330415,-50337/660830,316169/330415]],REC2020_to_XYZD65:[[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,472592308/697040785,8267143/139408157],[0/1,19567812/697040785,295819943/278816314]],XYZD65_to_REC2020:[[30757411/17917100,-6372589/17917100,-4539589/17917100],[-19765991/29648200,47925759/29648200,467509/29648200],[792561/44930125,-1921689/44930125,42328811/44930125]],A98_to_XYZD65:[[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],ProPhoto_to_XYZD50:[[.7977666449006423,.13518129740053308,.0313477341283922],[.2880748288194013,.711835234241873,8993693872564e-17],[0,0,.8251046025104602]],XYZD50_to_ProPhoto:[[1.3457868816471583,-.25557208737979464,-.05110186497554526],[-.5446307051249019,1.5082477428451468,.02052744743642139],[0,0,1.2119675456389452]],XYZD65_to_A98:[[1829569/896150,-506331/896150,-308931/896150],[-851781/878810,1648619/878810,36519/878810],[16779/1248040,-147721/1248040,1266979/1248040]],LMS_to_XYZD65:[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],XYZD65_to_LMS:[[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],LMS_to_OKLAB:[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],OKLAB_to_LMS:[[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]]},oe={"chroma-reduction":(o,e)=>{let n=new M(e,o),{targetGamut:t}=E[e];if(t===null||(t===void 0&&(t="srgb"),n.inGamut(t,1e-5)))return o;let[r,,l]=n.in("oklch").toArray({fit:"none",precision:null}),a=Math.min(1,Math.max(0,r)),s=0,i=1,c=1e-6,h;for(;i-s>c;){let d=(s+i)/2,p=new M("oklch",[a,d,l]);if(p.inGamut(t,1e-5))s=d;else{let g=O(p.toArray({fit:"none",precision:null}).slice(0,3),e,{method:"clip"}),f=new M(e,g);if(p.deltaEOK(f)<2)return h=g,h;i=d}}return h=new M("oklch",[a,s,l]).in(e).toArray({fit:"none",precision:null}),h},"css-gamut-map":(o,e)=>{let{targetGamut:n}=E[e];if(n===null)return o;n===void 0&&(n="srgb");let t=new M(e,o),[r,l,a]=t.in("oklch").toArray({fit:"none",precision:null});if(r>=1)return new M("oklab",[1,0,0]).in(e).toArray({fit:"none",precision:null});if(r<=0)return new M("oklab",[0,0,0]).in(e).toArray({fit:"none",precision:null});if(t.inGamut(n,1e-5))return o;let s=.02,i=1e-4,c=new M("oklch",[r,l,a]),h=O(c.in(e).toArray({fit:"none",precision:null}).slice(0,3),e,{method:"clip"}),u=new M(e,h);if(c.deltaEOK(u)<s)return h;let p=0,g=l,f=!0;for(;g-p>i;){let m=(p+g)/2,y=new M("oklch",[r,m,a]);if(f&&y.inGamut(n,1e-5))p=m;else{let b=O(y.in(e).toArray({fit:"none",precision:null}).slice(0,3),e,{method:"clip"});h=b;let v=new M(e,b),x=y.deltaEOK(v);if(x<s){if(s-x<i)return h;f=!1,p=m}else g=m}}return h}};function we(o){let e=o.map(n=>{let t=n/255,r=t<0?-1:1,l=Math.abs(t);return l<=.04045?t/12.92:r*((l+.055)/1.055)**2.4});return R(L.SRGB_to_XYZD65,e)}function Me(o){return R(L.XYZD65_to_SRGB,o).map(t=>{let r=t<0?-1:1,l=Math.abs(t);return l>.0031308?r*(1.055*l**(1/2.4)-.055):12.92*t}).map(t=>t*255)}function re([o,e,n]){e/=100,n/=100;let t=r=>{let l=(r+o/30)%12,a=e*Math.min(n,1-n);return n-a*Math.max(-1,Math.min(l-3,9-l,1))};return[t(0)*255,t(8)*255,t(4)*255]}function ke(o){let[e,n,t]=o.map(p=>p/255),r=Math.max(e,n,t),l=Math.min(e,n,t),a=(r+l)/2,s=r-l,i=NaN,c=0;s>0&&(c=s/(1-Math.abs(2*a-1)),i=r===e?(n-t)/s+(n<t?6:0):r===n?(t-e)/s+2:(e-n)/s+4,i=i*60%360);let h=c*100,u=a*100;return[u<=T||100-u<=T||h<=T?NaN:i,h,u]}function Ee([o,e,n]){if(e/=100,n/=100,e+n>=1){let r=e/(e+n)*255;return[r,r,r]}return re([o,100,50]).map(r=>r/255).map(r=>(r*(1-e-n)+e)*255)}function Ae(o){let[e,n,t]=o.map(i=>i/255),r=Math.max(e,n,t),l=Math.min(e,n,t),a=r-l,s=NaN;return a>T&&(s=r===e?(n-t)/a+(n<t?6:0):r===n?(t-e)/a+2:(e-n)/a+4,s=s*60%360),[s,l*100,(1-r)*100]}function Ce([o,e,n]){let t=[.9642956764295677,1,.8251046025104602],r=24389/27,l=216/24389,a=(o+16)/116,s=e/500+a,i=a-n/200;return[s**3>l?s**3:(116*s-16)/r,o>r*l?a**3:o/r,i**3>l?i**3:(116*i-16)/r].map((h,u)=>h*t[u])}function _e(o){let e=[.9642956764295677,1,.8251046025104602],n=24389/27,t=216/24389,r=o.map((i,c)=>i/e[c]),[l,a,s]=r.map(i=>i>t?Math.cbrt(i):(n*i+16)/116);return[116*a-16,500*(l-a),200*(a-s)]}function $e([o,e,n]){return[o,e*Math.cos(n*Math.PI/180),e*Math.sin(n*Math.PI/180)]}function Le([o,e,n]){let t=Math.hypot(e,n),r=Math.atan2(n,e)*180/Math.PI;return r<0&&(r+=360),[o,t,t<=T?NaN:r]}function Be(o){let{LMS_to_XYZD65:e,OKLAB_to_LMS:n}=L,t=R(n,o);return R(e,t.map(r=>r**3))}function Ne(o){let{XYZD65_to_LMS:e,LMS_to_OKLAB:n}=L,t=R(e,o);return R(n,t.map(Math.cbrt))}function Se([o,e,n]){return[o,e*Math.cos(n*Math.PI/180),e*Math.sin(n*Math.PI/180)]}function Ie([o,e,n]){let t=Math.hypot(e,n),r=Math.atan2(n,e)*180/Math.PI;return r<0&&(r+=360),[o,t,t<=T?NaN:r]}var J={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},Z={srgb:I("srgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:o=>{let e=o<0?-1:1,n=Math.abs(o);return n<=.04045?e*(n/12.92):e*Math.pow((n+.055)/1.055,2.4)},fromLinear:o=>{let e=o<0?-1:1,n=Math.abs(o);return n>.0031308?e*(1.055*Math.pow(n,1/2.4)-.055):e*(12.92*n)},toBridgeMatrix:L.SRGB_to_XYZD65,fromBridgeMatrix:L.XYZD65_to_SRGB}),"srgb-linear":I("srgb-linear",{components:["r","g","b"],bridge:"xyz-d65",toBridgeMatrix:L.SRGB_to_XYZD65,fromBridgeMatrix:L.XYZD65_to_SRGB}),"display-p3":I("display-p3",{components:["r","g","b"],bridge:"xyz-d65",toLinear:o=>{let e=o<0?-1:1,n=Math.abs(o);return n<=.04045?e*(n/12.92):e*Math.pow((n+.055)/1.055,2.4)},fromLinear:o=>{let e=o<0?-1:1,n=Math.abs(o);return n>.0031308?e*(1.055*Math.pow(n,1/2.4)-.055):e*(12.92*n)},toBridgeMatrix:L.P3_to_XYZD65,fromBridgeMatrix:L.XYZD65_to_P3}),rec2020:I("rec2020",{components:["r","g","b"],bridge:"xyz-d65",toLinear:o=>{let e=1.09929682680944,n=.018053968510807,t=o<0?-1:1,r=Math.abs(o);return r<n*4.5?t*(r/4.5):t*Math.pow((r+e-1)/e,1/.45)},fromLinear:o=>{let e=1.09929682680944,n=.018053968510807,t=o<0?-1:1,r=Math.abs(o);return r>n?t*(e*Math.pow(r,.45)-(e-1)):t*(4.5*r)},toBridgeMatrix:L.REC2020_to_XYZD65,fromBridgeMatrix:L.XYZD65_to_REC2020}),"a98-rgb":I("a98-rgb",{components:["r","g","b"],bridge:"xyz-d65",toLinear:o=>{let e=o<0?-1:1,n=Math.abs(o);return e*Math.pow(n,563/256)},fromLinear:o=>{let e=o<0?-1:1,n=Math.abs(o);return e*Math.pow(n,256/563)},toBridgeMatrix:L.A98_to_XYZD65,fromBridgeMatrix:L.XYZD65_to_A98}),"prophoto-rgb":I("prophoto-rgb",{components:["r","g","b"],bridge:"xyz-d50",toLinear:o=>{let n=o<0?-1:1,t=Math.abs(o);return t<=.03125?n*(t/16):n*Math.pow(t,1.8)},fromLinear:o=>{let e=.001953125,n=o<0?-1:1,t=Math.abs(o);return t>=e?n*Math.pow(t,1/1.8):n*(16*t)},toBridgeMatrix:L.ProPhoto_to_XYZD50,fromBridgeMatrix:L.XYZD50_to_ProPhoto}),"xyz-d65":I("xyz-d65",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]}),"xyz-d50":I("xyz-d50",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:L.D50_to_D65,fromBridgeMatrix:L.D65_to_d50}),xyz:I("xyz",{targetGamut:null,components:["x","y","z"],bridge:"xyz-d65",toBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]],fromBridgeMatrix:[[1,0,0],[0,1,0],[0,0,1]]})},E={rgb:{supportsLegacy:!0,alphaVariant:"rgba",components:{r:{index:0,value:[0,255],precision:0},g:{index:1,value:[0,255],precision:0},b:{index:2,value:[0,255],precision:0},alpha:{index:3,value:[0,1],precision:3}},bridge:"xyz-d65",toBridge:we,fromBridge:Me},hsl:{supportsLegacy:!0,alphaVariant:"hsla",components:{h:{index:0,value:"hue",precision:0},s:{index:1,value:"percentage",precision:0},l:{index:2,value:"percentage",precision:0},alpha:{index:3,value:[0,1],precision:3}},bridge:"rgb",toBridge:re,fromBridge:ke},hwb:{components:{h:{index:0,value:"hue",precision:0},w:{index:1,value:"percentage",precision:0},b:{index:2,value:"percentage",precision:0},alpha:{index:3,value:[0,1],precision:3}},bridge:"rgb",toBridge:Ee,fromBridge:Ae},lab:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},a:{index:1,value:[-125,125],precision:5},b:{index:2,value:[-125,125],precision:5},alpha:{index:3,value:[0,1],precision:3}},bridge:"xyz-d50",toBridge:Ce,fromBridge:_e},lch:{targetGamut:null,components:{l:{index:0,value:"percentage",precision:5},c:{index:1,value:[0,150],precision:5},h:{index:2,value:"hue",precision:5},alpha:{index:3,value:[0,1],precision:3}},bridge:"lab",toBridge:$e,fromBridge:Le},oklab:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},a:{index:1,value:[-.4,.4],precision:5},b:{index:2,value:[-.4,.4],precision:5},alpha:{index:3,value:[0,1],precision:3}},bridge:"xyz-d65",toBridge:Be,fromBridge:Ne},oklch:{targetGamut:null,components:{l:{index:0,value:[0,1],precision:5},c:{index:1,value:[0,.4],precision:5},h:{index:2,value:"hue",precision:5},alpha:{index:3,value:[0,1],precision:3}},bridge:"oklab",toBridge:Se,fromBridge:Ie},...Z};var tt=`
|
|
2
|
+
/* ==========================================================================
|
|
3
|
+
Core Color Types
|
|
4
|
+
========================================================================== */
|
|
5
|
+
<color> = <color-base> | currentColor | <system-color> | <contrast-color()> | <device-cmyk()> | <light-dark-color>
|
|
6
|
+
|
|
7
|
+
<color-base> = <hex-color> | <color-function> | <named-color> | <color-mix()> | transparent
|
|
8
|
+
|
|
9
|
+
<color-function> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <lab()> | <lch()> | <oklab()> | <oklch()> | <alpha()> | <color()> | <custom-color-function>
|
|
10
|
+
|
|
11
|
+
/* ==========================================================================
|
|
12
|
+
RGB & RGBA Syntax
|
|
13
|
+
========================================================================== */
|
|
14
|
+
<rgb()> = [ <legacy-rgb-syntax> | <modern-rgb-syntax> | <relative-rgb-syntax> ]
|
|
15
|
+
<rgba()> = [ <legacy-rgba-syntax> | <modern-rgba-syntax> | <relative-rgba-syntax> ]
|
|
16
|
+
|
|
17
|
+
<legacy-rgb-syntax> = rgb( <percentage>#{3} [ , <alpha-value> ]? ) | rgb( <number>#{3} [ , <alpha-value> ]? )
|
|
18
|
+
<legacy-rgba-syntax> = rgba( <percentage>#{3} [ , <alpha-value> ]? ) | rgba( <number>#{3} [ , <alpha-value> ]? )
|
|
19
|
+
|
|
20
|
+
<modern-rgb-syntax> = rgb( <rgb-absolute-component>{3} [ / <alpha-absolute-value> ]? )
|
|
21
|
+
<modern-rgba-syntax> = rgba( <rgb-absolute-component>{3} [ / <alpha-absolute-value> ]? )
|
|
22
|
+
<rgb-absolute-component> = <number> | <percentage> | none
|
|
23
|
+
<alpha-absolute-value> = <alpha-value> | none
|
|
24
|
+
|
|
25
|
+
<relative-rgb-syntax> = rgb( from <color> <rgb-relative-component>{3} [ / <rgb-relative-alpha> ]? )
|
|
26
|
+
<relative-rgba-syntax> = rgba( from <color> <rgb-relative-component>{3} [ / <rgb-relative-alpha> ]? )
|
|
27
|
+
|
|
28
|
+
/* ==========================================================================
|
|
29
|
+
HSL & HSLA Syntax
|
|
30
|
+
========================================================================== */
|
|
31
|
+
<hsl()> = [ <legacy-hsl-syntax> | <modern-hsl-syntax> | <relative-hsl-syntax> ]
|
|
32
|
+
<hsla()> = [ <legacy-hsla-syntax> | <modern-hsla-syntax> | <relative-hsla-syntax> ]
|
|
33
|
+
|
|
34
|
+
<legacy-hsl-syntax> = hsl( <hue> , <percentage> , <percentage> [ , <alpha-value> ]? )
|
|
35
|
+
<legacy-hsla-syntax> = hsla( <hue> , <percentage> , <percentage> [ , <alpha-value> ]? )
|
|
36
|
+
|
|
37
|
+
<modern-hsl-syntax> = hsl( [ <hue> | none ] [ <percentage> | <number> | none ]{2} [ / <alpha-absolute-value> ]? )
|
|
38
|
+
<modern-hsla-syntax> = hsla( [ <hue> | none ] [ <percentage> | <number> | none ]{2} [ / <alpha-absolute-value> ]? )
|
|
39
|
+
|
|
40
|
+
<relative-hsl-syntax> = hsl( from <color> <hsl-relative-hue> <hsl-relative-component>{2} [ / <hsl-relative-alpha> ]? )
|
|
41
|
+
<relative-hsla-syntax> = hsla( from <color> <hsl-relative-hue> <hsl-relative-component>{2} [ / <hsl-relative-alpha> ]? )
|
|
42
|
+
<hsl-relative-hue> = <hue> | none | h | s | l | alpha
|
|
43
|
+
<hsl-relative-component> = <percentage> | <number> | none | h | s | l | alpha
|
|
44
|
+
<hsl-relative-alpha> = <alpha-value> | none | h | s | l | alpha
|
|
45
|
+
|
|
46
|
+
/* ==========================================================================
|
|
47
|
+
HWB Syntax
|
|
48
|
+
========================================================================== */
|
|
49
|
+
<hwb()> = [ <absolute-hwb-syntax> | <relative-hwb-syntax> ]
|
|
50
|
+
<absolute-hwb-syntax> = hwb( [ <hue> | none ] [ <percentage> | <number> | none ]{2} [ / <alpha-absolute-value> ]? )
|
|
51
|
+
<relative-hwb-syntax> = hwb( from <color> <hwb-relative-hue> <hwb-relative-component>{2} [ / <hwb-relative-alpha> ]? )
|
|
52
|
+
<hwb-relative-hue> = <hue> | none | h | w | b | alpha
|
|
53
|
+
<hwb-relative-component> = <percentage> | <number> | none | h | w | b | alpha
|
|
54
|
+
<hwb-relative-alpha> = <alpha-value> | none | h | w | b | alpha
|
|
55
|
+
|
|
56
|
+
/* ==========================================================================
|
|
57
|
+
LAB & LCH Syntax
|
|
58
|
+
========================================================================== */
|
|
59
|
+
<lab()> = [ <absolute-lab-syntax> | <relative-lab-syntax> ]
|
|
60
|
+
<absolute-lab-syntax> = lab( [ <percentage> | <number> | none ]{3} [ / <alpha-absolute-value> ]? )
|
|
61
|
+
<relative-lab-syntax> = lab( from <color> <lab-relative-component>{3} [ / <lab-relative-alpha> ]? )
|
|
62
|
+
<lab-relative-component> = <percentage> | <number> | none | l | a | b | alpha
|
|
63
|
+
<lab-relative-alpha> = <alpha-value> | none | l | a | b | alpha
|
|
64
|
+
|
|
65
|
+
<lch()> = [ <absolute-lch-syntax> | <relative-lch-syntax> ]
|
|
66
|
+
<absolute-lch-syntax> = lch( [ <percentage> | <number> | none ]{2} [ <hue> | none ] [ / <alpha-absolute-value> ]? )
|
|
67
|
+
<relative-lch-syntax> = lch( from <color> <lch-relative-component>{2} <lch-relative-hue> [ / <lch-relative-alpha> ]? )
|
|
68
|
+
<lch-relative-component> = <percentage> | <number> | none | l | c | h | alpha
|
|
69
|
+
<lch-relative-hue> = <hue> | none | l | c | h | alpha
|
|
70
|
+
<lch-relative-alpha> = <alpha-value> | none | l | c | h | alpha
|
|
71
|
+
|
|
72
|
+
/* ==========================================================================
|
|
73
|
+
OKLAB & OKLCH Syntax
|
|
74
|
+
========================================================================== */
|
|
75
|
+
<oklab()> = [ <absolute-oklab-syntax> | <relative-oklab-syntax> ]
|
|
76
|
+
<absolute-oklab-syntax> = oklab( [ <percentage> | <number> | none ]{3} [ / <alpha-absolute-value> ]? )
|
|
77
|
+
<relative-oklab-syntax> = oklab( from <color> <oklab-relative-component>{3} [ / <oklab-relative-alpha> ]? )
|
|
78
|
+
<oklab-relative-component> = <percentage> | <number> | none | l | a | b | alpha
|
|
79
|
+
<oklab-relative-alpha> = <alpha-value> | none | l | a | b | alpha
|
|
80
|
+
|
|
81
|
+
<oklch()> = [ <absolute-oklch-syntax> | <relative-oklch-syntax> ]
|
|
82
|
+
<absolute-oklch-syntax> = oklch( [ <percentage> | <number> | none ]{2} [ <hue> | none ] [ / <alpha-absolute-value> ]? )
|
|
83
|
+
<relative-oklch-syntax> = oklch( from <color> <oklch-relative-component>{2} <oklch-relative-hue> [ / <oklch-relative-alpha> ]? )
|
|
84
|
+
<oklch-relative-component> = <percentage> | <number> | none | l | c | h | alpha
|
|
85
|
+
<oklch-relative-hue> = <hue> | none | l | c | h | alpha
|
|
86
|
+
<oklch-relative-alpha> = <alpha-value> | none | l | c | h | alpha
|
|
87
|
+
|
|
88
|
+
/* ==========================================================================
|
|
89
|
+
ALPHA Syntax
|
|
90
|
+
========================================================================== */
|
|
91
|
+
<alpha()> = alpha( from <color> [ / [ <alpha-value> | none | alpha ] ]? )
|
|
92
|
+
|
|
93
|
+
/* ==========================================================================
|
|
94
|
+
COLOR Space Function Syntax
|
|
95
|
+
========================================================================== */
|
|
96
|
+
<color()> = [ <absolute-color-syntax> | <relative-color-syntax> ]
|
|
97
|
+
<absolute-color-syntax> = color( [ <predefined-rgb> | <xyz-space> | <custom-color-space> ] [ <number> | <percentage> | none ]{3} [ / [ <alpha-value> | none ] ]? )
|
|
98
|
+
<relative-color-syntax> = [ <relative-rgb-color-syntax> | <relative-xyz-color-syntax> | <relative-custom-color-syntax> ]
|
|
99
|
+
|
|
100
|
+
<relative-rgb-color-syntax> = color( from <color> <predefined-rgb> <rgb-relative-component>{3} [ / <rgb-relative-alpha> ]? )
|
|
101
|
+
|
|
102
|
+
<relative-xyz-color-syntax> = color( from <color> <xyz-space> <xyz-relative-component>{3} [ / <xyz-relative-alpha> ]? )
|
|
103
|
+
<xyz-relative-component> = <number> | <percentage> | none | x | y | z | alpha
|
|
104
|
+
<xyz-relative-alpha> = <alpha-value> | none | x | y | z | alpha
|
|
105
|
+
|
|
106
|
+
<predefined-rgb> = srgb | srgb-linear | display-p3 | a98-rgb | prophoto-rgb | rec2020
|
|
107
|
+
<xyz-space> = xyz | xyz-d50 | xyz-d65
|
|
108
|
+
|
|
109
|
+
<relative-custom-color-syntax> = %unregistered-sentinal-value%
|
|
110
|
+
|
|
111
|
+
/* ==========================================================================
|
|
112
|
+
Functional Utilities (Light/Dark, Contrast, CMYK, Mix)
|
|
113
|
+
========================================================================== */
|
|
114
|
+
<light-dark-color> = light-dark( <color> , <color> )
|
|
115
|
+
|
|
116
|
+
<contrast-color()> = contrast-color( <color> )
|
|
117
|
+
|
|
118
|
+
<device-cmyk()> = <legacy-device-cmyk-syntax> | <modern-device-cmyk-syntax>
|
|
119
|
+
<legacy-device-cmyk-syntax> = device-cmyk( <number>#{4} )
|
|
120
|
+
<modern-device-cmyk-syntax> = device-cmyk( <cmyk-component>{4} [ / [ <alpha-value> | none ] ]? )
|
|
121
|
+
<cmyk-component> = <number> | <percentage> | none
|
|
122
|
+
|
|
123
|
+
<color-mix()> = color-mix( [ <color-interpolation-method> , ]? [ <color> && <percentage [0,100]>? ]# )
|
|
124
|
+
<color-interpolation-method> = in [ <rectangular-color-space> | <polar-color-space> <hue-interpolation-method>? ]
|
|
125
|
+
<color-space> = <rectangular-color-space> | <polar-color-space>
|
|
126
|
+
<rectangular-color-space> = srgb | srgb-linear | display-p3 | display-p3-linear | a98-rgb | prophoto-rgb | rec2020 | lab | oklab | <xyz-space> | <custom-color-space> | <custom-rectangular-space>
|
|
127
|
+
<polar-color-space> = hsl | hwb | lch | oklch | <custom-polar-space>
|
|
128
|
+
<hue-interpolation-method> = [ shorter | longer | increasing | decreasing ] hue
|
|
129
|
+
|
|
130
|
+
<custom-color-function> = %unregistered-sentinel-value%
|
|
131
|
+
<custom-rectangular-space> = %unregistered-sentinel-value%
|
|
132
|
+
<custom-polar-space> = %unregistered-sentinel-value%
|
|
133
|
+
|
|
134
|
+
/* ==========================================================================
|
|
135
|
+
Shared Value Components
|
|
136
|
+
========================================================================== */
|
|
137
|
+
<alpha-value> = <number> | <percentage>
|
|
138
|
+
<hue> = <number> | <angle>
|
|
139
|
+
<rgb-relative-component> = <number> | <percentage> | none | r | g | b | alpha
|
|
140
|
+
<rgb-relative-alpha> = <alpha-value> | none | r | g | b | alpha
|
|
141
|
+
<custom-color-space> = %unregistered-sentinel-value%
|
|
142
|
+
`,nt=/^<[^>]+>\s*=/,ot=/^(.*)#\{(\d+)\}$/,rt=/^(.*)\{(\d+)\}$/,at=/^<([^>\s]+)(?:\s+([^>]+))?>$/,st=/\[[^\]]+\]|[^\s]+/g,F=lt(tt);function ae(o,e){let n=o.length,t=e.length,r=new Array(n+t);for(let l=0;l<n;l++)r[l]=o[l];for(let l=0;l<t;l++)r[n+l]=e[l];return r}function it(o){if(!o?.value)return 0;let e=Array.isArray(o.value)?o.value[0]?.value:o.value;return parseFloat(e.trim())}function se(o){return o?o.type==="literal"?o.value:Array.isArray(o.value)?se(o.value[0]):"":""}function Te(o,e){let n=new Map,t=e?[e]:Object.keys(F);for(let r=0;r<t.length;r++){let l=t[r],a=V(l,o,0,F,n,null);for(let s=0;s<a.length;s++){let i=a[s];if(i.success&&i.nextIndex===o.length)return i.nodes[0]}}throw new Error("Invalid syntax")}function V(o,e,n,t,r,l,a){let s=`${o}:${n}:${l||""}:${a?a.join(","):""}`,i=r.get(s);if(i)return i;let c=e[n],h=ce[o];if(h){if(!c)return[];if(h(c,a)){let g=[{success:!0,nextIndex:n+1,nodes:[{type:o,value:c}]}];return r.set(s,g),g}return r.set(s,[]),[]}let u=t[o];if(!u)return r.set(s,[]),[];let d=D(u,e,n,t,r,l),p=new Array(d.length);for(let g=0;g<d.length;g++)p[g]={success:!0,nextIndex:d[g].nextIndex,nodes:[{type:o,value:d[g].nodes}]};return r.set(s,p),p}function D(o,e,n,t,r,l){switch(o.kind){case"literal":{let a=e[n];return!a||a!==o.value.toLowerCase()?[]:[{success:!0,nextIndex:n+1,nodes:[{type:a==="("||a===")"||a===","||a==="/"?"symbol":"literal",value:a}]}]}case"ref":{let a=e[n];if(!a)return[];if(l&&E[l]){let s=E[l].components[a];if(s&&s.value===o.name)return[{success:!0,nextIndex:n+1,nodes:[{type:o.name,value:a}]}]}return V(o.name,e,n,t,r,l,o.args)}case"choice":{let a=[];for(let s=0;s<o.nodes.length;s++){let i=D(o.nodes[s],e,n,t,r,l);for(let c=0;c<i.length;c++)a.push(i[c])}return a}case"sequence":{let a=[{success:!0,nextIndex:n,nodes:[]}];for(let s=0;s<o.nodes.length;s++){let i=o.nodes[s],c=[];for(let h=0;h<a.length;h++){let u=a[h],d=D(i,e,u.nextIndex,t,r,l);for(let p=0;p<d.length;p++)c.push({success:!0,nextIndex:d[p].nextIndex,nodes:ae(u.nodes,d[p].nodes)})}if(a=c,a.length===0)return[]}return a}case"optional":{let a=D(o.node,e,n,t,r,l),s=new Array(a.length+1);s[0]={success:!0,nextIndex:n,nodes:[]};for(let i=0;i<a.length;i++)s[i+1]=a[i];return s}case"repeat":{let a=[{success:!0,nextIndex:n,nodes:[]}];for(let s=0;s<o.min;s++){let i=[];for(let c=0;c<a.length;c++){let h=a[c],u=D(o.node,e,h.nextIndex,t,r,l);for(let d=0;d<u.length;d++)i.push({success:!0,nextIndex:u[d].nextIndex,nodes:ae(h.nodes,u[d].nodes)})}if(a=i,a.length===0)return[]}return a}case"permutation":{let a=o.nodes.length,s=(1<<a)-1,i=[{nextIndex:n,nodes:[],remainingMask:s}],c=[];for(;i.length>0;){let h=[];for(let u=0;u<i.length;u++){let d=i[u],p=!0;for(let g=0;g<a;g++)if((d.remainingMask&1<<g)!==0&&o.nodes[g].kind!=="optional"){p=!1;break}p&&c.push({success:!0,nextIndex:d.nextIndex,nodes:d.nodes});for(let g=0;g<a;g++)if((d.remainingMask&1<<g)!==0){let f=o.nodes[g],m=f.kind==="optional"?f.node:f,y=D(m,e,d.nextIndex,t,r,l),b=d.remainingMask&~(1<<g);for(let v=0;v<y.length;v++)h.push({nextIndex:y[v].nextIndex,nodes:ae(d.nodes,y[v].nodes),remainingMask:b})}}i=h}return c}case"hashList":{let a=D(o.node,e,n,t,r,l),s=[];for(;a.length>0;){let i=[];for(let c=0;c<a.length;c++){let h=a[c];s.push(h);let u=h.nextIndex;if(u<e.length&&e[u]===","){let d={type:"symbol",value:","},p=D(o.node,e,u+1,t,r,l);for(let g=0;g<p.length;g++){let f=p[g];if(f.nextIndex>u){let m=new Array(h.nodes.length+1+f.nodes.length),y=0;for(let b=0;b<h.nodes.length;b++)m[y++]=h.nodes[b];m[y++]=d;for(let b=0;b<f.nodes.length;b++)m[y++]=f.nodes[b];i.push({success:!0,nextIndex:f.nextIndex,nodes:m})}}}}a=i}return s}}}function ue(o){let e=o.toLowerCase(),n=[],t=0;for(;t<e.length;){if(e.slice(t,t+2)==="/*"){let a=e.indexOf("*/",t+2);a!==-1?t=a+2:t=e.length;continue}let r=e[t];if(/\s/.test(r)){t++;continue}if(e.slice(t,t+5)==="calc("){let a=t,s=0;for(;t<e.length;){if(e[t]==="(")s++;else if(e[t]===")"&&(s--,s===0)){t++;break}t++}n.push(e.slice(a,t));continue}if("(),/".includes(r)){n.push(r),t++;continue}let l=t;for(;t<e.length&&!/\s/.test(e[t])&&!"(),/".includes(e[t]);)t++;n.push(e.slice(l,t))}return n}function lt(o){let e={},n=o.replace(/\/\*[\s\S]*?\*\//g,"").split(`
|
|
143
|
+
`),t="",r="";for(let l=0;l<n.length;l++){let a=n[l].trim();if(a)if(nt.test(a)){t&&(e[t]=ee(r));let s=a.indexOf("=");t=a.slice(0,s).trim(),r=a.slice(s+1).trim()}else t&&(r+=" "+a)}return t&&(e[t]=ee(r)),e}function ee(o){let e=Ge(o,"|");return e.length>1?{kind:"choice",nodes:e.map(je)}:je(o)}function Ge(o,e){let n=[],t=0,r=0,l=e.length,a=o.length;for(let i=0;i<a;i++){let c=o.charCodeAt(i);if(c===91||c===40)t++;else if(c===93||c===41)t--;else if(t===0&&o.startsWith(e,i)){let h=o.slice(r,i).trim();h&&n.push(h),i+=l-1,r=i+1}}let s=o.slice(r).trim();return s&&n.push(s),n}function ct(o){let e=[],n=0,t=o.length;for(;n<t;){let r=o.charCodeAt(n);if(r===32||r===9||r===10||r===13){n++;continue}if(r===40||r===41||r===44||r===47||r===124){e.push(o[n]),n++;continue}let l=n;if(r===60){for(;n<t&&o.charCodeAt(n)!==62;)n++;for(n++;n<t;){let a=o.charCodeAt(n);if(a===32||a===9||a===10||a===13||a===40||a===41||a===44||a===47||a===124)break;n++}e.push(o.slice(l,n));continue}if(r===91){let a=1;for(n++;n<t&&a>0;){let s=o.charCodeAt(n);s===91?a++:s===93&&a--,n++}for(;n<t;){let s=o.charCodeAt(n);if(s===32||s===9||s===10||s===13||s===40||s===41||s===44||s===47||s===124)break;n++}e.push(o.slice(l,n));continue}for(;n<t;){let a=o.charCodeAt(n);if(a===32||a===9||a===10||a===13||a===40||a===41||a===44||a===47||a===124)break;n++}e.push(o.slice(l,n))}return e}function je(o){let e=Ge(o,"&&");return e.length>1?{kind:"permutation",nodes:e.map(Re)}:Re(o)}function Re(o){return{kind:"sequence",nodes:ct(o).map(U)}}function U(o){o=o.trim();let e=o.length;if(e===1){let a=o.charCodeAt(0);if(a===40||a===41||a===44||a===47)return{kind:"literal",value:o}}let n=o.charCodeAt(e-1);if(n===35&&o.indexOf("{")===-1)return{kind:"hashList",node:U(o.slice(0,-1))};if(n===63)return{kind:"optional",node:U(o.slice(0,-1))};let t=ot.exec(o);if(t){let a=U(t[1]),s=Number(t[2]),i={kind:"literal",value:","},c=[];for(let h=0;h<s;h++)c.push(a),h<s-1&&c.push(i);return{kind:"sequence",nodes:c}}let r=rt.exec(o);if(r){let a=Number(r[2]);return{kind:"repeat",node:U(r[1]),min:a,max:a}}let l=o.charCodeAt(0);if(l===91&&n===93)return ee(o.slice(1,-1));if(l===60&&n===62){let a=at.exec(o);if(a){let s;if(a[2]){let i=a[2].match(st);i&&(s=i.map(c=>c.trim()))}return{kind:"ref",name:`<${a[1]}>`,args:s}}return{kind:"ref",name:o}}return{kind:"literal",value:o}}var{PI:ie,E:ut,pow:ht,sqrt:pt,sin:ft,cos:dt,tan:mt,asin:gt,acos:yt,atan:bt,atan2:xt,exp:vt,log:wt,log10:Mt,log2:kt,abs:Et,min:At,max:Ct,hypot:_t,round:$t,ceil:Lt,floor:Bt,sign:Nt,trunc:St,random:It}=Math,jt={pi:ie,e:ut,tau:ie*2,pow:ht,sqrt:pt,sin:ft,cos:dt,tan:mt,asin:gt,acos:yt,atan:bt,atan2:xt,exp:vt,log:wt,log10:Mt,log2:kt,abs:Et,min:At,max:Ct,hypot:_t,round:$t,ceil:Lt,floor:Bt,sign:Nt,trunc:St,random:It};function ze(o){return typeof o=="string"?o:o.type==="<percentage>"?String(o.value||""):Array.isArray(o.value)?ze(o.value[0]):String(o.value||"")}function De(o,e,n,t){let r=parseFloat(o);if(isNaN(r))throw new Error(`Invalid percentage: '${o}'.`);return e==="percentage"?r:n<0&&t>0?r/100*(t-n)/2:r/100*(t-n)+n}function Fe(o){let e=parseFloat(o);if(isNaN(e))throw new Error(`Invalid hue: '${o}'.`);return o[o.length-1]==="deg"?e:o[o.length-1]==="rad"?e*(180/ie):o[o.length-1]==="grad"?e*.9:o[o.length-1]==="turn"?e*360:e}function Rt(o,e,n,t,r){if(o==="infinity")return 1/0;if(o==="-infinity")return-1/0;if(o==="nan")return NaN;let l=1,a=2,s=4,i=p=>p===s?"angle":p===a?"percent":"number",c=p=>{let g=[];for(let f=0;f<p.length;){let m=p[f];if(/\s/.test(m)){f++;continue}if(p.slice(f,f+2)==="**"){g.push({type:"operator",value:"**"}),f+=2;continue}if(/[0-9]/.test(m)||m==="."&&/[0-9]/.test(p[f+1]||"")){let y="";for(;f<p.length&&/[0-9.]/.test(p[f]);)y+=p[f++];if(f<p.length&&/[eE]/.test(p[f]))for(y+=p[f++],/[+-]/.test(p[f])&&(y+=p[f++]);f<p.length&&/[0-9]/.test(p[f]);)y+=p[f++];let b=l,v="";p[f]==="%"?(b=a,v="%",f++):p.slice(f,f+3)==="deg"?(b=s,v="deg",f+=3):p.slice(f,f+3)==="rad"?(b=s,v="rad",f+=3):p.slice(f,f+4)==="grad"?(b=s,v="grad",f+=4):p.slice(f,f+4)==="turn"&&(b=s,v="turn",f+=4);let x=parseFloat(y);b===a?x=De(y+v,e,t,r):b===s&&(x=Fe(y+v)),g.push({type:"number",value:x,unit:b});continue}if(/[a-zA-Z_]/.test(m)){let y="";for(;f<p.length&&/[a-zA-Z0-9_]/.test(p[f]);)y+=p[f++];g.push({type:"identifier",value:y});continue}if("+-*/%(),".includes(m)){g.push({type:"operator",value:m}),f++;continue}throw new Error(`Unexpected character: ${m}`)}return g},h=p=>{let g=0,f=()=>g<p.length?p[g]:null,m=()=>{if(g>=p.length)throw new Error("Unexpected end of input");return p[g++]},y=w=>{let B=f();if(!B||B.value!==w)throw new Error(`Expected "${w}" but got "${B?B.value:"end of input"}"`);m()},b=()=>{let w=f();if(!w)throw new Error("Unexpected end of input");if(w.type==="number")return m(),{type:"number",value:w.value,unit:w.unit};if(w.type==="identifier"){if(m(),f()&&f().value==="("){m();let B=[];if(f()&&f().value!==")")for(B.push(k());f()&&f().value===",";)m(),B.push(k());return y(")"),{type:"call",func:w.value,args:B}}return{type:"var",name:w.value}}if(w.value==="("){m();let B=k();return y(")"),B}throw new Error(`Unexpected token: ${w.value}`)},v=()=>f()&&(f().value==="+"||f().value==="-")?{type:"unary",op:m().value,arg:v()}:b(),x=()=>{let w=v();for(;f()&&f().value==="**";)w={type:"binary",op:m().value,left:w,right:v()};return w},C=()=>{let w=x();for(;f()&&["*","/","%"].includes(String(f().value));)w={type:"binary",op:m().value,left:w,right:x()};return w},k=()=>{let w=C();for(;f()&&(f().value==="+"||f().value==="-");)w={type:"binary",op:m().value,left:w,right:C()};return w},$=k();if(g<p.length)throw new Error(`Extra tokens after expression: ${p.slice(g).map(w=>w.value).join(" ")}`);return $},u=(p,g)=>{switch(p.type){case"number":return{value:p.value,unit:p.unit};case"var":{let f=g[p.name];if(f===void 0)throw new Error(`Unknown variable: ${p.name}`);if(typeof f=="function")throw new Error(`Expected variable but found function: ${p.name}`);return{value:f,unit:l}}case"binary":{let f=u(p.left,g),m=u(p.right,g);switch(p.op){case"+":case"-":{let y=p.op==="+"?f.value+m.value:f.value-m.value,b=f.unit|m.unit;if(f.unit===m.unit)return{value:y,unit:f.unit};if(b===5)return{value:y,unit:s};throw new Error(`Cannot ${p.op} mismatched units: ${i(f.unit)} and ${i(m.unit)}`)}case"*":{let y=f.value*m.value;if(f.unit===l)return{value:y,unit:m.unit};if(m.unit===l)return{value:y,unit:f.unit};throw new Error(`Cannot multiply units: ${i(f.unit)} and ${i(m.unit)}`)}case"/":{if(m.unit===l)return{value:f.value/m.value,unit:f.unit};if(f.unit===m.unit)return{value:f.value/m.value,unit:l};throw new Error(`Cannot divide units: ${i(f.unit)} by ${i(m.unit)}`)}case"%":{if(m.unit===l)return{value:f.value%m.value,unit:f.unit};if(f.unit===m.unit)return{value:f.value%m.value,unit:f.unit};throw new Error(`Cannot modulo units: ${i(f.unit)} by ${i(m.unit)}`)}case"**":{if(m.unit!==l)throw new Error(`Exponent must be a number, got ${i(m.unit)}`);return{value:f.value**m.value,unit:f.unit}}default:throw new Error(`Unknown binary operator: ${p.op}`)}}case"unary":{let f=u(p.arg,g);switch(p.op){case"+":return{value:+f.value,unit:f.unit};case"-":return{value:-f.value,unit:f.unit};default:throw new Error(`Unknown unary operator: ${p.op}`)}}case"call":{let f=g[p.func];if(typeof f!="function")throw new Error(`Unknown function: ${p.func}`);let m=p.args.map(x=>u(x,g)),y=m.map(x=>x.value),b=f(...y);if(["min","max","round","ceil","floor","abs","sign","trunc"].includes(p.func)){let x=0;for(let k=0;k<m.length;k++)x|=m[k].unit;if((x&6)===6)throw new Error(`Function ${p.func} cannot mix angle and percent`);if((x&3)===3)throw new Error(`Function ${p.func} cannot mix number and percent`);let C=x&s?s:x&a?a:l;return{value:b,unit:C}}return{value:b,unit:l}}default:throw new Error(`Unknown AST node type: ${p.type}`)}},d=Object.assign({},jt,n);return u(h(c(o)),d).value}function A(o,e,n={}){if(!o)return NaN;let t=ze(o);return le(t,e,n)}function le(o,e,n={}){let t=o.trim();if(t==="none")return NaN;if(t in n)return n[t];let[r,l]=Array.isArray(e)?e:e==="percentage"?[0,100]:[0,1];if(/^-?(?:\d+|\d*\.\d+)$/.test(t))return parseFloat(t);if(t[t.length-1]==="%"&&/^-?(?:\d+|\d*\.\d+)%$/.test(t))return De(t,e,r,l);if(/^-?(?:\d+|\d*\.\d+)(deg|rad|grad|turn)$/.test(t))return Fe(t);if(t.slice(0,5)==="calc("&&t[t.length-1]===")")return Rt(t.slice(5,-1).trim(),e,n,r,l);throw new Error(`Unable to parse component token: ${t}`)}function Q(o,e){return n=>{let t=n.value,r=E[o].components,l=A(t[2],r[e[0]].value),a=A(t[4],r[e[1]].value),s=A(t[6],r[e[2]].value),i=1;return t[7]?.type==="symbol"&&t[7]?.value===","&&(i=A(t[8],[0,1])),{model:o,coords:[l,a,s,i]}}}function G(o,e){return n=>{let t=n.value,r=E[o].components,l=A(t[2],r[e[0]].value),a=A(t[3],r[e[1]].value),s=A(t[4],r[e[2]].value),i=1;return t[5]?.type==="symbol"&&t[5]?.value==="/"&&(i=A(t[6],[0,1])),{model:o,coords:[l,a,s,i]}}}function z(o,e){return n=>{let t=n.value,r=E[o].components,l=t[3],a=_(l),i=new M(a.model,a.coords).in(o).toObject({fit:"none",precision:null}),c=A(t[4],r[e[0]].value,i),h=A(t[5],r[e[1]].value,i),u=A(t[6],r[e[2]].value,i),d=1;return t[7]?.type==="symbol"&&t[7]?.value==="/"&&(d=A(t[8],[0,1],i)),{model:o,coords:[c,h,u,d]}}}function Oe(o){let e=o.value,{model:n,coords:t}=_(e[3]),r=e[4],l=Array.isArray(r.value)?r.value[0]?.value:r.value,s=new M(n,t).in(l).toObject({fit:"none",precision:null}),i=A(e[5],[0,1],s),c=A(e[6],[0,1],s),h=A(e[7],[0,1],s),u=1;return e[8]?.type==="symbol"&&e[8]?.value==="/"&&(u=A(e[9],[0,1],s)),{model:l,coords:[i,c,h,u]}}var ce=(()=>{let o=/^-?(?:\d+(?:\.\d+)?|\.\d+)$/,e=/^-?(?:\d+(?:\.\d+)?|\.\d+)%$/,n=/^-?(?:\d+(?:\.\d+)?|\.\d+)(?:deg|rad|turn|grad)$/,t=/^\[([^,]+),([^\]]+)\]$/,r=new Set(Object.keys(q).map(i=>i.toLowerCase())),l=new Map,a=i=>{if(i){for(let c=0;c<i.length;c++)if(t.test(i[c]))return i[c]}},s=(i,c)=>{let h=l.get(c);if(!h){let u=c.match(t);h={min:u[1].trim()==="-INF"?-1/0:parseFloat(u[1]),max:u[2].trim()==="INF"||u[2].trim()==="+INF"?1/0:parseFloat(u[2])},l.set(c,h)}return!(h.min!==-1/0&&i<h.min||h.max!==1/0&&i>h.max)};return{"<named-color>":i=>Object.hasOwn(J,i),"<system-color>":i=>r.has(i),"<hex-color>":i=>i[0]==="#"&&(i.length===4||i.length===5||i.length===7||i.length===9)&&/^[0-9a-fA-F]+$/.test(i.slice(1)),"<number>":(i,c)=>{if(i.startsWith("calc(")&&i.endsWith(")"))return!0;if(!o.test(i))return!1;if(c!==void 0){let h=a(c);if(h)return s(parseFloat(i),h)}return!0},"<percentage>":(i,c)=>{if(i.startsWith("calc(")&&i.endsWith(")"))return!0;if(!e.test(i))return!1;if(c!==void 0){let h=a(c);if(h)return s(parseFloat(i),h)}return!0},"<angle>":(i,c)=>{if(i.startsWith("calc(")&&i.endsWith(")"))return!0;if(!n.test(i))return!1;if(c!==void 0){let h=a(c);if(h)return s(parseFloat(i),h)}return!0}}})(),Ot={"<color>":o=>{let e=o.value[0],{type:n,value:t}=e;if(n==="literal"){if(t==="currentcolor")return{model:"rgb",coords:[0,0,0,1]};throw new Error(`Unknown <color>: ${t}`)}return _(e)},"<color-base>":o=>{let e=o.value[0],{type:n,value:t}=e;if(n==="literal"){if(t==="transparent")return{model:"rgb",coords:[0,0,0,0]};throw new Error(`Unknown <color-base>: ${t}`)}return _(e)},"<named-color>":o=>{let{value:e}=o,n=J[e];if(!n)throw new Error(`Unknown <named-color>: ${e}`);return{model:"rgb",coords:[...n,1]}},"<system-color>":o=>{let{value:e}=o,n=N.theme==="light"?0:1,t=Object.keys(q).find(l=>l.toLowerCase()===e),r=q[t][n];if(!r)throw new Error(`Unknown <system-color>: ${e}`);return{model:"rgb",coords:[...r,1]}},"<contrast-color()>":o=>{let e=o.value[2],{model:n,coords:t}=_(e),[,r]=new M(n,t).in("xyz-d65").coords;return{model:"rgb",coords:r>.5?[0,0,0,1]:[255,255,255,1]}},"<light-dark-color>":o=>{let e=o.value,n=e[2],t=e[4],{model:r,coords:l}=_(N?.theme==="light"?n:t),{coords:a}=new M(r,l).in("rgb");return{model:"rgb",coords:a}},"<hex-color>":o=>{let e=o.value,n=e.length,t=0,r=0,l=0,a=1;if(n===4||n===5){let s=e.charCodeAt(1),i=e.charCodeAt(2),c=e.charCodeAt(3),h=s>64?(s&7)+9:s&15,u=i>64?(i&7)+9:i&15,d=c>64?(c&7)+9:c&15;if(t=h<<4|h,r=u<<4|u,l=d<<4|d,n===5){let p=e.charCodeAt(4),g=p>64?(p&7)+9:p&15;a=(g<<4|g)/255}}else{let s=parseInt(e.slice(1),16);n===7?(t=s>>16&255,r=s>>8&255,l=s&255):n===9&&(t=s>>24&255,r=s>>16&255,l=s>>8&255,a=(s&255)/255)}return{model:"rgb",coords:[t,r,l,a]}},"<device-cmyk()>":o=>_(o.value[0]),"<legacy-device-cmyk-syntax>":o=>{let e=o.value,[n,t,r,l]=[e[2],e[4],e[6],e[8]].map(it);return{model:"rgb",coords:[(1-(n*(1-l)+l))*255,(1-(t*(1-l)+l))*255,(1-(r*(1-l)+l))*255,1]}},"<modern-device-cmyk-syntax>":o=>{let e=o.value,n=A(e[2],[0,1]),t=A(e[3],[0,1]),r=A(e[4],[0,1]),l=A(e[5],[0,1]),a=e.find((p,g)=>g===7&&(p.type==="<alpha-value>"||p.type==="literal"&&p.value==="none")),s=a?A(a,[0,1]):1,i=S(n,[0,1]),c=S(t,[0,1]),h=S(r,[0,1]),u=S(l,[0,1]),d=isNaN(s)?s:Math.max(0,Math.min(1,s));return{model:"rgb",coords:[(1-(i*(1-u)+u))*255,(1-(c*(1-u)+u))*255,(1-(h*(1-u)+u))*255,d]}},"<color-mix()>":o=>{let e="oklab",n="shorter",t=o.value,r=2;if(t[r]?.type==="<color-interpolation-method>"){let s=t[r].value;r++,s[1]&&(e=se(s[1])),s[2]&&s[2].type!=="symbol"&&(n=se(s[2]))}let l=[];for(;r<t.length;){let s=t[r];if(s.type==="symbol"&&(s.value===","||s.value===")")){r++;continue}let i,c;if(s.type==="<percentage>"){let u=String(s.value||"");i=le(u,"percentage"),r++,c=t[r]}else{c=s;let u=t[r+1];if(u?.type==="<percentage>"){let d=String(u.value||"");i=le(d,"percentage"),r++}}let h=c?_(c):null;if(h&&h.coords){r++,l.push({color:new M(h.model,h.coords),percentage:i});continue}r++}if(l.length===0)throw new Error("color-mix() must contain at least one color component.");let a=M.mix(l,{in:e,hue:n});return{model:a.model,coords:a.coords}},"<color-function>":o=>_(o.value[0]),"<custom-color-function>":o=>_(o.value[0]),"<rgb()>":o=>_(o.value[0]),"<rgba()>":o=>_(o.value[0]),"<hsl()>":o=>_(o.value[0]),"<hsla()>":o=>_(o.value[0]),"<hwb()>":o=>_(o.value[0]),"<lab()>":o=>_(o.value[0]),"<lch()>":o=>_(o.value[0]),"<oklab()>":o=>_(o.value[0]),"<oklch()>":o=>_(o.value[0]),"<legacy-rgb-syntax>":Q("rgb",["r","g","b"]),"<legacy-rgba-syntax>":Q("rgb",["r","g","b"]),"<legacy-hsl-syntax>":Q("hsl",["h","s","l"]),"<legacy-hsla-syntax>":Q("hsl",["h","s","l"]),"<modern-rgb-syntax>":G("rgb",["r","g","b"]),"<modern-rgba-syntax>":G("rgb",["r","g","b"]),"<modern-hsl-syntax>":G("hsl",["h","s","l"]),"<modern-hsla-syntax>":G("hsl",["h","s","l"]),"<absolute-hwb-syntax>":G("hwb",["h","w","b"]),"<absolute-lab-syntax>":G("lab",["l","a","b"]),"<absolute-lch-syntax>":G("lch",["l","c","h"]),"<absolute-oklab-syntax>":G("oklab",["l","a","b"]),"<absolute-oklch-syntax>":G("oklch",["l","c","h"]),"<relative-rgb-syntax>":z("rgb",["r","g","b"]),"<relative-rgba-syntax>":z("rgb",["r","g","b"]),"<relative-hsl-syntax>":z("hsl",["h","s","l"]),"<relative-hsla-syntax>":z("hsl",["h","s","l"]),"<relative-hwb-syntax>":z("hwb",["h","w","b"]),"<relative-lab-syntax>":z("lab",["l","a","b"]),"<relative-lch-syntax>":z("lch",["l","c","h"]),"<relative-oklab-syntax>":z("oklab",["l","a","b"]),"<relative-oklch-syntax>":z("oklch",["l","c","h"]),"<alpha()>":o=>{let e=o.value,n=e[3],t=_(n);if(!t)throw new Error("Missing or invalid origin color in alpha() function");let l=new M(t.model,t.coords).toObject({fit:"none",precision:null}),a=e.find((i,c)=>i.type==="<alpha-value>"||c===5&&i.type==="literal"&&i.value==="none"),s=a?A(a,[0,1],l):t.coords[3];return{model:t.model,coords:[...t.coords.slice(0,3),s]}},"<color()>":o=>_(o.value[0]),"<relative-color-syntax>":o=>_(o.value[0]),"<absolute-color-syntax>":o=>{let e=o.value,n=e[2],t=Array.isArray(n.value)?n.value[0]?.value:n.value,r=A(e[3],[0,1]),l=A(e[4],[0,1]),a=A(e[5],[0,1]),s=e.find((c,h)=>h>5&&(c.type==="<alpha-value>"||c.type==="literal"&&c.value==="none")),i=s?A(s,[0,1]):1;return{model:t,coords:[r,l,a,i]}},"<relative-rgb-color-syntax>":Oe,"<relative-xyz-color-syntax>":Oe,"<relative-custom-color-syntax>":o=>_(o.value[0])},he=(()=>{let o=(()=>{let e={};for(let n of Object.keys(E)){let{bridge:t,fromBridge:r,supportsLegacy:l,components:a,alphaVariant:s}=E[n];e[n]={bridge:t,fromBridge:i=>[...r(i),i[3]??1],format:([i,c,h,u=1],d={})=>{let{legacy:p=!1,fit:g=N.defaults.fit,precision:f,units:m=!1}=d,b=[...O([i,c,h],n,{method:g,precision:f}),u].map((C,k)=>{let $=S(C,Object.values(a)[k].value);if((m||p)&&a){let w=Object.values(a).find(B=>B.index===k);if(w?.value==="percentage")return`${$}%`;if(w?.value==="hue"&&m)return`${$}deg`}return $.toString()}),v=b.slice(0,3),x=b[3];return n in Z?`color(${n} ${v.join(" ")}${u!==1?` / ${x}`:""})`:p&&l?u===1?`${n}(${v.join(", ")})`:`${s||n}(${v.join(", ")}, ${x})`:`${n}(${v.join(" ")}${u!==1?` / ${x}`:""})`}}}return e})();return{...o,"hex-color":{bridge:"rgb",fromBridge:e=>e,format:([e,n,t,r=1])=>{let l=s=>s.toString(16).padStart(2,"0");return`#${[e,n,t].map(s=>l(Math.round(Math.max(0,Math.min(255,s))))).join("")}${r<1?l(Math.round(r*255)):""}`}},"named-color":{bridge:"rgb",fromBridge:e=>e,format:e=>{let[n,t,r]=e.map((l,a)=>a<3?Math.round(Math.min(255,Math.max(0,l))):l);for(let[l,[a,s,i]]of Object.entries(J))if(n===a&&t===s&&r===i)return l}},"device-cmyk":{bridge:"rgb",fromBridge:e=>e,format:([e,n,t,r=1],l={})=>{let{legacy:a=!1,precision:s=3,fit:i=N.defaults.fit}=l,[c,h,u]=O([e,n,t],"rgb",{method:i}),d=c/255,p=h/255,g=u/255,f=1-Math.max(d,p,g),m=$=>Number(s===null?$:$.toFixed(s)).toString(),y=m(f===1?0:(1-d-f)/(1-f)),b=m(f===1?0:(1-p-f)/(1-f)),v=m(f===1?0:(1-g-f)/(1-f)),x=m(f),C=Number(r.toFixed(3)).toString();if(a)return`device-cmyk(${y}, ${b}, ${v}, ${x}${r<1?`, ${C}`:""})`;let k=o.rgb.format?.([c,h,u,r],l);return`device-cmyk(${y} ${b} ${v} ${x}${r<1?` / ${C}`:""}, ${k})`}}}})();function _(o){let e=Ot[o.type];if(!e)throw new Error(`No parser for rule: ${o.type}`);return e(o)}function Xe(o,e){let n=o.replace(/[A-Z]/g,a=>String.fromCharCode(a.charCodeAt(0)+32)),t=ue(n),r=new Map;if(e){if(F[e])return V(e,t,0,F,r,null).some(s=>s.success&&s.nextIndex===t.length);if(ce[e])return V(e,t,0,F,r,null).some(s=>s.success&&s.nextIndex===t.length);try{let a=ee(e);return D(a,t,0,F,r,null).some(i=>i.success&&i.nextIndex===t.length)}catch(a){throw new Error(`Failed to resolve rule or parse inline expression: "${e}"`,{cause:a})}}let l=new Set([...Object.keys(F),...Object.keys(ce)]);for(let a of l)if(V(a,t,0,F,r,null).some(c=>c.success&&c.nextIndex===t.length))return!0;return!1}var M=class o{model;coords;constructor(e,n=[0,0,0,0]){if(!(e in E))throw new Error(`Unsupported color model: '${e}'`);if([3,4].includes(n.length)===!1)throw new Error("Coordinates array must have 3 or 4 elements.");let t=n.slice();t.length===3&&t.push(1),this.model=e,this.coords=t}static from(e){let n=ue(e),t=Te(n);try{let{model:r,coords:l}=_(t);return new o(r,l)}catch(r){throw new Error(`Failed to parse color string '${e}'`,{cause:r})}}static isValid(e,n={}){let{rule:t}=n;try{return Xe(e,t)&&!!o.from(e)}catch{return!1}}static random(e={}){let n=Object.keys(E),t=e.model??n[Math.floor(Math.random()*n.length)],{components:r}=E[t],l=new Set(Object.keys(r));for(let s of["limits","bias","base","deviation"]){let i=e[s];if(i){for(let c of Object.keys(i))if(!l.has(c))throw new Error(`Invalid component "${c}" for model "${t}". Valid components: ${[...l].join(", ")}`)}}let a=[];for(let[s,i]of Object.entries(r)){let c=e.base?.[s],h=e.deviation?.[s],u;if(c!=null&&h!=null){let d=Math.random()||1e-9,p=Math.random()||1e-9;u=c+Math.sqrt(-2*Math.log(d))*Math.cos(2*Math.PI*p)*h}else{let[d,p]=i.value==="hue"?[0,360]:i.value==="percentage"?[0,100]:i.value,g=e.limits?.[s];if(g){let[y,b]=g;d=Math.max(d,y),p=Math.min(p,b)}let f=Math.random(),m=e.bias?.[s];m&&(f=m(f)),u=d+f*(p-d)}if(i.value==="hue")u=(u%360+360)%360;else if(i.value==="percentage")u=Math.min(100,Math.max(0,u));else if(Array.isArray(i.value)){let[d,p]=i.value;u=Math.min(p,Math.max(d,u))}else throw new Error(`Invalid component value definition for "${s}".`);a[i.index]=u}return new o(t,a)}static mix(e,n){let{in:t="oklab",hue:r="shorter"}=n;if(!e||e.length===0)throw new Error("At least one color must be provided in the colors array.");if(e.length===1)return e[0].color.in(t);let l=e.map(u=>u.percentage!==void 0?u.percentage/100:void 0),a=l.reduce((u,d)=>u+(d||0),0),s=l.filter(u=>u===void 0).length,i=1;if(l.length>0&&l.every(u=>u===0)){i=0;for(let u=0;u<l.length;u++)l[u]=1/l.length}else s===0&&a<1&&(i=a);if(i>0){if(s>0){let d=Math.max(0,1-a)/s;for(let p=0;p<l.length;p++)l[p]===void 0&&(l[p]=d)}else if(a>0&&a!==1)for(let u=0;u<l.length;u++)l[u]=l[u]/a}let c=e[0].color.in(t),h=l[0];for(let u=1;u<e.length;u++){let d=l[u];h+=d;let p=h===0?0:d/h;c=ve(c,e[u].color.in(t),p,t,r)}if(i!==1){let u=[...c.coords];return u[3]=(u[3]??1)*i,new o(t,u)}return c}to(e,n={}){let t=e.toLowerCase(),{legacy:r=!1,fit:l=N.defaults.fit,precision:a,units:s=!1}=n,i=he[t];if(!i)throw new Error(`Unsupported color type: '${t}'.`);let{fromBridge:c,bridge:h,format:u}=i;if(!c||!u)throw new Error(`Invalid output type: '${t}'.`);let d=p=>u(p,{legacy:r,fit:l,precision:a,units:s});return t===this.model?d(this.coords):t in E?d(this.in(t).toArray({fit:"none",precision:null})):d(c(this.in(h).toArray({fit:"none",precision:null})))}in(e){let n=this.model,t=e.trim().toLowerCase();if(t===n)return new o(t,[...this.coords]);let r=X.get("graph"),l=X.get("paths");if(!r){r={};for(let[c,h]of Object.entries(E)){let{bridge:u}=h;r[c]=[...r[c]||[],u],r[u]=[...r[u]||[],c]}X.set("graph",r)}l||(l=new Map,X.set("paths",l));let a=`${n}-${t}`;if(!l.has(a)){let c=[n],h={[n]:null};for(let d=0;d<c.length;d++){let p=c[d];if(p===t)break;for(let g of r[p]||[])g in h||(h[g]=p,c.push(g))}let u=[];for(let d=t;d;d=h[d])u.push(d);if(u.reverse(),!u.length||u[0]!==n)throw new Error(`Cannot convert from ${n} to ${t}. No path found.`);l.set(a,u)}let s=[...this.coords.map(c=>isNaN(c)?0:c)],i=l.get(a);for(let c=0;c<i.length-1;c++){let h=i[c],u=i[c+1],d=E[h],p=E[u];if(d.toBridge&&d.bridge===u)s=d.toBridge(s);else if(p.fromBridge&&p.bridge===h)s=p.fromBridge(s);else throw new Error(`No conversion found between ${h} and ${u}.`)}return new o(t,[...s.slice(0,3),this.coords[3]??1])}toString(e={}){let{format:n}=he[this.model],{legacy:t=!1,fit:r=N.defaults.fit,precision:l,units:a=!1}=e;return n?.(this.coords,{legacy:t,fit:r,precision:l,units:a})}toObject(e={}){let n=this.toArray(e),{components:t}=E[this.model];if(!t)throw new Error(`Model ${this.model} does not have defined components.`);let r={};for(let[l,{index:a}]of Object.entries(t))r[l]=n[a];return r}toArray(e={}){let{fit:n=N.defaults.fit,precision:t}=e,{model:r,coords:l}=this,{components:a}=E[r];if(!a)throw new Error(`Model ${r} does not have defined components.`);let s=l.slice(0,3).map((c,h)=>S(c,Object.values(a)[h].value));return[...O(s,r,{method:n,precision:t}),l[3]]}with(e){let{model:n}=this,t=this.coords.slice(),{components:r}=E[n],l=Object.keys(r),a=Object.values(r),s=typeof e=="function"?e(Object.fromEntries(l.map(c=>{let h=r[c];return[c,S(t[h.index],h.value)]}))):e;if(Array.isArray(s)){let c=t.map((h,u)=>{let d=s[u];if(typeof d!="number")return h;let p=a.find(g=>g.index===u);return S(d,p.value)});return new o(n,[...c.slice(0,3),t[3]??1])}let i=[...t];for(let c of l){if(!(c in s))continue;let{index:h,value:u}=r[c],d=s[c],p=S(t[h],u),g=typeof d=="function"?S(d(p),u):typeof d=="number"?S(d,u):t[h];i[h]=g}return new o(n,[...i.slice(0,3),i[3]??t[3]])}fit(e={}){let{fit:n=N.defaults.fit,precision:t}=e,r=this.toArray({fit:n,precision:t});return new o(this.model,r)}within(e,n=N.defaults.fit){let t=e.trim().toLowerCase();if(!(t in Z))throw new Error(`Unsupported color gamut: '${t}'.`);let r=this.in(t).toArray({fit:n,precision:null});return new o(t,r).in(this.model)}contrast(e){let[,n]=this.in("xyz-d65").toArray({fit:"none",precision:null}),[,t]=e.in("xyz-d65").toArray({fit:"none",precision:null});return(Math.max(n,t)+.05)/(Math.min(n,t)+.05)}deltaEOK(e){let n={fit:"none",precision:null},[t,r,l]=this.in("oklab").toArray(n),[a,s,i]=e.in("oklab").toArray(n),c=t-a,h=r-s,u=l-i;return Math.sqrt(c**2+h**2+u**2)*100}deltaE76(e){let n={fit:"none",precision:null},[t,r,l]=this.in("lab").toArray(n),[a,s,i]=e.in("lab").toArray(n),c=t-a,h=r-s,u=l-i;return Math.hypot(c,h,u)}deltaE94(e){let n={fit:"none",precision:null},[t,r,l]=this.in("lab").toArray(n),[a,s,i]=e.in("lab").toArray(n),c=t-a,h=r-s,u=l-i,d=Math.sqrt(r*r+l*l),p=Math.sqrt(s*s+i*i),g=d-p,f=Math.sqrt(Math.max(0,h*h+u*u-g*g)),m=1,y=1,b=1,v=.045,x=.015,C=1+v*d,k=1+x*d;return Math.sqrt((c/m)**2+(g/(y*C))**2+(f/(b*k))**2)}deltaE2000(e){let n={fit:"none",precision:null},[t,r,l]=this.in("lab").toArray(n),[a,s,i]=e.in("lab").toArray(n),c=Math.PI,h=c/180,u=180/c,d=Math.sqrt(r**2+l**2),p=Math.sqrt(s**2+i**2),g=(d+p)/2,f=Math.pow(25,7),m=Math.pow(g,7),y=.5*(1-Math.sqrt(m/(m+f))),b=(1+y)*r,v=(1+y)*s,x=Math.sqrt(b**2+l**2),C=Math.sqrt(v**2+i**2),k=Math.atan2(l,b),$=Math.atan2(i,v);k<0&&(k+=2*c),$<0&&($+=2*c),k*=u,$*=u;let w=a-t,B=C-x,P=$-k,pe=Math.abs(P),K=0;x*C!==0&&(pe<=180?K=P:P>180?K=P-360:K=P+360);let fe=2*Math.sqrt(x*C)*Math.sin(K*h/2),Ze=(t+a)/2,te=(x+C)/2,de=Math.pow(te,7),Y=k+$,j;x===0&&C===0?j=Y:pe<=180?j=Y/2:Y<360?j=(Y+360)/2:j=(Y-360)/2;let me=(Ze-50)**2,Pe=1+.015*me/Math.sqrt(20+me),ge=1+.045*te,H=1;H-=.17*Math.cos((j-30)*h),H+=.24*Math.cos(2*j*h),H+=.32*Math.cos((3*j+6)*h),H-=.2*Math.cos((4*j-63)*h);let ye=1+.015*te*H,Ye=30*Math.exp(-1*((j-275)/25)**2),He=2*Math.sqrt(de/(de+f)),qe=-1*Math.sin(2*Ye*h)*He,W=(w/Pe)**2;return W+=(B/ge)**2,W+=(fe/ye)**2,W+=qe*(B/ge)*(fe/ye),Math.sqrt(W)}equals(e,n=T){let t=this.toArray({fit:"none",precision:null}),r=e.toArray({fit:"none",precision:null});if(e.model===this.model)return t.every((s,i)=>Math.abs(s-r[i])<=n);let l=this.in("xyz-d65").toArray({fit:"none",precision:null}),a=e.in("xyz-d65").toArray({fit:"none",precision:null});return l.every((s,i)=>Math.abs(s-a[i])<=n)}inGamut(e,n=T){let t=e.trim().toLowerCase();if(!(t in Z))throw new Error(`Unsupported color gamut: '${t}'.`);let{components:r,targetGamut:l}=E[t];if(!l)return!0;let a=this.in(t).toArray({fit:"none",precision:null});return Object.values(r).every(({index:s,value:i})=>{let c=a[s],[h,u]=Array.isArray(i)?i:i==="hue"?[0,360]:[0,100];return c>=h-n&&c<=u+n})}};return Qe(Tt);})();
|
package/dist/math.d.ts
CHANGED
|
@@ -22,16 +22,6 @@ export declare const MATRICES: {
|
|
|
22
22
|
LMS_to_OKLAB: number[][];
|
|
23
23
|
OKLAB_to_LMS: number[][];
|
|
24
24
|
};
|
|
25
|
-
/** A collection of common easing functions for interpolation. */
|
|
26
|
-
export declare const EASINGS: {
|
|
27
|
-
linear: (t: number) => number;
|
|
28
|
-
"ease-in": (t: number) => number;
|
|
29
|
-
"ease-out": (t: number) => number;
|
|
30
|
-
"ease-in-out": (t: number) => number;
|
|
31
|
-
"ease-in-cubic": (t: number) => number;
|
|
32
|
-
"ease-out-cubic": (t: number) => number;
|
|
33
|
-
"ease-in-out-cubic": (t: number) => number;
|
|
34
|
-
};
|
|
35
25
|
/**
|
|
36
26
|
* A collection of color coordinate fitting methods used to ensure color values conform to specific constraints or gamuts.
|
|
37
27
|
*
|
|
@@ -44,8 +34,8 @@ export declare const EASINGS: {
|
|
|
44
34
|
* @see {@link https://www.w3.org/TR/css-color-4/|CSS Color Module Level 4}
|
|
45
35
|
*/
|
|
46
36
|
export declare const fitMethods: {
|
|
47
|
-
"chroma-reduction": (coords: number[], model: "
|
|
48
|
-
"css-gamut-map": (coords: number[], model: "
|
|
37
|
+
"chroma-reduction": (coords: number[], model: "xyz-d65" | "rgb" | "xyz-d50" | "lab" | "oklab" | "srgb" | "srgb-linear" | "display-p3" | "rec2020" | "a98-rgb" | "prophoto-rgb" | "xyz" | "hsl" | "hwb" | "lch" | "oklch") => number[];
|
|
38
|
+
"css-gamut-map": (coords: number[], model: "xyz-d65" | "rgb" | "xyz-d50" | "lab" | "oklab" | "srgb" | "srgb-linear" | "display-p3" | "rec2020" | "a98-rgb" | "prophoto-rgb" | "xyz" | "hsl" | "hwb" | "lch" | "oklch") => number[];
|
|
49
39
|
};
|
|
50
40
|
/**
|
|
51
41
|
* Converts RGB to XYZ (D65).
|
package/dist/math.js
CHANGED
|
@@ -89,16 +89,6 @@ export const MATRICES = {
|
|
|
89
89
|
[1.0, -0.0894841775298119, -1.2914855480194092],
|
|
90
90
|
],
|
|
91
91
|
};
|
|
92
|
-
/** A collection of common easing functions for interpolation. */
|
|
93
|
-
export const EASINGS = {
|
|
94
|
-
linear: (t) => t,
|
|
95
|
-
"ease-in": (t) => t * t,
|
|
96
|
-
"ease-out": (t) => t * (2 - t),
|
|
97
|
-
"ease-in-out": (t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t),
|
|
98
|
-
"ease-in-cubic": (t) => t * t * t,
|
|
99
|
-
"ease-out-cubic": (t) => --t * t * t + 1,
|
|
100
|
-
"ease-in-out-cubic": (t) => (t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2),
|
|
101
|
-
};
|
|
102
92
|
/**
|
|
103
93
|
* A collection of color coordinate fitting methods used to ensure color values conform to specific constraints or gamuts.
|
|
104
94
|
*
|
|
@@ -125,7 +115,7 @@ export const fitMethods = {
|
|
|
125
115
|
let C_low = 0;
|
|
126
116
|
let C_high = 1.0;
|
|
127
117
|
const epsilon = 1e-6;
|
|
128
|
-
let clipped
|
|
118
|
+
let clipped;
|
|
129
119
|
while (C_high - C_low > epsilon) {
|
|
130
120
|
const C_mid = (C_low + C_high) / 2;
|
|
131
121
|
const candidate_color = new Color("oklch", [L_clipped, C_mid, H]);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ColorModel } from "../types.js";
|
|
2
|
+
declare module "../Color.js" {
|
|
3
|
+
interface Color<M extends ColorModel = ColorModel> {
|
|
4
|
+
/**
|
|
5
|
+
* Lightens the color by the given amount.
|
|
6
|
+
* @param amount - The amount to lighten the color by.
|
|
7
|
+
* @returns A new `Color` instance with increased brightness.
|
|
8
|
+
*/
|
|
9
|
+
lighten(amount: number): Color<"hsl">;
|
|
10
|
+
/**
|
|
11
|
+
* Darkens the color by the given amount.
|
|
12
|
+
* @param amount - The amount to darken the color by.
|
|
13
|
+
* @returns A new `Color` instance with decreased brightness.
|
|
14
|
+
*/
|
|
15
|
+
darken(amount: number): Color<"hsl">;
|
|
16
|
+
}
|
|
17
|
+
}
|