@asamuzakjp/css-color
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -1,2 +0,2 @@ | ||
var L=t=>Object.prototype.toString.call(t).slice(8,-1),Y=t=>typeof t=="string"||t instanceof String;var et=.5,$t=2,nt=3,K=4,qt=10,G=16,q=360,rt=60,R=100,M=255,Tt=2,mt=3,bt=2.4,Ft=12.92,v=.055,yt=116,Zt=500,Ut=200,Dt=216/24389,Mt=24389/27,jt=[.3457/.3585,1,(1-.3457-.3585)/.3585],wt=[[.9554734527042182,-.023098536874261423,.0632593086610217],[-.028369706963208136,1.0099954580058226,.021041398966943008],[.012314001688319899,-.020507696433477912,1.3303659366080753]],tt=[[1.0479298208405488,.022946793341019088,-.05019222954313557],[.029627815688159344,.990434484573249,-.01707382502938514],[-.009243058152591178,.015055144896577895,.7518742899580008]],Nt=[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],Lt=[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],fe=[[.8190224432164319,.3619062562801221,-.12887378261216414],[.0329836671980271,.9292868468965546,.03614466816999844],[.048177199566046255,.26423952494422764,.6335478258136937]],Kt=[[1.2268798733741557,-.5578149965554813,.28139105017721583],[-.04057576262431372,1.1122868293970594,-.07171106666151701],[-.07637294974672142,-.4214933239627914,1.5869240244272418]],Qt=[[.9999999984505196,.39633779217376774,.2158037580607588],[1.0000000088817607,-.10556134232365633,-.0638541747717059],[1.0000000546724108,-.08948418209496574,-1.2914855378640917]],he=[[.2104542553,.793617785,-.0040720468],[1.9779984951,-2.428592205,.4505937099],[.0259040371,.7827717662,-.808675766]],pe=[[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0,32229/714400,5220557/5000800]],ge=[[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,472592308/697040785,8267143/139408157],[0,19567812/697040785,295819943/278816314]],$e=[[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],be=[[.7977604896723027,.13518583717574031,.0313493495815248],[.2880711282292934,.7118432178101014,8565396060525902e-20],[0,0,.8251046025104601]],b="none",Bt="deg|g?rad|turn",Jt="srgb(?:-linear)?",vt="xyz(?:-d(?:50|65))?",Fe=`(?:ok)?l(?:ab|ch)|h(?:sl|wb)|${Jt}|${vt}`,me=`(?:a98|prophoto)-rgb|display-p3|rec2020|${Jt}`,Z="[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?",j=`${Z}%`,dt=`(?:${Z}(?:${Bt})?|${b})(?:\\s+(?:${j}|${b})){2}(?:\\s*\\/\\s*(?:${Z}|${j}|${b}))?`,te=`${Z}(?:${Bt})?(?:\\s*,\\s*${j}){2}(?:\\s*,\\s*(?:${Z}|${j}))?`,kt=`(?:(?:${Z}|${b})(?:\\s+(?:${Z}|${b})){2}|(?:${j}|${b})(?:\\s+(?:${j}|${b})){2})(?:\\s*\\/\\s*(?:${Z}|${j}|${b}))?`,ee=`(?:${Z}(?:\\s*,\\s*${Z}){2}|${j}(?:\\s*,\\s*${j}){2})(?:\\s*,\\s*(?:${Z}|${j}))?`,Et=`(?:${Z}|${j}|${b})(?:\\s+(?:${Z}|${j}|${b})){2}(?:\\s*\\/\\s*(?:${Z}|${j}|${b}))?`,It=`(?:(?:${Z}|${j}|${b})\\s+){2}(?:${Z}(?:${Bt})?|${b})(?:\\s*\\/\\s*(?:${Z}|${j}|${b}))?`,zt=`(?:${me}|${vt})(?:\\s+(?:${Z}|${j}|${b})){3}(?:\\s*\\/\\s*(?:${Z}|${j}|${b}))?`,se=`[a-z]+|#(?:[\\da-f]{3}|[\\da-f]{4}|[\\da-f]{6}|[\\da-f]{8})|hsla?\\(\\s*(?:${dt}|${te})\\s*\\)|hwb\\(\\s*${dt}\\s*\\)|rgba?\\(\\s*(?:${kt}|${ee})\\s*\\)|(?:ok)?lab\\(\\s*${Et}\\s*\\)|(?:ok)?lch\\(\\s*${It}\\s*\\)|color\\(\\s*${zt}\\s*\\)`,Vt=`(?:${se})(?:\\s+${j})?`,ye=`color-mix\\(\\s*in\\s+(${Fe})\\s*,\\s*(${Vt})\\s*,\\s*(${Vt})\\s*\\)`,H=/^currentColor$/i,Rt={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]},J=(t,x={})=>{if(!Array.isArray(t))throw new TypeError(`Expected Array but got ${L(t)}.`);let{alpha:a=!1,minLength:o=nt,maxLength:e=K,minRange:s=0,maxRange:r=1,validateRange:n=!0}=x;if(typeof o!="number")throw new TypeError(`Expected Number but got ${L(o)}.`);if(Number.isNaN(o))throw new TypeError(`${o} is not a number.`);if(typeof e!="number")throw new TypeError(`Expected Number but got ${L(e)}.`);if(Number.isNaN(e))throw new TypeError(`${e} is not a number.`);if(typeof s!="number")throw new TypeError(`Expected Number but got ${L(s)}.`);if(Number.isNaN(s))throw new TypeError(`${s} is not a number.`);if(typeof r!="number")throw new TypeError(`Expected Number but got ${L(r)}.`);if(Number.isNaN(r))throw new TypeError(`${r} is not a number.`);let l=t.length;if(l<o||l>e){let i;throw o===e?i=`Expected array length of ${e} but got ${l}.`:i=`Expected array length of ${o} or ${e} but got ${l}.`,new Error(i)}let h=0;for(;h<l;){let i=t[h];if(typeof i!="number")throw new TypeError(`Expected Number but got ${L(i)}.`);if(Number.isNaN(i))throw new TypeError(`${i} is not a number.`);if(h<nt&&n&&(i<s||i>r))throw new RangeError(`${i} is not between ${s} and ${r}.`);if(h===nt&&(i<0||i>1))throw new RangeError(`${i} is not between 0 and 1.`);h++}return a&&l===nt&&t.push(1),t},O=(t,x)=>{if(Array.isArray(t)){if(t.length!==nt)throw new Error(`Expected array length of 3 but got ${t.length}.`);for(let X of t)X=J(X,{maxLength:nt,validateRange:!1})}else throw new TypeError(`Expected Array but got ${L(t)}.`);let[[a,o,e],[s,r,n],[l,h,i]]=t,[E,c,A]=J(x,{maxLength:nt,validateRange:!1}),p=a*E+o*c+e*A,$=s*E+r*c+n*A,W=l*E+h*c+i*A;return[p,$,W]},C=(t,x=[])=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let[a,o,e,s]=x,r,n,l,h;if(/none/.test(t)){let i=new RegExp(`^rgba?\\(\\s*(${kt})\\s*\\)$`),E=new RegExp(`^color\\(\\s*(${zt})\\s*\\)$`),c=new RegExp(`^h(?:sla?|wb)\\(\\s*(${dt})\\s*\\)$`),A=new RegExp(`^(?:ok)?lab\\(\\s*(${Et})\\s*\\)$`),p=new RegExp(`^(?:ok)?lch\\(\\s*(${It})\\s*\\)$`);i.test(t)?[r,n,l,h]=t.match(i)[1].replace("/"," ").split(/\s+/):E.test(t)?[,r,n,l,h]=t.match(E)[1].replace("/"," ").split(/\s+/):t.startsWith("hsl")&&c.test(t)?[l,n,r,h]=t.match(c)[1].replace("/"," ").split(/\s+/):t.startsWith("hwb")&&c.test(t)?[l,,,h]=t.match(c)[1].replace("/"," ").split(/\s+/):A.test(t)?[r,,,h]=t.match(A)[1].replace("/"," ").split(/\s+/):p.test(t)&&([r,n,l,h]=t.match(p)[1].replace("/"," ").split(/\s+/))}return[r===b?r:a,n===b?n:o,l===b?l:e,h===b?h:s]},st=(t,x)=>{if(Array.isArray(t)){if(t.length!==K)throw new Error(`Expected array length of 4 but got ${t.length}.`)}else throw new TypeError(`Expected Array but got ${L(t)}.`);if(Array.isArray(x)){if(x.length!==K)throw new Error(`Expected array length of 4 but got ${x.length}.`)}else throw new TypeError(`Expected Array but got ${L(x)}.`);let a=0;for(;a<K;)t[a]===b&&x[a]===b?(t[a]=0,x[a]=0):t[a]===b?t[a]=x[a]:x[a]===b&&(x[a]=t[a]),a++;return t=J(t,{minLength:K,validateRange:!1}),x=J(x,{minLength:K,validateRange:!1}),[t,x]},ot=t=>{if(typeof t!="number")throw new TypeError(`Expected Number but got ${L(t)}.`);if(Number.isNaN(t))throw new TypeError(`${t} is not a number.`);if(t=Math.round(t),t<0||t>M)throw new RangeError(`${t} is not between 0 and ${M}.`);let x=t.toString(G);return x.length===1&&(x=`0${x}`),x},Ct=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=q/400,a=q/(Math.PI*$t),o=new RegExp(`^(${Z})(${Bt})?$`);if(!o.test(t))throw new Error(`Invalid property value: ${t}`);let[,e,s]=t.match(o),r=e.startsWith(".")?`0${e}`:e,n;switch(s){case"grad":n=parseFloat(r)*x;break;case"rad":n=parseFloat(r)*a;break;case"turn":n=parseFloat(r)*q;break;default:n=parseFloat(r)}return n%=q,n<0&&(n+=q),n},Xt=t=>{let[x,a,o]=J(t,{maxLength:nt,maxRange:M}),e=x/M,s=a/M,r=o/M,n=.04045;return e>n?e=Math.pow((e+v)/(1+v),bt):e/=Ft,s>n?s=Math.pow((s+v)/(1+v),bt):s/=Ft,r>n?r=Math.pow((r+v)/(1+v),bt):r/=Ft,[e,s,r]},Wt=t=>{let[x,a,o,e]=J(t,{alpha:!0,maxRange:M}),[s,r,n]=Xt([x,a,o]),[l,h,i]=O(Nt,[s,r,n]);return[l,h,i,e]};var _t=t=>{let[x,a,o,e]=J(t,{alpha:!0,maxRange:M}),s=ot(x),r=ot(a),n=ot(o),l=ot(e*M),h;return l==="ff"?h=`#${s}${r}${n}`:h=`#${s}${r}${n}${l}`,h},Pt=t=>{let[x,a,o]=J(t,{maxLength:nt}),e=809/258400;return x>e?x=Math.pow(x,1/bt)*(1+v)-v:x*=Ft,a>e?a=Math.pow(a,1/bt)*(1+v)-v:a*=Ft,o>e?o=Math.pow(o,1/bt)*(1+v)-v:o*=Ft,[Math.round(x*M),Math.round(a*M),Math.round(o*M)]},we=t=>{let[x,a,o,e]=J(t,{minLength:K});[x,a,o]=Pt([x,a,o]);let s=ot(x),r=ot(a),n=ot(o),l=ot(e*M),h;return l==="ff"?h=`#${s}${r}${n}`:h=`#${s}${r}${n}${l}`,h},re=t=>{let[x,a,o,e]=J(t,{minLength:K,validateRange:!1}),[s,r,n]=O(Lt,[x,a,o]);return we([Math.min(Math.max(s,0),1),Math.min(Math.max(r,0),1),Math.min(Math.max(n,0),1),e])};var at=t=>{let[x,a,o,e]=J(t,{validateRange:!1}),[s,r,n]=O(Lt,[x,a,o]);return[s,r,n]=Pt([Math.min(Math.max(s,0),1),Math.min(Math.max(r,0),1),Math.min(Math.max(n,0),1)]),[s,r,n,e]},oe=t=>{let[x,a,o,e]=J(t,{validateRange:!1}),[s,r,n]=O(tt,[x,a,o]);return[s,r,n,e]},xt=t=>{let[x,a,o,e]=at(t),s=x/M,r=a/M,n=o/M,l=Math.max(s,r,n),h=Math.min(s,r,n),i=l-h,E=(l+h)*et*R,c,A;if(Math.round(E)===0||Math.round(E)===R)c=b,A=b;else if(A=i/(1-Math.abs(l+h-1))*R,A===0)c=b;else{switch(l){case s:c=(r-n)/i;break;case r:c=(n-s)/i+$t;break;case n:default:c=(s-r)/i+K;break}c=c*rt%q,c<0&&(c+=q)}return[c,A,E,e]},ht=t=>{let[x,a,o,e]=at(t),s=Math.min(x,a,o)/M,r=1-Math.max(x,a,o)/M,n;return s+r===1?n=b:[n]=xt(t),[n,s*R,r*R,e]},lt=t=>{let[x,a,o,e]=J(t,{validateRange:!1}),r=O(fe,[x,a,o]).map(E=>Math.cbrt(E)),[n,l,h]=O(he,r);n=Math.min(Math.max(n,0),1);let i=Math.round(parseFloat(n.toFixed(K))*R);return(i===0||i===R)&&(l=b,h=b),[n,l,h,e]},pt=t=>{let[x,a,o,e]=lt(t),s,r,n=Math.round(parseFloat(x.toFixed(K))*R);return n===0||n===R?(s=b,r=b):(s=Math.max(Math.sqrt(Math.pow(a,Tt)+Math.pow(o,Tt)),0),parseFloat(s.toFixed(K))===0?r=b:(r=Math.atan2(o,a)*q*et/Math.PI,r<0&&(r+=q))),[x,s,r,e]},ne=t=>{let[x,a,o,e]=J(t,{minLength:K,validateRange:!1}),s=O(wt,[x,a,o]),[r,n,l]=at(s);return[r,n,l,e]},ct=t=>{let[x,a,o,e]=J(t,{validateRange:!1}),s=[x,a,o].map((c,A)=>c/jt[A]),[r,n,l]=s.map(c=>c>Dt?Math.cbrt(c):(c*Mt+G)/yt),h=Math.min(Math.max(yt*n-G,0),R),i,E;return h===0||h===R?(i=b,E=b):(i=(r-n)*Zt,E=(n-l)*Ut),[h,i,E,e]},gt=t=>{let[x,a,o,e]=ct(t),s,r;return x===0||x===R?(s=b,r=b):(s=Math.max(Math.sqrt(Math.pow(a,Tt)+Math.pow(o,Tt)),0),parseFloat(s.toFixed(K))===0?r=b:(r=Math.atan2(o,a)*q*et/Math.PI,r<0&&(r+=q))),[x,s,r,e]},ut=t=>{if(Y(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${L(t)}.`);if(!(/^#[\da-f]{6}$/.test(t)||/^#[\da-f]{3}$/.test(t)||/^#[\da-f]{8}$/.test(t)||/^#[\da-f]{4}$/.test(t)))throw new Error(`Invalid property value: ${t}`);let x=[];if(/^#[\da-f]{6}$/.test(t)){let[,a,o,e]=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);x.push(parseInt(a,G),parseInt(o,G),parseInt(e,G),1)}else if(/^#[\da-f]{3}$/.test(t)){let[,a,o,e]=t.match(/^#([\da-f])([\da-f])([\da-f])$/);x.push(parseInt(`${a}${a}`,G),parseInt(`${o}${o}`,G),parseInt(`${e}${e}`,G),1)}else if(/^#[\da-f]{8}$/.test(t)){let[,a,o,e,s]=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);x.push(parseInt(a,G),parseInt(o,G),parseInt(e,G),parseInt(s,G)/M)}else if(/^#[\da-f]{4}$/.test(t)){let[,a,o,e,s]=t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])$/);x.push(parseInt(`${a}${a}`,G),parseInt(`${o}${o}`,G),parseInt(`${e}${e}`,G),parseInt(`${s}${s}`,G)/M)}return x},de=t=>{let[x,a,o,e]=ut(t),[s,r,n]=Xt([x,a,o]);return[s,r,n,e]},Ee=t=>{let[x,a,o,e]=de(t),[s,r,n]=O(Nt,[x,a,o]);return[s,r,n,e]},it=t=>{if(Y(t))if(t=t.trim(),!t)t=1;else if(t===b)t=0;else{if(t.startsWith(".")&&(t=`0${t}`),t.endsWith("%")?t=parseFloat(t)/R:t=parseFloat(t),Number.isNaN(t))throw new TypeError(`${t} is not a number.`);(t<0||t>1)&&(t=Math.min(Math.max(t,0),1))}else t=1;return t},ae=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=new RegExp(`^rgba?\\(\\s*(${kt}|${ee})\\s*\\)$`);if(!x.test(t))throw new Error(`Invalid property value: ${t}`);let[,a]=t.match(x),[o,e,s,r]=a.replace(/[,/]/g," ").split(/\s+/);return o===b?o=0:(o.startsWith(".")&&(o=`0${o}`),o.endsWith("%")?o=parseFloat(o)*M/R:o=parseFloat(o)),e===b?e=0:(e.startsWith(".")&&(e=`0${e}`),e.endsWith("%")?e=parseFloat(e)*M/R:e=parseFloat(e)),s===b?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?s=parseFloat(s)*M/R:s=parseFloat(s)),r=it(r),[Math.min(Math.max(o,0),M),Math.min(Math.max(e,0),M),Math.min(Math.max(s,0),M),r]},St=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=new RegExp(`^hsla?\\(\\s*(${dt}|${te})\\s*\\)$`);if(!x.test(t))throw new Error(`Invalid property value: ${t}`);let[,a]=t.match(x),[o,e,s,r]=a.replace(/[,/]/g," ").split(/\s+/);o===b?o=0:o=Ct(o),e===b?e=0:(e.startsWith(".")&&(e=`0${e}`),e=Math.min(Math.max(parseFloat(e),0),R)),s===b?s=0:(s.startsWith(".")&&(s=`0${s}`),s=Math.min(Math.max(parseFloat(s),0),R)),r=it(r);let n,l;s<R*et?(n=(s+s*(e/R))*M/R,l=(s-s*(e/R))*M/R):(n=(s+(R-s)*(e/R))*M/R,l=(s-(R-s)*(e/R))*M/R);let h=(n-l)/rt,i,E,c;return o>=0&&o<rt?(i=n,E=o*h+l,c=l):o<rt*$t?(i=(rt*$t-o)*h+l,E=n,c=l):o<q*et?(i=l,E=n,c=(o-rt*$t)*h+l):o<rt*K?(i=l,E=(rt*K-o)*h+l,c=n):o<q-rt?(i=(o-rt*K)*h+l,E=l,c=n):o<q&&(i=n,E=l,c=(q-o)*h+l),[Math.min(Math.max(i,0),M),Math.min(Math.max(E,0),M),Math.min(Math.max(c,0),M),r]},ie=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=new RegExp(`^hwb\\(\\s*(${dt})\\s*\\)$`);if(!x.test(t))throw new Error(`Invalid property value: ${t}`);let[,a]=t.match(x),[o,e,s,r]=a.replace("/"," ").split(/\s+/);o===b?o=0:o=Ct(o),e===b?e=0:(e.startsWith(".")&&(e=`0${e}`),e=Math.min(Math.max(parseFloat(e),0),R)/R),s===b?s=0:(s.startsWith(".")&&(s=`0${s}`),s=Math.min(Math.max(parseFloat(s),0),R)/R),r=it(r);let n=[];if(e+s>=1){let l=e/(e+s)*M;n.push(l,l,l,r)}else{let[l,h,i]=St(`hsl(${o} 100% 50%)`),E=(1-e-s)/M;n.push((l*E+e)*M,(h*E+e)*M,(i*E+e)*M,r)}return n},Ht=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=new RegExp(`^lab\\(\\s*(${Et})\\s*\\)$`);if(!x.test(t))throw new Error(`Invalid property value: ${t}`);let a=1.25,o=8,[,e]=t.match(x),[s,r,n,l]=e.replace("/"," ").split(/\s+/);s===b?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?(s=parseFloat(s),s>R&&(s=R)):s=parseFloat(s),s<0&&(s=0)),r===b?r=0:(r.startsWith(".")&&(r=`0${r}`),r.endsWith("%")?r=parseFloat(r)*a:r=parseFloat(r)),n===b?n=0:n.endsWith("%")?n=parseFloat(n)*a:n=parseFloat(n),l=it(l);let h=(s+G)/yt,i=r/Zt+h,E=h-n/Ut,c=Math.pow(h,mt),A=Math.pow(i,mt),p=Math.pow(E,mt),$=[A>Dt?A:(i*yt-G)/Mt,s>o?c:s/Mt,p>Dt?p:(E*yt-G)/Mt],[W,X,I]=$.map((S,w)=>S*jt[w]);return[W,X,I,l]},xe=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=new RegExp(`^lch\\(\\s*(${It})\\s*\\)$`);if(!x.test(t))throw new Error(`Invalid property value: ${t}`);let a=1.5,[,o]=t.match(x),[e,s,r,n]=o.replace("/"," ").split(/\s+/);e===b?e=0:(e.startsWith(".")&&(e=`0${e}`),e=parseFloat(e),e<0&&(e=0)),s===b?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?s=parseFloat(s)*a:s=parseFloat(s)),r===b?r=0:r=Ct(r),n=it(n);let l=s*Math.cos(r*Math.PI/(q*et)),h=s*Math.sin(r*Math.PI/(q*et)),[i,E,c]=Ht(`lab(${e} ${l} ${h})`);return[i,E,c,n]},le=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=new RegExp(`^oklab\\(\\s*(${Et})\\s*\\)$`);if(!x.test(t))throw new Error(`Invalid property value: ${t}`);let a=.4,[,o]=t.match(x),[e,s,r,n]=o.replace("/"," ").split(/\s+/);e===b?e=0:(e.startsWith(".")&&(e=`0${e}`),e.endsWith("%")?e=parseFloat(e)/R:e=parseFloat(e),e<0&&(e=0)),s===b?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?s=parseFloat(s)*a/R:s=parseFloat(s)),r===b?r=0:r.endsWith("%")?r=parseFloat(r)*a/R:r=parseFloat(r),n=it(n);let h=O(Qt,[e,s,r]).map(A=>Math.pow(A,mt)),[i,E,c]=O(Kt,h);return[i,E,c,n]},ce=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x=new RegExp(`^oklch\\(\\s*(${Et})\\s*\\)$`);if(!x.test(t))throw new Error(`Invalid property value: ${t}`);let a=.4,[,o]=t.match(x),[e,s,r,n]=o.replace("/"," ").split(/\s+/);e===b?e=0:(e.startsWith(".")&&(e=`0${e}`),e.endsWith("%")?e=parseFloat(e)/R:e=parseFloat(e),e<0&&(e=0)),s===b?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?s=parseFloat(s)*a/R:s=parseFloat(s),s<0&&(s=0)),r===b?r=0:r=Ct(r),n=it(n);let l=s*Math.cos(r*Math.PI/(q*et)),h=s*Math.sin(r*Math.PI/(q*et)),E=O(Qt,[e,l,h]).map($=>Math.pow($,mt)),[c,A,p]=O(Kt,E);return[c,A,p,n]},V=(t,x=!1)=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let a=new RegExp(`^color\\(\\s*(${zt})\\s*\\)$`);if(!a.test(t))throw new Error(`Invalid property value: ${t}`);let[,o]=t.match(a),[e,s,r,n,l]=o.replace("/"," ").split(/\s+/),h,i,E;if(s===b)h=0;else{let W;s.startsWith(".")?W=`0${s}`:W=s,h=W.endsWith("%")?parseFloat(W)/R:parseFloat(W)}if(r===b)i=0;else{let W;r.startsWith(".")?W=`0${r}`:W=r,i=W.endsWith("%")?parseFloat(W)/R:parseFloat(W)}if(n===b)E=0;else{let W;n.startsWith(".")?W=`0${n}`:W=n,E=W.endsWith("%")?parseFloat(W)/R:parseFloat(W)}let c=it(l),A,p,$;if(e==="srgb")[A,p,$]=Wt([h*M,i*M,E*M]),x&&([A,p,$]=O(tt,[A,p,$]));else if(e==="srgb-linear")[A,p,$]=O(Nt,[h,i,E]),x&&([A,p,$]=O(tt,[A,p,$]));else if(e==="display-p3"){let W=Xt([h*M,i*M,E*M]);[A,p,$]=O(pe,W),x&&([A,p,$]=O(tt,[A,p,$]))}else if(e==="rec2020"){let W=1.09929682680944,X=.018053968510807,I=.45,S=[h,i,E].map(w=>{let f;return w<X*I*qt?f=w/(I*qt):f=Math.pow((w+W-1)/W,1/I),f});[A,p,$]=O(ge,S),x&&([A,p,$]=O(tt,[A,p,$]))}else if(e==="a98-rgb"){let W=2.19921875,X=[h,i,E].map(I=>Math.pow(I,W));[A,p,$]=O($e,X),x&&([A,p,$]=O(tt,[A,p,$]))}else if(e==="prophoto-rgb"){let X=[h,i,E].map(I=>{let S;return I>1/(G*$t)?S=Math.pow(I,1.8):S=I/G,S});[A,p,$]=O(be,X),x||([A,p,$]=O(wt,[A,p,$]))}else/^xyz(?:-d(?:50|65))?$/.test(e)&&([A,p,$]=[h,i,E],e==="xyz-d50"?x||([A,p,$]=O(wt,[A,p,$])):x&&([A,p,$]=O(tt,[A,p,$])));return[A,p,$,c]},U=(t,x=!1)=>{if(Y(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let a,o,e,s;if(H.test(t))a=0,o=0,e=0,s=0;else if(/^[a-z]+$/.test(t))if(Object.prototype.hasOwnProperty.call(Rt,t)){let[r,n,l]=Rt[t];s=1,[a,o,e]=Wt([r,n,l]),x&&([a,o,e]=O(tt,[a,o,e]))}else if(t==="transparent")a=0,o=0,e=0,s=0;else throw new Error(`Invalid property value: ${t}`);else if(t.startsWith("#")){let r;if(/^#[\da-f]{6}$/.test(t))r=t;else if(/^#[\da-f]{3}$/.test(t)){let[,n,l,h]=t.match(/^#([\da-f])([\da-f])([\da-f])$/);r=`#${n}${n}${l}${l}${h}${h}`}else if(/^#[\da-f]{8}$/.test(t))r=t;else if(/^#[\da-f]{4}$/.test(t)){let[,n,l,h,i]=t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])$/);r=`#${n}${n}${l}${l}${h}${h}${i}${i}`}else throw new Error(`Invalid property value: ${t}`);[a,o,e,s]=Ee(r),x&&([a,o,e]=O(tt,[a,o,e]))}else if(t.startsWith("lab"))[a,o,e,s]=Ht(t),x||([a,o,e]=O(wt,[a,o,e]));else if(t.startsWith("lch"))[a,o,e,s]=xe(t),x||([a,o,e]=O(wt,[a,o,e]));else if(t.startsWith("oklab"))[a,o,e,s]=le(t),x&&([a,o,e]=O(tt,[a,o,e]));else if(t.startsWith("oklch"))[a,o,e,s]=ce(t),x&&([a,o,e]=O(tt,[a,o,e]));else{let r,n,l;if(t.startsWith("rgb"))[r,n,l,s]=ae(t);else if(t.startsWith("hsl"))[r,n,l,s]=St(t);else if(t.startsWith("hwb"))[r,n,l,s]=ie(t);else throw new Error(`Invalid property value: ${t}`);[a,o,e]=Wt([r,n,l]),x&&([a,o,e]=O(tt,[a,o,e]))}return[a,o,e,s]},Ot=(t,x={})=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let{alpha:a}=x,o,e,s,r;t.startsWith("color(")?[o,e,s,r]=V(t):[o,e,s,r]=U(t);let[n,l,h]=O(Lt,[o,e,s]);n=Math.min(Math.max(n,0),1),l=Math.min(Math.max(l,0),1),h=Math.min(Math.max(h,0),1);let i=[n,l,h];return a?i.push(r):i.push(1),i},At=t=>{let[x,a,o,e]=Ot(t,{alpha:!0});return[x,a,o]=Pt([x,a,o]),[x,a,o,e]},ft=t=>{if(Y(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let x,a,o,e;if(H.test(t))x=0,a=0,o=0,e=0;else if(/^[a-z]+$/i.test(t))Object.prototype.hasOwnProperty.call(Rt,t)?([x,a,o]=Rt[t],e=1):t==="transparent"&&(x=0,a=0,o=0,e=0);else if(t.startsWith("#"))[x,a,o,e]=ut(t);else if(/^l(?:ab|ch)/.test(t)){let r,n,l;t.startsWith("lab")?[r,n,l,e]=Ht(t):[r,n,l,e]=xe(t),[x,a,o,e]=ne([r,n,l,e])}else if(/^okl(?:ab|ch)/.test(t)){let r,n,l;t.startsWith("oklab")?[r,n,l,e]=le(t):[r,n,l,e]=ce(t),[x,a,o,e]=at([r,n,l,e])}else t.startsWith("rgb")?[x,a,o,e]=ae(t):t.startsWith("hsl")?[x,a,o,e]=St(t):t.startsWith("hwb")&&([x,a,o,e]=ie(t));let s;return isNaN(x)||isNaN(a)||isNaN(o)||isNaN(e)?s=[]:s=[Math.round(x),Math.round(a),Math.round(o),e],s},Gt=t=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);if(!new RegExp(`^color\\(\\s*${zt}\\s*\\)$`).test(t))throw new Error(`Invalid property value: ${t}`);let[a,o,e,s]=V(t),[r,n,l]=at([a,o,e]);return[r,n,l,s]},Yt=(t,x={})=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let a=new RegExp(`^${ye}$`,"i");if(!a.test(t))throw new Error(`Invalid property value: ${t}`);let o="lch(none none none / none)",e="rgb(none none none / none)",s=new RegExp(`^(${se})(?:\\s+(${j}))?$`,"i"),r=new RegExp(b),[,n,l,h]=t.match(a),[,i,E]=l.match(s),[,c,A]=h.match(s),p,$,W;if(E&&A){let f=parseFloat(E)/R,g=parseFloat(A)/R;if(f<0||f>1)throw new RangeError(`${E} is not between 0% and 100%.`);if(g<0||g>1)throw new RangeError(`${A} is not between 0% and 100%.`);let d=f+g;if(d===0)throw new Error(`Invalid property value: ${t}`);p=f/d,$=g/d,W=d<1?d:1}else{if(E){if(p=parseFloat(E)/R,p<0||p>1)throw new RangeError(`${E} is not between 0% and 100%.`);$=1-p}else if(A){if($=parseFloat(A)/R,$<0||$>1)throw new RangeError(`${A} is not between 0% and 100%.`);p=1-$}else p=et,$=et;W=1}let X,I,S,w;if(n==="srgb"){let f=At(i,{alpha:!0}),g=At(c,{alpha:!0});H.test(i)?f=C(e,f):r.test(i)&&(f=C(i,f)),H.test(c)?g=C(e,g):r.test(c)&&(g=C(c,g));let[[d,m,F,z],[T,y,D,k]]=st(f,g),_=z*p,B=k*$;w=_+B,w===0?(X=d*p+T*$,I=m*p+y*$,S=F*p+D*$):(X=(d*_+T*B)/w,I=(m*_+y*B)/w,S=(F*_+D*B)/w)}else if(n==="srgb-linear"){let f=Ot(i,{alpha:!0}),g=Ot(c,{alpha:!0});H.test(i)?f=C(e,f):r.test(i)&&(f=C(i,f)),H.test(c)?g=C(e,g):r.test(c)&&(g=C(c,g));let[[d,m,F,z],[T,y,D,k]]=st(f,g),_=z*p,B=k*$;w=_+B,w===0?(X=(d*p+T*$)*M,I=(m*p+y*$)*M,S=(F*p+D*$)*M):(X=(d*_+T*B)*w*M,I=(m*_+y*B)*w*M,S=(F*_+D*B)*w*M)}else if(/^xyz(?:-d65)?$/.test(n)){let f,g;i.startsWith("color(")?f=V(i):f=U(i),c.startsWith("color(")?g=V(c):g=U(c),H.test(i)?f=C(e,f):r.test(i)&&(f=C(i,f)),H.test(c)?g=C(e,g):r.test(c)&&(g=C(c,g));let[[d,m,F,z],[T,y,D,k]]=st(f,g),_=z*p,B=k*$;w=_+B;let N,u,P;w===0?(N=d*p+T*$,u=m*p+y*$,P=F*p+D*$):(N=(d*_+T*B)*w,u=(m*_+y*B)*w,P=(F*_+D*B)*w),[X,I,S]=at([N,u,P])}else if(n==="xyz-d50"){let f,g;i.startsWith("color(")?f=V(i,!0):f=U(i,!0),c.startsWith("color(")?g=V(c,!0):g=U(c,!0),H.test(i)?f=C(e,f):r.test(i)&&(f=C(i,f)),H.test(c)?g=C(e,g):r.test(c)&&(g=C(c,g));let[[d,m,F,z],[T,y,D,k]]=st(f,g),_=z*p,B=k*$;w=_+B;let N,u,P;w===0?(N=d*p+T*$,u=m*p+y*$,P=F*p+D*$):(N=(d*_+T*B)*w,u=(m*_+y*B)*w,P=(F*_+D*B)*w),[X,I,S]=ne([N,u,P,w])}else if(n==="hsl"){let f,g,d,m;if(i.startsWith("color(")){let u=V(i);[f,g,d,m]=xt(u)}else{let u=U(i);[f,g,d,m]=xt(u)}let F,z,T,y;if(c.startsWith("color(")){let u=V(c);[F,z,T,y]=xt(u)}else{let u=U(c);[F,z,T,y]=xt(u)}H.test(i)?[d,g,f,m]=C(o,[d,g,f,m]):r.test(i)&&([d,g,f,m]=C(i,[d,g,f,m])),H.test(c)?[T,z,F,y]=C(o,[T,z,F,y]):r.test(c)&&([T,z,F,y]=C(c,[T,z,F,y])),[[f,g,d,m],[F,z,T,y]]=st([f,g,d,m],[F,z,T,y]);let D=m*p,k=y*$;w=D+k;let _=(f*p+F*$)%q,B,N;w===0?(B=g*p+z*$,N=d*p+T*$):(B=(g*D+z*k)/w,N=(d*D+T*k)/w),[X,I,S]=At(`hsl(${_} ${B}% ${N}%)`)}else if(n==="hwb"){let f,g,d,m;if(i.startsWith("color(")){let P=V(i);[f,g,d,m]=ht(P)}else{let P=U(i);[f,g,d,m]=ht(P)}let F,z,T,y;if(c.startsWith("color(")){let P=V(c);[F,z,T,y]=ht(P)}else{let P=U(c);[F,z,T,y]=ht(P)}H.test(i)?[,,f,m]=C(o,[null,null,f,m]):r.test(i)&&([,,f,m]=C(i,[null,null,f,m])),H.test(c)?[,,F,y]=C(o,[null,null,F,y]):r.test(c)&&([,,F,y]=C(c,[null,null,F,y])),[[f,g,d,m],[F,z,T,y]]=st([f,g,d,m],[F,z,T,y]);let D=m*p,k=y*$;w=D+k;let _=(f*p+F*$)%q,B,N;w===0?(B=g*p+z*$,N=d*p+T*$):(B=(g*D+z*k)/w,N=(d*D+T*k)/w),[X,I,S]=At(`hwb(${_} ${B}% ${N}%)`)}else if(n==="lab"){let f,g,d,m;if(i.startsWith("color(")){let u=V(i,!0);[f,g,d,m]=ct(u)}else{let u=U(i,!0);[f,g,d,m]=ct(u)}let F,z,T,y;if(c.startsWith("color(")){let u=V(c,!0);[F,z,T,y]=ct(u)}else{let u=U(c,!0);[F,z,T,y]=ct(u)}H.test(i)?[f,,,m]=C(o,[f,null,null,m]):r.test(i)&&([f,,,m]=C(i,[f,null,null,m])),H.test(c)?[F,,,y]=C(o,[F,null,null,y]):r.test(c)&&([F,,,y]=C(c,[F,null,null,y])),[[f,g,d,m],[F,z,T,y]]=st([f,g,d,m],[F,z,T,y]);let D=m*p,k=y*$;w=D+k;let _,B,N;w===0?(_=f*p+F*$,B=g*p+z*$,N=d*p+T*$):(_=(f*D+F*k)*w,B=(g*D+z*k)*w,N=(d*D+T*k)*w),[X,I,S]=ft(`lab(${_} ${B} ${N})`)}else if(n==="lch"){let f,g;if(i.startsWith("color(")){let Q=V(i,!0);f=gt(Q)}else{let Q=U(i,!0);f=gt(Q)}if(c.startsWith("color(")){let Q=V(c,!0);g=gt(Q)}else{let Q=U(c,!0);g=gt(Q)}H.test(i)?f=C(o,f):r.test(i)&&(f=C(i,f)),H.test(c)?g=C(o,g):r.test(c)&&(g=C(c,g));let[[d,m,F,z],[T,y,D,k]]=st(f,g),_=z*p,B=k*$;w=_+B;let N,u,P;w===0?(N=d*p+T*$,u=m*p+y*$,P=F*p+D*$):(N=(d*_+T*B)*w,u=(m*_+y*B)*w,P=(F*_+D*B)*w),[X,I,S]=ft(`lch(${N} ${u} ${P})`)}else if(n==="oklab"){let f,g,d,m;if(i.startsWith("color(")){let u=V(i);[f,g,d,m]=lt(u)}else{let u=U(i);[f,g,d,m]=lt(u)}let F,z,T,y;if(c.startsWith("color(")){let u=V(c);[F,z,T,y]=lt(u)}else{let u=U(c);[F,z,T,y]=lt(u)}H.test(i)?[f,,,m]=C(o,[f,null,null,m]):r.test(i)&&([f,,,m]=C(i,[f,null,null,m])),H.test(c)?[f,,,y]=C(o,[F,null,null,y]):r.test(c)&&([F,,,y]=C(c,[F,null,null,y])),[[f,g,d,m],[F,z,T,y]]=st([f,g,d,m],[F,z,T,y]);let D=m*p,k=y*$;w=D+k;let _,B,N;w===0?(_=f*p+F*$,B=g*p+z*$,N=d*p+T*$):(_=(f*D+F*k)*w,B=(g*D+z*k)*w,N=(d*D+T*k)*w),[X,I,S]=ft(`oklab(${_} ${B} ${N})`)}else if(n==="oklch"){let f,g;if(i.startsWith("color(")){let Q=V(i,!0);f=pt(Q)}else{let Q=U(i,!0);f=pt(Q)}if(c.startsWith("color(")){let Q=V(c,!0);g=pt(Q)}else{let Q=U(c,!0);g=pt(Q)}H.test(i)?f=C(o,f):r.test(i)&&(f=C(i,f)),H.test(c)?g=C(o,g):r.test(c)&&(g=C(c,g)),r.test(i)&&(f=C(i,f)),r.test(c)&&(g=C(c,g));let[[d,m,F,z],[T,y,D,k]]=st(f,g),_=z*p,B=k*$;w=_+B;let N,u,P;w===0?(N=d*p+T*$,u=m*p+y*$,P=F*p+D*$):(N=(d*_+T*B)*w,u=(m*_+y*B)*w,P=(F*_+D*B)*w),[X,I,S]=ft(`oklch(${N} ${u} ${P})`)}return[X,I,S,w*W]};var ze=(t,x={})=>{if(Y(t))t=t.trim();else throw new TypeError(`Expected String but got ${L(t)}.`);let{currentColor:a,format:o,key:e}=x,s,r,n,l;/^currentcolor$/i.test(t)?a?a.startsWith("color-mix")?[s,r,n,l]=Yt(a):a.startsWith("color(")?[s,r,n,l]=Gt(a):[s,r,n,l]=ft(a):(s=0,r=0,n=0,l=0):/^transparent$/i.test(t)?(s=0,r=0,n=0,l=0):t.startsWith("color-mix")?[s,r,n,l]=Yt(t):t.startsWith("color(")?[s,r,n,l]=Gt(t):[s,r,n,l]=ft(t);let h;switch(o){case"array":{e?h=[e,[s,r,n,l]]:h=[s,r,n,l];break}case"hex":{let i;/^transparent$/i.test(t)||isNaN(s)||isNaN(r)||isNaN(n)?i=null:i=_t([s,r,n]),e?h=[e,i]:h=i;break}case"hexAlpha":{let i;/^transparent$/i.test(t)?i="#00000000":isNaN(s)||isNaN(r)||isNaN(n)||isNaN(l)?i=null:i=_t([s,r,n,l]),e?h=[e,i]:h=i;break}default:{let i;isNaN(s)||isNaN(r)||isNaN(n)||isNaN(l)?i="":(s=Math.round(s),r=Math.round(r),n=Math.round(n),l===1?i=`rgb(${s}, ${r}, ${n})`:i=`rgba(${s}, ${r}, ${n}, ${l})`),e?h=[e,i]:h=i}}return h},Ce=(t,x={})=>{if(Y(t)){if(t=t.trim(),t.startsWith("color-mix("))throw new Error("color-mix() is not supported.")}else throw new TypeError(`Expected String but got ${L(t)}.`);let{d50:a}=x,o;return t.startsWith("color(")?o=V(t,a):o=U(t,a),o},_e={hexToRgb:ut,numberToHex:ot,rgbToHex:_t,xyzD50ToLab:ct,xyzD50ToLch:gt,xyzToHex:re,xyzToHsl:xt,xyzToHwb:ht,xyzToOklab:lt,xyzToOklch:pt,xyzToRgb:at,xyzToXyzD50:oe};export{_e as convert,Ce as parse,ze as resolve}; | ||
var pt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,te=new Set,Nt=typeof process=="object"&&process?process:{},ee=(t,s,i,r)=>{typeof Nt.emitWarning=="function"?Nt.emitWarning(t,s,i,r):console.error(`[${i}] ${s}: ${t}`)},Tt=globalThis.AbortController,Jt=globalThis.AbortSignal;if(typeof Tt>"u"){Jt=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(r,e){this._onabort.push(e)}},Tt=class{constructor(){s()}signal=new Jt;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let e of this.signal._onabort)e(r);this.signal.onabort?.(r)}}};let t=Nt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",s=()=>{t&&(t=!1,ee("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",s))}}var Ee=t=>!te.has(t),ke=Symbol("type"),ot=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),se=t=>ot(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?dt:null:null,dt=class extends Array{constructor(s){super(s),this.fill(0)}},kt=class t{heap;length;static#h=!1;static create(s){let i=se(s);if(!i)return[];t.#h=!0;let r=new t(s,i);return t.#h=!1,r}constructor(s,i){if(!t.#h)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(s),this.length=0}push(s){this.heap[this.length++]=s}pop(){return this.heap[--this.length]}},Rt=class t{#h;#f;#g;#u;#C;#S;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#r;#b;#i;#s;#t;#l;#x;#a;#n;#w;#o;#m;#F;#p;#y;#T;#c;static unsafeExposeInternals(s){return{starts:s.#F,ttls:s.#p,sizes:s.#m,keyMap:s.#i,keyList:s.#s,valList:s.#t,next:s.#l,prev:s.#x,get head(){return s.#a},get tail(){return s.#n},free:s.#w,isBackgroundFetch:i=>s.#e(i),backgroundFetch:(i,r,e,n)=>s.#W(i,r,e,n),moveToTail:i=>s.#M(i),indexes:i=>s.#$(i),rindexes:i=>s.#E(i),isStale:i=>s.#d(i)}}get max(){return this.#h}get maxSize(){return this.#f}get calculatedSize(){return this.#b}get size(){return this.#r}get fetchMethod(){return this.#C}get memoMethod(){return this.#S}get dispose(){return this.#g}get disposeAfter(){return this.#u}constructor(s){let{max:i=0,ttl:r,ttlResolution:e=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:h,dispose:f,disposeAfter:l,noDisposeOnSet:d,noUpdateTTL:c,maxSize:w=0,maxEntrySize:g=0,sizeCalculation:p,fetchMethod:R,memoMethod:A,noDeleteOnFetchRejection:D,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:x,ignoreFetchAbort:u}=s;if(i!==0&&!ot(i))throw new TypeError("max option must be a nonnegative integer");let m=i?se(i):Array;if(!m)throw new Error("invalid max value: "+i);if(this.#h=i,this.#f=w,this.maxEntrySize=g||this.#f,this.sizeCalculation=p,this.sizeCalculation){if(!this.#f&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(A!==void 0&&typeof A!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#S=A,R!==void 0&&typeof R!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#C=R,this.#T=!!R,this.#i=new Map,this.#s=new Array(i).fill(void 0),this.#t=new Array(i).fill(void 0),this.#l=new m(i),this.#x=new m(i),this.#a=0,this.#n=0,this.#w=kt.create(i),this.#r=0,this.#b=0,typeof f=="function"&&(this.#g=f),typeof l=="function"?(this.#u=l,this.#o=[]):(this.#u=void 0,this.#o=void 0),this.#y=!!this.#g,this.#c=!!this.#u,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!c,this.noDeleteOnFetchRejection=!!D,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!u,this.maxEntrySize!==0){if(this.#f!==0&&!ot(this.#f))throw new TypeError("maxSize must be a positive integer if specified");if(!ot(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#X()}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!N,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!a,this.ttlResolution=ot(e)||e===0?e:1,this.ttlAutopurge=!!n,this.ttl=r||0,this.ttl){if(!ot(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#B()}if(this.#h===0&&this.ttl===0&&this.#f===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#h&&!this.#f){let y="LRU_CACHE_UNBOUNDED";Ee(y)&&(te.add(y),ee("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",y,t))}}getRemainingTTL(s){return this.#i.has(s)?1/0:0}#B(){let s=new dt(this.#h),i=new dt(this.#h);this.#p=s,this.#F=i,this.#L=(n,o,a=pt.now())=>{if(i[n]=o!==0?a:0,s[n]=o,o!==0&&this.ttlAutopurge){let h=setTimeout(()=>{this.#d(n)&&this.#A(this.#s[n],"expire")},o+1);h.unref&&h.unref()}},this.#R=n=>{i[n]=s[n]!==0?pt.now():0},this.#_=(n,o)=>{if(s[o]){let a=s[o],h=i[o];if(!a||!h)return;n.ttl=a,n.start=h,n.now=r||e();let f=n.now-h;n.remainingTTL=a-f}};let r=0,e=()=>{let n=pt.now();if(this.ttlResolution>0){r=n;let o=setTimeout(()=>r=0,this.ttlResolution);o.unref&&o.unref()}return n};this.getRemainingTTL=n=>{let o=this.#i.get(n);if(o===void 0)return 0;let a=s[o],h=i[o];if(!a||!h)return 1/0;let f=(r||e())-h;return a-f},this.#d=n=>{let o=i[n],a=s[n];return!!a&&!!o&&(r||e())-o>a}}#R=()=>{};#_=()=>{};#L=()=>{};#d=()=>!1;#X(){let s=new dt(this.#h);this.#b=0,this.#m=s,this.#z=i=>{this.#b-=s[i],s[i]=0},this.#N=(i,r,e,n)=>{if(this.#e(r))return 0;if(!ot(e))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(e=n(r,i),!ot(e))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return e},this.#O=(i,r,e)=>{if(s[i]=r,this.#f){let n=this.#f-s[i];for(;this.#b>n;)this.#D(!0)}this.#b+=s[i],e&&(e.entrySize=r,e.totalCalculatedSize=this.#b)}}#z=s=>{};#O=(s,i,r)=>{};#N=(s,i,r,e)=>{if(r||e)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#$({allowStale:s=this.allowStale}={}){if(this.#r)for(let i=this.#n;!(!this.#k(i)||((s||!this.#d(i))&&(yield i),i===this.#a));)i=this.#x[i]}*#E({allowStale:s=this.allowStale}={}){if(this.#r)for(let i=this.#a;!(!this.#k(i)||((s||!this.#d(i))&&(yield i),i===this.#n));)i=this.#l[i]}#k(s){return s!==void 0&&this.#i.get(this.#s[s])===s}*entries(){for(let s of this.#$())this.#t[s]!==void 0&&this.#s[s]!==void 0&&!this.#e(this.#t[s])&&(yield[this.#s[s],this.#t[s]])}*rentries(){for(let s of this.#E())this.#t[s]!==void 0&&this.#s[s]!==void 0&&!this.#e(this.#t[s])&&(yield[this.#s[s],this.#t[s]])}*keys(){for(let s of this.#$()){let i=this.#s[s];i!==void 0&&!this.#e(this.#t[s])&&(yield i)}}*rkeys(){for(let s of this.#E()){let i=this.#s[s];i!==void 0&&!this.#e(this.#t[s])&&(yield i)}}*values(){for(let s of this.#$())this.#t[s]!==void 0&&!this.#e(this.#t[s])&&(yield this.#t[s])}*rvalues(){for(let s of this.#E())this.#t[s]!==void 0&&!this.#e(this.#t[s])&&(yield this.#t[s])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(s,i={}){for(let r of this.#$()){let e=this.#t[r],n=this.#e(e)?e.__staleWhileFetching:e;if(n!==void 0&&s(n,this.#s[r],this))return this.get(this.#s[r],i)}}forEach(s,i=this){for(let r of this.#$()){let e=this.#t[r],n=this.#e(e)?e.__staleWhileFetching:e;n!==void 0&&s.call(i,n,this.#s[r],this)}}rforEach(s,i=this){for(let r of this.#E()){let e=this.#t[r],n=this.#e(e)?e.__staleWhileFetching:e;n!==void 0&&s.call(i,n,this.#s[r],this)}}purgeStale(){let s=!1;for(let i of this.#E({allowStale:!0}))this.#d(i)&&(this.#A(this.#s[i],"expire"),s=!0);return s}info(s){let i=this.#i.get(s);if(i===void 0)return;let r=this.#t[i],e=this.#e(r)?r.__staleWhileFetching:r;if(e===void 0)return;let n={value:e};if(this.#p&&this.#F){let o=this.#p[i],a=this.#F[i];if(o&&a){let h=o-(pt.now()-a);n.ttl=h,n.start=Date.now()}}return this.#m&&(n.size=this.#m[i]),n}dump(){let s=[];for(let i of this.#$({allowStale:!0})){let r=this.#s[i],e=this.#t[i],n=this.#e(e)?e.__staleWhileFetching:e;if(n===void 0||r===void 0)continue;let o={value:n};if(this.#p&&this.#F){o.ttl=this.#p[i];let a=pt.now()-this.#F[i];o.start=Math.floor(Date.now()-a)}this.#m&&(o.size=this.#m[i]),s.unshift([r,o])}return s}load(s){this.clear();for(let[i,r]of s){if(r.start){let e=Date.now()-r.start;r.start=pt.now()-e}this.set(i,r.value,r)}}set(s,i,r={}){if(i===void 0)return this.delete(s),this;let{ttl:e=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=r,{noUpdateTTL:f=this.noUpdateTTL}=r,l=this.#N(s,i,r.size||0,a);if(this.maxEntrySize&&l>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this.#A(s,"set"),this;let d=this.#r===0?void 0:this.#i.get(s);if(d===void 0)d=this.#r===0?this.#n:this.#w.length!==0?this.#w.pop():this.#r===this.#h?this.#D(!1):this.#r,this.#s[d]=s,this.#t[d]=i,this.#i.set(s,d),this.#l[this.#n]=d,this.#x[d]=this.#n,this.#n=d,this.#r++,this.#O(d,l,h),h&&(h.set="add"),f=!1;else{this.#M(d);let c=this.#t[d];if(i!==c){if(this.#T&&this.#e(c)){c.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=c;w!==void 0&&!o&&(this.#y&&this.#g?.(w,s,"set"),this.#c&&this.#o?.push([w,s,"set"]))}else o||(this.#y&&this.#g?.(c,s,"set"),this.#c&&this.#o?.push([c,s,"set"]));if(this.#z(d),this.#O(d,l,h),this.#t[d]=i,h){h.set="replace";let w=c&&this.#e(c)?c.__staleWhileFetching:c;w!==void 0&&(h.oldValue=w)}}else h&&(h.set="update")}if(e!==0&&!this.#p&&this.#B(),this.#p&&(f||this.#L(d,e,n),h&&this.#_(h,d)),!o&&this.#c&&this.#o){let c=this.#o,w;for(;w=c?.shift();)this.#u?.(...w)}return this}pop(){try{for(;this.#r;){let s=this.#t[this.#a];if(this.#D(!0),this.#e(s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(this.#c&&this.#o){let s=this.#o,i;for(;i=s?.shift();)this.#u?.(...i)}}}#D(s){let i=this.#a,r=this.#s[i],e=this.#t[i];return this.#T&&this.#e(e)?e.__abortController.abort(new Error("evicted")):(this.#y||this.#c)&&(this.#y&&this.#g?.(e,r,"evict"),this.#c&&this.#o?.push([e,r,"evict"])),this.#z(i),s&&(this.#s[i]=void 0,this.#t[i]=void 0,this.#w.push(i)),this.#r===1?(this.#a=this.#n=0,this.#w.length=0):this.#a=this.#l[i],this.#i.delete(r),this.#r--,i}has(s,i={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:e}=i,n=this.#i.get(s);if(n!==void 0){let o=this.#t[n];if(this.#e(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#d(n))e&&(e.has="stale",this.#_(e,n));else return r&&this.#R(n),e&&(e.has="hit",this.#_(e,n)),!0}else e&&(e.has="miss");return!1}peek(s,i={}){let{allowStale:r=this.allowStale}=i,e=this.#i.get(s);if(e===void 0||!r&&this.#d(e))return;let n=this.#t[e];return this.#e(n)?n.__staleWhileFetching:n}#W(s,i,r,e){let n=i===void 0?void 0:this.#t[i];if(this.#e(n))return n;let o=new Tt,{signal:a}=r;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let h={signal:o.signal,options:r,context:e},f=(p,R=!1)=>{let{aborted:A}=o.signal,D=r.ignoreFetchAbort&&p!==void 0;if(r.status&&(A&&!R?(r.status.fetchAborted=!0,r.status.fetchError=o.signal.reason,D&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),A&&!D&&!R)return d(o.signal.reason);let N=w;return this.#t[i]===w&&(p===void 0?N.__staleWhileFetching?this.#t[i]=N.__staleWhileFetching:this.#A(s,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(s,p,h.options))),p},l=p=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=p),d(p)),d=p=>{let{aborted:R}=o.signal,A=R&&r.allowStaleOnFetchAbort,D=A||r.allowStaleOnFetchRejection,N=D||r.noDeleteOnFetchRejection,b=w;if(this.#t[i]===w&&(!N||b.__staleWhileFetching===void 0?this.#A(s,"fetch"):A||(this.#t[i]=b.__staleWhileFetching)),D)return r.status&&b.__staleWhileFetching!==void 0&&(r.status.returnedStale=!0),b.__staleWhileFetching;if(b.__returned===b)throw p},c=(p,R)=>{let A=this.#C?.(s,n,h);A&&A instanceof Promise&&A.then(D=>p(D===void 0?void 0:D),R),o.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(p(void 0),r.allowStaleOnFetchAbort&&(p=D=>f(D,!0)))})};r.status&&(r.status.fetchDispatched=!0);let w=new Promise(c).then(f,l),g=Object.assign(w,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(s,g,{...h.options,status:void 0}),i=this.#i.get(s)):this.#t[i]=g,g}#e(s){if(!this.#T)return!1;let i=s;return!!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Tt}async fetch(s,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:e=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:f=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:d=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:c=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:g=this.allowStaleOnFetchAbort,context:p,forceRefresh:R=!1,status:A,signal:D}=i;if(!this.#T)return A&&(A.fetch="get"),this.get(s,{allowStale:r,updateAgeOnGet:e,noDeleteOnStaleGet:n,status:A});let N={allowStale:r,updateAgeOnGet:e,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:a,size:h,sizeCalculation:f,noUpdateTTL:l,noDeleteOnFetchRejection:d,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:g,ignoreFetchAbort:w,status:A,signal:D},b=this.#i.get(s);if(b===void 0){A&&(A.fetch="miss");let x=this.#W(s,b,N,p);return x.__returned=x}else{let x=this.#t[b];if(this.#e(x)){let M=r&&x.__staleWhileFetching!==void 0;return A&&(A.fetch="inflight",M&&(A.returnedStale=!0)),M?x.__staleWhileFetching:x.__returned=x}let u=this.#d(b);if(!R&&!u)return A&&(A.fetch="hit"),this.#M(b),e&&this.#R(b),A&&this.#_(A,b),x;let m=this.#W(s,b,N,p),$=m.__staleWhileFetching!==void 0&&r;return A&&(A.fetch=u?"stale":"refresh",$&&u&&(A.returnedStale=!0)),$?m.__staleWhileFetching:m.__returned=m}}async forceFetch(s,i={}){let r=await this.fetch(s,i);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(s,i={}){let r=this.#S;if(!r)throw new Error("no memoMethod provided to constructor");let{context:e,forceRefresh:n,...o}=i,a=this.get(s,o);if(!n&&a!==void 0)return a;let h=r(s,a,{options:o,context:e});return this.set(s,h,o),h}get(s,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:e=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,a=this.#i.get(s);if(a!==void 0){let h=this.#t[a],f=this.#e(h);return o&&this.#_(o,a),this.#d(a)?(o&&(o.get="stale"),f?(o&&r&&h.__staleWhileFetching!==void 0&&(o.returnedStale=!0),r?h.__staleWhileFetching:void 0):(n||this.#A(s,"expire"),o&&r&&(o.returnedStale=!0),r?h:void 0)):(o&&(o.get="hit"),f?h.__staleWhileFetching:(this.#M(a),e&&this.#R(a),h))}else o&&(o.get="miss")}#I(s,i){this.#x[i]=s,this.#l[s]=i}#M(s){s!==this.#n&&(s===this.#a?this.#a=this.#l[s]:this.#I(this.#x[s],this.#l[s]),this.#I(this.#n,s),this.#n=s)}delete(s){return this.#A(s,"delete")}#A(s,i){let r=!1;if(this.#r!==0){let e=this.#i.get(s);if(e!==void 0)if(r=!0,this.#r===1)this.#P(i);else{this.#z(e);let n=this.#t[e];if(this.#e(n)?n.__abortController.abort(new Error("deleted")):(this.#y||this.#c)&&(this.#y&&this.#g?.(n,s,i),this.#c&&this.#o?.push([n,s,i])),this.#i.delete(s),this.#s[e]=void 0,this.#t[e]=void 0,e===this.#n)this.#n=this.#x[e];else if(e===this.#a)this.#a=this.#l[e];else{let o=this.#x[e];this.#l[o]=this.#l[e];let a=this.#l[e];this.#x[a]=this.#x[e]}this.#r--,this.#w.push(e)}}if(this.#c&&this.#o?.length){let e=this.#o,n;for(;n=e?.shift();)this.#u?.(...n)}return r}clear(){return this.#P("delete")}#P(s){for(let i of this.#E({allowStale:!0})){let r=this.#t[i];if(this.#e(r))r.__abortController.abort(new Error("deleted"));else{let e=this.#s[i];this.#y&&this.#g?.(r,e,s),this.#c&&this.#o?.push([r,e,s])}}if(this.#i.clear(),this.#t.fill(void 0),this.#s.fill(void 0),this.#p&&this.#F&&(this.#p.fill(0),this.#F.fill(0)),this.#m&&this.#m.fill(0),this.#a=0,this.#n=0,this.#w.length=0,this.#b=0,this.#r=0,this.#c&&this.#o){let i=this.#o,r;for(;r=i?.shift();)this.#u?.(...r)}}};var I=t=>Object.prototype.toString.call(t).slice(8,-1),U=t=>typeof t=="string"||t instanceof String;var et=.5,wt=2,nt=3,v=4,ie=10,H=16,j=360,it=60,z=100,_=255,Ct=2,yt=3,mt=2.4,Ft=12.92,J=.055,$t=116,ne=500,oe=200,It=216/24389,Mt=24389/27,ae=[.3457/.3585,1,(1-.3457-.3585)/.3585],Et=[[.9554734527042182,-.023098536874261423,.0632593086610217],[-.028369706963208136,1.0099954580058226,.021041398966943008],[.012314001688319899,-.020507696433477912,1.3303659366080753]],tt=[[1.0479298208405488,.022946793341019088,-.05019222954313557],[.029627815688159344,.990434484573249,-.01707382502938514],[-.009243058152591178,.015055144896577895,.7518742899580008]],Gt=[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],Ht=[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],Ae=[[.8190224432164319,.3619062562801221,-.12887378261216414],[.0329836671980271,.9292868468965546,.03614466816999844],[.048177199566046255,.26423952494422764,.6335478258136937]],he=[[1.2268798733741557,-.5578149965554813,.28139105017721583],[-.04057576262431372,1.1122868293970594,-.07171106666151701],[-.07637294974672142,-.4214933239627914,1.5869240244272418]],le=[[.9999999984505196,.39633779217376774,.2158037580607588],[1.0000000088817607,-.10556134232365633,-.0638541747717059],[1.0000000546724108,-.08948418209496574,-1.2914855378640917]],_e=[[.2104542553,.793617785,-.0040720468],[1.9779984951,-2.428592205,.4505937099],[.0259040371,.7827717662,-.808675766]],Te=[[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0,32229/714400,5220557/5000800]],Re=[[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,472592308/697040785,8267143/139408157],[0,19567812/697040785,295819943/278816314]],ze=[[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],Me=[[.7977604896723027,.13518583717574031,.0313493495815248],[.2880711282292934,.7118432178101014,8565396060525902e-20],[0,0,.8251046025104601]],F="none",Ot="deg|g?rad|turn",ce="srgb(?:-linear)?",fe="xyz(?:-d(?:50|65))?",Ce=`(?:ok)?l(?:ab|ch)|h(?:sl|wb)|${ce}|${fe}`,Se=`(?:a98|prophoto)-rgb|display-p3|rec2020|${ce}`,V="[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?",Z=`${V}%`,At=`(?:${V}(?:${Ot})?|${F})(?:\\s+(?:${Z}|${F})){2}(?:\\s*\\/\\s*(?:${V}|${Z}|${F}))?`,xe=`${V}(?:${Ot})?(?:\\s*,\\s*${Z}){2}(?:\\s*,\\s*(?:${V}|${Z}))?`,Ut=`(?:(?:${V}|${F})(?:\\s+(?:${V}|${F})){2}|(?:${Z}|${F})(?:\\s+(?:${Z}|${F})){2})(?:\\s*\\/\\s*(?:${V}|${Z}|${F}))?`,pe=`(?:${V}(?:\\s*,\\s*${V}){2}|${Z}(?:\\s*,\\s*${Z}){2})(?:\\s*,\\s*(?:${V}|${Z}))?`,_t=`(?:${V}|${Z}|${F})(?:\\s+(?:${V}|${Z}|${F})){2}(?:\\s*\\/\\s*(?:${V}|${Z}|${F}))?`,jt=`(?:(?:${V}|${Z}|${F})\\s+){2}(?:${V}(?:${Ot})?|${F})(?:\\s*\\/\\s*(?:${V}|${Z}|${F}))?`,Dt=`(?:${Se}|${fe})(?:\\s+(?:${V}|${Z}|${F})){3}(?:\\s*\\/\\s*(?:${V}|${Z}|${F}))?`,de=`[a-z]+|#(?:[\\da-f]{3}|[\\da-f]{4}|[\\da-f]{6}|[\\da-f]{8})|hsla?\\(\\s*(?:${At}|${xe})\\s*\\)|hwb\\(\\s*${At}\\s*\\)|rgba?\\(\\s*(?:${Ut}|${pe})\\s*\\)|(?:ok)?lab\\(\\s*${_t}\\s*\\)|(?:ok)?lch\\(\\s*${jt}\\s*\\)|color\\(\\s*${Dt}\\s*\\)`,re=`(?:${de})(?:\\s+${Z})?`,Oe=`color-mix\\(\\s*in\\s+(${Ce})\\s*,\\s*(${re})\\s*,\\s*(${re})\\s*\\)`,G=/^currentColor$/i,St={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]},Q=(t,s={})=>{if(!Array.isArray(t))throw new TypeError(`Expected Array but got ${I(t)}.`);let{alpha:i=!1,minLength:r=nt,maxLength:e=v,minRange:n=0,maxRange:o=1,validateRange:a=!0}=s;if(typeof r!="number")throw new TypeError(`Expected Number but got ${I(r)}.`);if(Number.isNaN(r))throw new TypeError(`${r} is not a number.`);if(typeof e!="number")throw new TypeError(`Expected Number but got ${I(e)}.`);if(Number.isNaN(e))throw new TypeError(`${e} is not a number.`);if(typeof n!="number")throw new TypeError(`Expected Number but got ${I(n)}.`);if(Number.isNaN(n))throw new TypeError(`${n} is not a number.`);if(typeof o!="number")throw new TypeError(`Expected Number but got ${I(o)}.`);if(Number.isNaN(o))throw new TypeError(`${o} is not a number.`);let h=t.length;if(h<r||h>e){let l;throw r===e?l=`Expected array length of ${e} but got ${h}.`:l=`Expected array length of ${r} or ${e} but got ${h}.`,new Error(l)}let f=0;for(;f<h;){let l=t[f];if(typeof l!="number")throw new TypeError(`Expected Number but got ${I(l)}.`);if(Number.isNaN(l))throw new TypeError(`${l} is not a number.`);if(f<nt&&a&&(l<n||l>o))throw new RangeError(`${l} is not between ${n} and ${o}.`);if(f===nt&&(l<0||l>1))throw new RangeError(`${l} is not between 0 and 1.`);f++}return i&&h===nt&&t.push(1),t},L=(t,s)=>{if(Array.isArray(t)){if(t.length!==nt)throw new Error(`Expected array length of 3 but got ${t.length}.`);for(let A of t)A=Q(A,{maxLength:nt,validateRange:!1})}else throw new TypeError(`Expected Array but got ${I(t)}.`);let[[i,r,e],[n,o,a],[h,f,l]]=t,[d,c,w]=Q(s,{maxLength:nt,validateRange:!1}),g=i*d+r*c+e*w,p=n*d+o*c+a*w,R=h*d+f*c+l*w;return[g,p,R]},S=(t,s=[])=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let[i,r,e,n]=s,o,a,h,f;if(/none/.test(t)){let l=new RegExp(`^rgba?\\(\\s*(${Ut})\\s*\\)$`),d=new RegExp(`^color\\(\\s*(${Dt})\\s*\\)$`),c=new RegExp(`^h(?:sla?|wb)\\(\\s*(${At})\\s*\\)$`),w=new RegExp(`^(?:ok)?lab\\(\\s*(${_t})\\s*\\)$`),g=new RegExp(`^(?:ok)?lch\\(\\s*(${jt})\\s*\\)$`);l.test(t)?[o,a,h,f]=t.match(l)[1].replace("/"," ").split(/\s+/):d.test(t)?[,o,a,h,f]=t.match(d)[1].replace("/"," ").split(/\s+/):t.startsWith("hsl")&&c.test(t)?[h,a,o,f]=t.match(c)[1].replace("/"," ").split(/\s+/):t.startsWith("hwb")&&c.test(t)?[h,,,f]=t.match(c)[1].replace("/"," ").split(/\s+/):w.test(t)?[o,,,f]=t.match(w)[1].replace("/"," ").split(/\s+/):g.test(t)&&([o,a,h,f]=t.match(g)[1].replace("/"," ").split(/\s+/))}return[o===F?o:i,a===F?a:r,h===F?h:e,f===F?f:n]},st=(t,s)=>{if(Array.isArray(t)){if(t.length!==v)throw new Error(`Expected array length of 4 but got ${t.length}.`)}else throw new TypeError(`Expected Array but got ${I(t)}.`);if(Array.isArray(s)){if(s.length!==v)throw new Error(`Expected array length of 4 but got ${s.length}.`)}else throw new TypeError(`Expected Array but got ${I(s)}.`);let i=0;for(;i<v;)t[i]===F&&s[i]===F?(t[i]=0,s[i]=0):t[i]===F?t[i]=s[i]:s[i]===F&&(s[i]=t[i]),i++;return t=Q(t,{minLength:v,validateRange:!1}),s=Q(s,{minLength:v,validateRange:!1}),[t,s]},rt=t=>{if(typeof t!="number")throw new TypeError(`Expected Number but got ${I(t)}.`);if(Number.isNaN(t))throw new TypeError(`${t} is not a number.`);if(t=Math.round(t),t<0||t>_)throw new RangeError(`${t} is not between 0 and ${_}.`);let s=t.toString(H);return s.length===1&&(s=`0${s}`),s},Wt=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=j/400,i=j/(Math.PI*wt),r=new RegExp(`^(${V})(${Ot})?$`);if(!r.test(t))throw new Error(`Invalid property value: ${t}`);let[,e,n]=t.match(r),o=e.startsWith(".")?`0${e}`:e,a;switch(n){case"grad":a=parseFloat(o)*s;break;case"rad":a=parseFloat(o)*i;break;case"turn":a=parseFloat(o)*j;break;default:a=parseFloat(o)}return a%=j,a<0?a+=j:Object.is(a,-0)&&(a=0),a},Yt=t=>{let[s,i,r]=Q(t,{maxLength:nt,maxRange:_}),e=s/_,n=i/_,o=r/_,a=.04045;return e>a?e=Math.pow((e+J)/(1+J),mt):e/=Ft,n>a?n=Math.pow((n+J)/(1+J),mt):n/=Ft,o>a?o=Math.pow((o+J)/(1+J),mt):o/=Ft,[e,n,o]},Pt=t=>{let[s,i,r,e]=Q(t,{alpha:!0,maxRange:_}),[n,o,a]=Yt([s,i,r]),[h,f,l]=L(Gt,[n,o,a]);return[h,f,l,e]};var Bt=t=>{let[s,i,r,e]=Q(t,{alpha:!0,maxRange:_}),n=rt(s),o=rt(i),a=rt(r),h=rt(e*_),f;return h==="ff"?f=`#${n}${o}${a}`:f=`#${n}${o}${a}${h}`,f},Vt=t=>{let[s,i,r]=Q(t,{maxLength:nt}),e=809/258400;return s>e?s=Math.pow(s,1/mt)*(1+J)-J:s*=Ft,i>e?i=Math.pow(i,1/mt)*(1+J)-J:i*=Ft,r>e?r=Math.pow(r,1/mt)*(1+J)-J:r*=Ft,[Math.round(s*_),Math.round(i*_),Math.round(r*_)]},De=t=>{let[s,i,r,e]=Q(t,{minLength:v});[s,i,r]=Vt([s,i,r]);let n=rt(s),o=rt(i),a=rt(r),h=rt(e*_),f;return h==="ff"?f=`#${n}${o}${a}`:f=`#${n}${o}${a}${h}`,f},ge=t=>{let[s,i,r,e]=Q(t,{minLength:v,validateRange:!1}),[n,o,a]=L(Ht,[s,i,r]);return De([Math.min(Math.max(n,0),1),Math.min(Math.max(o,0),1),Math.min(Math.max(a,0),1),e])};var at=t=>{let[s,i,r,e]=Q(t,{validateRange:!1}),[n,o,a]=L(Ht,[s,i,r]);return[n,o,a]=Vt([Math.min(Math.max(n,0),1),Math.min(Math.max(o,0),1),Math.min(Math.max(a,0),1)]),[n,o,a,e]},ue=t=>{let[s,i,r,e]=Q(t,{validateRange:!1}),[n,o,a]=L(tt,[s,i,r]);return[n,o,a,e]},lt=t=>{let[s,i,r,e]=at(t),n=s/_,o=i/_,a=r/_,h=Math.max(n,o,a),f=Math.min(n,o,a),l=h-f,d=(h+f)*et*z,c,w;if(Math.round(d)===0||Math.round(d)===z)c=F,w=F;else if(w=l/(1-Math.abs(h+f-1))*z,w===0)c=F;else{switch(h){case n:c=(o-a)/l;break;case o:c=(a-n)/l+wt;break;case a:default:c=(n-o)/l+v;break}c=c*it%j,c<0&&(c+=j)}return[c,w,d,e]},gt=t=>{let[s,i,r,e]=at(t),n=Math.min(s,i,r)/_,o=1-Math.max(s,i,r)/_,a;return n+o===1?a=F:[a]=lt(t),[a,n*z,o*z,e]},ct=t=>{let[s,i,r,e]=Q(t,{validateRange:!1}),o=L(Ae,[s,i,r]).map(d=>Math.cbrt(d)),[a,h,f]=L(_e,o);a=Math.min(Math.max(a,0),1);let l=Math.round(parseFloat(a.toFixed(v))*z);return(l===0||l===z)&&(h=F,f=F),[a,h,f,e]},ut=t=>{let[s,i,r,e]=ct(t),n,o,a=Math.round(parseFloat(s.toFixed(v))*z);return a===0||a===z?(n=F,o=F):(n=Math.max(Math.sqrt(Math.pow(i,Ct)+Math.pow(r,Ct)),0),parseFloat(n.toFixed(v))===0?o=F:(o=Math.atan2(r,i)*j*et/Math.PI,o<0&&(o+=j))),[s,n,o,e]},be=t=>{let[s,i,r,e]=Q(t,{minLength:v,validateRange:!1}),n=L(Et,[s,i,r]),[o,a,h]=at(n);return[o,a,h,e]},ft=t=>{let[s,i,r,e]=Q(t,{validateRange:!1}),n=[s,i,r].map((c,w)=>c/ae[w]),[o,a,h]=n.map(c=>c>It?Math.cbrt(c):(c*Mt+H)/$t),f=Math.min(Math.max($t*a-H,0),z),l,d;return f===0||f===z?(l=F,d=F):(l=(o-a)*ne,d=(a-h)*oe),[f,l,d,e]},bt=t=>{let[s,i,r,e]=ft(t),n,o;return s===0||s===z?(n=F,o=F):(n=Math.max(Math.sqrt(Math.pow(i,Ct)+Math.pow(r,Ct)),0),parseFloat(n.toFixed(v))===0?o=F:(o=Math.atan2(r,i)*j*et/Math.PI,o<0&&(o+=j))),[s,n,o,e]},Lt=t=>{if(U(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${I(t)}.`);if(!(/^#[\da-f]{6}$/.test(t)||/^#[\da-f]{3}$/.test(t)||/^#[\da-f]{8}$/.test(t)||/^#[\da-f]{4}$/.test(t)))throw new Error(`Invalid property value: ${t}`);let s=[];if(/^#[\da-f]{6}$/.test(t)){let[,i,r,e]=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);s.push(parseInt(i,H),parseInt(r,H),parseInt(e,H),1)}else if(/^#[\da-f]{3}$/.test(t)){let[,i,r,e]=t.match(/^#([\da-f])([\da-f])([\da-f])$/);s.push(parseInt(`${i}${i}`,H),parseInt(`${r}${r}`,H),parseInt(`${e}${e}`,H),1)}else if(/^#[\da-f]{8}$/.test(t)){let[,i,r,e,n]=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);s.push(parseInt(i,H),parseInt(r,H),parseInt(e,H),parseInt(n,H)/_)}else if(/^#[\da-f]{4}$/.test(t)){let[,i,r,e,n]=t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])$/);s.push(parseInt(`${i}${i}`,H),parseInt(`${r}${r}`,H),parseInt(`${e}${e}`,H),parseInt(`${n}${n}`,H)/_)}return s},We=t=>{let[s,i,r,e]=Lt(t),[n,o,a]=Yt([s,i,r]);return[n,o,a,e]},Be=t=>{let[s,i,r,e]=We(t),[n,o,a]=L(Gt,[s,i,r]);return[n,o,a,e]},ht=t=>{if(U(t))if(t=t.trim(),!t)t=1;else if(t===F)t=0;else{if(t.startsWith(".")&&(t=`0${t}`),t.endsWith("%")?t=parseFloat(t)/z:t=parseFloat(t),Number.isNaN(t))throw new TypeError(`${t} is not a number.`);(t<0||t>1)&&(t=Math.min(Math.max(t,0),1))}else t=1;return t},we=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=new RegExp(`^rgba?\\(\\s*(${Ut}|${pe})\\s*\\)$`);if(!s.test(t))throw new Error(`Invalid property value: ${t}`);let[,i]=t.match(s),[r,e,n,o]=i.replace(/[,/]/g," ").split(/\s+/);return r===F?r=0:(r.startsWith(".")&&(r=`0${r}`),r.endsWith("%")?r=parseFloat(r)*_/z:r=parseFloat(r)),e===F?e=0:(e.startsWith(".")&&(e=`0${e}`),e.endsWith("%")?e=parseFloat(e)*_/z:e=parseFloat(e)),n===F?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*_/z:n=parseFloat(n)),o=ht(o),[Math.min(Math.max(r,0),_),Math.min(Math.max(e,0),_),Math.min(Math.max(n,0),_),o]},qt=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=new RegExp(`^hsla?\\(\\s*(${At}|${xe})\\s*\\)$`);if(!s.test(t))throw new Error(`Invalid property value: ${t}`);let[,i]=t.match(s),[r,e,n,o]=i.replace(/[,/]/g," ").split(/\s+/);r===F?r=0:r=Wt(r),e===F?e=0:(e.startsWith(".")&&(e=`0${e}`),e=Math.min(Math.max(parseFloat(e),0),z)),n===F?n=0:(n.startsWith(".")&&(n=`0${n}`),n=Math.min(Math.max(parseFloat(n),0),z)),o=ht(o);let a,h;n<z*et?(a=(n+n*(e/z))*_/z,h=(n-n*(e/z))*_/z):(a=(n+(z-n)*(e/z))*_/z,h=(n-(z-n)*(e/z))*_/z);let f=(a-h)/it,l,d,c;return r>=0&&r<it?(l=a,d=r*f+h,c=h):r<it*wt?(l=(it*wt-r)*f+h,d=a,c=h):r<j*et?(l=h,d=a,c=(r-it*wt)*f+h):r<it*v?(l=h,d=(it*v-r)*f+h,c=a):r<j-it?(l=(r-it*v)*f+h,d=h,c=a):r<j&&(l=a,d=h,c=(j-r)*f+h),[Math.min(Math.max(l,0),_),Math.min(Math.max(d,0),_),Math.min(Math.max(c,0),_),o]},me=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=new RegExp(`^hwb\\(\\s*(${At})\\s*\\)$`);if(!s.test(t))throw new Error(`Invalid property value: ${t}`);let[,i]=t.match(s),[r,e,n,o]=i.replace("/"," ").split(/\s+/);r===F?r=0:r=Wt(r),e===F?e=0:(e.startsWith(".")&&(e=`0${e}`),e=Math.min(Math.max(parseFloat(e),0),z)/z),n===F?n=0:(n.startsWith(".")&&(n=`0${n}`),n=Math.min(Math.max(parseFloat(n),0),z)/z),o=ht(o);let a=[];if(e+n>=1){let h=e/(e+n)*_;a.push(h,h,h,o)}else{let[h,f,l]=qt(`hsl(${r} 100% 50%)`),d=(1-e-n)/_;a.push((h*d+e)*_,(f*d+e)*_,(l*d+e)*_,o)}return a},Zt=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=new RegExp(`^lab\\(\\s*(${_t})\\s*\\)$`);if(!s.test(t))throw new Error(`Invalid property value: ${t}`);let i=1.25,r=8,[,e]=t.match(s),[n,o,a,h]=e.replace("/"," ").split(/\s+/);n===F?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?(n=parseFloat(n),n>z&&(n=z)):n=parseFloat(n),n<0&&(n=0)),o===F?o=0:(o.startsWith(".")&&(o=`0${o}`),o.endsWith("%")?o=parseFloat(o)*i:o=parseFloat(o)),a===F?a=0:a.endsWith("%")?a=parseFloat(a)*i:a=parseFloat(a),h=ht(h);let f=(n+H)/$t,l=o/ne+f,d=f-a/oe,c=Math.pow(f,yt),w=Math.pow(l,yt),g=Math.pow(d,yt),p=[w>It?w:(l*$t-H)/Mt,n>r?c:n/Mt,g>It?g:(d*$t-H)/Mt],[R,A,D]=p.map((N,b)=>N*ae[b]);return[R,A,D,h]},Fe=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=new RegExp(`^lch\\(\\s*(${jt})\\s*\\)$`);if(!s.test(t))throw new Error(`Invalid property value: ${t}`);let i=1.5,[,r]=t.match(s),[e,n,o,a]=r.replace("/"," ").split(/\s+/);e===F?e=0:(e.startsWith(".")&&(e=`0${e}`),e=parseFloat(e),e<0&&(e=0)),n===F?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*i:n=parseFloat(n)),o===F?o=0:o=Wt(o),a=ht(a);let h=n*Math.cos(o*Math.PI/(j*et)),f=n*Math.sin(o*Math.PI/(j*et)),[l,d,c]=Zt(`lab(${e} ${h} ${f})`);return[l,d,c,a]},ye=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=new RegExp(`^oklab\\(\\s*(${_t})\\s*\\)$`);if(!s.test(t))throw new Error(`Invalid property value: ${t}`);let i=.4,[,r]=t.match(s),[e,n,o,a]=r.replace("/"," ").split(/\s+/);e===F?e=0:(e.startsWith(".")&&(e=`0${e}`),e.endsWith("%")?e=parseFloat(e)/z:e=parseFloat(e),e<0&&(e=0)),n===F?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*i/z:n=parseFloat(n)),o===F?o=0:o.endsWith("%")?o=parseFloat(o)*i/z:o=parseFloat(o),a=ht(a);let f=L(le,[e,n,o]).map(w=>Math.pow(w,yt)),[l,d,c]=L(he,f);return[l,d,c,a]},$e=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s=new RegExp(`^oklch\\(\\s*(${_t})\\s*\\)$`);if(!s.test(t))throw new Error(`Invalid property value: ${t}`);let i=.4,[,r]=t.match(s),[e,n,o,a]=r.replace("/"," ").split(/\s+/);e===F?e=0:(e.startsWith(".")&&(e=`0${e}`),e.endsWith("%")?e=parseFloat(e)/z:e=parseFloat(e),e<0&&(e=0)),n===F?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*i/z:n=parseFloat(n),n<0&&(n=0)),o===F?o=0:o=Wt(o),a=ht(a);let h=n*Math.cos(o*Math.PI/(j*et)),f=n*Math.sin(o*Math.PI/(j*et)),d=L(le,[e,h,f]).map(p=>Math.pow(p,yt)),[c,w,g]=L(he,d);return[c,w,g,a]},Y=(t,s=!1)=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i=new RegExp(`^color\\(\\s*(${Dt})\\s*\\)$`);if(!i.test(t))throw new Error(`Invalid property value: ${t}`);let[,r]=t.match(i),[e,n,o,a,h]=r.replace("/"," ").split(/\s+/),f,l,d;if(n===F)f=0;else{let R;n.startsWith(".")?R=`0${n}`:R=n,f=R.endsWith("%")?parseFloat(R)/z:parseFloat(R)}if(o===F)l=0;else{let R;o.startsWith(".")?R=`0${o}`:R=o,l=R.endsWith("%")?parseFloat(R)/z:parseFloat(R)}if(a===F)d=0;else{let R;a.startsWith(".")?R=`0${a}`:R=a,d=R.endsWith("%")?parseFloat(R)/z:parseFloat(R)}let c=ht(h),w,g,p;if(e==="srgb")[w,g,p]=Pt([f*_,l*_,d*_]),s&&([w,g,p]=L(tt,[w,g,p]));else if(e==="srgb-linear")[w,g,p]=L(Gt,[f,l,d]),s&&([w,g,p]=L(tt,[w,g,p]));else if(e==="display-p3"){let R=Yt([f*_,l*_,d*_]);[w,g,p]=L(Te,R),s&&([w,g,p]=L(tt,[w,g,p]))}else if(e==="rec2020"){let R=1.09929682680944,A=.018053968510807,D=.45,N=[f,l,d].map(b=>{let x;return b<A*D*ie?x=b/(D*ie):x=Math.pow((b+R-1)/R,1/D),x});[w,g,p]=L(Re,N),s&&([w,g,p]=L(tt,[w,g,p]))}else if(e==="a98-rgb"){let R=2.19921875,A=[f,l,d].map(D=>Math.pow(D,R));[w,g,p]=L(ze,A),s&&([w,g,p]=L(tt,[w,g,p]))}else if(e==="prophoto-rgb"){let A=[f,l,d].map(D=>{let N;return D>1/(H*wt)?N=Math.pow(D,1.8):N=D/H,N});[w,g,p]=L(Me,A),s||([w,g,p]=L(Et,[w,g,p]))}else/^xyz(?:-d(?:50|65))?$/.test(e)&&([w,g,p]=[f,l,d],e==="xyz-d50"?s||([w,g,p]=L(Et,[w,g,p])):s&&([w,g,p]=L(tt,[w,g,p])));return[w,g,p,c]},q=(t,s=!1)=>{if(U(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i,r,e,n;if(G.test(t))i=0,r=0,e=0,n=0;else if(/^[a-z]+$/.test(t))if(Object.prototype.hasOwnProperty.call(St,t)){let[o,a,h]=St[t];n=1,[i,r,e]=Pt([o,a,h]),s&&([i,r,e]=L(tt,[i,r,e]))}else if(t==="transparent")i=0,r=0,e=0,n=0;else throw new Error(`Invalid property value: ${t}`);else if(t.startsWith("#")){let o;if(/^#[\da-f]{6}$/.test(t))o=t;else if(/^#[\da-f]{3}$/.test(t)){let[,a,h,f]=t.match(/^#([\da-f])([\da-f])([\da-f])$/);o=`#${a}${a}${h}${h}${f}${f}`}else if(/^#[\da-f]{8}$/.test(t))o=t;else if(/^#[\da-f]{4}$/.test(t)){let[,a,h,f,l]=t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])$/);o=`#${a}${a}${h}${h}${f}${f}${l}${l}`}else throw new Error(`Invalid property value: ${t}`);[i,r,e,n]=Be(o),s&&([i,r,e]=L(tt,[i,r,e]))}else if(t.startsWith("lab"))[i,r,e,n]=Zt(t),s||([i,r,e]=L(Et,[i,r,e]));else if(t.startsWith("lch"))[i,r,e,n]=Fe(t),s||([i,r,e]=L(Et,[i,r,e]));else if(t.startsWith("oklab"))[i,r,e,n]=ye(t),s&&([i,r,e]=L(tt,[i,r,e]));else if(t.startsWith("oklch"))[i,r,e,n]=$e(t),s&&([i,r,e]=L(tt,[i,r,e]));else{let o,a,h;if(t.startsWith("rgb"))[o,a,h,n]=we(t);else if(t.startsWith("hsl"))[o,a,h,n]=qt(t);else if(t.startsWith("hwb"))[o,a,h,n]=me(t);else throw new Error(`Invalid property value: ${t}`);[i,r,e]=Pt([o,a,h]),s&&([i,r,e]=L(tt,[i,r,e]))}return[i,r,e,n]},Xt=(t,s={})=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let{alpha:i}=s,r,e,n,o;t.startsWith("color(")?[r,e,n,o]=Y(t):[r,e,n,o]=q(t);let[a,h,f]=L(Ht,[r,e,n]);a=Math.min(Math.max(a,0),1),h=Math.min(Math.max(h,0),1),f=Math.min(Math.max(f,0),1);let l=[a,h,f];return i?l.push(o):l.push(1),l},zt=t=>{let[s,i,r,e]=Xt(t,{alpha:!0});return[s,i,r]=Vt([s,i,r]),[s,i,r,e]},xt=t=>{if(U(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let s,i,r,e;if(G.test(t))s=0,i=0,r=0,e=0;else if(/^[a-z]+$/i.test(t))Object.prototype.hasOwnProperty.call(St,t)?([s,i,r]=St[t],e=1):t==="transparent"&&(s=0,i=0,r=0,e=0);else if(t.startsWith("#"))[s,i,r,e]=Lt(t);else if(/^l(?:ab|ch)/.test(t)){let o,a,h;t.startsWith("lab")?[o,a,h,e]=Zt(t):[o,a,h,e]=Fe(t),[s,i,r,e]=be([o,a,h,e])}else if(/^okl(?:ab|ch)/.test(t)){let o,a,h;t.startsWith("oklab")?[o,a,h,e]=ye(t):[o,a,h,e]=$e(t),[s,i,r,e]=at([o,a,h,e])}else t.startsWith("rgb")?[s,i,r,e]=we(t):t.startsWith("hsl")?[s,i,r,e]=qt(t):t.startsWith("hwb")&&([s,i,r,e]=me(t));let n;return isNaN(s)||isNaN(i)||isNaN(r)||isNaN(e)?n=[]:n=[Math.round(s),Math.round(i),Math.round(r),e],n},vt=t=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);if(!new RegExp(`^color\\(\\s*${Dt}\\s*\\)$`).test(t))throw new Error(`Invalid property value: ${t}`);let[i,r,e,n]=Y(t),[o,a,h]=at([i,r,e]);return[o,a,h,n]},Kt=(t,s={})=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i=new RegExp(`^${Oe}$`,"i");if(!i.test(t))throw new Error(`Invalid property value: ${t}`);let r="lch(none none none / none)",e="rgb(none none none / none)",n=new RegExp(`^(${de})(?:\\s+(${Z}))?$`,"i"),o=new RegExp(F),[,a,h,f]=t.match(i),[,l,d]=h.match(n),[,c,w]=f.match(n),g,p,R;if(d&&w){let x=parseFloat(d)/z,u=parseFloat(w)/z;if(x<0||x>1)throw new RangeError(`${d} is not between 0% and 100%.`);if(u<0||u>1)throw new RangeError(`${w} is not between 0% and 100%.`);let m=x+u;if(m===0)throw new Error(`Invalid property value: ${t}`);g=x/m,p=u/m,R=m<1?m:1}else{if(d){if(g=parseFloat(d)/z,g<0||g>1)throw new RangeError(`${d} is not between 0% and 100%.`);p=1-g}else if(w){if(p=parseFloat(w)/z,p<0||p>1)throw new RangeError(`${w} is not between 0% and 100%.`);g=1-p}else g=et,p=et;R=1}let A,D,N,b;if(a==="srgb"){let x=zt(l,{alpha:!0}),u=zt(c,{alpha:!0});G.test(l)?x=S(e,x):o.test(l)&&(x=S(l,x)),G.test(c)?u=S(e,u):o.test(c)&&(u=S(c,u));let[[m,y,$,M],[T,E,B,P]]=st(x,u),O=M*g,C=P*p;b=O+C,b===0?(A=m*g+T*p,D=y*g+E*p,N=$*g+B*p):(A=(m*O+T*C)/b,D=(y*O+E*C)/b,N=($*O+B*C)/b)}else if(a==="srgb-linear"){let x=Xt(l,{alpha:!0}),u=Xt(c,{alpha:!0});G.test(l)?x=S(e,x):o.test(l)&&(x=S(l,x)),G.test(c)?u=S(e,u):o.test(c)&&(u=S(c,u));let[[m,y,$,M],[T,E,B,P]]=st(x,u),O=M*g,C=P*p;b=O+C,b===0?(A=(m*g+T*p)*_,D=(y*g+E*p)*_,N=($*g+B*p)*_):(A=(m*O+T*C)*b*_,D=(y*O+E*C)*b*_,N=($*O+B*C)*b*_)}else if(/^xyz(?:-d65)?$/.test(a)){let x,u;l.startsWith("color(")?x=Y(l):x=q(l),c.startsWith("color(")?u=Y(c):u=q(c),G.test(l)?x=S(e,x):o.test(l)&&(x=S(l,x)),G.test(c)?u=S(e,u):o.test(c)&&(u=S(c,u));let[[m,y,$,M],[T,E,B,P]]=st(x,u),O=M*g,C=P*p;b=O+C;let k,W,X;b===0?(k=m*g+T*p,W=y*g+E*p,X=$*g+B*p):(k=(m*O+T*C)*b,W=(y*O+E*C)*b,X=($*O+B*C)*b),[A,D,N]=at([k,W,X])}else if(a==="xyz-d50"){let x,u;l.startsWith("color(")?x=Y(l,!0):x=q(l,!0),c.startsWith("color(")?u=Y(c,!0):u=q(c,!0),G.test(l)?x=S(e,x):o.test(l)&&(x=S(l,x)),G.test(c)?u=S(e,u):o.test(c)&&(u=S(c,u));let[[m,y,$,M],[T,E,B,P]]=st(x,u),O=M*g,C=P*p;b=O+C;let k,W,X;b===0?(k=m*g+T*p,W=y*g+E*p,X=$*g+B*p):(k=(m*O+T*C)*b,W=(y*O+E*C)*b,X=($*O+B*C)*b),[A,D,N]=be([k,W,X,b])}else if(a==="hsl"){let x,u,m,y;if(l.startsWith("color(")){let W=Y(l);[x,u,m,y]=lt(W)}else{let W=q(l);[x,u,m,y]=lt(W)}let $,M,T,E;if(c.startsWith("color(")){let W=Y(c);[$,M,T,E]=lt(W)}else{let W=q(c);[$,M,T,E]=lt(W)}G.test(l)?[m,u,x,y]=S(r,[m,u,x,y]):o.test(l)&&([m,u,x,y]=S(l,[m,u,x,y])),G.test(c)?[T,M,$,E]=S(r,[T,M,$,E]):o.test(c)&&([T,M,$,E]=S(c,[T,M,$,E])),[[x,u,m,y],[$,M,T,E]]=st([x,u,m,y],[$,M,T,E]);let B=y*g,P=E*p;b=B+P;let O=(x*g+$*p)%j,C,k;b===0?(C=u*g+M*p,k=m*g+T*p):(C=(u*B+M*P)/b,k=(m*B+T*P)/b),[A,D,N]=zt(`hsl(${O} ${C}% ${k}%)`)}else if(a==="hwb"){let x,u,m,y;if(l.startsWith("color(")){let X=Y(l);[x,u,m,y]=gt(X)}else{let X=q(l);[x,u,m,y]=gt(X)}let $,M,T,E;if(c.startsWith("color(")){let X=Y(c);[$,M,T,E]=gt(X)}else{let X=q(c);[$,M,T,E]=gt(X)}G.test(l)?[,,x,y]=S(r,[null,null,x,y]):o.test(l)&&([,,x,y]=S(l,[null,null,x,y])),G.test(c)?[,,$,E]=S(r,[null,null,$,E]):o.test(c)&&([,,$,E]=S(c,[null,null,$,E])),[[x,u,m,y],[$,M,T,E]]=st([x,u,m,y],[$,M,T,E]);let B=y*g,P=E*p;b=B+P;let O=(x*g+$*p)%j,C,k;b===0?(C=u*g+M*p,k=m*g+T*p):(C=(u*B+M*P)/b,k=(m*B+T*P)/b),[A,D,N]=zt(`hwb(${O} ${C}% ${k}%)`)}else if(a==="lab"){let x,u,m,y;if(l.startsWith("color(")){let W=Y(l,!0);[x,u,m,y]=ft(W)}else{let W=q(l,!0);[x,u,m,y]=ft(W)}let $,M,T,E;if(c.startsWith("color(")){let W=Y(c,!0);[$,M,T,E]=ft(W)}else{let W=q(c,!0);[$,M,T,E]=ft(W)}G.test(l)?[x,,,y]=S(r,[x,null,null,y]):o.test(l)&&([x,,,y]=S(l,[x,null,null,y])),G.test(c)?[$,,,E]=S(r,[$,null,null,E]):o.test(c)&&([$,,,E]=S(c,[$,null,null,E])),[[x,u,m,y],[$,M,T,E]]=st([x,u,m,y],[$,M,T,E]);let B=y*g,P=E*p;b=B+P;let O,C,k;b===0?(O=x*g+$*p,C=u*g+M*p,k=m*g+T*p):(O=(x*B+$*P)*b,C=(u*B+M*P)*b,k=(m*B+T*P)*b),[A,D,N]=xt(`lab(${O} ${C} ${k})`)}else if(a==="lch"){let x,u;if(l.startsWith("color(")){let K=Y(l,!0);x=bt(K)}else{let K=q(l,!0);x=bt(K)}if(c.startsWith("color(")){let K=Y(c,!0);u=bt(K)}else{let K=q(c,!0);u=bt(K)}G.test(l)?x=S(r,x):o.test(l)&&(x=S(l,x)),G.test(c)?u=S(r,u):o.test(c)&&(u=S(c,u));let[[m,y,$,M],[T,E,B,P]]=st(x,u),O=M*g,C=P*p;b=O+C;let k,W,X;b===0?(k=m*g+T*p,W=y*g+E*p,X=$*g+B*p):(k=(m*O+T*C)*b,W=(y*O+E*C)*b,X=($*O+B*C)*b),[A,D,N]=xt(`lch(${k} ${W} ${X})`)}else if(a==="oklab"){let x,u,m,y;if(l.startsWith("color(")){let W=Y(l);[x,u,m,y]=ct(W)}else{let W=q(l);[x,u,m,y]=ct(W)}let $,M,T,E;if(c.startsWith("color(")){let W=Y(c);[$,M,T,E]=ct(W)}else{let W=q(c);[$,M,T,E]=ct(W)}G.test(l)?[x,,,y]=S(r,[x,null,null,y]):o.test(l)&&([x,,,y]=S(l,[x,null,null,y])),G.test(c)?[x,,,E]=S(r,[$,null,null,E]):o.test(c)&&([$,,,E]=S(c,[$,null,null,E])),[[x,u,m,y],[$,M,T,E]]=st([x,u,m,y],[$,M,T,E]);let B=y*g,P=E*p;b=B+P;let O,C,k;b===0?(O=x*g+$*p,C=u*g+M*p,k=m*g+T*p):(O=(x*B+$*P)*b,C=(u*B+M*P)*b,k=(m*B+T*P)*b),[A,D,N]=xt(`oklab(${O} ${C} ${k})`)}else if(a==="oklch"){let x,u;if(l.startsWith("color(")){let K=Y(l,!0);x=ut(K)}else{let K=q(l,!0);x=ut(K)}if(c.startsWith("color(")){let K=Y(c,!0);u=ut(K)}else{let K=q(c,!0);u=ut(K)}G.test(l)?x=S(r,x):o.test(l)&&(x=S(l,x)),G.test(c)?u=S(r,u):o.test(c)&&(u=S(c,u)),o.test(l)&&(x=S(l,x)),o.test(c)&&(u=S(c,u));let[[m,y,$,M],[T,E,B,P]]=st(x,u),O=M*g,C=P*p;b=O+C;let k,W,X;b===0?(k=m*g+T*p,W=y*g+E*p,X=$*g+B*p):(k=(m*O+T*C)*b,W=(y*O+E*C)*b,X=($*O+B*C)*b),[A,D,N]=xt(`oklch(${k} ${W} ${X})`)}return[A,D,N,b*R]};var Qt=new Rt({max:4096}),Ye=(t,s={})=>{if(U(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i=`{color:${t.toLowerCase()},opt:${JSON.stringify(s)}}`;if(Qt.has(i))return Qt.get(i);let{currentColor:r,format:e,key:n}=s,o,a,h,f;/^currentcolor$/i.test(t)?r?r.startsWith("color-mix")?[o,a,h,f]=Kt(r):r.startsWith("color(")?[o,a,h,f]=vt(r):[o,a,h,f]=xt(r):(o=0,a=0,h=0,f=0):/^transparent$/i.test(t)?(o=0,a=0,h=0,f=0):t.startsWith("color-mix")?[o,a,h,f]=Kt(t):t.startsWith("color(")?[o,a,h,f]=vt(t):[o,a,h,f]=xt(t);let l;switch(e){case"array":{n?l=[n,[o,a,h,f]]:l=[o,a,h,f];break}case"hex":{let d;/^transparent$/i.test(t)||isNaN(o)||isNaN(a)||isNaN(h)?d=null:d=Bt([o,a,h]),n?l=[n,d]:l=d;break}case"hexAlpha":{let d;/^transparent$/i.test(t)?d="#00000000":isNaN(o)||isNaN(a)||isNaN(h)||isNaN(f)?d=null:d=Bt([o,a,h,f]),n?l=[n,d]:l=d;break}default:{let d;isNaN(o)||isNaN(a)||isNaN(h)||isNaN(f)?d="":(o=Math.round(o),a=Math.round(a),h=Math.round(h),f===1?d=`rgb(${o}, ${a}, ${h})`:d=`rgba(${o}, ${a}, ${h}, ${f})`),n?l=[n,d]:l=d}}return Qt.set(i,l),l},Ve=(t,s={})=>{if(U(t)){if(t=t.trim(),t.startsWith("color-mix("))throw new Error("color-mix() is not supported.")}else throw new TypeError(`Expected String but got ${I(t)}.`);let{d50:i}=s,r;return t.startsWith("color(")?r=Y(t,i):r=q(t,i),r},qe={hexToRgb:Lt,numberToHex:rt,rgbToHex:Bt,xyzD50ToLab:ft,xyzD50ToLch:bt,xyzToHex:ge,xyzToHsl:lt,xyzToHwb:gt,xyzToOklab:ct,xyzToOklch:ut,xyzToRgb:at,xyzToXyzD50:ue};export{qe as convert,Ve as parse,Ye as resolve}; | ||
/*! | ||
@@ -3,0 +3,0 @@ * CSS color - Resolve, parse, convert CSS color. |
@@ -26,17 +26,22 @@ { | ||
"types": "types/index.d.ts", | ||
"dependencies": { | ||
"lru-cache": "^11.0.2" | ||
}, | ||
"devDependencies": { | ||
"c8": "^9.1.0", | ||
"chai": "^5.1.0", | ||
"esbuild": "^0.20.1", | ||
"eslint": "^8.57.0", | ||
"eslint-config-standard": "^17.1.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-jsdoc": "^48.2.0", | ||
"eslint-plugin-regexp": "^2.2.0", | ||
"eslint-plugin-unicorn": "^51.0.1", | ||
"mocha": "^10.3.0", | ||
"npm-run-all": "^4.1.5", | ||
"sinon": "^17.0.1", | ||
"typescript": "^5.3.3" | ||
"c8": "^10.1.2", | ||
"esbuild": "^0.24.0", | ||
"eslint": "^9.15.0", | ||
"eslint-plugin-import-x": "^4.4.2", | ||
"eslint-plugin-jsdoc": "^50.5.0", | ||
"eslint-plugin-regexp": "^2.7.0", | ||
"globals": "^15.12.0", | ||
"mocha": "^10.8.2", | ||
"neostandard": "^0.11.8", | ||
"npm-run-all2": "^7.0.1", | ||
"sinon": "^19.0.2", | ||
"typescript": "^5.6.3" | ||
}, | ||
"overrides": { | ||
"glob": "^10.4.5" | ||
}, | ||
"scripts": { | ||
@@ -51,3 +56,3 @@ "build": "npm run tsc && npm run lint && npm test && npm run bundle", | ||
}, | ||
"version": "1.1.0" | ||
"version": "1.1.1" | ||
} |
@@ -32,3 +32,3 @@ # CSS color | ||
### resolve | ||
### resolve(color, opt) | ||
@@ -64,3 +64,3 @@ Resolve CSS color. | ||
### parse | ||
### parse(color, opt) | ||
@@ -84,3 +84,3 @@ Parse CSS color. | ||
### convert.numberToHex | ||
### convert.numberToHex(n) | ||
@@ -96,3 +96,3 @@ Convert number to hex string. | ||
### convert.hexToRgb | ||
### convert.hexToRgb(hex) | ||
@@ -108,3 +108,3 @@ Convert hex color to rgb color array. | ||
### convert.rgbToHex | ||
### convert.rgbToHex(rgb) | ||
@@ -120,3 +120,3 @@ Convert rgb to hex color notation. | ||
### convert.xyzToHex | ||
### convert.xyzToHex(xyz) | ||
@@ -132,3 +132,3 @@ Convert xyz to hex color notation. | ||
### convert.xyzToHsl | ||
### convert.xyzToHsl(xyz) | ||
@@ -144,3 +144,3 @@ Convert xyz to hsl color array. | ||
### convert.xyzToHwb | ||
### convert.xyzToHwb(xyz) | ||
@@ -156,3 +156,3 @@ Convert xyz to hwb color array. | ||
### convert.xyzToOklab | ||
### convert.xyzToOklab(xyz) | ||
@@ -168,3 +168,3 @@ Convert xyz to oklab color array. | ||
### convert.xyzToOklch | ||
### convert.xyzToOklch(xyz) | ||
@@ -180,3 +180,3 @@ Convert xyz to oklch color array. | ||
### convert.xyzToRgb | ||
### convert.xyzToRgb(xyz) | ||
@@ -192,3 +192,3 @@ Convert xyz to rgb color array. | ||
### convert.xyzToXyzD50 | ||
### convert.xyzToXyzD50(xyz) | ||
@@ -204,3 +204,3 @@ Convert xyz to xyz-d50 color array. | ||
### convert.xyzD50ToLab | ||
### convert.xyzD50ToLab(xyz) | ||
@@ -216,3 +216,3 @@ Convert xyz-d50 to lab color array. | ||
### convert.xyzD50ToLch | ||
### convert.xyzD50ToLch(xyz) | ||
@@ -219,0 +219,0 @@ Convert xyz-d50 to lch color array. |
@@ -8,2 +8,3 @@ /*! | ||
import { LRUCache } from 'lru-cache'; | ||
import { | ||
@@ -18,2 +19,7 @@ convertHexToRgb, convertRgbToHex, convertXyzD50ToLab, convertXyzD50ToLch, | ||
/* cache resolved colors */ | ||
const resolvedColors = new LRUCache({ | ||
max: 4096 | ||
}); | ||
/** | ||
@@ -45,2 +51,6 @@ * resolve CSS color | ||
} | ||
const cacheKey = `{color:${color.toLowerCase()},opt:${JSON.stringify(opt)}}`; | ||
if (resolvedColors.has(cacheKey)) { | ||
return resolvedColors.get(cacheKey); | ||
} | ||
const { currentColor, format, key } = opt; | ||
@@ -136,2 +146,3 @@ let r, g, b, a; | ||
} | ||
resolvedColors.set(cacheKey, res); | ||
return res; | ||
@@ -138,0 +149,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
695665
12
3016
1
+ Addedlru-cache@^11.0.2
+ Addedlru-cache@11.0.2(transitive)