@asamuzakjp/css-color
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -1,2 +0,2 @@ | ||
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}; | ||
var dt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,se=new Set,Ht=typeof process=="object"&&process?process:{},ie=(t,e,i,r)=>{typeof Ht.emitWarning=="function"?Ht.emitWarning(t,e,i,r):console.error(`[${i}] ${e}: ${t}`)},St=globalThis.AbortController,ee=globalThis.AbortSignal;if(typeof St>"u"){ee=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(r,s){this._onabort.push(s)}},St=class{constructor(){e()}signal=new ee;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=!0;for(let s of this.signal._onabort)s(r);this.signal.onabort?.(r)}}};let t=Ht.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{t&&(t=!1,ie("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",e))}}var Re=t=>!se.has(t),is=Symbol("type"),ht=t=>t&&t===Math.floor(t)&&t>0&&isFinite(t),re=t=>ht(t)?t<=Math.pow(2,8)?Uint8Array:t<=Math.pow(2,16)?Uint16Array:t<=Math.pow(2,32)?Uint32Array:t<=Number.MAX_SAFE_INTEGER?ut:null:null,ut=class extends Array{constructor(e){super(e),this.fill(0)}},Gt=class t{heap;length;static#h=!1;static create(e){let i=re(e);if(!i)return[];t.#h=!0;let r=new t(e,i);return t.#h=!1,r}constructor(e,i){if(!t.#h)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0}push(e){this.heap[this.length++]=e}pop(){return this.heap[--this.length]}},bt=class t{#h;#f;#d;#u;#C;#O;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;#y;#m;#p;#F;#_;#c;static unsafeExposeInternals(e){return{starts:e.#m,ttls:e.#p,sizes:e.#y,keyMap:e.#i,keyList:e.#s,valList:e.#t,next:e.#l,prev:e.#x,get head(){return e.#a},get tail(){return e.#n},free:e.#w,isBackgroundFetch:i=>e.#e(i),backgroundFetch:(i,r,s,n)=>e.#W(i,r,s,n),moveToTail:i=>e.#M(i),indexes:i=>e.#$(i),rindexes:i=>e.#E(i),isStale:i=>e.#g(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.#O}get dispose(){return this.#d}get disposeAfter(){return this.#u}constructor(e){let{max:i=0,ttl:r,ttlResolution:s=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:a,allowStale:h,dispose:f,disposeAfter:l,noDisposeOnSet:g,noUpdateTTL:c,maxSize:w=0,maxEntrySize:d=0,sizeCalculation:p,fetchMethod:z,memoMethod:A,noDeleteOnFetchRejection:D,noDeleteOnStaleGet:N,allowStaleOnFetchRejection:b,allowStaleOnFetchAbort:x,ignoreFetchAbort:u}=e;if(i!==0&&!ht(i))throw new TypeError("max option must be a nonnegative integer");let y=i?re(i):Array;if(!y)throw new Error("invalid max value: "+i);if(this.#h=i,this.#f=w,this.maxEntrySize=d||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.#O=A,z!==void 0&&typeof z!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#C=z,this.#_=!!z,this.#i=new Map,this.#s=new Array(i).fill(void 0),this.#t=new Array(i).fill(void 0),this.#l=new y(i),this.#x=new y(i),this.#a=0,this.#n=0,this.#w=Gt.create(i),this.#r=0,this.#b=0,typeof f=="function"&&(this.#d=f),typeof l=="function"?(this.#u=l,this.#o=[]):(this.#u=void 0,this.#o=void 0),this.#F=!!this.#d,this.#c=!!this.#u,this.noDisposeOnSet=!!g,this.noUpdateTTL=!!c,this.noDeleteOnFetchRejection=!!D,this.allowStaleOnFetchRejection=!!b,this.allowStaleOnFetchAbort=!!x,this.ignoreFetchAbort=!!u,this.maxEntrySize!==0){if(this.#f!==0&&!ht(this.#f))throw new TypeError("maxSize must be a positive integer if specified");if(!ht(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=ht(s)||s===0?s:1,this.ttlAutopurge=!!n,this.ttl=r||0,this.ttl){if(!ht(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 F="LRU_CACHE_UNBOUNDED";Re(F)&&(se.add(F),ie("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",F,t))}}getRemainingTTL(e){return this.#i.has(e)?1/0:0}#B(){let e=new ut(this.#h),i=new ut(this.#h);this.#p=e,this.#m=i,this.#L=(n,o,a=dt.now())=>{if(i[n]=o!==0?a:0,e[n]=o,o!==0&&this.ttlAutopurge){let h=setTimeout(()=>{this.#g(n)&&this.#A(this.#s[n],"expire")},o+1);h.unref&&h.unref()}},this.#z=n=>{i[n]=e[n]!==0?dt.now():0},this.#T=(n,o)=>{if(e[o]){let a=e[o],h=i[o];if(!a||!h)return;n.ttl=a,n.start=h,n.now=r||s();let f=n.now-h;n.remainingTTL=a-f}};let r=0,s=()=>{let n=dt.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=e[o],h=i[o];if(!a||!h)return 1/0;let f=(r||s())-h;return a-f},this.#g=n=>{let o=i[n],a=e[n];return!!a&&!!o&&(r||s())-o>a}}#z=()=>{};#T=()=>{};#L=()=>{};#g=()=>!1;#X(){let e=new ut(this.#h);this.#b=0,this.#y=e,this.#R=i=>{this.#b-=e[i],e[i]=0},this.#N=(i,r,s,n)=>{if(this.#e(r))return 0;if(!ht(s))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(s=n(r,i),!ht(s))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 s},this.#S=(i,r,s)=>{if(e[i]=r,this.#f){let n=this.#f-e[i];for(;this.#b>n;)this.#D(!0)}this.#b+=e[i],s&&(s.entrySize=r,s.totalCalculatedSize=this.#b)}}#R=e=>{};#S=(e,i,r)=>{};#N=(e,i,r,s)=>{if(r||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#$({allowStale:e=this.allowStale}={}){if(this.#r)for(let i=this.#n;!(!this.#k(i)||((e||!this.#g(i))&&(yield i),i===this.#a));)i=this.#x[i]}*#E({allowStale:e=this.allowStale}={}){if(this.#r)for(let i=this.#a;!(!this.#k(i)||((e||!this.#g(i))&&(yield i),i===this.#n));)i=this.#l[i]}#k(e){return e!==void 0&&this.#i.get(this.#s[e])===e}*entries(){for(let e of this.#$())this.#t[e]!==void 0&&this.#s[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#s[e],this.#t[e]])}*rentries(){for(let e of this.#E())this.#t[e]!==void 0&&this.#s[e]!==void 0&&!this.#e(this.#t[e])&&(yield[this.#s[e],this.#t[e]])}*keys(){for(let e of this.#$()){let i=this.#s[e];i!==void 0&&!this.#e(this.#t[e])&&(yield i)}}*rkeys(){for(let e of this.#E()){let i=this.#s[e];i!==void 0&&!this.#e(this.#t[e])&&(yield i)}}*values(){for(let e of this.#$())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}*rvalues(){for(let e of this.#E())this.#t[e]!==void 0&&!this.#e(this.#t[e])&&(yield this.#t[e])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(e,i={}){for(let r of this.#$()){let s=this.#t[r],n=this.#e(s)?s.__staleWhileFetching:s;if(n!==void 0&&e(n,this.#s[r],this))return this.get(this.#s[r],i)}}forEach(e,i=this){for(let r of this.#$()){let s=this.#t[r],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&e.call(i,n,this.#s[r],this)}}rforEach(e,i=this){for(let r of this.#E()){let s=this.#t[r],n=this.#e(s)?s.__staleWhileFetching:s;n!==void 0&&e.call(i,n,this.#s[r],this)}}purgeStale(){let e=!1;for(let i of this.#E({allowStale:!0}))this.#g(i)&&(this.#A(this.#s[i],"expire"),e=!0);return e}info(e){let i=this.#i.get(e);if(i===void 0)return;let r=this.#t[i],s=this.#e(r)?r.__staleWhileFetching:r;if(s===void 0)return;let n={value:s};if(this.#p&&this.#m){let o=this.#p[i],a=this.#m[i];if(o&&a){let h=o-(dt.now()-a);n.ttl=h,n.start=Date.now()}}return this.#y&&(n.size=this.#y[i]),n}dump(){let e=[];for(let i of this.#$({allowStale:!0})){let r=this.#s[i],s=this.#t[i],n=this.#e(s)?s.__staleWhileFetching:s;if(n===void 0||r===void 0)continue;let o={value:n};if(this.#p&&this.#m){o.ttl=this.#p[i];let a=dt.now()-this.#m[i];o.start=Math.floor(Date.now()-a)}this.#y&&(o.size=this.#y[i]),e.unshift([r,o])}return e}load(e){this.clear();for(let[i,r]of e){if(r.start){let s=Date.now()-r.start;r.start=dt.now()-s}this.set(i,r.value,r)}}set(e,i,r={}){if(i===void 0)return this.delete(e),this;let{ttl:s=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=r,{noUpdateTTL:f=this.noUpdateTTL}=r,l=this.#N(e,i,r.size||0,a);if(this.maxEntrySize&&l>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=!0),this.#A(e,"set"),this;let g=this.#r===0?void 0:this.#i.get(e);if(g===void 0)g=this.#r===0?this.#n:this.#w.length!==0?this.#w.pop():this.#r===this.#h?this.#D(!1):this.#r,this.#s[g]=e,this.#t[g]=i,this.#i.set(e,g),this.#l[this.#n]=g,this.#x[g]=this.#n,this.#n=g,this.#r++,this.#S(g,l,h),h&&(h.set="add"),f=!1;else{this.#M(g);let c=this.#t[g];if(i!==c){if(this.#_&&this.#e(c)){c.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:w}=c;w!==void 0&&!o&&(this.#F&&this.#d?.(w,e,"set"),this.#c&&this.#o?.push([w,e,"set"]))}else o||(this.#F&&this.#d?.(c,e,"set"),this.#c&&this.#o?.push([c,e,"set"]));if(this.#R(g),this.#S(g,l,h),this.#t[g]=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(s!==0&&!this.#p&&this.#B(),this.#p&&(f||this.#L(g,s,n),h&&this.#T(h,g)),!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 e=this.#t[this.#a];if(this.#D(!0),this.#e(e)){if(e.__staleWhileFetching)return e.__staleWhileFetching}else if(e!==void 0)return e}}finally{if(this.#c&&this.#o){let e=this.#o,i;for(;i=e?.shift();)this.#u?.(...i)}}}#D(e){let i=this.#a,r=this.#s[i],s=this.#t[i];return this.#_&&this.#e(s)?s.__abortController.abort(new Error("evicted")):(this.#F||this.#c)&&(this.#F&&this.#d?.(s,r,"evict"),this.#c&&this.#o?.push([s,r,"evict"])),this.#R(i),e&&(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(e,i={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:s}=i,n=this.#i.get(e);if(n!==void 0){let o=this.#t[n];if(this.#e(o)&&o.__staleWhileFetching===void 0)return!1;if(this.#g(n))s&&(s.has="stale",this.#T(s,n));else return r&&this.#z(n),s&&(s.has="hit",this.#T(s,n)),!0}else s&&(s.has="miss");return!1}peek(e,i={}){let{allowStale:r=this.allowStale}=i,s=this.#i.get(e);if(s===void 0||!r&&this.#g(s))return;let n=this.#t[s];return this.#e(n)?n.__staleWhileFetching:n}#W(e,i,r,s){let n=i===void 0?void 0:this.#t[i];if(this.#e(n))return n;let o=new St,{signal:a}=r;a?.addEventListener("abort",()=>o.abort(a.reason),{signal:o.signal});let h={signal:o.signal,options:r,context:s},f=(p,z=!1)=>{let{aborted:A}=o.signal,D=r.ignoreFetchAbort&&p!==void 0;if(r.status&&(A&&!z?(r.status.fetchAborted=!0,r.status.fetchError=o.signal.reason,D&&(r.status.fetchAbortIgnored=!0)):r.status.fetchResolved=!0),A&&!D&&!z)return g(o.signal.reason);let N=w;return this.#t[i]===w&&(p===void 0?N.__staleWhileFetching?this.#t[i]=N.__staleWhileFetching:this.#A(e,"fetch"):(r.status&&(r.status.fetchUpdated=!0),this.set(e,p,h.options))),p},l=p=>(r.status&&(r.status.fetchRejected=!0,r.status.fetchError=p),g(p)),g=p=>{let{aborted:z}=o.signal,A=z&&r.allowStaleOnFetchAbort,D=A||r.allowStaleOnFetchRejection,N=D||r.noDeleteOnFetchRejection,b=w;if(this.#t[i]===w&&(!N||b.__staleWhileFetching===void 0?this.#A(e,"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,z)=>{let A=this.#C?.(e,n,h);A&&A instanceof Promise&&A.then(D=>p(D===void 0?void 0:D),z),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),d=Object.assign(w,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,d,{...h.options,status:void 0}),i=this.#i.get(e)):this.#t[i]=d,d}#e(e){if(!this.#_)return!1;let i=e;return!!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof St}async fetch(e,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=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:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:c=this.allowStaleOnFetchRejection,ignoreFetchAbort:w=this.ignoreFetchAbort,allowStaleOnFetchAbort:d=this.allowStaleOnFetchAbort,context:p,forceRefresh:z=!1,status:A,signal:D}=i;if(!this.#_)return A&&(A.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:n,status:A});let N={allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:a,size:h,sizeCalculation:f,noUpdateTTL:l,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:c,allowStaleOnFetchAbort:d,ignoreFetchAbort:w,status:A,signal:D},b=this.#i.get(e);if(b===void 0){A&&(A.fetch="miss");let x=this.#W(e,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.#g(b);if(!z&&!u)return A&&(A.fetch="hit"),this.#M(b),s&&this.#z(b),A&&this.#T(A,b),x;let y=this.#W(e,b,N,p),$=y.__staleWhileFetching!==void 0&&r;return A&&(A.fetch=u?"stale":"refresh",$&&u&&(A.returnedStale=!0)),$?y.__staleWhileFetching:y.__returned=y}}async forceFetch(e,i={}){let r=await this.fetch(e,i);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,i={}){let r=this.#O;if(!r)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:n,...o}=i,a=this.get(e,o);if(!n&&a!==void 0)return a;let h=r(e,a,{options:o,context:s});return this.set(e,h,o),h}get(e,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,a=this.#i.get(e);if(a!==void 0){let h=this.#t[a],f=this.#e(h);return o&&this.#T(o,a),this.#g(a)?(o&&(o.get="stale"),f?(o&&r&&h.__staleWhileFetching!==void 0&&(o.returnedStale=!0),r?h.__staleWhileFetching:void 0):(n||this.#A(e,"expire"),o&&r&&(o.returnedStale=!0),r?h:void 0)):(o&&(o.get="hit"),f?h.__staleWhileFetching:(this.#M(a),s&&this.#z(a),h))}else o&&(o.get="miss")}#I(e,i){this.#x[i]=e,this.#l[e]=i}#M(e){e!==this.#n&&(e===this.#a?this.#a=this.#l[e]:this.#I(this.#x[e],this.#l[e]),this.#I(this.#n,e),this.#n=e)}delete(e){return this.#A(e,"delete")}#A(e,i){let r=!1;if(this.#r!==0){let s=this.#i.get(e);if(s!==void 0)if(r=!0,this.#r===1)this.#P(i);else{this.#R(s);let n=this.#t[s];if(this.#e(n)?n.__abortController.abort(new Error("deleted")):(this.#F||this.#c)&&(this.#F&&this.#d?.(n,e,i),this.#c&&this.#o?.push([n,e,i])),this.#i.delete(e),this.#s[s]=void 0,this.#t[s]=void 0,s===this.#n)this.#n=this.#x[s];else if(s===this.#a)this.#a=this.#l[s];else{let o=this.#x[s];this.#l[o]=this.#l[s];let a=this.#l[s];this.#x[a]=this.#x[s]}this.#r--,this.#w.push(s)}}if(this.#c&&this.#o?.length){let s=this.#o,n;for(;n=s?.shift();)this.#u?.(...n)}return r}clear(){return this.#P("delete")}#P(e){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 s=this.#s[i];this.#F&&this.#d?.(r,s,e),this.#c&&this.#o?.push([r,s,e])}}if(this.#i.clear(),this.#t.fill(void 0),this.#s.fill(void 0),this.#p&&this.#m&&(this.#p.fill(0),this.#m.fill(0)),this.#y&&this.#y.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),H=t=>typeof t=="string"||t instanceof String;var st=.5,Ft=2,at=3,Z=4,ne=10,U=16,j=360,rt=60,R=100,T=255,Bt=2,_t=3,$t=2.4,Et=12.92,Q=.055,zt=116,ae=500,he=200,Ut=216/24389,Wt=24389/27,le=[.3457/.3585,1,(1-.3457-.3585)/.3585],At=[[.9554734527042182,-.023098536874261423,.0632593086610217],[-.028369706963208136,1.0099954580058226,.021041398966943008],[.012314001688319899,-.020507696433477912,1.3303659366080753]],tt=[[1.0479298208405488,.022946793341019088,-.05019222954313557],[.029627815688159344,.990434484573249,-.01707382502938514],[-.009243058152591178,.015055144896577895,.7518742899580008]],Vt=[[506752/1228815,87881/245763,12673/70218],[87098/409605,175762/245763,12673/175545],[7918/409605,87881/737289,1001167/1053270]],Nt=[[12831/3959,-329/214,-1974/3959],[-851781/878810,1648619/878810,36519/878810],[705/12673,-2585/12673,705/667]],Me=[[.8190224432164319,.3619062562801221,-.12887378261216414],[.0329836671980271,.9292868468965546,.03614466816999844],[.048177199566046255,.26423952494422764,.6335478258136937]],ce=[[1.2268798733741557,-.5578149965554813,.28139105017721583],[-.04057576262431372,1.1122868293970594,-.07171106666151701],[-.07637294974672142,-.4214933239627914,1.5869240244272418]],fe=[[.9999999984505196,.39633779217376774,.2158037580607588],[1.0000000088817607,-.10556134232365633,-.0638541747717059],[1.0000000546724108,-.08948418209496574,-1.2914855378640917]],Ce=[[.2104542553,.793617785,-.0040720468],[1.9779984951,-2.428592205,.4505937099],[.0259040371,.7827717662,-.808675766]],Oe=[[608311/1250200,189793/714400,198249/1000160],[35783/156275,247089/357200,198249/2500400],[0,32229/714400,5220557/5000800]],Se=[[63426534/99577255,20160776/139408157,47086771/278816314],[26158966/99577255,472592308/697040785,8267143/139408157],[0,19567812/697040785,295819943/278816314]],De=[[573536/994567,263643/1420810,187206/994567],[591459/1989134,6239551/9945670,374412/4972835],[53769/1989134,351524/4972835,4929758/4972835]],We=[[.7977604896723027,.13518583717574031,.0313493495815248],[.2880711282292934,.7118432178101014,8565396060525902e-20],[0,0,.8251046025104601]],m="none",kt="deg|g?rad|turn",xe="srgb(?:-linear)?",pe="xyz(?:-d(?:50|65))?",Be=`(?:ok)?l(?:ab|ch)|h(?:sl|wb)|${xe}|${pe}`,Le=`(?:a98|prophoto)-rgb|display-p3|rec2020|${xe}`,V="[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?",K=`${V}%`,Rt=`(?:${V}(?:${kt})?|${m})(?:\\s+(?:${K}|${m})){2}(?:\\s*\\/\\s*(?:${V}|${K}|${m}))?`,ge=`${V}(?:${kt})?(?:\\s*,\\s*${K}){2}(?:\\s*,\\s*(?:${V}|${K}))?`,qt=`(?:(?:${V}|${m})(?:\\s+(?:${V}|${m})){2}|(?:${K}|${m})(?:\\s+(?:${K}|${m})){2})(?:\\s*\\/\\s*(?:${V}|${K}|${m}))?`,de=`(?:${V}(?:\\s*,\\s*${V}){2}|${K}(?:\\s*,\\s*${K}){2})(?:\\s*,\\s*(?:${V}|${K}))?`,Mt=`(?:${V}|${K}|${m})(?:\\s+(?:${V}|${K}|${m})){2}(?:\\s*\\/\\s*(?:${V}|${K}|${m}))?`,Kt=`(?:(?:${V}|${K}|${m})\\s+){2}(?:${V}(?:${kt})?|${m})(?:\\s*\\/\\s*(?:${V}|${K}|${m}))?`,It=`(?:${Le}|${pe})(?:\\s+(?:${V}|${K}|${m})){3}(?:\\s*\\/\\s*(?:${V}|${K}|${m}))?`,ue=`[a-z]+|#(?:[\\da-f]{3}|[\\da-f]{4}|[\\da-f]{6}|[\\da-f]{8})|hsla?\\(\\s*(?:${Rt}|${ge})\\s*\\)|hwb\\(\\s*${Rt}\\s*\\)|rgba?\\(\\s*(?:${qt}|${de})\\s*\\)|(?:ok)?lab\\(\\s*${Mt}\\s*\\)|(?:ok)?lch\\(\\s*${Kt}\\s*\\)|color\\(\\s*${It}\\s*\\)`,oe=`(?:${ue})(?:\\s+${K})?`,Ne=`color-mix\\(\\s*in\\s+(${Be})\\s*,\\s*(${oe})\\s*,\\s*(${oe})\\s*\\)`,G=/^currentColor$/i,Lt={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]},v=(t,e={})=>{if(!Array.isArray(t))throw new TypeError(`Expected Array but got ${I(t)}.`);let{alpha:i=!1,minLength:r=at,maxLength:s=Z,minRange:n=0,maxRange:o=1,validateRange:a=!0}=e;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 s!="number")throw new TypeError(`Expected Number but got ${I(s)}.`);if(Number.isNaN(s))throw new TypeError(`${s} 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>s){let l;throw r===s?l=`Expected array length of ${s} but got ${h}.`:l=`Expected array length of ${r} or ${s} 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<at&&a&&(l<n||l>o))throw new RangeError(`${l} is not between ${n} and ${o}.`);if(f===at&&(l<0||l>1))throw new RangeError(`${l} is not between 0 and 1.`);f++}return i&&h===at&&t.push(1),t},L=(t,e)=>{if(Array.isArray(t)){if(t.length!==at)throw new Error(`Expected array length of 3 but got ${t.length}.`);for(let A of t)A=v(A,{maxLength:at,validateRange:!1})}else throw new TypeError(`Expected Array but got ${I(t)}.`);let[[i,r,s],[n,o,a],[h,f,l]]=t,[g,c,w]=v(e,{maxLength:at,validateRange:!1}),d=i*g+r*c+s*w,p=n*g+o*c+a*w,z=h*g+f*c+l*w;return[d,p,z]},O=(t,e=[])=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let[i,r,s,n]=e,o,a,h,f;if(/none/.test(t)){let l=new RegExp(`^rgba?\\(\\s*(${qt})\\s*\\)$`),g=new RegExp(`^color\\(\\s*(${It})\\s*\\)$`),c=new RegExp(`^h(?:sla?|wb)\\(\\s*(${Rt})\\s*\\)$`),w=new RegExp(`^(?:ok)?lab\\(\\s*(${Mt})\\s*\\)$`),d=new RegExp(`^(?:ok)?lch\\(\\s*(${Kt})\\s*\\)$`);l.test(t)?[o,a,h,f]=t.match(l)[1].replace("/"," ").split(/\s+/):g.test(t)?[,o,a,h,f]=t.match(g)[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+/):d.test(t)&&([o,a,h,f]=t.match(d)[1].replace("/"," ").split(/\s+/))}return[o===m?o:i,a===m?a:r,h===m?h:s,f===m?f:n]},it=(t,e)=>{if(Array.isArray(t)){if(t.length!==Z)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(e)){if(e.length!==Z)throw new Error(`Expected array length of 4 but got ${e.length}.`)}else throw new TypeError(`Expected Array but got ${I(e)}.`);let i=0;for(;i<Z;)t[i]===m&&e[i]===m?(t[i]=0,e[i]=0):t[i]===m?t[i]=e[i]:e[i]===m&&(e[i]=t[i]),i++;return t=v(t,{minLength:Z,validateRange:!1}),e=v(e,{minLength:Z,validateRange:!1}),[t,e]},nt=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>T)throw new RangeError(`${t} is not between 0 and ${T}.`);let e=t.toString(U);return e.length===1&&(e=`0${e}`),e},Pt=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=j/400,i=j/(Math.PI*Ft),r=new RegExp(`^(${V})(${kt})?$`);if(!r.test(t))throw new Error(`Invalid property value: ${t}`);let[,s,n]=t.match(r),o=s.startsWith(".")?`0${s}`:s,a;switch(n){case"grad":a=parseFloat(o)*e;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},Zt=t=>{let[e,i,r]=v(t,{maxLength:at,maxRange:T}),s=e/T,n=i/T,o=r/T,a=.04045;return s>a?s=Math.pow((s+Q)/(1+Q),$t):s/=Et,n>a?n=Math.pow((n+Q)/(1+Q),$t):n/=Et,o>a?o=Math.pow((o+Q)/(1+Q),$t):o/=Et,[s,n,o]},jt=t=>{let[e,i,r,s]=v(t,{alpha:!0,maxRange:T}),[n,o,a]=Zt([e,i,r]),[h,f,l]=L(Vt,[n,o,a]);return[h,f,l,s]};var Ct=t=>{let[e,i,r,s]=v(t,{alpha:!0,maxRange:T}),n=nt(e),o=nt(i),a=nt(r),h=nt(s*T),f;return h==="ff"?f=`#${n}${o}${a}`:f=`#${n}${o}${a}${h}`,f},vt=t=>{let[e,i,r]=v(t,{maxLength:at}),s=809/258400;return e>s?e=Math.pow(e,1/$t)*(1+Q)-Q:e*=Et,i>s?i=Math.pow(i,1/$t)*(1+Q)-Q:i*=Et,r>s?r=Math.pow(r,1/$t)*(1+Q)-Q:r*=Et,[Math.round(e*T),Math.round(i*T),Math.round(r*T)]},be=t=>{let[e,i,r,s]=v(t,{minLength:Z});[e,i,r]=vt([e,i,r]);let n=nt(e),o=nt(i),a=nt(r),h=nt(s*T),f;return h==="ff"?f=`#${n}${o}${a}`:f=`#${n}${o}${a}${h}`,f},we=t=>{let[e,i,r,s]=v(t,{minLength:Z,validateRange:!1}),[n,o,a]=L(Nt,[e,i,r]);return be([Math.min(Math.max(n,0),1),Math.min(Math.max(o,0),1),Math.min(Math.max(a,0),1),s])},ye=t=>{let[e,i,r,s]=v(t,{minLength:Z,validateRange:!1}),n=L(At,[e,i,r]),[o,a,h]=L(Nt,n);return be([Math.min(Math.max(o,0),1),Math.min(Math.max(a,0),1),Math.min(Math.max(h,0),1),s])},lt=t=>{let[e,i,r,s]=v(t,{validateRange:!1}),[n,o,a]=L(Nt,[e,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,s]},me=t=>{let[e,i,r,s]=v(t,{validateRange:!1}),[n,o,a]=L(tt,[e,i,r]);return[n,o,a,s]},ft=t=>{let[e,i,r,s]=lt(t),n=e/T,o=i/T,a=r/T,h=Math.max(n,o,a),f=Math.min(n,o,a),l=h-f,g=(h+f)*st*R,c,w;if(Math.round(g)===0||Math.round(g)===R)c=m,w=m;else if(w=l/(1-Math.abs(h+f-1))*R,w===0)c=m;else{switch(h){case n:c=(o-a)/l;break;case o:c=(a-n)/l+Ft;break;case a:default:c=(n-o)/l+Z;break}c=c*rt%j,c<0&&(c+=j)}return[c,w,g,s]},wt=t=>{let[e,i,r,s]=lt(t),n=Math.min(e,i,r)/T,o=1-Math.max(e,i,r)/T,a;return n+o===1?a=m:[a]=ft(t),[a,n*R,o*R,s]},xt=t=>{let[e,i,r,s]=v(t,{validateRange:!1}),o=L(Me,[e,i,r]).map(g=>Math.cbrt(g)),[a,h,f]=L(Ce,o);a=Math.min(Math.max(a,0),1);let l=Math.round(parseFloat(a.toFixed(Z))*R);return(l===0||l===R)&&(h=m,f=m),[a,h,f,s]},yt=t=>{let[e,i,r,s]=xt(t),n,o,a=Math.round(parseFloat(e.toFixed(Z))*R);return a===0||a===R?(n=m,o=m):(n=Math.max(Math.sqrt(Math.pow(i,Bt)+Math.pow(r,Bt)),0),parseFloat(n.toFixed(Z))===0?o=m:(o=Math.atan2(r,i)*j*st/Math.PI,o<0&&(o+=j))),[e,n,o,s]},Fe=t=>{let[e,i,r,s]=v(t,{minLength:Z,validateRange:!1}),n=L(At,[e,i,r]),[o,a,h]=lt(n);return[o,a,h,s]},pt=t=>{let[e,i,r,s]=v(t,{validateRange:!1}),n=[e,i,r].map((c,w)=>c/le[w]),[o,a,h]=n.map(c=>c>Ut?Math.cbrt(c):(c*Wt+U)/zt),f=Math.min(Math.max(zt*a-U,0),R),l,g;return f===0||f===R?(l=m,g=m):(l=(o-a)*ae,g=(a-h)*he),[f,l,g,s]},mt=t=>{let[e,i,r,s]=pt(t),n,o;return e===0||e===R?(n=m,o=m):(n=Math.max(Math.sqrt(Math.pow(i,Bt)+Math.pow(r,Bt)),0),parseFloat(n.toFixed(Z))===0?o=m:(o=Math.atan2(r,i)*j*st/Math.PI,o<0&&(o+=j))),[e,n,o,s]},Xt=t=>{if(H(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 e=[];if(/^#[\da-f]{6}$/.test(t)){let[,i,r,s]=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);e.push(parseInt(i,U),parseInt(r,U),parseInt(s,U),1)}else if(/^#[\da-f]{3}$/.test(t)){let[,i,r,s]=t.match(/^#([\da-f])([\da-f])([\da-f])$/);e.push(parseInt(`${i}${i}`,U),parseInt(`${r}${r}`,U),parseInt(`${s}${s}`,U),1)}else if(/^#[\da-f]{8}$/.test(t)){let[,i,r,s,n]=t.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);e.push(parseInt(i,U),parseInt(r,U),parseInt(s,U),parseInt(n,U)/T)}else if(/^#[\da-f]{4}$/.test(t)){let[,i,r,s,n]=t.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])$/);e.push(parseInt(`${i}${i}`,U),parseInt(`${r}${r}`,U),parseInt(`${s}${s}`,U),parseInt(`${n}${n}`,U)/T)}return e},ke=t=>{let[e,i,r,s]=Xt(t),[n,o,a]=Zt([e,i,r]);return[n,o,a,s]},Ie=t=>{let[e,i,r,s]=ke(t),[n,o,a]=L(Vt,[e,i,r]);return[n,o,a,s]},ct=t=>{if(H(t))if(t=t.trim(),!t)t=1;else if(t===m)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},$e=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=new RegExp(`^rgba?\\(\\s*(${qt}|${de})\\s*\\)$`);if(!e.test(t))throw new Error(`Invalid property value: ${t}`);let[,i]=t.match(e),[r,s,n,o]=i.replace(/[,/]/g," ").split(/\s+/);return r===m?r=0:(r.startsWith(".")&&(r=`0${r}`),r.endsWith("%")?r=parseFloat(r)*T/R:r=parseFloat(r)),s===m?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?s=parseFloat(s)*T/R:s=parseFloat(s)),n===m?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*T/R:n=parseFloat(n)),o=ct(o),[Math.min(Math.max(r,0),T),Math.min(Math.max(s,0),T),Math.min(Math.max(n,0),T),o]},Jt=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=new RegExp(`^hsla?\\(\\s*(${Rt}|${ge})\\s*\\)$`);if(!e.test(t))throw new Error(`Invalid property value: ${t}`);let[,i]=t.match(e),[r,s,n,o]=i.replace(/[,/]/g," ").split(/\s+/);r===m?r=0:r=Pt(r),s===m?s=0:(s.startsWith(".")&&(s=`0${s}`),s=Math.min(Math.max(parseFloat(s),0),R)),n===m?n=0:(n.startsWith(".")&&(n=`0${n}`),n=Math.min(Math.max(parseFloat(n),0),R)),o=ct(o);let a,h;n<R*st?(a=(n+n*(s/R))*T/R,h=(n-n*(s/R))*T/R):(a=(n+(R-n)*(s/R))*T/R,h=(n-(R-n)*(s/R))*T/R);let f=(a-h)/rt,l,g,c;return r>=0&&r<rt?(l=a,g=r*f+h,c=h):r<rt*Ft?(l=(rt*Ft-r)*f+h,g=a,c=h):r<j*st?(l=h,g=a,c=(r-rt*Ft)*f+h):r<rt*Z?(l=h,g=(rt*Z-r)*f+h,c=a):r<j-rt?(l=(r-rt*Z)*f+h,g=h,c=a):r<j&&(l=a,g=h,c=(j-r)*f+h),[Math.min(Math.max(l,0),T),Math.min(Math.max(g,0),T),Math.min(Math.max(c,0),T),o]},Ee=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=new RegExp(`^hwb\\(\\s*(${Rt})\\s*\\)$`);if(!e.test(t))throw new Error(`Invalid property value: ${t}`);let[,i]=t.match(e),[r,s,n,o]=i.replace("/"," ").split(/\s+/);r===m?r=0:r=Pt(r),s===m?s=0:(s.startsWith(".")&&(s=`0${s}`),s=Math.min(Math.max(parseFloat(s),0),R)/R),n===m?n=0:(n.startsWith(".")&&(n=`0${n}`),n=Math.min(Math.max(parseFloat(n),0),R)/R),o=ct(o);let a=[];if(s+n>=1){let h=s/(s+n)*T;a.push(h,h,h,o)}else{let[h,f,l]=Jt(`hsl(${r} 100% 50%)`),g=(1-s-n)/T;a.push((h*g+s)*T,(f*g+s)*T,(l*g+s)*T,o)}return a},Qt=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=new RegExp(`^lab\\(\\s*(${Mt})\\s*\\)$`);if(!e.test(t))throw new Error(`Invalid property value: ${t}`);let i=1.25,r=8,[,s]=t.match(e),[n,o,a,h]=s.replace("/"," ").split(/\s+/);n===m?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?(n=parseFloat(n),n>R&&(n=R)):n=parseFloat(n),n<0&&(n=0)),o===m?o=0:(o.startsWith(".")&&(o=`0${o}`),o.endsWith("%")?o=parseFloat(o)*i:o=parseFloat(o)),a===m?a=0:a.endsWith("%")?a=parseFloat(a)*i:a=parseFloat(a),h=ct(h);let f=(n+U)/zt,l=o/ae+f,g=f-a/he,c=Math.pow(f,_t),w=Math.pow(l,_t),d=Math.pow(g,_t),p=[w>Ut?w:(l*zt-U)/Wt,n>r?c:n/Wt,d>Ut?d:(g*zt-U)/Wt],[z,A,D]=p.map((N,b)=>N*le[b]);return[z,A,D,h]},Ae=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=new RegExp(`^lch\\(\\s*(${Kt})\\s*\\)$`);if(!e.test(t))throw new Error(`Invalid property value: ${t}`);let i=1.5,[,r]=t.match(e),[s,n,o,a]=r.replace("/"," ").split(/\s+/);s===m?s=0:(s.startsWith(".")&&(s=`0${s}`),s=parseFloat(s),s<0&&(s=0)),n===m?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*i:n=parseFloat(n)),o===m?o=0:o=Pt(o),a=ct(a);let h=n*Math.cos(o*Math.PI/(j*st)),f=n*Math.sin(o*Math.PI/(j*st)),[l,g,c]=Qt(`lab(${s} ${h} ${f})`);return[l,g,c,a]},Te=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=new RegExp(`^oklab\\(\\s*(${Mt})\\s*\\)$`);if(!e.test(t))throw new Error(`Invalid property value: ${t}`);let i=.4,[,r]=t.match(e),[s,n,o,a]=r.replace("/"," ").split(/\s+/);s===m?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?s=parseFloat(s)/R:s=parseFloat(s),s<0&&(s=0)),n===m?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*i/R:n=parseFloat(n)),o===m?o=0:o.endsWith("%")?o=parseFloat(o)*i/R:o=parseFloat(o),a=ct(a);let f=L(fe,[s,n,o]).map(w=>Math.pow(w,_t)),[l,g,c]=L(ce,f);return[l,g,c,a]},_e=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e=new RegExp(`^oklch\\(\\s*(${Mt})\\s*\\)$`);if(!e.test(t))throw new Error(`Invalid property value: ${t}`);let i=.4,[,r]=t.match(e),[s,n,o,a]=r.replace("/"," ").split(/\s+/);s===m?s=0:(s.startsWith(".")&&(s=`0${s}`),s.endsWith("%")?s=parseFloat(s)/R:s=parseFloat(s),s<0&&(s=0)),n===m?n=0:(n.startsWith(".")&&(n=`0${n}`),n.endsWith("%")?n=parseFloat(n)*i/R:n=parseFloat(n),n<0&&(n=0)),o===m?o=0:o=Pt(o),a=ct(a);let h=n*Math.cos(o*Math.PI/(j*st)),f=n*Math.sin(o*Math.PI/(j*st)),g=L(fe,[s,h,f]).map(p=>Math.pow(p,_t)),[c,w,d]=L(ce,g);return[c,w,d,a]},Y=(t,e=!1)=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i=new RegExp(`^color\\(\\s*(${It})\\s*\\)$`);if(!i.test(t))throw new Error(`Invalid property value: ${t}`);let[,r]=t.match(i),[s,n,o,a,h]=r.replace("/"," ").split(/\s+/),f,l,g;if(n===m)f=0;else{let z;n.startsWith(".")?z=`0${n}`:z=n,f=z.endsWith("%")?parseFloat(z)/R:parseFloat(z)}if(o===m)l=0;else{let z;o.startsWith(".")?z=`0${o}`:z=o,l=z.endsWith("%")?parseFloat(z)/R:parseFloat(z)}if(a===m)g=0;else{let z;a.startsWith(".")?z=`0${a}`:z=a,g=z.endsWith("%")?parseFloat(z)/R:parseFloat(z)}let c=ct(h),w,d,p;if(s==="srgb")[w,d,p]=jt([f*T,l*T,g*T]),e&&([w,d,p]=L(tt,[w,d,p]));else if(s==="srgb-linear")[w,d,p]=L(Vt,[f,l,g]),e&&([w,d,p]=L(tt,[w,d,p]));else if(s==="display-p3"){let z=Zt([f*T,l*T,g*T]);[w,d,p]=L(Oe,z),e&&([w,d,p]=L(tt,[w,d,p]))}else if(s==="rec2020"){let z=1.09929682680944,A=.018053968510807,D=.45,N=[f,l,g].map(b=>{let x;return b<A*D*ne?x=b/(D*ne):x=Math.pow((b+z-1)/z,1/D),x});[w,d,p]=L(Se,N),e&&([w,d,p]=L(tt,[w,d,p]))}else if(s==="a98-rgb"){let z=2.19921875,A=[f,l,g].map(D=>Math.pow(D,z));[w,d,p]=L(De,A),e&&([w,d,p]=L(tt,[w,d,p]))}else if(s==="prophoto-rgb"){let A=[f,l,g].map(D=>{let N;return D>1/(U*Ft)?N=Math.pow(D,1.8):N=D/U,N});[w,d,p]=L(We,A),e||([w,d,p]=L(At,[w,d,p]))}else/^xyz(?:-d(?:50|65))?$/.test(s)&&([w,d,p]=[f,l,g],s==="xyz-d50"?e||([w,d,p]=L(At,[w,d,p])):e&&([w,d,p]=L(tt,[w,d,p])));return[w,d,p,c]},q=(t,e=!1)=>{if(H(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i,r,s,n;if(G.test(t))i=0,r=0,s=0,n=0;else if(/^[a-z]+$/.test(t))if(Object.prototype.hasOwnProperty.call(Lt,t)){let[o,a,h]=Lt[t];n=1,[i,r,s]=jt([o,a,h]),e&&([i,r,s]=L(tt,[i,r,s]))}else if(t==="transparent")i=0,r=0,s=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,s,n]=Ie(o),e&&([i,r,s]=L(tt,[i,r,s]))}else if(t.startsWith("lab"))[i,r,s,n]=Qt(t),e||([i,r,s]=L(At,[i,r,s]));else if(t.startsWith("lch"))[i,r,s,n]=Ae(t),e||([i,r,s]=L(At,[i,r,s]));else if(t.startsWith("oklab"))[i,r,s,n]=Te(t),e&&([i,r,s]=L(tt,[i,r,s]));else if(t.startsWith("oklch"))[i,r,s,n]=_e(t),e&&([i,r,s]=L(tt,[i,r,s]));else{let o,a,h;if(t.startsWith("rgb"))[o,a,h,n]=$e(t);else if(t.startsWith("hsl"))[o,a,h,n]=Jt(t);else if(t.startsWith("hwb"))[o,a,h,n]=Ee(t);else throw new Error(`Invalid property value: ${t}`);[i,r,s]=jt([o,a,h]),e&&([i,r,s]=L(tt,[i,r,s]))}return[i,r,s,n]},Yt=(t,e={})=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let{alpha:i}=e,r,s,n,o;t.startsWith("color(")?[r,s,n,o]=Y(t):[r,s,n,o]=q(t);let[a,h,f]=L(Nt,[r,s,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},Dt=t=>{let[e,i,r,s]=Yt(t,{alpha:!0});return[e,i,r]=vt([e,i,r]),[e,i,r,s]},gt=t=>{if(H(t))t=t.toLowerCase().trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let e,i,r,s;if(G.test(t))e=0,i=0,r=0,s=0;else if(/^[a-z]+$/i.test(t))Object.prototype.hasOwnProperty.call(Lt,t)?([e,i,r]=Lt[t],s=1):t==="transparent"&&(e=0,i=0,r=0,s=0);else if(t.startsWith("#"))[e,i,r,s]=Xt(t);else if(/^l(?:ab|ch)/.test(t)){let o,a,h;t.startsWith("lab")?[o,a,h,s]=Qt(t):[o,a,h,s]=Ae(t),[e,i,r,s]=Fe([o,a,h,s])}else if(/^okl(?:ab|ch)/.test(t)){let o,a,h;t.startsWith("oklab")?[o,a,h,s]=Te(t):[o,a,h,s]=_e(t),[e,i,r,s]=lt([o,a,h,s])}else t.startsWith("rgb")?[e,i,r,s]=$e(t):t.startsWith("hsl")?[e,i,r,s]=Jt(t):t.startsWith("hwb")&&([e,i,r,s]=Ee(t));let n;return isNaN(e)||isNaN(i)||isNaN(r)||isNaN(s)?n=[]:n=[Math.round(e),Math.round(i),Math.round(r),s],n},te=t=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);if(!new RegExp(`^color\\(\\s*${It}\\s*\\)$`).test(t))throw new Error(`Invalid property value: ${t}`);let[i,r,s,n]=Y(t),[o,a,h]=lt([i,r,s]);return[o,a,h,n]},Ot=(t,e={})=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i=new RegExp(`^${Ne}$`,"i");if(!i.test(t))throw new Error(`Invalid property value: ${t}`);let r="lch(none none none / none)",s="rgb(none none none / none)",n=new RegExp(`^(${ue})(?:\\s+(${K}))?$`,"i"),o=new RegExp(m),[,a,h,f]=t.match(i),[,l,g]=h.match(n),[,c,w]=f.match(n),d,p,z;if(g&&w){let x=parseFloat(g)/R,u=parseFloat(w)/R;if(x<0||x>1)throw new RangeError(`${g} is not between 0% and 100%.`);if(u<0||u>1)throw new RangeError(`${w} is not between 0% and 100%.`);let y=x+u;if(y===0)throw new Error(`Invalid property value: ${t}`);d=x/y,p=u/y,z=y<1?y:1}else{if(g){if(d=parseFloat(g)/R,d<0||d>1)throw new RangeError(`${g} is not between 0% and 100%.`);p=1-d}else if(w){if(p=parseFloat(w)/R,p<0||p>1)throw new RangeError(`${w} is not between 0% and 100%.`);d=1-p}else d=st,p=st;z=1}let A,D,N,b;if(a==="srgb"){let x=Dt(l,{alpha:!0}),u=Dt(c,{alpha:!0});G.test(l)?x=O(s,x):o.test(l)&&(x=O(l,x)),G.test(c)?u=O(s,u):o.test(c)&&(u=O(c,u));let[[y,F,$,M],[_,E,B,P]]=it(x,u),S=M*d,C=P*p;b=S+C,b===0?(A=y*d+_*p,D=F*d+E*p,N=$*d+B*p):(A=(y*S+_*C)/b,D=(F*S+E*C)/b,N=($*S+B*C)/b)}else if(a==="srgb-linear"){let x=Yt(l,{alpha:!0}),u=Yt(c,{alpha:!0});G.test(l)?x=O(s,x):o.test(l)&&(x=O(l,x)),G.test(c)?u=O(s,u):o.test(c)&&(u=O(c,u));let[[y,F,$,M],[_,E,B,P]]=it(x,u),S=M*d,C=P*p;b=S+C,b===0?(A=(y*d+_*p)*T,D=(F*d+E*p)*T,N=($*d+B*p)*T):(A=(y*S+_*C)*b*T,D=(F*S+E*C)*b*T,N=($*S+B*C)*b*T)}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=O(s,x):o.test(l)&&(x=O(l,x)),G.test(c)?u=O(s,u):o.test(c)&&(u=O(c,u));let[[y,F,$,M],[_,E,B,P]]=it(x,u),S=M*d,C=P*p;b=S+C;let k,W,X;b===0?(k=y*d+_*p,W=F*d+E*p,X=$*d+B*p):(k=(y*S+_*C)*b,W=(F*S+E*C)*b,X=($*S+B*C)*b),[A,D,N]=lt([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=O(s,x):o.test(l)&&(x=O(l,x)),G.test(c)?u=O(s,u):o.test(c)&&(u=O(c,u));let[[y,F,$,M],[_,E,B,P]]=it(x,u),S=M*d,C=P*p;b=S+C;let k,W,X;b===0?(k=y*d+_*p,W=F*d+E*p,X=$*d+B*p):(k=(y*S+_*C)*b,W=(F*S+E*C)*b,X=($*S+B*C)*b),[A,D,N]=Fe([k,W,X,b])}else if(a==="hsl"){let x,u,y,F;if(l.startsWith("color(")){let W=Y(l);[x,u,y,F]=ft(W)}else{let W=q(l);[x,u,y,F]=ft(W)}let $,M,_,E;if(c.startsWith("color(")){let W=Y(c);[$,M,_,E]=ft(W)}else{let W=q(c);[$,M,_,E]=ft(W)}G.test(l)?[y,u,x,F]=O(r,[y,u,x,F]):o.test(l)&&([y,u,x,F]=O(l,[y,u,x,F])),G.test(c)?[_,M,$,E]=O(r,[_,M,$,E]):o.test(c)&&([_,M,$,E]=O(c,[_,M,$,E])),[[x,u,y,F],[$,M,_,E]]=it([x,u,y,F],[$,M,_,E]);let B=F*d,P=E*p;b=B+P;let S=(x*d+$*p)%j,C,k;b===0?(C=u*d+M*p,k=y*d+_*p):(C=(u*B+M*P)/b,k=(y*B+_*P)/b),[A,D,N]=Dt(`hsl(${S} ${C}% ${k}%)`)}else if(a==="hwb"){let x,u,y,F;if(l.startsWith("color(")){let X=Y(l);[x,u,y,F]=wt(X)}else{let X=q(l);[x,u,y,F]=wt(X)}let $,M,_,E;if(c.startsWith("color(")){let X=Y(c);[$,M,_,E]=wt(X)}else{let X=q(c);[$,M,_,E]=wt(X)}G.test(l)?[,,x,F]=O(r,[null,null,x,F]):o.test(l)&&([,,x,F]=O(l,[null,null,x,F])),G.test(c)?[,,$,E]=O(r,[null,null,$,E]):o.test(c)&&([,,$,E]=O(c,[null,null,$,E])),[[x,u,y,F],[$,M,_,E]]=it([x,u,y,F],[$,M,_,E]);let B=F*d,P=E*p;b=B+P;let S=(x*d+$*p)%j,C,k;b===0?(C=u*d+M*p,k=y*d+_*p):(C=(u*B+M*P)/b,k=(y*B+_*P)/b),[A,D,N]=Dt(`hwb(${S} ${C}% ${k}%)`)}else if(a==="lab"){let x,u,y,F;if(l.startsWith("color(")){let W=Y(l,!0);[x,u,y,F]=pt(W)}else{let W=q(l,!0);[x,u,y,F]=pt(W)}let $,M,_,E;if(c.startsWith("color(")){let W=Y(c,!0);[$,M,_,E]=pt(W)}else{let W=q(c,!0);[$,M,_,E]=pt(W)}G.test(l)?[x,,,F]=O(r,[x,null,null,F]):o.test(l)&&([x,,,F]=O(l,[x,null,null,F])),G.test(c)?[$,,,E]=O(r,[$,null,null,E]):o.test(c)&&([$,,,E]=O(c,[$,null,null,E])),[[x,u,y,F],[$,M,_,E]]=it([x,u,y,F],[$,M,_,E]);let B=F*d,P=E*p;b=B+P;let S,C,k;b===0?(S=x*d+$*p,C=u*d+M*p,k=y*d+_*p):(S=(x*B+$*P)*b,C=(u*B+M*P)*b,k=(y*B+_*P)*b),[A,D,N]=gt(`lab(${S} ${C} ${k})`)}else if(a==="lch"){let x,u;if(l.startsWith("color(")){let J=Y(l,!0);x=mt(J)}else{let J=q(l,!0);x=mt(J)}if(c.startsWith("color(")){let J=Y(c,!0);u=mt(J)}else{let J=q(c,!0);u=mt(J)}G.test(l)?x=O(r,x):o.test(l)&&(x=O(l,x)),G.test(c)?u=O(r,u):o.test(c)&&(u=O(c,u));let[[y,F,$,M],[_,E,B,P]]=it(x,u),S=M*d,C=P*p;b=S+C;let k,W,X;b===0?(k=y*d+_*p,W=F*d+E*p,X=$*d+B*p):(k=(y*S+_*C)*b,W=(F*S+E*C)*b,X=($*S+B*C)*b),[A,D,N]=gt(`lch(${k} ${W} ${X})`)}else if(a==="oklab"){let x,u,y,F;if(l.startsWith("color(")){let W=Y(l);[x,u,y,F]=xt(W)}else{let W=q(l);[x,u,y,F]=xt(W)}let $,M,_,E;if(c.startsWith("color(")){let W=Y(c);[$,M,_,E]=xt(W)}else{let W=q(c);[$,M,_,E]=xt(W)}G.test(l)?[x,,,F]=O(r,[x,null,null,F]):o.test(l)&&([x,,,F]=O(l,[x,null,null,F])),G.test(c)?[x,,,E]=O(r,[$,null,null,E]):o.test(c)&&([$,,,E]=O(c,[$,null,null,E])),[[x,u,y,F],[$,M,_,E]]=it([x,u,y,F],[$,M,_,E]);let B=F*d,P=E*p;b=B+P;let S,C,k;b===0?(S=x*d+$*p,C=u*d+M*p,k=y*d+_*p):(S=(x*B+$*P)*b,C=(u*B+M*P)*b,k=(y*B+_*P)*b),[A,D,N]=gt(`oklab(${S} ${C} ${k})`)}else if(a==="oklch"){let x,u;if(l.startsWith("color(")){let J=Y(l,!0);x=yt(J)}else{let J=q(l,!0);x=yt(J)}if(c.startsWith("color(")){let J=Y(c,!0);u=yt(J)}else{let J=q(c,!0);u=yt(J)}G.test(l)?x=O(r,x):o.test(l)&&(x=O(l,x)),G.test(c)?u=O(r,u):o.test(c)&&(u=O(c,u)),o.test(l)&&(x=O(l,x)),o.test(c)&&(u=O(c,u));let[[y,F,$,M],[_,E,B,P]]=it(x,u),S=M*d,C=P*p;b=S+C;let k,W,X;b===0?(k=y*d+_*p,W=F*d+E*p,X=$*d+B*p):(k=(y*S+_*C)*b,W=(F*S+E*C)*b,X=($*S+B*C)*b),[A,D,N]=gt(`oklch(${k} ${W} ${X})`)}return[A,D,N,b*z]};var et=new bt({max:4096}),Pe=t=>{let e=H(t)&&`{hexToRgb:${t.toLowerCase().trim()}}`;if(e&&et.has(e))return et.get(e);let i=Xt(t);return e&&et.set(e,i),i},Xe=t=>{let e=typeof t=="number"&&`{numberToHex:${t}}`;if(e&&et.has(e))return et.get(e);let i=nt(t);return e&&et.set(e,i),i},He=t=>{let e=`{name:rgbToHex,rgb:${JSON.stringify(t)}}`;if(et.has(e))return et.get(e);let i=Ct(t);return et.set(e,i),i},ot=(t,e)=>{let i=`{${e}:${JSON.stringify(t)}}`;if(et.has(i))return et.get(i);let r;switch(e){case"xyzD50ToHex":{r=ye(t);break}case"xyzD50ToLab":{r=pt(t);break}case"xyzD50ToLch":{r=mt(t);break}case"xyzToHex":{r=we(t);break}case"xyzToHsl":{r=ft(t);break}case"xyzToHwb":{r=wt(t);break}case"xyzToOklab":{r=xt(t);break}case"xyzToOklch":{r=yt(t);break}case"xyzToRgb":{r=lt(t);break}case"xyzToXyzD50":{r=me(t);break}default:throw new Error(`Invalid converter name: ${e}`)}return et.set(i,r),r},Ge=t=>ot(t,"xyzD50ToHex"),Ue=t=>ot(t,"xyzD50ToLab"),je=t=>ot(t,"xyzD50ToLch"),Ye=t=>ot(t,"xyzToHex"),Ve=t=>ot(t,"xyzToHsl"),qe=t=>ot(t,"xyzToHwb"),Ke=t=>ot(t,"xyzToOklab"),Ze=t=>ot(t,"xyzToOklch"),ve=t=>ot(t,"xyzToRgb"),Je=t=>ot(t,"xyzToXyzD50"),ze={hexToRgb:Pe,numberToHex:Xe,rgbToHex:He,xyzD50ToHex:Ge,xyzD50ToLab:Ue,xyzD50ToLch:je,xyzToHex:Ye,xyzToHsl:Ve,xyzToHwb:qe,xyzToOklab:Ke,xyzToOklch:Ze,xyzToRgb:ve,xyzToXyzD50:Je};var Tt=new bt({max:4096}),Qe=(t,e={})=>{if(H(t))t=t.trim();else throw new TypeError(`Expected String but got ${I(t)}.`);let i=`{resolve:${t.toLowerCase()},opt:${JSON.stringify(e)}}`;if(Tt.has(i))return Tt.get(i);let{currentColor:r,format:s,key:n}=e,o,a,h,f;/^currentcolor$/i.test(t)?r?r.startsWith("color-mix")?[o,a,h,f]=Ot(r):r.startsWith("color(")?[o,a,h,f]=te(r):[o,a,h,f]=gt(r):(o=0,a=0,h=0,f=0):/currentcolor/i.test(t)?(/transparent/i.test(t)&&(t=t.replace(/transparent/gi,"rgba(0, 0, 0, 0)")),r&&t.startsWith("color-mix")&&(t=t.replace(/currentcolor/gi,r),[o,a,h,f]=Ot(t))):/^transparent$/i.test(t)?(o=0,a=0,h=0,f=0):/transparent/i.test(t)?(t=t.replace(/transparent/gi,"rgba(0, 0, 0, 0)"),t.startsWith("color-mix")&&([o,a,h,f]=Ot(t))):t.startsWith("color-mix")?[o,a,h,f]=Ot(t):t.startsWith("color(")?[o,a,h,f]=te(t):[o,a,h,f]=gt(t);let l;switch(s){case"array":{n?l=[n,[o,a,h,f]]:l=[o,a,h,f];break}case"hex":{let g;/^transparent$/i.test(t)||isNaN(o)||isNaN(a)||isNaN(h)?g=null:g=Ct([o,a,h]),n?l=[n,g]:l=g;break}case"hexAlpha":{let g;/^transparent$/i.test(t)?g="#00000000":isNaN(o)||isNaN(a)||isNaN(h)||isNaN(f)?g=null:g=Ct([o,a,h,f]),n?l=[n,g]:l=g;break}default:{let g;isNaN(o)||isNaN(a)||isNaN(h)||isNaN(f)?g="":(o=Math.round(o),a=Math.round(a),h=Math.round(h),f===1?g=`rgb(${o}, ${a}, ${h})`:g=`rgba(${o}, ${a}, ${h}, ${f})`),n?l=[n,g]:l=g}}return Tt.set(i,l),l},ts=(t,e={})=>{if(H(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 i=`{parse:${t.toLowerCase()},opt:${JSON.stringify(e)}}`;if(Tt.has(i))return Tt.get(i);let{d50:r}=e,s;return t.startsWith("color(")?s=Y(t,r):s=q(t,r),Tt.set(i,s),s};export{ze as convert,ts as parse,Qe as resolve}; | ||
/*! | ||
@@ -3,0 +3,0 @@ * CSS color - Resolve, parse, convert CSS color. |
@@ -55,3 +55,3 @@ { | ||
}, | ||
"version": "1.1.1" | ||
"version": "1.1.2" | ||
} |
198
src/index.js
@@ -8,198 +8,2 @@ /*! | ||
import { LRUCache } from 'lru-cache'; | ||
import { | ||
convertHexToRgb, convertRgbToHex, convertXyzD50ToLab, convertXyzD50ToLch, | ||
convertXyzToHex, convertXyzToHsl, convertXyzToHwb, convertXyzToOklab, | ||
convertXyzToOklch, convertXyzToRgb, convertXyzToXyzD50, numberToHexString, | ||
parseColorFunc, parseColorValue, resolveColorFunc, resolveColorMix, | ||
resolveColorValue | ||
} from './js/color.js'; | ||
import { getType, isString } from './js/common.js'; | ||
/* cache resolved colors */ | ||
const resolvedColors = new LRUCache({ | ||
max: 4096 | ||
}); | ||
/** | ||
* resolve CSS color | ||
* @param {string} color - color value | ||
* - system colors are not supported | ||
* @param {object} [opt] - options | ||
* @param {string} [opt.currentColor] - color to use for `currentcolor` keyword | ||
* @param {string} [opt.format] - `rgb`(default), `array`, `hex` or `hexAlpha` | ||
* - `hexAlpha` is a hex color notation with alpha channel, i.e. #rrggbbaa | ||
* @param {*} [opt.key] - key e.g. CSS property `background-color` | ||
* @returns {?string|Array} - rgba?(), [r, g, b, a], #rrggbb(aa)?, null | ||
* - if `key` is specified, [key, rgba?()|[r, g, b, a]|#rrggbb(aa)?|null] | ||
* - in `rgb`, `r`, `g`, `b` values are rounded, | ||
* resolves as empty string if any of `r`, `g`, `b`, `a` is not a number | ||
* - in `array`, values are floating point, | ||
* if any of `r`, `g`, `b`, `a` is not a number then they stay as is, | ||
* e.g. [undefined, undefined, undefined, undefined] | ||
* - in `hex`, `transparent` resolves as `null`, | ||
* also resolves as `null` if any of `r`, `g`, `b`, `a` is not a number | ||
* - in `hexAlpha`, resolves as `null` if any of `r`, `g`, `b`, `a` is not a number | ||
*/ | ||
export const resolve = (color, opt = {}) => { | ||
if (isString(color)) { | ||
color = color.trim(); | ||
} else { | ||
throw new TypeError(`Expected String but got ${getType(color)}.`); | ||
} | ||
const cacheKey = `{color:${color.toLowerCase()},opt:${JSON.stringify(opt)}}`; | ||
if (resolvedColors.has(cacheKey)) { | ||
return resolvedColors.get(cacheKey); | ||
} | ||
const { currentColor, format, key } = opt; | ||
let r, g, b, a; | ||
if (/^currentcolor$/i.test(color)) { | ||
if (currentColor) { | ||
if (currentColor.startsWith('color-mix')) { | ||
[r, g, b, a] = resolveColorMix(currentColor); | ||
} else if (currentColor.startsWith('color(')) { | ||
[r, g, b, a] = resolveColorFunc(currentColor); | ||
} else { | ||
[r, g, b, a] = resolveColorValue(currentColor); | ||
} | ||
} else { | ||
r = 0; | ||
g = 0; | ||
b = 0; | ||
a = 0; | ||
} | ||
} else if (/^transparent$/i.test(color)) { | ||
r = 0; | ||
g = 0; | ||
b = 0; | ||
a = 0; | ||
} else if (color.startsWith('color-mix')) { | ||
[r, g, b, a] = resolveColorMix(color); | ||
} else if (color.startsWith('color(')) { | ||
[r, g, b, a] = resolveColorFunc(color); | ||
} else { | ||
[r, g, b, a] = resolveColorValue(color); | ||
} | ||
let res; | ||
switch (format) { | ||
case 'array': { | ||
if (key) { | ||
res = [key, [r, g, b, a]]; | ||
} else { | ||
res = [r, g, b, a]; | ||
} | ||
break; | ||
} | ||
case 'hex': { | ||
let hex; | ||
if (/^transparent$/i.test(color) || isNaN(r) || isNaN(g) || isNaN(b)) { | ||
hex = null; | ||
} else { | ||
hex = convertRgbToHex([r, g, b]); | ||
} | ||
if (key) { | ||
res = [key, hex]; | ||
} else { | ||
res = hex; | ||
} | ||
break; | ||
} | ||
case 'hexAlpha': { | ||
let hex; | ||
if (/^transparent$/i.test(color)) { | ||
hex = '#00000000'; | ||
} else if (isNaN(r) || isNaN(g) || isNaN(b) || isNaN(a)) { | ||
hex = null; | ||
} else { | ||
hex = convertRgbToHex([r, g, b, a]); | ||
} | ||
if (key) { | ||
res = [key, hex]; | ||
} else { | ||
res = hex; | ||
} | ||
break; | ||
} | ||
default: { | ||
let rgb; | ||
if (isNaN(r) || isNaN(g) || isNaN(b) || isNaN(a)) { | ||
rgb = ''; | ||
} else { | ||
r = Math.round(r); | ||
g = Math.round(g); | ||
b = Math.round(b); | ||
if (a === 1) { | ||
rgb = `rgb(${r}, ${g}, ${b})`; | ||
} else { | ||
rgb = `rgba(${r}, ${g}, ${b}, ${a})`; | ||
} | ||
} | ||
if (key) { | ||
res = [key, rgb]; | ||
} else { | ||
res = rgb; | ||
} | ||
} | ||
} | ||
resolvedColors.set(cacheKey, res); | ||
return res; | ||
}; | ||
/** | ||
* parse CSS color | ||
* @param {string} value - color value | ||
* - color-mix() and system colors are not supported | ||
* @param {object} [opt] - options | ||
* @param {boolean} [opt.d50] - xyz in d50 white point | ||
* @returns {Array.<number>} - [x, y, z, a] x|y|z: around 0..1 a: 0..1 | ||
*/ | ||
export const parse = (value, opt = {}) => { | ||
if (isString(value)) { | ||
value = value.trim(); | ||
if (value.startsWith('color-mix(')) { | ||
throw new Error('color-mix() is not supported.'); | ||
} | ||
} else { | ||
throw new TypeError(`Expected String but got ${getType(value)}.`); | ||
} | ||
const { d50 } = opt; | ||
let xyz; | ||
if (value.startsWith('color(')) { | ||
xyz = parseColorFunc(value, d50); | ||
} else { | ||
xyz = parseColorValue(value, d50); | ||
} | ||
return xyz; | ||
}; | ||
/** | ||
* convert | ||
* @property {Function} hexToRgb - convert hex to rgb | ||
* @property {Function} numberToHex - number to hex string | ||
* @property {Function} rgbToHex - convert rgb to hex | ||
* @property {Function} xyzD50ToHex - convert xyz d50 to hex | ||
* @property {Function} xyzD50ToLab - convert xyz d50 to lab | ||
* @property {Function} xyzD50ToLch - convert xyz d50 to lch | ||
* @property {Function} xyzD50ToRgb - convert xyz d50 to rgb | ||
* @property {Function} xyzToHex - convert xyz to hex | ||
* @property {Function} xyzToHsl - convert xyz to hsl | ||
* @property {Function} xyzToHwb - convert xyz to hwb | ||
* @property {Function} xyzToOklab - convert xyz to oklab | ||
* @property {Function} xyzToOklch - convert xyz to oklch | ||
* @property {Function} xyzToRgb - convert xyz to rgb | ||
* @property {Function} xyzToXyzD50 - convert xyz to xyz d50 | ||
*/ | ||
export const convert = { | ||
hexToRgb: convertHexToRgb, | ||
numberToHex: numberToHexString, | ||
rgbToHex: convertRgbToHex, | ||
xyzD50ToLab: convertXyzD50ToLab, | ||
xyzD50ToLch: convertXyzD50ToLch, | ||
xyzToHex: convertXyzToHex, | ||
xyzToHsl: convertXyzToHsl, | ||
xyzToHwb: convertXyzToHwb, | ||
xyzToOklab: convertXyzToOklab, | ||
xyzToOklch: convertXyzToOklch, | ||
xyzToRgb: convertXyzToRgb, | ||
xyzToXyzD50: convertXyzToXyzD50 | ||
}; | ||
export { convert, parse, resolve } from './js/api.js'; |
@@ -1,34 +0,1 @@ | ||
export function resolve(color: string, opt?: { | ||
currentColor?: string; | ||
format?: string; | ||
key?: any; | ||
}): (string | any[]) | null; | ||
export function parse(value: string, opt?: { | ||
d50?: boolean; | ||
}): Array<number>; | ||
export namespace convert { | ||
export { convertHexToRgb as hexToRgb }; | ||
export { numberToHexString as numberToHex }; | ||
export { convertRgbToHex as rgbToHex }; | ||
export { convertXyzD50ToLab as xyzD50ToLab }; | ||
export { convertXyzD50ToLch as xyzD50ToLch }; | ||
export { convertXyzToHex as xyzToHex }; | ||
export { convertXyzToHsl as xyzToHsl }; | ||
export { convertXyzToHwb as xyzToHwb }; | ||
export { convertXyzToOklab as xyzToOklab }; | ||
export { convertXyzToOklch as xyzToOklch }; | ||
export { convertXyzToRgb as xyzToRgb }; | ||
export { convertXyzToXyzD50 as xyzToXyzD50 }; | ||
} | ||
import { convertHexToRgb } from './js/color.js'; | ||
import { numberToHexString } from './js/color.js'; | ||
import { convertRgbToHex } from './js/color.js'; | ||
import { convertXyzD50ToLab } from './js/color.js'; | ||
import { convertXyzD50ToLch } from './js/color.js'; | ||
import { convertXyzToHex } from './js/color.js'; | ||
import { convertXyzToHsl } from './js/color.js'; | ||
import { convertXyzToHwb } from './js/color.js'; | ||
import { convertXyzToOklab } from './js/color.js'; | ||
import { convertXyzToOklch } from './js/color.js'; | ||
import { convertXyzToRgb } from './js/color.js'; | ||
import { convertXyzToXyzD50 } from './js/color.js'; | ||
export { convert, parse, resolve } from "./js/api.js"; |
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
720229
18
3225