gradiente 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gradiente.global.iife.js +79 -7
- package/dist/index.d.ts +170 -16
- package/dist/index.js +2134 -327
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){let n=10**t;return Math.round(e*n)/n}function n(e,t){let n=10**t;return Math.floor(e*n)/n}function r(e,t){let n=10**t;return Math.ceil(e*n)/n}function i(e,t){let n=10**t;return Math.trunc(e*n)/n}function a(e,t,n){return Math.min(Math.max(e,t),n)}function o(e){return e/100}function s(e){return e*100}function c(e){return e===`deg`||e===`rad`||e===`turn`||e===`grad`}function l(e){try{return typeof u(e)==`number`}catch{return!1}}function u(e){let t=e.match(/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/);if(t===null)throw Error(`Invalid angle value: "${e}"`);if(!c(t[2]))throw Error(`Unsupported angle unit: "${t[2]}"`);if(!Number.isFinite(+t[1]))throw SyntaxError(`Invalid angle value: "${t[1]}"`);let n=Number(t[1]);switch(t[2]){case`deg`:return d(n);case`rad`:return n;case`turn`:return p(n);case`grad`:return m(n)}}function d(e){return e*Math.PI/180}function f(e){return e*180/Math.PI}function p(e){return e*Math.PI*2}function m(e){return e*Math.PI/200}function h(e,n=3){return t((e%360+360)%360,n)}function g(e,n=6){let r=Math.PI*2;return t((e%r+r)%r,n)}let _=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},v={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},y=e=>_(v[e.toLowerCase()],6),b=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,x=e=>{let t;return(t=e.match(b))?_(parseInt(t[1],16),t[1].length):void 0},S=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`;`${S}`;let C=`${S}%`;`${S}`;let
|
|
2
|
-
`||r===` `||r===` `){for(;
|
|
3
|
-
`||t[
|
|
4
|
-
`||t[N]===` `||t[N]===` `);)N++;let e;if(de(t)&&(e=P(t),e.type!==M.Hue)){n.push({type:M.Alpha,value:e});continue}if(fe(t)&&he(t)===`none`){n.push({type:M.Alpha,value:{type:M.None,value:void 0}});continue}return}if(/\d/.test(r)){N--,n.push(P(t));continue}if(le.test(r)){N--,n.push(ge(t));continue}return}return n}function ve(e){e._i=0;let t=e[e._i++];if(!t||t.type!==M.Function||t.value!==`color`||(t=e[e._i++],t.type!==M.Ident))return;let n=ae[t.value];if(!n)return;let r={mode:n},i=ye(e,!1);if(!i)return;let a=se(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==M.None&&(r[n]=t.type===M.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function ye(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===M.None||r.type===M.Number||r.type===M.Alpha||r.type===M.Percentage||t&&r.type===M.Hue){n.push(r);continue}if(r.type===M.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==M.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:M.None,value:void 0}),n.every(e=>e.type!==M.Alpha)?n:void 0}}function be(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==M.Function)return;let r=ye(e,t);if(r)return r.unshift(n.value),r}let xe=e=>{if(typeof e!=`string`)return;let t=_e(e),n=t?be(t,!0):void 0,r,i=0,a=A.length;for(;i<a;)if((r=A[i++](e,n))!==void 0)return r;return t?ve(t):void 0};function Se(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(!(r.type===M.Hue||i.type===M.Hue||a.type===M.Hue))return r.type!==M.None&&(n.r=r.type===M.Number?r.value/255:r.value/100),i.type!==M.None&&(n.g=i.type===M.Number?i.value/255:i.value/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value/255:a.value/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let Ce=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,we=(e,t,n)=>e+n*(t-e),Te=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},F=(e=>t=>{let n=Te(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(we),I=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},L={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[Se,x,ne,y,Ce,`srgb`],serialize:`srgb`,interpolate:{r:F,g:F,b:F,alpha:{use:F,fixup:I}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},Ee=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),De=e=>{let t=Ee(e.r),n=Ee(e.g),r=Ee(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},Oe=e=>Math.abs(e)**(256/563)*Math.sign(e),ke=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:Oe(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:Oe(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:Oe(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Ae=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},R=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Ae(e),g:Ae(t),b:Ae(n)};return r!==void 0&&(i.alpha=r),i},z=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},je=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},B=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:je(e),g:je(t),b:je(n)};return r!==void 0&&(a.alpha=r),a},V=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=B({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},Me={...L,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>ke(z(e)),xyz65:ke},toMode:{rgb:e=>V(De(e)),xyz65:De}},H=e=>(e%=360)<0?e+360:e,Ne=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=H(n);return r===0||e[r-1]===void 0?a:t(a-H(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),U=e=>Ne(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),Pe=e=>Ne(e,e=>Math.abs(e)>=180||e===0?e:e-360*Math.sign(e)),Fe=e=>Ne(e,e=>e>=0?e:e+360),Ie=e=>Ne(e,e=>e<=0?e:e-360),W=[-.14861,1.78277,-.29227,-.90649,1.97294,0],Le=Math.PI/180,Re=180/Math.PI,ze=W[3]*W[4],Be=W[1]*W[4],Ve=W[1]*W[2]-W[0]*W[3],He=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(Ve*n+e*ze-t*Be)/(Ve+ze-Be),a=n-i,o=(W[4]*(t-i)-W[2]*a)/W[3],s={mode:`cubehelix`,l:i,s:i===0||i===1?void 0:Math.sqrt(a*a+o*o)/(W[4]*i*(1-i))};return s.s&&(s.h=Math.atan2(o,a)*Re-120),r!==void 0&&(s.alpha=r),s},Ue=({h:e,s:t,l:n,alpha:r})=>{let i={mode:`rgb`};e=(e===void 0?0:e+120)*Le,n===void 0&&(n=0);let a=t===void 0?0:t*n*(1-n),o=Math.cos(e),s=Math.sin(e);return i.r=n+a*(W[0]*o+W[1]*s),i.g=n+a*(W[2]*o+W[3]*s),i.b=n+a*(W[4]*o+W[5]*s),r!==void 0&&(i.alpha=r),i},We=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=H(e.h),r=H(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},Ge=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=H(e.h),r=H(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},Ke=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=H(e.h),r=H(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},G=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},qe={mode:`cubehelix`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--cubehelix`],serialize:`--cubehelix`,ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:He},toMode:{rgb:Ue},interpolate:{h:{use:F,fixup:U},s:F,l:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}},K=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=H(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},q=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a},Je=29**3/3**3,Ye=6**3/29**3,J={X:.3457/.3585,Y:1,Z:.2958/.3585},Y={X:.3127/.329,Y:1,Z:.3583/.329},Xe=e=>e**3>Ye?e**3:(116*e-16)/Je,Ze=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz65`,x:Xe(a)*Y.X,y:Xe(i)*Y.Y,z:Xe(o)*Y.Z};return r!==void 0&&(s.alpha=r),s},Qe=e=>V(Ze(e)),$e=e=>e>Ye?Math.cbrt(e):(Je*e+16)/116,et=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=$e(e/Y.X),a=$e(t/Y.Y),o=$e(n/Y.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},tt=e=>{let t=et(z(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},nt=26/180*Math.PI,rt=Math.cos(nt),it=Math.sin(nt),at=100/Math.log(139/100),ot=({l:e,c:t,h:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`lab65`,l:(Math.exp(e*1/at)-1)/.0039},a=(Math.exp(.0435*t*1*1)-1)/.075,o=a*Math.cos(n/180*Math.PI-nt),s=a*Math.sin(n/180*Math.PI-nt);return i.a=o*rt-s/.83*it,i.b=o*it+s/.83*rt,r!==void 0&&(i.alpha=r),i},st=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=t*rt+n*it,a=.83*(n*rt-t*it),o=Math.sqrt(i*i+a*a),s={mode:`dlch`,l:at/1*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*1*1)};return s.c&&(s.h=H((Math.atan2(a,i)+nt)/Math.PI*180)),r!==void 0&&(s.alpha=r),s},ct=e=>ot(K(e,`dlch`)),lt=e=>q(st(e),`dlab`),ut={mode:`dlab`,parse:[`--din99o-lab`],serialize:`--din99o-lab`,toMode:{lab65:ct,rgb:e=>Qe(ct(e))},fromMode:{lab65:lt,rgb:e=>lt(tt(e))},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:F,a:F,b:F,alpha:{use:F,fixup:I}}},dt={mode:`dlch`,parse:[`--din99o-lch`],serialize:`--din99o-lch`,toMode:{lab65:ot,dlab:e=>q(e,`dlab`),rgb:e=>Qe(ot(e))},fromMode:{lab65:st,dlab:e=>K(e,`dlch`),rgb:e=>st(tt(e))},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:F,c:F,h:{use:F,fixup:U},alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}};function ft({h:e,s:t,i:n,alpha:r}){e=H(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n*(1+t*(3/(2-i)-1)),g:n*(1+t*(3*(1-i)/(2-i)-1)),b:n*(1-t)};break;case 1:a={r:n*(1+t*(3*(1-i)/(2-i)-1)),g:n*(1+t*(3/(2-i)-1)),b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n*(1+t*(3/(2-i)-1)),b:n*(1+t*(3*(1-i)/(2-i)-1))};break;case 3:a={r:n*(1-t),g:n*(1+t*(3*(1-i)/(2-i)-1)),b:n*(1+t*(3/(2-i)-1))};break;case 4:a={r:n*(1+t*(3*(1-i)/(2-i)-1)),g:n*(1-t),b:n*(1+t*(3/(2-i)-1))};break;case 5:a={r:n*(1+t*(3/(2-i)-1)),g:n*(1-t),b:n*(1+t*(3*(1-i)/(2-i)-1))};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function pt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsi`,s:e+t+n===0?0:1-3*a/(e+t+n),i:(e+t+n)/3};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let mt={mode:`hsi`,toMode:{rgb:ft},parse:[`--hsi`],serialize:`--hsi`,fromMode:{rgb:pt},channels:[`h`,`s`,`i`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:F,fixup:U},s:F,i:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}};function ht({h:e,s:t,l:n,alpha:r}){e=H(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function gt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let _t=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},vt=RegExp(`^hsla?\\(\\s*${ee}${E}${C}${E}${C}\\s*(?:,\\s*${w}\\s*)?\\)$`),yt=e=>{let t=e.match(vt);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=_t(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function bt(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Percentage)return;n.h=r.value}if(i.type!==M.None){if(i.type===M.Hue)return;n.s=i.value/100}if(a.type!==M.None){if(a.type===M.Hue)return;n.l=a.value/100}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let xt={mode:`hsl`,toMode:{rgb:ht},fromMode:{rgb:gt},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[bt,yt],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:F,fixup:U},s:F,l:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}};function St({h:e,s:t,v:n,alpha:r}){e=H(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function Ct({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let wt={mode:`hsv`,toMode:{rgb:St},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:Ct},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:F,fixup:U},s:F,v:F,alpha:{use:F,fixup:I}},difference:{h:We},average:{h:G}};function Tt({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return St({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function Et(e){let t=Ct(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function Dt(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Percentage)return;n.h=r.value}if(i.type!==M.None){if(i.type===M.Hue)return;n.w=i.value/100}if(a.type!==M.None){if(a.type===M.Hue)return;n.b=a.value/100}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let Ot={mode:`hwb`,toMode:{rgb:Tt},fromMode:{rgb:Et},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Dt],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:F,fixup:U},w:F,b:F,alpha:{use:F,fixup:I}},difference:{h:Ge},average:{h:G}},kt=.1593017578125,At=78.84375,jt=.8359375,Mt=18.8515625,Nt=18.6875;function Pt(e){if(e<0)return 0;let t=e**(1/At);return 1e4*(Math.max(0,t-jt)/(Mt-Nt*t))**(1/kt)}function Ft(e){if(e<0)return 0;let t=(e/1e4)**kt;return((jt+Mt*t)/(1+Nt*t))**+At}let It=e=>Math.max(e/203,0),Lt=({i:e,t,p:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Pt(e+.008609037037932761*t+.11102962500302593*n),a=Pt(e-.00860903703793275*t-.11102962500302599*n),o=Pt(e+.5600313357106791*t-.32062717498731885*n),s={mode:`xyz65`,x:It(2.070152218389422*i-1.3263473389671556*a+.2066510476294051*o),y:It(.3647385209748074*i+.680566024947227*a-.0453045459220346*o),z:It(-.049747207535812*i-.0492609666966138*a+1.1880659249923042*o)};return r!==void 0&&(s.alpha=r),s},Rt=(e=0)=>Math.max(e*203,0),zt=({x:e,y:t,z:n,alpha:r})=>{let i=Rt(e),a=Rt(t),o=Rt(n),s=Ft(.3592832590121217*i+.6976051147779502*a-.0358915932320289*o),c=Ft(-.1920808463704995*i+1.1004767970374323*a+.0753748658519118*o),l=Ft(.0070797844607477*i+.0748396662186366*a+.8433265453898765*o),u={mode:`itp`,i:.5*s+.5*c,t:1.61376953125*s-3.323486328125*c+1.709716796875*l,p:4.378173828125*s-4.24560546875*c-.132568359375*l};return r!==void 0&&(u.alpha=r),u},Bt={mode:`itp`,channels:[`i`,`t`,`p`,`alpha`],parse:[`--ictcp`],serialize:`--ictcp`,toMode:{xyz65:Lt,rgb:e=>V(Lt(e))},fromMode:{xyz65:zt,rgb:e=>zt(z(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:F,t:F,p:F,alpha:{use:F,fixup:I}}},Vt=e=>{if(e<0)return 0;let t=(e/1e4)**kt;return((jt+Mt*t)/(1+Nt*t))**134.03437499999998},Ht=(e=0)=>Math.max(e*203,0),Ut=({x:e,y:t,z:n,alpha:r})=>{e=Ht(e),t=Ht(t),n=Ht(n);let i=1.15*e-.15*n,a=.66*t+.34*e,o=Vt(.41478972*i+.579999*a+.014648*n),s=Vt(-.20151*i+1.120649*a+.0531008*n),c=Vt(-.0166008*i+.2648*a+.6684799*n),l=(o+s)/2,u={mode:`jab`,j:.44*l/(1-.56*l)-16295499532821565e-27,a:3.524*o-4.066708*s+.542708*c,b:.199076*o+1.096799*s-1.295875*c};return r!==void 0&&(u.alpha=r),u},Wt=16295499532821565e-27,Gt=e=>{if(e<0)return 0;let t=e**(1/134.03437499999998);return 1e4*((jt-t)/(Nt*t-Mt))**(1/kt)},Kt=e=>e/203,qt=({j:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+Wt)/(.44+.56*(e+Wt)),a=Gt(i+.13860504*t+.058047316*n),o=Gt(i-.13860504*t-.058047316*n),s=Gt(i-.096019242*t-.8118919*n),c={mode:`xyz65`,x:Kt(1.661373024652174*a-.914523081304348*o+.23136208173913045*s),y:Kt(-.3250758611844533*a+1.571847026732543*o-.21825383453227928*s),z:Kt(-.090982811*a-.31272829*o+1.5227666*s)};return r!==void 0&&(c.alpha=r),c},Jt=e=>{let t=Ut(z(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Yt=e=>V(qt(e)),Xt={mode:`jab`,channels:[`j`,`a`,`b`,`alpha`],parse:[`--jzazbz`],serialize:`--jzazbz`,fromMode:{rgb:Jt,xyz65:Ut},toMode:{rgb:Yt,xyz65:qt},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:F,a:F,b:F,alpha:{use:F,fixup:I}}},Zt=({j:e,a:t,b:n,alpha:r})=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),a={mode:`jch`,j:e,c:i};return i&&(a.h=H(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},Qt=({j:e,c:t,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:`jab`,j:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},$t={mode:`jch`,parse:[`--jzczhz`],serialize:`--jzczhz`,toMode:{jab:Qt,rgb:e=>Yt(Qt(e))},fromMode:{rgb:e=>Zt(Jt(e)),jab:Zt},channels:[`j`,`c`,`h`,`alpha`],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:F,fixup:U},c:F,j:F,alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}},en=29**3/3**3,tn=6**3/29**3,nn=e=>e**3>tn?e**3:(116*e-16)/en,rn=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:nn(a)*J.X,y:nn(i)*J.Y,z:nn(o)*J.Z};return r!==void 0&&(s.alpha=r),s},an=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=B({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},on=e=>an(rn(e)),sn=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},cn=e=>e>tn?Math.cbrt(e):(en*e+16)/116,ln=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=cn(e/J.X),a=cn(t/J.Y),o=cn(n/J.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},un=e=>{let t=ln(sn(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function dn(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(!(r.type===M.Hue||i.type===M.Hue||a.type===M.Hue))return r.type!==M.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==M.None&&(n.a=i.type===M.Number?i.value:i.value*125/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value:a.value*125/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let fn={mode:`lab`,toMode:{xyz50:rn,rgb:on},fromMode:{xyz50:ln,rgb:un},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[dn],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:F,a:F,b:F,alpha:{use:F,fixup:I}}},pn={...fn,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:Ze,rgb:Qe},fromMode:{xyz65:et,rgb:tt},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function mn(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==M.None&&(n.c=Math.max(0,i.type===M.Number?i.value:i.value*150/100)),a.type!==M.None){if(a.type===M.Percentage)return;n.h=a.value}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let hn={mode:`lch`,toMode:{lab:q,rgb:e=>on(q(e))},fromMode:{rgb:e=>K(un(e)),lab:K},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[mn],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:F,fixup:U},c:F,l:F,alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}},gn={...hn,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>q(e,`lab65`),rgb:e=>Qe(q(e,`lab65`))},fromMode:{rgb:e=>K(tt(e),`lch65`),lab65:e=>K(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},_n=({l:e,u:t,v:n,alpha:r})=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),a={mode:`lchuv`,l:e,c:i};return i&&(a.h=H(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},vn=({l:e,c:t,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:`luv`,l:e,u:t?t*Math.cos(n/180*Math.PI):0,v:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},yn=(e,t,n)=>4*e/(e+15*t+3*n),bn=(e,t,n)=>9*t/(e+15*t+3*n),xn=yn(J.X,J.Y,J.Z),Sn=bn(J.X,J.Y,J.Z),Cn=e=>e<=tn?en*e:116*Math.cbrt(e)-16,wn=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Cn(t/J.Y),a=yn(e,t,n),o=bn(e,t,n);!isFinite(a)||!isFinite(o)?i=a=o=0:(a=13*i*(a-xn),o=13*i*(o-Sn));let s={mode:`luv`,l:i,u:a,v:o};return r!==void 0&&(s.alpha=r),s},Tn=(e,t,n)=>4*e/(e+15*t+3*n),En=(e,t,n)=>9*t/(e+15*t+3*n),Dn=Tn(J.X,J.Y,J.Z),On=En(J.X,J.Y,J.Z),kn=({l:e,u:t,v:n,alpha:r})=>{if(e===void 0&&(e=0),e===0)return{mode:`xyz50`,x:0,y:0,z:0};t===void 0&&(t=0),n===void 0&&(n=0);let i=t/(13*e)+Dn,a=n/(13*e)+On,o=J.Y*(e<=8?e/en:((e+16)/116)**3),s={mode:`xyz50`,x:9*i*o/(4*a),y:o,z:o*(12-3*i-20*a)/(4*a)};return r!==void 0&&(s.alpha=r),s},An={mode:`lchuv`,toMode:{luv:vn,rgb:e=>an(kn(vn(e)))},fromMode:{rgb:e=>_n(wn(sn(e))),luv:_n},channels:[`l`,`c`,`h`,`alpha`],parse:[`--lchuv`],serialize:`--lchuv`,ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:F,fixup:U},c:F,l:F,alpha:{use:F,fixup:I}},difference:{h:Ke},average:{h:G}},jn={...L,mode:`lrgb`,toMode:{rgb:B},fromMode:{rgb:R},parse:[`srgb-linear`],serialize:`srgb-linear`},Mn={mode:`luv`,toMode:{xyz50:kn,rgb:e=>an(kn(e))},fromMode:{xyz50:wn,rgb:e=>wn(sn(e))},channels:[`l`,`u`,`v`,`alpha`],parse:[`--luv`],serialize:`--luv`,ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l:F,u:F,v:F,alpha:{use:F,fixup:I}}},Nn=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},Pn=e=>{let t=Nn(R(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Fn=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},In=e=>B(Fn(e));function Ln(e){let t=.206,n=.03,r=(1+t)/(1+n);return .5*(r*e-t+Math.sqrt((r*e-t)*(r*e-t)+4*n*r*e))}function Rn(e){let t=.206,n=.03;return(1+t)/(1+n),(e*e+t*e)/(1.170873786407767*(e+n))}function zn(e,t){let n,r,i,a,o,s,c,l;-1.88170328*e-.80936493*t>1?(n=1.19086277,r=1.76576728,i=.59662641,a=.75515197,o=.56771245,s=4.0767416621,c=-3.3077115913,l=.2309699292):1.81444104*e-1.19445276*t>1?(n=.73956515,r=-.45954404,i=.08285427,a=.1254107,o=.14503204,s=-1.2684380046,c=2.6097574011,l=-.3413193965):(n=1.35733652,r=-.00915799,i=-1.1513021,a=-.50559606,o=.00692167,s=-.0041960863,c=-.7034186147,l=1.707614701);let u=n+r*e+i*t+a*e*e+o*e*t,d=.3963377774*e+.2158037573*t,f=-.1055613458*e-.0638541728*t,p=-.0894841775*e-1.291485548*t;{let e=1+u*d,t=1+u*f,n=1+u*p,r=e*e*e,i=t*t*t,a=n*n*n,o=3*d*e*e,m=3*f*t*t,h=3*p*n*n,g=6*d*d*e,_=6*f*f*t,v=6*p*p*n,y=s*r+c*i+l*a,b=s*o+c*m+l*h,x=s*g+c*_+l*v;u-=y*b/(b*b-.5*y*x)}return u}function Bn(e,t){let n=zn(e,t),r=Fn({l:1,a:n*e,b:n*t}),i=Math.cbrt(1/Math.max(r.r,r.g,r.b));return[i,i*n]}function Vn(e,t,n,r,i,a=null){a||=Bn(e,t);let o;if((n-i)*a[1]-(a[0]-i)*r<=0)o=a[1]*i/(r*a[0]+a[1]*(i-n));else{o=a[1]*(i-1)/(r*(a[0]-1)+a[1]*(i-n));{let a=n-i,s=r,c=.3963377774*e+.2158037573*t,l=-.1055613458*e-.0638541728*t,u=-.0894841775*e-1.291485548*t,d=a+s*c,f=a+s*l,p=a+s*u;{let e=i*(1-o)+o*n,t=o*r,a=e+t*c,s=e+t*l,m=e+t*u,h=a*a*a,g=s*s*s,_=m*m*m,v=3*d*a*a,y=3*f*s*s,b=3*p*m*m,x=6*d*d*a,S=6*f*f*s,C=6*p*p*m,w=4.0767416621*h-3.3077115913*g+.2309699292*_-1,T=4.0767416621*v-3.3077115913*y+.2309699292*b,ee=4.0767416621*x-3.3077115913*S+.2309699292*C,E=T/(T*T-.5*w*ee),D=-w*E,te=-1.2684380046*h+2.6097574011*g-.3413193965*_-1,ne=-1.2684380046*v+2.6097574011*y-.3413193965*b,re=-1.2684380046*x+2.6097574011*S-.3413193965*C,O=ne/(ne*ne-.5*te*re),k=-te*O,ie=-.0041960863*h-.7034186147*g+1.707614701*_-1,A=-.0041960863*v-.7034186147*y+1.707614701*b,ae=-.0041960863*x-.7034186147*S+1.707614701*C,oe=A/(A*A-.5*ie*ae),j=-ie*oe;D=E>=0?D:1e6,k=O>=0?k:1e6,j=oe>=0?j:1e6,o+=Math.min(D,Math.min(k,j))}}}return o}function Hn(e,t,n=null){n||=Bn(e,t);let r=n[0],i=n[1];return[i/r,i/(1-r)]}function Un(e,t,n){let r=Bn(t,n),i=Vn(t,n,e,1,e,r),a=Hn(t,n,r),o=.11516993+1/(7.4477897+4.1590124*n+t*(-2.19557347+1.75198401*n+t*(-2.13704948-10.02301043*n+t*(-4.24894561+5.38770819*n+4.69891013*t)))),s=.11239642+1/(1.6132032-.68124379*n+t*(.40370612+.90148123*n+t*(-.27087943+.6122399*n+t*(.00299215-.45399568*n-.14661872*t)))),c=i/Math.min(e*a[0],(1-e)*a[1]),l=e*o,u=(1-e)*s,d=.9*c*Math.sqrt(Math.sqrt(1/(1/(l*l*l*l)+1/(u*u*u*u))));return l=e*.4,u=(1-e)*.8,[Math.sqrt(1/(1/(l*l)+1/(u*u))),d,i]}function Wn(e){let t=e.l===void 0?0:e.l,n=e.a===void 0?0:e.a,r=e.b===void 0?0:e.b,i={mode:`okhsl`,l:Ln(t)};e.alpha!==void 0&&(i.alpha=e.alpha);let a=Math.sqrt(n*n+r*r);if(!a)return i.s=0,i;let[o,s,c]=Un(t,n/a,r/a),l;if(a<s){let e=.8*o,t=1-e/s;l=(a-0)/(e+t*(a-0))*.8}else{let e=s,t=.2*s*s*1.25*1.25/o,n=1-t/(c-s);l=.8+.2*((a-e)/(t+n*(a-e)))}return l&&(i.s=l,i.h=H(Math.atan2(r,n)*180/Math.PI)),i}function Gn(e){let t=e.h===void 0?0:e.h,n=e.s===void 0?0:e.s,r=e.l===void 0?0:e.l,i={mode:`oklab`,l:Rn(r)};if(e.alpha!==void 0&&(i.alpha=e.alpha),!n||r===1)return i.a=i.b=0,i;let a=Math.cos(t/180*Math.PI),o=Math.sin(t/180*Math.PI),[s,c,l]=Un(i.l,a,o),u,d,f,p;n<.8?(u=1.25*n,d=0,f=.8*s,p=1-f/c):(u=5*(n-.8),d=c,f=.2*c*c*1.25*1.25/s,p=1-f/(l-c));let m=d+u*f/(1-p*u);return i.a=m*a,i.b=m*o,i}let Kn={...xt,mode:`okhsl`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--okhsl`],serialize:`--okhsl`,fromMode:{oklab:Wn,rgb:e=>Wn(Pn(e))},toMode:{oklab:Gn,rgb:e=>In(Gn(e))}};function qn(e){let t=e.l===void 0?0:e.l,n=e.a===void 0?0:e.a,r=e.b===void 0?0:e.b,i=Math.sqrt(n*n+r*r),a=i?n/i:1,o=i?r/i:1,[s,c]=Hn(a,o),l=.5,u=1-l/s,d=c/(i+t*c),f=d*t,p=d*i,m=Rn(f),h=p*m/f,g=Fn({l:m,a:a*h,b:o*h}),_=Math.cbrt(1/Math.max(g.r,g.g,g.b,0));t/=_,i=i/_*Ln(t)/t,t=Ln(t);let v={mode:`okhsv`,s:i?(l+c)*p/(c*l+c*u*p):0,v:t?t/f:0};return v.s&&(v.h=H(Math.atan2(r,n)*180/Math.PI)),e.alpha!==void 0&&(v.alpha=e.alpha),v}function Jn(e){let t={mode:`oklab`};e.alpha!==void 0&&(t.alpha=e.alpha);let n=e.h===void 0?0:e.h,r=e.s===void 0?0:e.s,i=e.v===void 0?0:e.v,a=Math.cos(n/180*Math.PI),o=Math.sin(n/180*Math.PI),[s,c]=Hn(a,o),l=.5,u=1-l/s,d=1-r*l/(l+c-c*u*r),f=r*c*l/(l+c-c*u*r),p=Rn(d),m=f*p/d,h=Fn({l:p,a:a*m,b:o*m}),g=Math.cbrt(1/Math.max(h.r,h.g,h.b,0)),_=Rn(i*d),v=f*_/d;return t.l=_*g,t.a=v*a*g,t.b=v*o*g,t}let Yn={...wt,mode:`okhsv`,channels:[`h`,`s`,`v`,`alpha`],parse:[`--okhsv`],serialize:`--okhsv`,fromMode:{oklab:qn,rgb:e=>qn(Pn(e))},toMode:{oklab:Jn,rgb:e=>In(Jn(e))}};function Xn(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(!(r.type===M.Hue||i.type===M.Hue||a.type===M.Hue))return r.type!==M.None&&(n.l=Math.min(Math.max(0,r.type===M.Number?r.value:r.value/100),1)),i.type!==M.None&&(n.a=i.type===M.Number?i.value:i.value*.4/100),a.type!==M.None&&(n.b=a.type===M.Number?a.value:a.value*.4/100),o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let Zn={...fn,mode:`oklab`,toMode:{lrgb:Fn,rgb:In},fromMode:{lrgb:Nn,rgb:Pn},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[Xn],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function Qn(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==M.None){if(r.type===M.Hue)return;n.l=Math.min(Math.max(0,r.type===M.Number?r.value:r.value/100),1)}if(i.type!==M.None&&(n.c=Math.max(0,i.type===M.Number?i.value:i.value*.4/100)),a.type!==M.None){if(a.type===M.Percentage)return;n.h=a.value}return o.type!==M.None&&(n.alpha=Math.min(1,Math.max(0,o.type===M.Number?o.value:o.value/100))),n}let $n={...hn,mode:`oklch`,toMode:{oklab:e=>q(e,`oklab`),rgb:e=>In(q(e,`oklab`))},fromMode:{rgb:e=>K(Pn(e),`oklch`),oklab:e=>K(e,`oklch`)},parse:[Qn],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},er=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},tr=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=B({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},nr={...L,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>tr(z(e)),xyz65:tr},toMode:{rgb:e=>V(er(e)),xyz65:er}},rr=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},ir=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:rr(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:rr(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:rr(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},ar=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},or=e=>{let t=ar(e.r),n=ar(e.g),r=ar(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},sr={...L,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:ir,rgb:e=>ir(sn(e))},toMode:{xyz50:or,rgb:e=>an(or(e))}},cr=1.09929682680944,lr=e=>{let t=Math.abs(e);return t>.018053968510807?(Math.sign(e)||1)*(cr*t**.45-(cr-1)):4.5*e},ur=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:lr(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:lr(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:lr(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},dr=1.09929682680944,fr=(e=0)=>{let t=Math.abs(e);return t<.018053968510807*4.5?e/4.5:(Math.sign(e)||1)*((t+dr-1)/dr)**(1/.45)},pr=e=>{let t=fr(e.r),n=fr(e.g),r=fr(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},mr={...L,mode:`rec2020`,fromMode:{xyz65:ur,rgb:e=>ur(z(e))},toMode:{xyz65:pr,rgb:e=>V(pr(e))},parse:[`rec2020`],serialize:`rec2020`},X=.0037930732552754493,hr=Math.cbrt(X),gr=e=>Math.cbrt(e)-hr,_r=e=>{let{r:t,g:n,b:r,alpha:i}=R(e),a=gr(.3*t+.622*n+.078*r+X),o=gr(.23*t+.692*n+.078*r+X),s=gr(.2434226892454782*t+.2047674442449682*n+.5518098665095535*r+X),c={mode:`xyb`,x:(a-o)/2,y:(a+o)/2,b:s-(a+o)/2};return i!==void 0&&(c.alpha=i),c},vr=e=>(e+hr)**3,yr={mode:`xyb`,channels:[`x`,`y`,`b`,`alpha`],parse:[`--xyb`],serialize:`--xyb`,toMode:{rgb:({x:e,y:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=vr(e+t)-X,a=vr(t-e)-X,o=vr(n+t)-X,s=B({r:11.031566904639861*i-9.866943908131562*a-.16462299650829934*o,g:-3.2541473810744237*i+4.418770377582723*a-.16462299650829934*o,b:-3.6588512867136815*i+2.7129230459360922*a+1.9459282407775895*o});return r!==void 0&&(s.alpha=r),s}},fromMode:{rgb:_r},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:F,y:F,b:F,alpha:{use:F,fixup:I}}},br={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:an,lab:ln},fromMode:{rgb:sn,lab:rn},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:F,y:F,z:F,alpha:{use:F,fixup:I}}},xr={mode:`xyz65`,toMode:{rgb:V,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:z,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:F,y:F,z:F,alpha:{use:F,fixup:I}}},Sr={mode:`yiq`,toMode:{rgb:({y:e,i:t,q:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rgb`,r:e+.95608445*t+.6208885*n,g:e-.27137664*t-.6486059*n,b:e-1.10561724*t+1.70250126*n};return r!==void 0&&(i.alpha=r),i}},fromMode:{rgb:({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`yiq`,y:.29889531*e+.58662247*t+.11448223*n,i:.59597799*e-.2741761*t-.32180189*n,q:.21147017*e-.52261711*t+.31114694*n};return r!==void 0&&(i.alpha=r),i}},channels:[`y`,`i`,`q`,`alpha`],parse:[`--yiq`],serialize:`--yiq`,ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:F,i:F,q:F,alpha:{use:F,fixup:I}}},Cr=(e,t)=>Math.round(e*(t=10**t))/t,wr=((e=4)=>t=>typeof t==`number`?Cr(t,e):t)(2),Tr=e=>Math.max(0,Math.min(1,e||0)),Er=e=>Math.round(Tr(e)*255),Dr=O(`rgb`),Or=e=>{if(e===void 0)return;let t=Er(e.r),n=Er(e.g),r=Er(e.b);return e.alpha===void 0||e.alpha===1?`rgb(${t}, ${n}, ${r})`:`rgba(${t}, ${n}, ${r}, ${wr(Tr(e.alpha))})`},Z=e=>Or(Dr(e)),kr=(e,t=`rgb`,n=!1)=>{let r=t?se(t).channels:null,i=t?O(t):re;return a=>{let o=i(a);if(!o)return;let s=(r||se(o.mode).channels).reduce((n,r)=>{let i=e(o[r],r,o,t);return i!==void 0&&!isNaN(i)&&(n[r]=i),n},{mode:o.mode});if(!n)return s;let c=re(a);return c&&c.mode!==s.mode?O(c.mode)(s):s}},Ar=(e,t,n)=>t===`alpha`?e:(e||0)*(n.alpha===void 0?1:n.alpha),jr=(e,t,n)=>t!==`alpha`&&n.alpha!==0?(e||0)/(n.alpha===void 0?1:n.alpha):e,Mr=e=>{e[0]===void 0&&(e[0]=0),e[e.length-1]===void 0&&(e[e.length-1]=1);let t=1,n,r,i,a;for(;t<e.length;){if(e[t]===void 0){for(r=t,i=e[t-1],n=t;e[n]===void 0;)n++;for(a=(e[n]-i)/(n-t+1);t<n;)e[t]=i+(t+1-r)*a,t++}else e[t]<e[t-1]&&(e[t]=e[t-1]);t++}return e},Nr=(e=.5)=>t=>e<=0?1:e>=1?0:t**+(Math.log(.5)/Math.log(e)),Pr=e=>typeof e==`function`,Q=e=>e&&typeof e==`object`,Fr=e=>typeof e==`number`,Ir=(e,t=`rgb`,n,r)=>{let i=se(t),a=O(t),o=[],s=[],c={};e.forEach(e=>{Array.isArray(e)?(o.push(a(e[0])),s.push(e[1])):Fr(e)||Pr(e)?c[s.length]=e:(o.push(a(e)),s.push(void 0))}),Mr(s);let l=i.channels.reduce((e,t)=>{let r;return r=Q(n)&&Q(n[t])&&n[t].fixup?n[t].fixup:Q(i.interpolate[t])&&i.interpolate[t].fixup?i.interpolate[t].fixup:e=>e,e[t]=r(o.map(e=>e[t])),e},{});if(r){let e=o.map((e,n)=>i.channels.reduce((e,t)=>(e[t]=l[t][n],e),{mode:t}));l=i.channels.reduce((n,i)=>(n[i]=e.map(e=>{let n=r(e[i],i,e,t);return isNaN(n)?void 0:n}),n),{})}let u=i.channels.reduce((e,t)=>{let r;return Pr(n)?r=n:Q(n)&&Pr(n[t])?r=n[t]:Q(n)&&Q(n[t])&&n[t].use?r=n[t].use:Pr(i.interpolate[t])?r=i.interpolate[t]:Q(i.interpolate[t])&&(r=i.interpolate[t].use),e[t]=r(l[t]),e},{}),d=o.length-1;return e=>{if(e=Math.min(Math.max(0,e),1),e<=s[0])return o[0];if(e>s[d])return o[d];let n=0;for(;s[n]<e;)n++;let r=s[n-1],a=s[n]-r,l=(e-r)/a,f=c[n]||c[0];f!==void 0&&(Fr(f)&&(f=Nr((f-r)/a)),l=f(l));let p=(n-1+l)/d;return i.channels.reduce((e,t)=>{let n=u[t](p);return n!==void 0&&(e[t]=n),e},{mode:t})}},Lr=(e,t=`rgb`,n)=>Ir(e,t,n);((e,t)=>(n,r=`rgb`,i)=>{let a=t?kr(t,r):void 0,o=Ir(n,r,i,e);return a?e=>a(o(e)):o})(Ar,jr),j(Me),j(qe),j(ut),j(dt),j(mt),j(xt),j(wt),j(Ot),j(Bt),j(Xt),j($t),j(fn),j(pn),j(hn),j(gn),j(An),j(jn),j(Mn),j(Kn),j(Yn),j(Zn),j($n),j(nr),j(sr),j(mr),j(L),j(yr),j(br),j(xr),j(Sr);let Rr=function(e){return e.START=`^`,e.END=`.`,e.GROUP_OPEN=`(`,e.GROUP_CLOSE=`)`,e.COMMA=`,`,e.SEQUENCE_OPEN=`[`,e.SEQUENCE_CLOSE=`]`,e.OR=`|`,e.AND=`&`,e.NOT=`!`,e.REPEAT=`~`,e.CONFIG=`config`,e.COLOR_STOP=`color-stop`,e.COLOR_HINT=`color-hint`,e}({});function zr(e,t,n,r){let i=n,a=r;for(;a<t.length;){let o=t[a];if(o===`.`||o===`)`||o===`]`||o===`|`)break;if(o===`,`){a+=1;continue}let s=Vr(e,t,i,a);if(!s.matched)return{matched:!1,nextInputIndex:n,nextPatternIndex:r};i=s.nextInputIndex,a=s.nextPatternIndex}return{matched:!0,nextInputIndex:i,nextPatternIndex:a}}function Br(e,t,n,r){let i=t[r],a=e[n];if(i!==`config`&&i!==`color-stop`&&i!==`color-hint`)throw Error(`Expected entity token at pattern index ${r}`);return!a||a.type!==i?{matched:!1,nextInputIndex:n,nextPatternIndex:r}:{matched:!0,nextInputIndex:n+1,nextPatternIndex:r+1}}function Vr(e,t,n,r){let i=t[r];if(i===`config`||i===`color-stop`||i===`color-hint`)return Br(e,t,n,r);if(i===`[`)return Ur(e,t,n,r);if(i===`(`)return Gr(e,t,n,r);if(i===`~`)return Kr(e,t,n,r);throw Error(`Unsupported primary token "${i}" at pattern index ${r}`)}function Hr(e,t,n,r){if(e[t]!==n)throw Error(`Expected "${n}" at pattern index ${t}, got "${e[t]}"`);let i=0;for(let a=t;a<e.length;a+=1){let t=e[a];if(t===n){i+=1;continue}if(t===r&&(--i,i===0))return a}throw Error(`Unclosed token pair "${n}${r}"`)}function Ur(e,t,n,r){if(t[r]!==`[`)throw Error(`Expected "[" at pattern index ${r}`);let i=Hr(t,r,`[`,`]`),a=n,o=r+1;for(;o<i;){if(t[o]===`,`){o+=1;continue}let i=Vr(e,t,a,o);if(!i.matched)return{matched:!1,nextInputIndex:n,nextPatternIndex:r};a=i.nextInputIndex,o=i.nextPatternIndex}return{matched:!0,nextInputIndex:a,nextPatternIndex:i+1}}function Wr(e){let t=[],n=[],r=0,i=0;for(let a=0;a<e.length;a+=1){let o=e[a];if(o===`(`){r+=1,n.push(o);continue}if(o===`)`){--r,n.push(o);continue}if(o===`[`){i+=1,n.push(o);continue}if(o===`]`){--i,n.push(o);continue}if(o===`|`&&r===0&&i===0){t.push(n),n=[];continue}n.push(o)}return n.length>0&&t.push(n),t}function Gr(e,t,n,r){if(t[r]!==`(`)throw Error(`Expected "(" at pattern index ${r}`);let i=Hr(t,r,`(`,`)`),a=Wr(t.slice(r+1,i));for(let t of a){let r=zr(e,t,n,0);if(r.matched)return{matched:!0,nextInputIndex:r.nextInputIndex,nextPatternIndex:i+1}}return{matched:!1,nextInputIndex:n,nextPatternIndex:r}}function Kr(e,t,n,r){if(t[r]!==`~`)throw Error(`Expected "~" at pattern index ${r}`);let i=n,a=r+1;for(;;){let n=Vr(e,t,i,a);if(!n.matched)break;if(n.nextInputIndex===i)throw Error(`Repeat expression did not consume input`);i=n.nextInputIndex}let o=qr(t,a);return{matched:!0,nextInputIndex:i,nextPatternIndex:o}}function qr(e,t){let n=e[t];if(n===`config`||n===`color-stop`||n===`color-hint`)return t+1;if(n===`[`)return Hr(e,t,`[`,`]`)+1;if(n===`(`)return Hr(e,t,`(`,`)`)+1;if(n===`~`)return qr(e,t+1);throw Error(`Unsupported token "${n}" in getPrimaryEndIndex`)}function Jr(e){return Xr(e),$r(e),ei(e),!0}function Yr(e){try{return Jr(e),!0}catch{return!1}}function Xr(e){let t=ti(e);if(t.length===0)throw Error(`Pattern cannot be empty`);if(t[0]!==`^`)throw Error(`Pattern must start with ^`);if(t[t.length-1]!==`.`)throw Error(`Pattern must end with "."`);let n=0,r=0;for(let e=0;e<t.length;e+=1){let i=t[e];if(i===`(`){n+=1;continue}if(i===`)`){if(--n,n<0)throw Error(`Unexpected ")" at token index ${e}`);continue}if(i===`[`){r+=1;continue}if(i===`]`){if(--r,r<0)throw Error(`Unexpected "]" at token index ${e}`);continue}}if(n!==0)throw Error(`Unclosed group "()" in pattern`);if(r!==0)throw Error(`Unclosed sequence "[]" in pattern`);return!0}function Zr(e){try{return Xr(e),!0}catch{return!1}}let Qr={"^":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"(":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"[":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"|":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"&":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"!":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"~":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],",":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],config:[`,`,`|`,`&`,`)`,`]`,`.`],"color-stop":[`,`,`|`,`&`,`)`,`]`,`.`],"color-hint":[`,`,`|`,`&`,`)`,`]`,`.`],")":[`,`,`|`,`&`,`)`,`]`,`.`],"]":[`,`,`|`,`&`,`)`,`]`,`.`],".":[]};function $r(e){let t=ti(e);if(t.length===0)throw Error(`Pattern cannot be empty`);for(let e=0;e<t.length-1;e+=1){let n=t[e],r=t[e+1],i=Qr[n];if(!i)throw Error(`No semantic transition rule defined for token "${n}"`);if(!i.includes(r))throw Error(`Token "${r}" is not allowed after "${n}" at index ${e+1}`)}return!0}function ei(e){let t=ti(e);for(let e=0;e<t.length;e+=1){let n=t[e],r=t[e+1],i=t[e-1];if(n===`(`&&r===`)`)throw Error(`Empty group "()" is not allowed at token index ${e}`);if(n===`[`&&r===`]`)throw Error(`Empty sequence "[]" is not allowed at token index ${e}`);if(n===`,`){if(i===void 0||r===void 0)throw Error(`Unexpected "," at token index ${e}`);if(i===`[`)throw Error(`Sequence cannot start with "," at token index ${e}`);if(r===`]`)throw Error(`Sequence cannot end with "," at token index ${e}`);if(i===`,`||r===`,`)throw Error(`Unexpected consecutive "," at token index ${e}`)}}return!0}function ti(e){let t=e.trim(),n=[],r=0;for(;r<t.length;){let e=t.slice(r),i=t[r];if(/\s/.test(i)){r+=1;continue}if(e.startsWith(`color-stop`)){n.push(`color-stop`),r+=10;continue}if(e.startsWith(`color-hint`)){n.push(`color-hint`),r+=10;continue}if(e.startsWith(`config`)){n.push(`config`),r+=6;continue}if(i===`^`||i===`.`||i===`(`||i===`)`||i===`[`||i===`]`||i===`,`||i===`|`||i===`&`||i===`!`||i===`~`){n.push(i),r+=1;continue}throw Error(`Unexpected token near "${e}" at index ${r}`)}return n}function ni(e,t){try{return ri(e,t),!0}catch{return!1}}function ri(e,t){Jr(t);let n=ti(t).slice(1,-1),r=zr(e,n,0,0);if(!r.matched)throw Error(`Input does not match pattern`);if(r.nextInputIndex!==e.length)throw Error(`Pattern did not consume all inputs`);if(r.nextPatternIndex!==n.length)throw Error(`Input ended before pattern was fully matched`);return!0}function ii(e,t=`^[([config,color-stop,([color-hint,color-stop]|color-stop)]|color-stop),~([color-hint,color-stop]|color-stop)].`){let n=e.trim();if(n.length===0)throw Error(`Expected function call, received empty string`);let{functionName:r,isRepeating:i,inputs:a}=li(n),o=ci(a);return ri(o,t),{functionName:r,isRepeating:i,inputs:o}}function ai(e){return/^-?\d*\.?\d+(%|deg|rad|turn|grad|px|em|rem|vh|vw|vmin|vmax|cm|mm|in|pt|pc|q)?$/i.test(e.trim())}function oi(e){try{let t=pi(e)[0];return xe(t)!==void 0}catch{return!1}}function si(e){return!ai(e)&&!oi(e)}function ci(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?[]:t.map((e,t)=>t===0&&!oi(e)?{type:`config`,value:e}:oi(e)?{type:`color-stop`,value:e}:ai(e)?{type:`color-hint`,value:e}:{type:`config`,value:e})}function li(e){let t=e.indexOf(`(`);if(t<=0)throw Error(`Expected function opening parenthesis`);let n=e.slice(0,t).trim();if(n.length===0)throw Error(`Expected function name before "("`);let r=n.startsWith(`repeating-`);r&&(n=n.slice(10));let i=ui(e,t);if(i===-1)throw Error(`Unclosed function parenthesis`);let a=di(e.slice(t+1,i));return{functionName:n,isRepeating:r,inputs:a}}function ui(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`){n+=1;continue}if(t===`)`){if(--n,n===0)return r;if(n<0)return-1}}return-1}function di(e){let t=[],n=``,r=0,i=0,a=0;for(let o=0;o<e.length;o+=1){let s=e[o];if(s===`(`){r+=1,n+=s;continue}if(s===`)`){--r,n+=s;continue}if(s===`{`){i+=1,n+=s;continue}if(s===`}`){--i,n+=s;continue}if(s===`[`){a+=1,n+=s;continue}if(s===`]`){--a,n+=s;continue}if(s===`,`&&r===0&&i===0&&a===0){fi(t,n),n=``;continue}n+=s}return fi(t,n),t}function fi(e,t){let n=t.trim();n.length>0&&e.push(n)}function pi(e){let t=e.trim(),n=[],r=``,i=0,a=0,o=0;for(let e=0;e<t.length;e+=1){let s=t[e];if(s===`(`){i+=1,r+=s;continue}if(s===`)`){--i,r+=s;continue}if(s===`{`){a+=1,r+=s;continue}if(s===`}`){--a,r+=s;continue}if(s===`[`){o+=1,r+=s;continue}if(s===`]`){--o,r+=s;continue}if(/\s/.test(s)&&i===0&&a===0&&o===0){r.trim().length>0&&(n.push(r.trim()),r=``);continue}r+=s}return r.trim().length>0&&n.push(r.trim()),n}let mi=[`oklab`,`lch`,`oklch`,`hsl`,`hwb`,`lab`,`srgb`,`srgb-linear`,`xyz`,`display-p3`,`a98-rgb`,`prophoto-rgb`,`rec2020`],hi=[`shorter`,`longer`,`increasing`,`decreasing`],gi=[`hsl`,`hwb`,`lch`,`oklch`];function _i(e){return hi.includes(e)}function vi(e){return mi.includes(e)}function yi(e){return gi.includes(e)}var bi=class{_isRepeating;_config;_stops;constructor(e){this._isRepeating=e.isRepeating,this._config=this._cloneConfig(e.config),this._stops=this._getSortedStops(this._cloneStops(e.stops)),this._validateConfig(this._config),this._validateStops(this._stops)}get isRepeating(){return this._isRepeating}get config(){return this._cloneConfig(this._config)}get stops(){return this._cloneStops(this._stops)}toJSON(){return{type:this.type,isRepeating:this.isRepeating,config:this._cloneConfig(this.config),stops:this._cloneStops(this.stops)}}addStop(e){let t=[...this._cloneStops(this._stops),...this._cloneStops([e])],n=this._getSortedStops(t);this._validateStops(n),this._stops=n}static fromString(e){throw Error(`Not implimented`)}static fromAbi(e){throw Error(`Not implimented`)}removeStop(e){if(!Number.isInteger(e))throw TypeError(`Gradient stop index must be an integer`);if(e<0||e>=this._stops.length)throw RangeError(`Gradient stop index is out of bounds`);if(this._stops.filter(e=>e.type===`color-stop`).length<=this._minColorStopsCount())throw Error(`Color stop count should be greather than ${this._minColorStopsCount()}`);let t=e+1>this._stops.length-1?this._stops.length-1:e+1,n=e-1>=0?e-1:0;e!==t&&this._stops[t].type===`color-hint`&&this._stops.splice(t,1),this._stops.splice(e,1),e!==n&&this._stops[n].type===`color-hint`&&this._stops.splice(n,1)}equals(e){if(this.type!==e.type||this.isRepeating!==e.isRepeating||JSON.stringify(this.config)!==JSON.stringify(e.config)||this.stops.length!==e.stops.length)return!1;for(let t=0;t<this.stops.length;t++){let n=this.stops[t],r=e.stops[t];if(n.type!==r.type||n.value!==r.value||n.position!==r.position)return!1}return!0}_minColorStopsCount(){return 0}_getSortedStops(e){return e.map((e,t)=>({stop:e,index:t})).sort((e,t)=>e.stop.position===t.stop.position?e.index-t.index:e.stop.position-t.stop.position).map(e=>e.stop)}_validateStops(e){this._validateStopsShape(e),this._validateStopsSequence(e)}_validateStopsShape(e){if(!Array.isArray(e))throw TypeError(`Gradient stops must be an array`);for(let t of e){if(typeof t!=`object`||!t)throw TypeError(`Gradient stop must be an object`);if(t.type!==`color-stop`&&t.type!==`color-hint`)throw TypeError(`Invalid gradient stop type: ${String(t.type)}`);if(typeof t.value!=`string`)throw TypeError(`Gradient stop value must be a string`);if(typeof t.position!=`number`||Number.isNaN(t.position))throw TypeError(`Gradient stop position must be a valid number`)}}_validateStopsSequence(e){if(e.length<this._minColorStopsCount())throw TypeError(`Gradient must contain at least ${this._minColorStopsCount()} stop`);if(e[0].type!==`color-stop`)throw TypeError(`Gradient stop sequence must start with a color-stop`);if(e[e.length-1].type===`color-hint`)throw TypeError(`Gradient stop sequence cannot end with a color-hint`);for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(n.type===`color-hint`&&r.type!==`color-stop`)throw TypeError(`A color-hint must be followed by a color-stop`)}}_cloneStops(e){return structuredClone(e)}_cloneConfig(e){return structuredClone(e)}_buildSerializedStopTokens(){let e=[];for(let t=0;t<this.stops.length;t++){let n=this.stops[t];if(n.type===`color-hint`){e.push({type:`color-hint`,position:n.position});continue}let r=this.stops[t+1];if(r&&r.type===`color-stop`&&r.value===n.value){e.push({type:`color-stop`,value:n.value,positions:[n.position,r.position]}),t+=1;continue}e.push({type:`color-stop`,value:n.value,positions:[n.position]})}return e}_canOmitAllStopPositions(e){let t=e.filter(e=>e.type===`color-stop`);if(e.some(e=>e.type===`color-hint`)||t.some(e=>e.positions.length!==1)||t.length<=1)return!1;for(let e=0;e<t.length;e++){let n=e/(t.length-1),r=t[e].positions[0];if(Math.abs(r-n)>1e-6)return!1}return!0}_serializeStopsCompact(){let e=this._buildSerializedStopTokens();return this._canOmitAllStopPositions(e)?e.map(e=>{if(e.type!==`color-stop`)throw Error(`Unexpected color-hint token in compact stop serialization`);return e.value}):e.map(e=>e.type===`color-hint`?`${this._formatPercent(e.position)}%`:e.positions.length===2?`${e.value} ${this._formatPercent(e.positions[0])}% ${this._formatPercent(e.positions[1])}%`:`${e.value} ${this._formatPercent(e.positions[0])}%`)}_formatPercent(e){return t(e*100,3)}static _normalizeAbiInputsToStops(e){let t=[];for(let n of e){if(n.type===`color-hint`){t.push({type:`color-hint`,value:n.value,position:this._parsePosition(n.value)});continue}if(n.type===`color-stop`){let e=this._parseColorStopInput(n.value);t.push(...e);continue}throw SyntaxError(`Unsupported linear gradient ABI input type: "${n.type}"`)}return this._resolvePendingStops(t)}static _parsePosition(e){let t=e.trim().toLowerCase().match(/^([+-]?(?:\d+\.?\d*|\.\d+))%$/);if(t===null)throw SyntaxError(`Invalid gradient stop position: "${e}"`);let n=Number(t[1]);if(!Number.isFinite(n))throw SyntaxError(`Invalid gradient stop position: "${e}"`);return n/100}static _parseColorStopInput(e){let t=pi(e);if(t.length===0)throw SyntaxError(`Color-stop input cannot be empty`);let n=[];for(;t.length>0;){let e=t[t.length-1];if(!/%$/.test(e)||(n.unshift(this._parsePosition(e)),t.pop(),n.length===2))break}let r=t.join(` `).trim();if(r.length===0)throw SyntaxError(`Color-stop is missing color value: "${e}"`);return n.length===0?[{type:`color-stop`,value:r}]:n.length===1?[{type:`color-stop`,value:r,position:n[0]}]:[{type:`color-stop`,value:r,position:n[0]},{type:`color-stop`,value:r,position:n[1]}]}static _resolvePendingStops(e){if(e.length===0)throw SyntaxError(`Linear gradient must contain at least one stop`);let t=e.map(e=>({...e})),n=t.findIndex(e=>e.type===`color-stop`),r=[...t].reverse().findIndex(e=>e.type===`color-stop`);if(n===-1)throw SyntaxError(`Linear gradient must contain at least one color-stop`);let i=t.length-1-r;t[n].position===void 0&&(t[n].position=0),t[i].position===void 0&&(t[i].position=1);let a=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.position!==void 0){if(a!==-1){let r=t[a],i=n,o=e-a;for(let e=1;e<o;e++){let n=t[a+e];n.position===void 0&&(n.position=r.position+(i.position-r.position)*e/o)}}a=e}}return t.map(e=>{if(e.position===void 0)throw SyntaxError(`Failed to resolve gradient stop position`);return{type:e.type,value:e.value,position:e.position}})}},xi=class e extends bi{type=`linear-gradient`;constructor(t){t.config.angle=g(t.config.angle),t.config.interpolation&&(t.config.interpolation=e._normalizeConfigInterpolation(t.config.interpolation)),super(t)}static normalizeConfig(t){let n=e._tokenizeConfigInput(t),r=new Set;for(let e of n){if(r.has(e.type))throw SyntaxError(`Duplicate linear gradient config token: "${e.type}"`);r.add(e.type)}let i=n.find(e=>e.type===`angle`),a=n.find(e=>e.type===`colorSpace`),o=n.find(e=>e.type===`hue`),s={angle:3.141593,interpolation:{hue:`shorter`,colorSpace:`oklab`}};if(i){let e=i.value;if(e.startsWith(`to `)){let t=e.trim().toLowerCase().split(/\s+/).filter(Boolean);if(t.length===0)throw SyntaxError(`Linear gradient angle keyword cannot be empty`);if(t[0]!==`to`)throw SyntaxError(`Linear gradient keyword direction must start with "to"`);let n=t.slice(1);if(n.length===0||n.length>2)throw SyntaxError(`Linear gradient keyword direction must contain one or two direction tokens`);let r=new Set([`top`,`right`,`bottom`,`left`]);for(let e of n)if(!r.has(e))throw SyntaxError(`Invalid linear gradient direction token: "${e}"`);if(new Set(n).size!==n.length)throw SyntaxError(`Linear gradient keyword direction cannot contain duplicate tokens`);let i=n.includes(`top`),a=n.includes(`right`),o=n.includes(`bottom`),c=n.includes(`left`);if(i&&o||c&&a)throw SyntaxError(`Linear gradient keyword direction contains conflicting tokens`);if(i&&c)s.angle=d(315);else if(i&&a)s.angle=d(45);else if(o&&c)s.angle=d(225);else if(o&&a)s.angle=d(135);else if(i)s.angle=d(0);else if(a)s.angle=d(90);else if(o)s.angle=d(180);else if(c)s.angle=d(270);else throw SyntaxError(`Unsupported linear gradient keyword direction: "${e}"`)}else s.angle=g(u(e))}return a&&(s.interpolation.colorSpace=a.value),o&&(s.interpolation.hue=o.value),s}static fromString(t){return e.fromAbi(ii(t))}static fromAbi(t){let n={angle:3.141592};if(t.inputs[0].type===`config`){let r=t.inputs[0].value.trim().toLowerCase();if(r.length===0)throw SyntaxError(`Linear gradient config cannot be empty`);n=e.normalizeConfig(r)}let r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs,i=e._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:n,stops:i})}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._parseConfigToString(this.config),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){}static _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!yi(t)?{colorSpace:t}:{colorSpace:t,hue:n}}_parseConfigToString(e){let{angle:t,interpolation:n}=e,r=[],i=this._parseAngleToString(t);return i.length>0&&r.push(i),n!==void 0&&r.push(this._parseInterpolationToString(n)),r.join(` `)}_parseAngleToString(e){let t=h(f(e),3);switch(t){case 0:return`to top`;case 45:return`to top right`;case 90:return`to right`;case 135:return`to bottom right`;case 180:return``;case 225:return`to bottom left`;case 270:return`to left`;case 315:return`to top left`;default:return`${t}deg`}}_parseInterpolationToString(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}static _tokenizeConfigInput(e){let t=e.trim().toLowerCase();if(t.length===0)throw SyntaxError(`Linear gradient config cannot be empty`);let n=t.split(/\s+/),r=[];for(let e=0;e<n.length;e+=1){let t=n[e];if(t===`in`){let t=n[e+1];if(t===void 0||!vi(t))throw SyntaxError(`Expected color space after "in"`);r.push({type:`colorSpace`,value:t}),e+=1;continue}if(l(t)){r.push({type:`angle`,value:t});continue}if(t===`to`){let t=[],i=n[e+1],a=n[e+2];i!==void 0&&t.push(i),(a===`left`||a===`right`)&&t.push(a);let o=`to ${t.join(` `)}`;r.push({type:`angle`,value:o}),e+=t.length;continue}if(_i(t)){if(n[e+1]!==`hue`)throw SyntaxError(`Expected "hue" after "${t}"`);r.push({type:`hue`,value:t}),e+=1;continue}throw SyntaxError(`Unknown linear gradient config token: "${t}"`)}return r}},Si=class e extends bi{static DEFAULT_CONFIG={isRepeating:!1,stops:[{type:`color-stop`,value:`red`,position:0},{type:`color-stop`,value:`blue`,position:1}],config:{shape:`ellipse`,size:{kind:`extent`,value:`farthest-corner`},position:{kind:`keywords`,x:`center`,y:`center`}}};type=`radial-gradient`;constructor(t){let n={...e.DEFAULT_CONFIG,...t};n.config.interpolation&&(n.config.interpolation=e._normalizeConfigInterpolation(n.config.interpolation)),super(n)}static fromString(t){return e.fromAbi(ii(t))}static fromAbi(t){if(t.functionName!==`radial-gradient`)throw Error(`Invalid function name for RadialGradient`);let n=this._parseConfig(t.inputs),r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs,i=this._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:n,stops:i})}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._parseConfigToString(this.config),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){if(e.shape!==`circle`&&e.shape!==`ellipse`)throw Error(`Invalid shape`);if(!e.position)throw Error(`Position is required`);if(!e.size)throw Error(`Size is required`)}_parseConfigToString(e){let t=[],n=this._parseRadialConfigToString(e);return n.length>0&&t.push(n),e.interpolation!==void 0&&t.push(this._parseInterpolationToString(e.interpolation)),t.join(` `)}_parseRadialConfigToString(e){let t=[];return this._isDefaultRadialShape(e.shape)||t.push(e.shape),this._isDefaultRadialSize(e.size)||t.push(this._parseRadialSizeToString(e.size)),this._isDefaultRadialPosition(e.position)||t.push(`at ${this._serializePosition(e.position)}`),t.join(` `)}_parseRadialSizeToString(e){if(e.kind===`extent`)return e.value;let t=this._formatLengthPercentage(e.x);return e.y===void 0?t:`${t} ${this._formatLengthPercentage(e.y)}`}_parseInterpolationToString(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultRadialShape(e){return e===`ellipse`}_isDefaultRadialSize(e){return e.kind===`extent`&&e.value===`farthest-corner`}_isDefaultRadialPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}_serializePosition(e){if(e.kind===`keywords`)return`${e.x} ${e.y}`;let t=this._formatLengthPercentage(e.x),n=e.y?this._formatLengthPercentage(e.y):``;return n===``?t:`${t} ${n}`}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}static _parseConfig(e){let t=`ellipse`,n={kind:`extent`,value:`farthest-corner`},r={kind:`keywords`,x:`center`,y:`center`},i,a=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let o of e){if(o.type!==`config`)continue;let e=pi(o.value);for(let o=0;o<e.length;o++){let s=e[o];if(s===`circle`||s===`ellipse`){t=s;continue}if(s===`closest-side`||s===`closest-corner`||s===`farthest-side`||s===`farthest-corner`){n={kind:`extent`,value:s};continue}if(a(s)){let r=e[o+1];if(t===`ellipse`&&a(r)){n={kind:`explicit`,x:this._parseLengthPercentage(s),y:this._parseLengthPercentage(r)},o+=1;continue}n={kind:`explicit`,x:this._parseLengthPercentage(s)};continue}if(s===`at`){let t=e[o+1],n=e[o+2];if(t===`center`&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:`center`},o+=1;continue}if((t===`left`||t===`right`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:t,y:`center`},o+=1;continue}if((t===`top`||t===`bottom`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:t},o+=1;continue}if((t===`left`||t===`center`||t===`right`)&&(n===`top`||n===`center`||n===`bottom`)){r={kind:`keywords`,x:t,y:n},o+=2;continue}if(a(t)&&a(n)){r={kind:`values`,x:this._parseLengthPercentage(t),y:this._parseLengthPercentage(n)},o+=2;continue}throw Error(`Invalid radial-gradient position: ${t??``} ${n??``}`)}if(s===`in`){let t=e[o+1],n=e[o+2],r=e[o+3];if(!t)throw Error(`Invalid radial-gradient interpolation: missing color space`);if(n!==void 0&&r===`hue`){i=this._normalizeConfigInterpolation({colorSpace:t,hue:n}),o+=3;continue}i=this._normalizeConfigInterpolation({colorSpace:t}),o+=1;continue}}}return{shape:t,size:n,position:r,interpolation:i}}static _parseLengthPercentage(e){if(e.endsWith(`%`))return{kind:`percent`,value:parseFloat(e)};let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid length-percentage: ${e}`);return{kind:`length`,value:parseFloat(t[1]),unit:t[2]}}static _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!yi(t)?{colorSpace:t}:{colorSpace:t,hue:n}}},Ci=class e extends bi{type=`conic-gradient`;constructor(e){super(e)}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._serializeConfig(),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}static fromString(e){return this.fromAbi(ii(e))}static fromAbi(t){if(t.functionName!==`conic-gradient`)throw Error(`Invalid function name for ConicGradient`);let n=t.inputs.find(e=>e.type===`config`),r=t.inputs.filter(e=>e.type!==`config`),i=this._parseConfig(n?.value),a=this._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:i,stops:a})}_validateConfig(e){}_serializeConfig(){let e=[];if(!this._isDefaultFrom(this.config.from)){let t=this.config.from;e.push(`from ${t.value}${t.unit}`)}return this._isDefaultPosition(this.config.position)||e.push(`at ${this._serializePosition(this.config.position)}`),this.config.interpolation!==void 0&&e.push(this._serializeInterpolation(this.config.interpolation)),e.join(` `)}_serializePosition(e){if(e.kind===`keywords`)return`${e.x} ${e.y}`;let t=this._formatLengthPercentage(e.x),n=e.y?this._formatLengthPercentage(e.y):``;return n===``?t:`${t} ${n}`}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}_serializeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultFrom(e){return e.value===0&&e.unit===`deg`}_isDefaultPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}static _parseConfig(e){let t={from:{kind:`angle`,value:0,unit:`deg`},position:{kind:`keywords`,x:`center`,y:`center`}};if(!e)return t;let n=pi(e),r=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let e=0;e<n.length;e++){let i=n[e];if(i===`from`){let r=n[e+1];if(r===void 0)throw Error(`Invalid conic-gradient config: missing angle after from`);t.from=this._parseAngle(r),e+=1;continue}if(i===`at`){let i=n[e+1],a=n[e+2];if(i===void 0)throw Error(`Invalid conic-gradient config: missing position after at`);if(i===`center`&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:`center`},e+=1;continue}if((i===`left`||i===`right`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:i,y:`center`},e+=1;continue}if((i===`top`||i===`bottom`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:i},e+=1;continue}if((i===`left`||i===`center`||i===`right`)&&(a===`top`||a===`center`||a===`bottom`)){t.position={kind:`keywords`,x:i,y:a},e+=2;continue}if(r(i)&&r(a)){t.position={kind:`values`,x:this._parseLengthPercentage(i),y:this._parseLengthPercentage(a)},e+=2;continue}throw Error(`Invalid conic-gradient position: ${i} ${a??``}`)}if(i===`in`){let r=n[e+1],i=n[e+2],a=n[e+3];if(r===void 0)throw Error(`Invalid conic-gradient interpolation: missing color space`);if(a===`hue`&&(i===`shorter`||i===`longer`||i===`increasing`||i===`decreasing`)){t.interpolation={colorSpace:r,hue:i},e+=3;continue}t.interpolation={colorSpace:r},e+=1;continue}}return t}static _parseLengthPercentage(e){if(e.endsWith(`%`))return{kind:`percent`,value:parseFloat(e)};let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid length-percentage: ${e}`);return{kind:`length`,value:parseFloat(t[1]),unit:t[2]}}static _parseAngle(e){let t=e.match(/^(-?\d*\.?\d+)(deg|rad|turn|grad)$/);if(!t)throw Error(`Invalid angle: ${e}`);return{kind:`angle`,value:Number(t[1]),unit:t[2]}}},wi=class{target=`css`;gradientType=`linear-gradient`;to(e){if(!(e instanceof xi))throw Error(`Expected LinearGradient`);return e.toString()}},Ti=class{target=`css`;gradientType=`radial-gradient`;to(e){if(!(e instanceof Si))throw Error(`Expected RadialGradient`);return e.toString()}},Ei=class{target=`css`;gradientType=`conic-gradient`;to(e){if(!(e instanceof Ci))throw Error(`Expected ConicGradient`);return e.toString()}};function Di(e,t){return(e%t+t)%t}function Oi(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return Z(Lr([r.value,i.value],`rgb`)(n))}}return r.value}function ki(e,t,n,r){return Oi(e,n+Di(t-n,r))}function Ai(e,t,n){let r=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(r.length<2)return r;let i=r[0].position,a=r[r.length-1].position-i;if(a<=0)return r;let o=[],s=0;o.push({type:`color-stop`,value:ki(r,t,i,a),position:t,_order:s}),s+=1;let c=Math.floor((t-i)/a)-1,l=Math.ceil((n-i)/a)+1;for(let e=c;e<=l;e+=1){let i=e*a;for(let e of r){let r=e.position+i;r<=t||r>=n||(o.push({...e,position:r,_order:s}),s+=1)}}return o.push({type:`color-stop`,value:ki(r,n,i,a),position:n,_order:s}),o.sort((e,t)=>e.position===t.position?e._order-t._order:e.position-t.position).map(({_order:e,...t})=>t)}function ji(e){return Ai(e,0,1)}function Mi(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>{let r=(n.x-e.x)/Math.max(t.x,1e-4),i=(n.y-e.y)/Math.max(t.y,1e-4);return Math.sqrt(r*r+i*i)}))}function Ni(e){switch(e){case`longer`:return Pe;case`increasing`:return Fe;case`decreasing`:return Ie;default:return U}}function Pi(e){switch(e){case`a98-rgb`:return`a98`;case`display-p3`:return`p3`;case`prophoto-rgb`:return`prophoto`;case`xyz`:return`xyz65`;case`srgb`:case`srgb-linear`:return`rgb`;default:return e}}function Fi(e){if(e.hue!==void 0)return{h:{fixup:Ni(e.hue)}}}function Ii(e){let t=e.filter(e=>e.type===`color-stop`);return t.length===0?[]:t.length===1?[{...t[0],position:t[0].position??0}]:t.map((e,n)=>e.position==null?n===0?{...e,position:0}:n===t.length-1?{...e,position:1}:{...e,position:n/(t.length-1)}:e)}function Li(e){let t=Ri(e);if(!t)throw Error(`Failed to convert interpolated color to rgb.`);return Z(t)}let Ri=O(`rgb`);function $(e,t=64){let n=Ii(e.stops),r=e.config.interpolation;if(n.length<2)return n;if(r===void 0)return e.isRepeating?ji(n):n;let i=[],a=Pi(r.colorSpace),o=Fi(r);for(let e=0;e<n.length-1;e+=1){let r=n[e],s=n[e+1],c=r.position,l=s.position,u=Lr([r.value,s.value],a,o);for(let n=0;n<=t;n+=1){if(e>0&&n===0)continue;let r=n/t,a=c+(l-c)*r,o=u(r);i.push({type:`color-stop`,value:Li(o),position:a})}}return e.isRepeating?ji(i):i}let zi=O(`rgb`);function Bi(e){let t=zi(e);if(!t)throw Error(`Failed to convert color: ${e}`);return Z(t)}function Vi(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function Hi(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}var Ui=class{target=`canvas-2d`;gradientType=`linear-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=t.config.angle,a=Math.sin(i),o=-Math.cos(i),s=n/2,c=r/2,l=Math.abs(n*a)+Math.abs(r*o),u=s-a*l/2,d=c-o*l/2,f=s+a*l/2,p=c+o*l/2,{min:m,max:h,stops:g}=Vi($(t)),_=g;if(m<0||h>1){let e=f-u,t=p-d,n=u,r=d;u=n+e*m,d=r+t*m,f=n+e*h,p=r+t*h,_=Hi(g,m,h)}let v=e.createLinearGradient(u,d,f,p);for(let e of _)v.addColorStop(e.position,Bi(e.value));e.clearRect(0,0,n,r),e.fillStyle=v,e.fillRect(0,0,n,r)}}}};let Wi=O(`rgb`);function Gi(e){let t=Wi(e);if(!t)throw Error(`Failed to convert color: ${e}`);return Z(t)}function Ki(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function qi(e,t,n){let r=n-t||1;return e.map(e=>({...e,position:(e.position-t)/r}))}function Ji(e,t,n,r){return r===`left`?e.x:r===`right`?t-e.x:r===`top`?e.y:n-e.y}function Yi(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Xi(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Zi(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.sqrt(n*n/(i*i)+r*r/(a*a));return{x:i*o,y:a*o}}var Qi=class{target=`canvas-2d`;gradientType=`radial-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=this._resolveCenter(t.config.position,n,r),a=this._resolveRadialRadii(t.config.size,t.config.shape,i,n,r),o=Mi(i,a,n,r),s=$(t,128),{min:c,max:l,stops:u}=Ki(t.isRepeating?Ai(s,0,o):s),d=u,f=0,p=t.isRepeating?o:1;if(t.isRepeating?d=qi(u,0,o):(c<0||l>1)&&(d=qi(u,c,l),f=c,p=l),t.config.shape===`circle`){let t=a.x,o=Math.max(0,t*f),s=Math.max(o+1e-4,t*p),c=e.createRadialGradient(i.x,i.y,o,i.x,i.y,s);for(let e of d)c.addColorStop(e.position,Gi(e.value));e.fillStyle=c,e.fillRect(0,0,n,r);return}let m=Math.max(a.x,a.y),h=a.x/m,g=a.y/m,_=Math.max(0,m*f),v=Math.max(_+1e-4,m*p);e.save(),e.translate(i.x,i.y),e.scale(h,g);let y=e.createRadialGradient(0,0,_,0,0,v);for(let e of d)y.addColorStop(e.position,Gi(e.value));e.fillStyle=y;let b=v+2;e.fillRect(-b/h*2,-b/g*2,b/h*4,b/g*4),e.restore()}}}_resolveCenter(e,t,n){return e.kind===`keywords`?{x:this._resolveKeywordX(e.x,t),y:this._resolveKeywordY(e.y,n)}:{x:this._resolve(e.x,t),y:this._resolve(e.y,n)}}_resolveKeywordX(e,t){return e===`left`?0:e===`center`?t/2:t}_resolveKeywordY(e,t){return e===`top`?0:e===`center`?t/2:t}_resolveRadialRadii(e,t,n,r,i){if(e.kind===`explicit`){let n=this._resolve(e.x,r),a=e.y?this._resolve(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=Ji(n,r,i,`left`),o=Ji(n,r,i,`right`),s=Ji(n,r,i,`top`),c=Ji(n,r,i,`bottom`);if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>Yi(n,e));if(e.value===`closest-side`){let e=Math.min(a,o,s,c);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(a,o,s,c);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.min(...t);return{x:e,y:e}}let l=Math.max(...t);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Xi(n,r,i);return e.value===`closest-corner`?p.map(e=>Zi(l,u,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y<n?t:e}):p.map(e=>Zi(d,f,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y>n?t:e})}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}};let $i=O(`rgb`);var ea=class{target=`canvas-2d`;gradientType=`conic-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.createImageData(n,r),a=i.data,{x:o,y:s}=this._resolvePosition(t.config.position,n,r),c=this._toRad(t.config.from),l=$(t,128),u=this._normalizeStops(l);if(u.length===0){e.putImageData(i,0,0);return}for(let e=0;e<r;e++)for(let t=0;t<n;t++){let r=t-o,i=e-s,l=Math.atan2(i,r)+Math.PI/2-c;for(;l<0;)l+=Math.PI*2;for(;l>=Math.PI*2;)l-=Math.PI*2;let d=l/(Math.PI*2),f=this._sampleColor(u,d),p=(e*n+t)*4;a[p]=f.r,a[p+1]=f.g,a[p+2]=f.b,a[p+3]=f.a}e.putImageData(i,0,0)}}}_resolvePosition(e,t,n){return e.kind===`keywords`?{x:this._resolveKeywordX(e.x,t),y:this._resolveKeywordY(e.y,n)}:{x:this._resolve(e.x,t),y:this._resolve(e.y,n)}}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}_resolveKeywordX(e,t){return e===`left`?0:e===`right`?t:t/2}_resolveKeywordY(e,t){return e===`top`?0:e===`bottom`?t:t/2}_toRad(e){return e.unit===`deg`?d(e.value):e.unit===`turn`?p(e.value):e.unit===`grad`?m(e.value):e.value}_normalizeStops(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({position:this._clamp01(e.position),color:this._parseColor(e.value)})).sort((e,t)=>e.position-t.position)}_sampleColor(e,t){if(e.length===1)return e[0].color;let n=e[0],r=[...e,{...n,position:n.position+1}],i=t;i<n.position&&(i+=1);for(let e=0;e<r.length-1;e++){let t=r[e],n=r[e+1];if(i>=t.position&&i<=n.position){let e=n.position-t.position||1,r=(i-t.position)/e;return this._mixColor(t.color,n.color,r)}}return e[e.length-1].color}_mixColor(e,t,n){return{r:Math.round(e.r+(t.r-e.r)*n),g:Math.round(e.g+(t.g-e.g)*n),b:Math.round(e.b+(t.b-e.b)*n),a:Math.round(e.a+(t.a-e.a)*n)}}_parseColor(e){let t=$i(e);if(!t)throw Error(`Failed to convert color: ${e}`);return{r:Math.round((t.r??0)*255),g:Math.round((t.g??0)*255),b:Math.round((t.b??0)*255),a:Math.round((t.alpha??1)*255)}}_clamp01(e){return Math.max(0,Math.min(1,e))}};let ta=O(`rgb`);function na(e){let t=ta(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function ra(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function ia(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}function aa(e,t,n){let r=e.createShader(t);if(!r)throw Error(`Failed to create WebGL shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebGL shader compile error: ${t}`)}return r}function oa(e,t,n){let r=aa(e,e.VERTEX_SHADER,t),i=aa(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw Error(`Failed to create WebGL program.`);if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let t=e.getProgramInfoLog(a);throw e.deleteProgram(a),Error(`WebGL program link error: ${t}`)}return a}function sa(e){return e.filter(e=>e.type===`color-stop`).length}function ca(e,t){let n=sa(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function la(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return Z(Lr([r.value,i.value],`rgb`)(n))}}return r.value}function ua(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length<=t)return n;let r=[];for(let e=0;e<t;e+=1){let i=e/(t-1);r.push({type:`color-stop`,value:la(n,i),position:i})}return r}var da=class{target=`canvas-webgl`;gradientType=`linear-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.getContext(`webgl`);if(!i)throw Error(`WebGL is not supported.`);e.width=n,e.height=r,i.viewport(0,0,n,r);let a=oa(i,`
|
|
1
|
+
var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e,t){let n=10**t;return Math.round(e*n)/n}function n(e,t){let n=10**t;return Math.floor(e*n)/n}function r(e,t){let n=10**t;return Math.ceil(e*n)/n}function i(e,t){let n=10**t;return Math.trunc(e*n)/n}function a(e,t,n){return Math.min(Math.max(e,t),n)}function o(e){return e/100}function s(e){return e*100}function c(e){return e===`deg`||e===`rad`||e===`turn`||e===`grad`}function l(e){try{return typeof u(e)==`number`}catch{return!1}}function u(e){let t=e.match(/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/);if(t===null)throw Error(`Invalid angle value: "${e}"`);if(!c(t[2]))throw Error(`Unsupported angle unit: "${t[2]}"`);if(!Number.isFinite(+t[1]))throw SyntaxError(`Invalid angle value: "${t[1]}"`);let n=Number(t[1]);switch(t[2]){case`deg`:return d(n);case`rad`:return n;case`turn`:return p(n);case`grad`:return m(n)}}function d(e){return e*Math.PI/180}function f(e){return e*180/Math.PI}function p(e){return e*Math.PI*2}function m(e){return e*Math.PI/200}function h(e,n=3){return t((e%360+360)%360,n)}function g(e,n=6){let r=Math.PI*2;return t((e%r+r)%r,n)}let _=(e,t)=>{if(typeof e==`number`){if(t===3)return{mode:`rgb`,r:(e>>8&15|e>>4&240)/255,g:(e>>4&15|e&240)/255,b:(e&15|e<<4&240)/255};if(t===4)return{mode:`rgb`,r:(e>>12&15|e>>8&240)/255,g:(e>>8&15|e>>4&240)/255,b:(e>>4&15|e&240)/255,alpha:(e&15|e<<4&240)/255};if(t===6)return{mode:`rgb`,r:(e>>16&255)/255,g:(e>>8&255)/255,b:(e&255)/255};if(t===8)return{mode:`rgb`,r:(e>>24&255)/255,g:(e>>16&255)/255,b:(e>>8&255)/255,alpha:(e&255)/255}}},v={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},y=e=>_(v[e.toLowerCase()],6),b=/^#?([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})$/i,x=e=>{let t;return(t=e.match(b))?_(parseInt(t[1],16),t[1].length):void 0},S=`([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)`;`${S}`;let C=`${S}%`;`${S}`;let ee=`(?:${S}%|${S})`,te=`(?:${S}%|${S}|none)`,ne=`(?:${S}(deg|grad|rad|turn)|${S})`;`${S}${S}`;let w=`\\s*,\\s*`;RegExp(`^`+te+`$`);let T=RegExp(`^rgba?\\(\\s*${S}${w}${S}${w}${S}\\s*(?:,\\s*${ee}\\s*)?\\)$`),re=RegExp(`^rgba?\\(\\s*${C}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),ie=e=>{let t={mode:`rgb`},n;if(n=e.match(T))n[1]!==void 0&&(t.r=n[1]/255),n[2]!==void 0&&(t.g=n[2]/255),n[3]!==void 0&&(t.b=n[3]/255);else if(n=e.match(re))n[1]!==void 0&&(t.r=n[1]/100),n[2]!==void 0&&(t.g=n[2]/100),n[3]!==void 0&&(t.b=n[3]/100);else return;return n[4]===void 0?n[5]!==void 0&&(t.alpha=Math.max(0,Math.min(1,+n[5]))):t.alpha=Math.max(0,Math.min(1,n[4]/100)),t},ae=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:we(e),E=(e=`rgb`)=>t=>(t=ae(t,e))===void 0?void 0:t.mode===e?t:D[t.mode][e]?D[t.mode][e](t):e===`rgb`?D[t.mode].rgb(t):D.rgb[e](D[t.mode].rgb(t)),D={},oe={},O=[],se={},ce=e=>e,k=e=>(D[e.mode]={...D[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{D[t]||(D[t]={}),D[t][e.mode]=e.fromMode[t]}),e.ranges||={},e.difference||={},e.channels.forEach(t=>{if(e.ranges[t]===void 0&&(e.ranges[t]=[0,1]),!e.interpolate[t])throw Error(`Missing interpolator for: ${t}`);typeof e.interpolate[t]==`function`&&(e.interpolate[t]={use:e.interpolate[t]}),e.interpolate[t].fixup||(e.interpolate[t].fixup=ce)}),oe[e.mode]=e,(e.parse||[]).forEach(t=>{ue(t,e.mode)}),E(e.mode)),le=e=>oe[e],ue=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);se[e]=t}else typeof e==`function`&&O.indexOf(e)<0&&O.push(e)},de=/[^\x00-\x7F]|[a-zA-Z_]/,fe=/[^\x00-\x7F]|[-\w]/,A={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},j=0;function pe(e){let t=e[j],n=e[j+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[j+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function me(e){if(j>=e.length)return!1;let t=e[j];if(de.test(t))return!0;if(t===`-`){if(e.length-j<2)return!1;let t=e[j+1];return!!(t===`-`||de.test(t))}return!1}let he={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function ge(e){let t=``;if((e[j]===`-`||e[j]===`+`)&&(t+=e[j++]),t+=_e(e),e[j]===`.`&&/\d/.test(e[j+1])&&(t+=e[j++]+_e(e)),(e[j]===`e`||e[j]===`E`)&&((e[j+1]===`-`||e[j+1]===`+`)&&/\d/.test(e[j+2])?t+=e[j++]+e[j++]+_e(e):/\d/.test(e[j+1])&&(t+=e[j++]+_e(e))),me(e)){let n=ve(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:A.Hue,value:t*he[n]}:void 0}return e[j]===`%`?(j++,{type:A.Percentage,value:+t}):{type:A.Number,value:+t}}function _e(e){let t=``;for(;/\d/.test(e[j]);)t+=e[j++];return t}function ve(e){let t=``;for(;j<e.length&&fe.test(e[j]);)t+=e[j++];return t}function ye(e){let t=ve(e);return e[j]===`(`?(j++,{type:A.Function,value:t}):t===`none`?{type:A.None,value:void 0}:{type:A.Ident,value:t}}function be(e=``){let t=e.trim(),n=[],r;for(j=0;j<t.length;){if(r=t[j++],r===`
|
|
2
|
+
`||r===` `||r===` `){for(;j<t.length&&(t[j]===`
|
|
3
|
+
`||t[j]===` `||t[j]===` `);)j++;continue}if(r===`,`)return;if(r===`)`){n.push({type:A.ParenClose});continue}if(r===`+`){if(j--,pe(t)){n.push(ge(t));continue}return}if(r===`-`){if(j--,pe(t)){n.push(ge(t));continue}if(me(t)){n.push({type:A.Ident,value:ve(t)});continue}return}if(r===`.`){if(j--,pe(t)){n.push(ge(t));continue}return}if(r===`/`){for(;j<t.length&&(t[j]===`
|
|
4
|
+
`||t[j]===` `||t[j]===` `);)j++;let e;if(pe(t)&&(e=ge(t),e.type!==A.Hue)){n.push({type:A.Alpha,value:e});continue}if(me(t)&&ve(t)===`none`){n.push({type:A.Alpha,value:{type:A.None,value:void 0}});continue}return}if(/\d/.test(r)){j--,n.push(ge(t));continue}if(de.test(r)){j--,n.push(ye(t));continue}return}return n}function xe(e){e._i=0;let t=e[e._i++];if(!t||t.type!==A.Function||t.value!==`color`||(t=e[e._i++],t.type!==A.Ident))return;let n=se[t.value];if(!n)return;let r={mode:n},i=Se(e,!1);if(!i)return;let a=le(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==A.None&&(r[n]=t.type===A.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function Se(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===A.None||r.type===A.Number||r.type===A.Alpha||r.type===A.Percentage||t&&r.type===A.Hue){n.push(r);continue}if(r.type===A.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==A.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:A.None,value:void 0}),n.every(e=>e.type!==A.Alpha)?n:void 0}}function Ce(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==A.Function)return;let r=Se(e,t);if(r)return r.unshift(n.value),r}let we=e=>{if(typeof e!=`string`)return;let t=be(e),n=t?Ce(t,!0):void 0,r,i=0,a=O.length;for(;i<a;)if((r=O[i++](e,n))!==void 0)return r;return t?xe(t):void 0};function Te(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.r=r.type===A.Number?r.value/255:r.value/100),i.type!==A.None&&(n.g=i.type===A.Number?i.value/255:i.value/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value/255:a.value/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Ee=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,De=(e,t,n)=>e+n*(t-e),Oe=e=>{let t=[];for(let n=0;n<e.length-1;n++){let r=e[n],i=e[n+1];r===void 0&&i===void 0?t.push(void 0):r!==void 0&&i!==void 0?t.push([r,i]):t.push(r===void 0?[i,i]:[r,r])}return t},M=(e=>t=>{let n=Oe(t);return t=>{let r=t*n.length,i=t>=1?n.length-1:Math.max(Math.floor(r),0),a=n[i];return a===void 0?void 0:e(a[0],a[1],r-i)}})(De),N=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},P={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[Te,x,ie,y,Ee,`srgb`],serialize:`srgb`,interpolate:{r:M,g:M,b:M,alpha:{use:M,fixup:N}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},ke=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),Ae=e=>{let t=ke(e.r),n=ke(e.g),r=ke(e.b),i={mode:`xyz65`,x:.5766690429101305*t+.1855582379065463*n+.1882286462349947*r,y:.297344975250536*t+.6273635662554661*n+.0752914584939979*r,z:.0270313613864123*t+.0706888525358272*n+.9913375368376386*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},je=e=>Math.abs(e)**(256/563)*Math.sign(e),Me=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`a98`,r:je(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:je(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:je(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Ne=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},Pe=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Ne(e),g:Ne(t),b:Ne(n)};return r!==void 0&&(i.alpha=r),i},F=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(e),a={mode:`xyz65`,x:.4123907992659593*t+.357584339383878*n+.1804807884018343*r,y:.2126390058715102*t+.715168678767756*n+.0721923153607337*r,z:.0193308187155918*t+.119194779794626*n+.9505321522496607*r};return i!==void 0&&(a.alpha=i),a},Fe=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},Ie=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:Fe(e),g:Fe(t),b:Fe(n)};return r!==void 0&&(a.alpha=r),a},I=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Ie({r:e*3.2409699419045226-t*1.537383177570094-.4986107602930034*n,g:e*-.9692436362808796+t*1.8759675015077204+.0415550574071756*n,b:e*.0556300796969936-t*.2039769588889765+1.0569715142428784*n});return r!==void 0&&(i.alpha=r),i},Le={...P,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>Me(F(e)),xyz65:Me},toMode:{rgb:e=>I(Ae(e)),xyz65:Ae}},L=e=>(e%=360)<0?e+360:e,Re=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=L(n);return r===0||e[r-1]===void 0?a:t(a-L(i[r-1]))}).reduce((e,t)=>!e.length||t===void 0||e[e.length-1]===void 0?(e.push(t),e):(e.push(t+e[e.length-1]),e),[]),R=e=>Re(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),ze=e=>Re(e,e=>Math.abs(e)>=180||e===0?e:e-360*Math.sign(e)),Be=e=>Re(e,e=>e>=0?e:e+360),Ve=e=>Re(e,e=>e<=0?e:e-360),z=[-.14861,1.78277,-.29227,-.90649,1.97294,0],He=Math.PI/180,Ue=180/Math.PI,We=z[3]*z[4],Ge=z[1]*z[4],Ke=z[1]*z[2]-z[0]*z[3],qe=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(Ke*n+e*We-t*Ge)/(Ke+We-Ge),a=n-i,o=(z[4]*(t-i)-z[2]*a)/z[3],s={mode:`cubehelix`,l:i,s:i===0||i===1?void 0:Math.sqrt(a*a+o*o)/(z[4]*i*(1-i))};return s.s&&(s.h=Math.atan2(o,a)*Ue-120),r!==void 0&&(s.alpha=r),s},Je=({h:e,s:t,l:n,alpha:r})=>{let i={mode:`rgb`};e=(e===void 0?0:e+120)*He,n===void 0&&(n=0);let a=t===void 0?0:t*n*(1-n),o=Math.cos(e),s=Math.sin(e);return i.r=n+a*(z[0]*o+z[1]*s),i.g=n+a*(z[2]*o+z[3]*s),i.b=n+a*(z[4]*o+z[5]*s),r!==void 0&&(i.alpha=r),i},Ye=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=L(e.h),r=L(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},Xe=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=L(e.h),r=L(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},Ze=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=L(e.h),r=L(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},B=e=>{let t=e.reduce((e,t)=>{if(t!==void 0){let n=t*Math.PI/180;e.sin+=Math.sin(n),e.cos+=Math.cos(n)}return e},{sin:0,cos:0}),n=Math.atan2(t.sin,t.cos)*180/Math.PI;return n<0?360+n:n},Qe={mode:`cubehelix`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--cubehelix`],serialize:`--cubehelix`,ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:qe},toMode:{rgb:Je},interpolate:{h:{use:M,fixup:R},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}},V=({l:e,a:t,b:n,alpha:r},i=`lch`)=>{t===void 0&&(t=0),n===void 0&&(n=0);let a=Math.sqrt(t*t+n*n),o={mode:i,l:e,c:a};return a&&(o.h=L(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},H=({l:e,c:t,h:n,alpha:r},i=`lab`)=>{n===void 0&&(n=0);let a={mode:i,l:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(a.alpha=r),a},$e=29**3/3**3,et=6**3/29**3,U={X:.3457/.3585,Y:1,Z:.2958/.3585},W={X:.3127/.329,Y:1,Z:.3583/.329},tt=e=>e**3>et?e**3:(116*e-16)/$e,nt=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz65`,x:tt(a)*W.X,y:tt(i)*W.Y,z:tt(o)*W.Z};return r!==void 0&&(s.alpha=r),s},rt=e=>I(nt(e)),it=e=>e>et?Math.cbrt(e):($e*e+16)/116,at=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=it(e/W.X),a=it(t/W.Y),o=it(n/W.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},ot=e=>{let t=at(F(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},st=26/180*Math.PI,ct=Math.cos(st),lt=Math.sin(st),ut=100/Math.log(139/100),dt=({l:e,c:t,h:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`lab65`,l:(Math.exp(e*1/ut)-1)/.0039},a=(Math.exp(.0435*t*1*1)-1)/.075,o=a*Math.cos(n/180*Math.PI-st),s=a*Math.sin(n/180*Math.PI-st);return i.a=o*ct-s/.83*lt,i.b=o*lt+s/.83*ct,r!==void 0&&(i.alpha=r),i},ft=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=t*ct+n*lt,a=.83*(n*ct-t*lt),o=Math.sqrt(i*i+a*a),s={mode:`dlch`,l:ut/1*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*1*1)};return s.c&&(s.h=L((Math.atan2(a,i)+st)/Math.PI*180)),r!==void 0&&(s.alpha=r),s},pt=e=>dt(V(e,`dlch`)),mt=e=>H(ft(e),`dlab`),ht={mode:`dlab`,parse:[`--din99o-lab`],serialize:`--din99o-lab`,toMode:{lab65:pt,rgb:e=>rt(pt(e))},fromMode:{lab65:mt,rgb:e=>mt(ot(e))},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:M,a:M,b:M,alpha:{use:M,fixup:N}}},gt={mode:`dlch`,parse:[`--din99o-lch`],serialize:`--din99o-lch`,toMode:{lab65:dt,dlab:e=>H(e,`dlab`),rgb:e=>rt(dt(e))},fromMode:{lab65:ft,dlab:e=>V(e,`dlch`),rgb:e=>ft(ot(e))},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:M,c:M,h:{use:M,fixup:R},alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}};function _t({h:e,s:t,i:n,alpha:r}){e=L(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n*(1+t*(3/(2-i)-1)),g:n*(1+t*(3*(1-i)/(2-i)-1)),b:n*(1-t)};break;case 1:a={r:n*(1+t*(3*(1-i)/(2-i)-1)),g:n*(1+t*(3/(2-i)-1)),b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n*(1+t*(3/(2-i)-1)),b:n*(1+t*(3*(1-i)/(2-i)-1))};break;case 3:a={r:n*(1-t),g:n*(1+t*(3*(1-i)/(2-i)-1)),b:n*(1+t*(3/(2-i)-1))};break;case 4:a={r:n*(1+t*(3*(1-i)/(2-i)-1)),g:n*(1-t),b:n*(1+t*(3/(2-i)-1))};break;case 5:a={r:n*(1+t*(3/(2-i)-1)),g:n*(1-t),b:n*(1+t*(3*(1-i)/(2-i)-1))};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function vt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsi`,s:e+t+n===0?0:1-3*a/(e+t+n),i:(e+t+n)/3};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let yt={mode:`hsi`,toMode:{rgb:_t},parse:[`--hsi`],serialize:`--hsi`,fromMode:{rgb:vt},channels:[`h`,`s`,`i`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:R},s:M,i:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}};function bt({h:e,s:t,l:n,alpha:r}){e=L(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=n+t*(n<.5?n:1-n),a=i-(i-n)*2*Math.abs(e/60%2-1),o;switch(Math.floor(e/60)){case 0:o={r:i,g:a,b:2*n-i};break;case 1:o={r:a,g:i,b:2*n-i};break;case 2:o={r:2*n-i,g:i,b:a};break;case 3:o={r:2*n-i,g:a,b:i};break;case 4:o={r:a,g:2*n-i,b:i};break;case 5:o={r:i,g:2*n-i,b:a};break;default:o={r:2*n-i,g:2*n-i,b:2*n-i}}return o.mode=`rgb`,r!==void 0&&(o.alpha=r),o}function xt({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsl`,s:i===a?0:(i-a)/(1-Math.abs(i+a-1)),l:.5*(i+a)};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let St=(e,t)=>{switch(t){case`deg`:return+e;case`rad`:return e/Math.PI*180;case`grad`:return e/10*9;case`turn`:return e*360}},Ct=RegExp(`^hsla?\\(\\s*${ne}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),wt=e=>{let t=e.match(Ct);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=St(t[1],t[2])):n.h=+t[3],t[4]!==void 0&&(n.s=Math.min(Math.max(0,t[4]/100),1)),t[5]!==void 0&&(n.l=Math.min(Math.max(0,t[5]/100),1)),t[6]===void 0?t[7]!==void 0&&(n.alpha=Math.max(0,Math.min(1,+t[7]))):n.alpha=Math.max(0,Math.min(1,t[6]/100)),n};function Tt(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.s=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.l=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Et={mode:`hsl`,toMode:{rgb:bt},fromMode:{rgb:xt},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Tt,wt],serialize:e=>`hsl(${e.h===void 0?`none`:e.h} ${e.s===void 0?`none`:e.s*100+`%`} ${e.l===void 0?`none`:e.l*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:M,fixup:R},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}};function Dt({h:e,s:t,v:n,alpha:r}){e=L(e===void 0?0:e),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.abs(e/60%2-1),a;switch(Math.floor(e/60)){case 0:a={r:n,g:n*(1-t*i),b:n*(1-t)};break;case 1:a={r:n*(1-t*i),g:n,b:n*(1-t)};break;case 2:a={r:n*(1-t),g:n,b:n*(1-t*i)};break;case 3:a={r:n*(1-t),g:n*(1-t*i),b:n};break;case 4:a={r:n*(1-t*i),g:n*(1-t),b:n};break;case 5:a={r:n,g:n*(1-t),b:n*(1-t*i)};break;default:a={r:n*(1-t),g:n*(1-t),b:n*(1-t)}}return a.mode=`rgb`,r!==void 0&&(a.alpha=r),a}function Ot({r:e,g:t,b:n,alpha:r}){e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.max(e,t,n),a=Math.min(e,t,n),o={mode:`hsv`,s:i===0?0:1-a/i,v:i};return i-a!==0&&(o.h=(i===e?(t-n)/(i-a)+(t<n)*6:i===t?(n-e)/(i-a)+2:(e-t)/(i-a)+4)*60),r!==void 0&&(o.alpha=r),o}let kt={mode:`hsv`,toMode:{rgb:Dt},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:Ot},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:R},s:M,v:M,alpha:{use:M,fixup:N}},difference:{h:Ye},average:{h:B}};function At({h:e,w:t,b:n,alpha:r}){if(t===void 0&&(t=0),n===void 0&&(n=0),t+n>1){let e=t+n;t/=e,n/=e}return Dt({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function jt(e){let t=Ot(e);if(t===void 0)return;let n=t.s===void 0?0:t.s,r=t.v===void 0?0:t.v,i={mode:`hwb`,w:(1-n)*r,b:1-r};return t.h!==void 0&&(i.h=t.h),t.alpha!==void 0&&(i.alpha=t.alpha),i}function Mt(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Percentage)return;n.h=r.value}if(i.type!==A.None){if(i.type===A.Hue)return;n.w=i.value/100}if(a.type!==A.None){if(a.type===A.Hue)return;n.b=a.value/100}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let Nt={mode:`hwb`,toMode:{rgb:At},fromMode:{rgb:jt},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Mt],serialize:e=>`hwb(${e.h===void 0?`none`:e.h} ${e.w===void 0?`none`:e.w*100+`%`} ${e.b===void 0?`none`:e.b*100+`%`}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:M,fixup:R},w:M,b:M,alpha:{use:M,fixup:N}},difference:{h:Xe},average:{h:B}},Pt=.1593017578125,Ft=78.84375,It=.8359375,Lt=18.8515625,Rt=18.6875;function zt(e){if(e<0)return 0;let t=e**(1/Ft);return 1e4*(Math.max(0,t-It)/(Lt-Rt*t))**(1/Pt)}function Bt(e){if(e<0)return 0;let t=(e/1e4)**Pt;return((It+Lt*t)/(1+Rt*t))**+Ft}let Vt=e=>Math.max(e/203,0),Ht=({i:e,t,p:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=zt(e+.008609037037932761*t+.11102962500302593*n),a=zt(e-.00860903703793275*t-.11102962500302599*n),o=zt(e+.5600313357106791*t-.32062717498731885*n),s={mode:`xyz65`,x:Vt(2.070152218389422*i-1.3263473389671556*a+.2066510476294051*o),y:Vt(.3647385209748074*i+.680566024947227*a-.0453045459220346*o),z:Vt(-.049747207535812*i-.0492609666966138*a+1.1880659249923042*o)};return r!==void 0&&(s.alpha=r),s},Ut=(e=0)=>Math.max(e*203,0),Wt=({x:e,y:t,z:n,alpha:r})=>{let i=Ut(e),a=Ut(t),o=Ut(n),s=Bt(.3592832590121217*i+.6976051147779502*a-.0358915932320289*o),c=Bt(-.1920808463704995*i+1.1004767970374323*a+.0753748658519118*o),l=Bt(.0070797844607477*i+.0748396662186366*a+.8433265453898765*o),u={mode:`itp`,i:.5*s+.5*c,t:1.61376953125*s-3.323486328125*c+1.709716796875*l,p:4.378173828125*s-4.24560546875*c-.132568359375*l};return r!==void 0&&(u.alpha=r),u},Gt={mode:`itp`,channels:[`i`,`t`,`p`,`alpha`],parse:[`--ictcp`],serialize:`--ictcp`,toMode:{xyz65:Ht,rgb:e=>I(Ht(e))},fromMode:{xyz65:Wt,rgb:e=>Wt(F(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:M,t:M,p:M,alpha:{use:M,fixup:N}}},Kt=e=>{if(e<0)return 0;let t=(e/1e4)**Pt;return((It+Lt*t)/(1+Rt*t))**134.03437499999998},qt=(e=0)=>Math.max(e*203,0),Jt=({x:e,y:t,z:n,alpha:r})=>{e=qt(e),t=qt(t),n=qt(n);let i=1.15*e-.15*n,a=.66*t+.34*e,o=Kt(.41478972*i+.579999*a+.014648*n),s=Kt(-.20151*i+1.120649*a+.0531008*n),c=Kt(-.0166008*i+.2648*a+.6684799*n),l=(o+s)/2,u={mode:`jab`,j:.44*l/(1-.56*l)-16295499532821565e-27,a:3.524*o-4.066708*s+.542708*c,b:.199076*o+1.096799*s-1.295875*c};return r!==void 0&&(u.alpha=r),u},Yt=16295499532821565e-27,Xt=e=>{if(e<0)return 0;let t=e**(1/134.03437499999998);return 1e4*((It-t)/(Rt*t-Lt))**(1/Pt)},Zt=e=>e/203,Qt=({j:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+Yt)/(.44+.56*(e+Yt)),a=Xt(i+.13860504*t+.058047316*n),o=Xt(i-.13860504*t-.058047316*n),s=Xt(i-.096019242*t-.8118919*n),c={mode:`xyz65`,x:Zt(1.661373024652174*a-.914523081304348*o+.23136208173913045*s),y:Zt(-.3250758611844533*a+1.571847026732543*o-.21825383453227928*s),z:Zt(-.090982811*a-.31272829*o+1.5227666*s)};return r!==void 0&&(c.alpha=r),c},$t=e=>{let t=Jt(F(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},en=e=>I(Qt(e)),tn={mode:`jab`,channels:[`j`,`a`,`b`,`alpha`],parse:[`--jzazbz`],serialize:`--jzazbz`,fromMode:{rgb:$t,xyz65:Jt},toMode:{rgb:en,xyz65:Qt},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:M,a:M,b:M,alpha:{use:M,fixup:N}}},nn=({j:e,a:t,b:n,alpha:r})=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),a={mode:`jch`,j:e,c:i};return i&&(a.h=L(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},rn=({j:e,c:t,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:`jab`,j:e,a:t?t*Math.cos(n/180*Math.PI):0,b:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},an={mode:`jch`,parse:[`--jzczhz`],serialize:`--jzczhz`,toMode:{jab:rn,rgb:e=>en(rn(e))},fromMode:{rgb:e=>nn($t(e)),jab:nn},channels:[`j`,`c`,`h`,`alpha`],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:M,fixup:R},c:M,j:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}},on=29**3/3**3,sn=6**3/29**3,cn=e=>e**3>sn?e**3:(116*e-16)/on,ln=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:cn(a)*U.X,y:cn(i)*U.Y,z:cn(o)*U.Z};return r!==void 0&&(s.alpha=r),s},un=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Ie({r:e*3.1341359569958707-t*1.6173863321612538-.4906619460083532*n,g:e*-.978795502912089+t*1.916254567259524+.03344273116131949*n,b:e*.07195537988411677-t*.2289768264158322+1.405386058324125*n});return r!==void 0&&(i.alpha=r),i},dn=e=>un(ln(e)),fn=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(e),a={mode:`xyz50`,x:.436065742824811*t+.3851514688337912*n+.14307845442264197*r,y:.22249319175623702*t+.7168870538238823*n+.06061979053616537*r,z:.013923904500943465*t+.09708128566574634*n+.7140993584005155*r};return i!==void 0&&(a.alpha=i),a},pn=e=>e>sn?Math.cbrt(e):(on*e+16)/116,mn=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=pn(e/U.X),a=pn(t/U.Y),o=pn(n/U.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},hn=e=>{let t=mn(fn(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function gn(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*125/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*125/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let _n={mode:`lab`,toMode:{xyz50:ln,rgb:dn},fromMode:{xyz50:mn,rgb:hn},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[gn],serialize:e=>`lab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{l:M,a:M,b:M,alpha:{use:M,fixup:N}}},vn={..._n,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:nt,rgb:rt},fromMode:{xyz65:at,rgb:ot},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function yn(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*150/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let bn={mode:`lch`,toMode:{lab:H,rgb:e=>dn(H(e))},fromMode:{rgb:e=>V(hn(e)),lab:V},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[yn],serialize:e=>`lch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,interpolate:{h:{use:M,fixup:R},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}},xn={...bn,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>H(e,`lab65`),rgb:e=>rt(H(e,`lab65`))},fromMode:{rgb:e=>V(ot(e),`lch65`),lab65:e=>V(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Sn=({l:e,u:t,v:n,alpha:r})=>{t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.sqrt(t*t+n*n),a={mode:`lchuv`,l:e,c:i};return i&&(a.h=L(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},Cn=({l:e,c:t,h:n,alpha:r})=>{n===void 0&&(n=0);let i={mode:`luv`,l:e,u:t?t*Math.cos(n/180*Math.PI):0,v:t?t*Math.sin(n/180*Math.PI):0};return r!==void 0&&(i.alpha=r),i},wn=(e,t,n)=>4*e/(e+15*t+3*n),Tn=(e,t,n)=>9*t/(e+15*t+3*n),En=wn(U.X,U.Y,U.Z),Dn=Tn(U.X,U.Y,U.Z),On=e=>e<=sn?on*e:116*Math.cbrt(e)-16,kn=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=On(t/U.Y),a=wn(e,t,n),o=Tn(e,t,n);!isFinite(a)||!isFinite(o)?i=a=o=0:(a=13*i*(a-En),o=13*i*(o-Dn));let s={mode:`luv`,l:i,u:a,v:o};return r!==void 0&&(s.alpha=r),s},An=(e,t,n)=>4*e/(e+15*t+3*n),jn=(e,t,n)=>9*t/(e+15*t+3*n),Mn=An(U.X,U.Y,U.Z),Nn=jn(U.X,U.Y,U.Z),Pn=({l:e,u:t,v:n,alpha:r})=>{if(e===void 0&&(e=0),e===0)return{mode:`xyz50`,x:0,y:0,z:0};t===void 0&&(t=0),n===void 0&&(n=0);let i=t/(13*e)+Mn,a=n/(13*e)+Nn,o=U.Y*(e<=8?e/on:((e+16)/116)**3),s={mode:`xyz50`,x:9*i*o/(4*a),y:o,z:o*(12-3*i-20*a)/(4*a)};return r!==void 0&&(s.alpha=r),s},Fn={mode:`lchuv`,toMode:{luv:Cn,rgb:e=>un(Pn(Cn(e)))},fromMode:{rgb:e=>Sn(kn(fn(e))),luv:Sn},channels:[`l`,`c`,`h`,`alpha`],parse:[`--lchuv`],serialize:`--lchuv`,ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:M,fixup:R},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:B}},In={...P,mode:`lrgb`,toMode:{rgb:Ie},fromMode:{rgb:Pe},parse:[`srgb-linear`],serialize:`srgb-linear`},Ln={mode:`luv`,toMode:{xyz50:Pn,rgb:e=>un(Pn(e))},fromMode:{xyz50:kn,rgb:e=>kn(fn(e))},channels:[`l`,`u`,`v`,`alpha`],parse:[`--luv`],serialize:`--luv`,ranges:{l:[0,100],u:[-84.936,175.042],v:[-125.882,87.243]},interpolate:{l:M,u:M,v:M,alpha:{use:M,fixup:N}}},Rn=({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Math.cbrt(.412221469470763*e+.5363325372617348*t+.0514459932675022*n),a=Math.cbrt(.2119034958178252*e+.6806995506452344*t+.1073969535369406*n),o=Math.cbrt(.0883024591900564*e+.2817188391361215*t+.6299787016738222*n),s={mode:`oklab`,l:.210454268309314*i+.7936177747023054*a-.0040720430116193*o,a:1.9779985324311684*i-2.42859224204858*a+.450593709617411*o,b:.0259040424655478*i+.7827717124575296*a-.8086757549230774*o};return r!==void 0&&(s.alpha=r),s},zn=e=>{let t=Rn(Pe(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Bn=({l:e,a:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=(e+.3963377773761749*t+.2158037573099136*n)**3,a=(e-.1055613458156586*t-.0638541728258133*n)**3,o=(e-.0894841775298119*t-1.2914855480194092*n)**3,s={mode:`lrgb`,r:4.076741636075957*i-3.3077115392580616*a+.2309699031821044*o,g:-1.2684379732850317*i+2.6097573492876887*a-.3413193760026573*o,b:-.0041960761386756*i-.7034186179359362*a+1.7076146940746117*o};return r!==void 0&&(s.alpha=r),s},Vn=e=>Ie(Bn(e));function Hn(e){let t=.206,n=.03,r=(1+t)/(1+n);return .5*(r*e-t+Math.sqrt((r*e-t)*(r*e-t)+4*n*r*e))}function Un(e){let t=.206,n=.03;return(1+t)/(1+n),(e*e+t*e)/(1.170873786407767*(e+n))}function Wn(e,t){let n,r,i,a,o,s,c,l;-1.88170328*e-.80936493*t>1?(n=1.19086277,r=1.76576728,i=.59662641,a=.75515197,o=.56771245,s=4.0767416621,c=-3.3077115913,l=.2309699292):1.81444104*e-1.19445276*t>1?(n=.73956515,r=-.45954404,i=.08285427,a=.1254107,o=.14503204,s=-1.2684380046,c=2.6097574011,l=-.3413193965):(n=1.35733652,r=-.00915799,i=-1.1513021,a=-.50559606,o=.00692167,s=-.0041960863,c=-.7034186147,l=1.707614701);let u=n+r*e+i*t+a*e*e+o*e*t,d=.3963377774*e+.2158037573*t,f=-.1055613458*e-.0638541728*t,p=-.0894841775*e-1.291485548*t;{let e=1+u*d,t=1+u*f,n=1+u*p,r=e*e*e,i=t*t*t,a=n*n*n,o=3*d*e*e,m=3*f*t*t,h=3*p*n*n,g=6*d*d*e,_=6*f*f*t,v=6*p*p*n,y=s*r+c*i+l*a,b=s*o+c*m+l*h,x=s*g+c*_+l*v;u-=y*b/(b*b-.5*y*x)}return u}function Gn(e,t){let n=Wn(e,t),r=Bn({l:1,a:n*e,b:n*t}),i=Math.cbrt(1/Math.max(r.r,r.g,r.b));return[i,i*n]}function Kn(e,t,n,r,i,a=null){a||=Gn(e,t);let o;if((n-i)*a[1]-(a[0]-i)*r<=0)o=a[1]*i/(r*a[0]+a[1]*(i-n));else{o=a[1]*(i-1)/(r*(a[0]-1)+a[1]*(i-n));{let a=n-i,s=r,c=.3963377774*e+.2158037573*t,l=-.1055613458*e-.0638541728*t,u=-.0894841775*e-1.291485548*t,d=a+s*c,f=a+s*l,p=a+s*u;{let e=i*(1-o)+o*n,t=o*r,a=e+t*c,s=e+t*l,m=e+t*u,h=a*a*a,g=s*s*s,_=m*m*m,v=3*d*a*a,y=3*f*s*s,b=3*p*m*m,x=6*d*d*a,S=6*f*f*s,C=6*p*p*m,ee=4.0767416621*h-3.3077115913*g+.2309699292*_-1,te=4.0767416621*v-3.3077115913*y+.2309699292*b,ne=4.0767416621*x-3.3077115913*S+.2309699292*C,w=te/(te*te-.5*ee*ne),T=-ee*w,re=-1.2684380046*h+2.6097574011*g-.3413193965*_-1,ie=-1.2684380046*v+2.6097574011*y-.3413193965*b,ae=-1.2684380046*x+2.6097574011*S-.3413193965*C,E=ie/(ie*ie-.5*re*ae),D=-re*E,oe=-.0041960863*h-.7034186147*g+1.707614701*_-1,O=-.0041960863*v-.7034186147*y+1.707614701*b,se=-.0041960863*x-.7034186147*S+1.707614701*C,ce=O/(O*O-.5*oe*se),k=-oe*ce;T=w>=0?T:1e6,D=E>=0?D:1e6,k=ce>=0?k:1e6,o+=Math.min(T,Math.min(D,k))}}}return o}function qn(e,t,n=null){n||=Gn(e,t);let r=n[0],i=n[1];return[i/r,i/(1-r)]}function Jn(e,t,n){let r=Gn(t,n),i=Kn(t,n,e,1,e,r),a=qn(t,n,r),o=.11516993+1/(7.4477897+4.1590124*n+t*(-2.19557347+1.75198401*n+t*(-2.13704948-10.02301043*n+t*(-4.24894561+5.38770819*n+4.69891013*t)))),s=.11239642+1/(1.6132032-.68124379*n+t*(.40370612+.90148123*n+t*(-.27087943+.6122399*n+t*(.00299215-.45399568*n-.14661872*t)))),c=i/Math.min(e*a[0],(1-e)*a[1]),l=e*o,u=(1-e)*s,d=.9*c*Math.sqrt(Math.sqrt(1/(1/(l*l*l*l)+1/(u*u*u*u))));return l=e*.4,u=(1-e)*.8,[Math.sqrt(1/(1/(l*l)+1/(u*u))),d,i]}function Yn(e){let t=e.l===void 0?0:e.l,n=e.a===void 0?0:e.a,r=e.b===void 0?0:e.b,i={mode:`okhsl`,l:Hn(t)};e.alpha!==void 0&&(i.alpha=e.alpha);let a=Math.sqrt(n*n+r*r);if(!a)return i.s=0,i;let[o,s,c]=Jn(t,n/a,r/a),l;if(a<s){let e=.8*o,t=1-e/s;l=(a-0)/(e+t*(a-0))*.8}else{let e=s,t=.2*s*s*1.25*1.25/o,n=1-t/(c-s);l=.8+.2*((a-e)/(t+n*(a-e)))}return l&&(i.s=l,i.h=L(Math.atan2(r,n)*180/Math.PI)),i}function Xn(e){let t=e.h===void 0?0:e.h,n=e.s===void 0?0:e.s,r=e.l===void 0?0:e.l,i={mode:`oklab`,l:Un(r)};if(e.alpha!==void 0&&(i.alpha=e.alpha),!n||r===1)return i.a=i.b=0,i;let a=Math.cos(t/180*Math.PI),o=Math.sin(t/180*Math.PI),[s,c,l]=Jn(i.l,a,o),u,d,f,p;n<.8?(u=1.25*n,d=0,f=.8*s,p=1-f/c):(u=5*(n-.8),d=c,f=.2*c*c*1.25*1.25/s,p=1-f/(l-c));let m=d+u*f/(1-p*u);return i.a=m*a,i.b=m*o,i}let Zn={...Et,mode:`okhsl`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--okhsl`],serialize:`--okhsl`,fromMode:{oklab:Yn,rgb:e=>Yn(zn(e))},toMode:{oklab:Xn,rgb:e=>Vn(Xn(e))}};function Qn(e){let t=e.l===void 0?0:e.l,n=e.a===void 0?0:e.a,r=e.b===void 0?0:e.b,i=Math.sqrt(n*n+r*r),a=i?n/i:1,o=i?r/i:1,[s,c]=qn(a,o),l=.5,u=1-l/s,d=c/(i+t*c),f=d*t,p=d*i,m=Un(f),h=p*m/f,g=Bn({l:m,a:a*h,b:o*h}),_=Math.cbrt(1/Math.max(g.r,g.g,g.b,0));t/=_,i=i/_*Hn(t)/t,t=Hn(t);let v={mode:`okhsv`,s:i?(l+c)*p/(c*l+c*u*p):0,v:t?t/f:0};return v.s&&(v.h=L(Math.atan2(r,n)*180/Math.PI)),e.alpha!==void 0&&(v.alpha=e.alpha),v}function $n(e){let t={mode:`oklab`};e.alpha!==void 0&&(t.alpha=e.alpha);let n=e.h===void 0?0:e.h,r=e.s===void 0?0:e.s,i=e.v===void 0?0:e.v,a=Math.cos(n/180*Math.PI),o=Math.sin(n/180*Math.PI),[s,c]=qn(a,o),l=.5,u=1-l/s,d=1-r*l/(l+c-c*u*r),f=r*c*l/(l+c-c*u*r),p=Un(d),m=f*p/d,h=Bn({l:p,a:a*m,b:o*m}),g=Math.cbrt(1/Math.max(h.r,h.g,h.b,0)),_=Un(i*d),v=f*_/d;return t.l=_*g,t.a=v*a*g,t.b=v*o*g,t}let er={...kt,mode:`okhsv`,channels:[`h`,`s`,`v`,`alpha`],parse:[`--okhsv`],serialize:`--okhsv`,fromMode:{oklab:Qn,rgb:e=>Qn(zn(e))},toMode:{oklab:$n,rgb:e=>Vn($n(e))}};function tr(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(!(r.type===A.Hue||i.type===A.Hue||a.type===A.Hue))return r.type!==A.None&&(n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)),i.type!==A.None&&(n.a=i.type===A.Number?i.value:i.value*.4/100),a.type!==A.None&&(n.b=a.type===A.Number?a.value:a.value*.4/100),o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let nr={..._n,mode:`oklab`,toMode:{lrgb:Bn,rgb:Vn},fromMode:{lrgb:Rn,rgb:zn},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[tr],serialize:e=>`oklab(${e.l===void 0?`none`:e.l} ${e.a===void 0?`none`:e.a} ${e.b===void 0?`none`:e.b}${e.alpha<1?` / ${e.alpha}`:``})`};function rr(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==A.None){if(r.type===A.Hue)return;n.l=Math.min(Math.max(0,r.type===A.Number?r.value:r.value/100),1)}if(i.type!==A.None&&(n.c=Math.max(0,i.type===A.Number?i.value:i.value*.4/100)),a.type!==A.None){if(a.type===A.Percentage)return;n.h=a.value}return o.type!==A.None&&(n.alpha=Math.min(1,Math.max(0,o.type===A.Number?o.value:o.value/100))),n}let ir={...bn,mode:`oklch`,toMode:{oklab:e=>H(e,`oklab`),rgb:e=>Vn(H(e,`oklab`))},fromMode:{rgb:e=>V(zn(e),`oklch`),oklab:e=>V(e,`oklch`)},parse:[rr],serialize:e=>`oklch(${e.l===void 0?`none`:e.l} ${e.c===void 0?`none`:e.c} ${e.h===void 0?`none`:e.h}${e.alpha<1?` / ${e.alpha}`:``})`,ranges:{l:[0,1],c:[0,.4],h:[0,360]}},ar=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(e),a={mode:`xyz65`,x:.486570948648216*t+.265667693169093*n+.1982172852343625*r,y:.2289745640697487*t+.6917385218365062*n+.079286914093745*r,z:0*t+.0451133818589026*n+1.043944368900976*r};return i!==void 0&&(a.alpha=i),a},or=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Ie({r:e*2.4934969119414263-t*.9313836179191242-.402710784450717*n,g:e*-.8294889695615749+t*1.7626640603183465+.0236246858419436*n,b:e*.0358458302437845-t*.0761723892680418+.9568845240076871*n},`p3`);return r!==void 0&&(i.alpha=r),i},sr={...P,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>or(F(e)),xyz65:or},toMode:{rgb:e=>I(ar(e)),xyz65:ar}},cr=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},lr=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`prophoto`,r:cr(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:cr(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:cr(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},ur=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},dr=e=>{let t=ur(e.r),n=ur(e.g),r=ur(e.b),i={mode:`xyz50`,x:.7977666449006423*t+.1351812974005331*n+.0313477341283922*r,y:.2880748288194013*t+.7118352342418731*n+899369387256e-16*r,z:0*t+0*n+.8251046025104602*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},fr={...P,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:lr,rgb:e=>lr(fn(e))},toMode:{xyz50:dr,rgb:e=>un(dr(e))}},pr=1.09929682680944,mr=e=>{let t=Math.abs(e);return t>.018053968510807?(Math.sign(e)||1)*(pr*t**.45-(pr-1)):4.5*e},hr=({x:e,y:t,z:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rec2020`,r:mr(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:mr(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:mr(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},gr=1.09929682680944,_r=(e=0)=>{let t=Math.abs(e);return t<.018053968510807*4.5?e/4.5:(Math.sign(e)||1)*((t+gr-1)/gr)**(1/.45)},vr=e=>{let t=_r(e.r),n=_r(e.g),r=_r(e.b),i={mode:`xyz65`,x:.6369580483012911*t+.1446169035862083*n+.1688809751641721*r,y:.262700212011267*t+.6779980715188708*n+.059301716469862*r,z:0*t+.0280726930490874*n+1.0609850577107909*r};return e.alpha!==void 0&&(i.alpha=e.alpha),i},yr={...P,mode:`rec2020`,fromMode:{xyz65:hr,rgb:e=>hr(F(e))},toMode:{xyz65:vr,rgb:e=>I(vr(e))},parse:[`rec2020`],serialize:`rec2020`},G=.0037930732552754493,br=Math.cbrt(G),xr=e=>Math.cbrt(e)-br,Sr=e=>{let{r:t,g:n,b:r,alpha:i}=Pe(e),a=xr(.3*t+.622*n+.078*r+G),o=xr(.23*t+.692*n+.078*r+G),s=xr(.2434226892454782*t+.2047674442449682*n+.5518098665095535*r+G),c={mode:`xyb`,x:(a-o)/2,y:(a+o)/2,b:s-(a+o)/2};return i!==void 0&&(c.alpha=i),c},Cr=e=>(e+br)**3,wr={mode:`xyb`,channels:[`x`,`y`,`b`,`alpha`],parse:[`--xyb`],serialize:`--xyb`,toMode:{rgb:({x:e,y:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Cr(e+t)-G,a=Cr(t-e)-G,o=Cr(n+t)-G,s=Ie({r:11.031566904639861*i-9.866943908131562*a-.16462299650829934*o,g:-3.2541473810744237*i+4.418770377582723*a-.16462299650829934*o,b:-3.6588512867136815*i+2.7129230459360922*a+1.9459282407775895*o});return r!==void 0&&(s.alpha=r),s}},fromMode:{rgb:Sr},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:M,y:M,b:M,alpha:{use:M,fixup:N}}},Tr={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:un,lab:mn},fromMode:{rgb:fn,lab:ln},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:M,y:M,z:M,alpha:{use:M,fixup:N}}},Er={mode:`xyz65`,toMode:{rgb:I,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz50`,x:1.0479298208405488*t+.0229467933410191*n-.0501922295431356*r,y:.0296278156881593*t+.990434484573249*n-.0170738250293851*r,z:-.0092430581525912*t+.0150551448965779*n+.7518742899580008*r};return i!==void 0&&(a.alpha=i),a}},fromMode:{rgb:F,xyz50:e=>{let{x:t,y:n,z:r,alpha:i}=e;t===void 0&&(t=0),n===void 0&&(n=0),r===void 0&&(r=0);let a={mode:`xyz65`,x:.9554734527042182*t-.0230985368742614*n+.0632593086610217*r,y:-.0283697069632081*t+1.0099954580058226*n+.021041398966943*r,z:.0123140016883199*t-.0205076964334779*n+1.3303659366080753*r};return i!==void 0&&(a.alpha=i),a}},ranges:{x:[0,.95],y:[0,1],z:[0,1.088]},channels:[`x`,`y`,`z`,`alpha`],parse:[`xyz`,`xyz-d65`],serialize:`xyz-d65`,interpolate:{x:M,y:M,z:M,alpha:{use:M,fixup:N}}},Dr={mode:`yiq`,toMode:{rgb:({y:e,i:t,q:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`rgb`,r:e+.95608445*t+.6208885*n,g:e-.27137664*t-.6486059*n,b:e-1.10561724*t+1.70250126*n};return r!==void 0&&(i.alpha=r),i}},fromMode:{rgb:({r:e,g:t,b:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i={mode:`yiq`,y:.29889531*e+.58662247*t+.11448223*n,i:.59597799*e-.2741761*t-.32180189*n,q:.21147017*e-.52261711*t+.31114694*n};return r!==void 0&&(i.alpha=r),i}},channels:[`y`,`i`,`q`,`alpha`],parse:[`--yiq`],serialize:`--yiq`,ranges:{i:[-.595,.595],q:[-.522,.522]},interpolate:{y:M,i:M,q:M,alpha:{use:M,fixup:N}}},Or=(e,t)=>Math.round(e*(t=10**t))/t,kr=((e=4)=>t=>typeof t==`number`?Or(t,e):t)(2),Ar=e=>Math.max(0,Math.min(1,e||0)),jr=e=>Math.round(Ar(e)*255),Mr=E(`rgb`),Nr=e=>{if(e===void 0)return;let t=jr(e.r),n=jr(e.g),r=jr(e.b);return e.alpha===void 0||e.alpha===1?`rgb(${t}, ${n}, ${r})`:`rgba(${t}, ${n}, ${r}, ${kr(Ar(e.alpha))})`},K=e=>Nr(Mr(e)),Pr=(e,t=`rgb`,n=!1)=>{let r=t?le(t).channels:null,i=t?E(t):ae;return a=>{let o=i(a);if(!o)return;let s=(r||le(o.mode).channels).reduce((n,r)=>{let i=e(o[r],r,o,t);return i!==void 0&&!isNaN(i)&&(n[r]=i),n},{mode:o.mode});if(!n)return s;let c=ae(a);return c&&c.mode!==s.mode?E(c.mode)(s):s}},Fr=(e,t,n)=>t===`alpha`?e:(e||0)*(n.alpha===void 0?1:n.alpha),Ir=(e,t,n)=>t!==`alpha`&&n.alpha!==0?(e||0)/(n.alpha===void 0?1:n.alpha):e,Lr=e=>{e[0]===void 0&&(e[0]=0),e[e.length-1]===void 0&&(e[e.length-1]=1);let t=1,n,r,i,a;for(;t<e.length;){if(e[t]===void 0){for(r=t,i=e[t-1],n=t;e[n]===void 0;)n++;for(a=(e[n]-i)/(n-t+1);t<n;)e[t]=i+(t+1-r)*a,t++}else e[t]<e[t-1]&&(e[t]=e[t-1]);t++}return e},Rr=(e=.5)=>t=>e<=0?1:e>=1?0:t**+(Math.log(.5)/Math.log(e)),zr=e=>typeof e==`function`,q=e=>e&&typeof e==`object`,Br=e=>typeof e==`number`,Vr=(e,t=`rgb`,n,r)=>{let i=le(t),a=E(t),o=[],s=[],c={};e.forEach(e=>{Array.isArray(e)?(o.push(a(e[0])),s.push(e[1])):Br(e)||zr(e)?c[s.length]=e:(o.push(a(e)),s.push(void 0))}),Lr(s);let l=i.channels.reduce((e,t)=>{let r;return r=q(n)&&q(n[t])&&n[t].fixup?n[t].fixup:q(i.interpolate[t])&&i.interpolate[t].fixup?i.interpolate[t].fixup:e=>e,e[t]=r(o.map(e=>e[t])),e},{});if(r){let e=o.map((e,n)=>i.channels.reduce((e,t)=>(e[t]=l[t][n],e),{mode:t}));l=i.channels.reduce((n,i)=>(n[i]=e.map(e=>{let n=r(e[i],i,e,t);return isNaN(n)?void 0:n}),n),{})}let u=i.channels.reduce((e,t)=>{let r;return zr(n)?r=n:q(n)&&zr(n[t])?r=n[t]:q(n)&&q(n[t])&&n[t].use?r=n[t].use:zr(i.interpolate[t])?r=i.interpolate[t]:q(i.interpolate[t])&&(r=i.interpolate[t].use),e[t]=r(l[t]),e},{}),d=o.length-1;return e=>{if(e=Math.min(Math.max(0,e),1),e<=s[0])return o[0];if(e>s[d])return o[d];let n=0;for(;s[n]<e;)n++;let r=s[n-1],a=s[n]-r,l=(e-r)/a,f=c[n]||c[0];f!==void 0&&(Br(f)&&(f=Rr((f-r)/a)),l=f(l));let p=(n-1+l)/d;return i.channels.reduce((e,t)=>{let n=u[t](p);return n!==void 0&&(e[t]=n),e},{mode:t})}},J=(e,t=`rgb`,n)=>Vr(e,t,n);((e,t)=>(n,r=`rgb`,i)=>{let a=t?Pr(t,r):void 0,o=Vr(n,r,i,e);return a?e=>a(o(e)):o})(Fr,Ir),k(Le),k(Qe),k(ht),k(gt),k(yt),k(Et),k(kt),k(Nt),k(Gt),k(tn),k(an),k(_n),k(vn),k(bn),k(xn),k(Fn),k(In),k(Ln),k(Zn),k(er),k(nr),k(ir),k(sr),k(fr),k(yr),k(P),k(wr),k(Tr),k(Er),k(Dr);let Hr=function(e){return e.START=`^`,e.END=`.`,e.GROUP_OPEN=`(`,e.GROUP_CLOSE=`)`,e.COMMA=`,`,e.SEQUENCE_OPEN=`[`,e.SEQUENCE_CLOSE=`]`,e.OR=`|`,e.AND=`&`,e.NOT=`!`,e.REPEAT=`~`,e.CONFIG=`config`,e.COLOR_STOP=`color-stop`,e.COLOR_HINT=`color-hint`,e}({});function Ur(e,t,n,r){let i=n,a=r;for(;a<t.length;){let o=t[a];if(o===`.`||o===`)`||o===`]`||o===`|`)break;if(o===`,`){a+=1;continue}let s=Gr(e,t,i,a);if(!s.matched)return{matched:!1,nextInputIndex:n,nextPatternIndex:r};i=s.nextInputIndex,a=s.nextPatternIndex}return{matched:!0,nextInputIndex:i,nextPatternIndex:a}}function Wr(e,t,n,r){let i=t[r],a=e[n];if(i!==`config`&&i!==`color-stop`&&i!==`color-hint`)throw Error(`Expected entity token at pattern index ${r}`);return!a||a.type!==i?{matched:!1,nextInputIndex:n,nextPatternIndex:r}:{matched:!0,nextInputIndex:n+1,nextPatternIndex:r+1}}function Gr(e,t,n,r){let i=t[r];if(i===`config`||i===`color-stop`||i===`color-hint`)return Wr(e,t,n,r);if(i===`[`)return qr(e,t,n,r);if(i===`(`)return Yr(e,t,n,r);if(i===`~`)return Xr(e,t,n,r);throw Error(`Unsupported primary token "${i}" at pattern index ${r}`)}function Kr(e,t,n,r){if(e[t]!==n)throw Error(`Expected "${n}" at pattern index ${t}, got "${e[t]}"`);let i=0;for(let a=t;a<e.length;a+=1){let t=e[a];if(t===n){i+=1;continue}if(t===r&&(--i,i===0))return a}throw Error(`Unclosed token pair "${n}${r}"`)}function qr(e,t,n,r){if(t[r]!==`[`)throw Error(`Expected "[" at pattern index ${r}`);let i=Kr(t,r,`[`,`]`),a=n,o=r+1;for(;o<i;){if(t[o]===`,`){o+=1;continue}let i=Gr(e,t,a,o);if(!i.matched)return{matched:!1,nextInputIndex:n,nextPatternIndex:r};a=i.nextInputIndex,o=i.nextPatternIndex}return{matched:!0,nextInputIndex:a,nextPatternIndex:i+1}}function Jr(e){let t=[],n=[],r=0,i=0;for(let a=0;a<e.length;a+=1){let o=e[a];if(o===`(`){r+=1,n.push(o);continue}if(o===`)`){--r,n.push(o);continue}if(o===`[`){i+=1,n.push(o);continue}if(o===`]`){--i,n.push(o);continue}if(o===`|`&&r===0&&i===0){t.push(n),n=[];continue}n.push(o)}return n.length>0&&t.push(n),t}function Yr(e,t,n,r){if(t[r]!==`(`)throw Error(`Expected "(" at pattern index ${r}`);let i=Kr(t,r,`(`,`)`),a=Jr(t.slice(r+1,i));for(let t of a){let r=Ur(e,t,n,0);if(r.matched)return{matched:!0,nextInputIndex:r.nextInputIndex,nextPatternIndex:i+1}}return{matched:!1,nextInputIndex:n,nextPatternIndex:r}}function Xr(e,t,n,r){if(t[r]!==`~`)throw Error(`Expected "~" at pattern index ${r}`);let i=n,a=r+1;for(;;){let n=Gr(e,t,i,a);if(!n.matched)break;if(n.nextInputIndex===i)throw Error(`Repeat expression did not consume input`);i=n.nextInputIndex}let o=Zr(t,a);return{matched:!0,nextInputIndex:i,nextPatternIndex:o}}function Zr(e,t){let n=e[t];if(n===`config`||n===`color-stop`||n===`color-hint`)return t+1;if(n===`[`)return Kr(e,t,`[`,`]`)+1;if(n===`(`)return Kr(e,t,`(`,`)`)+1;if(n===`~`)return Zr(e,t+1);throw Error(`Unsupported token "${n}" in getPrimaryEndIndex`)}function Qr(e){return ei(e),ri(e),ii(e),!0}function $r(e){try{return Qr(e),!0}catch{return!1}}function ei(e){let t=ai(e);if(t.length===0)throw Error(`Pattern cannot be empty`);if(t[0]!==`^`)throw Error(`Pattern must start with ^`);if(t[t.length-1]!==`.`)throw Error(`Pattern must end with "."`);let n=0,r=0;for(let e=0;e<t.length;e+=1){let i=t[e];if(i===`(`){n+=1;continue}if(i===`)`){if(--n,n<0)throw Error(`Unexpected ")" at token index ${e}`);continue}if(i===`[`){r+=1;continue}if(i===`]`){if(--r,r<0)throw Error(`Unexpected "]" at token index ${e}`);continue}}if(n!==0)throw Error(`Unclosed group "()" in pattern`);if(r!==0)throw Error(`Unclosed sequence "[]" in pattern`);return!0}function ti(e){try{return ei(e),!0}catch{return!1}}let ni={"^":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"(":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"[":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"|":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"&":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"!":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],"~":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],",":[`(`,`[`,`!`,`~`,`config`,`color-stop`,`color-hint`],config:[`,`,`|`,`&`,`)`,`]`,`.`],"color-stop":[`,`,`|`,`&`,`)`,`]`,`.`],"color-hint":[`,`,`|`,`&`,`)`,`]`,`.`],")":[`,`,`|`,`&`,`)`,`]`,`.`],"]":[`,`,`|`,`&`,`)`,`]`,`.`],".":[]};function ri(e){let t=ai(e);if(t.length===0)throw Error(`Pattern cannot be empty`);for(let e=0;e<t.length-1;e+=1){let n=t[e],r=t[e+1],i=ni[n];if(!i)throw Error(`No semantic transition rule defined for token "${n}"`);if(!i.includes(r))throw Error(`Token "${r}" is not allowed after "${n}" at index ${e+1}`)}return!0}function ii(e){let t=ai(e);for(let e=0;e<t.length;e+=1){let n=t[e],r=t[e+1],i=t[e-1];if(n===`(`&&r===`)`)throw Error(`Empty group "()" is not allowed at token index ${e}`);if(n===`[`&&r===`]`)throw Error(`Empty sequence "[]" is not allowed at token index ${e}`);if(n===`,`){if(i===void 0||r===void 0)throw Error(`Unexpected "," at token index ${e}`);if(i===`[`)throw Error(`Sequence cannot start with "," at token index ${e}`);if(r===`]`)throw Error(`Sequence cannot end with "," at token index ${e}`);if(i===`,`||r===`,`)throw Error(`Unexpected consecutive "," at token index ${e}`)}}return!0}function ai(e){let t=e.trim(),n=[],r=0;for(;r<t.length;){let e=t.slice(r),i=t[r];if(/\s/.test(i)){r+=1;continue}if(e.startsWith(`color-stop`)){n.push(`color-stop`),r+=10;continue}if(e.startsWith(`color-hint`)){n.push(`color-hint`),r+=10;continue}if(e.startsWith(`config`)){n.push(`config`),r+=6;continue}if(i===`^`||i===`.`||i===`(`||i===`)`||i===`[`||i===`]`||i===`,`||i===`|`||i===`&`||i===`!`||i===`~`){n.push(i),r+=1;continue}throw Error(`Unexpected token near "${e}" at index ${r}`)}return n}function oi(e,t){try{return si(e,t),!0}catch{return!1}}function si(e,t){Qr(t);let n=ai(t).slice(1,-1),r=Ur(e,n,0,0);if(!r.matched)throw Error(`Input does not match pattern`);if(r.nextInputIndex!==e.length)throw Error(`Pattern did not consume all inputs`);if(r.nextPatternIndex!==n.length)throw Error(`Input ended before pattern was fully matched`);return!0}function ci(e,t=`^[([config,color-stop,([color-hint,color-stop]|color-stop)]|color-stop),~([color-hint,color-stop]|color-stop)].`){let n=e.trim();if(n.length===0)throw Error(`Expected function call, received empty string`);let{functionName:r,isRepeating:i,inputs:a}=pi(n),o=fi(a);return si(o,t),{functionName:r,isRepeating:i,inputs:o}}function li(e){return/^-?\d*\.?\d+(%|deg|rad|turn|grad|px|em|rem|vh|vw|vmin|vmax|cm|mm|in|pt|pc|q)?$/i.test(e.trim())}function ui(e){try{let t=_i(e)[0];return we(t)!==void 0}catch{return!1}}function di(e){return!li(e)&&!ui(e)}function fi(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?[]:t.map((e,t)=>t===0&&!ui(e)?{type:`config`,value:e}:ui(e)?{type:`color-stop`,value:e}:li(e)?{type:`color-hint`,value:e}:{type:`config`,value:e})}function pi(e){let t=e.indexOf(`(`);if(t<=0)throw Error(`Expected function opening parenthesis`);let n=e.slice(0,t).trim();if(n.length===0)throw Error(`Expected function name before "("`);let r=n.startsWith(`repeating-`);r&&(n=n.slice(10));let i=mi(e,t);if(i===-1)throw Error(`Unclosed function parenthesis`);let a=hi(e.slice(t+1,i));return{functionName:n,isRepeating:r,inputs:a}}function mi(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`){n+=1;continue}if(t===`)`){if(--n,n===0)return r;if(n<0)return-1}}return-1}function hi(e){let t=[],n=``,r=0,i=0,a=0;for(let o=0;o<e.length;o+=1){let s=e[o];if(s===`(`){r+=1,n+=s;continue}if(s===`)`){--r,n+=s;continue}if(s===`{`){i+=1,n+=s;continue}if(s===`}`){--i,n+=s;continue}if(s===`[`){a+=1,n+=s;continue}if(s===`]`){--a,n+=s;continue}if(s===`,`&&r===0&&i===0&&a===0){gi(t,n),n=``;continue}n+=s}return gi(t,n),t}function gi(e,t){let n=t.trim();n.length>0&&e.push(n)}function _i(e){let t=e.trim(),n=[],r=``,i=0,a=0,o=0;for(let e=0;e<t.length;e+=1){let s=t[e];if(s===`(`){i+=1,r+=s;continue}if(s===`)`){--i,r+=s;continue}if(s===`{`){a+=1,r+=s;continue}if(s===`}`){--a,r+=s;continue}if(s===`[`){o+=1,r+=s;continue}if(s===`]`){--o,r+=s;continue}if(/\s/.test(s)&&i===0&&a===0&&o===0){r.trim().length>0&&(n.push(r.trim()),r=``);continue}r+=s}return r.trim().length>0&&n.push(r.trim()),n}let vi=[`oklab`,`lch`,`oklch`,`hsl`,`hwb`,`lab`,`srgb`,`srgb-linear`,`xyz`,`display-p3`,`a98-rgb`,`prophoto-rgb`,`rec2020`],yi=[`shorter`,`longer`,`increasing`,`decreasing`],bi=[`hsl`,`hwb`,`lch`,`oklch`];function xi(e){return yi.includes(e)}function Si(e){return vi.includes(e)}function Ci(e){return bi.includes(e)}var wi=class{_isRepeating;_config;_stops;constructor(e){this._isRepeating=e.isRepeating,this._config=this._cloneConfig(e.config),this._stops=this._getSortedStops(this._cloneStops(e.stops)),this._validateConfig(this._config),this._validateStops(this._stops)}get isRepeating(){return this._isRepeating}get config(){return this._cloneConfig(this._config)}get stops(){return this._cloneStops(this._stops)}toJSON(){return{type:this.type,isRepeating:this.isRepeating,config:this._cloneConfig(this.config),stops:this._cloneStops(this.stops)}}addStop(e){let t=[...this._cloneStops(this._stops),...this._cloneStops([e])],n=this._getSortedStops(t);this._validateStops(n),this._stops=n}static fromString(e){throw Error(`Not implimented`)}static fromAbi(e){throw Error(`Not implimented`)}removeStop(e){if(!Number.isInteger(e))throw TypeError(`Gradient stop index must be an integer`);if(e<0||e>=this._stops.length)throw RangeError(`Gradient stop index is out of bounds`);if(this._stops.filter(e=>e.type===`color-stop`).length<=this._minColorStopsCount())throw Error(`Color stop count should be greather than ${this._minColorStopsCount()}`);let t=e+1>this._stops.length-1?this._stops.length-1:e+1,n=e-1>=0?e-1:0;e!==t&&this._stops[t].type===`color-hint`&&this._stops.splice(t,1),this._stops.splice(e,1),e!==n&&this._stops[n].type===`color-hint`&&this._stops.splice(n,1)}equals(e){if(this.type!==e.type||this.isRepeating!==e.isRepeating||JSON.stringify(this.config)!==JSON.stringify(e.config)||this.stops.length!==e.stops.length)return!1;for(let t=0;t<this.stops.length;t++){let n=this.stops[t],r=e.stops[t];if(n.type!==r.type||n.value!==r.value||n.position!==r.position)return!1}return!0}_minColorStopsCount(){return 0}_getSortedStops(e){return e.map((e,t)=>({stop:e,index:t})).sort((e,t)=>e.stop.position===t.stop.position?e.index-t.index:e.stop.position-t.stop.position).map(e=>e.stop)}_validateStops(e){this._validateStopsShape(e),this._validateStopsSequence(e)}_validateStopsShape(e){if(!Array.isArray(e))throw TypeError(`Gradient stops must be an array`);for(let t of e){if(typeof t!=`object`||!t)throw TypeError(`Gradient stop must be an object`);if(t.type!==`color-stop`&&t.type!==`color-hint`)throw TypeError(`Invalid gradient stop type: ${String(t.type)}`);if(typeof t.value!=`string`)throw TypeError(`Gradient stop value must be a string`);if(typeof t.position!=`number`||Number.isNaN(t.position))throw TypeError(`Gradient stop position must be a valid number`)}}_validateStopsSequence(e){if(e.length<this._minColorStopsCount())throw TypeError(`Gradient must contain at least ${this._minColorStopsCount()} stop`);if(e[0].type!==`color-stop`)throw TypeError(`Gradient stop sequence must start with a color-stop`);if(e[e.length-1].type===`color-hint`)throw TypeError(`Gradient stop sequence cannot end with a color-hint`);for(let t=1;t<e.length;t++){let n=e[t-1],r=e[t];if(n.type===`color-hint`&&r.type!==`color-stop`)throw TypeError(`A color-hint must be followed by a color-stop`)}}_cloneStops(e){return structuredClone(e)}_cloneConfig(e){return structuredClone(e)}_buildSerializedStopTokens(){let e=[];for(let t=0;t<this.stops.length;t++){let n=this.stops[t];if(n.type===`color-hint`){e.push({type:`color-hint`,position:n.position});continue}let r=this.stops[t+1];if(r&&r.type===`color-stop`&&r.value===n.value){e.push({type:`color-stop`,value:n.value,positions:[n.position,r.position]}),t+=1;continue}e.push({type:`color-stop`,value:n.value,positions:[n.position]})}return e}_canOmitAllStopPositions(e){let t=e.filter(e=>e.type===`color-stop`);if(e.some(e=>e.type===`color-hint`)||t.some(e=>e.positions.length!==1)||t.length<=1)return!1;for(let e=0;e<t.length;e++){let n=e/(t.length-1),r=t[e].positions[0];if(Math.abs(r-n)>1e-6)return!1}return!0}_serializeStopsCompact(){let e=this._buildSerializedStopTokens();return this._canOmitAllStopPositions(e)?e.map(e=>{if(e.type!==`color-stop`)throw Error(`Unexpected color-hint token in compact stop serialization`);return e.value}):e.map(e=>e.type===`color-hint`?`${this._formatPercent(e.position)}%`:e.positions.length===2?`${e.value} ${this._formatPercent(e.positions[0])}% ${this._formatPercent(e.positions[1])}%`:`${e.value} ${this._formatPercent(e.positions[0])}%`)}_formatPercent(e){return t(e*100,3)}static _normalizeAbiInputsToStops(e){let t=[];for(let n of e){if(n.type===`color-hint`){t.push({type:`color-hint`,value:n.value,position:this._parsePosition(n.value)});continue}if(n.type===`color-stop`){let e=this._parseColorStopInput(n.value);t.push(...e);continue}throw SyntaxError(`Unsupported linear gradient ABI input type: "${n.type}"`)}return this._resolvePendingStops(t)}static _parsePosition(e){let t=e.trim().toLowerCase().match(/^([+-]?(?:\d+\.?\d*|\.\d+))%$/);if(t===null)throw SyntaxError(`Invalid gradient stop position: "${e}"`);let n=Number(t[1]);if(!Number.isFinite(n))throw SyntaxError(`Invalid gradient stop position: "${e}"`);return n/100}static _parseColorStopInput(e){let t=_i(e);if(t.length===0)throw SyntaxError(`Color-stop input cannot be empty`);let n=[];for(;t.length>0;){let e=t[t.length-1];if(!/%$/.test(e)||(n.unshift(this._parsePosition(e)),t.pop(),n.length===2))break}let r=t.join(` `).trim();if(r.length===0)throw SyntaxError(`Color-stop is missing color value: "${e}"`);return n.length===0?[{type:`color-stop`,value:r}]:n.length===1?[{type:`color-stop`,value:r,position:n[0]}]:[{type:`color-stop`,value:r,position:n[0]},{type:`color-stop`,value:r,position:n[1]}]}static _resolvePendingStops(e){if(e.length===0)throw SyntaxError(`Linear gradient must contain at least one stop`);let t=e.map(e=>({...e})),n=t.findIndex(e=>e.type===`color-stop`),r=[...t].reverse().findIndex(e=>e.type===`color-stop`);if(n===-1)throw SyntaxError(`Linear gradient must contain at least one color-stop`);let i=t.length-1-r;t[n].position===void 0&&(t[n].position=0),t[i].position===void 0&&(t[i].position=1);let a=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.position!==void 0){if(a!==-1){let r=t[a],i=n,o=e-a;for(let e=1;e<o;e++){let n=t[a+e];n.position===void 0&&(n.position=r.position+(i.position-r.position)*e/o)}}a=e}}return t.map(e=>{if(e.position===void 0)throw SyntaxError(`Failed to resolve gradient stop position`);return{type:e.type,value:e.value,position:e.position}})}},Ti=class e extends wi{type=`linear-gradient`;constructor(t){t.config.angle=g(t.config.angle),t.config.interpolation&&(t.config.interpolation=e._normalizeConfigInterpolation(t.config.interpolation)),super(t)}static normalizeConfig(t){let n=e._tokenizeConfigInput(t),r=new Set;for(let e of n){if(r.has(e.type))throw SyntaxError(`Duplicate linear gradient config token: "${e.type}"`);r.add(e.type)}let i=n.find(e=>e.type===`angle`),a=n.find(e=>e.type===`colorSpace`),o=n.find(e=>e.type===`hue`),s={angle:3.141593,interpolation:{hue:`shorter`,colorSpace:`oklab`}};if(i){let e=i.value;if(e.startsWith(`to `)){let t=e.trim().toLowerCase().split(/\s+/).filter(Boolean);if(t.length===0)throw SyntaxError(`Linear gradient angle keyword cannot be empty`);if(t[0]!==`to`)throw SyntaxError(`Linear gradient keyword direction must start with "to"`);let n=t.slice(1);if(n.length===0||n.length>2)throw SyntaxError(`Linear gradient keyword direction must contain one or two direction tokens`);let r=new Set([`top`,`right`,`bottom`,`left`]);for(let e of n)if(!r.has(e))throw SyntaxError(`Invalid linear gradient direction token: "${e}"`);if(new Set(n).size!==n.length)throw SyntaxError(`Linear gradient keyword direction cannot contain duplicate tokens`);let i=n.includes(`top`),a=n.includes(`right`),o=n.includes(`bottom`),c=n.includes(`left`);if(i&&o||c&&a)throw SyntaxError(`Linear gradient keyword direction contains conflicting tokens`);if(i&&c)s.angle=d(315);else if(i&&a)s.angle=d(45);else if(o&&c)s.angle=d(225);else if(o&&a)s.angle=d(135);else if(i)s.angle=d(0);else if(a)s.angle=d(90);else if(o)s.angle=d(180);else if(c)s.angle=d(270);else throw SyntaxError(`Unsupported linear gradient keyword direction: "${e}"`)}else s.angle=g(u(e))}return a&&(s.interpolation.colorSpace=a.value),o&&(s.interpolation.hue=o.value),s}static fromString(t){return e.fromAbi(ci(t))}static fromAbi(t){let n={angle:3.141592};if(t.inputs[0].type===`config`){let r=t.inputs[0].value.trim().toLowerCase();if(r.length===0)throw SyntaxError(`Linear gradient config cannot be empty`);n=e.normalizeConfig(r)}let r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs,i=e._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:n,stops:i})}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._parseConfigToString(this.config),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){}static _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ci(t)?{colorSpace:t}:{colorSpace:t,hue:n}}_parseConfigToString(e){let{angle:t,interpolation:n}=e,r=[],i=this._parseAngleToString(t);return i.length>0&&r.push(i),n!==void 0&&r.push(this._parseInterpolationToString(n)),r.join(` `)}_parseAngleToString(e){let t=h(f(e),3);switch(t){case 0:return`to top`;case 45:return`to top right`;case 90:return`to right`;case 135:return`to bottom right`;case 180:return``;case 225:return`to bottom left`;case 270:return`to left`;case 315:return`to top left`;default:return`${t}deg`}}_parseInterpolationToString(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}static _tokenizeConfigInput(e){let t=e.trim().toLowerCase();if(t.length===0)throw SyntaxError(`Linear gradient config cannot be empty`);let n=t.split(/\s+/),r=[];for(let e=0;e<n.length;e+=1){let t=n[e];if(t===`in`){let t=n[e+1];if(t===void 0||!Si(t))throw SyntaxError(`Expected color space after "in"`);r.push({type:`colorSpace`,value:t}),e+=1;continue}if(l(t)){r.push({type:`angle`,value:t});continue}if(t===`to`){let t=[],i=n[e+1],a=n[e+2];i!==void 0&&t.push(i),(a===`left`||a===`right`)&&t.push(a);let o=`to ${t.join(` `)}`;r.push({type:`angle`,value:o}),e+=t.length;continue}if(xi(t)){if(n[e+1]!==`hue`)throw SyntaxError(`Expected "hue" after "${t}"`);r.push({type:`hue`,value:t}),e+=1;continue}throw SyntaxError(`Unknown linear gradient config token: "${t}"`)}return r}},Ei=class e extends wi{static DEFAULT_CONFIG={isRepeating:!1,stops:[{type:`color-stop`,value:`red`,position:0},{type:`color-stop`,value:`blue`,position:1}],config:{shape:`ellipse`,size:{kind:`extent`,value:`farthest-corner`},position:{kind:`keywords`,x:`center`,y:`center`}}};type=`radial-gradient`;constructor(t){let n={...e.DEFAULT_CONFIG,...t};n.config.interpolation&&(n.config.interpolation=e._normalizeConfigInterpolation(n.config.interpolation)),super(n)}static fromString(t){return e.fromAbi(ci(t))}static fromAbi(t){if(t.functionName!==`radial-gradient`)throw Error(`Invalid function name for RadialGradient`);let n=this._parseConfig(t.inputs),r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs,i=this._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:n,stops:i})}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._parseConfigToString(this.config),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){if(e.shape!==`circle`&&e.shape!==`ellipse`)throw Error(`Invalid shape`);if(!e.position)throw Error(`Position is required`);if(!e.size)throw Error(`Size is required`)}_parseConfigToString(e){let t=[],n=this._parseRadialConfigToString(e);return n.length>0&&t.push(n),e.interpolation!==void 0&&t.push(this._parseInterpolationToString(e.interpolation)),t.join(` `)}_parseRadialConfigToString(e){let t=[];return this._isDefaultRadialShape(e.shape)||t.push(e.shape),this._isDefaultRadialSize(e.size)||t.push(this._parseRadialSizeToString(e.size)),this._isDefaultRadialPosition(e.position)||t.push(`at ${this._serializePosition(e.position)}`),t.join(` `)}_parseRadialSizeToString(e){if(e.kind===`extent`)return e.value;let t=this._formatLengthPercentage(e.x);return e.y===void 0?t:`${t} ${this._formatLengthPercentage(e.y)}`}_parseInterpolationToString(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultRadialShape(e){return e===`ellipse`}_isDefaultRadialSize(e){return e.kind===`extent`&&e.value===`farthest-corner`}_isDefaultRadialPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}_serializePosition(e){if(e.kind===`keywords`)return`${e.x} ${e.y}`;let t=this._formatLengthPercentage(e.x),n=e.y?this._formatLengthPercentage(e.y):``;return n===``?t:`${t} ${n}`}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}static _parseConfig(e){let t=`ellipse`,n={kind:`extent`,value:`farthest-corner`},r={kind:`keywords`,x:`center`,y:`center`},i,a=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let o of e){if(o.type!==`config`)continue;let e=_i(o.value);for(let o=0;o<e.length;o++){let s=e[o];if(s===`circle`||s===`ellipse`){t=s;continue}if(s===`closest-side`||s===`closest-corner`||s===`farthest-side`||s===`farthest-corner`){n={kind:`extent`,value:s};continue}if(a(s)){let r=e[o+1];if(t===`ellipse`&&a(r)){n={kind:`explicit`,x:this._parseLengthPercentage(s),y:this._parseLengthPercentage(r)},o+=1;continue}n={kind:`explicit`,x:this._parseLengthPercentage(s)};continue}if(s===`at`){let t=e[o+1],n=e[o+2];if(t===`center`&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:`center`},o+=1;continue}if((t===`left`||t===`right`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:t,y:`center`},o+=1;continue}if((t===`top`||t===`bottom`)&&(n===void 0||n===`in`)){r={kind:`keywords`,x:`center`,y:t},o+=1;continue}if((t===`left`||t===`center`||t===`right`)&&(n===`top`||n===`center`||n===`bottom`)){r={kind:`keywords`,x:t,y:n},o+=2;continue}if(a(t)&&a(n)){r={kind:`values`,x:this._parseLengthPercentage(t),y:this._parseLengthPercentage(n)},o+=2;continue}throw Error(`Invalid radial-gradient position: ${t??``} ${n??``}`)}if(s===`in`){let t=e[o+1],n=e[o+2],r=e[o+3];if(!t)throw Error(`Invalid radial-gradient interpolation: missing color space`);if(n!==void 0&&r===`hue`){i=this._normalizeConfigInterpolation({colorSpace:t,hue:n}),o+=3;continue}i=this._normalizeConfigInterpolation({colorSpace:t}),o+=1;continue}}}return{shape:t,size:n,position:r,interpolation:i}}static _parseLengthPercentage(e){if(e.endsWith(`%`))return{kind:`percent`,value:parseFloat(e)};let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid length-percentage: ${e}`);return{kind:`length`,value:parseFloat(t[1]),unit:t[2]}}static _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ci(t)?{colorSpace:t}:{colorSpace:t,hue:n}}},Di=class e extends Ei{type=`diamond-gradient`;constructor(e){super(e)}static fromString(t){return e.fromAbi(ci(t))}static fromAbi(t){if(t.functionName!==`diamond-gradient`)throw Error(`Invalid function name for DiamondGradient`);let n=this._parseConfig(t.inputs),r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs,i=this._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:n,stops:i})}clone(){return new e(this.toJSON())}},Oi=class e extends wi{type=`conic-gradient`;constructor(e){super(e)}clone(){return new e(this.toJSON())}toString(){return`${this.isRepeating?`repeating-${this.type}`:this.type}(${[this._serializeConfig(),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}static fromString(e){return this.fromAbi(ci(e))}static fromAbi(t){if(t.functionName!==`conic-gradient`)throw Error(`Invalid function name for ConicGradient`);let n=t.inputs.find(e=>e.type===`config`),r=t.inputs.filter(e=>e.type!==`config`),i=this._parseConfig(n?.value),a=this._normalizeAbiInputsToStops(r);return new e({isRepeating:t.isRepeating,config:i,stops:a})}_validateConfig(e){}_serializeConfig(){let e=[];if(!this._isDefaultFrom(this.config.from)){let t=this.config.from;e.push(`from ${t.value}${t.unit}`)}return this._isDefaultPosition(this.config.position)||e.push(`at ${this._serializePosition(this.config.position)}`),this.config.interpolation!==void 0&&e.push(this._serializeInterpolation(this.config.interpolation)),e.join(` `)}_serializePosition(e){if(e.kind===`keywords`)return`${e.x} ${e.y}`;let t=this._formatLengthPercentage(e.x),n=e.y?this._formatLengthPercentage(e.y):``;return n===``?t:`${t} ${n}`}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}_serializeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultFrom(e){return e.value===0&&e.unit===`deg`}_isDefaultPosition(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}static _parseConfig(e){let t={from:{kind:`angle`,value:0,unit:`deg`},position:{kind:`keywords`,x:`center`,y:`center`}};if(!e)return t;let n=_i(e),r=e=>e===void 0?!1:e.endsWith(`%`)||/^-?\d*\.?\d+[a-zA-Z]+$/.test(e);for(let e=0;e<n.length;e++){let i=n[e];if(i===`from`){let r=n[e+1];if(r===void 0)throw Error(`Invalid conic-gradient config: missing angle after from`);t.from=this._parseAngle(r),e+=1;continue}if(i===`at`){let i=n[e+1],a=n[e+2];if(i===void 0)throw Error(`Invalid conic-gradient config: missing position after at`);if(i===`center`&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:`center`},e+=1;continue}if((i===`left`||i===`right`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:i,y:`center`},e+=1;continue}if((i===`top`||i===`bottom`)&&(a===void 0||a===`in`)){t.position={kind:`keywords`,x:`center`,y:i},e+=1;continue}if((i===`left`||i===`center`||i===`right`)&&(a===`top`||a===`center`||a===`bottom`)){t.position={kind:`keywords`,x:i,y:a},e+=2;continue}if(r(i)&&r(a)){t.position={kind:`values`,x:this._parseLengthPercentage(i),y:this._parseLengthPercentage(a)},e+=2;continue}throw Error(`Invalid conic-gradient position: ${i} ${a??``}`)}if(i===`in`){let r=n[e+1],i=n[e+2],a=n[e+3];if(r===void 0)throw Error(`Invalid conic-gradient interpolation: missing color space`);if(a===`hue`&&(i===`shorter`||i===`longer`||i===`increasing`||i===`decreasing`)){t.interpolation={colorSpace:r,hue:i},e+=3;continue}t.interpolation={colorSpace:r},e+=1;continue}}return t}static _parseLengthPercentage(e){if(e.endsWith(`%`))return{kind:`percent`,value:parseFloat(e)};let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid length-percentage: ${e}`);return{kind:`length`,value:parseFloat(t[1]),unit:t[2]}}static _parseAngle(e){let t=e.match(/^(-?\d*\.?\d+)(deg|rad|turn|grad)$/);if(!t)throw Error(`Invalid angle: ${e}`);return{kind:`angle`,value:Number(t[1]),unit:t[2]}}};let ki=/^[A-Za-z_][A-Za-z0-9_-]*$/,Ai=[`px`,`em`,`rem`,`vw`,`vh`,`vmin`,`vmax`,`cm`,`mm`,`in`,`pt`,`pc`];var ji=class e{type=`mesh-gradient`;_config;_vertices;_patches;constructor(t){let n=structuredClone(t.config);n.interpolation&&=e._normalizeInterpolation(n.interpolation),this._config=n,this._vertices=structuredClone(t.vertices),this._patches=structuredClone(t.patches),this._validate()}get config(){return structuredClone(this._config)}get vertices(){return structuredClone(this._vertices)}get patches(){return structuredClone(this._patches)}static fromString(t){let{functionName:n,isRepeating:r,inputs:i}=e._parseFunction(t);if(n!==`mesh-gradient`)throw Error(`Invalid function name for MeshGradient`);if(r)throw Error(`MeshGradient does not support repeating gradients`);let a=null,o=[],s=[],c=[];for(let e of i){let t=_i(e),n=t[0];if(n===`grid`){if(a!==null)throw Error(`mesh-gradient can only contain one grid config`);a=this._parseConfig(t);continue}if(n===`vertex`){o.push(this._parseVertex(t));continue}if(n===`patch`){s.push(this._parsePatch(t));continue}if(n===`handle`){c.push(this._parseHandle(t));continue}throw Error(`Unsupported mesh-gradient input: ${e}`)}if(!a)throw Error(`mesh-gradient requires a grid config`);let l=this._attachHandles(s,c);return new e({config:a,vertices:o,patches:l})}static fromAbi(t){if(t.functionName!==`mesh-gradient`)throw Error(`Invalid function name for MeshGradient`);if(t.isRepeating)throw Error(`MeshGradient does not support repeating gradients`);return e.fromString(`${t.functionName}(${t.inputs.map(e=>e.value).join(`, `)})`)}clone(){return new e(this.toJSON())}toJSON(){return{type:this.type,config:this.config,vertices:this.vertices,patches:this.patches}}toString(){let e=[this._serializeConfig(),...this._vertices.map(e=>this._serializeVertex(e)),...this._patches.map(e=>this._serializePatch(e)),...this._patches.flatMap(e=>this._serializeHandles(e))];return`${this.type}(${e.join(`, `)})`}getVertex(e){let t=this._vertices.find(t=>t.id===e);return t?structuredClone(t):null}_serializeConfig(){let e=[`grid`,String(this._config.rows),String(this._config.columns),`method`,this._config.method];return this._config.interpolation&&(e.push(`in`,this._config.interpolation.colorSpace),this._config.interpolation.hue&&e.push(this._config.interpolation.hue,`hue`)),e.join(` `)}_serializeVertex(e){return[`vertex`,e.id,this._formatLengthPercentage(e.x),this._formatLengthPercentage(e.y),e.color].join(` `)}_serializePatch(e){return[`patch`,e.id,e.topLeft,e.topRight,e.bottomRight,e.bottomLeft].join(` `)}_serializeHandles(e){if(!e.handles)return[];let t=[];for(let n of[`top`,`right`,`bottom`,`left`]){let r=e.handles[n];r&&t.push([`handle`,e.id,n,this._formatLengthPercentage(r.from.x),this._formatLengthPercentage(r.from.y),this._formatLengthPercentage(r.to.x),this._formatLengthPercentage(r.to.y)].join(` `))}return t}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}_validate(){if(!Number.isInteger(this._config.rows)||this._config.rows<2)throw Error(`Mesh gradient rows must be an integer >= 2`);if(!Number.isInteger(this._config.columns)||this._config.columns<2)throw Error(`Mesh gradient columns must be an integer >= 2`);if(this._config.method!==`bilinear`&&this._config.method!==`bicubic`)throw Error(`Invalid mesh gradient interpolation method`);if(this._config.interpolation&&!Si(this._config.interpolation.colorSpace))throw Error(`Invalid mesh gradient color space: ${this._config.interpolation.colorSpace}`);let e=this._config.rows*this._config.columns,t=(this._config.rows-1)*(this._config.columns-1);if(this._vertices.length!==e)throw Error(`Mesh gradient expected ${e} vertices for ${this._config.rows}x${this._config.columns} grid, received ${this._vertices.length}`);if(this._patches.length!==t)throw Error(`Mesh gradient expected ${t} patches for ${this._config.rows}x${this._config.columns} grid, received ${this._patches.length}`);let n=new Set;for(let e of this._vertices){if(this._validateId(e.id,`vertex`),n.has(e.id))throw Error(`Duplicate mesh vertex id: ${e.id}`);if(n.add(e.id),this._validateLengthPercentage(e.x,`vertex ${e.id} x`),this._validateLengthPercentage(e.y,`vertex ${e.id} y`),!we(e.color))throw Error(`Invalid mesh vertex color: ${e.color}`)}let r=new Set;for(let e of this._patches){if(this._validateId(e.id,`patch`),r.has(e.id))throw Error(`Duplicate mesh patch id: ${e.id}`);r.add(e.id);let t=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];if(new Set(t).size!==4)throw Error(`Mesh patch must use 4 unique vertices: ${e.id}`);for(let e of t)if(!n.has(e))throw Error(`Mesh patch references missing vertex: ${e}`);e.handles&&this._validateHandles(e)}if(this._patches.length===0)throw Error(`Mesh gradient requires at least one patch`)}_validateId(e,t){if(!ki.test(e))throw Error(`Invalid mesh ${t} id: ${e}`)}_validateHandles(e){if(e.handles)for(let t of[`top`,`right`,`bottom`,`left`]){let n=e.handles[t];n&&(this._validateLengthPercentage(n.from.x,`patch ${e.id} ${t} handle from x`),this._validateLengthPercentage(n.from.y,`patch ${e.id} ${t} handle from y`),this._validateLengthPercentage(n.to.x,`patch ${e.id} ${t} handle to x`),this._validateLengthPercentage(n.to.y,`patch ${e.id} ${t} handle to y`))}}_validateLengthPercentage(e,t){if(e.kind===`percent`){if(!Number.isFinite(e.value))throw Error(`Invalid mesh ${t}`);return}if(!Number.isFinite(e.value))throw Error(`Invalid mesh ${t}`)}static _parseConfig(e){if(e.length<3)throw Error(`Invalid mesh grid config`);let t=Number(e[1]),n=Number(e[2]),r=`bilinear`,i;for(let t=3;t<e.length;t+=1){let n=e[t];if(n===`method`){let n=e[t+1];if(n!==`bilinear`&&n!==`bicubic`)throw Error(`Invalid mesh gradient method: ${n}`);r=n,t+=1;continue}if(n===`in`){let n=e[t+1],r=e[t+2],a=e[t+3];if(!Si(n))throw Error(`Invalid mesh gradient color space: ${n}`);if(r!==void 0&&a===`hue`&&xi(r)){i=this._normalizeInterpolation({colorSpace:n,hue:r}),t+=3;continue}i={colorSpace:n},t+=1;continue}throw Error(`Unsupported mesh grid config token: ${n}`)}return{rows:t,columns:n,method:r,interpolation:i}}static _parseVertex(e){if(e.length<5)throw Error(`Invalid mesh vertex input`);return{id:e[1],x:this._parseLengthPercentage(e[2]),y:this._parseLengthPercentage(e[3]),color:e.slice(4).join(` `)}}static _parsePatch(e){if(e.length!==6)throw Error(`Invalid mesh patch input`);return{id:e[1],topLeft:e[2],topRight:e[3],bottomRight:e[4],bottomLeft:e[5]}}static _parseHandle(e){if(e.length!==7)throw Error(`Invalid mesh handle input`);let t=e[2];if(t!==`top`&&t!==`right`&&t!==`bottom`&&t!==`left`)throw Error(`Invalid mesh handle side: ${t}`);return{patchId:e[1],side:t,from:{x:this._parseLengthPercentage(e[3]),y:this._parseLengthPercentage(e[4])},to:{x:this._parseLengthPercentage(e[5]),y:this._parseLengthPercentage(e[6])}}}static _attachHandles(e,t){if(t.length===0)return e;let n=new Map(e.map(e=>[e.id,e])),r=e.map(e=>structuredClone(e)),i=new Map(r.map(e=>[e.id,e]));for(let e of t){if(!n.has(e.patchId))throw Error(`Mesh handle references missing patch: ${e.patchId}`);let t=i.get(e.patchId);if(t.handles??={},t.handles[e.side])throw Error(`Duplicate mesh handle for patch ${e.patchId} side ${e.side}`);t.handles[e.side]={from:e.from,to:e.to}}return r}static _parseLengthPercentage(e){if(e.endsWith(`%`)){let t=parseFloat(e);if(!Number.isFinite(t))throw Error(`Invalid mesh length-percentage: ${e}`);return{kind:`percent`,value:t}}let t=e.match(/^(-?\d*\.?\d+)([a-zA-Z]+)$/);if(!t)throw Error(`Invalid mesh length-percentage: ${e}`);let n=t[2];if(!Ai.includes(n))throw Error(`Unsupported mesh length unit: ${t[2]}`);return{kind:`length`,value:parseFloat(t[1]),unit:n}}static _normalizeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ci(t)?{colorSpace:t}:{colorSpace:t,hue:n}}static _parseFunction(e){let t=e.trim(),n=t.indexOf(`(`);if(n<=0)throw Error(`Expected mesh-gradient function call`);let r=t.slice(0,n).trim(),i=r.startsWith(`repeating-`);i&&(r=r.slice(10));let a=this._findOuterClosingParenIndex(t,n);if(a===-1)throw Error(`Unclosed mesh-gradient function parenthesis`);let o=t.slice(a+1).trim();if(o.length>0&&!o.startsWith(`${r}(`)&&!o.startsWith(`repeating-${r}(`))throw Error(`Unexpected mesh-gradient trailing input: ${o}`);let s=t.slice(n+1,a);return{functionName:r,isRepeating:i,inputs:this._splitTopLevelInputs(s)}}static _findOuterClosingParenIndex(e,t){let n=0;for(let r=t;r<e.length;r+=1){let t=e[r];if(t===`(`){n+=1;continue}if(t===`)`){if(--n,n===0)return r;if(n<0)return-1}}return-1}static _splitTopLevelInputs(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i+=1){let a=e[i];if(a===`(`){r+=1,n+=a;continue}if(a===`)`){if(--r,r<0)throw Error(`Unbalanced mesh-gradient input parentheses`);n+=a;continue}if(a===`,`&&r===0){this._pushTrimmed(t,n),n=``;continue}n+=a}if(this._pushTrimmed(t,n),r!==0)throw Error(`Unbalanced mesh-gradient input parentheses`);return t}static _pushTrimmed(e,t){let n=t.trim();n.length>0&&e.push(n)}},Mi=class{target=`css`;gradientType=`linear-gradient`;to(e){if(!(e instanceof Ti))throw Error(`Expected LinearGradient`);return e.toString()}},Ni=class{target=`css`;gradientType=`radial-gradient`;to(e){if(!(e instanceof Ei))throw Error(`Expected RadialGradient`);return e.toString()}};function Pi(e,t){return(e%t+t)%t}function Fi(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return K(J([r.value,i.value],`rgb`)(n))}}return r.value}function Ii(e,t,n,r){return Fi(e,n+Pi(t-n,r))}function Li(e,t,n){let r=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(r.length<2)return r;let i=r[0].position,a=r[r.length-1].position-i;if(a<=0)return r;let o=[],s=0;o.push({type:`color-stop`,value:Ii(r,t,i,a),position:t,_order:s}),s+=1;let c=Math.floor((t-i)/a)-1,l=Math.ceil((n-i)/a)+1;for(let e=c;e<=l;e+=1){let i=e*a;for(let e of r){let r=e.position+i;r<=t||r>=n||(o.push({...e,position:r,_order:s}),s+=1)}}return o.push({type:`color-stop`,value:Ii(r,n,i,a),position:n,_order:s}),o.sort((e,t)=>e.position===t.position?e._order-t._order:e.position-t.position).map(({_order:e,...t})=>t)}function Ri(e){return Li(e,0,1)}function zi(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>{let r=(n.x-e.x)/Math.max(t.x,1e-4),i=(n.y-e.y)/Math.max(t.y,1e-4);return Math.sqrt(r*r+i*i)}))}function Bi(e){switch(e){case`longer`:return ze;case`increasing`:return Be;case`decreasing`:return Ve;default:return R}}function Vi(e){switch(e){case`a98-rgb`:return`a98`;case`display-p3`:return`p3`;case`prophoto-rgb`:return`prophoto`;case`xyz`:return`xyz65`;case`srgb`:case`srgb-linear`:return`rgb`;default:return e}}function Hi(e){if(e.hue!==void 0)return{h:{fixup:Bi(e.hue)}}}function Ui(e){let t=e.filter(e=>e.type===`color-stop`);return t.length===0?[]:t.length===1?[{...t[0],position:t[0].position??0}]:t.map((e,n)=>e.position==null?n===0?{...e,position:0}:n===t.length-1?{...e,position:1}:{...e,position:n/(t.length-1)}:e)}function Wi(e){let t=Gi(e);if(!t)throw Error(`Failed to convert interpolated color to rgb.`);return K(t)}let Gi=E(`rgb`);function Y(e,t=64){let n=Ui(e.stops),r=e.config.interpolation;if(n.length<2)return n;if(r===void 0)return e.isRepeating?Ri(n):n;let i=[],a=Vi(r.colorSpace),o=Hi(r);for(let e=0;e<n.length-1;e+=1){let r=n[e],s=n[e+1],c=r.position,l=s.position,u=J([r.value,s.value],a,o);for(let n=0;n<=t;n+=1){if(e>0&&n===0)continue;let r=n/t,a=c+(l-c)*r,o=u(r);i.push({type:`color-stop`,value:Wi(o),position:a})}}return e.isRepeating?Ri(i):i}let Ki=E(`rgb`);function qi(e){let t=Ki(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Ji(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported mesh-gradient length unit: ${e.unit}`)}function Yi(e,t,n){return{id:e.id,x:Ji(e.x,t),y:Ji(e.y,n),color:qi(e.color)}}function Xi(e,t,n){return new Map(e.vertices.map(e=>[e.id,Yi(e,t,n)]))}function Zi(e,t){let n=Qi(e,t);if(n)return n;let r=e.vertices.map(e=>{let n=t.get(e.id);if(!n)throw Error(`Missing mesh vertex: ${e.id}`);return n}).sort((e,t)=>Math.abs(e.y-t.y)>1e-4?e.y-t.y:e.x-t.x),i=[];for(let t=0;t<e.config.rows;t+=1){let n=t*e.config.columns,a=n+e.config.columns;i.push(r.slice(n,a))}return i}function Qi(e,t){let n=Array.from({length:e.config.rows},()=>[]);for(let r of e.vertices){let i=r.id.match(/^v(\d+)(\d+)$/);if(!i)return null;let a=Number(i[1]),o=Number(i[2]);if(!Number.isInteger(o)||!Number.isInteger(a)||o<0||a<0||o>=e.config.rows||a>=e.config.columns)return null;let s=t.get(r.id);if(!s)throw Error(`Missing mesh vertex: ${r.id}`);if(n[o][a])return null;n[o][a]=s}return n.some(t=>t.length!==e.config.columns||t.some(e=>e===void 0))?null:n}function $i(e,t){for(let n=0;n<e.length-1;n+=1)for(let r=0;r<e[n].length-1;r+=1)if(e[n][r].id===t.topLeft&&e[n][r+1].id===t.topRight&&e[n+1][r+1].id===t.bottomRight&&e[n+1][r].id===t.bottomLeft)return{row:n,column:r};throw Error(`Mesh patch does not match adjacent regular grid vertices: ${t.id}`)}function ea(e,t){return Math.min(t-1,Math.max(0,e))}function ta(e,t,n,r,i){let a=i*i,o=a*i;return .5*(2*t+(-e+n)*i+(2*e-5*t+4*n-r)*a+(-e+3*t-3*n+r)*o)}function na(e){return Math.min(1,Math.max(0,e))}function X(e,t,n){return e+(t-e)*n}function ra(e,t,n){return[X(e[0],t[0],n),X(e[1],t[1],n),X(e[2],t[2],n),X(e[3],t[3],n)]}function ia(e,t,n,r,i,a){return ra(ra(e.color,t.color,i),ra(r.color,n.color,i),a)}function aa(e,t,n,r,i){let a=e.length,o=e[0]?.length??0,s=[0,0,0,0];for(let c=0;c<4;c+=1){let l=[];for(let i=-1;i<=2;i+=1){let s=e[ea(t+i,a)],u=s[ea(n-1,o)].color[c],d=s[ea(n,o)].color[c],f=s[ea(n+1,o)].color[c],p=s[ea(n+2,o)].color[c];l.push(ta(u,d,f,p,r))}s[c]=na(ta(l[0],l[1],l[2],l[3],i))}return s}function Z(e,t,n,r,i,a){let o=X(e.x,t.x,i),s=X(e.y,t.y,i),c=X(r.x,n.x,i),l=X(r.y,n.y,i);return{x:X(o,c,a),y:X(s,l,a)}}function oa(e,t,n,r,i,a,o,s,c,l){return e.config.method===`bicubic`?aa(t,n,r,c,l):ia(i,a,o,s,c,l).map(na)}function sa(e,t,n,r,i){let a=r.get(n.topLeft),o=r.get(n.topRight),s=r.get(n.bottomRight),c=r.get(n.bottomLeft);if(!a||!o||!s||!c)throw Error(`Mesh patch references missing vertex: ${n.id}`);let l=$i(t,n),u=[];for(let r=0;r<=i;r+=1){let d=[],f=r/i;for(let u=0;u<=i;u+=1){let p=u/i,m=Z(a,o,s,c,p,f),h=oa(e,t,l.row,l.column,a,o,s,c,p,f);d.push({id:`${n.id}:${u}:${r}`,x:m.x,y:m.y,color:h})}u.push(d)}let d=[];for(let e=0;e<i;e+=1)for(let t=0;t<i;t+=1){let n=u[e][t],r=u[e][t+1],i=u[e+1][t+1],a=u[e+1][t];d.push([n,r,i],[n,i,a])}return d}function Q(e,t,n,r,i,a,o,s,c,l,u,d,f){return{id:f,x:u,y:d,color:oa(e,t,n,r,i,a,o,s,c,l)}}function ca(e,t,n,r,i){let a=[],o=t.length,s=t[0]?.length??0;if(o<2||s<2)return a;for(let n=0;n<s-1;n+=1){let r=t[0][n],o=t[0][n+1],s=t[1][n+1],c=t[1][n];for(let l=0;l<i;l+=1){let u=l/i,d=(l+1)/i,f=Z(r,o,s,c,u,0),p=Z(r,o,s,c,d,0),m=Z(r,o,s,c,u,1),h=Z(r,o,s,c,d,1),g=Math.min(0,(0-f.y)/Math.max(m.y-f.y,1e-4)),_=Math.min(0,(0-p.y)/Math.max(h.y-p.y,1e-4)),v=Q(e,t,0,n,r,o,s,c,u,0,f.x,f.y,`top:${n}:${l}:b0`),y=Q(e,t,0,n,r,o,s,c,d,0,p.x,p.y,`top:${n}:${l}:b1`),b=Q(e,t,0,n,r,o,s,c,u,g,f.x,0,`top:${n}:${l}:p0`),x=Q(e,t,0,n,r,o,s,c,d,_,p.x,0,`top:${n}:${l}:p1`);a.push([b,x,y],[b,y,v])}}for(let n=0;n<s-1;n+=1){let s=o-2,c=t[s][n],l=t[s][n+1],u=t[s+1][n+1],d=t[s+1][n];for(let o=0;o<i;o+=1){let f=o/i,p=(o+1)/i,m=Z(c,l,u,d,f,0),h=Z(c,l,u,d,p,0),g=Z(c,l,u,d,f,1),_=Z(c,l,u,d,p,1),v=Math.max(1,(r-m.y)/Math.max(g.y-m.y,1e-4)),y=Math.max(1,(r-h.y)/Math.max(_.y-h.y,1e-4)),b=Q(e,t,s,n,c,l,u,d,f,1,g.x,g.y,`bottom:${n}:${o}:b0`),x=Q(e,t,s,n,c,l,u,d,p,1,_.x,_.y,`bottom:${n}:${o}:b1`),S=Q(e,t,s,n,c,l,u,d,f,v,g.x,r,`bottom:${n}:${o}:p0`),C=Q(e,t,s,n,c,l,u,d,p,y,_.x,r,`bottom:${n}:${o}:p1`);a.push([b,x,C],[b,C,S])}}for(let n=0;n<o-1;n+=1){let r=t[n][0],o=t[n][1],s=t[n+1][1],c=t[n+1][0];for(let l=0;l<i;l+=1){let u=l/i,d=(l+1)/i,f=Z(r,o,s,c,0,u),p=Z(r,o,s,c,0,d),m=Z(r,o,s,c,1,u),h=Z(r,o,s,c,1,d),g=Math.min(0,(0-f.x)/Math.max(m.x-f.x,1e-4)),_=Math.min(0,(0-p.x)/Math.max(h.x-p.x,1e-4)),v=Q(e,t,n,0,r,o,s,c,0,u,f.x,f.y,`left:${n}:${l}:b0`),y=Q(e,t,n,0,r,o,s,c,0,d,p.x,p.y,`left:${n}:${l}:b1`),b=Q(e,t,n,0,r,o,s,c,g,u,0,f.y,`left:${n}:${l}:p0`),x=Q(e,t,n,0,r,o,s,c,_,d,0,p.y,`left:${n}:${l}:p1`);a.push([b,v,y],[b,y,x])}}for(let r=0;r<o-1;r+=1){let o=s-2,c=t[r][o],l=t[r][o+1],u=t[r+1][o+1],d=t[r+1][o];for(let s=0;s<i;s+=1){let f=s/i,p=(s+1)/i,m=Z(c,l,u,d,0,f),h=Z(c,l,u,d,0,p),g=Z(c,l,u,d,1,f),_=Z(c,l,u,d,1,p),v=Math.max(1,(n-m.x)/Math.max(g.x-m.x,1e-4)),y=Math.max(1,(n-h.x)/Math.max(_.x-h.x,1e-4)),b=Q(e,t,r,o,c,l,u,d,1,f,g.x,g.y,`right:${r}:${s}:b0`),x=Q(e,t,r,o,c,l,u,d,1,p,_.x,_.y,`right:${r}:${s}:b1`),S=Q(e,t,r,o,c,l,u,d,v,f,n,g.y,`right:${r}:${s}:p0`),C=Q(e,t,r,o,c,l,u,d,y,p,n,_.y,`right:${r}:${s}:p1`);a.push([b,S,C],[b,C,x])}}return a}function la(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function ua(e,t){if(e.length===0)throw Error(`Cannot sample color from empty diamond gradient stops.`);if(e.length===1||t<=e[0].position)return e[0].value;let n=e[e.length-1];if(t>=n.position)return n.value;for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return K(J([r.value,i.value],`rgb`)(n))}}return n.value}function da(e){return e.kind===`keywords`?{x:fa(e.x),y:pa(e.y)}:{x:ma(e.x,100),y:ma(e.y,100)}}function fa(e){return e===`left`?0:e===`right`?100:50}function pa(e){return e===`top`?0:e===`bottom`?100:50}function ma(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for CSS transformer: ${e.unit}`)}function ha(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function ga(e){return[{dx:-e.x,dy:-e.y},{dx:100-e.x,dy:-e.y},{dx:-e.x,dy:100-e.y},{dx:100-e.x,dy:100-e.y}]}function _a(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}function va(e,t){return Math.max(...[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}function ya(e,t,n){if(e.kind===`explicit`){let n=ma(e.x,100),r=e.y?ma(e.y,100):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:r,1e-4)}}let r=n.x,i=100-n.x,a=n.y,o=100-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(e=>ha(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(r,i,a,o),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let s=Math.max(Math.max(...t),1e-4);return{x:s,y:s}}let s=Math.min(r,i),c=Math.min(a,o),l=Math.max(r,i),u=Math.max(a,o);if(e.value===`closest-side`)return{x:Math.max(s,1e-4),y:Math.max(c,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};let d=ga(n);return e.value===`closest-corner`?d.map(e=>_a(s,c,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):d.map(e=>_a(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function $(e){return Number(e.toFixed(3)).toString()}function ba(e,t,n){let r=t.x*n,i=t.y*n;return[`${$(e.x)} ${$(e.y-i)}`,`${$(e.x+r)} ${$(e.y)}`,`${$(e.x)} ${$(e.y+i)}`,`${$(e.x-r)} ${$(e.y)}`].join(` `)}function xa(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var Sa=class{target=`css`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Di))throw Error(`Expected DiamondGradient`);let t=da(e.config.position),n=ya(e.config.size,e.config.shape,t),r=va(t,n),i=e.isRepeating?r:1,a=Y(e,96),o=la(e.isRepeating?Li(a,0,r):a),s=ua(o,i),c=[],l=Math.max(96,Math.ceil(96*i));for(let e=l;e>=0;--e){let r=e/l*i,a=ua(o,r),s=ba(t,n,r);c.push(`<polygon points="${s}" fill="${a}"/>`)}return xa([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<rect width="100" height="100" fill="${s}"/>`,...c,`</svg>`].join(``))}},Ca=class{target=`css`;gradientType=`conic-gradient`;to(e){if(!(e instanceof Oi))throw Error(`Expected ConicGradient`);return e.toString()}};function wa(e){return`rgba(${e[0]},${e[1]},${e[2]},${Number(e[3].toFixed(3))})`}function Ta(e,t,n,r,i){let a=(r.y-i.y)*(n.x-i.x)+(i.x-r.x)*(n.y-i.y);if(Math.abs(a)<1e-6)return null;let o=((r.y-i.y)*(e-i.x)+(i.x-r.x)*(t-i.y))/a,s=((i.y-n.y)*(e-i.x)+(n.x-i.x)*(t-i.y))/a,c=1-o-s;return o<-1e-4||s<-1e-4||c<-1e-4?null:[o,s,c]}function Ea(e,t,n,r){let[i,a,o]=e;return[Math.round((t.color[0]*i+n.color[0]*a+r.color[0]*o)*255),Math.round((t.color[1]*i+n.color[1]*a+r.color[1]*o)*255),Math.round((t.color[2]*i+n.color[2]*a+r.color[2]*o)*255),t.color[3]*i+n.color[3]*a+r.color[3]*o]}function Da(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var Oa=class{target=`css`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected MeshGradient`);let t=Xi(e,96,96),n=Zi(e,t),r=e.config.method===`bicubic`?24:1,i=e.patches.flatMap(i=>sa(e,n,i,t,r)),a=ca(e,n,96,96,r),o=[...i,...a],s=[];for(let e=0;e<96;e+=1)for(let t=0;t<96;t+=1){let n=t+.5,r=e+.5,i=null;for(let[e,t,a]of o){let o=Ta(n,r,e,t,a);if(o){i=Ea(o,e,t,a);break}}i&&s.push(`<rect x="${t}" y="${e}" width="1" height="1" fill="${wa(i)}"/>`)}return Da([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" preserveAspectRatio="none" shape-rendering="crispEdges">`,...s,`</svg>`].join(``))}};let ka=E(`rgb`);function Aa(e){let t=ka(e);if(!t)throw Error(`Failed to convert color: ${e}`);return K(t)}function ja(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function Ma(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}var Na=class{target=`canvas-2d`;gradientType=`linear-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=t.config.angle,a=Math.sin(i),o=-Math.cos(i),s=n/2,c=r/2,l=Math.abs(n*a)+Math.abs(r*o),u=s-a*l/2,d=c-o*l/2,f=s+a*l/2,p=c+o*l/2,{min:m,max:h,stops:g}=ja(Y(t)),_=g;if(m<0||h>1){let e=f-u,t=p-d,n=u,r=d;u=n+e*m,d=r+t*m,f=n+e*h,p=r+t*h,_=Ma(g,m,h)}let v=e.createLinearGradient(u,d,f,p);for(let e of _)v.addColorStop(e.position,Aa(e.value));e.clearRect(0,0,n,r),e.fillStyle=v,e.fillRect(0,0,n,r)}}}};let Pa=E(`rgb`);function Fa(e){let t=Pa(e);if(!t)throw Error(`Failed to convert color: ${e}`);return K(t)}function Ia(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function La(e,t,n){let r=n-t||1;return e.map(e=>({...e,position:(e.position-t)/r}))}function Ra(e,t,n,r){return r===`left`?e.x:r===`right`?t-e.x:r===`top`?e.y:n-e.y}function za(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ba(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Va(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.sqrt(n*n/(i*i)+r*r/(a*a));return{x:i*o,y:a*o}}var Ha=class{target=`canvas-2d`;gradientType=`radial-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=this._resolveCenter(t.config.position,n,r),a=this._resolveRadialRadii(t.config.size,t.config.shape,i,n,r),o=zi(i,a,n,r),s=Y(t,128),{min:c,max:l,stops:u}=Ia(t.isRepeating?Li(s,0,o):s),d=u,f=0,p=t.isRepeating?o:1;if(t.isRepeating?d=La(u,0,o):(c<0||l>1)&&(d=La(u,c,l),f=c,p=l),t.config.shape===`circle`){let t=a.x,o=Math.max(0,t*f),s=Math.max(o+1e-4,t*p),c=e.createRadialGradient(i.x,i.y,o,i.x,i.y,s);for(let e of d)c.addColorStop(e.position,Fa(e.value));e.fillStyle=c,e.fillRect(0,0,n,r);return}let m=Math.max(a.x,a.y),h=a.x/m,g=a.y/m,_=Math.max(0,m*f),v=Math.max(_+1e-4,m*p);e.save(),e.translate(i.x,i.y),e.scale(h,g);let y=e.createRadialGradient(0,0,_,0,0,v);for(let e of d)y.addColorStop(e.position,Fa(e.value));e.fillStyle=y;let b=v+2;e.fillRect(-b/h*2,-b/g*2,b/h*4,b/g*4),e.restore()}}}_resolveCenter(e,t,n){return e.kind===`keywords`?{x:this._resolveKeywordX(e.x,t),y:this._resolveKeywordY(e.y,n)}:{x:this._resolve(e.x,t),y:this._resolve(e.y,n)}}_resolveKeywordX(e,t){return e===`left`?0:e===`center`?t/2:t}_resolveKeywordY(e,t){return e===`top`?0:e===`center`?t/2:t}_resolveRadialRadii(e,t,n,r,i){if(e.kind===`explicit`){let n=this._resolve(e.x,r),a=e.y?this._resolve(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=Ra(n,r,i,`left`),o=Ra(n,r,i,`right`),s=Ra(n,r,i,`top`),c=Ra(n,r,i,`bottom`);if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>za(n,e));if(e.value===`closest-side`){let e=Math.min(a,o,s,c);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(a,o,s,c);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.min(...t);return{x:e,y:e}}let l=Math.max(...t);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Ba(n,r,i);return e.value===`closest-corner`?p.map(e=>Va(l,u,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y<n?t:e}):p.map(e=>Va(d,f,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y>n?t:e})}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}};let Ua=E(`rgb`),Wa=1024;function Ga(e){let t=Ua(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[Math.round((t.r??0)*255),Math.round((t.g??0)*255),Math.round((t.b??0)*255),Math.round((t.alpha??1)*255)]}function Ka(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function qa(e,t){if(e.length===0)throw Error(`Cannot sample color from empty diamond gradient stops.`);if(e.length===1||t<=e[0].position)return Ga(e[0].value);let n=e[e.length-1];if(t>=n.position)return Ga(n.value);for(let n=0;n<e.length-1;n+=1){let r=e[n],i=e[n+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e,a=Ga(r.value),o=Ga(i.value);return[Math.round(a[0]+(o[0]-a[0])*n),Math.round(a[1]+(o[1]-a[1])*n),Math.round(a[2]+(o[2]-a[2])*n),Math.round(a[3]+(o[3]-a[3])*n)]}}return Ga(n.value)}function Ja(e,t){let n=new Uint8ClampedArray(Wa*4);for(let r=0;r<Wa;r+=1){let i=qa(e,r/(Wa-1)*t),a=r*4;n[a]=i[0],n[a+1]=i[1],n[a+2]=i[2],n[a+3]=i[3]}return n}function Ya(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}function Xa(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function Za(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Qa(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}var $a=class{target=`canvas-2d`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Di))throw Error(`Expected DiamondGradient`);let t=e;return{draw:(e,n,r)=>{let i=this._resolveCenter(t.config.position,n,r),a=this._resolveDiamondRadii(t.config.size,t.config.shape,i,n,r),o=Ya(i,a,n,r),s=Y(t,128),c=Ja(Ka(t.isRepeating?Li(s,0,o):s),o),l=e.createImageData(n,r),u=l.data;for(let e=0;e<r;e+=1)for(let t=0;t<n;t+=1){let r=Math.abs(t-i.x)/Math.max(a.x,1e-4)+Math.abs(e-i.y)/Math.max(a.y,1e-4),s=Math.min(Wa-1,Math.max(0,Math.round(r/Math.max(o,1e-4)*(Wa-1))))*4,l=(e*n+t)*4;u[l]=c[s],u[l+1]=c[s+1],u[l+2]=c[s+2],u[l+3]=c[s+3]}e.putImageData(l,0,0)}}}_resolveCenter(e,t,n){return e.kind===`keywords`?{x:this._resolveKeywordX(e.x,t),y:this._resolveKeywordY(e.y,n)}:{x:this._resolve(e.x,t),y:this._resolve(e.y,n)}}_resolveKeywordX(e,t){return e===`left`?0:e===`center`?t/2:t}_resolveKeywordY(e,t){return e===`top`?0:e===`center`?t/2:t}_resolveDiamondRadii(e,t,n,r,i){if(e.kind===`explicit`){let n=this._resolve(e.x,r),a=e.y?this._resolve(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=n.x,o=r-n.x,s=n.y,c=i-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>Xa(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let l=Math.max(Math.max(...t),1e-4);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Za(n,r,i);return e.value===`closest-corner`?p.map(e=>Qa(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):p.map(e=>Qa(d,f,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}_resolve(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for Canvas transformer: ${e.unit}`)}};let eo=E(`rgb`);var to=class{target=`canvas-2d`;gradientType=`conic-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.createImageData(n,r),a=i.data,{x:o,y:s}=this._resolvePosition(t.config.position,n,r),c=this._toRad(t.config.from),l=Y(t,128),u=this._normalizeStops(l);if(u.length===0){e.putImageData(i,0,0);return}for(let e=0;e<r;e++)for(let t=0;t<n;t++){let r=t-o,i=e-s,l=Math.atan2(i,r)+Math.PI/2-c;for(;l<0;)l+=Math.PI*2;for(;l>=Math.PI*2;)l-=Math.PI*2;let d=l/(Math.PI*2),f=this._sampleColor(u,d),p=(e*n+t)*4;a[p]=f.r,a[p+1]=f.g,a[p+2]=f.b,a[p+3]=f.a}e.putImageData(i,0,0)}}}_resolvePosition(e,t,n){return e.kind===`keywords`?{x:this._resolveKeywordX(e.x,t),y:this._resolveKeywordY(e.y,n)}:{x:this._resolve(e.x,t),y:this._resolve(e.y,n)}}_resolve(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}_resolveKeywordX(e,t){return e===`left`?0:e===`right`?t:t/2}_resolveKeywordY(e,t){return e===`top`?0:e===`bottom`?t:t/2}_toRad(e){return e.unit===`deg`?d(e.value):e.unit===`turn`?p(e.value):e.unit===`grad`?m(e.value):e.value}_normalizeStops(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({position:this._clamp01(e.position),color:this._parseColor(e.value)})).sort((e,t)=>e.position-t.position)}_sampleColor(e,t){if(e.length===1)return e[0].color;let n=e[0],r=[...e,{...n,position:n.position+1}],i=t;i<n.position&&(i+=1);for(let e=0;e<r.length-1;e++){let t=r[e],n=r[e+1];if(i>=t.position&&i<=n.position){let e=n.position-t.position||1,r=(i-t.position)/e;return this._mixColor(t.color,n.color,r)}}return e[e.length-1].color}_mixColor(e,t,n){return{r:Math.round(e.r+(t.r-e.r)*n),g:Math.round(e.g+(t.g-e.g)*n),b:Math.round(e.b+(t.b-e.b)*n),a:Math.round(e.a+(t.a-e.a)*n)}}_parseColor(e){let t=eo(e);if(!t)throw Error(`Failed to convert color: ${e}`);return{r:Math.round((t.r??0)*255),g:Math.round((t.g??0)*255),b:Math.round((t.b??0)*255),a:Math.round((t.alpha??1)*255)}}_clamp01(e){return Math.max(0,Math.min(1,e))}};function no(e,t,n,r,i){let a=(r.y-i.y)*(n.x-i.x)+(i.x-r.x)*(n.y-i.y);if(Math.abs(a)<1e-6)return null;let o=((r.y-i.y)*(e-i.x)+(i.x-r.x)*(t-i.y))/a,s=((i.y-n.y)*(e-i.x)+(n.x-i.x)*(t-i.y))/a,c=1-o-s,l=-1e-4;return o<l||s<l||c<l?null:[o,s,c]}function ro(e,t,n,r){let[i,a,o]=e;return[Math.round((t.color[0]*i+n.color[0]*a+r.color[0]*o)*255),Math.round((t.color[1]*i+n.color[1]*a+r.color[1]*o)*255),Math.round((t.color[2]*i+n.color[2]*a+r.color[2]*o)*255),Math.round((t.color[3]*i+n.color[3]*a+r.color[3]*o)*255)]}function io(e,t,n,r,i,a){let o=Math.max(0,Math.floor(Math.min(r.x,i.x,a.x))),s=Math.min(t-1,Math.ceil(Math.max(r.x,i.x,a.x))),c=Math.max(0,Math.floor(Math.min(r.y,i.y,a.y))),l=Math.min(n-1,Math.ceil(Math.max(r.y,i.y,a.y)));for(let n=c;n<=l;n+=1)for(let c=o;c<=s;c+=1){let o=no(c+.5,n+.5,r,i,a);if(!o)continue;let s=ro(o,r,i,a),l=(n*t+c)*4;e[l]=s[0],e[l+1]=s[1],e[l+2]=s[2],e[l+3]=s[3]}}var ao=class{target=`canvas-2d`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected MeshGradient`);let t=e;return{draw:(e,n,r)=>{let i=e.createImageData(n,r),a=Xi(t,n,r),o=Zi(t,a),s=t.config.method===`bicubic`?24:1,c=ca(t,o,n,r,s);for(let e of t.patches){let c=sa(t,o,e,a,s);for(let[e,t,a]of c)io(i.data,n,r,e,t,a)}for(let[e,t,a]of c)io(i.data,n,r,e,t,a);e.putImageData(i,0,0)}}}};let oo=E(`rgb`);function so(e){let t=oo(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function co(e){let t=e.filter(e=>e.type===`color-stop`&&e.position!=null);return t.length?{min:Math.min(...t.map(e=>e.position)),max:Math.max(...t.map(e=>e.position)),stops:t}:{min:0,max:1,stops:[]}}function lo(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}function uo(e,t,n){let r=e.createShader(t);if(!r)throw Error(`Failed to create WebGL shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebGL shader compile error: ${t}`)}return r}function fo(e,t,n){let r=uo(e,e.VERTEX_SHADER,t),i=uo(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw Error(`Failed to create WebGL program.`);if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let t=e.getProgramInfoLog(a);throw e.deleteProgram(a),Error(`WebGL program link error: ${t}`)}return a}function po(e){return e.filter(e=>e.type===`color-stop`).length}function mo(e,t){let n=po(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function ho(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return K(J([r.value,i.value],`rgb`)(n))}}return r.value}function go(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length<=t)return n;let r=[];for(let e=0;e<t;e+=1){let i=e/(t-1);r.push({type:`color-stop`,value:ho(n,i),position:i})}return r}var _o=class{target=`canvas-webgl`;gradientType=`linear-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.getContext(`webgl`);if(!i)throw Error(`WebGL is not supported.`);e.width=n,e.height=r,i.viewport(0,0,n,r);let a=fo(i,`
|
|
5
5
|
attribute vec2 a_position;
|
|
6
6
|
varying vec2 v_uv;
|
|
7
7
|
|
|
@@ -57,7 +57,7 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
57
57
|
|
|
58
58
|
gl_FragColor = getGradientColor(t);
|
|
59
59
|
}
|
|
60
|
-
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=t.config.angle,l=Math.sin(c),u=-Math.cos(c),d=n/2,f=r/2,p=Math.abs(n*l)+Math.abs(r*u),m=d-l*p/2,h=f-u*p/2,g=d+l*p/2,_=f+u*p/2,{min:v,max:y,stops:b}=
|
|
60
|
+
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=t.config.angle,l=Math.sin(c),u=-Math.cos(c),d=n/2,f=r/2,p=Math.abs(n*l)+Math.abs(r*u),m=d-l*p/2,h=f-u*p/2,g=d+l*p/2,_=f+u*p/2,{min:v,max:y,stops:b}=co(Y(t,mo(t,128))),x=b;if(v<0||y>1){let e=g-m,t=_-h,n=m,r=h;m=n+e*v,h=r+t*v,g=n+e*y,_=r+t*y,x=lo(b,v,y)}let S=m/n,C=1-h/r,ee=g/n,te=1-_/r,ne=go(x,128),w=new Float32Array(128),T=new Float32Array(512);ne.forEach((e,t)=>{let n=so(e.value);w[t]=e.position,T[t*4+0]=n[0],T[t*4+1]=n[1],T[t*4+2]=n[2],T[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_start`),S,C),i.uniform2f(i.getUniformLocation(a,`u_end`),ee,te),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),ne.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),w),i.uniform4fv(i.getUniformLocation(a,`u_colors`),T),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}};let vo=E(`rgb`),yo=Math.PI*2;function bo(e){let t=vo(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function xo(e,t,n){let r=e.createShader(t);if(!r)throw Error(`Failed to create WebGL shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebGL shader compile error: ${t}`)}return r}function So(e,t,n){let r=xo(e,e.VERTEX_SHADER,t),i=xo(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw Error(`Failed to create WebGL program.`);if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let t=e.getProgramInfoLog(a);throw e.deleteProgram(a),Error(`WebGL program link error: ${t}`)}return a}function Co(e){return e.filter(e=>e.type===`color-stop`).length}function wo(e,t){let n=Co(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function To(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return K(J([r.value,i.value],`rgb`)(n))}}return r.value}function Eo(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length<=t)return n;let r=[];for(let e=0;e<t;e+=1){let i=e/(t-1);r.push({type:`color-stop`,value:To(n,i),position:i})}return r}function Do(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.kind===`length`){if(e.unit===`px`)return e.value;throw Error(`Unsupported gradient length unit for WebGL conic gradient: ${e.unit}`)}return e}function Oo(e){return e.unit===`rad`?e.value:e.unit===`deg`?e.value/360*yo:e.unit===`turn`?e.value*yo:e.unit===`grad`?e.value/400*yo:e.unit}function ko(e,t){return e===`left`?0:e===`center`?t/2:e===`right`?t:t/2}function Ao(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:t/2}function jo(e,t,n){return e.kind===`keywords`?{x:ko(e.x,t),y:Ao(e.y,n)}:e.kind===`values`?{x:Do(e.x,t),y:Do(e.y,n)}:{x:t/2,y:n/2}}var Mo=class{target=`canvas-webgl`;gradientType=`conic-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.getContext(`webgl`);if(!i)throw Error(`WebGL is not supported.`);e.width=n,e.height=r,i.viewport(0,0,n,r);let a=So(i,`
|
|
61
61
|
attribute vec2 a_position;
|
|
62
62
|
varying vec2 v_uv;
|
|
63
63
|
|
|
@@ -115,7 +115,7 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
115
115
|
|
|
116
116
|
gl_FragColor = getGradientColor(t);
|
|
117
117
|
}
|
|
118
|
-
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=
|
|
118
|
+
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=jo(t.config.position,n,r),l=Eo(Y(t,wo(t,128)),128),u=new Float32Array(128),d=new Float32Array(512);l.forEach((e,t)=>{let n=bo(e.value);u[t]=e.position,d[t*4+0]=n[0],d[t*4+1]=n[1],d[t*4+2]=n[2],d[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_center`),c.x/n,1-c.y/r),i.uniform1f(i.getUniformLocation(a,`u_startAngle`),Oo(t.config.from)),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),l.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),u),i.uniform4fv(i.getUniformLocation(a,`u_colors`),d),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}};let No=E(`rgb`);function Po(e){let t=No(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Fo(e,t,n){let r=e.createShader(t);if(!r)throw Error(`Failed to create WebGL shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebGL shader compile error: ${t}`)}return r}function Io(e,t,n){let r=Fo(e,e.VERTEX_SHADER,t),i=Fo(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw Error(`Failed to create WebGL program.`);if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let t=e.getProgramInfoLog(a);throw e.deleteProgram(a),Error(`WebGL program link error: ${t}`)}return a}function Lo(e){return e.filter(e=>e.type===`color-stop`).length}function Ro(e,t){let n=Lo(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function zo(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return K(J([r.value,i.value],`rgb`)(n))}}return r.value}function Bo(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length<=t)return n;let r=[];for(let e=0;e<t;e+=1){let i=e/(t-1);r.push({type:`color-stop`,value:zo(n,i),position:i})}return r}function Vo(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.kind===`length`){if(e.unit===`px`)return e.value;throw Error(`Unsupported gradient length unit for WebGL radial gradient: ${e.unit}`)}return e}function Ho(e,t){return e===`left`?0:e===`center`?t/2:e===`right`?t:t/2}function Uo(e,t){return e===`top`?0:e===`center`?t/2:e===`bottom`?t:t/2}function Wo(e,t,n){return e.kind===`keywords`?{x:Ho(e.x,t),y:Uo(e.y,n)}:e.kind===`values`?{x:Vo(e.x,t),y:Vo(e.y,n)}:{x:t/2,y:n/2}}function Go(e,t,n,r){return r===`left`?e.x:r===`right`?t-e.x:r===`top`?e.y:n-e.y}function Ko(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function qo(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}function Jo(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function Yo(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.sqrt(n*n/(i*i)+r*r/(a*a));return{x:i*o,y:a*o}}function Xo(e,t,n,r,i){if(e.kind===`explicit`){let n=Vo(e.x,r),a=e.y?Vo(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=Go(n,r,i,`left`),o=Go(n,r,i,`right`),s=Go(n,r,i,`top`),c=Go(n,r,i,`bottom`);if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>Ko(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let l=Math.max(Math.max(...t),1e-4);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=Jo(n,r,i);return e.value===`closest-corner`?p.map(e=>Yo(l,u,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y<n?t:e}):p.map(e=>Yo(d,f,e.dx,e.dy)).reduce((e,t)=>{let n=e.x*e.y;return t.x*t.y>n?t:e})}var Zo=class{target=`canvas-webgl`;gradientType=`radial-gradient`;to(e){let t=e;return{draw:(e,n,r)=>{let i=e.getContext(`webgl`);if(!i)throw Error(`WebGL is not supported.`);e.width=n,e.height=r,i.viewport(0,0,n,r);let a=Io(i,`
|
|
119
119
|
attribute vec2 a_position;
|
|
120
120
|
varying vec2 v_uv;
|
|
121
121
|
|
|
@@ -171,4 +171,76 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
171
171
|
|
|
172
172
|
gl_FragColor = getGradientColor(t);
|
|
173
173
|
}
|
|
174
|
-
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=
|
|
174
|
+
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=Wo(t.config.position,n,r),l=Xo(t.config.size,t.config.shape,c,n,r),u=zi(c,l,n,r),d=Y(t,Ro(t,128)),f=Math.min(u,16),p=t.isRepeating?f:1,m=t.isRepeating?Li(d,0,f):d,h=Bo(t.isRepeating?qo(m,0,f):m,128),g=new Float32Array(128),_=new Float32Array(512);h.forEach((e,t)=>{let n=Po(e.value);g[t]=e.position,_[t*4+0]=n[0],_[t*4+1]=n[1],_[t*4+2]=n[2],_[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_center`),c.x/n,1-c.y/r),i.uniform2f(i.getUniformLocation(a,`u_radius`),l.x/n,l.y/r),i.uniform1f(i.getUniformLocation(a,`u_tMax`),p),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),h.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),g),i.uniform4fv(i.getUniformLocation(a,`u_colors`),_),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}};let Qo=E(`rgb`);function $o(e){let t=Qo(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function es(e,t,n){let r=e.createShader(t);if(!r)throw Error(`Failed to create WebGL shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebGL shader compile error: ${t}`)}return r}function ts(e,t,n){let r=es(e,e.VERTEX_SHADER,t),i=es(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw Error(`Failed to create WebGL program.`);if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let t=e.getProgramInfoLog(a);throw e.deleteProgram(a),Error(`WebGL program link error: ${t}`)}return a}function ns(e){return e.filter(e=>e.type===`color-stop`).length}function rs(e,t){let n=ns(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function is(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length===0)throw Error(`Cannot sample color from empty diamond gradient stops.`);if(t<=n[0].position)return n[0].value;let r=n[n.length-1];if(t>=r.position)return r.value;for(let e=0;e<n.length-1;e+=1){let r=n[e],i=n[e+1];if(t>=r.position&&t<=i.position){let e=i.position-r.position||1,n=(t-r.position)/e;return K(J([r.value,i.value],`rgb`)(n))}}return r.value}function as(e,t){let n=e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position);if(n.length<=t)return n;let r=[];for(let e=0;e<t;e+=1){let i=e/(t-1);r.push({type:`color-stop`,value:is(n,i),position:i})}return r}function os(e,t,n){let r=n-t||1;return e.filter(e=>e.type===`color-stop`&&e.position!=null).map(e=>({...e,position:(e.position-t)/r}))}function ss(e,t){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for WebGL transformer: ${e.unit}`)}function cs(e,t){return e===`left`?0:e===`right`?t:t/2}function ls(e,t){return e===`top`?0:e===`bottom`?t:t/2}function us(e,t,n){return e.kind===`keywords`?{x:cs(e.x,t),y:ls(e.y,n)}:{x:ss(e.x,t),y:ss(e.y,n)}}function ds(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function fs(e,t,n){return[{dx:-e.x,dy:-e.y},{dx:t-e.x,dy:-e.y},{dx:-e.x,dy:n-e.y},{dx:t-e.x,dy:n-e.y}]}function ps(e,t,n,r){let i=Math.max(e,1e-4),a=Math.max(t,1e-4),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}function ms(e,t,n,r,i){if(e.kind===`explicit`){let n=ss(e.x,r),a=e.y?ss(e.y,i):n;return{x:Math.max(n,1e-4),y:Math.max(t===`circle`?n:a,1e-4)}}let a=n.x,o=r-n.x,s=n.y,c=i-n.y;if(t===`circle`){let t=[{x:0,y:0},{x:r,y:0},{x:0,y:i},{x:r,y:i}].map(e=>ds(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(a,o,s,c),1e-4);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),1e-4);return{x:e,y:e}}let l=Math.max(Math.max(...t),1e-4);return{x:l,y:l}}let l=Math.min(a,o),u=Math.min(s,c),d=Math.max(a,o),f=Math.max(s,c);if(e.value===`closest-side`)return{x:Math.max(l,1e-4),y:Math.max(u,1e-4)};if(e.value===`farthest-side`)return{x:Math.max(d,1e-4),y:Math.max(f,1e-4)};let p=fs(n,r,i);return e.value===`closest-corner`?p.map(e=>ps(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):p.map(e=>ps(d,f,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function hs(e,t,n,r){return Math.max(...[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}].map(n=>Math.abs(n.x-e.x)/Math.max(t.x,1e-4)+Math.abs(n.y-e.y)/Math.max(t.y,1e-4)))}var gs=class{target=`canvas-webgl`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Di))throw Error(`Expected DiamondGradient`);let t=e;return{draw:(e,n,r)=>{let i=e.getContext(`webgl`);if(!i)throw Error(`WebGL is not supported.`);e.width=n,e.height=r,i.viewport(0,0,n,r);let a=ts(i,`
|
|
175
|
+
attribute vec2 a_position;
|
|
176
|
+
varying vec2 v_uv;
|
|
177
|
+
|
|
178
|
+
void main() {
|
|
179
|
+
v_uv = a_position * 0.5 + 0.5;
|
|
180
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
181
|
+
}
|
|
182
|
+
`,`
|
|
183
|
+
precision mediump float;
|
|
184
|
+
|
|
185
|
+
varying vec2 v_uv;
|
|
186
|
+
|
|
187
|
+
uniform vec2 u_center;
|
|
188
|
+
uniform vec2 u_radius;
|
|
189
|
+
uniform int u_stopCount;
|
|
190
|
+
uniform float u_positions[128];
|
|
191
|
+
uniform vec4 u_colors[128];
|
|
192
|
+
uniform float u_tMax;
|
|
193
|
+
|
|
194
|
+
vec4 getGradientColor(float t) {
|
|
195
|
+
vec4 result = u_colors[0];
|
|
196
|
+
|
|
197
|
+
for (int i = 0; i < 127; i++) {
|
|
198
|
+
if (i >= u_stopCount - 1) {
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
float currentPosition = u_positions[i];
|
|
203
|
+
float nextPosition = u_positions[i + 1];
|
|
204
|
+
|
|
205
|
+
if (t <= currentPosition) {
|
|
206
|
+
return u_colors[i];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (t >= currentPosition && t <= nextPosition) {
|
|
210
|
+
float localT = (t - currentPosition) / max(nextPosition - currentPosition, 0.00001);
|
|
211
|
+
return mix(u_colors[i], u_colors[i + 1], localT);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
result = u_colors[i + 1];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
void main() {
|
|
221
|
+
vec2 delta = v_uv - u_center;
|
|
222
|
+
vec2 normalized = abs(delta) / max(u_radius, vec2(0.00001));
|
|
223
|
+
float t = normalized.x + normalized.y;
|
|
224
|
+
|
|
225
|
+
t = clamp(t, 0.0, u_tMax);
|
|
226
|
+
t = t / max(u_tMax, 0.00001);
|
|
227
|
+
|
|
228
|
+
gl_FragColor = getGradientColor(t);
|
|
229
|
+
}
|
|
230
|
+
`);i.useProgram(a);let o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),i.STATIC_DRAW);let s=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(s),i.vertexAttribPointer(s,2,i.FLOAT,!1,0,0);let c=us(t.config.position,n,r),l=ms(t.config.size,t.config.shape,c,n,r),u=hs(c,l,n,r),d=Y(t,rs(t,128)),f=Math.min(u,16),p=t.isRepeating?f:1,m=t.isRepeating?Li(d,0,f):d,h=as(t.isRepeating?os(m,0,f):m,128),g=new Float32Array(128),_=new Float32Array(512);h.forEach((e,t)=>{let n=$o(e.value);g[t]=e.position,_[t*4+0]=n[0],_[t*4+1]=n[1],_[t*4+2]=n[2],_[t*4+3]=n[3]}),i.uniform2f(i.getUniformLocation(a,`u_center`),c.x/n,1-c.y/r),i.uniform2f(i.getUniformLocation(a,`u_radius`),l.x/n,l.y/r),i.uniform1f(i.getUniformLocation(a,`u_tMax`),p),i.uniform1i(i.getUniformLocation(a,`u_stopCount`),h.length),i.uniform1fv(i.getUniformLocation(a,`u_positions`),g),i.uniform4fv(i.getUniformLocation(a,`u_colors`),_),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,6)}}}};function _s(e,t,n){let r=e.createShader(t);if(!r)throw Error(`Failed to create WebGL shader.`);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){let t=e.getShaderInfoLog(r);throw e.deleteShader(r),Error(`WebGL shader compile error: ${t}`)}return r}function vs(e,t,n){let r=_s(e,e.VERTEX_SHADER,t),i=_s(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(!a)throw Error(`Failed to create WebGL program.`);if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS)){let t=e.getProgramInfoLog(a);throw e.deleteProgram(a),Error(`WebGL program link error: ${t}`)}return a}function ys(e,t){return e/t*2-1}function bs(e,t){return 1-e/t*2}var xs=class{target=`canvas-webgl`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected MeshGradient`);let t=e;return{draw:(e,n,r)=>{let i=e.getContext(`webgl`);if(!i)throw Error(`WebGL is not supported.`);e.width=n,e.height=r,i.viewport(0,0,n,r);let a=vs(i,`
|
|
231
|
+
attribute vec2 a_position;
|
|
232
|
+
attribute vec4 a_color;
|
|
233
|
+
varying vec4 v_color;
|
|
234
|
+
|
|
235
|
+
void main() {
|
|
236
|
+
v_color = a_color;
|
|
237
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
238
|
+
}
|
|
239
|
+
`,`
|
|
240
|
+
precision mediump float;
|
|
241
|
+
varying vec4 v_color;
|
|
242
|
+
|
|
243
|
+
void main() {
|
|
244
|
+
gl_FragColor = v_color;
|
|
245
|
+
}
|
|
246
|
+
`),o=Xi(t,n,r),s=Zi(t,o),c=t.config.method===`bicubic`?24:1,l=ca(t,s,n,r,c),u=[],d=[];for(let e of t.patches){let i=sa(t,s,e,o,c);for(let e of i)for(let t of e)u.push(ys(t.x,n),bs(t.y,r)),d.push(...t.color)}for(let e of l)for(let t of e)u.push(ys(t.x,n),bs(t.y,r)),d.push(...t.color);let f=i.createBuffer(),p=i.createBuffer();i.useProgram(a),i.bindBuffer(i.ARRAY_BUFFER,f),i.bufferData(i.ARRAY_BUFFER,new Float32Array(u),i.STATIC_DRAW);let m=i.getAttribLocation(a,`a_position`);i.enableVertexAttribArray(m),i.vertexAttribPointer(m,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,p),i.bufferData(i.ARRAY_BUFFER,new Float32Array(d),i.STATIC_DRAW);let h=i.getAttribLocation(a,`a_color`);i.enableVertexAttribArray(h),i.vertexAttribPointer(h,4,i.FLOAT,!1,0,0),i.clearColor(0,0,0,0),i.clear(i.COLOR_BUFFER_BIT),i.drawArrays(i.TRIANGLES,0,u.length/2)}}}},Ss=class{static _modules=new Map;static _initialized=!1;static add(e){this._ensureInitialized(),this._modules.set(this._getKey(e.target,e.gradientType),e)}static get(e,t){return this._ensureInitialized(),this._modules.get(this._getKey(e,t))??null}static remove(e,t){return this._ensureInitialized(),this._modules.delete(this._getKey(e,t))}static to(e,t){let n=typeof t==`string`?Cs.create(t):t,r=this.get(e,n.type);if(!r)throw Error(`No transformer registered for target "${e}" and gradient "${n.type}"`);return r.to(n)}static from(e,t,n){let r=this.get(e,t);if(!r||!r.from)throw Error(`No reverse transformer registered for target "${e}" and gradient "${t}"`);return r.from(n)}static _ensureInitialized(){this._initialized||(this._initialized=!0,this.add(new Mi),this.add(new Ni),this.add(new Sa),this.add(new Ca),this.add(new Oa),this.add(new Na),this.add(new Ha),this.add(new $a),this.add(new to),this.add(new ao),this.add(new _o),this.add(new Zo),this.add(new gs),this.add(new Mo),this.add(new xs))}static _getKey(e,t){return`${e}:${t}`}},Cs=class{static _registry=new Map;static _initialized=!1;static add(e,t){this._ensureInitialized(),this._registry.set(e,t)}static get(e){return this._ensureInitialized(),this._registry.get(e)??null}static remove(e){return this._registry.delete(e)}static create(e){if(typeof e==`string`){let t=this._getFunctionName(e),n=this.get(t);if(!n)throw Error(`No gradient registered for: ${t}`);return n.fromString(e)}let t=e,n=this.get(t.functionName);if(!n)throw Error(`No gradient registered for: ${t.functionName}`);return n.fromAbi(t)}static isValid(e){try{return this.create(e),!0}catch{return!1}}static _ensureInitialized(){this._initialized||(this._initialized=!0,this.add(`linear-gradient`,Ti),this.add(`radial-gradient`,Ei),this.add(`diamond-gradient`,Di),this.add(`conic-gradient`,Oi),this.add(`mesh-gradient`,ji))}static _getFunctionName(e){let t=e.trim(),n=t.indexOf(`(`);if(n<=0)throw Error(`Expected function opening parenthesis`);let r=t.slice(0,n).trim();return r.startsWith(`repeating-`)&&(r=r.slice(10)),r}};function ws(e){return Cs.create(e)}function Ts(e){return Cs.isValid(e)}function Es(e){return typeof e==`string`?ws(e).toString():e.toString()}function Ds(e,t){let n=typeof t==`string`?ws(t):t;return Ss.to(e,n)}function Os(e,t,n){return Ss.from(e,t,n)}return e.ConicGradient=Oi,e.DiamondGradient=Di,e.GRADIENT_COLOR_SPACE=vi,e.GRADIENT_HUE_INTERPOLATIONS=yi,e.GRADIENT_POLAR_COLOR_SPACES=bi,e.GradientBase=wi,e.GradientFactory=Cs,e.GradientTransformer=Ss,e.LinearGradient=Ti,e.MeshGradient=ji,e.ModuleTransformerConicGradientToCanvas=to,e.ModuleTransformerConicGradientToCanvasWebGL=Mo,e.ModuleTransformerConicGradientToCss=Ca,e.ModuleTransformerDiamondGradientToCanvas=$a,e.ModuleTransformerDiamondGradientToCanvasWebGL=gs,e.ModuleTransformerDiamondGradientToCss=Sa,e.ModuleTransformerLinearGradientToCanvas=Na,e.ModuleTransformerLinearGradientToCanvasWebGL=_o,e.ModuleTransformerLinearGradientToCss=Mi,e.ModuleTransformerMeshGradientToCanvas=ao,e.ModuleTransformerMeshGradientToCanvasWebGL=xs,e.ModuleTransformerMeshGradientToCss=Oa,e.ModuleTransformerRadialGradientToCanvas=Ha,e.ModuleTransformerRadialGradientToCanvasWebGL=Zo,e.ModuleTransformerRadialGradientToCss=Ni,e.PatternTokenKind=Hr,e.RadialGradient=Ei,e.angleValueFromString=u,e.ceilTo=r,e.clamp=a,e.degToRad=d,e.floorTo=n,e.format=Es,e.fromPercent=s,e.gradToRad=m,e.isAngle=l,e.isAngleUnit=c,e.isColorHint=li,e.isColorStop=ui,e.isConfig=di,e.isGradient=Ts,e.isGradientColorSpace=Si,e.isGradientHueInterpolation=xi,e.isGradientPolarColorSpace=Ci,e.isPatternSyntaxValid=ti,e.isPatternValid=$r,e.isValid=oi,e.matchExpression=Ur,e.normalizeAngleDeg=h,e.normalizeAngleRad=g,e.parse=ws,e.parseStringToAbi=ci,e.radToDeg=f,e.roundTo=t,e.splitTopLevelByWhitespace=_i,e.toPercent=o,e.tokenizePattern=ai,e.transformFrom=Os,e.transformTo=Ds,e.truncTo=i,e.turnToRad=p,e.validate=si,e.validatePattern=Qr,e.validatePatternSemantic=ri,e.validatePatternStructure=ii,e.validatePatternSyntax=ei,e})({});
|