@cobalt-ui/core
Advanced tools
Comparing version 0.6.4 to 0.7.0
# @cobalt-ui/core | ||
## 0.7.0 | ||
### Minor Changes | ||
- e50c864: Add strokeStyle and border support in plugins, improve validation in core | ||
## 0.6.4 | ||
@@ -4,0 +10,0 @@ |
@@ -1,6 +0,6 @@ | ||
function M(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function dr(r){return r==null?!0:typeof r=="string"||Array.isArray(r)?r.length===0:M(r)?Object.keys(r).length===0:!1}function X(r,e){if(r==null&&e.undefined)return e.undefined(r);if(typeof r=="string"&&e.string)return e.string(r);if(typeof r=="number"&&e.number)return e.number(r);if(Array.isArray(r)&&e.array)return e.array(r);if(M(r)&&e.object)return e.object(r);if(e.default)return e.default(r)}function N(r,e=2){let t=r;for(;t.length<e;)t=`0${t}`;return t}function Gr(r){return r*(Math.PI/180)}function Br(r){return r*(180/Math.PI)}function m(r,e,t){return Math.min(Math.max(r,e),t)}function _(r,e){let[t,o,n,a]=e,s=a<1?`/${A(a,5)}`:"";switch(r){case"rgb":case"rgba":return a<1?`rgba(${Math.round(t*255)}, ${Math.round(o*255)}, ${Math.round(n*255)}, ${A(a,5)})`:`rgb(${Math.round(t*255)}, ${Math.round(o*255)}, ${Math.round(n*255)})`;case"oklab":case"oklch":return`${r}(${A(t*100,6)}% ${A(o,6)} ${A(n,6)}${s})`;default:return`color(${r} ${A(t,6)} ${A(o,6)} ${A(n,6)}${s})`}}function C(r,e){let t=[...r];for(let o=0;o<e.length;o++){let n=0;for(let a=0;a<e[o].length;a++)n+=r[a]*e[o][a];t[o]=n}return t}function A(r,e=2){let t=10**e;return Math.round(r*t)/t}var Dr=[[.4123907992659593,.357584339383878,.1804807884018343],[.2126390058715102,.715168678767756,.0721923153607337],[.0193308187155918,.11919477979462,.9505321522496607]],Sr=[[3.240969941904522,-1.537383177570094,-.4986107602930034],[-.9692436362808793,1.8759675015077202,.0415550574071756],[.0556300796969937,-.2039769588889766,1.0569715142428782]],Tr=[[.2104542553,.793617785,-.0040720468],[1.9779984951,-2.428592205,.4505937099],[.0259040371,.7827717662,-.808675766]],b=[[4.0767416621,-3.3077115913,.2309699292],[-1.2684380046,2.6097574011,-.3413193965],[-.0041960863,-.7034186147,1.707614701]],Ir=[[.4122214708,.5363325363,.0514459929],[.2119034982,.6806995451,.1073969566],[.0883024619,.2817188376,.6299787005]],qr=[[1,.39633779217376774,.2158037580607588],[1,-.10556134232365633,-.0638541747717059],[1,-.08948418209496574,-1.2914855378640917]];function Nr(r,e){let t=[1/0,1/0,1/0,1/0,1/0],o=1/0,n=1/0,a=1/0;-1.88170328*r-.80936493*e>1?(t=[1.19086277,1.76576728,.59662641,.75515197,.56771245],o=4.0767416621,n=-3.3077115913,a=.2309699292):1.81444104*r-1.19445276*e>1?(t=[.73956515,-.45954404,.08285427,.1254107,.14503204],o=-1.2684380046,n=2.6097574011,a=-.3413193965):(t=[1.35733652,-.00915799,-1.1513021,-.50559606,.00692167],o=-.0041960863,n=-.7034186147,a=1.707614701);let s=t[0]+t[1]*r+t[2]*e+t[3]*r*r+t[4]*r*e,h=.3963377774*r+.2158037573*e,l=-.1055613458*r-.0638541728*e,c=-.0894841775*r-1.291485548*e;{let p=1+s*h,i=1+s*l,g=1+s*c,f=p**3,d=i**3,y=g**3,w=3*h*p**2,O=3*l*i**2,$=3*c*g**2,k=6*h**2*p,u=6*l**2*i,x=6*c**2*g,L=o*f+n*d+a*y,B=o*w+n*O+a*$,q=o*k+n*u+a*x;s=s-L*B/(B*B-.5*L*q)}return s}function vr(r,e){let t=Nr(r,e),o=v(Z([1,t*r,t*e,1])),n=Math.cbrt(1/Math.max(o[0],o[1],o[3])),a=n*t;return{L:n,C:a}}function Ur(r,e,t,o,n){let a=vr(r,e);if((t-n)*a.C-(a.L-n)*o<=0)return a.C*n/(o*a.L+a.C*(n-t));let s=a.C*(n-1)/(o*(a.L-1)+a.C*(n-t)),h=t-n,l=o,c=.3963377774*r+.2158037573*e,p=-.1055613458*r-.0638541728*e,i=-.0894841775*r-1.291485548*e,g=h+l*c,f=h+l*p,d=h+l*i,y=n*(1-s)+s*t,w=s*o,O=y+w*c,$=y+w*p,k=y+w*i,u=[[O**3,$**3,k**3],[3*g*O**2,3*f*$**2,3*d*k**2],[6*g**2*O,6*f**2*$,6*d**2*k]],x=b[0][0]*u[0][0]+b[0][1]*u[0][1]+b[0][2]*u[0][2]-1,L=b[0][0]*u[1][0]+b[0][1]*u[1][1]+b[0][2]*u[1][2],B=b[0][0]*u[2][0]+b[0][1]*u[2][1]+b[0][2]*u[2][2],q=L/(L*L-.5*x*B),_r=q>=0?-x*q:1/0,fr=b[1][0]*u[0][0]+b[1][1]*u[0][1]+b[1][2]*u[0][2]-1,K=b[1][0]*u[1][0]+b[1][1]*u[1][1]+b[1][2]*u[1][2],jr=b[1][0]*u[2][0]+b[1][1]*u[2][1]+b[1][2]*u[2][2],mr=K/(K*K-.5*fr*jr),Rr=mr>=0?-fr*mr:1/0,hr=b[2][0]*u[0][0]+b[2][1]*u[0][1]+b[2][2]*u[0][2]-1,H=b[2][0]*u[1][0]+b[2][1]*u[1][1]+b[2][2]*u[1][2],Lr=b[2][0]*u[2][0]+b[2][1]*u[2][1]+b[2][2]*u[2][2],pr=H/(H*H-.5*hr*Lr),Cr=pr>=0?-hr*pr:1/0;return s+Math.min(_r,Rr,Cr)}function P(r){let[e,t,o,n]=r;e=Math.abs(e%360);let a=t*(1-Math.abs(2*o-1)),s=a*(1-Math.abs(e/60%2-1)),h=0,l=0,c=0;0<=e&&e<60?(h=a,l=s):60<=e&&e<120?(h=s,l=a):120<=e&&e<180?(l=a,c=s):180<=e&&e<240?(l=s,c=a):240<=e&&e<300?(h=s,c=a):300<=e&&e<360&&(h=a,c=s);let p=o-a/2;return[h+p,l+p,c+p,n]}function br(r){let[e,t,o,n]=r;if(t+o>=1){let s=t/(t+o);return[s,s,s,n]}let a=P([e,100,50,n]);for(let s=0;s<3;s++)a[s]*=1-t-o,a[s]+=t;return a}function Wr(r,e=2e-4){let[t,o,n,a]=r,s=Math.abs(o)<e&&Math.abs(n)<e?0:Br(Math.atan2(n,o));for(;s<0;)s+=360;for(;s>=360;)s-=360;return[t,Math.sqrt(o**2+n**2),s,a]}function Yr(r){let[e,t,o,n]=r;if(e===0)return[0,0,0,r[3]];for(;o<0;)o+=360;for(;o>=360;)o-=360;let a=Gr(o);return[e,Math.cos(a)*t,Math.sin(a)*t,n]}function Kr(r){return C(r,Tr)}function v(r){let[e,t,o,n]=C([r[0]**3,r[1]**3,r[2]**3,r[3]],b);return[e,t,o,n]}function R(r,e=2.4){let t=Math.abs(r[0]),o=Math.abs(r[1]),n=Math.abs(r[2]);return[t<.0031308?r[0]*12.92:1.055*Math.pow(t,1/e)-.055,o<.0031308?r[1]*12.92:1.055*Math.pow(o,1/e)-.055,n<.0031308?r[2]*12.92:1.055*Math.pow(n,1/e)-.055,r[3]]}function kr(r){let e=C(r,Ir);return[Math.cbrt(e[0]),Math.cbrt(e[1]),Math.cbrt(e[2]),e[3]]}function gr(r){return C(r,Dr)}function Z(r){return C(r,qr)}function U(r){let e=R(v(Z(r)));if(e[0]>1.001||e[0]<-.001||e[1]>1.001||e[1]<-.001||e[2]>1.001||e[2]<-.001){let[t,o,n,a]=r,s=Math.max(1e-5,Math.sqrt(o**2+n**2)),h=m(t,0,1),l=o/s,c=n/s,p=Ur(l,c,t,s,h);return R(v(Z([h*(1-p)+p*t,l*(p*s),c*(p*s),a])))}return e}function J(r){return U(Yr(r))}function j(r,e=2.4){let t=Math.abs(r[0]),o=Math.abs(r[1]),n=Math.abs(r[2]);return[t<.04045?r[0]/12.92:((t+.055)/1.055)**e,o<.04045?r[1]/12.92:((o+.055)/1.055)**e,n<.04045?r[2]/12.92:((n+.055)/1.055)**e,r[3]]}function W(r){return Kr(kr(j(r)))}function Q(r){return Wr(W(r))}function yr(r){return C(r,Sr)}var Hr={black:0,silver:12632256,gray:8421504,white:16777215,maroon:8388608,red:16711680,purple:8388736,fuchsia:16711935,green:32768,lime:65280,olive:8421376,yellow:16776960,navy:128,blue:255,teal:32896,aqua:65535,orange:16753920,aliceblue:15792383,antiquewhite:16444375,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,blanchedalmond:16772045,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,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,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,limegreen:3329330,linen:16445670,magenta:16711935,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,oldlace:16643558,olivedrab:7048739,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,whitesmoke:16119285,yellowgreen:10145074,rebeccapurple:6697881},wr=Hr,Xr=/-?[0-9.]+%?/g,Pr=/^#?[0-9a-f]{3,8}$/i,Zr=16**6,rr=16**4,er=16**2;function F(r){let e=Jr(r),t={get hex(){let o="#";return o+=N(Math.round(m(e[0]*255,0,255)).toString(16),2),o+=N(Math.round(m(e[1]*255,0,255)).toString(16),2),o+=N(Math.round(m(e[2]*255,0,255)).toString(16),2),e[3]<1&&(o+=N(Math.round(e[3]*255).toString(16),2)),o},get hexVal(){e[3]<1&&console.warn(`hexVal converted a semi-transparent color (${e[3]*100}%) to fully opaque`);let o=Math.round(m(e[0]*255,0,255)),n=Math.round(m(e[1]*255,0,255)),a=Math.round(m(e[2]*255,0,255));return o*rr+n*er+a},get rgb(){return _("rgb",e)},rgbVal:e,get rgba(){return _("rgb",e)},rgbaVal:e,get linearRGB(){return _("srgb-linear",j(e))},get linearRGBVal(){return j(e)},get p3(){return _("display-p3",e)},p3Val:e,get oklab(){return _("oklab",W(e))},get oklabVal(){return W(e)},get oklch(){return _("oklch",Q(e))},get oklchVal(){return Q(e)},get xyz(){return _("xyz-d65",gr(j(e)))},get xyzVal(){return gr(j(e))}};return t.toString=()=>t.hex,t}function $r(r){if(r>Zr)throw new Error("8-digit hex values (with transparency) aren\u2019t supported");let e=r,t=Math.floor(e/rr);e-=t*rr;let o=Math.floor(e/er);e-=o*er;let n=e;return[t/255,o/255,n/255,1]}function V(r,e){let t=r.match(Xr);if(!t)throw new Error(`Unexpected color format: ${r}`);let o=[0,0,0,1];return t.forEach((n,a)=>{n.includes("%")?o[a]=parseFloat(n)/100:e[a]===1/0||e[a]===0||e[a]===1?o[a]=parseFloat(n):o[a]=parseFloat(n)/e[a]}),o}function Jr(r){let e=new Error(`Unable to parse color "${r}"`);if(r==null||r==null)throw e;if(Array.isArray(r)){if(typeof r[0]!="number"||typeof r[1]!="number"||typeof r[2]!="number")throw new Error(`Color array must be numbers, received ${r}`);if(r.length<3||r.length>4)throw new Error(`Expected [R, G, B, A?], received ${r}`);return[m(r[0],0,1),m(r[1],0,1),m(r[2],0,1),typeof r[3]=="number"?m(r[3],0,1):1]}if(typeof r=="object"){let t={...r},o=1;for(let n of Object.keys(t))n==="alpha"?o=m(t[n],0,1):t[n.toLowerCase()]=t[n];if("r"in t&&"g"in t&&"b"in t)return[m(t.r||t.R,0,1),m(t.r||t.R,0,1),m(t.r||t.R,0,1),o];if("h"in t&&"s"in t&&"l"in t)return P([t.h,m(t.s,0,1),m(t.l,0,1),o]);if("h"in t&&"w"in t&&"b"in t)return br([t.h,m(t.w,0,1),m(t.b,0,1),o]);if("l"in t&&"a"in t&&"b"in t)return U([t.l,t.a,t.b,o]);if("l"in t&&"c"in t&&"h"in t)return J([t.l,t.c,t.h,o]);if("x"in t&&"y"in t&&"z"in t)return R(yr([t.x,t.y,t.z,o]));throw e}if(typeof r=="number")return $r(r);if(typeof r=="string"){let t=r.trim();if(!t)throw new Error("Expected color, received empty string");let o=t.toLowerCase();if(typeof wr[o]=="number")return $r(wr[o]);if(Pr.test(t)){let s=t.replace("#",""),h=[0,0,0,1];if(s.length>=6)for(let l=0;l<s.length/2;l++){let c=l*2,p=c+2,i=s.substring(c,p);h[l]=parseInt(i,16)/255}else for(let l=0;l<s.length;l++){let c=s.charAt(l);h[l]=parseInt(`${c}${c}`,16)/255}return h}let[n,a]=t.split("(");if(n==="color"){let s=a.indexOf(" ");n=a.substring(0,s),a=a.substring(s)}switch(n){case"rgb":case"rgba":case"srgb":{let[s,h,l,c]=V(a,[255,255,255,1]);return[m(s,0,1),m(h,0,1),m(l,0,1),m(c,0,1)]}case"linear-rgb":case"linear-srgb":case"rgb-linear":case"srgb-linear":{let s=V(a,[255,255,255,1]);return R(s)}case"hsl":case"hsla":{let[s,h,l,c]=V(a,[1,1,1,1]);return P([s,m(h,0,1),m(l,0,1),m(c,0,1)])}case"hwb":case"hwba":{let[s,h,l,c]=V(a,[1,1,1,1]);return br([s,m(h,0,1),m(l,0,1),m(c,0,1)])}case"p3":case"display-p3":{let[s,h,l,c]=V(a,[1,1,1,1]);return[m(s,0,1),m(h,0,1),m(l,0,1),m(c,0,1)]}case"oklab":return U(V(a,[1,1,1,1]));case"oklch":return J(V(a,[1,1,1,1]));case"xyz":case"xyz-d65":return R(yr(V(a,[1,1,1,1])))}}throw e}function tr(r,e,t=.5,o="oklab"){let n=m(t,0,1);if(t===0)return F(r);if(t===1)return F(e);let a=1-n,s=n,h={oklch:Q,oklab:W,lms:x=>j(kr(x)),linearRGB:j,sRGB:x=>x},l={oklch:J,oklab:U,lms:x=>v(R(x)),linearRGB:R,sRGB:x=>x},c=h[o],p=l[o];if(!c)throw new Error(`Unknown color space "${o}", try "oklab", "oklch", "linearRGB", or "sRGB"`);let i=F(r).rgbVal,g=F(e).rgbVal;o==="oklch"&&(i[0]===i[1]&&i[1]===i[2]||g[0]===g[1]&&g[1]===g[2])&&(c=h.oklab,p=l.oklab);let[f,d,y,w]=c(i),[O,$,k,u]=c(g);return o==="oklch"&&Math.abs(k-y)>180&&(Math.max(y,k)===k?k-=360:y-=360),F(p([f*a+O*s,d*a+$*s,y*a+k*s,w*a+u*s]))}function xr(r,e,t="oklab"){let o=m(e,-1,1);return o>=0?tr(r,"black",o,t):Er(r,-o)}function Er(r,e,t="oklab"){let o=m(e,-1,1);return o>=0?tr(r,"white",o,t):xr(r,-o)}function Y(r){return F(r).xyzVal[1]}function Qr(r){return A(F(r).oklabVal[0],5)}function re(r){return Y(r)<.36?"dark":"light"}function ee(r,e){let t=Y(r),o=Y(e),n=Math.max(t,o),a=Math.min(t,o),s=(n+.05)/(a+.05);return{ratio:s,AA:s>=4.5,AAA:s>=7}}var Mr={contrastRatio:ee,darken:xr,from:F,lighten:Er,lightness:Qr,lightOrDark:re,luminance:Y,mix:tr};function z(r){if(!r)throw new Error("missing value");if(typeof r=="string"||typeof r=="number")try{return Mr.from(r).hex}catch{throw new Error(`invalid color "${r}"`)}throw new Error(`expected string, received ${typeof r}`)}function D(r){if(!r)throw new Error("missing value");if(typeof r=="string")return[r];if(Array.isArray(r)){if(r.every(e=>!!e&&typeof e=="string"))return r;throw new Error("expected array of strings")}throw new Error(`expected string or array of strings, received ${typeof r}`)}var te=/^\d+(\.\d+)?(ms|s)$/;function G(r){if(typeof r=="number")return`${r}ms`;if(typeof r=="string"){if(parseFloat(r)===0)return"0ms";if(te.test(r))return r;throw new Error(`invalid duration "${r}"`)}throw new Error(`expected string, received ${typeof r}`)}function E(r){if(typeof r=="number"){if(r===0)return"0";throw new Error("missing units")}if(typeof r=="string")return parseFloat(r)===0?"0":r;throw new Error(`expected string, received ${typeof r}`)}function S(r){if(!r)throw new Error("missing value");if(!Array.isArray(r)||r.length!==4||r.some(e=>typeof e!="number"))throw new Error(`expected [\u{1D465}1, \u{1D466}1, \u{1D465}2, \u{1D466}2], received ${r}`);return[Math.max(0,Math.min(1,r[0])),r[1],Math.max(0,Math.min(1,r[2])),r[3]]}function or(r){if(!r)throw new Error("missing value");if(typeof r=="string")return r;throw new Error(`expected string, received ${typeof r}`)}var Ar=new Set(["solid","dashed","dotted","double","groove","ridge","outset","inset"]);function T(r){if(!Ar.has(r))throw new Error(`Unsupported stroke type "${r}", must be one of: | ||
function M(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function dr(r){return r==null?!0:typeof r=="string"||Array.isArray(r)?r.length===0:M(r)?Object.keys(r).length===0:!1}function X(r,e){if(r==null&&e.undefined)return e.undefined(r);if(typeof r=="string"&&e.string)return e.string(r);if(typeof r=="number"&&e.number)return e.number(r);if(Array.isArray(r)&&e.array)return e.array(r);if(M(r)&&e.object)return e.object(r);if(e.default)return e.default(r)}function N(r,e=2){let t=r;for(;t.length<e;)t=`0${t}`;return t}function Gr(r){return r*(Math.PI/180)}function Br(r){return r*(180/Math.PI)}function m(r,e,t){return Math.min(Math.max(r,e),t)}function _(r,e){let[t,o,n,a]=e,s=a<1?`/${A(a,5)}`:"";switch(r){case"rgb":case"rgba":return a<1?`rgba(${Math.round(t*255)}, ${Math.round(o*255)}, ${Math.round(n*255)}, ${A(a,5)})`:`rgb(${Math.round(t*255)}, ${Math.round(o*255)}, ${Math.round(n*255)})`;case"oklab":case"oklch":return`${r}(${A(t*100,6)}% ${A(o,6)} ${A(n,6)}${s})`;default:return`color(${r} ${A(t,6)} ${A(o,6)} ${A(n,6)}${s})`}}function C(r,e){let t=[...r];for(let o=0;o<e.length;o++){let n=0;for(let a=0;a<e[o].length;a++)n+=r[a]*e[o][a];t[o]=n}return t}function A(r,e=2){let t=10**e;return Math.round(r*t)/t}var Dr=[[.4123907992659593,.357584339383878,.1804807884018343],[.2126390058715102,.715168678767756,.0721923153607337],[.0193308187155918,.11919477979462,.9505321522496607]],Tr=[[3.240969941904522,-1.537383177570094,-.4986107602930034],[-.9692436362808793,1.8759675015077202,.0415550574071756],[.0556300796969937,-.2039769588889766,1.0569715142428782]],Sr=[[.2104542553,.793617785,-.0040720468],[1.9779984951,-2.428592205,.4505937099],[.0259040371,.7827717662,-.808675766]],g=[[4.0767416621,-3.3077115913,.2309699292],[-1.2684380046,2.6097574011,-.3413193965],[-.0041960863,-.7034186147,1.707614701]],Ir=[[.4122214708,.5363325363,.0514459929],[.2119034982,.6806995451,.1073969566],[.0883024619,.2817188376,.6299787005]],qr=[[1,.39633779217376774,.2158037580607588],[1,-.10556134232365633,-.0638541747717059],[1,-.08948418209496574,-1.2914855378640917]];function Nr(r,e){let t=[1/0,1/0,1/0,1/0,1/0],o=1/0,n=1/0,a=1/0;-1.88170328*r-.80936493*e>1?(t=[1.19086277,1.76576728,.59662641,.75515197,.56771245],o=4.0767416621,n=-3.3077115913,a=.2309699292):1.81444104*r-1.19445276*e>1?(t=[.73956515,-.45954404,.08285427,.1254107,.14503204],o=-1.2684380046,n=2.6097574011,a=-.3413193965):(t=[1.35733652,-.00915799,-1.1513021,-.50559606,.00692167],o=-.0041960863,n=-.7034186147,a=1.707614701);let s=t[0]+t[1]*r+t[2]*e+t[3]*r*r+t[4]*r*e,h=.3963377774*r+.2158037573*e,l=-.1055613458*r-.0638541728*e,c=-.0894841775*r-1.291485548*e;{let p=1+s*h,i=1+s*l,b=1+s*c,f=p**3,d=i**3,y=b**3,w=3*h*p**2,V=3*l*i**2,$=3*c*b**2,x=6*h**2*p,u=6*l**2*i,k=6*c**2*b,L=o*f+n*d+a*y,B=o*w+n*V+a*$,q=o*x+n*u+a*k;s=s-L*B/(B*B-.5*L*q)}return s}function vr(r,e){let t=Nr(r,e),o=v(Z([1,t*r,t*e,1])),n=Math.cbrt(1/Math.max(o[0],o[1],o[3])),a=n*t;return{L:n,C:a}}function Wr(r,e,t,o,n){let a=vr(r,e);if((t-n)*a.C-(a.L-n)*o<=0)return a.C*n/(o*a.L+a.C*(n-t));let s=a.C*(n-1)/(o*(a.L-1)+a.C*(n-t)),h=t-n,l=o,c=.3963377774*r+.2158037573*e,p=-.1055613458*r-.0638541728*e,i=-.0894841775*r-1.291485548*e,b=h+l*c,f=h+l*p,d=h+l*i,y=n*(1-s)+s*t,w=s*o,V=y+w*c,$=y+w*p,x=y+w*i,u=[[V**3,$**3,x**3],[3*b*V**2,3*f*$**2,3*d*x**2],[6*b**2*V,6*f**2*$,6*d**2*x]],k=g[0][0]*u[0][0]+g[0][1]*u[0][1]+g[0][2]*u[0][2]-1,L=g[0][0]*u[1][0]+g[0][1]*u[1][1]+g[0][2]*u[1][2],B=g[0][0]*u[2][0]+g[0][1]*u[2][1]+g[0][2]*u[2][2],q=L/(L*L-.5*k*B),_r=q>=0?-k*q:1/0,fr=g[1][0]*u[0][0]+g[1][1]*u[0][1]+g[1][2]*u[0][2]-1,K=g[1][0]*u[1][0]+g[1][1]*u[1][1]+g[1][2]*u[1][2],Rr=g[1][0]*u[2][0]+g[1][1]*u[2][1]+g[1][2]*u[2][2],mr=K/(K*K-.5*fr*Rr),jr=mr>=0?-fr*mr:1/0,hr=g[2][0]*u[0][0]+g[2][1]*u[0][1]+g[2][2]*u[0][2]-1,H=g[2][0]*u[1][0]+g[2][1]*u[1][1]+g[2][2]*u[1][2],Lr=g[2][0]*u[2][0]+g[2][1]*u[2][1]+g[2][2]*u[2][2],pr=H/(H*H-.5*hr*Lr),Cr=pr>=0?-hr*pr:1/0;return s+Math.min(_r,jr,Cr)}function P(r){let[e,t,o,n]=r;e=Math.abs(e%360);let a=t*(1-Math.abs(2*o-1)),s=a*(1-Math.abs(e/60%2-1)),h=0,l=0,c=0;0<=e&&e<60?(h=a,l=s):60<=e&&e<120?(h=s,l=a):120<=e&&e<180?(l=a,c=s):180<=e&&e<240?(l=s,c=a):240<=e&&e<300?(h=s,c=a):300<=e&&e<360&&(h=a,c=s);let p=o-a/2;return[h+p,l+p,c+p,n]}function gr(r){let[e,t,o,n]=r;if(t+o>=1){let s=t/(t+o);return[s,s,s,n]}let a=P([e,100,50,n]);for(let s=0;s<3;s++)a[s]*=1-t-o,a[s]+=t;return a}function Ur(r,e=2e-4){let[t,o,n,a]=r,s=Math.abs(o)<e&&Math.abs(n)<e?0:Br(Math.atan2(n,o));for(;s<0;)s+=360;for(;s>=360;)s-=360;return[t,Math.sqrt(o**2+n**2),s,a]}function Yr(r){let[e,t,o,n]=r;if(e===0)return[0,0,0,r[3]];for(;o<0;)o+=360;for(;o>=360;)o-=360;let a=Gr(o);return[e,Math.cos(a)*t,Math.sin(a)*t,n]}function Kr(r){return C(r,Sr)}function v(r){let[e,t,o,n]=C([r[0]**3,r[1]**3,r[2]**3,r[3]],g);return[e,t,o,n]}function j(r,e=2.4){let t=Math.abs(r[0]),o=Math.abs(r[1]),n=Math.abs(r[2]);return[t<.0031308?r[0]*12.92:1.055*Math.pow(t,1/e)-.055,o<.0031308?r[1]*12.92:1.055*Math.pow(o,1/e)-.055,n<.0031308?r[2]*12.92:1.055*Math.pow(n,1/e)-.055,r[3]]}function xr(r){let e=C(r,Ir);return[Math.cbrt(e[0]),Math.cbrt(e[1]),Math.cbrt(e[2]),e[3]]}function br(r){return C(r,Dr)}function Z(r){return C(r,qr)}function W(r){let e=j(v(Z(r)));if(e[0]>1.001||e[0]<-.001||e[1]>1.001||e[1]<-.001||e[2]>1.001||e[2]<-.001){let[t,o,n,a]=r,s=Math.max(1e-5,Math.sqrt(o**2+n**2)),h=m(t,0,1),l=o/s,c=n/s,p=Wr(l,c,t,s,h);return j(v(Z([h*(1-p)+p*t,l*(p*s),c*(p*s),a])))}return e}function J(r){return W(Yr(r))}function R(r,e=2.4){let t=Math.abs(r[0]),o=Math.abs(r[1]),n=Math.abs(r[2]);return[t<.04045?r[0]/12.92:((t+.055)/1.055)**e,o<.04045?r[1]/12.92:((o+.055)/1.055)**e,n<.04045?r[2]/12.92:((n+.055)/1.055)**e,r[3]]}function U(r){return Kr(xr(R(r)))}function Q(r){return Ur(U(r))}function yr(r){return C(r,Tr)}var Hr={black:0,silver:12632256,gray:8421504,white:16777215,maroon:8388608,red:16711680,purple:8388736,fuchsia:16711935,green:32768,lime:65280,olive:8421376,yellow:16776960,navy:128,blue:255,teal:32896,aqua:65535,orange:16753920,aliceblue:15792383,antiquewhite:16444375,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,blanchedalmond:16772045,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,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,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,limegreen:3329330,linen:16445670,magenta:16711935,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,oldlace:16643558,olivedrab:7048739,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,whitesmoke:16119285,yellowgreen:10145074,rebeccapurple:6697881},wr=Hr,Xr=/-?[0-9.]+%?/g,Pr=/^#?[0-9a-f]{3,8}$/i,Zr=16**6,rr=16**4,er=16**2;function O(r){let e=Jr(r),t={get hex(){let o="#";return o+=N(Math.round(m(e[0]*255,0,255)).toString(16),2),o+=N(Math.round(m(e[1]*255,0,255)).toString(16),2),o+=N(Math.round(m(e[2]*255,0,255)).toString(16),2),e[3]<1&&(o+=N(Math.round(e[3]*255).toString(16),2)),o},get hexVal(){e[3]<1&&console.warn(`hexVal converted a semi-transparent color (${e[3]*100}%) to fully opaque`);let o=Math.round(m(e[0]*255,0,255)),n=Math.round(m(e[1]*255,0,255)),a=Math.round(m(e[2]*255,0,255));return o*rr+n*er+a},get rgb(){return _("rgb",e)},rgbVal:e,get rgba(){return _("rgb",e)},rgbaVal:e,get linearRGB(){return _("srgb-linear",R(e))},get linearRGBVal(){return R(e)},get p3(){return _("display-p3",e)},p3Val:e,get oklab(){return _("oklab",U(e))},get oklabVal(){return U(e)},get oklch(){return _("oklch",Q(e))},get oklchVal(){return Q(e)},get xyz(){return _("xyz-d65",br(R(e)))},get xyzVal(){return br(R(e))}};return t.toString=()=>t.hex,t}function $r(r){if(r>Zr)throw new Error("8-digit hex values (with transparency) aren\u2019t supported");let e=r,t=Math.floor(e/rr);e-=t*rr;let o=Math.floor(e/er);e-=o*er;let n=e;return[t/255,o/255,n/255,1]}function F(r,e){let t=r.match(Xr);if(!t)throw new Error(`Unexpected color format: ${r}`);let o=[0,0,0,1];return t.forEach((n,a)=>{n.includes("%")?o[a]=parseFloat(n)/100:e[a]===1/0||e[a]===0||e[a]===1?o[a]=parseFloat(n):o[a]=parseFloat(n)/e[a]}),o}function Jr(r){let e=new Error(`Unable to parse color "${r}"`);if(r==null||r==null)throw e;if(Array.isArray(r)){if(typeof r[0]!="number"||typeof r[1]!="number"||typeof r[2]!="number")throw new Error(`Color array must be numbers, received ${r}`);if(r.length<3||r.length>4)throw new Error(`Expected [R, G, B, A?], received ${r}`);return[m(r[0],0,1),m(r[1],0,1),m(r[2],0,1),typeof r[3]=="number"?m(r[3],0,1):1]}if(typeof r=="object"){let t={...r},o=1;for(let n of Object.keys(t))n==="alpha"?o=m(t[n],0,1):t[n.toLowerCase()]=t[n];if("r"in t&&"g"in t&&"b"in t)return[m(t.r||t.R,0,1),m(t.r||t.R,0,1),m(t.r||t.R,0,1),o];if("h"in t&&"s"in t&&"l"in t)return P([t.h,m(t.s,0,1),m(t.l,0,1),o]);if("h"in t&&"w"in t&&"b"in t)return gr([t.h,m(t.w,0,1),m(t.b,0,1),o]);if("l"in t&&"a"in t&&"b"in t)return W([t.l,t.a,t.b,o]);if("l"in t&&"c"in t&&"h"in t)return J([t.l,t.c,t.h,o]);if("x"in t&&"y"in t&&"z"in t)return j(yr([t.x,t.y,t.z,o]));throw e}if(typeof r=="number")return $r(r);if(typeof r=="string"){let t=r.trim();if(!t)throw new Error("Expected color, received empty string");let o=t.toLowerCase();if(typeof wr[o]=="number")return $r(wr[o]);if(Pr.test(t)){let s=t.replace("#",""),h=[0,0,0,1];if(s.length>=6)for(let l=0;l<s.length/2;l++){let c=l*2,p=c+2,i=s.substring(c,p);h[l]=parseInt(i,16)/255}else for(let l=0;l<s.length;l++){let c=s.charAt(l);h[l]=parseInt(`${c}${c}`,16)/255}return h}let[n,a]=t.split("(");if(n==="color"){let s=a.indexOf(" ");n=a.substring(0,s),a=a.substring(s)}switch(n){case"rgb":case"rgba":case"srgb":{let[s,h,l,c]=F(a,[255,255,255,1]);return[m(s,0,1),m(h,0,1),m(l,0,1),m(c,0,1)]}case"linear-rgb":case"linear-srgb":case"rgb-linear":case"srgb-linear":{let s=F(a,[255,255,255,1]);return j(s)}case"hsl":case"hsla":{let[s,h,l,c]=F(a,[1,1,1,1]);return P([s,m(h,0,1),m(l,0,1),m(c,0,1)])}case"hwb":case"hwba":{let[s,h,l,c]=F(a,[1,1,1,1]);return gr([s,m(h,0,1),m(l,0,1),m(c,0,1)])}case"p3":case"display-p3":{let[s,h,l,c]=F(a,[1,1,1,1]);return[m(s,0,1),m(h,0,1),m(l,0,1),m(c,0,1)]}case"oklab":return W(F(a,[1,1,1,1]));case"oklch":return J(F(a,[1,1,1,1]));case"xyz":case"xyz-d65":return j(yr(F(a,[1,1,1,1])))}}throw e}function tr(r,e,t=.5,o="oklab"){let n=m(t,0,1);if(t===0)return O(r);if(t===1)return O(e);let a=1-n,s=n,h={oklch:Q,oklab:U,lms:k=>R(xr(k)),linearRGB:R,sRGB:k=>k},l={oklch:J,oklab:W,lms:k=>v(j(k)),linearRGB:j,sRGB:k=>k},c=h[o],p=l[o];if(!c)throw new Error(`Unknown color space "${o}", try "oklab", "oklch", "linearRGB", or "sRGB"`);let i=O(r).rgbVal,b=O(e).rgbVal;o==="oklch"&&(i[0]===i[1]&&i[1]===i[2]||b[0]===b[1]&&b[1]===b[2])&&(c=h.oklab,p=l.oklab);let[f,d,y,w]=c(i),[V,$,x,u]=c(b);return o==="oklch"&&Math.abs(x-y)>180&&(Math.max(y,x)===x?x-=360:y-=360),O(p([f*a+V*s,d*a+$*s,y*a+x*s,w*a+u*s]))}function kr(r,e,t="oklab"){let o=m(e,-1,1);return o>=0?tr(r,"black",o,t):Er(r,-o)}function Er(r,e,t="oklab"){let o=m(e,-1,1);return o>=0?tr(r,"white",o,t):kr(r,-o)}function Y(r){return O(r).xyzVal[1]}function Qr(r){return A(O(r).oklabVal[0],5)}function re(r){return Y(r)<.36?"dark":"light"}function ee(r,e){let t=Y(r),o=Y(e),n=Math.max(t,o),a=Math.min(t,o),s=(n+.05)/(a+.05);return{ratio:s,AA:s>=4.5,AAA:s>=7}}var Mr={contrastRatio:ee,darken:kr,from:O,lighten:Er,lightness:Qr,lightOrDark:re,luminance:Y,mix:tr};function z(r){if(!r)throw new Error("missing value");if(typeof r=="string"||typeof r=="number")try{return Mr.from(r).hex}catch{throw new Error(`invalid color "${r}"`)}throw new Error(`expected string, received ${typeof r}`)}function D(r){if(!r)throw new Error("missing value");if(typeof r=="string")return[r];if(Array.isArray(r)){if(r.every(e=>!!e&&typeof e=="string"))return r;throw new Error("expected array of strings")}throw new Error(`expected string or array of strings, received ${typeof r}`)}var te=/^\d+(\.\d+)?(ms|s)$/;function G(r){if(typeof r=="number")return`${r}ms`;if(typeof r=="string"){if(parseFloat(r)===0)return"0ms";if(te.test(r))return r;throw new Error(`invalid duration "${r}"`)}throw new Error(`expected string, received ${typeof r}`)}function E(r){if(typeof r=="number"){if(r===0)return"0";throw new Error("missing units")}if(typeof r=="string")return parseFloat(r)===0?"0":r;throw new Error(`expected string, received ${typeof r}`)}function T(r){if(!r)throw new Error("missing value");if(!Array.isArray(r)||r.length!==4||r.some(e=>typeof e!="number"))throw new Error(`expected [\u{1D465}1, \u{1D466}1, \u{1D465}2, \u{1D466}2], received ${r}`);return[Math.max(0,Math.min(1,r[0])),r[1],Math.max(0,Math.min(1,r[2])),r[3]]}function or(r){if(!r)throw new Error("missing value");if(typeof r=="string")return r;throw new Error(`expected string, received ${typeof r}`)}var Ar=new Set(["solid","dashed","dotted","double","groove","ridge","outset","inset"]);function S(r){if(!Ar.has(r))throw new Error(`Unsupported stroke type "${r}", must be one of: | ||
- ${[...Ar].join(` | ||
- `)}`);return r}function nr(r){if(!M(r))throw new Error(`Expected object, received ${Array.isArray(r)?"array":typeof r}`);let e={};if(!Object.keys(r).length)throw new Error("Must specify at least 1 property for border");for(let t of Object.keys(r))switch(t){case"color":{e.color=z(r.color);break}case"width":{e.width=E(r.width);break}case"style":{e.style=T(r.style);break}default:throw new Error(`Unknown property "${t}" on border token`)}return e}var oe=[.25,.1,.25,1];function ir(r){if(!r)throw new Error("missing value");if(typeof r!="object"||Array.isArray(r))throw new Error("invalid transition format, e");if(!Object.keys(r).length)throw new Error("At least 1 transition property is required");let e=r;return{duration:G(e.duration||"0"),delay:G(e.delay||"0"),timingFunction:S(e.timingFunction||oe)}}function ar(r){if(!r)throw new Error("missing value");if(typeof r!="object"||Array.isArray(r))throw new Error("invalid shadow");let e=r;return["offsetX","offsetX","blur","spread","color"].forEach(t=>{if(typeof e[t]=="number"&&e[t]>0)throw new Error(`${t} missing units`);if((t==="offsetX"||t==="offsetY")&&typeof e[t]!="string"&&e[t]!==0)throw new Error(`missing ${t}`)}),{offsetX:E(e.offsetX||"0"),offsetY:E(e.offsetY||"0"),blur:E(e.blur||"0"),spread:E(e.spread||"0"),color:z(e.color)}}function sr(r){if(!r)throw new Error("missing value");if(!Array.isArray(r))throw new Error(`expected array of gradient stops, received ${typeof r}`);if(r.some(e=>!e||!e.color))throw new Error("all gradient stops must have color");return r.map(e=>({color:z(e.color),position:typeof e.position=="number"?Math.max(0,Math.min(1,e.position)):void 0}))}var Fe=!process.env.NODE_DISABLE_COLORS&&(!process.env.NO_COLOR||process.env.NO_COLOR=="0");var ne=["0-9","A-Za-z","\xC0-\xFF","\u0100-\u017F","\u0180-\u024F","\u0370-\u03FF","\u0400-\u04FF","\u0530-\u058F","\u0590-\u05FF","\u0600-\u06FF","\u0900-\u097F","\u1100-\u11FF","\u3040-\u309F","\u30A0-\u30FF","\u3400-\u4DBF","\u4E00-\u9FFF"];var ie=/[^-_.\s][-_.\s]+[^-_.\s]/g,Re=new RegExp(`^[${ne.join("")}]+$`);function zr(r){return r.replace(ie,e=>`${e[0].toLocaleLowerCase()}${e[e.length-1].toLocaleUpperCase()}`)}var Or=new Map([["thin",100],["hairline",100],["extra-light",200],["ultra-light",200],["light",300],["normal",400],["regular",400],["book",400],["medium",500],["semi-bold",600],["demi-bold",600],["bold",700],["extra-bold",800],["ultra-bold",800],["black",900],["heavy",900],["extra-black",950],["ultra-black",950]]);function lr(r){if(!r)throw new Error("missing value");if(typeof r!="object"||Array.isArray(r))throw new Error(`expected object, received ${Array.isArray(r)?"array":typeof r}`);if(!Object.keys(r).length)throw new Error("must specify at least 1 font property");let e={};for(let[t,o]of Object.entries(r)){let n=zr(t);switch(n){case"fontName":case"fontFamily":{e.fontFamily=D(o);break}case"fontWeight":{if(typeof o=="string"){let a=Or.get(o);if(a)e.fontWeight=a;else throw new Error(`invalid font weight "${o}", use number (1-999) or any of: | ||
- ${[...Or.values()].join(` | ||
- `)}`)}else typeof o=="number"&&(e.fontWeight=Math.max(1,Math.min(999,o)));break}default:{e[n]=typeof o=="string"&&parseFloat(o)>=0?E(o):o;break}}}return e}var I=/^\{([^}]+)\}$/,Vr=new Set(["$description","$name","$type","$value","$extensions"]);function cr(r){let e=[],t=[],o={result:{metadata:{},tokens:[]}};if(!r||typeof r!="object"||Array.isArray(r))return e.push(`Invalid schema type. Expected object, received "${Array.isArray(r)?"Array":typeof r}"`),o.errors=e,o;let n={};function a(i,g=[],f={$extensions:{requiredModes:[]}}){if(!(!i||!M(i)))for(let[d,y]of Object.entries(i)){if(!y||!M(y)){e.push(`${d}: unexpected token format "${y}"`);continue}if(d.includes(".")||d.includes("{")||d.includes("}")||d.includes("#")){e.push(`${d}: IDs can\u2019t include any of the following: .{}#`);continue}Object.keys(y).length||e.push(`${d}: groups can\u2019t be empty`);let w={_original:{...y},_group:{id:g.join(".")||".",...f||{}},id:g.concat(d).join("."),$type:y.$type||f.$type,...y};if(w.hasOwnProperty("$value")){if(d.startsWith("$")){e.push(`${d}: token ID can\u2019t start with the $ character`);continue}if(dr(w.$value)){e.push(`${w.id}: missing "$value"`);continue}if(!!w.$extensions&&w.$extensions.mode&&!M(w.$extensions.mode)&&e.push(`${w.id}: "mode" must be an object`),f.$extensions.requiredModes.length)for(let $ of f.$extensions.requiredModes)(!w.$extensions||!w.$extensions.mode||!w.$extensions.mode[$])&&e.push(`${w.id}: missing mode "${$}" required from parent group`);n[w.id]=w}else{let $={...f},k={};for(let u of Object.keys(y))u.startsWith("$")?(u==="$extensions"?$.$extensions={...$.$extensions,...y.$extensions}:$[u]=y[u],Vr.has(u)||(o.warnings||(o.warnings=[]),o.warnings.push(`Unknown property "${u}"`))):k[u]=y[u];if(Object.values(k).every(u=>M(u)))a(k,[...g,d],$);else throw new Error(`${d}: missing $type`)}}}let s={$extensions:{requiredModes:[]}},h={};for(let i of Object.keys(r))i.startsWith("$")?(i==="$extensions"?s.$extensions={...s.$extensions,...r.$extensions}:s[i]=r[i],Vr.has(i)||(o.warnings||(o.warnings=[]),o.warnings.push(`Unknown property "${i}"`)),o.result.metadata[i]=r[i]):h[i]=r[i];if(a(h,[],s),e.length)return o.errors=e,o;let l={};for(let i of Object.values(n))if(l[i.id]=i.$value,i.$extensions&&i.$extensions.mode)for(let[g,f]of Object.entries(i.$extensions.mode||{}))l[`${i.id}#${g}`]=f;function c(i,g){return X(g,{default(f){return f},string(f){if(!I.test(f))return f;let d=Fr(f);if(!l[d])throw new Error(`${i}: can\u2019t find ${f}`);let y=l[d];if(typeof y=="string"&&I.test(y)&&i===Fr(y))throw new Error(`${i}: can\u2019t reference circular alias ${f}`);return l[d]},array(f){return f.map(d=>c(i,d))},object(f){for(let d of Object.keys(f))f[d]=c(i,f[d]);return f}})}for(;ur(l);)try{for(let[i,g]of Object.entries(l))l[i]=c(i,g)}catch(i){e.push(i.message||i);break}if(e.length)return o.errors=e,o;function p(i,g){let f=n[i];if(!(!f.$extensions||!f.$extensions.mode))for(let d of Object.keys(f.$extensions.mode||{}))n[i].$extensions.mode[d]=g(l[`${i}#${d}`])}for(let[i,g]of Object.entries(n))try{switch(g.$type){case"color":n[i].$value=z(l[i]),p(i,z);break;case"dimension":n[i].$value=E(l[i]),p(i,E);break;case"font":n[i].$value=D(l[i]),p(i,D);break;case"duration":n[i].$value=G(l[i]),p(i,G);break;case"cubicBezier":n[i].$value=S(l[i]),p(i,S);break;case"link":n[i].$value=or(l[i]),p(i,or);break;case"strokeStyle":n[i].$value=T(l[i]),p(i,T);break;case"border":n[i].$value=nr(l[i]),p(i,nr);break;case"transition":n[i].$value=ir(l[i]),p(i,ir);break;case"shadow":n[i].$value=ar(l[i]),p(i,ar);break;case"gradient":n[i].$value=sr(l[i]),p(i,sr);break;case"typography":n[i].$value=lr(l[i]),p(i,lr);break;default:n[i].value=l[i],p(i,f=>f);break}}catch(f){e.push(`${i}: ${f.message||f}`)}return e.length&&(o.errors=e),t.length&&(o.warnings=t),o.result.tokens=Object.values(n),o}function ur(r){return Object.values(r).some(e=>X(e,{default:()=>!1,string:t=>I.test(t),array:t=>t.some(o=>typeof o=="string"?I.test(o):M(o)?ur(o):!1),object:t=>ur(t)}))}function Fr(r){let e=r.match(I);return e?e[1]:r}var ot={parse:cr};export{ot as default,cr as parse}; | ||
- `)}`);return r}function nr(r){if(!M(r))throw new Error(`Expected object, received ${Array.isArray(r)?"array":typeof r}`);let e=r;if(!("color"in e))throw new Error('Token missing required "color" property');if(!("width"in e))throw new Error('Token missing required "width" property');if(!("style"in e))throw new Error('Token missing required "style" property');return{color:z(e.color),width:E(e.width),style:S(e.style)}}var oe=[.25,.1,.25,1];function ir(r){if(!r)throw new Error("missing value");if(typeof r!="object"||Array.isArray(r))throw new Error("invalid transition format, e");if(!Object.keys(r).length)throw new Error("At least 1 transition property is required");let e=r;return{duration:G(e.duration||"0"),delay:G(e.delay||"0"),timingFunction:T(e.timingFunction||oe)}}function ar(r){if(!r)throw new Error("missing value");if(typeof r!="object"||Array.isArray(r))throw new Error("invalid shadow");let e=r;return["offsetX","offsetX","blur","spread","color"].forEach(t=>{if(typeof e[t]=="number"&&e[t]>0)throw new Error(`${t} missing units`);if((t==="offsetX"||t==="offsetY")&&typeof e[t]!="string"&&e[t]!==0)throw new Error(`missing ${t}`)}),{offsetX:E(e.offsetX||"0"),offsetY:E(e.offsetY||"0"),blur:E(e.blur||"0"),spread:E(e.spread||"0"),color:z(e.color)}}function sr(r){if(!r)throw new Error("missing value");if(!Array.isArray(r))throw new Error(`expected array of gradient stops, received ${typeof r}`);if(r.some(e=>!e||!e.color))throw new Error("all gradient stops must have color");return r.map(e=>({color:z(e.color),position:typeof e.position=="number"?Math.max(0,Math.min(1,e.position)):void 0}))}var Oe=!process.env.NODE_DISABLE_COLORS&&(!process.env.NO_COLOR||process.env.NO_COLOR=="0");var ne=["0-9","A-Za-z","\xC0-\xFF","\u0100-\u017F","\u0180-\u024F","\u0370-\u03FF","\u0400-\u04FF","\u0530-\u058F","\u0590-\u05FF","\u0600-\u06FF","\u0900-\u097F","\u1100-\u11FF","\u3040-\u309F","\u30A0-\u30FF","\u3400-\u4DBF","\u4E00-\u9FFF"];var ie=/[^-_.\s][-_.\s]+[^-_.\s]/g,je=new RegExp(`^[${ne.join("")}]+$`);function zr(r){return r.replace(ie,e=>`${e[0].toLocaleLowerCase()}${e[e.length-1].toLocaleUpperCase()}`)}var Vr=new Map([["thin",100],["hairline",100],["extra-light",200],["ultra-light",200],["light",300],["normal",400],["regular",400],["book",400],["medium",500],["semi-bold",600],["demi-bold",600],["bold",700],["extra-bold",800],["ultra-bold",800],["black",900],["heavy",900],["extra-black",950],["ultra-black",950]]);function lr(r){if(!r)throw new Error("missing value");if(typeof r!="object"||Array.isArray(r))throw new Error(`expected object, received ${Array.isArray(r)?"array":typeof r}`);if(!Object.keys(r).length)throw new Error("must specify at least 1 font property");let e={};for(let[t,o]of Object.entries(r)){let n=zr(t);switch(n){case"fontName":case"fontFamily":{e.fontFamily=D(o);break}case"fontWeight":{if(typeof o=="string"){let a=Vr.get(o);if(a)e.fontWeight=a;else throw new Error(`invalid font weight "${o}", use number (1-999) or any of: | ||
- ${[...Vr.values()].join(` | ||
- `)}`)}else typeof o=="number"&&(e.fontWeight=Math.max(1,Math.min(999,o)));break}default:{e[n]=typeof o=="string"&&parseFloat(o)>=0?E(o):o;break}}}return e}var I=/^\{([^}]+)\}$/,Fr=new Set(["$description","$name","$type","$value","$extensions"]);function cr(r){let e=[],t=[],o={result:{metadata:{},tokens:[]}};if(!r||typeof r!="object"||Array.isArray(r))return e.push(`Invalid schema type. Expected object, received "${Array.isArray(r)?"Array":typeof r}"`),o.errors=e,o;let n={};function a(i,b=[],f={$extensions:{requiredModes:[]}}){if(!(!i||!M(i)))for(let[d,y]of Object.entries(i)){if(!y||!M(y)){e.push(`${d}: unexpected token format "${y}"`);continue}if(d.includes(".")||d.includes("{")||d.includes("}")||d.includes("#")){e.push(`${d}: IDs can\u2019t include any of the following: .{}#`);continue}Object.keys(y).length||e.push(`${d}: groups can\u2019t be empty`);let w={_original:{...y},_group:{id:b.join(".")||".",...f||{}},id:b.concat(d).join("."),$type:y.$type||f.$type,...y};if(w.hasOwnProperty("$value")){if(d.startsWith("$")){e.push(`${d}: token ID can\u2019t start with the $ character`);continue}if(dr(w.$value)){e.push(`${w.id}: missing "$value"`);continue}if(!!w.$extensions&&w.$extensions.mode&&!M(w.$extensions.mode)&&e.push(`${w.id}: "mode" must be an object`),f.$extensions.requiredModes.length)for(let $ of f.$extensions.requiredModes)(!w.$extensions||!w.$extensions.mode||!w.$extensions.mode[$])&&e.push(`${w.id}: missing mode "${$}" required from parent group`);n[w.id]=w}else{let $={...f},x={};for(let u of Object.keys(y))u.startsWith("$")?(u==="$extensions"?$.$extensions={...$.$extensions,...y.$extensions}:$[u]=y[u],Fr.has(u)||(o.warnings||(o.warnings=[]),o.warnings.push(`Unknown property "${u}"`))):x[u]=y[u];if(Object.values(x).every(u=>M(u)))a(x,[...b,d],$);else throw new Error(`${d}: missing $type`)}}}let s={$extensions:{requiredModes:[]}},h={};for(let i of Object.keys(r))i.startsWith("$")?(i==="$extensions"?s.$extensions={...s.$extensions,...r.$extensions}:s[i]=r[i],Fr.has(i)||(o.warnings||(o.warnings=[]),o.warnings.push(`Unknown property "${i}"`)),o.result.metadata[i]=r[i]):h[i]=r[i];if(a(h,[],s),e.length)return o.errors=e,o;let l={};for(let i of Object.values(n))if(l[i.id]=i.$value,i.$extensions&&i.$extensions.mode)for(let[b,f]of Object.entries(i.$extensions.mode||{}))l[`${i.id}#${b}`]=f;function c(i,b){return X(b,{default(f){return f},string(f){if(!I.test(f))return f;let d=Or(f);if(!l[d])throw new Error(`${i}: can\u2019t find ${f}`);let y=l[d];if(typeof y=="string"&&I.test(y)&&i===Or(y))throw new Error(`${i}: can\u2019t reference circular alias ${f}`);return l[d]},array(f){return f.map(d=>c(i,d))},object(f){for(let d of Object.keys(f))f[d]=c(i,f[d]);return f}})}for(;ur(l);)try{for(let[i,b]of Object.entries(l))l[i]=c(i,b)}catch(i){e.push(i.message||i);break}if(e.length)return o.errors=e,o;function p(i,b){let f=n[i];if(!(!f.$extensions||!f.$extensions.mode))for(let d of Object.keys(f.$extensions.mode||{}))n[i].$extensions.mode[d]=b(l[`${i}#${d}`])}for(let[i,b]of Object.entries(n))try{switch(b.$type){case"color":n[i].$value=z(l[i]),p(i,z);break;case"dimension":n[i].$value=E(l[i]),p(i,E);break;case"font":n[i].$value=D(l[i]),p(i,D);break;case"duration":n[i].$value=G(l[i]),p(i,G);break;case"cubicBezier":n[i].$value=T(l[i]),p(i,T);break;case"link":n[i].$value=or(l[i]),p(i,or);break;case"strokeStyle":n[i].$value=S(l[i]),p(i,S);break;case"border":n[i].$value=nr(l[i]),p(i,nr);break;case"transition":n[i].$value=ir(l[i]),p(i,ir);break;case"shadow":n[i].$value=ar(l[i]),p(i,ar);break;case"gradient":n[i].$value=sr(l[i]),p(i,sr);break;case"typography":n[i].$value=lr(l[i]),p(i,lr);break;default:n[i].value=l[i],p(i,f=>f);break}}catch(f){e.push(`${i}: ${f.message||f}`)}return e.length&&(o.errors=e),t.length&&(o.warnings=t),o.result.tokens=Object.values(n),o}function ur(r){return Object.values(r).some(e=>X(e,{default:()=>!1,string:t=>I.test(t),array:t=>t.some(o=>typeof o=="string"?I.test(o):M(o)?ur(o):!1),object:t=>ur(t)}))}function Or(r){let e=r.match(I);return e?e[1]:r}var ot={parse:cr};export{ot as default,cr as parse}; | ||
//# sourceMappingURL=index.min.js.map |
@@ -20,27 +20,15 @@ import { isObj } from '../../util.js'; | ||
throw new Error(`Expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
const normalized = {}; | ||
if (!Object.keys(value).length) | ||
throw new Error(`Must specify at least 1 property for border`); | ||
for (const k of Object.keys(value)) { | ||
// note: all properties are required | ||
switch (k) { | ||
case 'color': { | ||
normalized.color = normalizeColorValue(value.color); | ||
break; | ||
} | ||
case 'width': { | ||
normalized.width = normalizeDimensionValue(value.width); | ||
break; | ||
} | ||
case 'style': { | ||
normalized.style = normalizeStrokeStyleValue(value.style); | ||
break; | ||
} | ||
default: { | ||
throw new Error(`Unknown property "${k}" on border token`); | ||
} | ||
} | ||
} | ||
return normalized; | ||
const tokenValue = value; | ||
if (!('color' in tokenValue)) | ||
throw new Error(`Token missing required "color" property`); | ||
if (!('width' in tokenValue)) | ||
throw new Error(`Token missing required "width" property`); | ||
if (!('style' in tokenValue)) | ||
throw new Error(`Token missing required "style" property`); | ||
return { | ||
color: normalizeColorValue(tokenValue.color), | ||
width: normalizeDimensionValue(tokenValue.width), | ||
style: normalizeStrokeStyleValue(tokenValue.style), | ||
}; | ||
} | ||
//# sourceMappingURL=border.js.map |
{ | ||
"name": "@cobalt-ui/core", | ||
"description": "CLI for using the W3C design token format", | ||
"version": "0.6.4", | ||
"version": "0.7.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Drew Powers", |
@@ -1,2 +0,2 @@ | ||
import type {ParsedBorderToken} from '../../token.js'; | ||
import type {BorderToken, ParsedBorderToken} from '../../token.js'; | ||
import {isObj} from '../../util.js'; | ||
@@ -22,25 +22,11 @@ import {normalizeColorValue} from './color.js'; | ||
if (!isObj(value)) throw new Error(`Expected object, received ${Array.isArray(value) ? 'array' : typeof value}`); | ||
const normalized = {} as ParsedBorderToken['$value']; | ||
if (!Object.keys(value as any).length) throw new Error(`Must specify at least 1 property for border`); | ||
for (const k of Object.keys(value as ParsedBorderToken['$value'])) { | ||
// note: all properties are required | ||
switch (k) { | ||
case 'color': { | ||
normalized.color = normalizeColorValue((value as any).color); | ||
break; | ||
} | ||
case 'width': { | ||
normalized.width = normalizeDimensionValue((value as any).width); | ||
break; | ||
} | ||
case 'style': { | ||
normalized.style = normalizeStrokeStyleValue((value as any).style); | ||
break; | ||
} | ||
default: { | ||
throw new Error(`Unknown property "${k}" on border token`); | ||
} | ||
} | ||
} | ||
return normalized; | ||
const tokenValue = value as BorderToken['$value']; | ||
if (!('color' in tokenValue)) throw new Error(`Token missing required "color" property`); | ||
if (!('width' in tokenValue)) throw new Error(`Token missing required "width" property`); | ||
if (!('style' in tokenValue)) throw new Error(`Token missing required "style" property`); | ||
return { | ||
color: normalizeColorValue(tokenValue.color), | ||
width: normalizeDimensionValue(tokenValue.width), | ||
style: normalizeStrokeStyleValue(tokenValue.style), | ||
}; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168118
2233