gradiente 2.5.0 → 3.0.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 +70 -176
- package/dist/index.d.ts +824 -398
- package/dist/index.js +2870 -3404
- package/package.json +1 -1
|
@@ -1,50 +1,59 @@
|
|
|
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
|
|
2
|
-
`||r===` `||r===` `){for(;
|
|
3
|
-
`||t[
|
|
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},ke={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}},Ae=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),je=e=>{let t=Ae(e.r),n=Ae(e.g),r=Ae(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},Me=e=>Math.abs(e)**(256/563)*Math.sign(e),Ne=({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:Me(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:Me(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:Me(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Pe=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},Fe=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Pe(e),g:Pe(t),b:Pe(n)};return r!==void 0&&(i.alpha=r),i},P=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(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},Ie=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},Le=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:Ie(e),g:Ie(t),b:Ie(n)};return r!==void 0&&(a.alpha=r),a},Re=({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=Le({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},ze={...ke,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>Ne(P(e)),xyz65:Ne},toMode:{rgb:e=>Re(je(e)),xyz65:je}},F=e=>(e%=360)<0?e+360:e,Be=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=F(n);return r===0||e[r-1]===void 0?a:t(a-F(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),[]),I=e=>Be(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),Ve=e=>Be(e,e=>Math.abs(e)>=180||e===0?e:e-360*Math.sign(e)),He=e=>Be(e,e=>e>=0?e:e+360),Ue=e=>Be(e,e=>e<=0?e:e-360),L=[-.14861,1.78277,-.29227,-.90649,1.97294,0],We=Math.PI/180,Ge=180/Math.PI,Ke=L[3]*L[4],qe=L[1]*L[4],Je=L[1]*L[2]-L[0]*L[3],Ye=({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=(Je*n+e*Ke-t*qe)/(Je+Ke-qe),a=n-i,o=(L[4]*(t-i)-L[2]*a)/L[3],s={mode:`cubehelix`,l:i,s:i===0||i===1?void 0:Math.sqrt(a*a+o*o)/(L[4]*i*(1-i))};return s.s&&(s.h=Math.atan2(o,a)*Ge-120),r!==void 0&&(s.alpha=r),s},Xe=({h:e,s:t,l:n,alpha:r})=>{let i={mode:`rgb`};e=(e===void 0?0:e+120)*We,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*(L[0]*o+L[1]*s),i.g=n+a*(L[2]*o+L[3]*s),i.b=n+a*(L[4]*o+L[5]*s),r!==void 0&&(i.alpha=r),i},Ze=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=F(e.h),r=F(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},Qe=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=F(e.h),r=F(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},$e=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=F(e.h),r=F(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},R=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},et={mode:`cubehelix`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--cubehelix`],serialize:`--cubehelix`,ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:Ye},toMode:{rgb:Xe},interpolate:{h:{use:M,fixup:I},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}},z=({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=F(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},B=({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},tt=29**3/3**3,nt=6**3/29**3,V={X:.3457/.3585,Y:1,Z:.2958/.3585},rt={X:.3127/.329,Y:1,Z:.3583/.329},it=e=>e**3>nt?e**3:(116*e-16)/tt,at=({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:it(a)*rt.X,y:it(i)*rt.Y,z:it(o)*rt.Z};return r!==void 0&&(s.alpha=r),s},ot=e=>Re(at(e)),st=e=>e>nt?Math.cbrt(e):(tt*e+16)/116,ct=({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=st(e/rt.X),a=st(t/rt.Y),o=st(n/rt.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},lt=e=>{let t=ct(P(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},ut=26/180*Math.PI,dt=Math.cos(ut),ft=Math.sin(ut),pt=100/Math.log(139/100),mt=({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/pt)-1)/.0039},a=(Math.exp(.0435*t*1*1)-1)/.075,o=a*Math.cos(n/180*Math.PI-ut),s=a*Math.sin(n/180*Math.PI-ut);return i.a=o*dt-s/.83*ft,i.b=o*ft+s/.83*dt,r!==void 0&&(i.alpha=r),i},ht=({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*dt+n*ft,a=.83*(n*dt-t*ft),o=Math.sqrt(i*i+a*a),s={mode:`dlch`,l:pt/1*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*1*1)};return s.c&&(s.h=F((Math.atan2(a,i)+ut)/Math.PI*180)),r!==void 0&&(s.alpha=r),s},gt=e=>mt(z(e,`dlch`)),_t=e=>B(ht(e),`dlab`),vt={mode:`dlab`,parse:[`--din99o-lab`],serialize:`--din99o-lab`,toMode:{lab65:gt,rgb:e=>ot(gt(e))},fromMode:{lab65:_t,rgb:e=>_t(lt(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}}},yt={mode:`dlch`,parse:[`--din99o-lch`],serialize:`--din99o-lch`,toMode:{lab65:mt,dlab:e=>B(e,`dlab`),rgb:e=>ot(mt(e))},fromMode:{lab65:ht,dlab:e=>z(e,`dlch`),rgb:e=>ht(lt(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:I},alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}};function bt({h:e,s:t,i:n,alpha:r}){e=F(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 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:`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 St={mode:`hsi`,toMode:{rgb:bt},parse:[`--hsi`],serialize:`--hsi`,fromMode:{rgb:xt},channels:[`h`,`s`,`i`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:I},s:M,i:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}};function Ct({h:e,s:t,l:n,alpha:r}){e=F(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 wt({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 Tt=(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}},Et=RegExp(`^hsla?\\(\\s*${ne}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),Dt=e=>{let t=e.match(Et);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=Tt(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 Ot(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 kt={mode:`hsl`,toMode:{rgb:Ct},fromMode:{rgb:wt},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Ot,Dt],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:I},s:M,l:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}};function At({h:e,s:t,v:n,alpha:r}){e=F(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 jt({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 Mt={mode:`hsv`,toMode:{rgb:At},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:jt},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:M,fixup:I},s:M,v:M,alpha:{use:M,fixup:N}},difference:{h:Ze},average:{h:R}};function Nt({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 At({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function Pt(e){let t=jt(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 Ft(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 It={mode:`hwb`,toMode:{rgb:Nt},fromMode:{rgb:Pt},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Ft],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:I},w:M,b:M,alpha:{use:M,fixup:N}},difference:{h:Qe},average:{h:R}},Lt=.1593017578125,Rt=78.84375,zt=.8359375,Bt=18.8515625,Vt=18.6875;function Ht(e){if(e<0)return 0;let t=e**(1/Rt);return 1e4*(Math.max(0,t-zt)/(Bt-Vt*t))**(1/Lt)}function Ut(e){if(e<0)return 0;let t=(e/1e4)**Lt;return((zt+Bt*t)/(1+Vt*t))**+Rt}let Wt=e=>Math.max(e/203,0),Gt=({i:e,t,p:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Ht(e+.008609037037932761*t+.11102962500302593*n),a=Ht(e-.00860903703793275*t-.11102962500302599*n),o=Ht(e+.5600313357106791*t-.32062717498731885*n),s={mode:`xyz65`,x:Wt(2.070152218389422*i-1.3263473389671556*a+.2066510476294051*o),y:Wt(.3647385209748074*i+.680566024947227*a-.0453045459220346*o),z:Wt(-.049747207535812*i-.0492609666966138*a+1.1880659249923042*o)};return r!==void 0&&(s.alpha=r),s},Kt=(e=0)=>Math.max(e*203,0),qt=({x:e,y:t,z:n,alpha:r})=>{let i=Kt(e),a=Kt(t),o=Kt(n),s=Ut(.3592832590121217*i+.6976051147779502*a-.0358915932320289*o),c=Ut(-.1920808463704995*i+1.1004767970374323*a+.0753748658519118*o),l=Ut(.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},Jt={mode:`itp`,channels:[`i`,`t`,`p`,`alpha`],parse:[`--ictcp`],serialize:`--ictcp`,toMode:{xyz65:Gt,rgb:e=>Re(Gt(e))},fromMode:{xyz65:qt,rgb:e=>qt(P(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:M,t:M,p:M,alpha:{use:M,fixup:N}}},Yt=e=>{if(e<0)return 0;let t=(e/1e4)**Lt;return((zt+Bt*t)/(1+Vt*t))**134.03437499999998},Xt=(e=0)=>Math.max(e*203,0),Zt=({x:e,y:t,z:n,alpha:r})=>{e=Xt(e),t=Xt(t),n=Xt(n);let i=1.15*e-.15*n,a=.66*t+.34*e,o=Yt(.41478972*i+.579999*a+.014648*n),s=Yt(-.20151*i+1.120649*a+.0531008*n),c=Yt(-.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},Qt=16295499532821565e-27,$t=e=>{if(e<0)return 0;let t=e**(1/134.03437499999998);return 1e4*((zt-t)/(Vt*t-Bt))**(1/Lt)},en=e=>e/203,tn=({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+Qt)/(.44+.56*(e+Qt)),a=$t(i+.13860504*t+.058047316*n),o=$t(i-.13860504*t-.058047316*n),s=$t(i-.096019242*t-.8118919*n),c={mode:`xyz65`,x:en(1.661373024652174*a-.914523081304348*o+.23136208173913045*s),y:en(-.3250758611844533*a+1.571847026732543*o-.21825383453227928*s),z:en(-.090982811*a-.31272829*o+1.5227666*s)};return r!==void 0&&(c.alpha=r),c},nn=e=>{let t=Zt(P(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},rn=e=>Re(tn(e)),an={mode:`jab`,channels:[`j`,`a`,`b`,`alpha`],parse:[`--jzazbz`],serialize:`--jzazbz`,fromMode:{rgb:nn,xyz65:Zt},toMode:{rgb:rn,xyz65:tn},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:M,a:M,b:M,alpha:{use:M,fixup:N}}},on=({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=F(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},sn=({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},cn={mode:`jch`,parse:[`--jzczhz`],serialize:`--jzczhz`,toMode:{jab:sn,rgb:e=>rn(sn(e))},fromMode:{rgb:e=>on(nn(e)),jab:on},channels:[`j`,`c`,`h`,`alpha`],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:M,fixup:I},c:M,j:M,alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}},ln=29**3/3**3,un=6**3/29**3,dn=e=>e**3>un?e**3:(116*e-16)/ln,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+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz50`,x:dn(a)*V.X,y:dn(i)*V.Y,z:dn(o)*V.Z};return r!==void 0&&(s.alpha=r),s},pn=({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=Le({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},mn=e=>pn(fn(e)),hn=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(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},gn=e=>e>un?Math.cbrt(e):(ln*e+16)/116,_n=({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=gn(e/V.X),a=gn(t/V.Y),o=gn(n/V.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},vn=e=>{let t=_n(hn(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function yn(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 bn={mode:`lab`,toMode:{xyz50:fn,rgb:mn},fromMode:{xyz50:_n,rgb:vn},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[yn],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}}},xn={...bn,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:at,rgb:ot},fromMode:{xyz65:ct,rgb:lt},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function Sn(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 Cn={mode:`lch`,toMode:{lab:B,rgb:e=>mn(B(e))},fromMode:{rgb:e=>z(vn(e)),lab:z},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[Sn],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:I},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}},wn={...Cn,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>B(e,`lab65`),rgb:e=>ot(B(e,`lab65`))},fromMode:{rgb:e=>z(lt(e),`lch65`),lab65:e=>z(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Tn=({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=F(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},En=({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},Dn=(e,t,n)=>4*e/(e+15*t+3*n),On=(e,t,n)=>9*t/(e+15*t+3*n),kn=Dn(V.X,V.Y,V.Z),An=On(V.X,V.Y,V.Z),jn=e=>e<=un?ln*e:116*Math.cbrt(e)-16,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=jn(t/V.Y),a=Dn(e,t,n),o=On(e,t,n);!isFinite(a)||!isFinite(o)?i=a=o=0:(a=13*i*(a-kn),o=13*i*(o-An));let s={mode:`luv`,l:i,u:a,v:o};return r!==void 0&&(s.alpha=r),s},Nn=(e,t,n)=>4*e/(e+15*t+3*n),Pn=(e,t,n)=>9*t/(e+15*t+3*n),Fn=Nn(V.X,V.Y,V.Z),In=Pn(V.X,V.Y,V.Z),Ln=({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)+Fn,a=n/(13*e)+In,o=V.Y*(e<=8?e/ln:((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},Rn={mode:`lchuv`,toMode:{luv:En,rgb:e=>pn(Ln(En(e)))},fromMode:{rgb:e=>Tn(Mn(hn(e))),luv:Tn},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:I},c:M,l:M,alpha:{use:M,fixup:N}},difference:{h:$e},average:{h:R}},zn={...ke,mode:`lrgb`,toMode:{rgb:Le},fromMode:{rgb:Fe},parse:[`srgb-linear`],serialize:`srgb-linear`},Bn={mode:`luv`,toMode:{xyz50:Ln,rgb:e=>pn(Ln(e))},fromMode:{xyz50:Mn,rgb:e=>Mn(hn(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}}},Vn=({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},Hn=e=>{let t=Vn(Fe(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Un=({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},Wn=e=>Le(Un(e));function Gn(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 Kn(e){let t=.206,n=.03;return(1+t)/(1+n),(e*e+t*e)/(1.170873786407767*(e+n))}function qn(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 Jn(e,t){let n=qn(e,t),r=Un({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 Yn(e,t,n,r,i,a=null){a||=Jn(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 Xn(e,t,n=null){n||=Jn(e,t);let r=n[0],i=n[1];return[i/r,i/(1-r)]}function Zn(e,t,n){let r=Jn(t,n),i=Yn(t,n,e,1,e,r),a=Xn(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 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={mode:`okhsl`,l:Gn(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]=Zn(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=F(Math.atan2(r,n)*180/Math.PI)),i}function $n(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:Kn(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]=Zn(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 er={...kt,mode:`okhsl`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--okhsl`],serialize:`--okhsl`,fromMode:{oklab:Qn,rgb:e=>Qn(Hn(e))},toMode:{oklab:$n,rgb:e=>Wn($n(e))}};function tr(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]=Xn(a,o),l=.5,u=1-l/s,d=c/(i+t*c),f=d*t,p=d*i,m=Kn(f),h=p*m/f,g=Un({l:m,a:a*h,b:o*h}),_=Math.cbrt(1/Math.max(g.r,g.g,g.b,0));t/=_,i=i/_*Gn(t)/t,t=Gn(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=F(Math.atan2(r,n)*180/Math.PI)),e.alpha!==void 0&&(v.alpha=e.alpha),v}function nr(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]=Xn(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=Kn(d),m=f*p/d,h=Un({l:p,a:a*m,b:o*m}),g=Math.cbrt(1/Math.max(h.r,h.g,h.b,0)),_=Kn(i*d),v=f*_/d;return t.l=_*g,t.a=v*a*g,t.b=v*o*g,t}let rr={...Mt,mode:`okhsv`,channels:[`h`,`s`,`v`,`alpha`],parse:[`--okhsv`],serialize:`--okhsv`,fromMode:{oklab:tr,rgb:e=>tr(Hn(e))},toMode:{oklab:nr,rgb:e=>Wn(nr(e))}};function ir(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 ar={...bn,mode:`oklab`,toMode:{lrgb:Un,rgb:Wn},fromMode:{lrgb:Vn,rgb:Hn},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[ir],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 or(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 sr={...Cn,mode:`oklch`,toMode:{oklab:e=>B(e,`oklab`),rgb:e=>Wn(B(e,`oklab`))},fromMode:{rgb:e=>z(Hn(e),`oklch`),oklab:e=>z(e,`oklch`)},parse:[or],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]}},cr=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(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},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=Le({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},ur={...ke,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>lr(P(e)),xyz65:lr},toMode:{rgb:e=>Re(cr(e)),xyz65:cr}},dr=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},fr=({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:dr(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:dr(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:dr(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},pr=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},mr=e=>{let t=pr(e.r),n=pr(e.g),r=pr(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},hr={...ke,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:fr,rgb:e=>fr(hn(e))},toMode:{xyz50:mr,rgb:e=>pn(mr(e))}},gr=1.09929682680944,_r=e=>{let t=Math.abs(e);return t>.018053968510807?(Math.sign(e)||1)*(gr*t**.45-(gr-1)):4.5*e},vr=({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:_r(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:_r(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:_r(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},yr=1.09929682680944,br=(e=0)=>{let t=Math.abs(e);return t<.018053968510807*4.5?e/4.5:(Math.sign(e)||1)*((t+yr-1)/yr)**(1/.45)},xr=e=>{let t=br(e.r),n=br(e.g),r=br(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},Sr={...ke,mode:`rec2020`,fromMode:{xyz65:vr,rgb:e=>vr(P(e))},toMode:{xyz65:xr,rgb:e=>Re(xr(e))},parse:[`rec2020`],serialize:`rec2020`},H=.0037930732552754493,Cr=Math.cbrt(H),wr=e=>Math.cbrt(e)-Cr,Tr=e=>{let{r:t,g:n,b:r,alpha:i}=Fe(e),a=wr(.3*t+.622*n+.078*r+H),o=wr(.23*t+.692*n+.078*r+H),s=wr(.2434226892454782*t+.2047674442449682*n+.5518098665095535*r+H),c={mode:`xyb`,x:(a-o)/2,y:(a+o)/2,b:s-(a+o)/2};return i!==void 0&&(c.alpha=i),c},Er=e=>(e+Cr)**3,Dr={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=Er(e+t)-H,a=Er(t-e)-H,o=Er(n+t)-H,s=Le({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:Tr},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:M,y:M,b:M,alpha:{use:M,fixup:N}}},Or={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:pn,lab:_n},fromMode:{rgb:hn,lab:fn},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}}},kr={mode:`xyz65`,toMode:{rgb:Re,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:P,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}}},Ar={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}}},jr=(e,t)=>Math.round(e*(t=10**t))/t,Mr=((e=4)=>t=>typeof t==`number`?jr(t,e):t)(2),Nr=e=>Math.max(0,Math.min(1,e||0)),Pr=e=>Math.round(Nr(e)*255),Fr=E(`rgb`),Ir=e=>{if(e===void 0)return;let t=Pr(e.r),n=Pr(e.g),r=Pr(e.b);return e.alpha===void 0||e.alpha===1?`rgb(${t}, ${n}, ${r})`:`rgba(${t}, ${n}, ${r}, ${Mr(Nr(e.alpha))})`},U=e=>Ir(Fr(e)),Lr=(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}},Rr=(e,t,n)=>t===`alpha`?e:(e||0)*(n.alpha===void 0?1:n.alpha),zr=(e,t,n)=>t!==`alpha`&&n.alpha!==0?(e||0)/(n.alpha===void 0?1:n.alpha):e,Br=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},Vr=(e=.5)=>t=>e<=0?1:e>=1?0:t**+(Math.log(.5)/Math.log(e)),Hr=e=>typeof e==`function`,W=e=>e&&typeof e==`object`,Ur=e=>typeof e==`number`,Wr=(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])):Ur(e)||Hr(e)?c[s.length]=e:(o.push(a(e)),s.push(void 0))}),Br(s);let l=i.channels.reduce((e,t)=>{let r;return r=W(n)&&W(n[t])&&n[t].fixup?n[t].fixup:W(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 Hr(n)?r=n:W(n)&&Hr(n[t])?r=n[t]:W(n)&&W(n[t])&&n[t].use?r=n[t].use:Hr(i.interpolate[t])?r=i.interpolate[t]:W(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&&(Ur(f)&&(f=Vr((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})}},G=(e,t=`rgb`,n)=>Wr(e,t,n);((e,t)=>(n,r=`rgb`,i)=>{let a=t?Lr(t,r):void 0,o=Wr(n,r,i,e);return a?e=>a(o(e)):o})(Rr,zr),k(ze),k(et),k(vt),k(yt),k(St),k(kt),k(Mt),k(It),k(Jt),k(an),k(cn),k(bn),k(xn),k(Cn),k(wn),k(Rn),k(zn),k(Bn),k(er),k(rr),k(ar),k(sr),k(ur),k(hr),k(Sr),k(ke),k(Dr),k(Or),k(kr),k(Ar);let Gr=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 Kr(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=Jr(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 qr(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 Jr(e,t,n,r){let i=t[r];if(i===`config`||i===`color-stop`||i===`color-hint`)return qr(e,t,n,r);if(i===`[`)return Xr(e,t,n,r);if(i===`(`)return Qr(e,t,n,r);if(i===`~`)return $r(e,t,n,r);throw Error(`Unsupported primary token "${i}" at pattern index ${r}`)}function Yr(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 Xr(e,t,n,r){if(t[r]!==`[`)throw Error(`Expected "[" at pattern index ${r}`);let i=Yr(t,r,`[`,`]`),a=n,o=r+1;for(;o<i;){if(t[o]===`,`){o+=1;continue}let i=Jr(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 Zr(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 Qr(e,t,n,r){if(t[r]!==`(`)throw Error(`Expected "(" at pattern index ${r}`);let i=Yr(t,r,`(`,`)`),a=Zr(t.slice(r+1,i));for(let t of a){let r=Kr(e,t,n,0);if(r.matched)return{matched:!0,nextInputIndex:r.nextInputIndex,nextPatternIndex:i+1}}return{matched:!1,nextInputIndex:n,nextPatternIndex:r}}function $r(e,t,n,r){if(t[r]!==`~`)throw Error(`Expected "~" at pattern index ${r}`);let i=n,a=r+1;for(;;){let n=Jr(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=ei(t,a);return{matched:!0,nextInputIndex:i,nextPatternIndex:o}}function ei(e,t){let n=e[t];if(n===`config`||n===`color-stop`||n===`color-hint`)return t+1;if(n===`[`)return Yr(e,t,`[`,`]`)+1;if(n===`(`)return Yr(e,t,`(`,`)`)+1;if(n===`~`)return ei(e,t+1);throw Error(`Unsupported token "${n}" in getPrimaryEndIndex`)}function ti(e){return ri(e),oi(e),si(e),!0}function ni(e){try{return ti(e),!0}catch{return!1}}function ri(e){let t=ci(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 ii(e){try{return ri(e),!0}catch{return!1}}let ai={"^":[`(`,`[`,`!`,`~`,`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 oi(e){let t=ci(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=ai[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 si(e){let t=ci(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 ci(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 li(e,t){try{return ui(e,t),!0}catch{return!1}}function ui(e,t){ti(t);let n=ci(t).slice(1,-1),r=Kr(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 di(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}=gi(n),o=hi(a);return ui(o,t),{functionName:r,isRepeating:i,inputs:o}}function fi(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 pi(e){try{let t=bi(e)[0];return we(t)!==void 0}catch{return!1}}function mi(e){return!fi(e)&&!pi(e)}function hi(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?[]:t.map((e,t)=>t===0&&!pi(e)?{type:`config`,value:e}:pi(e)?{type:`color-stop`,value:e}:fi(e)?{type:`color-hint`,value:e}:{type:`config`,value:e})}function gi(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=_i(e,t);if(i===-1)throw Error(`Unclosed function parenthesis`);let a=vi(e.slice(t+1,i));return{functionName:n,isRepeating:r,inputs:a}}function _i(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 vi(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){yi(t,n),n=``;continue}n+=s}return yi(t,n),t}function yi(e,t){let n=t.trim();n.length>0&&e.push(n)}function bi(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 xi=[`oklab`,`lch`,`oklch`,`hsl`,`hwb`,`lab`,`srgb`,`srgb-linear`,`xyz`,`display-p3`,`a98-rgb`,`prophoto-rgb`,`rec2020`],Si=[`shorter`,`longer`,`increasing`,`decreasing`],Ci=[`hsl`,`hwb`,`lch`,`oklch`];function wi(e){return Si.includes(e)}function Ti(e){return xi.includes(e)}function Ei(e){return Ci.includes(e)}var Di=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=bi(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}})}},Oi=class e extends Di{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(di(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||!Ei(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||!Ti(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(wi(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}},ki=class e extends Di{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(di(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=bi(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||!Ei(t)?{colorSpace:t}:{colorSpace:t,hue:n}}},Ai=class e extends ki{type=`diamond-gradient`;constructor(e){super(e)}static fromString(t){return e.fromAbi(di(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())}},ji=class e extends Di{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(di(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=bi(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 Mi=/^[A-Za-z_][A-Za-z0-9_-]*$/,Ni=[`px`,`em`,`rem`,`vw`,`vh`,`vmin`,`vmax`,`cm`,`mm`,`in`,`pt`,`pc`];var Pi=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=bi(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&&!Ti(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(!Mi.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(!Ti(n))throw Error(`Invalid mesh gradient color space: ${n}`);if(r!==void 0&&a===`hue`&&wi(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(!Ni.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||!Ei(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)}},Fi=class{target=`css`;gradientType=`linear-gradient`;to(e){if(!(e instanceof Oi))throw Error(`Expected LinearGradient`);return e.toString()}},Ii=class{target=`css`;gradientType=`radial-gradient`;to(e){if(!(e instanceof ki))throw Error(`Expected RadialGradient`);return e.toString()}};function Li(e,t){return(e%t+t)%t}function Ri(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 U(G([r.value,i.value],`rgb`)(n))}}return r.value}function zi(e,t,n,r){return Ri(e,n+Li(t-n,r))}function K(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:zi(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:zi(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 Bi(e){return K(e,0,1)}function Vi(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 Hi(e){switch(e){case`longer`:return Ve;case`increasing`:return He;case`decreasing`:return Ue;default:return I}}function Ui(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 Wi(e){if(e.hue!==void 0)return{h:{fixup:Hi(e.hue)}}}function Gi(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 Ki(e){let t=qi(e);if(!t)throw Error(`Failed to convert interpolated color to rgb.`);return U(t)}let qi=E(`rgb`);function q(e,t=64){let n=Gi(e.stops),r=e.config.interpolation;if(n.length<2)return n;if(r===void 0)return e.isRepeating?Bi(n):n;let i=[],a=Ui(r.colorSpace),o=Wi(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=G([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:Ki(o),position:a})}}return e.isRepeating?Bi(i):i}let Ji=E(`rgb`);function Yi(e){let t=Ji(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function Xi(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 Zi(e,t,n){return{id:e.id,x:Xi(e.x,t),y:Xi(e.y,n),color:Yi(e.color)}}function Qi(e,t,n){return new Map(e.vertices.map(e=>[e.id,Zi(e,t,n)]))}function $i(e,t){let n=ea(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 ea(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 ta(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 na(e,t){return Math.min(t-1,Math.max(0,e))}function ra(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 ia(e){return Math.min(1,Math.max(0,e))}function J(e,t,n){return e+(t-e)*n}function aa(e,t,n){return[J(e[0],t[0],n),J(e[1],t[1],n),J(e[2],t[2],n),J(e[3],t[3],n)]}function oa(e,t,n,r,i,a){return aa(aa(e.color,t.color,i),aa(r.color,n.color,i),a)}function sa(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[na(t+i,a)],u=s[na(n-1,o)].color[c],d=s[na(n,o)].color[c],f=s[na(n+1,o)].color[c],p=s[na(n+2,o)].color[c];l.push(ra(u,d,f,p,r))}s[c]=ia(ra(l[0],l[1],l[2],l[3],i))}return s}function Y(e,t,n,r,i,a){let o=J(e.x,t.x,i),s=J(e.y,t.y,i),c=J(r.x,n.x,i),l=J(r.y,n.y,i);return{x:J(o,c,a),y:J(s,l,a)}}function ca(e,t,n,r,i,a,o,s,c,l){return e.config.method===`bicubic`?sa(t,n,r,c,l):oa(i,a,o,s,c,l).map(ia)}function la(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=ta(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=Y(a,o,s,c,p,f),h=ca(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 X(e,t,n,r,i,a,o,s,c,l,u,d,f){return{id:f,x:u,y:d,color:ca(e,t,n,r,i,a,o,s,c,l)}}function ua(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=Y(r,o,s,c,u,0),p=Y(r,o,s,c,d,0),m=Y(r,o,s,c,u,1),h=Y(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=X(e,t,0,n,r,o,s,c,u,0,f.x,f.y,`top:${n}:${l}:b0`),y=X(e,t,0,n,r,o,s,c,d,0,p.x,p.y,`top:${n}:${l}:b1`),b=X(e,t,0,n,r,o,s,c,u,g,f.x,0,`top:${n}:${l}:p0`),x=X(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=Y(c,l,u,d,f,0),h=Y(c,l,u,d,p,0),g=Y(c,l,u,d,f,1),_=Y(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=X(e,t,s,n,c,l,u,d,f,1,g.x,g.y,`bottom:${n}:${o}:b0`),x=X(e,t,s,n,c,l,u,d,p,1,_.x,_.y,`bottom:${n}:${o}:b1`),S=X(e,t,s,n,c,l,u,d,f,v,g.x,r,`bottom:${n}:${o}:p0`),C=X(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=Y(r,o,s,c,0,u),p=Y(r,o,s,c,0,d),m=Y(r,o,s,c,1,u),h=Y(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=X(e,t,n,0,r,o,s,c,0,u,f.x,f.y,`left:${n}:${l}:b0`),y=X(e,t,n,0,r,o,s,c,0,d,p.x,p.y,`left:${n}:${l}:b1`),b=X(e,t,n,0,r,o,s,c,g,u,0,f.y,`left:${n}:${l}:p0`),x=X(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=Y(c,l,u,d,0,f),h=Y(c,l,u,d,0,p),g=Y(c,l,u,d,1,f),_=Y(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=X(e,t,r,o,c,l,u,d,1,f,g.x,g.y,`right:${r}:${s}:b0`),x=X(e,t,r,o,c,l,u,d,1,p,_.x,_.y,`right:${r}:${s}:b1`),S=X(e,t,r,o,c,l,u,d,v,f,n,g.y,`right:${r}:${s}:p0`),C=X(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 da(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function fa(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 U(G([r.value,i.value],`rgb`)(n))}}return n.value}function pa(e){return e.kind===`keywords`?{x:ma(e.x),y:ha(e.y)}:{x:ga(e.x,100),y:ga(e.y,100)}}function ma(e){return e===`left`?0:e===`right`?100:50}function ha(e){return e===`top`?0:e===`bottom`?100:50}function ga(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 _a(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function va(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 ya(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 ba(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 xa(e,t,n){if(e.kind===`explicit`){let n=ga(e.x,100),r=e.y?ga(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=>_a(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=va(n);return e.value===`closest-corner`?d.map(e=>ya(s,c,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):d.map(e=>ya(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function Z(e){return Number(e.toFixed(3)).toString()}function Sa(e,t,n){let r=t.x*n,i=t.y*n;return[`${Z(e.x)} ${Z(e.y-i)}`,`${Z(e.x+r)} ${Z(e.y)}`,`${Z(e.x)} ${Z(e.y+i)}`,`${Z(e.x-r)} ${Z(e.y)}`].join(` `)}function Ca(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var wa=class{target=`css`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Ai))throw Error(`Expected DiamondGradient`);let t=pa(e.config.position),n=xa(e.config.size,e.config.shape,t),r=ba(t,n),i=e.isRepeating?r:1,a=q(e,96),o=da(e.isRepeating?K(a,0,r):a),s=fa(o,i),c=[],l=Math.max(96,Math.ceil(96*i));for(let e=l;e>=0;--e){let r=e/l*i,a=fa(o,r),s=Sa(t,n,r);c.push(`<polygon points="${s}" fill="${a}"/>`)}return Ca([`<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(``))}},Ta=class{target=`css`;gradientType=`conic-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected ConicGradient`);return e.toString()}};function Ea(e){return`rgba(${e[0]},${e[1]},${e[2]},${Number(e[3].toFixed(3))})`}function Da(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 Oa(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 ka(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}var Aa=class{target=`css`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof Pi))throw Error(`Expected MeshGradient`);let t=Qi(e,96,96),n=$i(e,t),r=e.config.method===`bicubic`?24:1,i=e.patches.flatMap(i=>la(e,n,i,t,r)),a=ua(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=Da(n,r,e,t,a);if(o){i=Oa(o,e,t,a);break}}i&&s.push(`<rect x="${t}" y="${e}" width="1" height="1" fill="${Ea(i)}"/>`)}return ka([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" preserveAspectRatio="none" shape-rendering="crispEdges">`,...s,`</svg>`].join(``))}};let ja=E(`rgb`);function Ma(e){let t=ja(e);if(!t)throw Error(`Failed to convert color: ${e}`);return U(t)}function Na(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 Pa(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 Fa=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}=Na(q(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,_=Pa(g,m,h)}let v=e.createLinearGradient(u,d,f,p);for(let e of _)v.addColorStop(e.position,Ma(e.value));e.clearRect(0,0,n,r),e.fillStyle=v,e.fillRect(0,0,n,r)}}}};let Ia=E(`rgb`);function La(e){let t=Ia(e);if(!t)throw Error(`Failed to convert color: ${e}`);return U(t)}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 za(e,t,n){let r=n-t||1;return e.map(e=>({...e,position:(e.position-t)/r}))}function Ba(e,t,n,r){return r===`left`?e.x:r===`right`?t-e.x:r===`top`?e.y:n-e.y}function Va(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ha(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 Ua(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 Wa=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=Vi(i,a,n,r),s=q(t,128),{min:c,max:l,stops:u}=Ra(t.isRepeating?K(s,0,o):s),d=u,f=0,p=t.isRepeating?o:1;if(t.isRepeating?d=za(u,0,o):(c<0||l>1)&&(d=za(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,La(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,La(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=Ba(n,r,i,`left`),o=Ba(n,r,i,`right`),s=Ba(n,r,i,`top`),c=Ba(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=>Va(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=Ha(n,r,i);return e.value===`closest-corner`?p.map(e=>Ua(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=>Ua(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 Ga=E(`rgb`),Ka=1024;function qa(e){let t=Ga(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 Ja(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function Ya(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 qa(e[0].value);let n=e[e.length-1];if(t>=n.position)return qa(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=qa(r.value),o=qa(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 qa(n.value)}function Xa(e,t){let n=new Uint8ClampedArray(Ka*4);for(let r=0;r<Ka;r+=1){let i=Ya(e,r/(Ka-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 Za(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 Qa(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function $a(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 eo(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 to=class{target=`canvas-2d`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Ai))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=Za(i,a,n,r),s=q(t,128),c=Xa(Ja(t.isRepeating?K(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(Ka-1,Math.max(0,Math.round(r/Math.max(o,1e-4)*(Ka-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=>Qa(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=$a(n,r,i);return e.value===`closest-corner`?p.map(e=>eo(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):p.map(e=>eo(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 no=E(`rgb`);var ro=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=q(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=no(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 io(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 ao(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 oo(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=io(c+.5,n+.5,r,i,a);if(!o)continue;let s=ao(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 so=class{target=`canvas-2d`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof Pi))throw Error(`Expected MeshGradient`);let t=e;return{draw:(e,n,r)=>{let i=e.createImageData(n,r),a=Qi(t,n,r),o=$i(t,a),s=t.config.method===`bicubic`?24:1,c=ua(t,o,n,r,s);for(let e of t.patches){let c=la(t,o,e,a,s);for(let[e,t,a]of c)oo(i.data,n,r,e,t,a)}for(let[e,t,a]of c)oo(i.data,n,r,e,t,a);e.putImageData(i,0,0)}}}};let co=E(`rgb`);function lo(e){let t=co(e);if(!t)throw Error(`Failed to convert color: ${e}`);return[t.r??0,t.g??0,t.b??0,t.alpha??1]}function uo(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 fo(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 po(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 mo(e,t,n){let r=po(e,e.VERTEX_SHADER,t),i=po(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 ho(e){return e.filter(e=>e.type===`color-stop`).length}function go(e,t){let n=ho(e.stops),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function _o(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 U(G([r.value,i.value],`rgb`)(n))}}return r.value}function vo(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:_o(n,i),position:i})}return r}var yo=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=mo(i,`
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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 re=RegExp(`^rgba?\\(\\s*${S}${w}${S}${w}${S}\\s*(?:,\\s*${ee}\\s*)?\\)$`),ie=RegExp(`^rgba?\\(\\s*${C}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),ae=e=>{let t={mode:`rgb`},n;if(n=e.match(re))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(ie))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},oe=(e,t)=>e===void 0?void 0:typeof e==`object`?e.mode===void 0?t?{...e,mode:t}:void 0:e:Ee(e),T=(e=`rgb`)=>t=>(t=oe(t,e))===void 0?void 0:t.mode===e?t:E[t.mode][e]?E[t.mode][e](t):e===`rgb`?E[t.mode].rgb(t):E.rgb[e](E[t.mode].rgb(t)),E={},se={},ce=[],le={},ue=e=>e,D=e=>(E[e.mode]={...E[e.mode],...e.toMode},Object.keys(e.fromMode||{}).forEach(t=>{E[t]||(E[t]={}),E[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=ue)}),se[e.mode]=e,(e.parse||[]).forEach(t=>{fe(t,e.mode)}),T(e.mode)),de=e=>se[e],fe=(e,t)=>{if(typeof e==`string`){if(!t)throw Error(`'mode' required when 'parser' is a string`);le[e]=t}else typeof e==`function`&&ce.indexOf(e)<0&&ce.push(e)},pe=/[^\x00-\x7F]|[a-zA-Z_]/,me=/[^\x00-\x7F]|[-\w]/,O={Function:`function`,Ident:`ident`,Number:`number`,Percentage:`percentage`,ParenClose:`)`,None:`none`,Hue:`hue`,Alpha:`alpha`},k=0;function he(e){let t=e[k],n=e[k+1];return t===`-`||t===`+`?/\d/.test(n)||n===`.`&&/\d/.test(e[k+2]):t===`.`?/\d/.test(n):/\d/.test(t)}function ge(e){if(k>=e.length)return!1;let t=e[k];if(pe.test(t))return!0;if(t===`-`){if(e.length-k<2)return!1;let t=e[k+1];return!!(t===`-`||pe.test(t))}return!1}let _e={deg:1,rad:180/Math.PI,grad:9/10,turn:360};function ve(e){let t=``;if((e[k]===`-`||e[k]===`+`)&&(t+=e[k++]),t+=ye(e),e[k]===`.`&&/\d/.test(e[k+1])&&(t+=e[k++]+ye(e)),(e[k]===`e`||e[k]===`E`)&&((e[k+1]===`-`||e[k+1]===`+`)&&/\d/.test(e[k+2])?t+=e[k++]+e[k++]+ye(e):/\d/.test(e[k+1])&&(t+=e[k++]+ye(e))),ge(e)){let n=be(e);return n===`deg`||n===`rad`||n===`turn`||n===`grad`?{type:O.Hue,value:t*_e[n]}:void 0}return e[k]===`%`?(k++,{type:O.Percentage,value:+t}):{type:O.Number,value:+t}}function ye(e){let t=``;for(;/\d/.test(e[k]);)t+=e[k++];return t}function be(e){let t=``;for(;k<e.length&&me.test(e[k]);)t+=e[k++];return t}function xe(e){let t=be(e);return e[k]===`(`?(k++,{type:O.Function,value:t}):t===`none`?{type:O.None,value:void 0}:{type:O.Ident,value:t}}function Se(e=``){let t=e.trim(),n=[],r;for(k=0;k<t.length;){if(r=t[k++],r===`
|
|
2
|
+
`||r===` `||r===` `){for(;k<t.length&&(t[k]===`
|
|
3
|
+
`||t[k]===` `||t[k]===` `);)k++;continue}if(r===`,`)return;if(r===`)`){n.push({type:O.ParenClose});continue}if(r===`+`){if(k--,he(t)){n.push(ve(t));continue}return}if(r===`-`){if(k--,he(t)){n.push(ve(t));continue}if(ge(t)){n.push({type:O.Ident,value:be(t)});continue}return}if(r===`.`){if(k--,he(t)){n.push(ve(t));continue}return}if(r===`/`){for(;k<t.length&&(t[k]===`
|
|
4
|
+
`||t[k]===` `||t[k]===` `);)k++;let e;if(he(t)&&(e=ve(t),e.type!==O.Hue)){n.push({type:O.Alpha,value:e});continue}if(ge(t)&&be(t)===`none`){n.push({type:O.Alpha,value:{type:O.None,value:void 0}});continue}return}if(/\d/.test(r)){k--,n.push(ve(t));continue}if(pe.test(r)){k--,n.push(xe(t));continue}return}return n}function Ce(e){e._i=0;let t=e[e._i++];if(!t||t.type!==O.Function||t.value!==`color`||(t=e[e._i++],t.type!==O.Ident))return;let n=le[t.value];if(!n)return;let r={mode:n},i=we(e,!1);if(!i)return;let a=de(n).channels;for(let e=0,t,n;e<a.length;e++)t=i[e],n=a[e],t.type!==O.None&&(r[n]=t.type===O.Number?t.value:t.value/100,n===`alpha`&&(r[n]=Math.max(0,Math.min(1,r[n]))));return r}function we(e,t){let n=[],r;for(;e._i<e.length;){if(r=e[e._i++],r.type===O.None||r.type===O.Number||r.type===O.Alpha||r.type===O.Percentage||t&&r.type===O.Hue){n.push(r);continue}if(r.type===O.ParenClose){if(e._i<e.length)return;continue}return}if(!(n.length<3||n.length>4)){if(n.length===4){if(n[3].type!==O.Alpha)return;n[3]=n[3].value}return n.length===3&&n.push({type:O.None,value:void 0}),n.every(e=>e.type!==O.Alpha)?n:void 0}}function Te(e,t){e._i=0;let n=e[e._i++];if(!n||n.type!==O.Function)return;let r=we(e,t);if(r)return r.unshift(n.value),r}let Ee=e=>{if(typeof e!=`string`)return;let t=Se(e),n=t?Te(t,!0):void 0,r,i=0,a=ce.length;for(;i<a;)if((r=ce[i++](e,n))!==void 0)return r;return t?Ce(t):void 0};function De(e,t){if(!t||t[0]!==`rgb`&&t[0]!==`rgba`)return;let n={mode:`rgb`},[,r,i,a,o]=t;if(!(r.type===O.Hue||i.type===O.Hue||a.type===O.Hue))return r.type!==O.None&&(n.r=r.type===O.Number?r.value/255:r.value/100),i.type!==O.None&&(n.g=i.type===O.Number?i.value/255:i.value/100),a.type!==O.None&&(n.b=a.type===O.Number?a.value/255:a.value/100),o.type!==O.None&&(n.alpha=Math.min(1,Math.max(0,o.type===O.Number?o.value:o.value/100))),n}let Oe=e=>e===`transparent`?{mode:`rgb`,r:0,g:0,b:0,alpha:0}:void 0,ke=(e,t,n)=>e+n*(t-e),Ae=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},A=(e=>t=>{let n=Ae(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)}})(ke),j=e=>{let t=!1,n=e.map(e=>e===void 0?1:(t=!0,e));return t?n:e},je={mode:`rgb`,channels:[`r`,`g`,`b`,`alpha`],parse:[De,x,ae,y,Oe,`srgb`],serialize:`srgb`,interpolate:{r:A,g:A,b:A,alpha:{use:A,fixup:j}},gamut:!0,white:{r:1,g:1,b:1},black:{r:0,g:0,b:0}},Me=(e=0)=>Math.abs(e)**(563/256)*Math.sign(e),Ne=e=>{let t=Me(e.r),n=Me(e.g),r=Me(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},Pe=e=>Math.abs(e)**(256/563)*Math.sign(e),Fe=({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:Pe(e*2.0415879038107465-t*.5650069742788597-.3447313507783297*n),g:Pe(e*-.9692436362808798+t*1.8759675015077206+.0415550574071756*n),b:Pe(e*.0134442806320312-t*.1183623922310184+1.0151749943912058*n)};return r!==void 0&&(i.alpha=r),i},Ie=(e=0)=>{let t=Math.abs(e);return t<=.04045?e/12.92:(Math.sign(e)||1)*((t+.055)/1.055)**2.4},Le=({r:e,g:t,b:n,alpha:r})=>{let i={mode:`lrgb`,r:Ie(e),g:Ie(t),b:Ie(n)};return r!==void 0&&(i.alpha=r),i},M=e=>{let{r:t,g:n,b:r,alpha:i}=Le(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},Re=(e=0)=>{let t=Math.abs(e);return t>.0031308?(Math.sign(e)||1)*(1.055*t**(1/2.4)-.055):e*12.92},ze=({r:e,g:t,b:n,alpha:r},i=`rgb`)=>{let a={mode:i,r:Re(e),g:Re(t),b:Re(n)};return r!==void 0&&(a.alpha=r),a},Be=({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=ze({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},Ve={...je,mode:`a98`,parse:[`a98-rgb`],serialize:`a98-rgb`,fromMode:{rgb:e=>Fe(M(e)),xyz65:Fe},toMode:{rgb:e=>Be(Ne(e)),xyz65:Ne}},N=e=>(e%=360)<0?e+360:e,He=(e,t)=>e.map((n,r,i)=>{if(n===void 0)return n;let a=N(n);return r===0||e[r-1]===void 0?a:t(a-N(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),[]),P=e=>He(e,e=>Math.abs(e)<=180?e:e-360*Math.sign(e)),Ue=e=>He(e,e=>Math.abs(e)>=180||e===0?e:e-360*Math.sign(e)),We=e=>He(e,e=>e>=0?e:e+360),Ge=e=>He(e,e=>e<=0?e:e-360),F=[-.14861,1.78277,-.29227,-.90649,1.97294,0],Ke=Math.PI/180,qe=180/Math.PI,Je=F[3]*F[4],Ye=F[1]*F[4],Xe=F[1]*F[2]-F[0]*F[3],Ze=({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=(Xe*n+e*Je-t*Ye)/(Xe+Je-Ye),a=n-i,o=(F[4]*(t-i)-F[2]*a)/F[3],s={mode:`cubehelix`,l:i,s:i===0||i===1?void 0:Math.sqrt(a*a+o*o)/(F[4]*i*(1-i))};return s.s&&(s.h=Math.atan2(o,a)*qe-120),r!==void 0&&(s.alpha=r),s},Qe=({h:e,s:t,l:n,alpha:r})=>{let i={mode:`rgb`};e=(e===void 0?0:e+120)*Ke,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*(F[0]*o+F[1]*s),i.g=n+a*(F[2]*o+F[3]*s),i.b=n+a*(F[4]*o+F[5]*s),r!==void 0&&(i.alpha=r),i},$e=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.s||!t.s)return 0;let n=N(e.h),r=N(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.s*t.s)*i},et=(e,t)=>{if(e.h===void 0||t.h===void 0)return 0;let n=N(e.h),r=N(t.h);return Math.abs(r-n)>180?n-(r-360*Math.sign(r-n)):r-n},tt=(e,t)=>{if(e.h===void 0||t.h===void 0||!e.c||!t.c)return 0;let n=N(e.h),r=N(t.h),i=Math.sin((r-n+360)/2*Math.PI/180);return 2*Math.sqrt(e.c*t.c)*i},I=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},nt={mode:`cubehelix`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--cubehelix`],serialize:`--cubehelix`,ranges:{h:[0,360],s:[0,4.614],l:[0,1]},fromMode:{rgb:Ze},toMode:{rgb:Qe},interpolate:{h:{use:A,fixup:P},s:A,l:A,alpha:{use:A,fixup:j}},difference:{h:$e},average:{h:I}},L=({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=N(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(o.alpha=r),o},R=({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},rt=29**3/3**3,it=6**3/29**3,z={X:.3457/.3585,Y:1,Z:.2958/.3585},at={X:.3127/.329,Y:1,Z:.3583/.329},ot=e=>e**3>it?e**3:(116*e-16)/rt,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=(e+16)/116,a=t/500+i,o=i-n/200,s={mode:`xyz65`,x:ot(a)*at.X,y:ot(i)*at.Y,z:ot(o)*at.Z};return r!==void 0&&(s.alpha=r),s},ct=e=>Be(st(e)),lt=e=>e>it?Math.cbrt(e):(rt*e+16)/116,ut=({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=lt(e/at.X),a=lt(t/at.Y),o=lt(n/at.Z),s={mode:`lab65`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},dt=e=>{let t=ut(M(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},ft=26/180*Math.PI,pt=Math.cos(ft),mt=Math.sin(ft),ht=100/Math.log(139/100),gt=({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/ht)-1)/.0039},a=(Math.exp(.0435*t*1*1)-1)/.075,o=a*Math.cos(n/180*Math.PI-ft),s=a*Math.sin(n/180*Math.PI-ft);return i.a=o*pt-s/.83*mt,i.b=o*mt+s/.83*pt,r!==void 0&&(i.alpha=r),i},_t=({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*pt+n*mt,a=.83*(n*pt-t*mt),o=Math.sqrt(i*i+a*a),s={mode:`dlch`,l:ht/1*Math.log(1+.0039*e),c:Math.log(1+.075*o)/(.0435*1*1)};return s.c&&(s.h=N((Math.atan2(a,i)+ft)/Math.PI*180)),r!==void 0&&(s.alpha=r),s},vt=e=>gt(L(e,`dlch`)),yt=e=>R(_t(e),`dlab`),bt={mode:`dlab`,parse:[`--din99o-lab`],serialize:`--din99o-lab`,toMode:{lab65:vt,rgb:e=>ct(vt(e))},fromMode:{lab65:yt,rgb:e=>yt(dt(e))},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-40.09,45.501],b:[-40.469,44.344]},interpolate:{l:A,a:A,b:A,alpha:{use:A,fixup:j}}},xt={mode:`dlch`,parse:[`--din99o-lch`],serialize:`--din99o-lch`,toMode:{lab65:gt,dlab:e=>R(e,`dlab`),rgb:e=>ct(gt(e))},fromMode:{lab65:_t,dlab:e=>L(e,`dlch`),rgb:e=>_t(dt(e))},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,51.484],h:[0,360]},interpolate:{l:A,c:A,h:{use:A,fixup:P},alpha:{use:A,fixup:j}},difference:{h:tt},average:{h:I}};function St({h:e,s:t,i:n,alpha:r}){e=N(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 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:`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 wt={mode:`hsi`,toMode:{rgb:St},parse:[`--hsi`],serialize:`--hsi`,fromMode:{rgb:Ct},channels:[`h`,`s`,`i`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:A,fixup:P},s:A,i:A,alpha:{use:A,fixup:j}},difference:{h:$e},average:{h:I}};function Tt({h:e,s:t,l:n,alpha:r}){e=N(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 Et({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 Dt=(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}},Ot=RegExp(`^hsla?\\(\\s*${ne}${w}${C}${w}${C}\\s*(?:,\\s*${ee}\\s*)?\\)$`),kt=e=>{let t=e.match(Ot);if(!t)return;let n={mode:`hsl`};return t[3]===void 0?t[1]!==void 0&&t[2]!==void 0&&(n.h=Dt(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 At(e,t){if(!t||t[0]!==`hsl`&&t[0]!==`hsla`)return;let n={mode:`hsl`},[,r,i,a,o]=t;if(r.type!==O.None){if(r.type===O.Percentage)return;n.h=r.value}if(i.type!==O.None){if(i.type===O.Hue)return;n.s=i.value/100}if(a.type!==O.None){if(a.type===O.Hue)return;n.l=a.value/100}return o.type!==O.None&&(n.alpha=Math.min(1,Math.max(0,o.type===O.Number?o.value:o.value/100))),n}let jt={mode:`hsl`,toMode:{rgb:Tt},fromMode:{rgb:Et},channels:[`h`,`s`,`l`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[At,kt],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:A,fixup:P},s:A,l:A,alpha:{use:A,fixup:j}},difference:{h:$e},average:{h:I}};function Mt({h:e,s:t,v:n,alpha:r}){e=N(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 Nt({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 Pt={mode:`hsv`,toMode:{rgb:Mt},parse:[`--hsv`],serialize:`--hsv`,fromMode:{rgb:Nt},channels:[`h`,`s`,`v`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,interpolate:{h:{use:A,fixup:P},s:A,v:A,alpha:{use:A,fixup:j}},difference:{h:$e},average:{h:I}};function Ft({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 Mt({h:e,s:n===1?1:1-t/(1-n),v:1-n,alpha:r})}function It(e){let t=Nt(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 Lt(e,t){if(!t||t[0]!==`hwb`)return;let n={mode:`hwb`},[,r,i,a,o]=t;if(r.type!==O.None){if(r.type===O.Percentage)return;n.h=r.value}if(i.type!==O.None){if(i.type===O.Hue)return;n.w=i.value/100}if(a.type!==O.None){if(a.type===O.Hue)return;n.b=a.value/100}return o.type!==O.None&&(n.alpha=Math.min(1,Math.max(0,o.type===O.Number?o.value:o.value/100))),n}let Rt={mode:`hwb`,toMode:{rgb:Ft},fromMode:{rgb:It},channels:[`h`,`w`,`b`,`alpha`],ranges:{h:[0,360]},gamut:`rgb`,parse:[Lt],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:A,fixup:P},w:A,b:A,alpha:{use:A,fixup:j}},difference:{h:et},average:{h:I}},zt=.1593017578125,Bt=78.84375,Vt=.8359375,Ht=18.8515625,Ut=18.6875;function Wt(e){if(e<0)return 0;let t=e**(1/Bt);return 1e4*(Math.max(0,t-Vt)/(Ht-Ut*t))**(1/zt)}function Gt(e){if(e<0)return 0;let t=(e/1e4)**zt;return((Vt+Ht*t)/(1+Ut*t))**+Bt}let Kt=e=>Math.max(e/203,0),qt=({i:e,t,p:n,alpha:r})=>{e===void 0&&(e=0),t===void 0&&(t=0),n===void 0&&(n=0);let i=Wt(e+.008609037037932761*t+.11102962500302593*n),a=Wt(e-.00860903703793275*t-.11102962500302599*n),o=Wt(e+.5600313357106791*t-.32062717498731885*n),s={mode:`xyz65`,x:Kt(2.070152218389422*i-1.3263473389671556*a+.2066510476294051*o),y:Kt(.3647385209748074*i+.680566024947227*a-.0453045459220346*o),z:Kt(-.049747207535812*i-.0492609666966138*a+1.1880659249923042*o)};return r!==void 0&&(s.alpha=r),s},Jt=(e=0)=>Math.max(e*203,0),Yt=({x:e,y:t,z:n,alpha:r})=>{let i=Jt(e),a=Jt(t),o=Jt(n),s=Gt(.3592832590121217*i+.6976051147779502*a-.0358915932320289*o),c=Gt(-.1920808463704995*i+1.1004767970374323*a+.0753748658519118*o),l=Gt(.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},Xt={mode:`itp`,channels:[`i`,`t`,`p`,`alpha`],parse:[`--ictcp`],serialize:`--ictcp`,toMode:{xyz65:qt,rgb:e=>Be(qt(e))},fromMode:{xyz65:Yt,rgb:e=>Yt(M(e))},ranges:{i:[0,.581],t:[-.369,.272],p:[-.164,.331]},interpolate:{i:A,t:A,p:A,alpha:{use:A,fixup:j}}},Zt=e=>{if(e<0)return 0;let t=(e/1e4)**zt;return((Vt+Ht*t)/(1+Ut*t))**134.03437499999998},Qt=(e=0)=>Math.max(e*203,0),$t=({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=Zt(.41478972*i+.579999*a+.014648*n),s=Zt(-.20151*i+1.120649*a+.0531008*n),c=Zt(-.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},en=16295499532821565e-27,tn=e=>{if(e<0)return 0;let t=e**(1/134.03437499999998);return 1e4*((Vt-t)/(Ut*t-Ht))**(1/zt)},nn=e=>e/203,rn=({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+en)/(.44+.56*(e+en)),a=tn(i+.13860504*t+.058047316*n),o=tn(i-.13860504*t-.058047316*n),s=tn(i-.096019242*t-.8118919*n),c={mode:`xyz65`,x:nn(1.661373024652174*a-.914523081304348*o+.23136208173913045*s),y:nn(-.3250758611844533*a+1.571847026732543*o-.21825383453227928*s),z:nn(-.090982811*a-.31272829*o+1.5227666*s)};return r!==void 0&&(c.alpha=r),c},an=e=>{let t=$t(M(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},on=e=>Be(rn(e)),sn={mode:`jab`,channels:[`j`,`a`,`b`,`alpha`],parse:[`--jzazbz`],serialize:`--jzazbz`,fromMode:{rgb:an,xyz65:$t},toMode:{rgb:on,xyz65:rn},ranges:{j:[0,.222],a:[-.109,.129],b:[-.185,.134]},interpolate:{j:A,a:A,b:A,alpha:{use:A,fixup:j}}},cn=({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=N(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},ln=({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},un={mode:`jch`,parse:[`--jzczhz`],serialize:`--jzczhz`,toMode:{jab:ln,rgb:e=>on(ln(e))},fromMode:{rgb:e=>cn(an(e)),jab:cn},channels:[`j`,`c`,`h`,`alpha`],ranges:{j:[0,.221],c:[0,.19],h:[0,360]},interpolate:{h:{use:A,fixup:P},c:A,j:A,alpha:{use:A,fixup:j}},difference:{h:tt},average:{h:I}},dn=29**3/3**3,fn=6**3/29**3,pn=e=>e**3>fn?e**3:(116*e-16)/dn,mn=({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:pn(a)*z.X,y:pn(i)*z.Y,z:pn(o)*z.Z};return r!==void 0&&(s.alpha=r),s},hn=({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=ze({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},gn=e=>hn(mn(e)),_n=e=>{let{r:t,g:n,b:r,alpha:i}=Le(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},vn=e=>e>fn?Math.cbrt(e):(dn*e+16)/116,yn=({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=vn(e/z.X),a=vn(t/z.Y),o=vn(n/z.Z),s={mode:`lab`,l:116*a-16,a:500*(i-a),b:200*(a-o)};return r!==void 0&&(s.alpha=r),s},bn=e=>{let t=yn(_n(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t};function xn(e,t){if(!t||t[0]!==`lab`)return;let n={mode:`lab`},[,r,i,a,o]=t;if(!(r.type===O.Hue||i.type===O.Hue||a.type===O.Hue))return r.type!==O.None&&(n.l=Math.min(Math.max(0,r.value),100)),i.type!==O.None&&(n.a=i.type===O.Number?i.value:i.value*125/100),a.type!==O.None&&(n.b=a.type===O.Number?a.value:a.value*125/100),o.type!==O.None&&(n.alpha=Math.min(1,Math.max(0,o.type===O.Number?o.value:o.value/100))),n}let Sn={mode:`lab`,toMode:{xyz50:mn,rgb:gn},fromMode:{xyz50:yn,rgb:bn},channels:[`l`,`a`,`b`,`alpha`],ranges:{l:[0,100],a:[-125,125],b:[-125,125]},parse:[xn],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:A,a:A,b:A,alpha:{use:A,fixup:j}}},Cn={...Sn,mode:`lab65`,parse:[`--lab-d65`],serialize:`--lab-d65`,toMode:{xyz65:st,rgb:ct},fromMode:{xyz65:ut,rgb:dt},ranges:{l:[0,100],a:[-125,125],b:[-125,125]}};function wn(e,t){if(!t||t[0]!==`lch`)return;let n={mode:`lch`},[,r,i,a,o]=t;if(r.type!==O.None){if(r.type===O.Hue)return;n.l=Math.min(Math.max(0,r.value),100)}if(i.type!==O.None&&(n.c=Math.max(0,i.type===O.Number?i.value:i.value*150/100)),a.type!==O.None){if(a.type===O.Percentage)return;n.h=a.value}return o.type!==O.None&&(n.alpha=Math.min(1,Math.max(0,o.type===O.Number?o.value:o.value/100))),n}let Tn={mode:`lch`,toMode:{lab:R,rgb:e=>gn(R(e))},fromMode:{rgb:e=>L(bn(e)),lab:L},channels:[`l`,`c`,`h`,`alpha`],ranges:{l:[0,100],c:[0,150],h:[0,360]},parse:[wn],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:A,fixup:P},c:A,l:A,alpha:{use:A,fixup:j}},difference:{h:tt},average:{h:I}},En={...Tn,mode:`lch65`,parse:[`--lch-d65`],serialize:`--lch-d65`,toMode:{lab65:e=>R(e,`lab65`),rgb:e=>ct(R(e,`lab65`))},fromMode:{rgb:e=>L(dt(e),`lch65`),lab65:e=>L(e,`lch65`)},ranges:{l:[0,100],c:[0,150],h:[0,360]}},Dn=({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=N(Math.atan2(n,t)*180/Math.PI)),r!==void 0&&(a.alpha=r),a},On=({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},kn=(e,t,n)=>4*e/(e+15*t+3*n),An=(e,t,n)=>9*t/(e+15*t+3*n),jn=kn(z.X,z.Y,z.Z),Mn=An(z.X,z.Y,z.Z),Nn=e=>e<=fn?dn*e:116*Math.cbrt(e)-16,Pn=({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=Nn(t/z.Y),a=kn(e,t,n),o=An(e,t,n);!isFinite(a)||!isFinite(o)?i=a=o=0:(a=13*i*(a-jn),o=13*i*(o-Mn));let s={mode:`luv`,l:i,u:a,v:o};return r!==void 0&&(s.alpha=r),s},Fn=(e,t,n)=>4*e/(e+15*t+3*n),In=(e,t,n)=>9*t/(e+15*t+3*n),Ln=Fn(z.X,z.Y,z.Z),Rn=In(z.X,z.Y,z.Z),zn=({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)+Ln,a=n/(13*e)+Rn,o=z.Y*(e<=8?e/dn:((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},Bn={mode:`lchuv`,toMode:{luv:On,rgb:e=>hn(zn(On(e)))},fromMode:{rgb:e=>Dn(Pn(_n(e))),luv:Dn},channels:[`l`,`c`,`h`,`alpha`],parse:[`--lchuv`],serialize:`--lchuv`,ranges:{l:[0,100],c:[0,176.956],h:[0,360]},interpolate:{h:{use:A,fixup:P},c:A,l:A,alpha:{use:A,fixup:j}},difference:{h:tt},average:{h:I}},Vn={...je,mode:`lrgb`,toMode:{rgb:ze},fromMode:{rgb:Le},parse:[`srgb-linear`],serialize:`srgb-linear`},Hn={mode:`luv`,toMode:{xyz50:zn,rgb:e=>hn(zn(e))},fromMode:{xyz50:Pn,rgb:e=>Pn(_n(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:A,u:A,v:A,alpha:{use:A,fixup:j}}},Un=({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},Wn=e=>{let t=Un(Le(e));return e.r===e.b&&e.b===e.g&&(t.a=t.b=0),t},Gn=({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},Kn=e=>ze(Gn(e));function qn(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 Jn(e){let t=.206,n=.03;return(1+t)/(1+n),(e*e+t*e)/(1.170873786407767*(e+n))}function Yn(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 Xn(e,t){let n=Yn(e,t),r=Gn({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 Zn(e,t,n,r,i,a=null){a||=Xn(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),re=-ee*w,ie=-1.2684380046*h+2.6097574011*g-.3413193965*_-1,ae=-1.2684380046*v+2.6097574011*y-.3413193965*b,oe=-1.2684380046*x+2.6097574011*S-.3413193965*C,T=ae/(ae*ae-.5*ie*oe),E=-ie*T,se=-.0041960863*h-.7034186147*g+1.707614701*_-1,ce=-.0041960863*v-.7034186147*y+1.707614701*b,le=-.0041960863*x-.7034186147*S+1.707614701*C,ue=ce/(ce*ce-.5*se*le),D=-se*ue;re=w>=0?re:1e6,E=T>=0?E:1e6,D=ue>=0?D:1e6,o+=Math.min(re,Math.min(E,D))}}}return o}function Qn(e,t,n=null){n||=Xn(e,t);let r=n[0],i=n[1];return[i/r,i/(1-r)]}function $n(e,t,n){let r=Xn(t,n),i=Zn(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 er(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:qn(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]=$n(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=N(Math.atan2(r,n)*180/Math.PI)),i}function tr(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:Jn(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]=$n(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 nr={...jt,mode:`okhsl`,channels:[`h`,`s`,`l`,`alpha`],parse:[`--okhsl`],serialize:`--okhsl`,fromMode:{oklab:er,rgb:e=>er(Wn(e))},toMode:{oklab:tr,rgb:e=>Kn(tr(e))}};function rr(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=Jn(f),h=p*m/f,g=Gn({l:m,a:a*h,b:o*h}),_=Math.cbrt(1/Math.max(g.r,g.g,g.b,0));t/=_,i=i/_*qn(t)/t,t=qn(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=N(Math.atan2(r,n)*180/Math.PI)),e.alpha!==void 0&&(v.alpha=e.alpha),v}function ir(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=Jn(d),m=f*p/d,h=Gn({l:p,a:a*m,b:o*m}),g=Math.cbrt(1/Math.max(h.r,h.g,h.b,0)),_=Jn(i*d),v=f*_/d;return t.l=_*g,t.a=v*a*g,t.b=v*o*g,t}let ar={...Pt,mode:`okhsv`,channels:[`h`,`s`,`v`,`alpha`],parse:[`--okhsv`],serialize:`--okhsv`,fromMode:{oklab:rr,rgb:e=>rr(Wn(e))},toMode:{oklab:ir,rgb:e=>Kn(ir(e))}};function or(e,t){if(!t||t[0]!==`oklab`)return;let n={mode:`oklab`},[,r,i,a,o]=t;if(!(r.type===O.Hue||i.type===O.Hue||a.type===O.Hue))return r.type!==O.None&&(n.l=Math.min(Math.max(0,r.type===O.Number?r.value:r.value/100),1)),i.type!==O.None&&(n.a=i.type===O.Number?i.value:i.value*.4/100),a.type!==O.None&&(n.b=a.type===O.Number?a.value:a.value*.4/100),o.type!==O.None&&(n.alpha=Math.min(1,Math.max(0,o.type===O.Number?o.value:o.value/100))),n}let sr={...Sn,mode:`oklab`,toMode:{lrgb:Gn,rgb:Kn},fromMode:{lrgb:Un,rgb:Wn},ranges:{l:[0,1],a:[-.4,.4],b:[-.4,.4]},parse:[or],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 cr(e,t){if(!t||t[0]!==`oklch`)return;let n={mode:`oklch`},[,r,i,a,o]=t;if(r.type!==O.None){if(r.type===O.Hue)return;n.l=Math.min(Math.max(0,r.type===O.Number?r.value:r.value/100),1)}if(i.type!==O.None&&(n.c=Math.max(0,i.type===O.Number?i.value:i.value*.4/100)),a.type!==O.None){if(a.type===O.Percentage)return;n.h=a.value}return o.type!==O.None&&(n.alpha=Math.min(1,Math.max(0,o.type===O.Number?o.value:o.value/100))),n}let lr={...Tn,mode:`oklch`,toMode:{oklab:e=>R(e,`oklab`),rgb:e=>Kn(R(e,`oklab`))},fromMode:{rgb:e=>L(Wn(e),`oklch`),oklab:e=>L(e,`oklch`)},parse:[cr],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]}},ur=e=>{let{r:t,g:n,b:r,alpha:i}=Le(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},dr=({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=ze({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},fr={...je,mode:`p3`,parse:[`display-p3`],serialize:`display-p3`,fromMode:{rgb:e=>dr(M(e)),xyz65:dr},toMode:{rgb:e=>Be(ur(e)),xyz65:ur}},pr=e=>{let t=Math.abs(e);return t>=1/512?Math.sign(e)*t**(1/1.8):16*e},mr=({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:pr(e*1.3457868816471585-t*.2555720873797946-.0511018649755453*n),g:pr(e*-.5446307051249019+t*1.5082477428451466+.0205274474364214*n),b:pr(e*0+t*0+1.2119675456389452*n)};return r!==void 0&&(i.alpha=r),i},hr=(e=0)=>{let t=Math.abs(e);return t>=16/512?Math.sign(e)*t**1.8:e/16},gr=e=>{let t=hr(e.r),n=hr(e.g),r=hr(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},_r={...je,mode:`prophoto`,parse:[`prophoto-rgb`],serialize:`prophoto-rgb`,fromMode:{xyz50:mr,rgb:e=>mr(_n(e))},toMode:{xyz50:gr,rgb:e=>hn(gr(e))}},vr=1.09929682680944,yr=e=>{let t=Math.abs(e);return t>.018053968510807?(Math.sign(e)||1)*(vr*t**.45-(vr-1)):4.5*e},br=({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:yr(e*1.7166511879712683-t*.3556707837763925-.2533662813736599*n),g:yr(e*-.6666843518324893+t*1.6164812366349395+.0157685458139111*n),b:yr(e*.0176398574453108-t*.0427706132578085+.9421031212354739*n)};return r!==void 0&&(i.alpha=r),i},xr=1.09929682680944,Sr=(e=0)=>{let t=Math.abs(e);return t<.018053968510807*4.5?e/4.5:(Math.sign(e)||1)*((t+xr-1)/xr)**(1/.45)},Cr=e=>{let t=Sr(e.r),n=Sr(e.g),r=Sr(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},wr={...je,mode:`rec2020`,fromMode:{xyz65:br,rgb:e=>br(M(e))},toMode:{xyz65:Cr,rgb:e=>Be(Cr(e))},parse:[`rec2020`],serialize:`rec2020`},Tr=.0037930732552754493,Er=Math.cbrt(Tr),Dr=e=>Math.cbrt(e)-Er,Or=e=>{let{r:t,g:n,b:r,alpha:i}=Le(e),a=Dr(.3*t+.622*n+.078*r+Tr),o=Dr(.23*t+.692*n+.078*r+Tr),s=Dr(.2434226892454782*t+.2047674442449682*n+.5518098665095535*r+Tr),c={mode:`xyb`,x:(a-o)/2,y:(a+o)/2,b:s-(a+o)/2};return i!==void 0&&(c.alpha=i),c},kr=e=>(e+Er)**3,Ar={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=kr(e+t)-Tr,a=kr(t-e)-Tr,o=kr(n+t)-Tr,s=ze({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:Or},ranges:{x:[-.0154,.0281],y:[0,.8453],b:[-.2778,.388]},interpolate:{x:A,y:A,b:A,alpha:{use:A,fixup:j}}},jr={mode:`xyz50`,parse:[`xyz-d50`],serialize:`xyz-d50`,toMode:{rgb:hn,lab:yn},fromMode:{rgb:_n,lab:mn},channels:[`x`,`y`,`z`,`alpha`],ranges:{x:[0,.964],y:[0,.999],z:[0,.825]},interpolate:{x:A,y:A,z:A,alpha:{use:A,fixup:j}}},Mr={mode:`xyz65`,toMode:{rgb:Be,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:M,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:A,y:A,z:A,alpha:{use:A,fixup:j}}},Nr={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:A,i:A,q:A,alpha:{use:A,fixup:j}}},Pr=(e,t)=>Math.round(e*(t=10**t))/t,Fr=((e=4)=>t=>typeof t==`number`?Pr(t,e):t)(2),Ir=e=>Math.max(0,Math.min(1,e||0)),Lr=e=>Math.round(Ir(e)*255),Rr=T(`rgb`),zr=e=>{if(e===void 0)return;let t=Lr(e.r),n=Lr(e.g),r=Lr(e.b);return e.alpha===void 0||e.alpha===1?`rgb(${t}, ${n}, ${r})`:`rgba(${t}, ${n}, ${r}, ${Fr(Ir(e.alpha))})`},Br=e=>zr(Rr(e)),Vr=(e,t=`rgb`,n=!1)=>{let r=t?de(t).channels:null,i=t?T(t):oe;return a=>{let o=i(a);if(!o)return;let s=(r||de(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=oe(a);return c&&c.mode!==s.mode?T(c.mode)(s):s}},Hr=(e,t,n)=>t===`alpha`?e:(e||0)*(n.alpha===void 0?1:n.alpha),Ur=(e,t,n)=>t!==`alpha`&&n.alpha!==0?(e||0)/(n.alpha===void 0?1:n.alpha):e,Wr=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},Gr=(e=.5)=>t=>e<=0?1:e>=1?0:t**+(Math.log(.5)/Math.log(e)),Kr=e=>typeof e==`function`,qr=e=>e&&typeof e==`object`,Jr=e=>typeof e==`number`,Yr=(e,t=`rgb`,n,r)=>{let i=de(t),a=T(t),o=[],s=[],c={};e.forEach(e=>{Array.isArray(e)?(o.push(a(e[0])),s.push(e[1])):Jr(e)||Kr(e)?c[s.length]=e:(o.push(a(e)),s.push(void 0))}),Wr(s);let l=i.channels.reduce((e,t)=>{let r;return r=qr(n)&&qr(n[t])&&n[t].fixup?n[t].fixup:qr(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 Kr(n)?r=n:qr(n)&&Kr(n[t])?r=n[t]:qr(n)&&qr(n[t])&&n[t].use?r=n[t].use:Kr(i.interpolate[t])?r=i.interpolate[t]:qr(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&&(Jr(f)&&(f=Gr((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})}},Xr=(e,t=`rgb`,n)=>Yr(e,t,n);((e,t)=>(n,r=`rgb`,i)=>{let a=t?Vr(t,r):void 0,o=Yr(n,r,i,e);return a?e=>a(o(e)):o})(Hr,Ur),D(Ve),D(nt),D(bt),D(xt),D(wt),D(jt),D(Pt),D(Rt),D(Xt),D(sn),D(un),D(Sn),D(Cn),D(Tn),D(En),D(Bn),D(Vn),D(Hn),D(nr),D(ar),D(sr),D(lr),D(fr),D(_r),D(wr),D(je),D(Ar),D(jr),D(Mr),D(Nr);let Zr=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 Qr(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=ei(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 $r(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 ei(e,t,n,r){let i=t[r];if(i===`config`||i===`color-stop`||i===`color-hint`)return $r(e,t,n,r);if(i===`[`)return ni(e,t,n,r);if(i===`(`)return ii(e,t,n,r);if(i===`~`)return ai(e,t,n,r);throw Error(`Unsupported primary token "${i}" at pattern index ${r}`)}function ti(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 ni(e,t,n,r){if(t[r]!==`[`)throw Error(`Expected "[" at pattern index ${r}`);let i=ti(t,r,`[`,`]`),a=n,o=r+1;for(;o<i;){if(t[o]===`,`){o+=1;continue}let i=ei(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 ri(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 ii(e,t,n,r){if(t[r]!==`(`)throw Error(`Expected "(" at pattern index ${r}`);let i=ti(t,r,`(`,`)`),a=ri(t.slice(r+1,i));for(let t of a){let r=Qr(e,t,n,0);if(r.matched)return{matched:!0,nextInputIndex:r.nextInputIndex,nextPatternIndex:i+1}}return{matched:!1,nextInputIndex:n,nextPatternIndex:r}}function ai(e,t,n,r){if(t[r]!==`~`)throw Error(`Expected "~" at pattern index ${r}`);let i=n,a=r+1;for(;;){let n=ei(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=oi(t,a);return{matched:!0,nextInputIndex:i,nextPatternIndex:o}}function oi(e,t){let n=e[t];if(n===`config`||n===`color-stop`||n===`color-hint`)return t+1;if(n===`[`)return ti(e,t,`[`,`]`)+1;if(n===`(`)return ti(e,t,`(`,`)`)+1;if(n===`~`)return oi(e,t+1);throw Error(`Unsupported token "${n}" in getPrimaryEndIndex`)}function si(e){return li(e),fi(e),pi(e),!0}function ci(e){try{return si(e),!0}catch{return!1}}function li(e){let t=mi(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 ui(e){try{return li(e),!0}catch{return!1}}let di={"^":[`(`,`[`,`!`,`~`,`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 fi(e){let t=mi(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=di[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 pi(e){let t=mi(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 mi(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 hi(e,t){try{return gi(e,t),!0}catch{return!1}}function gi(e,t){si(t);let n=mi(t).slice(1,-1),r=Qr(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 _i(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}=Si(n),o=xi(a);return gi(o,t),{functionName:r,isRepeating:i,inputs:o}}function vi(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 yi(e){try{let t=Ei(e)[0];return Ee(t)!==void 0}catch{return!1}}function bi(e){return!vi(e)&&!yi(e)}function xi(e){let t=e.map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?[]:t.map((e,t)=>t===0&&!yi(e)?{type:`config`,value:e}:yi(e)?{type:`color-stop`,value:e}:vi(e)?{type:`color-hint`,value:e}:{type:`config`,value:e})}function Si(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=Ci(e,t);if(i===-1)throw Error(`Unclosed function parenthesis`);let a=wi(e.slice(t+1,i));return{functionName:n,isRepeating:r,inputs:a}}function Ci(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 wi(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){Ti(t,n),n=``;continue}n+=s}return Ti(t,n),t}function Ti(e,t){let n=t.trim();n.length>0&&e.push(n)}function Ei(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 Di=[`oklab`,`lch`,`oklch`,`hsl`,`hwb`,`lab`,`srgb`,`srgb-linear`,`xyz`,`display-p3`,`a98-rgb`,`prophoto-rgb`,`rec2020`],Oi=[`shorter`,`longer`,`increasing`,`decreasing`],ki=[`hsl`,`hwb`,`lch`,`oklch`];function B(e){return Oi.includes(e)}function V(e){return Di.includes(e)}function Ai(e){return ki.includes(e)}var ji=class{type;_config;constructor(e,t){this.type=e,this._config=this._cloneConfig(t),this._validateConfig(this._config)}getConfig(){return this._cloneConfig(this._config)}toJSON(){return{type:this.type,config:this.getConfig()}}_cloneConfig(e){return structuredClone(e)}},Mi=class e extends ji{_stops=[];constructor(t,n,r){r.interpolation=e._normalizeConfigInterpolation(r.interpolation),super(t,r),this._stops=this._getSortedStops(this._cloneStops(n)),this._validateStops(this._stops)}static fromAbi(e){throw Error(`Gradient deserialization from ABI is not implemented in Base class. Please use specific gradient type classes.`)}static fromString(e){return this.fromAbi(_i(e))}static _normalizeConfigInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ai(t)?{colorSpace:t}:{colorSpace:t,hue:n}}isRepeating(){return this.getConfig().isRepeating??!1}minColorStopsCount(){return 1}getStops(){return this._cloneStops(this._stops)}toJSON(){return{...super.toJSON(),stops:this.getStops()}}addStop(e){let t=[...this._cloneStops(this._stops),...this._cloneStops([e])],n=this._getSortedStops(t);this._validateStops(n),this._stops=n}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)}_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])}%`)}_buildSerializedStopTokens(){let e=[],t=this.getStops();for(let n=0;n<t.length;n++){let r=t[n];if(r.type===`color-hint`){e.push({type:`color-hint`,position:r.position});continue}let i=t[n+1];if(i&&i.type===`color-stop`&&i.value===r.value){e.push({type:`color-stop`,value:r.value,positions:[r.position,i.position]}),n+=1;continue}e.push({type:`color-stop`,value:r.value,positions:[r.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}_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`,position:this._parsePosition(n.value)});continue}if(n.type===`color-stop`){t.push(...this._parseColorStopInput(n.value));continue}throw SyntaxError(`Unsupported gradient stop 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=Ei(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(`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(`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 e.type===`color-stop`?{type:e.type,value:e.value,position:e.position}:{type:e.type,position:e.position}})}_cloneStops(e){return structuredClone(e)}_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`);let e=t.type;if(e!==`color-stop`&&e!==`color-hint`)throw TypeError(`Invalid gradient stop type: ${String(e)}`);if(t.type===`color-stop`&&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`)}}};let Ni=[`deg`,`rad`,`turn`,`grad`],Pi=[`px`,`em`,`rem`,`vw`,`vh`,`vmin`,`vmax`,`cm`,`mm`,`in`,`pt`,`pc`];function Fi(e){let t=e.match(/^([+-]?(?:\d+\.?\d*|\.\d+))(deg|rad|turn|grad)$/);if(t===null||!Gi(t[2]))throw SyntaxError(`Invalid gradient angle: "${e}"`);return{kind:`angle`,value:Number(t[1]),unit:t[2]}}function Ii(e){return`${e.value}${e.unit}`}function Li(e){let t=e.match(/^([+-]?(?:\d+\.?\d*|\.\d+))%$/);if(t!==null)return{kind:`percent`,value:Number(t[1])};let n=e.match(/^([+-]?(?:\d+\.?\d*|\.\d+))([a-z]+)$/);if(n===null||!Ki(n[2]))throw SyntaxError(`Invalid gradient length-percentage: "${e}"`);return{kind:`length`,value:Number(n[1]),unit:n[2]}}function H(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}function Ri(e){return e===void 0?!1:/^([+-]?(?:\d+\.?\d*|\.\d+))%$/.test(e)||/^([+-]?(?:\d+\.?\d*|\.\d+))[a-z]+$/.test(e)}function zi(e){if(e.length===0)throw SyntaxError(`Gradient position cannot be empty`);if(e.length>2)throw SyntaxError(`Invalid gradient position: ${e.join(` `)}`);let t=e.every(e=>Ri(e)),n=e.some(e=>Ri(e));if(t){if(e.length!==2)throw SyntaxError(`Invalid gradient position: ${e.join(` `)}`);return{kind:`values`,x:Li(e[0]),y:Li(e[1])}}if(n)throw SyntaxError(`Invalid mixed gradient position: ${e.join(` `)}`);return Wi(e)}function Bi(e){return e.kind===`keywords`?`${e.x} ${e.y}`:`${H(e.x)} ${H(e.y)}`}function Vi(e){if(typeof e!=`object`||!e)throw TypeError(`Gradient angle must be an object`);if(e.kind!==`angle`)throw TypeError(`Gradient angle kind must be "angle"`);if(typeof e.value!=`number`||!Number.isFinite(e.value))throw TypeError(`Gradient angle value must be finite`);if(!Gi(e.unit))throw TypeError(`Invalid gradient angle unit: "${String(e.unit)}"`)}function U(e){if(typeof e!=`object`||!e)throw TypeError(`Gradient length-percentage must be an object`);if(typeof e.value!=`number`||!Number.isFinite(e.value))throw TypeError(`Gradient length-percentage value must be finite`);if(e.kind!==`percent`&&!(e.kind===`length`&&Ki(e.unit)))throw TypeError(`Invalid gradient length-percentage`)}function Hi(e){if(typeof e!=`object`||!e)throw TypeError(`Gradient position must be an object`);if(e.kind===`keywords`){if(!qi(e.x)||!Ji(e.y))throw TypeError(`Invalid gradient keyword position`);return}if(e.kind===`values`){U(e.x),U(e.y);return}throw TypeError(`Invalid gradient position kind: "${String(e.kind)}"`)}function Ui(e){return e.kind===`keywords`&&e.x===`center`&&e.y===`center`}function Wi(e){for(let t of e)if(!qi(t)&&!Ji(t))throw SyntaxError(`Invalid gradient position token: "${t}"`);let t=e.includes(`left`),n=e.includes(`right`),r=e.includes(`top`),i=e.includes(`bottom`);if(t&&n||r&&i)throw SyntaxError(`Invalid gradient position: ${e.join(` `)}`);return{kind:`keywords`,x:t?`left`:n?`right`:`center`,y:r?`top`:i?`bottom`:`center`}}function Gi(e){return Ni.includes(e)}function Ki(e){return Pi.includes(e)}function qi(e){return e===`left`||e===`center`||e===`right`}function Ji(e){return e===`top`||e===`center`||e===`bottom`}var Yi=class e extends Mi{static DEFAULT_CONFIG={angle:Math.PI,interpolation:{colorSpace:`srgb`},isRepeating:!1};constructor(t,n){super(`linear-gradient`,t,e._resolveConfig(n))}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`);return e._resolveConfig({angle:i?e._parseAngleToken(i.value):void 0,interpolation:{colorSpace:a?.value??e.DEFAULT_CONFIG.interpolation.colorSpace,hue:o?.value}})}static fromString(t){return e.fromAbi(_i(t))}static fromAbi(t){if(t.functionName!==`linear-gradient`)throw Error(`Invalid function name for GradientLinear`);let n=t.inputs[0]?.type===`config`?e.normalizeConfig(t.inputs[0].value):e._resolveConfig(),r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs;return new e(e._normalizeAbiInputsToStops(r),{...n,isRepeating:t.isRepeating})}clone(){let t=this.toJSON();return new e(t.stops,t.config)}equals(t){return t instanceof e&&JSON.stringify(this.toJSON())===JSON.stringify(t.toJSON())}toJSON(){return super.toJSON()}toString(){return`${this.isRepeating()?`repeating-${this.type}`:this.type}(${[this._serializeConfig(this.getConfig()),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){if(typeof e.angle!=`number`||!Number.isFinite(e.angle))throw TypeError(`Linear gradient angle must be a finite number`);if(e.isRepeating!==void 0&&typeof e.isRepeating!=`boolean`)throw TypeError(`Linear gradient repeating flag must be a boolean`);if(typeof e.interpolation!=`object`||e.interpolation===null)throw TypeError(`Linear gradient interpolation must be an object`);if(!V(e.interpolation.colorSpace))throw TypeError(`Invalid linear gradient color space: "${String(e.interpolation.colorSpace)}"`);if(e.interpolation.hue!==void 0&&!B(e.interpolation.hue))throw TypeError(`Invalid linear gradient hue interpolation: "${String(e.interpolation.hue)}"`)}static _resolveConfig(t={}){let n={...e.DEFAULT_CONFIG.interpolation,...t.interpolation};return{angle:g(t.angle??e.DEFAULT_CONFIG.angle),interpolation:n,isRepeating:t.isRepeating??e.DEFAULT_CONFIG.isRepeating}}static _parseAngleToken(e){if(!e.startsWith(`to `))return g(u(e));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`),s=n.includes(`left`);if(i&&o||s&&a)throw SyntaxError(`Linear gradient keyword direction contains conflicting tokens`);if(i&&s)return d(315);if(i&&a)return d(45);if(o&&s)return d(225);if(o&&a)return d(135);if(i)return d(0);if(a)return d(90);if(o)return d(180);if(s)return d(270);throw SyntaxError(`Unsupported linear gradient keyword direction: "${e}"`)}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||!V(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),r.push({type:`angle`,value:`to ${t.join(` `)}`}),e+=t.length;continue}if(B(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}_serializeConfig(e){return[this._serializeAngle(e.angle),this._serializeInterpolation(e.interpolation)].filter(Boolean).join(` `)}_serializeAngle(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`}}_serializeInterpolation(e){if(this._isDefaultInterpolation(e))return``;let{colorSpace:t,hue:n}=e;return n===void 0?`in ${t}`:`in ${t} ${n} hue`}_isDefaultInterpolation(t){return t.colorSpace===e.DEFAULT_CONFIG.interpolation.colorSpace&&t.hue===void 0}};let Xi=[`px`,`em`,`rem`,`vw`,`vh`,`vmin`,`vmax`,`cm`,`mm`,`in`,`pt`,`pc`];var W=class e extends Mi{static gradientType=`radial-gradient`;static DEFAULT_CONFIG={shape:`ellipse`,size:{kind:`extent`,value:`farthest-corner`},position:{kind:`keywords`,x:`center`,y:`center`},interpolation:{colorSpace:`srgb`},isRepeating:!1};constructor(t,n){super(new.target.gradientType,t,e._resolveConfig(n))}static normalizeConfig(t){let n=t.trim().toLowerCase();if(n.length===0)throw SyntaxError(`Radial gradient config cannot be empty`);return e._parseConfigInput(n)}static fromString(t){return e.fromAbi(_i(t))}static fromAbi(t){if(t.functionName!==`radial-gradient`)throw Error(`Invalid function name for GradientRadial`);let n=e._parseConfig(t.inputs),r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs;return new e(e._normalizeAbiInputsToStops(r),{...n,isRepeating:t.isRepeating})}clone(){let t=this.toJSON();return new e(t.stops,t.config)}equals(t){return t instanceof e&&JSON.stringify(this.toJSON())===JSON.stringify(t.toJSON())}minColorStopsCount(){return 2}toJSON(){return super.toJSON()}toString(){return`${this.isRepeating()?`repeating-${this.type}`:this.type}(${[this._serializeConfig(this.getConfig()),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(t){if(!e._isShape(t.shape))throw TypeError(`Invalid radial gradient shape: "${String(t.shape)}"`);if(this._validateSize(t.size),this._validatePosition(t.position),t.isRepeating!==void 0&&typeof t.isRepeating!=`boolean`)throw TypeError(`Radial gradient repeating flag must be a boolean`);if(typeof t.interpolation!=`object`||t.interpolation===null)throw TypeError(`Radial gradient interpolation must be an object`);if(!V(t.interpolation.colorSpace))throw TypeError(`Invalid radial gradient color space: "${String(t.interpolation.colorSpace)}"`);if(t.interpolation.hue!==void 0&&!B(t.interpolation.hue))throw TypeError(`Invalid radial gradient hue interpolation: "${String(t.interpolation.hue)}"`)}static _resolveConfig(t={}){let n={...e.DEFAULT_CONFIG.interpolation,...t.interpolation};return{shape:t.shape??e.DEFAULT_CONFIG.shape,size:structuredClone(t.size??e.DEFAULT_CONFIG.size),position:structuredClone(t.position??e.DEFAULT_CONFIG.position),interpolation:n,isRepeating:t.isRepeating??e.DEFAULT_CONFIG.isRepeating}}static _parseConfig(t){let n=t.find(e=>e.type===`config`);return n===void 0?e._resolveConfig():e.normalizeConfig(n.value)}static _parseConfigInput(t){let n=Ei(t),r={},i=!1,a=!1,o=!1,s=!1;for(let t=0;t<n.length;t+=1){let c=n[t];if(e._isShape(c)){if(i)throw SyntaxError(`Duplicate radial gradient shape`);r.shape=c,i=!0;continue}if(e._isExtent(c)){if(a)throw SyntaxError(`Duplicate radial gradient size`);r.size={kind:`extent`,value:c},a=!0;continue}if(e._isLengthPercentageToken(c)){if(a)throw SyntaxError(`Duplicate radial gradient size`);let i=n[t+1];(r.shape??e.DEFAULT_CONFIG.shape)===`ellipse`&&e._isLengthPercentageToken(i)?(r.size={kind:`explicit`,x:e._parseLengthPercentage(c),y:e._parseLengthPercentage(i)},t+=1):r.size={kind:`explicit`,x:e._parseLengthPercentage(c)},a=!0;continue}if(c===`at`){if(o)throw SyntaxError(`Duplicate radial gradient position`);let i=[];for(let e=t+1;e<n.length;e+=1){let t=n[e];if(t===`in`)break;i.push(t)}r.position=e._parseRadialPosition(i),t+=i.length,o=!0;continue}if(c===`in`){if(s)throw SyntaxError(`Duplicate radial gradient interpolation`);let e=n[t+1];if(e===void 0||!V(e))throw SyntaxError(`Invalid radial-gradient interpolation: missing color space`);let i=n[t+2],a=n[t+3];if(i!==void 0){if(!B(i))throw SyntaxError(`Invalid radial-gradient hue interpolation: "${i}"`);if(a!==`hue`)throw SyntaxError(`Expected "hue" after "${i}"`);r.interpolation={colorSpace:e,hue:i},t+=3}else r.interpolation={colorSpace:e},t+=1;s=!0;continue}throw SyntaxError(`Unknown radial gradient config token: "${c}"`)}return e._resolveConfig(r)}static _parseRadialPosition(t){if(t.length===0)throw SyntaxError(`Radial gradient position cannot be empty`);if(t.length>2)throw SyntaxError(`Invalid radial-gradient position: ${t.join(` `)}`);let n=t.every(t=>e._isLengthPercentageToken(t)),r=t.some(t=>e._isLengthPercentageToken(t));if(n){if(t.length!==2)throw SyntaxError(`Invalid radial-gradient position: ${t.join(` `)}`);return{kind:`values`,x:e._parseLengthPercentage(t[0]),y:e._parseLengthPercentage(t[1])}}if(r)throw SyntaxError(`Invalid mixed radial-gradient position: ${t.join(` `)}`);return e._parseKeywordPosition(t)}static _parseKeywordPosition(t){for(let n of t)if(!e._isPositionKeywordX(n)&&!e._isPositionKeywordY(n))throw SyntaxError(`Invalid radial-gradient position token: "${n}"`);let n=t.includes(`left`),r=t.includes(`right`),i=t.includes(`top`),a=t.includes(`bottom`);if(n&&r||i&&a)throw SyntaxError(`Invalid radial-gradient position: ${t.join(` `)}`);return{kind:`keywords`,x:n?`left`:r?`right`:`center`,y:i?`top`:a?`bottom`:`center`}}static _parseLengthPercentage(t){let n=t.match(/^([+-]?(?:\d+\.?\d*|\.\d+))%$/);if(n!==null)return{kind:`percent`,value:Number(n[1])};let r=t.match(/^([+-]?(?:\d+\.?\d*|\.\d+))([a-z]+)$/);if(r===null||!e._isLengthUnit(r[2]))throw SyntaxError(`Invalid length-percentage: "${t}"`);return{kind:`length`,value:Number(r[1]),unit:r[2]}}static _isShape(e){return e===`circle`||e===`ellipse`}static _isExtent(e){return e===`closest-side`||e===`closest-corner`||e===`farthest-side`||e===`farthest-corner`}static _isLengthPercentageToken(e){return e===void 0?!1:/^([+-]?(?:\d+\.?\d*|\.\d+))%$/.test(e)||/^([+-]?(?:\d+\.?\d*|\.\d+))[a-z]+$/.test(e)}static _isLengthUnit(e){return Xi.includes(e)}static _isPositionKeywordX(e){return e===`left`||e===`center`||e===`right`}static _isPositionKeywordY(e){return e===`top`||e===`center`||e===`bottom`}_serializeConfig(e){return[this._serializeRadialConfig(e),this._serializeInterpolation(e.interpolation)].filter(Boolean).join(` `)}_serializeRadialConfig(e){let t=[];return this._isDefaultShape(e.shape)||t.push(e.shape),this._isDefaultSize(e.size)||t.push(this._serializeSize(e.size)),this._isDefaultPosition(e.position)||t.push(`at ${this._serializePosition(e.position)}`),t.join(` `)}_serializeSize(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)}`}_serializePosition(e){return e.kind===`keywords`?`${e.x} ${e.y}`:`${this._formatLengthPercentage(e.x)} ${this._formatLengthPercentage(e.y)}`}_serializeInterpolation(e){return this._isDefaultInterpolation(e)?``:e.hue===void 0?`in ${e.colorSpace}`:`in ${e.colorSpace} ${e.hue} hue`}_formatLengthPercentage(e){return e.kind===`percent`?`${e.value}%`:`${e.value}${e.unit}`}_isDefaultShape(t){return t===e.DEFAULT_CONFIG.shape}_isDefaultSize(t){return t.kind===`extent`&&e.DEFAULT_CONFIG.size.kind===`extent`&&t.value===e.DEFAULT_CONFIG.size.value}_isDefaultPosition(t){let n=e.DEFAULT_CONFIG.position;return t.kind===`keywords`&&n.kind===`keywords`&&t.x===n.x&&t.y===n.y}_isDefaultInterpolation(t){return t.colorSpace===e.DEFAULT_CONFIG.interpolation.colorSpace&&t.hue===void 0}_validateSize(t){if(typeof t!=`object`||!t)throw TypeError(`Radial gradient size must be an object`);if(t.kind===`extent`){if(!e._isExtent(t.value))throw TypeError(`Invalid radial gradient extent: "${String(t.value)}"`);return}if(t.kind===`explicit`){this._validateLengthPercentage(t.x),t.y!==void 0&&this._validateLengthPercentage(t.y);return}throw TypeError(`Invalid radial gradient size kind: "${String(t.kind)}"`)}_validatePosition(t){if(typeof t!=`object`||!t)throw TypeError(`Radial gradient position must be an object`);if(t.kind===`keywords`){if(!e._isPositionKeywordX(t.x)||!e._isPositionKeywordY(t.y))throw TypeError(`Invalid radial gradient keyword position`);return}if(t.kind===`values`){this._validateLengthPercentage(t.x),this._validateLengthPercentage(t.y);return}throw TypeError(`Invalid radial gradient position kind: "${String(t.kind)}"`)}_validateLengthPercentage(t){if(typeof t!=`object`||!t)throw TypeError(`Gradient length-percentage must be an object`);if(typeof t.value!=`number`||!Number.isFinite(t.value))throw TypeError(`Gradient length-percentage value must be finite`);if(t.kind!==`percent`&&!(t.kind===`length`&&e._isLengthUnit(t.unit)))throw TypeError(`Invalid gradient length-percentage`)}},Zi=class e extends Mi{static DEFAULT_CONFIG={from:{kind:`angle`,value:0,unit:`deg`},position:{kind:`keywords`,x:`center`,y:`center`},interpolation:{colorSpace:`srgb`},isRepeating:!1};constructor(t,n){super(`conic-gradient`,t,e._resolveConfig(n))}static normalizeConfig(t){let n=t.trim().toLowerCase();if(n.length===0)throw SyntaxError(`Conic gradient config cannot be empty`);return e._parseConfigInput(n)}static fromString(t){return e.fromAbi(_i(t))}static fromAbi(t){if(t.functionName!==`conic-gradient`)throw Error(`Invalid function name for GradientConic`);let n=t.inputs.find(e=>e.type===`config`),r=n?e.normalizeConfig(n.value):e._resolveConfig(),i=t.inputs.filter(e=>e.type!==`config`);return new e(e._normalizeAbiInputsToStops(i),{...r,isRepeating:t.isRepeating})}clone(){let t=this.toJSON();return new e(t.stops,t.config)}equals(t){return t instanceof e&&JSON.stringify(this.toJSON())===JSON.stringify(t.toJSON())}minColorStopsCount(){return 2}toJSON(){return super.toJSON()}toString(){return`${this.isRepeating()?`repeating-${this.type}`:this.type}(${[this._serializeConfig(this.getConfig()),...this._serializeStopsCompact()].filter(Boolean).join(`, `)})`}_validateConfig(e){if(Vi(e.from),Hi(e.position),e.isRepeating!==void 0&&typeof e.isRepeating!=`boolean`)throw TypeError(`Conic gradient repeating flag must be a boolean`);if(typeof e.interpolation!=`object`||e.interpolation===null)throw TypeError(`Conic gradient interpolation must be an object`);if(!V(e.interpolation.colorSpace))throw TypeError(`Invalid conic gradient color space: "${String(e.interpolation.colorSpace)}"`);if(e.interpolation.hue!==void 0&&!B(e.interpolation.hue))throw TypeError(`Invalid conic gradient hue interpolation: "${String(e.interpolation.hue)}"`)}static _resolveConfig(t={}){let n={...e.DEFAULT_CONFIG.interpolation,...t.interpolation};return{from:structuredClone(t.from??e.DEFAULT_CONFIG.from),position:structuredClone(t.position??e.DEFAULT_CONFIG.position),interpolation:n,isRepeating:t.isRepeating??e.DEFAULT_CONFIG.isRepeating}}static _parseConfigInput(t){let n=Ei(t),r={},i=!1,a=!1,o=!1;for(let e=0;e<n.length;e+=1){let t=n[e];if(t===`from`){if(i)throw SyntaxError(`Duplicate conic gradient from angle`);let t=n[e+1];if(t===void 0)throw SyntaxError(`Invalid conic-gradient config: missing angle after from`);r.from=Fi(t),i=!0,e+=1;continue}if(t===`at`){if(a)throw SyntaxError(`Duplicate conic gradient position`);let t=[];for(let r=e+1;r<n.length;r+=1){let e=n[r];if(e===`in`)break;t.push(e)}r.position=zi(t),a=!0,e+=t.length;continue}if(t===`in`){if(o)throw SyntaxError(`Duplicate conic gradient interpolation`);let t=n[e+1];if(t===void 0||!V(t))throw SyntaxError(`Invalid conic-gradient interpolation: missing color space`);let i=n[e+2],a=n[e+3];if(i!==void 0){if(!B(i))throw SyntaxError(`Invalid conic-gradient hue interpolation: "${i}"`);if(a!==`hue`)throw SyntaxError(`Expected "hue" after "${i}"`);r.interpolation={colorSpace:t,hue:i},o=!0,e+=3;continue}r.interpolation={colorSpace:t},o=!0,e+=1;continue}throw SyntaxError(`Unknown conic gradient config token: "${t}"`)}return e._resolveConfig(r)}_serializeConfig(e){let t=[];this._isDefaultFrom(e.from)||t.push(`from ${Ii(e.from)}`),Ui(e.position)||t.push(`at ${Bi(e.position)}`);let n=this._serializeInterpolation(e.interpolation);return n.length>0&&t.push(n),t.join(` `)}_serializeInterpolation(e){return this._isDefaultInterpolation(e)?``:e.hue===void 0?`in ${e.colorSpace}`:`in ${e.colorSpace} ${e.hue} hue`}_isDefaultFrom(e){return e.value===0&&e.unit===`deg`}_isDefaultInterpolation(t){return t.colorSpace===e.DEFAULT_CONFIG.interpolation.colorSpace&&t.hue===void 0}},Qi=class e extends W{static gradientType=`diamond-gradient`;constructor(e,t){super(e,t)}static fromString(t){return e.fromAbi(_i(t))}static fromAbi(t){if(t.functionName!==`diamond-gradient`)throw Error(`Invalid function name for GradientDiamond`);let n=this._parseConfig(t.inputs),r=t.inputs[0]?.type===`config`?t.inputs.slice(1):t.inputs;return new e(this._normalizeAbiInputsToStops(r),{...n,isRepeating:t.isRepeating})}clone(){let t=this.toJSON();return new e(t.stops,t.config)}equals(t){return t instanceof e&&JSON.stringify(this.toJSON())===JSON.stringify(t.toJSON())}toJSON(){return super.toJSON()}};let $i=T(`rgb`);function ea(e){switch(e){case`longer`:return Ue;case`increasing`:return We;case`decreasing`:return Ge;default:return P}}function ta(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 na(e){let t=de(e);if(t===void 0)throw Error(`Unsupported Culori color mode: ${e}`);return t.channels.filter(e=>e!==`alpha`)}function ra(e){if(e.hue!==void 0)return{h:{fixup:ea(e.hue)}}}function ia(e,t,n){return Math.min(n,Math.max(t,e))}function aa(e){return ia(e,0,1)}function oa(e,t){return ia(e,0,t-1)}function sa(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 ca(e){let t=e%360;return t<0?t+360:t}function la(e){let t=$i(e);if(!t)throw Error(`Failed to convert sampled mesh color to rgb`);let n=Br(t);if(n===void 0)throw Error(`Failed to format sampled mesh color`);return n}function ua(e){let t=$i(e);if(!t)throw Error(`Failed to convert sampled mesh color to rgb`);return[aa(t.r??0),aa(t.g??0),aa(t.b??0),aa(t.alpha??1)]}function da(e){let t=e.match(/^v(\d+)[_-](\d+)$/);if(t!==null)return{column:Number(t[1]),row:Number(t[2])};let n=e.match(/^v(\d)(\d)$/);return n===null?null:{column:Number(n[1]),row:Number(n[2])}}function fa(e,t){let n=pa(e,t);if(n===null)throw Error(`Bicubic mesh sampling requires regular vertex ids such as v00, v10, v01, v11`);return n}function pa(e,t){let n=Array.from({length:t.rows},()=>Array.from({length:t.columns}));for(let r of e){let e=da(r.id);if(e===null||e.row<0||e.column<0||e.row>=t.rows||e.column>=t.columns||n[e.row][e.column]!==void 0)return null;n[e.row][e.column]=r}return n.some(e=>e.some(e=>e===void 0))?null:n}function ma(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 ha(e,t){let n=[...e];for(let e=1;e<n.length;e+=1){let r=n[e-1],i=n[e];if(t===`increasing`)for(;i<r;)i+=360;else if(t===`decreasing`)for(;i>r;)i-=360;else if(t===`longer`){let e=i-r;e>0&&e<180?i-=360:e<0&&e>-180&&(i+=360)}else{for(;i-r>180;)i-=360;for(;i-r<-180;)i+=360}n[e]=i}return n}function ga(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=new Map(t.map(e=>[e.id,e])),a=ta(n.interpolation.colorSpace),o=ra(n.interpolation),s=new Map,c;function l(e){let t=r.get(e);if(t===void 0)throw Error(`Mesh vertex not found: ${e}`);return t}function u(e){let t=i.get(e);if(t===void 0)throw Error(`Mesh patch not found: ${e}`);return t}function d(e,t){let n=`${e}\u0000${t}`,r=s.get(n);if(r!==void 0)return r;let i=Xr([e,t],a,o);return s.set(n,i),i}function f(e,t,n){return typeof e==`string`&&typeof t==`string`?d(e,t)(n):Xr([e,t],a,o)(n)}function p(e,t,n){let r=l(e.topLeft),i=l(e.topRight),a=l(e.bottomRight),o=l(e.bottomLeft);return f(f(r.color,i.color,t),f(o.color,a.color,t),n)}function m(){let r=fa(e,n),i=na(a),o=T(a),s=new Map,c=new Map;for(let t of e){let e=new Map,n=$i(t.color);if(!n)throw Error(`Failed to convert mesh vertex color: ${t.color}`);e.set(`alpha`,n.alpha??1);let r=o(t.color);if(r===void 0)throw Error(`Failed to convert mesh vertex color: ${t.color}`);for(let t of i){let n=r[t];e.set(t,typeof n==`number`&&Number.isFinite(n)?n:0)}s.set(t.id,e)}for(let e of t)c.set(e.id,ma(r,e));return{grid:r,patchCells:c,mode:a,channels:i,hue:n.interpolation.hue,vertexChannels:s}}function h(){return c??=m(),c}function g(e,t,n){let r=e.vertexChannels.get(t.id);if(r===void 0)throw Error(`Failed to read mesh vertex color: ${t.color}`);return r.get(n)??0}function _(e,t,n,r,i,a){let o=e.grid.length,s=e.grid[0]?.length??0,c=[];for(let a=-1;a<=2;a+=1){let l=e.grid[oa(t+a,o)],u=[g(e,l[oa(n-1,s)],r),g(e,l[oa(n,s)],r),g(e,l[oa(n+1,s)],r),g(e,l[oa(n+2,s)],r)],d=r===`h`?ha(u,e.hue):u;c.push(sa(d[0],d[1],d[2],d[3],i))}let l=r===`h`?ha(c,e.hue):c,u=sa(l[0],l[1],l[2],l[3],a);return r===`h`?ca(u):u}function v(e,t,n){let r=h(),i=r.patchCells.get(e.id);if(i===void 0)throw Error(`Mesh patch does not match adjacent regular grid vertices: ${e.id}`);let a={mode:r.mode};for(let e of r.channels)a[e]=_(r,i.row,i.column,e,t,n);return a.alpha=aa(_(r,i.row,i.column,`alpha`,t,n)),a}function y(e,t,r){let i=u(e);return n.method===`bicubic`?v(i,t,r):p(i,t,r)}return{samplePatchColor:(e,t,n)=>la(y(e,t,n)),samplePatchColorRgb:(e,t,n)=>ua(y(e,aa(t),aa(n)))}}let _a=/^[A-Za-z_][A-Za-z0-9_-]*$/,va=[`top`,`right`,`bottom`,`left`];var ya=class e extends ji{static DEFAULT_CONFIG={rows:2,columns:2,method:`bilinear`,interpolation:{colorSpace:`srgb`}};_vertices;_patches;_colorSampler;constructor(t,n,r){super(`mesh-gradient`,e._resolveConfig(t,n,r)),this._vertices=structuredClone(t),this._patches=structuredClone(n),this._validateMesh()}static normalizeConfig(t){let n=Ei(t.trim().toLowerCase());if(n.length===0)throw SyntaxError(`Mesh gradient config cannot be empty`);return e._resolveConfig([],[],e._parseConfig(n))}static fromString(t){let{functionName:n,isRepeating:r,inputs:i}=e._parseFunction(t);if(n!==`mesh-gradient`)throw Error(`Invalid function name for GradientMesh`);if(r)throw Error(`GradientMesh does not support repeating gradients`);let a,o=[],s=[],c=[];for(let t of i){let n=Ei(t),r=n[0];if(r===`grid`){if(a!==void 0)throw Error(`mesh-gradient can only contain one grid config`);a=e._parseConfig(n);continue}if(r===`vertex`){o.push(e._parseVertex(n));continue}if(r===`patch`){s.push(e._parsePatch(n));continue}if(r===`handle`){c.push(e._parseHandle(n));continue}throw Error(`Unsupported mesh-gradient input: ${t}`)}return new e(o,e._attachHandles(s,c),a)}static fromAbi(t){if(t.functionName!==`mesh-gradient`)throw Error(`Invalid function name for GradientMesh`);if(t.isRepeating)throw Error(`GradientMesh does not support repeating gradients`);return e.fromString(`${t.functionName}(${t.inputs.map(e=>e.value).join(`, `)})`)}clone(){let t=this.toJSON();return new e(t.vertices,t.patches,t.config)}equals(t){return t instanceof e&&JSON.stringify(this.toJSON())===JSON.stringify(t.toJSON())}toJSON(){return{...super.toJSON(),vertices:this.getVertices(),patches:this.getPatches()}}toString(){let e=[this._serializeConfig(this.getConfig()),...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(`, `)})`}getVertices(){return structuredClone(this._vertices)}getPatches(){return structuredClone(this._patches)}getVertex(e){let t=this._vertices.find(t=>t.id===e);return t?structuredClone(t):null}getPatch(e){let t=this._patches.find(t=>t.id===e);return t?structuredClone(t):null}samplePatchColor(e,t,n){return this._validateSampleCoordinate(t,`u`),this._validateSampleCoordinate(n,`v`),this._getColorSampler().samplePatchColor(e,t,n)}_validateConfig(t){if(!Number.isInteger(t.rows)||t.rows<2)throw TypeError(`Mesh gradient rows must be an integer >= 2`);if(!Number.isInteger(t.columns)||t.columns<2)throw TypeError(`Mesh gradient columns must be an integer >= 2`);if(!e._isInterpolationMethod(t.method))throw TypeError(`Invalid mesh gradient interpolation method`);if(typeof t.interpolation!=`object`||t.interpolation===null)throw TypeError(`Mesh gradient interpolation must be an object`);if(!V(t.interpolation.colorSpace))throw TypeError(`Invalid mesh gradient color space: "${String(t.interpolation.colorSpace)}"`);if(t.interpolation.hue!==void 0&&!B(t.interpolation.hue))throw TypeError(`Invalid mesh gradient hue interpolation: "${String(t.interpolation.hue)}"`)}static _resolveConfig(t,n,r={}){let i=e._inferGridSize(t,n),a=r.rows??i?.rows??e.DEFAULT_CONFIG.rows,o=r.columns??i?.columns??e._inferMissingColumns(t,a)??e.DEFAULT_CONFIG.columns,s=e._normalizeInterpolation({colorSpace:r.interpolation?.colorSpace??e.DEFAULT_CONFIG.interpolation.colorSpace,hue:r.interpolation?.hue});return{rows:a,columns:o,method:r.method??e.DEFAULT_CONFIG.method,interpolation:s}}static _inferMissingColumns(e,t){if(e.length===0||!Number.isInteger(t)||t<2||e.length%t!==0)return;let n=e.length/t;return n>=2?n:void 0}static _inferGridSize(t,n){return e._inferGridSizeFromVertexIds(t)??e._inferGridSizeFromCounts(t.length,n.length)}static _inferGridSizeFromVertexIds(e){if(e.length===0)return;let t=e.map(e=>da(e.id));if(t.some(e=>e===null))return;let n=t,r=Math.max(...n.map(e=>e.row))+1,i=Math.max(...n.map(e=>e.column))+1;if(r*i===e.length)return{rows:r,columns:i}}static _inferGridSizeFromCounts(e,t){if(e<4||t<1)return;let n=[];for(let r=2;r<=e;r+=1){if(e%r!==0)continue;let i=e/r;i<2||(r-1)*(i-1)===t&&n.push({rows:r,columns:i})}return n.length===1?n[0]:n.find(e=>e.rows===e.columns)}static _parseConfig(t){if(t[0]!==`grid`||t.length<3)throw SyntaxError(`Invalid mesh grid config`);let n=Number(t[1]),r=Number(t[2]),i,a,o=!1,s=!1;for(let n=3;n<t.length;n+=1){let r=t[n];if(r===`method`){if(o)throw SyntaxError(`Duplicate mesh gradient method`);let r=t[n+1];if(!e._isInterpolationMethod(r))throw SyntaxError(`Invalid mesh gradient method: ${r}`);i=r,o=!0,n+=1;continue}if(r===`in`){if(s)throw SyntaxError(`Duplicate mesh gradient interpolation`);let e=t[n+1];if(e===void 0||!V(e))throw SyntaxError(`Invalid mesh-gradient interpolation: missing color space`);let r=t[n+2],i=t[n+3];if(r!==void 0&&i===`hue`){if(!B(r))throw SyntaxError(`Invalid mesh-gradient hue interpolation: "${r}"`);a={colorSpace:e,hue:r},s=!0,n+=3;continue}a={colorSpace:e},s=!0,n+=1;continue}throw SyntaxError(`Unsupported mesh grid config token: ${r}`)}return{rows:n,columns:r,method:i,interpolation:a}}static _parseVertex(t){if(t.length<5)throw SyntaxError(`Invalid mesh vertex input`);return{id:t[1],x:e._parseLengthPercentage(t[2]),y:e._parseLengthPercentage(t[3]),color:t.slice(4).join(` `)}}static _parsePatch(e){if(e.length!==6)throw SyntaxError(`Invalid mesh patch input`);return{id:e[1],topLeft:e[2],topRight:e[3],bottomRight:e[4],bottomLeft:e[5]}}static _parseHandle(t){if(t.length!==7)throw SyntaxError(`Invalid mesh handle input`);let n=t[2];if(!e._isPatchSide(n))throw SyntaxError(`Invalid mesh handle side: ${n}`);return{patchId:t[1],side:n,from:{x:e._parseLengthPercentage(t[3]),y:e._parseLengthPercentage(t[4])},to:{x:e._parseLengthPercentage(t[5]),y:e._parseLengthPercentage(t[6])}}}static _attachHandles(e,t){let n=e.map(e=>structuredClone(e)),r=new Map(n.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.patchId);if(t===void 0)throw Error(`Mesh handle references missing patch: ${e.patchId}`);if(t.handles??={},t.handles[e.side]!==void 0)throw Error(`Duplicate mesh handle for patch ${e.patchId} side ${e.side}`);t.handles[e.side]={from:e.from,to:e.to}}return n}static _parseLengthPercentage(e){return Li(e)}static _normalizeInterpolation(e){let{colorSpace:t,hue:n}=e;return n===void 0||!Ai(t)?{colorSpace:t}:{colorSpace:t,hue:n}}static _isInterpolationMethod(e){return e===`bilinear`||e===`bicubic`}static _isPatchSide(e){return e===`top`||e===`right`||e===`bottom`||e===`left`}static _parseFunction(t){let n=t.trim(),r=n.indexOf(`(`);if(r<=0)throw Error(`Expected mesh-gradient function call`);let i=n.slice(0,r).trim(),a=i.startsWith(`repeating-`);a&&(i=i.slice(10));let o=e._findOuterClosingParenIndex(n,r);if(o===-1)throw Error(`Unclosed mesh-gradient function parenthesis`);let s=n.slice(o+1).trim();if(s.length>0&&!s.startsWith(`${i}(`)&&!s.startsWith(`repeating-${i}(`))throw Error(`Unexpected mesh-gradient trailing input: ${s}`);return{functionName:i,isRepeating:a,inputs:e._splitTopLevelInputs(n.slice(r+1,o))}}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(t){let n=[],r=``,i=0,a=0,o=0;for(let s=0;s<t.length;s+=1){let c=t[s];if(c===`(`){i+=1,r+=c;continue}if(c===`)`){--i,r+=c;continue}if(c===`{`){a+=1,r+=c;continue}if(c===`}`){--a,r+=c;continue}if(c===`[`){o+=1,r+=c;continue}if(c===`]`){--o,r+=c;continue}if(c===`,`&&i===0&&a===0&&o===0){e._pushTrimmed(n,r),r=``;continue}r+=c}if(i!==0||a!==0||o!==0)throw Error(`Unbalanced mesh-gradient input parentheses`);return e._pushTrimmed(n,r),n}static _pushTrimmed(e,t){let n=t.trim();n.length>0&&e.push(n)}_validateMesh(){if(!Array.isArray(this._vertices))throw TypeError(`Mesh gradient vertices must be an array`);if(!Array.isArray(this._patches))throw TypeError(`Mesh gradient patches must be an array`);let e=this.getConfig(),t=e.rows*e.columns,n=(e.rows-1)*(e.columns-1);if(this._vertices.length!==t)throw Error(`Mesh gradient expected ${t} vertices for ${e.rows}x${e.columns} grid, received ${this._vertices.length}`);if(this._patches.length!==n)throw Error(`Mesh gradient expected ${n} patches for ${e.rows}x${e.columns} grid, received ${this._patches.length}`);let r=new Set;for(let e of this._vertices){if(this._validateId(e.id,`vertex`),r.has(e.id))throw Error(`Duplicate mesh vertex id: ${e.id}`);if(r.add(e.id),U(e.x),U(e.y),!Ee(e.color))throw Error(`Invalid mesh vertex color: ${e.color}`)}let i=new Set;for(let e of this._patches){if(this._validateId(e.id,`patch`),i.has(e.id))throw Error(`Duplicate mesh patch id: ${e.id}`);i.add(e.id),this._validatePatchVertices(e,r),this._validateHandles(e)}this._validateRegularPatchTopology()}_validateId(e,t){if(!_a.test(e))throw Error(`Invalid mesh ${t} id: ${e}`)}_validatePatchVertices(e,t){let n=[e.topLeft,e.topRight,e.bottomRight,e.bottomLeft];if(new Set(n).size!==4)throw Error(`Mesh patch must use 4 unique vertices: ${e.id}`);for(let e of n)if(!t.has(e))throw Error(`Mesh patch references missing vertex: ${e}`)}_validateHandles(e){if(e.handles!==void 0)for(let t of va){let n=e.handles[t];n!==void 0&&(U(n.from.x),U(n.from.y),U(n.to.x),U(n.to.y))}}_validateRegularPatchTopology(){let e=new Map;for(let t of this._vertices){let n=da(t.id);if(n===null)return;e.set(t.id,n)}let t=this.getConfig(),n=new Set;for(let[n,r]of e)if(r.row<0||r.column<0||r.row>=t.rows||r.column>=t.columns)throw Error(`Mesh vertex is outside grid topology: ${n}`);for(let t of this._patches){let r=e.get(t.topLeft),i=e.get(t.topRight),a=e.get(t.bottomRight),o=e.get(t.bottomLeft);if(r===void 0||i===void 0||a===void 0||o===void 0)return;if(!(i.row===r.row&&i.column===r.column+1&&a.row===r.row+1&&a.column===r.column+1&&o.row===r.row+1&&o.column===r.column))throw Error(`Mesh patch does not match adjacent regular grid vertices: ${t.id}`);let s=`${r.row}:${r.column}`;if(n.has(s))throw Error(`Duplicate mesh patch cell: ${t.id}`);n.add(s)}}_serializeConfig(e){let t=[`grid`,String(e.rows),String(e.columns),`method`,e.method],n=this._serializeInterpolation(e.interpolation);return n.length>0&&t.push(n),t.join(` `)}_serializeInterpolation(e){return this._isDefaultInterpolation(e)?``:e.hue===void 0?`in ${e.colorSpace}`:`in ${e.colorSpace} ${e.hue} hue`}_serializeVertex(e){return[`vertex`,e.id,H(e.x),H(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===void 0)return[];let t=[];for(let n of va){let r=e.handles[n];r!==void 0&&t.push([`handle`,e.id,n,H(r.from.x),H(r.from.y),H(r.to.x),H(r.to.y)].join(` `))}return t}_isDefaultInterpolation(t){return t.colorSpace===e.DEFAULT_CONFIG.interpolation.colorSpace&&t.hue===void 0}_validateSampleCoordinate(e,t){if(!Number.isFinite(e)||e<0||e>1)throw RangeError(`Mesh patch sample coordinate ${t} must be between 0 and 1`)}_getColorSampler(){return this._colorSampler??=ga(this._vertices,this._patches,this.getConfig()),this._colorSampler}};let ba={"linear-gradient":Yi,"radial-gradient":W,"diamond-gradient":Qi,"conic-gradient":Zi,"mesh-gradient":ya};var xa=class{static _registry=new Map;static _initialized=!1;static add(e,t){this._ensureInitialized(),this._registry.set(this._normalizeFunctionName(e),t)}static get(e){return this._ensureInitialized(),this._registry.get(this._normalizeFunctionName(e))??null}static remove(e){return this._ensureInitialized(),this._registry.delete(this._normalizeFunctionName(e))}static create(e){if(typeof e==`string`){let t=this._readFunctionName(e),n=this.get(t);if(!n)throw Error(`No gradient registered for: ${t}`);return n.fromString(e)}let t=this._normalizeFunctionName(e.functionName),n=this.get(t);if(!n)throw Error(`No gradient registered for: ${t}`);return n.fromAbi({...e,functionName:t})}static isValid(e){try{return this.create(e),!0}catch{return!1}}static _ensureInitialized(){this._initialized||(this._initialized=!0,this.add(`linear-gradient`,ba[`linear-gradient`]),this.add(`radial-gradient`,ba[`radial-gradient`]),this.add(`diamond-gradient`,ba[`diamond-gradient`]),this.add(`conic-gradient`,ba[`conic-gradient`]),this.add(`mesh-gradient`,ba[`mesh-gradient`]))}static _readFunctionName(e){let t=e.trim(),n=t.indexOf(`(`);if(n<=0)throw Error(`Expected gradient function call`);return this._normalizeFunctionName(t.slice(0,n))}static _normalizeFunctionName(e){let t=e.trim().toLowerCase();return t.startsWith(`repeating-`)?t.slice(10):t}};function Sa(e){return xa.create(e)}function Ca(e){return xa.isValid(e)}function wa(e){return typeof e==`string`?Sa(e).toString():e.toString()}var G=class{target;gradientType;_gradientClass;_expectedName;constructor(e){this.target=e.target,this.gradientType=e.gradientType,this._gradientClass=e.gradientClass,this._expectedName=e.expectedName}to(e){return this.transform(this._expectGradient(e))}_expectGradient(e){if(!(e instanceof this._gradientClass))throw Error(`Expected ${this._expectedName}`);return e}},Ta=class extends G{transform(e){return e.toString()}},Ea=class extends Ta{constructor(){super({target:`css`,gradientType:`linear-gradient`,gradientClass:Yi,expectedName:`GradientLinear`})}},Da=class extends Ta{constructor(){super({target:`css`,gradientType:`radial-gradient`,gradientClass:W,expectedName:`GradientRadial`})}};function Oa(e){return e.type===`color-stop`&&e.position!=null}function K(e){return e.filter(Oa).sort((e,t)=>e.position-t.position)}function ka(e){return K(e).length}function Aa(e){let t=K(e);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 ja(e,t,n){let r=n-t||1;return K(e).map(e=>({...e,position:(e.position-t)/r}))}function Ma(e,t){let n=K(e);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,a=Br(Xr([r.value,i.value],`rgb`)(n));if(a===void 0)throw Error(`Failed to format sampled gradient color.`);return a}}return r.value}function Na(e,t){let n=K(e);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:Ma(n,i),position:i})}return r}function Pa(e,t){return(e%t+t)%t}function Fa(e,t,n,r){return Ma(e,n+Pa(t-n,r))}function Ia(e,t,n){let r=K(e);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:Fa(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:Fa(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 La(e){return Ia(e,0,1)}function Ra(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)}))}let za={colorSpace:`srgb`};function Ba(e){switch(e){case`longer`:return Ue;case`increasing`:return We;case`decreasing`:return Ge;default:return P}}function Va(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 Ha(e){if(e.hue!==void 0)return{h:{fixup:Ba(e.hue)}}}function Ua(e){return e.type===`color-hint`}function Wa(e){let t=e.filter(Oa);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 Ga(e){let t=[],n,r;for(let i of e){if(Oa(i)){n!==void 0&&t.push({from:n,to:i,hint:r}),n=i,r=void 0;continue}Ua(i)&&n!==void 0&&(r=i)}return t}function Ka(e){return e.some(Ua)}function qa(e,t,n=0,r=1){if(t===void 0)return e;let i=r-n;if(i===0)return e;let a=(t.position-n)/i;return a<=0?e<=0?0:1:a>=1?+(e>=1):Math.abs(a-.5)<1e-6?e:e**+(Math.log(.5)/Math.log(a))}function Ja(e,t){let n=Array.from({length:e+1},(t,n)=>n/e);if(t.hint===void 0)return n;let r=t.to.position-t.from.position;if(r===0)return n;let i=(t.hint.position-t.from.position)/r;if(i<=0||i>=1)return n;let a=Math.round(i*e);return n[a]=i,n}function Ya(e){let t=Xa(e);if(!t)throw Error(`Failed to convert interpolated color to rgb.`);let n=Br(t);if(n===void 0)throw Error(`Failed to format interpolated color to rgb.`);return n}let Xa=T(`rgb`);function q(e,t=64){let n=e.getStops(),r=Wa(n),i=e.getConfig().interpolation,a=i!==void 0||Ka(n);if(r.length<2)return r;if(!a)return e.isRepeating()?La(r):r;let o=[],s=i??za,c=Va(s.colorSpace),l=Ha(s),u=Ga(n);for(let e=0;e<u.length;e+=1){let n=u[e],r=n.from,i=n.to,a=r.position,s=i.position;if(a===s){e===0&&o.push(r),o.push(i);continue}let d=Xr([r.value,i.value],c,l),f=Ja(t,n);for(let t=0;t<f.length;t+=1){if(e>0&&t===0)continue;let r=f[t],i=qa(r,n.hint,a,s),c=a+(s-a)*r,l=d(i);o.push({type:`color-stop`,value:Ya(l),position:c})}}return e.isRepeating()?La(o):o}let J=1e-4;function Za(e){return Math.max(0,Math.min(1,e))}function Y(e,t=3){return`${Number(e.toFixed(t))}`}function X(e,t,n={}){if(e.kind===`percent`)return e.value/100*t;if(e.unit===`px`||n.allowUnsupportedUnitAsRaw)return e.value;let r=n.context??`gradient`;throw Error(`Unsupported ${r} length unit: ${e.unit}`)}function Qa(e,t){return e===`left`?0:e===`right`?t:t/2}function $a(e,t){return e===`top`?0:e===`bottom`?t:t/2}function Z(e,t,n,r={}){return e.kind===`keywords`?{x:Qa(e.x,t),y:$a(e.y,n)}:{x:X(e.x,t,r),y:X(e.y,n,r)}}function eo(e){return e.unit===`deg`?d(e.value):e.unit===`turn`?p(e.value):e.unit===`grad`?m(e.value):e.value}function to(e,t,n){let r=Math.sin(e),i=-Math.cos(e),a=t/2,o=n/2,s=Math.abs(t*r)+Math.abs(n*i);return{start:{x:a-r*s/2,y:o-i*s/2},end:{x:a+r*s/2,y:o+i*s/2}}}function no(e){let t=Math.sin(e),n=-Math.cos(e),r=Math.max(Math.abs(t),Math.abs(n),J),i=t/r,a=n/r;return{x1:50-i*50,y1:50-a*50,x2:50+i*50,y2:50+a*50}}function ro(e,t){return[{x:0,y:0},{x:e,y:0},{x:0,y:t},{x:e,y:t}]}function io(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function ao(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function oo(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 so(e,t,n,r){let i=Math.max(e,J),a=Math.max(t,J),o=Math.sqrt(n*n/(i*i)+r*r/(a*a));return{x:i*o,y:a*o}}function co(e,t,n,r){let i=Math.max(e,J),a=Math.max(t,J),o=Math.abs(n)/i+Math.abs(r)/a;return{x:i*o,y:a*o}}function lo(e,t,n,r,i,a={}){if(e.kind===`explicit`){let n=X(e.x,r,a),o=e.y?X(e.y,i,a):n;return{x:Math.max(n,J),y:Math.max(t===`circle`?n:o,J)}}let o=n.x,s=r-n.x,c=n.y,l=i-n.y;if(t===`circle`){let t=ro(r,i).map(e=>io(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(o,s,c,l),J);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(o,s,c,l),J);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),J);return{x:e,y:e}}let a=Math.max(Math.max(...t),J);return{x:a,y:a}}let u=Math.min(o,s),d=Math.min(c,l),f=Math.max(o,s),p=Math.max(c,l);if(e.value===`closest-side`)return{x:Math.max(u,J),y:Math.max(d,J)};if(e.value===`farthest-side`)return{x:Math.max(f,J),y:Math.max(p,J)};let m=oo(n,r,i);return e.value===`closest-corner`?m.map(e=>so(u,d,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):m.map(e=>so(f,p,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function uo(e,t,n,r,i,a={}){if(e.kind===`explicit`){let n=X(e.x,r,a),o=e.y?X(e.y,i,a):n;return{x:Math.max(n,J),y:Math.max(t===`circle`?n:o,J)}}let o=n.x,s=r-n.x,c=n.y,l=i-n.y;if(t===`circle`){let t=ro(r,i).map(e=>ao(n,e));if(e.value===`closest-side`){let e=Math.max(Math.min(o,s,c,l),J);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(Math.max(o,s,c,l),J);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.max(Math.min(...t),J);return{x:e,y:e}}let a=Math.max(Math.max(...t),J);return{x:a,y:a}}let u=Math.min(o,s),d=Math.min(c,l),f=Math.max(o,s),p=Math.max(c,l);if(e.value===`closest-side`)return{x:Math.max(u,J),y:Math.max(d,J)};if(e.value===`farthest-side`)return{x:Math.max(f,J),y:Math.max(p,J)};let m=oo(n,r,i);return e.value===`closest-corner`?m.map(e=>co(u,d,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):m.map(e=>co(f,p,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function fo(e,t,n,r){return Math.max(...ro(n,r).map(n=>Math.abs(n.x-e.x)/Math.max(t.x,J)+Math.abs(n.y-e.y)/Math.max(t.y,J)))}function po(e,t,n){return{id:e.id,x:X(e.x,t,{context:`mesh-gradient`}),y:X(e.y,n,{context:`mesh-gradient`}),color:ua(e.color)}}function mo(e,t,n){return new Map(e.map(e=>[e.id,po(e,t,n)]))}function ho(e,t,n){let r=go(e,t,n);if(r)return r;let i=t.map(e=>{let t=n.get(e.id);if(!t)throw Error(`Missing mesh vertex: ${e.id}`);return t}).sort((e,t)=>Math.abs(e.y-t.y)>1e-4?e.y-t.y:e.x-t.x),a=[];for(let t=0;t<e.rows;t+=1){let n=t*e.columns,r=n+e.columns;a.push(i.slice(n,r))}return a}function go(e,t,n){let r=Array.from({length:e.rows},()=>[]);for(let i of t){let t=da(i.id);if(t===null||t.row<0||t.column<0||t.row>=e.rows||t.column>=e.columns)return null;let a=n.get(i.id);if(!a)throw Error(`Missing mesh vertex: ${i.id}`);if(r[t.row][t.column])return null;r[t.row][t.column]=a}return r.some(t=>t.length!==e.columns||t.some(e=>e===void 0))?null:r}function _o(e,t,n){let r=e.getConfig(),i=e.getVertices(),a=e.getPatches(),o=mo(i,t,n);return{config:r,patches:a,vertexMap:o,grid:ho(r,i,o),sampler:ga(i,a,r)}}function vo(e){return Math.min(1,Math.max(0,e))}function yo(e,t,n){return e+(t-e)*n}function Q(e,t,n,r,i,a){let o=yo(e.x,t.x,i),s=yo(e.y,t.y,i),c=yo(r.x,n.x,i),l=yo(r.y,n.y,i);return{x:yo(o,c,a),y:yo(s,l,a)}}function bo(e,t,n,r){return e.samplePatchColorRgb(t,vo(n),vo(r))}function xo(e,t,n,r){let i=n.get(t.topLeft),a=n.get(t.topRight),o=n.get(t.bottomRight),s=n.get(t.bottomLeft);if(!i||!a||!o||!s)throw Error(`Mesh patch references missing vertex: ${t.id}`);let c=[];for(let n=0;n<=r;n+=1){let l=[],u=n/r;for(let c=0;c<=r;c+=1){let d=c/r,f=Q(i,a,o,s,d,u),p=bo(e,t.id,d,u);l.push({id:`${t.id}:${c}:${n}`,x:f.x,y:f.y,color:p})}c.push(l)}let l=[];for(let e=0;e<r;e+=1)for(let t=0;t<r;t+=1){let n=c[e][t],r=c[e][t+1],i=c[e+1][t+1],a=c[e+1][t];l.push([n,r,i],[n,i,a])}return l}function $(e,t,n,r,i,a,o){return{id:o,x:i,y:a,color:bo(e,t,n,r)}}function So(e,t,n,r){return`${e}\u0000${t}\u0000${n}\u0000${r}`}function Co(e){return new Map(e.map(e=>[So(e.topLeft,e.topRight,e.bottomRight,e.bottomLeft),e.id]))}function wo(e,t,n,r,i){let a=e.get(So(t.id,n.id,r.id,i.id));if(a===void 0)throw Error(`Missing mesh patch for cell ${t.id}/${n.id}/${r.id}/${i.id}`);return a}function To(e,t,n,r,i,a){let o=[],s=n.length,c=n[0]?.length??0;if(s<2||c<2)return o;let l=Co(t);for(let t=0;t<c-1;t+=1){let r=n[0][t],i=n[0][t+1],s=n[1][t+1],c=n[1][t],u=wo(l,r,i,s,c);for(let n=0;n<a;n+=1){let l=n/a,d=(n+1)/a,f=Q(r,i,s,c,l,0),p=Q(r,i,s,c,d,0),m=Q(r,i,s,c,l,1),h=Q(r,i,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=$(e,u,l,0,f.x,f.y,`top:${t}:${n}:b0`),y=$(e,u,d,0,p.x,p.y,`top:${t}:${n}:b1`),b=$(e,u,l,g,f.x,0,`top:${t}:${n}:p0`),x=$(e,u,d,_,p.x,0,`top:${t}:${n}:p1`);o.push([b,x,y],[b,y,v])}}for(let t=0;t<c-1;t+=1){let r=s-2,c=n[r][t],u=n[r][t+1],d=n[r+1][t+1],f=n[r+1][t],p=wo(l,c,u,d,f);for(let n=0;n<a;n+=1){let r=n/a,s=(n+1)/a,l=Q(c,u,d,f,r,0),m=Q(c,u,d,f,s,0),h=Q(c,u,d,f,r,1),g=Q(c,u,d,f,s,1),_=Math.max(1,(i-l.y)/Math.max(h.y-l.y,1e-4)),v=Math.max(1,(i-m.y)/Math.max(g.y-m.y,1e-4)),y=$(e,p,r,1,h.x,h.y,`bottom:${t}:${n}:b0`),b=$(e,p,s,1,g.x,g.y,`bottom:${t}:${n}:b1`),x=$(e,p,r,_,h.x,i,`bottom:${t}:${n}:p0`),S=$(e,p,s,v,g.x,i,`bottom:${t}:${n}:p1`);o.push([y,b,S],[y,S,x])}}for(let t=0;t<s-1;t+=1){let r=n[t][0],i=n[t][1],s=n[t+1][1],c=n[t+1][0],u=wo(l,r,i,s,c);for(let n=0;n<a;n+=1){let l=n/a,d=(n+1)/a,f=Q(r,i,s,c,0,l),p=Q(r,i,s,c,0,d),m=Q(r,i,s,c,1,l),h=Q(r,i,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=$(e,u,0,l,f.x,f.y,`left:${t}:${n}:b0`),y=$(e,u,0,d,p.x,p.y,`left:${t}:${n}:b1`),b=$(e,u,g,l,0,f.y,`left:${t}:${n}:p0`),x=$(e,u,_,d,0,p.y,`left:${t}:${n}:p1`);o.push([b,v,y],[b,y,x])}}for(let t=0;t<s-1;t+=1){let i=c-2,s=n[t][i],u=n[t][i+1],d=n[t+1][i+1],f=n[t+1][i],p=wo(l,s,u,d,f);for(let n=0;n<a;n+=1){let i=n/a,c=(n+1)/a,l=Q(s,u,d,f,0,i),m=Q(s,u,d,f,0,c),h=Q(s,u,d,f,1,i),g=Q(s,u,d,f,1,c),_=Math.max(1,(r-l.x)/Math.max(h.x-l.x,1e-4)),v=Math.max(1,(r-m.x)/Math.max(g.x-m.x,1e-4)),y=$(e,p,1,i,h.x,h.y,`right:${t}:${n}:b0`),b=$(e,p,1,c,g.x,g.y,`right:${t}:${n}:b1`),x=$(e,p,_,i,r,h.y,`right:${t}:${n}:p0`),S=$(e,p,v,c,r,g.y,`right:${t}:${n}:p1`);o.push([y,x,S],[y,S,b])}}return o}function Eo(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 Do(e,t,n,r){let[i,a,o]=e;return[t.color[0]*i+n.color[0]*a+r.color[0]*o,t.color[1]*i+n.color[1]*a+r.color[1]*o,t.color[2]*i+n.color[2]*a+r.color[2]*o,t.color[3]*i+n.color[3]*a+r.color[3]*o]}function Oo(e){let[t,n,r]=e;return[(t.color[0]+n.color[0]+r.color[0])/3,(t.color[1]+n.color[1]+r.color[1])/3,(t.color[2]+n.color[2]+r.color[2])/3,(t.color[3]+n.color[3]+r.color[3])/3]}function ko(e,t,n,r){let[i,a,o]=n,s=Math.max(0,Math.floor(Math.min(i.x,a.x,o.x))),c=Math.min(e-1,Math.ceil(Math.max(i.x,a.x,o.x))),l=Math.max(0,Math.floor(Math.min(i.y,a.y,o.y))),u=Math.min(t-1,Math.ceil(Math.max(i.y,a.y,o.y)));for(let e=l;e<=u;e+=1)for(let t=s;t<=c;t+=1){let n=Eo(t+.5,e+.5,i,a,o);n&&r(t,e,Do(n,i,a,o))}}let Ao=T(`rgb`);function jo(e){let t=Ao(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)}}function Mo(e){let t=jo(e);return[t.r,t.g,t.b,t.a]}function No(e){let t=Ao(e);if(!t)throw Error(`Failed to convert color: ${e}`);let n=Br(t);if(n===void 0)throw Error(`Failed to format color: ${e}`);return n}function Po(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)}}function Fo(e,t=4,n=`, `){return`rgba(${[e[0],e[1],e[2],Number(e[3].toFixed(t))].join(n)})`}function Io(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function Lo(e){return`url("data:image/svg+xml,${encodeURIComponent(e)}")`}function Ro(e,t,n){let r=t.x*n,i=t.y*n;return[`${Y(e.x)} ${Y(e.y-i)}`,`${Y(e.x+r)} ${Y(e.y)}`,`${Y(e.x)} ${Y(e.y+i)}`,`${Y(e.x-r)} ${Y(e.y)}`].join(` `)}var zo=class extends G{constructor(){super({target:`css`,gradientType:`diamond-gradient`,gradientClass:Qi,expectedName:`GradientDiamond`})}transform(e){let t=e.getConfig(),n=e.isRepeating(),r=Z(t.position,100,100,{context:`CSS diamond gradient`}),i=uo(t.size,t.shape,r,100,100,{context:`CSS diamond gradient`}),a=fo(r,i,100,100),o=n?a:1,s=q(e,96),c=K(n?Ia(s,0,a):s),l=Ma(c,o),u=[],d=Math.max(96,Math.ceil(96*o));for(let e=d;e>=0;--e){let t=e/d*o,n=Ma(c,t),a=Ro(r,i,t);u.push(`<polygon points="${a}" fill="${n}"/>`)}return Lo([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<rect width="100" height="100" fill="${l}"/>`,...u,`</svg>`].join(``))}},Bo=class extends Ta{constructor(){super({target:`css`,gradientType:`conic-gradient`,gradientClass:Zi,expectedName:`GradientConic`})}};function Vo(e,t,n,r){ko(t,n,r,(n,r,i)=>{let a=r*t+n;e[a]===null&&(e[a]=[Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255),i[3]])})}var Ho=class extends G{constructor(){super({target:`css`,gradientType:`mesh-gradient`,gradientClass:ya,expectedName:`GradientMesh`})}transform(e){let{config:t,patches:n,vertexMap:r,grid:i,sampler:a}=_o(e,96,96),o=t.method===`bicubic`?24:1,s=n.flatMap(e=>xo(a,e,r,o)),c=To(a,n,i,96,96,o),l=[...s,...c],u=Array.from({length:9216},()=>null),d=[];for(let e of l)Vo(u,96,96,e);for(let e=0;e<96;e+=1)for(let t=0;t<96;t+=1){let n=u[e*96+t];n&&d.push(`<rect x="${t}" y="${e}" width="1" height="1" fill="${Fo(n,3,`,`)}"/>`)}return Lo([`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" preserveAspectRatio="none" shape-rendering="crispEdges">`,...d,`</svg>`].join(``))}},Uo=class extends G{constructor(){super({target:`canvas-2d`,gradientType:`linear-gradient`,gradientClass:Yi,expectedName:`GradientLinear`})}transform(e){return{draw:(t,n,r)=>{let i=e.getConfig().angle,a=to(i,n,r),o=a.start.x,s=a.start.y,c=a.end.x,l=a.end.y,{min:u,max:d,stops:f}=Aa(q(e)),p=f;if(u<0||d>1){let e=c-o,t=l-s,n=o,r=s;o=n+e*u,s=r+t*u,c=n+e*d,l=r+t*d,p=ja(f,u,d)}let m=t.createLinearGradient(o,s,c,l);for(let e of p)m.addColorStop(e.position,No(e.value));t.clearRect(0,0,n,r),t.fillStyle=m,t.fillRect(0,0,n,r)}}}},Wo=class extends G{constructor(){super({target:`canvas-2d`,gradientType:`radial-gradient`,gradientClass:W,expectedName:`GradientRadial`})}transform(e){return{draw:(t,n,r)=>{let i=e.getConfig(),a=e.isRepeating(),o=Z(i.position,n,r,{context:`Canvas radial gradient`,allowUnsupportedUnitAsRaw:!0}),s=lo(i.size,i.shape,o,n,r,{context:`Canvas radial gradient`,allowUnsupportedUnitAsRaw:!0}),c=Ra(o,s,n,r),l=q(e,128),{min:u,max:d,stops:f}=Aa(a?Ia(l,0,c):l),p=f,m=0,h=a?c:1;if(a?p=ja(f,0,c):(u<0||d>1)&&(p=ja(f,u,d),m=u,h=d),i.shape===`circle`){let e=s.x,i=Math.max(0,e*m),a=Math.max(i+1e-4,e*h),c=t.createRadialGradient(o.x,o.y,i,o.x,o.y,a);for(let e of p)c.addColorStop(e.position,No(e.value));t.fillStyle=c,t.fillRect(0,0,n,r);return}let g=Math.max(s.x,s.y),_=s.x/g,v=s.y/g,y=Math.max(0,g*m),b=Math.max(y+1e-4,g*h);t.save(),t.translate(o.x,o.y),t.scale(_,v);let x=t.createRadialGradient(0,0,y,0,0,b);for(let e of p)x.addColorStop(e.position,No(e.value));t.fillStyle=x;let S=b+2;t.fillRect(-S/_*2,-S/v*2,S/_*4,S/v*4),t.restore()}}}};let Go=1024;function Ko(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 Mo(e[0].value);let n=e[e.length-1];if(t>=n.position)return Mo(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=Mo(r.value),o=Mo(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 Mo(n.value)}function qo(e,t){let n=new Uint8ClampedArray(Go*4);for(let r=0;r<Go;r+=1){let i=Ko(e,r/(Go-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}var Jo=class extends G{constructor(){super({target:`canvas-2d`,gradientType:`diamond-gradient`,gradientClass:Qi,expectedName:`GradientDiamond`})}transform(e){return{draw:(t,n,r)=>{let i=e.getConfig(),a=e.isRepeating(),o=Z(i.position,n,r,{context:`Canvas diamond gradient`}),s=uo(i.size,i.shape,o,n,r,{context:`Canvas diamond gradient`}),c=fo(o,s,n,r),l=q(e,128),u=qo(K(a?Ia(l,0,c):l),c),d=t.createImageData(n,r),f=d.data;for(let e=0;e<r;e+=1)for(let t=0;t<n;t+=1){let r=Math.abs(t-o.x)/Math.max(s.x,1e-4)+Math.abs(e-o.y)/Math.max(s.y,1e-4),i=Math.min(Go-1,Math.max(0,Math.round(r/Math.max(c,1e-4)*(Go-1))))*4,a=(e*n+t)*4;f[a]=u[i],f[a+1]=u[i+1],f[a+2]=u[i+2],f[a+3]=u[i+3]}t.putImageData(d,0,0)}}}},Yo=class extends G{constructor(){super({target:`canvas-2d`,gradientType:`conic-gradient`,gradientClass:Zi,expectedName:`GradientConic`})}transform(e){return{draw:(t,n,r)=>{let i=e.getConfig(),a=t.createImageData(n,r),o=a.data,{x:s,y:c}=Z(i.position,n,r,{context:`Canvas conic gradient`,allowUnsupportedUnitAsRaw:!0}),l=eo(i.from),u=q(e,128),d=this._normalizeStops(u);if(d.length===0){t.putImageData(a,0,0);return}for(let e=0;e<r;e++)for(let t=0;t<n;t++){let r=t-s,i=e-c,a=Math.atan2(i,r)+Math.PI/2-l;for(;a<0;)a+=Math.PI*2;for(;a>=Math.PI*2;)a-=Math.PI*2;let u=a/(Math.PI*2),f=this._sampleColor(d,u),p=(e*n+t)*4;o[p]=f.r,o[p+1]=f.g,o[p+2]=f.b,o[p+3]=f.a}t.putImageData(a,0,0)}}}_normalizeStops(e){return K(e).map(e=>({position:Za(e.position),color:jo(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 Po(t.color,n.color,r)}}return e[e.length-1].color}};function Xo(e,t,n,r){ko(t,n,r,(n,r,i)=>{let a=(r*t+n)*4;e[a]=Math.round(i[0]*255),e[a+1]=Math.round(i[1]*255),e[a+2]=Math.round(i[2]*255),e[a+3]=Math.round(i[3]*255)})}var Zo=class extends G{constructor(){super({target:`canvas-2d`,gradientType:`mesh-gradient`,gradientClass:ya,expectedName:`GradientMesh`})}transform(e){return{draw:(t,n,r)=>{let i=t.createImageData(n,r),{config:a,patches:o,vertexMap:s,grid:c,sampler:l}=_o(e,n,r),u=a.method===`bicubic`?24:1,d=To(l,o,c,n,r,u);for(let e of o){let t=xo(l,e,s,u);for(let e of t)Xo(i.data,n,r,e)}for(let e of d)Xo(i.data,n,r,e);t.putImageData(i,0,0)}}}};function Qo(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 $o(e,t,n){let r=Qo(e,e.VERTEX_SHADER,t),i=Qo(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 es(e){let t=jo(e);return[t.r/255,t.g/255,t.b/255,t.a/255]}function ts(e,t){let n=ka(e),r=Math.max(1,n-1);return Math.max(2,Math.floor((t-1)/r))}function ns(e,t){return Na(e,t)}let rs=`precision mediump float;`,is=`
|
|
5
|
+
attribute vec2 a_position;
|
|
6
|
+
varying vec2 v_uv;
|
|
7
|
+
|
|
8
|
+
void main() {
|
|
9
|
+
v_uv = a_position * 0.5 + 0.5;
|
|
10
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
11
|
+
}
|
|
12
|
+
`;function as(e=128){return`
|
|
13
|
+
uniform int u_stopCount;
|
|
14
|
+
uniform float u_positions[${e}];
|
|
15
|
+
uniform vec4 u_colors[${e}];
|
|
16
|
+
|
|
17
|
+
vec4 getGradientColor(float t) {
|
|
18
|
+
vec4 result = u_colors[0];
|
|
19
|
+
|
|
20
|
+
for (int i = 0; i < ${e-1}; i++) {
|
|
21
|
+
if (i >= u_stopCount - 1) {
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
float currentPosition = u_positions[i];
|
|
26
|
+
float nextPosition = u_positions[i + 1];
|
|
27
|
+
|
|
28
|
+
if (t <= currentPosition) {
|
|
29
|
+
return u_colors[i];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (t >= currentPosition && t <= nextPosition) {
|
|
33
|
+
float localT = (t - currentPosition) / max(nextPosition - currentPosition, 0.00001);
|
|
34
|
+
return mix(u_colors[i], u_colors[i + 1], localT);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
result = u_colors[i + 1];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
`}let os=`
|
|
43
|
+
${rs}
|
|
44
|
+
varying vec4 v_color;
|
|
45
|
+
|
|
46
|
+
void main() {
|
|
47
|
+
gl_FragColor = v_color;
|
|
48
|
+
}
|
|
49
|
+
`,ss=new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]);function cs(e,t,n){let r=e.getContext(`webgl`);if(!r)throw Error(`WebGL is not supported.`);return e.width=t,e.height=n,r.viewport(0,0,t,n),r}function ls(e,t,n,r,i){let a=e.createBuffer();if(!a)throw Error(`Failed to create WebGL buffer for attribute "${n}".`);let o=e.getAttribLocation(t,n);if(o<0)throw Error(`WebGL attribute "${n}" was not found.`);return e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,r,e.STATIC_DRAW),e.enableVertexAttribArray(o),e.vertexAttribPointer(o,i,e.FLOAT,!1,0,0),a}function us(e,t){ls(e,t,`a_position`,ss,2)}function ds(e,t,n,r=128){let i=n.slice(0,r),a=new Float32Array(r),o=new Float32Array(r*4);i.forEach((e,t)=>{let n=es(e.value);a[t]=e.position,o[t*4+0]=n[0],o[t*4+1]=n[1],o[t*4+2]=n[2],o[t*4+3]=n[3]}),e.uniform1i(e.getUniformLocation(t,`u_stopCount`),i.length),e.uniform1fv(e.getUniformLocation(t,`u_positions`),a),e.uniform4fv(e.getUniformLocation(t,`u_colors`),o)}function fs(e){e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)}function ps(e,t){fs(e),e.drawArrays(e.TRIANGLES,0,t)}var ms=class extends G{constructor(){super({target:`canvas-webgl`,gradientType:`linear-gradient`,gradientClass:Yi,expectedName:`GradientLinear`})}transform(e){return{draw:(t,n,r)=>{let i=cs(t,n,r),a=$o(i,is,`
|
|
50
|
+
${rs}
|
|
14
51
|
|
|
15
52
|
varying vec2 v_uv;
|
|
16
53
|
|
|
17
54
|
uniform vec2 u_start;
|
|
18
55
|
uniform vec2 u_end;
|
|
19
|
-
|
|
20
|
-
uniform float u_positions[128];
|
|
21
|
-
uniform vec4 u_colors[128];
|
|
22
|
-
|
|
23
|
-
vec4 getGradientColor(float t) {
|
|
24
|
-
vec4 result = u_colors[0];
|
|
25
|
-
|
|
26
|
-
for (int i = 0; i < 127; i++) {
|
|
27
|
-
if (i >= u_stopCount - 1) {
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
float currentPosition = u_positions[i];
|
|
32
|
-
float nextPosition = u_positions[i + 1];
|
|
33
|
-
|
|
34
|
-
if (t <= currentPosition) {
|
|
35
|
-
return u_colors[i];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (t >= currentPosition && t <= nextPosition) {
|
|
39
|
-
float localT = (t - currentPosition) / max(nextPosition - currentPosition, 0.00001);
|
|
40
|
-
return mix(u_colors[i], u_colors[i + 1], localT);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
result = u_colors[i + 1];
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return result;
|
|
47
|
-
}
|
|
56
|
+
${as(128)}
|
|
48
57
|
|
|
49
58
|
void main() {
|
|
50
59
|
vec2 axis = u_end - u_start;
|
|
@@ -57,16 +66,8 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
57
66
|
|
|
58
67
|
gl_FragColor = getGradientColor(t);
|
|
59
68
|
}
|
|
60
|
-
`);i.useProgram(a)
|
|
61
|
-
|
|
62
|
-
varying vec2 v_uv;
|
|
63
|
-
|
|
64
|
-
void main() {
|
|
65
|
-
v_uv = a_position * 0.5 + 0.5;
|
|
66
|
-
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
67
|
-
}
|
|
68
|
-
`,`
|
|
69
|
-
precision mediump float;
|
|
69
|
+
`);i.useProgram(a),us(i,a);let o=e.getConfig().angle,s=to(o,n,r),c=s.start.x,l=s.start.y,u=s.end.x,d=s.end.y,{min:f,max:p,stops:m}=Aa(q(e,ts(e.getStops(),128))),h=m;if(f<0||p>1){let e=u-c,t=d-l,n=c,r=l;c=n+e*f,l=r+t*f,u=n+e*p,d=r+t*p,h=ja(m,f,p)}let g=c/n,_=1-l/r,v=u/n,y=1-d/r,b=ns(h,128);i.uniform2f(i.getUniformLocation(a,`u_start`),g,_),i.uniform2f(i.getUniformLocation(a,`u_end`),v,y),ds(i,a,b,128),ps(i,6)}}}},hs=class extends G{constructor(){super({target:`canvas-webgl`,gradientType:`conic-gradient`,gradientClass:Zi,expectedName:`GradientConic`})}transform(e){return{draw:(t,n,r)=>{let i=e.getConfig(),a=cs(t,n,r),o=$o(a,is,`
|
|
70
|
+
${rs}
|
|
70
71
|
|
|
71
72
|
const float PI = 3.141592653589793;
|
|
72
73
|
const float TWO_PI = 6.283185307179586;
|
|
@@ -75,35 +76,7 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
75
76
|
|
|
76
77
|
uniform vec2 u_center;
|
|
77
78
|
uniform float u_startAngle;
|
|
78
|
-
|
|
79
|
-
uniform float u_positions[128];
|
|
80
|
-
uniform vec4 u_colors[128];
|
|
81
|
-
|
|
82
|
-
vec4 getGradientColor(float t) {
|
|
83
|
-
vec4 result = u_colors[0];
|
|
84
|
-
|
|
85
|
-
for (int i = 0; i < 127; i++) {
|
|
86
|
-
if (i >= u_stopCount - 1) {
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
float currentPosition = u_positions[i];
|
|
91
|
-
float nextPosition = u_positions[i + 1];
|
|
92
|
-
|
|
93
|
-
if (t <= currentPosition) {
|
|
94
|
-
return u_colors[i];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (t >= currentPosition && t <= nextPosition) {
|
|
98
|
-
float localT = (t - currentPosition) / max(nextPosition - currentPosition, 0.00001);
|
|
99
|
-
return mix(u_colors[i], u_colors[i + 1], localT);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
result = u_colors[i + 1];
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
79
|
+
${as(128)}
|
|
107
80
|
|
|
108
81
|
void main() {
|
|
109
82
|
vec2 delta = v_uv - u_center;
|
|
@@ -115,51 +88,15 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
115
88
|
|
|
116
89
|
gl_FragColor = getGradientColor(t);
|
|
117
90
|
}
|
|
118
|
-
`);
|
|
119
|
-
|
|
120
|
-
varying vec2 v_uv;
|
|
121
|
-
|
|
122
|
-
void main() {
|
|
123
|
-
v_uv = a_position * 0.5 + 0.5;
|
|
124
|
-
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
125
|
-
}
|
|
126
|
-
`,`
|
|
127
|
-
precision mediump float;
|
|
91
|
+
`);a.useProgram(o),us(a,o);let s=Z(i.position,n,r,{context:`WebGL conic gradient`}),c=ns(q(e,ts(e.getStops(),128)),128);a.uniform2f(a.getUniformLocation(o,`u_center`),s.x/n,1-s.y/r),a.uniform1f(a.getUniformLocation(o,`u_startAngle`),eo(i.from)),ds(a,o,c,128),ps(a,6)}}}},gs=class extends G{constructor(){super({target:`canvas-webgl`,gradientType:`radial-gradient`,gradientClass:W,expectedName:`GradientRadial`})}transform(e){return{draw:(t,n,r)=>{let i=e.getConfig(),a=e.isRepeating(),o=cs(t,n,r),s=$o(o,is,`
|
|
92
|
+
${rs}
|
|
128
93
|
|
|
129
94
|
varying vec2 v_uv;
|
|
130
95
|
|
|
131
96
|
uniform vec2 u_center;
|
|
132
97
|
uniform vec2 u_radius;
|
|
133
|
-
uniform int u_stopCount;
|
|
134
|
-
uniform float u_positions[128];
|
|
135
|
-
uniform vec4 u_colors[128];
|
|
136
98
|
uniform float u_tMax;
|
|
137
|
-
|
|
138
|
-
vec4 getGradientColor(float t) {
|
|
139
|
-
vec4 result = u_colors[0];
|
|
140
|
-
|
|
141
|
-
for (int i = 0; i < 127; i++) {
|
|
142
|
-
if (i >= u_stopCount - 1) {
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
float currentPosition = u_positions[i];
|
|
147
|
-
float nextPosition = u_positions[i + 1];
|
|
148
|
-
|
|
149
|
-
if (t <= currentPosition) {
|
|
150
|
-
return u_colors[i];
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (t >= currentPosition && t <= nextPosition) {
|
|
154
|
-
float localT = (t - currentPosition) / max(nextPosition - currentPosition, 0.00001);
|
|
155
|
-
return mix(u_colors[i], u_colors[i + 1], localT);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
result = u_colors[i + 1];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return result;
|
|
162
|
-
}
|
|
99
|
+
${as(128)}
|
|
163
100
|
|
|
164
101
|
void main() {
|
|
165
102
|
vec2 delta = v_uv - u_center;
|
|
@@ -171,51 +108,15 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
171
108
|
|
|
172
109
|
gl_FragColor = getGradientColor(t);
|
|
173
110
|
}
|
|
174
|
-
`);
|
|
175
|
-
|
|
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;
|
|
111
|
+
`);o.useProgram(s),us(o,s);let c=Z(i.position,n,r,{context:`WebGL radial gradient`}),l=lo(i.size,i.shape,c,n,r,{context:`WebGL radial gradient`}),u=Ra(c,l,n,r),d=q(e,ts(e.getStops(),128)),f=Math.min(u,16),p=a?f:1,m=a?Ia(d,0,f):d,h=ns(a?ja(m,0,f):m,128);o.uniform2f(o.getUniformLocation(s,`u_center`),c.x/n,1-c.y/r),o.uniform2f(o.getUniformLocation(s,`u_radius`),l.x/n,l.y/r),o.uniform1f(o.getUniformLocation(s,`u_tMax`),p),ds(o,s,h,128),ps(o,6)}}}},_s=class extends G{constructor(){super({target:`canvas-webgl`,gradientType:`diamond-gradient`,gradientClass:Qi,expectedName:`GradientDiamond`})}transform(e){return{draw:(t,n,r)=>{let i=e.getConfig(),a=e.isRepeating(),o=cs(t,n,r),s=$o(o,is,`
|
|
112
|
+
${rs}
|
|
184
113
|
|
|
185
114
|
varying vec2 v_uv;
|
|
186
115
|
|
|
187
116
|
uniform vec2 u_center;
|
|
188
117
|
uniform vec2 u_radius;
|
|
189
|
-
uniform int u_stopCount;
|
|
190
|
-
uniform float u_positions[128];
|
|
191
|
-
uniform vec4 u_colors[128];
|
|
192
118
|
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
|
-
}
|
|
119
|
+
${as(128)}
|
|
219
120
|
|
|
220
121
|
void main() {
|
|
221
122
|
vec2 delta = v_uv - u_center;
|
|
@@ -227,20 +128,13 @@ var gradiente=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Mo
|
|
|
227
128
|
|
|
228
129
|
gl_FragColor = getGradientColor(t);
|
|
229
130
|
}
|
|
230
|
-
`);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
precision mediump float;
|
|
241
|
-
varying vec4 v_color;
|
|
242
|
-
|
|
243
|
-
void main() {
|
|
244
|
-
gl_FragColor = v_color;
|
|
245
|
-
}
|
|
246
|
-
`),o=Qi(t,n,r),s=$i(t,o),c=t.config.method===`bicubic`?24:1,l=ua(t,s,n,r,c),u=[],d=[];for(let e of t.patches){let i=la(t,s,e,o,c);for(let e of i)for(let t of e)u.push(xs(t.x,n),Ss(t.y,r)),d.push(...t.color)}for(let e of l)for(let t of e)u.push(xs(t.x,n),Ss(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)}}}};let ws=E(`rgb`);function Ts(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`)}function Es(e){return Math.min(1,Math.max(0,e))}function Ds(e){return`${Number((e*100).toFixed(3))}%`}function Os(e){return`${Number(e.toFixed(3))}%`}function ks(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function As(e){let t=ws(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)}}function js(e){return e.a>=255?`rgb(${e.r} ${e.g} ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${Number((e.a/255).toFixed(4))})`}function Ms(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)}}function Ns(e,t){let n=ks(e);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(n.length===1)return As(n[0].value);let r=n[0],i=[...n,{...r,position:r.position+1}],a=t;a<r.position&&(a+=1);for(let e=0;e<i.length-1;e+=1){let t=i[e],n=i[e+1];if(a>=t.position&&a<=n.position){let e=n.position-t.position||1,r=(a-t.position)/e;return Ms(As(t.value),As(n.value),r)}}return As(n[n.length-1].value)}function Ps(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function Fs(e){return ks(q(e,128)).map(e=>`<stop offset="${Ds(Es(e.position))}" stop-color="${Ts(e.value)}"/>`).join(``)}function Is(e){let t=`<defs>${e.gradient}</defs>`;return{id:e.id,href:`#${e.id}`,url:`url(#${e.id})`,type:e.type,gradient:e.gradient,defs:t,svg:`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`}}function Ls(e){let t=Math.sin(e),n=-Math.cos(e),r=Math.max(Math.abs(t),Math.abs(n),1e-4),i=t/r,a=n/r;return{x1:50-i*50,y1:50-a*50,x2:50+i*50,y2:50+a*50}}var Rs=class{target=`svg`;gradientType=`linear-gradient`;to(e){if(!(e instanceof Oi))throw Error(`Expected LinearGradient`);let t=`gradiente-linear-gradient`,n=Ls(e.config.angle),r=Fs(e);return Is({id:t,type:`linearGradient`,gradient:[`<linearGradient id="${t}" gradientUnits="objectBoundingBox" x1="${Os(n.x1)}" y1="${Os(n.y1)}" x2="${Os(n.x2)}" y2="${Os(n.y2)}">`,r,`</linearGradient>`].join(``)})}};function zs(e){return e===`left`?0:e===`right`?100:50}function Bs(e){return e===`top`?0:e===`bottom`?100:50}function Vs(e){return e.kind===`percent`||e.unit,e.value}function Hs(e){return e.kind===`keywords`?{x:zs(e.x),y:Bs(e.y)}:{x:Vs(e.x),y:Vs(e.y)}}function Us(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function Ws(e,t,n){if(e.kind===`explicit`){let n=Vs(e.x),r=e.y?Vs(e.y):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=>Us(n,e));if(e.value===`closest-side`){let e=Math.min(r,i,a,o);return{x:e,y:e}}if(e.value===`farthest-side`){let e=Math.max(r,i,a,o);return{x:e,y:e}}if(e.value===`closest-corner`){let e=Math.min(...t);return{x:e,y:e}}let s=Math.max(...t);return{x:s,y:s}}return e.value===`closest-side`?{x:Math.min(r,i),y:Math.min(a,o)}:(e.value,{x:Math.max(r,i),y:Math.max(a,o)})}var Gs=class{target=`svg`;gradientType=`radial-gradient`;to(e){if(!(e instanceof ki))throw Error(`Expected RadialGradient`);let t=`gradiente-radial-gradient`,n=Hs(e.config.position),r=Ws(e.config.size,e.config.shape,n),i=Math.max(r.x,r.y),a=r.x/i,o=r.y/i,s=e.config.shape===`ellipse`?` gradientTransform="translate(${n.x} ${n.y}) scale(${a} ${o}) translate(${-n.x} ${-n.y})"`:``;return Is({id:t,type:`radialGradient`,gradient:[`<radialGradient id="${t}" gradientUnits="objectBoundingBox" cx="${Os(n.x)}" cy="${Os(n.y)}" r="${Os(i)}"${s}>`,Fs(e),`</radialGradient>`].join(``)})}};let Ks=Math.PI*2;function qs(e,t){return e===`left`?0:e===`right`?t:t/2}function Js(e,t){return e===`top`?0:e===`bottom`?t:t/2}function Ys(e,t){return e.kind===`percent`?e.value/100*t:(e.unit,e.value)}function Xs(e,t){return e.kind===`keywords`?{x:qs(e.x,t),y:Js(e.y,t)}:{x:Ys(e.x,t),y:Ys(e.y,t)}}function Zs(e){return e.unit===`deg`?d(e.value):e.unit===`turn`?p(e.value):e.unit===`grad`?m(e.value):e.value}function Qs(e,t){let n=t.x-e.x,r=t.y-e.y;return Math.sqrt(n*n+r*r)}function $s(e){return Math.max(...[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(t=>Qs(e,t)))*1.02}function ec(e,t,n){return{x:e.x+Math.sin(n)*t,y:e.y-Math.cos(n)*t}}function Q(e){return`${Number(e.toFixed(3))}`}var tc=class{target=`svg`;gradientType=`conic-gradient`;to(e){if(!(e instanceof ji))throw Error(`Expected ConicGradient`);let t=`gradiente-conic-gradient`,n=Xs(e.config.position,100),r=Zs(e.config.from),i=q(e,128),a=$s(n),o=[];for(let e=0;e<720;e+=1){let t=e/720,s=(e+1)/720,c=js(Ns(i,t+(s-t)/2)),l=ec(n,a,t*Ks+r),u=ec(n,a,s*Ks+r);o.push([`<path d="M ${Q(n.x)} ${Q(n.y)}`,`L ${Q(l.x)} ${Q(l.y)}`,`A ${Q(a)} ${Q(a)} 0 0 1 ${Q(u.x)} ${Q(u.y)}`,`Z" fill="${c}" stroke="${c}" stroke-width="0.25"/>`].join(` `))}let s=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">`,...o,`</svg>`].join(``);return Is({id:t,type:`pattern`,gradient:[`<pattern id="${t}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${Ts(Ps(s))}"/>`,`</pattern>`].join(``)})}};function nc(e){return e===`left`?0:e===`right`?100:100/2}function rc(e){return e===`top`?0:e===`bottom`?100:100/2}function ic(e){if(e.kind===`percent`)return e.value/100*100;if(e.unit===`px`)return e.value;throw Error(`Unsupported diamond-gradient length unit for SVG transformer: ${e.unit}`)}function ac(e){return e.kind===`keywords`?{x:nc(e.x),y:rc(e.y)}:{x:ic(e.x),y:ic(e.y)}}function oc(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function sc(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 cc(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 lc(e,t,n){if(e.kind===`explicit`){let n=ic(e.x),r=e.y?ic(e.y):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=>oc(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=sc(n);return e.value===`closest-corner`?d.map(e=>cc(s,c,e.dx,e.dy)).reduce((e,t)=>t.x*t.y<e.x*e.y?t:e):d.map(e=>cc(l,u,e.dx,e.dy)).reduce((e,t)=>t.x*t.y>e.x*e.y?t:e)}function uc(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 dc(e){return e.filter(e=>e.type===`color-stop`&&e.position!=null).sort((e,t)=>e.position-t.position)}function $(e){return`${Number(e.toFixed(3))}`}function fc(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(` `)}var pc=class{target=`svg`;gradientType=`diamond-gradient`;to(e){if(!(e instanceof Ai))throw Error(`Expected DiamondGradient`);let t=`gradiente-diamond-gradient`,n=ac(e.config.position),r=lc(e.config.size,e.config.shape,n),i=uc(n,r),a=e.isRepeating?i:1,o=q(e,128),s=dc(e.isRepeating?K(o,0,i):o),c=js(Ns(s,a)),l=Math.max(128,Math.ceil(128*a)),u=[];for(let e=l;e>=0;--e){let t=e/l*a,i=js(Ns(s,t)),o=fc(n,r,t);u.push(`<polygon points="${o}" fill="${i}"/>`)}let d=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" preserveAspectRatio="none">`,`<rect width="100" height="100" fill="${c}"/>`,...u,`</svg>`].join(``);return Is({id:t,type:`pattern`,gradient:[`<pattern id="${t}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${Ts(Ps(d))}"/>`,`</pattern>`].join(``)})}};function mc(e){return`rgba(${e[0]}, ${e[1]}, ${e[2]}, ${Number(e[3].toFixed(4))})`}function hc(e,t,n){return[Math.round((e.color[0]+t.color[0]+n.color[0])/3*255),Math.round((e.color[1]+t.color[1]+n.color[1])/3*255),Math.round((e.color[2]+t.color[2]+n.color[2])/3*255),(e.color[3]+t.color[3]+n.color[3])/3]}function gc(e){return`${Number(e.toFixed(3))}`}function _c(e){let[t,n,r]=e,i=mc(hc(t,n,r));return`<polygon points="${[`${gc(t.x)} ${gc(t.y)}`,`${gc(n.x)} ${gc(n.y)}`,`${gc(r.x)} ${gc(r.y)}`].join(` `)}" fill="${i}" stroke="${i}" stroke-width="0.08"/>`}var vc=class{target=`svg`;gradientType=`mesh-gradient`;to(e){if(!(e instanceof Pi))throw Error(`Expected MeshGradient`);let t=`gradiente-mesh-gradient`,n=Qi(e,100,100),r=$i(e,n),i=e.config.method===`bicubic`?40:32,a=e.patches.flatMap(t=>la(e,r,t,n,i)),o=ua(e,r,100,100,i),s=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" preserveAspectRatio="none">`,...[...a,...o].map(_c),`</svg>`].join(``);return Is({id:t,type:`pattern`,gradient:[`<pattern id="${t}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${Ts(Ps(s))}"/>`,`</pattern>`].join(``)})}},yc=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`?bc.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 Fi),this.add(new Ii),this.add(new wa),this.add(new Ta),this.add(new Aa),this.add(new Fa),this.add(new Wa),this.add(new to),this.add(new ro),this.add(new so),this.add(new yo),this.add(new $o),this.add(new vs),this.add(new Po),this.add(new Cs),this.add(new Rs),this.add(new Gs),this.add(new tc),this.add(new pc),this.add(new vc))}static _getKey(e,t){return`${e}:${t}`}},bc=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`,Oi),this.add(`radial-gradient`,ki),this.add(`diamond-gradient`,Ai),this.add(`conic-gradient`,ji),this.add(`mesh-gradient`,Pi))}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 xc(e){return bc.create(e)}function Sc(e){return bc.isValid(e)}function Cc(e){return typeof e==`string`?xc(e).toString():e.toString()}function wc(e,t){let n=typeof t==`string`?xc(t):t;return yc.to(e,n)}function Tc(e,t,n){return yc.from(e,t,n)}return e.ConicGradient=ji,e.DiamondGradient=Ai,e.GRADIENT_COLOR_SPACE=xi,e.GRADIENT_HUE_INTERPOLATIONS=Si,e.GRADIENT_POLAR_COLOR_SPACES=Ci,e.GradientBase=Di,e.GradientFactory=bc,e.GradientTransformer=yc,e.LinearGradient=Oi,e.MeshGradient=Pi,e.ModuleTransformerConicGradientToCanvas=ro,e.ModuleTransformerConicGradientToCanvasWebGL=Po,e.ModuleTransformerConicGradientToCss=Ta,e.ModuleTransformerConicGradientToSvg=tc,e.ModuleTransformerDiamondGradientToCanvas=to,e.ModuleTransformerDiamondGradientToCanvasWebGL=vs,e.ModuleTransformerDiamondGradientToCss=wa,e.ModuleTransformerDiamondGradientToSvg=pc,e.ModuleTransformerLinearGradientToCanvas=Fa,e.ModuleTransformerLinearGradientToCanvasWebGL=yo,e.ModuleTransformerLinearGradientToCss=Fi,e.ModuleTransformerLinearGradientToSvg=Rs,e.ModuleTransformerMeshGradientToCanvas=so,e.ModuleTransformerMeshGradientToCanvasWebGL=Cs,e.ModuleTransformerMeshGradientToCss=Aa,e.ModuleTransformerMeshGradientToSvg=vc,e.ModuleTransformerRadialGradientToCanvas=Wa,e.ModuleTransformerRadialGradientToCanvasWebGL=$o,e.ModuleTransformerRadialGradientToCss=Ii,e.ModuleTransformerRadialGradientToSvg=Gs,e.PatternTokenKind=Gr,e.RadialGradient=ki,e.angleValueFromString=u,e.ceilTo=r,e.clamp=a,e.degToRad=d,e.floorTo=n,e.format=Cc,e.fromPercent=s,e.gradToRad=m,e.isAngle=l,e.isAngleUnit=c,e.isColorHint=fi,e.isColorStop=pi,e.isConfig=mi,e.isGradient=Sc,e.isGradientColorSpace=Ti,e.isGradientHueInterpolation=wi,e.isGradientPolarColorSpace=Ei,e.isPatternSyntaxValid=ii,e.isPatternValid=ni,e.isValid=li,e.matchExpression=Kr,e.normalizeAngleDeg=h,e.normalizeAngleRad=g,e.parse=xc,e.parseStringToAbi=di,e.radToDeg=f,e.roundTo=t,e.splitTopLevelByWhitespace=bi,e.toPercent=o,e.tokenizePattern=ci,e.transformFrom=Tc,e.transformTo=wc,e.truncTo=i,e.turnToRad=p,e.validate=ui,e.validatePattern=ti,e.validatePatternSemantic=oi,e.validatePatternStructure=si,e.validatePatternSyntax=ri,e})({});
|
|
131
|
+
`);o.useProgram(s),us(o,s);let c=Z(i.position,n,r,{context:`WebGL diamond gradient`}),l=uo(i.size,i.shape,c,n,r,{context:`WebGL diamond gradient`}),u=fo(c,l,n,r),d=q(e,ts(e.getStops(),128)),f=Math.min(u,16),p=a?f:1,m=a?Ia(d,0,f):d,h=ns(a?ja(m,0,f):m,128);o.uniform2f(o.getUniformLocation(s,`u_center`),c.x/n,1-c.y/r),o.uniform2f(o.getUniformLocation(s,`u_radius`),l.x/n,l.y/r),o.uniform1f(o.getUniformLocation(s,`u_tMax`),p),ds(o,s,h,128),ps(o,6)}}}};function vs(e,t){return e/t*2-1}function ys(e,t){return 1-e/t*2}var bs=class extends G{constructor(){super({target:`canvas-webgl`,gradientType:`mesh-gradient`,gradientClass:ya,expectedName:`GradientMesh`})}transform(e){return{draw:(t,n,r)=>{let i=cs(t,n,r),a=$o(i,`
|
|
132
|
+
attribute vec2 a_position;
|
|
133
|
+
attribute vec4 a_color;
|
|
134
|
+
varying vec4 v_color;
|
|
135
|
+
|
|
136
|
+
void main() {
|
|
137
|
+
v_color = a_color;
|
|
138
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
139
|
+
}
|
|
140
|
+
`,os),{config:o,patches:s,vertexMap:c,grid:l,sampler:u}=_o(e,n,r),d=o.method===`bicubic`?24:1,f=To(u,s,l,n,r,d),p=[],m=[];for(let e of s){let t=xo(u,e,c,d);for(let e of t)for(let t of e)p.push(vs(t.x,n),ys(t.y,r)),m.push(...t.color)}for(let e of f)for(let t of e)p.push(vs(t.x,n),ys(t.y,r)),m.push(...t.color);i.useProgram(a),ls(i,a,`a_position`,new Float32Array(p),2),ls(i,a,`a_color`,new Float32Array(m),4),ps(i,p.length/2)}}}};function xs(e){return e.replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`)}function Ss(e){return`${Number((e*100).toFixed(3))}%`}function Cs(e){return`${Y(e)}%`}function ws(e){return K(e)}function Ts(e){return jo(e)}function Es(e){return e.a>=255?`rgb(${e.r} ${e.g} ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${Number((e.a/255).toFixed(4))})`}function Ds(e,t,n){return Po(e,t,n)}function Os(e,t){let n=ws(e);if(n.length===0)throw Error(`Cannot sample color from empty gradient stops.`);if(n.length===1)return Ts(n[0].value);let r=n[0],i=[...n,{...r,position:r.position+1}],a=t;a<r.position&&(a+=1);for(let e=0;e<i.length-1;e+=1){let t=i[e],n=i[e+1];if(a>=t.position&&a<=n.position){let e=n.position-t.position||1,r=(a-t.position)/e;return Ds(Ts(t.value),Ts(n.value),r)}}return Ts(n[n.length-1].value)}function ks(e){return ws(q(e,128)).map(e=>`<stop offset="${Ss(Za(e.position))}" stop-color="${xs(e.value)}"/>`).join(``)}function As(e){let t=`<defs>${e.gradient}</defs>`;return{id:e.id,href:`#${e.id}`,url:`url(#${e.id})`,type:e.type,gradient:e.gradient,defs:t,svg:`<svg xmlns="http://www.w3.org/2000/svg">${t}</svg>`}}var js=class extends G{constructor(){super({target:`svg`,gradientType:`linear-gradient`,gradientClass:Yi,expectedName:`GradientLinear`})}transform(e){let t=`gradiente-linear-gradient`,n=no(e.getConfig().angle),r=ks(e);return As({id:t,type:`linearGradient`,gradient:[`<linearGradient id="${t}" gradientUnits="objectBoundingBox" x1="${Cs(n.x1)}" y1="${Cs(n.y1)}" x2="${Cs(n.x2)}" y2="${Cs(n.y2)}">`,r,`</linearGradient>`].join(``)})}},Ms=class extends G{constructor(){super({target:`svg`,gradientType:`radial-gradient`,gradientClass:W,expectedName:`GradientRadial`})}transform(e){let t=e.getConfig(),n=`gradiente-radial-gradient`,r=Z(t.position,100,100,{context:`SVG radial gradient`,allowUnsupportedUnitAsRaw:!0}),i=lo(t.size,t.shape,r,100,100,{context:`SVG radial gradient`,allowUnsupportedUnitAsRaw:!0}),a=Math.max(i.x,i.y),o=i.x/a,s=i.y/a,c=t.shape===`ellipse`?` gradientTransform="translate(${r.x} ${r.y}) scale(${o} ${s}) translate(${-r.x} ${-r.y})"`:``;return As({id:n,type:`radialGradient`,gradient:[`<radialGradient id="${n}" gradientUnits="objectBoundingBox" cx="${Cs(r.x)}" cy="${Cs(r.y)}" r="${Cs(a)}"${c}>`,ks(e),`</radialGradient>`].join(``)})}};let Ns=Math.PI*2;function Ps(e){return Math.max(...[{x:0,y:0},{x:100,y:0},{x:0,y:100},{x:100,y:100}].map(t=>io(e,t)))*1.02}function Fs(e,t,n){return{x:e.x+Math.sin(n)*t,y:e.y-Math.cos(n)*t}}var Is=class extends G{constructor(){super({target:`svg`,gradientType:`conic-gradient`,gradientClass:Zi,expectedName:`GradientConic`})}transform(e){let t=e.getConfig(),n=`gradiente-conic-gradient`,r=Z(t.position,100,100,{context:`SVG conic gradient`,allowUnsupportedUnitAsRaw:!0}),i=eo(t.from),a=q(e,128),o=Ps(r),s=[];for(let e=0;e<720;e+=1){let t=e/720,n=(e+1)/720,c=Es(Os(a,t+(n-t)/2)),l=Fs(r,o,t*Ns+i),u=Fs(r,o,n*Ns+i);s.push([`<path d="M ${Y(r.x)} ${Y(r.y)}`,`L ${Y(l.x)} ${Y(l.y)}`,`A ${Y(o)} ${Y(o)} 0 0 1 ${Y(u.x)} ${Y(u.y)}`,`Z" fill="${c}" stroke="${c}" stroke-width="0.25"/>`].join(` `))}let c=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100">`,...s,`</svg>`].join(``);return As({id:n,type:`pattern`,gradient:[`<pattern id="${n}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${xs(Io(c))}"/>`,`</pattern>`].join(``)})}};function Ls(e,t,n){let r=t.x*n,i=t.y*n;return[`${Y(e.x)} ${Y(e.y-i)}`,`${Y(e.x+r)} ${Y(e.y)}`,`${Y(e.x)} ${Y(e.y+i)}`,`${Y(e.x-r)} ${Y(e.y)}`].join(` `)}var Rs=class extends G{constructor(){super({target:`svg`,gradientType:`diamond-gradient`,gradientClass:Qi,expectedName:`GradientDiamond`})}transform(e){let t=e.getConfig(),n=e.isRepeating(),r=`gradiente-diamond-gradient`,i=Z(t.position,100,100,{context:`SVG diamond gradient`}),a=uo(t.size,t.shape,i,100,100,{context:`SVG diamond gradient`}),o=fo(i,a,100,100),s=n?o:1,c=q(e,128),l=K(n?Ia(c,0,o):c),u=Es(Os(l,s)),d=Math.max(128,Math.ceil(128*s)),f=[];for(let e=d;e>=0;--e){let t=e/d*s,n=Es(Os(l,t)),r=Ls(i,a,t);f.push(`<polygon points="${r}" fill="${n}"/>`)}let p=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" preserveAspectRatio="none">`,`<rect width="100" height="100" fill="${u}"/>`,...f,`</svg>`].join(``);return As({id:r,type:`pattern`,gradient:[`<pattern id="${r}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${xs(Io(p))}"/>`,`</pattern>`].join(``)})}};function zs(e){let[t,n,r]=e,i=Oo(e),a=Fo([Math.round(i[0]*255),Math.round(i[1]*255),Math.round(i[2]*255),i[3]]);return`<polygon points="${[`${Y(t.x)} ${Y(t.y)}`,`${Y(n.x)} ${Y(n.y)}`,`${Y(r.x)} ${Y(r.y)}`].join(` `)}" fill="${a}" stroke="${a}" stroke-width="0.08"/>`}var Bs=class extends G{constructor(){super({target:`svg`,gradientType:`mesh-gradient`,gradientClass:ya,expectedName:`GradientMesh`})}transform(e){let t=`gradiente-mesh-gradient`,{config:n,patches:r,vertexMap:i,grid:a,sampler:o}=_o(e,100,100),s=n.method===`bicubic`?40:32,c=r.flatMap(e=>xo(o,e,i,s)),l=To(o,r,a,100,100,s),u=[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100" height="100" preserveAspectRatio="none">`,...[...c,...l].map(zs),`</svg>`].join(``);return As({id:t,type:`pattern`,gradient:[`<pattern id="${t}" patternUnits="objectBoundingBox" width="1" height="1" viewBox="0 0 100 100" preserveAspectRatio="none">`,`<image width="100" height="100" href="${xs(Io(u))}"/>`,`</pattern>`].join(``)})}},Vs=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`?Sa(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 Ea),this.add(new Da),this.add(new zo),this.add(new Bo),this.add(new Ho),this.add(new Uo),this.add(new Wo),this.add(new Jo),this.add(new Yo),this.add(new Zo),this.add(new ms),this.add(new gs),this.add(new _s),this.add(new hs),this.add(new bs),this.add(new js),this.add(new Ms),this.add(new Is),this.add(new Rs),this.add(new Bs))}static _getKey(e,t){return`${e}:${t}`}};function Hs(e,t){return Vs.to(e,t)}function Us(e,t,n){return Vs.from(e,t,n)}return e.GRADIENT_COLOR_SPACE=Di,e.GRADIENT_HUE_INTERPOLATIONS=Oi,e.GRADIENT_POLAR_COLOR_SPACES=ki,e.GradientBase=ji,e.GradientConic=Zi,e.GradientCssStringTransformerModule=Ta,e.GradientDiamond=Qi,e.GradientFactory=xa,e.GradientLinear=Yi,e.GradientMesh=ya,e.GradientRadial=W,e.GradientTransformer=Vs,e.GradientTransformerModule=G,e.GradientWithStopsBase=Mi,e.ModuleTransformerConicGradientToCanvas=Yo,e.ModuleTransformerConicGradientToCanvasWebGL=hs,e.ModuleTransformerConicGradientToCss=Bo,e.ModuleTransformerConicGradientToSvg=Is,e.ModuleTransformerDiamondGradientToCanvas=Jo,e.ModuleTransformerDiamondGradientToCanvasWebGL=_s,e.ModuleTransformerDiamondGradientToCss=zo,e.ModuleTransformerDiamondGradientToSvg=Rs,e.ModuleTransformerLinearGradientToCanvas=Uo,e.ModuleTransformerLinearGradientToCanvasWebGL=ms,e.ModuleTransformerLinearGradientToCss=Ea,e.ModuleTransformerLinearGradientToSvg=js,e.ModuleTransformerMeshGradientToCanvas=Zo,e.ModuleTransformerMeshGradientToCanvasWebGL=bs,e.ModuleTransformerMeshGradientToCss=Ho,e.ModuleTransformerMeshGradientToSvg=Bs,e.ModuleTransformerRadialGradientToCanvas=Wo,e.ModuleTransformerRadialGradientToCanvasWebGL=gs,e.ModuleTransformerRadialGradientToCss=Da,e.ModuleTransformerRadialGradientToSvg=Ms,e.PatternTokenKind=Zr,e.angleValueFromString=u,e.ceilTo=r,e.clamp=a,e.createWebGLProgram=$o,e.createWebGLShader=Qo,e.degToRad=d,e.fitStopsToWebGLLimit=ns,e.floorTo=n,e.format=wa,e.formatGradientAngle=Ii,e.formatGradientLengthPercentage=H,e.formatGradientPosition=Bi,e.fromPercent=s,e.getWebGLSampleCount=ts,e.gradToRad=m,e.isAngle=l,e.isAngleUnit=c,e.isColorHint=vi,e.isColorStop=yi,e.isConfig=bi,e.isDefaultGradientPosition=Ui,e.isGradient=Ca,e.isGradientColorSpace=V,e.isGradientHueInterpolation=B,e.isGradientLengthPercentageToken=Ri,e.isGradientPolarColorSpace=Ai,e.isPatternSyntaxValid=ui,e.isPatternValid=ci,e.isValid=hi,e.matchExpression=Qr,e.normalizeAngleDeg=h,e.normalizeAngleRad=g,e.parse=Sa,e.parseGradientAngle=Fi,e.parseGradientLengthPercentage=Li,e.parseGradientPosition=zi,e.parseStringToAbi=_i,e.radToDeg=f,e.roundTo=t,e.splitTopLevelByWhitespace=Ei,e.toPercent=o,e.toWebGLColor=es,e.tokenizePattern=mi,e.transformFrom=Us,e.transformTo=Hs,e.truncTo=i,e.turnToRad=p,e.validate=gi,e.validateGradientAngle=Vi,e.validateGradientLengthPercentage=U,e.validateGradientPosition=Hi,e.validatePattern=si,e.validatePatternSemantic=fi,e.validatePatternStructure=pi,e.validatePatternSyntax=li,e})({});
|