Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cobalt-ui/core

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cobalt-ui/core - npm Package Compare versions

Comparing version 0.7.3 to 0.7.4

6

CHANGELOG.md
# @cobalt-ui/core
## 0.7.4
### Patch Changes
- 91ff661: Update better-color-tools
## 0.7.3

@@ -4,0 +10,0 @@

10

dist/index.min.js

@@ -1,6 +0,6 @@

var se=typeof process!==void 0?!process.env.NODE_DISABLE_COLORS&&(!process.env.NO_COLOR||process.env.NO_COLOR=="0"):!0;var Br=["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 Dr=/[^-_.\s][-_.\s]+[^-_.\s]/g,ce=new RegExp(`^[${Br.join("")}]+$`);function gr(r){return r.replace(Dr,e=>`${e[0].toLocaleLowerCase()}${e[e.length-1].toLocaleUpperCase()}`)}function N(r){if(!r||typeof r=="string"||typeof r=="boolean"||typeof r=="number")return r;if(Array.isArray(r)){let t=[];for(let o of r)t.push(N(o));return t}let e={};for(let[t,o]of Object.entries(r))e[t]=N(o);return e}function A(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function br(r){return r==null?!0:typeof r=="string"||Array.isArray(r)?r.length===0:A(r)?Object.keys(r).length===0:!1}function P(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(A(r)&&e.object)return e.object(r);if(e.default)return e.default(r)}function v(r,e=2){let t=r;for(;t.length<e;)t=`0${t}`;return t}function Sr(r){return r*(Math.PI/180)}function Tr(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?`/${M(a,5)}`:"";switch(r){case"rgb":case"rgba":return a<1?`rgba(${Math.round(t*255)}, ${Math.round(o*255)}, ${Math.round(n*255)}, ${M(a,5)})`:`rgb(${Math.round(t*255)}, ${Math.round(o*255)}, ${Math.round(n*255)})`;case"oklab":case"oklch":return`${r}(${M(t*100,6)}% ${M(o,6)} ${M(n,6)}${s})`;default:return`color(${r} ${M(t,6)} ${M(o,6)} ${M(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 M(r,e=2){let t=10**e;return Math.round(r*t)/t}var Ir=[[.4123907992659593,.357584339383878,.1804807884018343],[.2126390058715102,.715168678767756,.0721923153607337],[.0193308187155918,.11919477979462,.9505321522496607]],qr=[[3.240969941904522,-1.537383177570094,-.4986107602930034],[-.9692436362808793,1.8759675015077202,.0415550574071756],[.0556300796969937,-.2039769588889766,1.0569715142428782]],Nr=[[.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]],vr=[[.4122214708,.5363325363,.0514459929],[.2119034982,.6806995451,.1073969566],[.0883024619,.2817188376,.6299787005]],Wr=[[1,.39633779217376774,.2158037580607588],[1,-.10556134232365633,-.0638541747717059],[1,-.08948418209496574,-1.2914855378640917]];function Ur(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,O=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*O+a*$,q=o*x+n*u+a*k;s=s-L*B/(B*B-.5*L*q)}return s}function Yr(r,e){let t=Ur(r,e),o=W(J([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 Kr(r,e,t,o,n){let a=Yr(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,O=y+w*c,$=y+w*p,x=y+w*i,u=[[O**3,$**3,x**3],[3*b*O**2,3*f*$**2,3*d*x**2],[6*b**2*O,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),Rr=q>=0?-k*q:1/0,mr=g[1][0]*u[0][0]+g[1][1]*u[0][1]+g[1][2]*u[0][2]-1,H=g[1][0]*u[1][0]+g[1][1]*u[1][1]+g[1][2]*u[1][2],jr=g[1][0]*u[2][0]+g[1][1]*u[2][1]+g[1][2]*u[2][2],hr=H/(H*H-.5*mr*jr),Lr=hr>=0?-mr*hr:1/0,pr=g[2][0]*u[0][0]+g[2][1]*u[0][1]+g[2][2]*u[0][2]-1,X=g[2][0]*u[1][0]+g[2][1]*u[1][1]+g[2][2]*u[1][2],Cr=g[2][0]*u[2][0]+g[2][1]*u[2][1]+g[2][2]*u[2][2],dr=X/(X*X-.5*pr*Cr),Gr=dr>=0?-pr*dr:1/0;return s+Math.min(Rr,Lr,Gr)}function Z(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 yr(r){let[e,t,o,n]=r;if(t+o>=1){let s=t/(t+o);return[s,s,s,n]}let a=Z([e,100,50,n]);for(let s=0;s<3;s++)a[s]*=1-t-o,a[s]+=t;return a}function Hr(r,e=2e-4){let[t,o,n,a]=r,s=Math.abs(o)<e&&Math.abs(n)<e?0:Tr(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 Xr(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=Sr(o);return[e,Math.cos(a)*t,Math.sin(a)*t,n]}function Pr(r){return C(r,Nr)}function W(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 Er(r){let e=C(r,vr);return[Math.cbrt(e[0]),Math.cbrt(e[1]),Math.cbrt(e[2]),e[3]]}function wr(r){return C(r,Ir)}function J(r){return C(r,Wr)}function U(r){let e=j(W(J(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=Kr(l,c,t,s,h);return j(W(J([h*(1-p)+p*t,l*(p*s),c*(p*s),a])))}return e}function Q(r){return U(Xr(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 Y(r){return Pr(Er(R(r)))}function rr(r){return Hr(Y(r))}function $r(r){return C(r,qr)}var Zr={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},xr=Zr,Jr=/-?[0-9.]+%?/g,Qr=/^#?[0-9a-f]{3,8}$/i,re=16**6,er=16**4,tr=16**2;function F(r){let e=ee(r),t={get hex(){let o="#";return o+=v(Math.round(m(e[0]*255,0,255)).toString(16),2),o+=v(Math.round(m(e[1]*255,0,255)).toString(16),2),o+=v(Math.round(m(e[2]*255,0,255)).toString(16),2),e[3]<1&&(o+=v(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*er+n*tr+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",Y(e))},get oklabVal(){return Y(e)},get oklch(){return _("oklch",rr(e))},get oklchVal(){return rr(e)},get xyz(){return _("xyz-d65",wr(R(e)))},get xyzVal(){return wr(R(e))}};return t.toString=()=>t.hex,t}function kr(r){if(r>re)throw new Error("8-digit hex values (with transparency) aren\u2019t supported");let e=r,t=Math.floor(e/er);e-=t*er;let o=Math.floor(e/tr);e-=o*tr;let n=e;return[t/255,o/255,n/255,1]}function V(r,e){let t=r.match(Jr);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 ee(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 Z([t.h,m(t.s,0,1),m(t.l,0,1),o]);if("h"in t&&"w"in t&&"b"in t)return yr([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 Q([t.l,t.c,t.h,o]);if("x"in t&&"y"in t&&"z"in t)return j($r([t.x,t.y,t.z,o]));throw e}if(typeof r=="number")return kr(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 xr[o]=="number")return kr(xr[o]);if(Qr.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 j(s)}case"hsl":case"hsla":{let[s,h,l,c]=V(a,[1,1,1,1]);return Z([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 yr([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 Q(V(a,[1,1,1,1]));case"xyz":case"xyz-d65":return j($r(V(a,[1,1,1,1])))}}throw e}function or(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:rr,oklab:Y,lms:k=>R(Er(k)),linearRGB:R,sRGB:k=>k},l={oklch:Q,oklab:U,lms:k=>W(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=F(r).rgbVal,b=F(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),[O,$,x,u]=c(b);return o==="oklch"&&Math.abs(x-y)>180&&(Math.max(y,x)===x?x-=360:y-=360),F(p([f*a+O*s,d*a+$*s,y*a+x*s,w*a+u*s]))}function Ar(r,e,t="oklab"){let o=m(e,-1,1);return o>=0?or(r,"black",o,t):Mr(r,-o)}function Mr(r,e,t="oklab"){let o=m(e,-1,1);return o>=0?or(r,"white",o,t):Ar(r,-o)}function K(r){return F(r).xyzVal[1]}function te(r){return M(F(r).oklabVal[0],5)}function oe(r){return K(r)<.36?"dark":"light"}function ne(r,e){let t=K(r),o=K(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 zr={contrastRatio:ne,darken:Ar,from:F,lighten:Mr,lightness:te,lightOrDark:oe,luminance:K,mix:or};function z(r){if(!r)throw new Error("missing value");if(typeof r=="string"||typeof r=="number")try{return zr.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 ie=/^\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(ie.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 nr(r){if(!r)throw new Error("missing value");if(typeof r=="string")return r;throw new Error(`expected string, received ${typeof r}`)}var Or=new Set(["solid","dashed","dotted","double","groove","ridge","outset","inset"]);function T(r){if(!Or.has(r))throw new Error(`Unsupported stroke type "${r}", must be one of:
- ${[...Or].join(`
- `)}`);return r}function ir(r){if(!A(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:T(e.style)}}var ae=[.25,.1,.25,1];function ar(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||ae)}}function sr(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 lr(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 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 ur(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=gr(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 fr(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||!A(i)))for(let[d,y]of Object.entries(i)){if(!y||!A(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:N(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(br(w.$value)){e.push(`${w.id}: missing "$value"`);continue}if(!!w.$extensions&&w.$extensions.mode&&!A(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=>A(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 P(b,{default(f){return f},string(f){if(!I.test(f))return f;let d=_r(f);if(!l[d])throw new Error(`${i}: can\u2019t find ${f}`);let y=l[d];if(typeof y=="string"&&I.test(y)&&i===_r(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(;cr(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=S(l[i]),p(i,S);break;case"link":n[i].$value=nr(l[i]),p(i,nr);break;case"strokeStyle":n[i].$value=T(l[i]),p(i,T);break;case"border":n[i].$value=ir(l[i]),p(i,ir);break;case"transition":n[i].$value=ar(l[i]),p(i,ar);break;case"shadow":n[i].$value=sr(l[i]),p(i,sr);break;case"gradient":n[i].$value=lr(l[i]),p(i,lr);break;case"typography":n[i].$value=ur(l[i]),p(i,ur);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 cr(r){return Object.values(r).some(e=>P(e,{default:()=>!1,string:t=>I.test(t),array:t=>t.some(o=>typeof o=="string"?I.test(o):A(o)?cr(o):!1),object:t=>cr(t)}))}function _r(r){let e=r.match(I);return e?e[1]:r}var ut={parse:fr};export{ut as default,fr as parse};
var fr=typeof process!==void 0?!process.env.NODE_DISABLE_COLORS&&(!process.env.NO_COLOR||process.env.NO_COLOR=="0"):!0;var Te=["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,hr=new RegExp(`^[${Te.join("")}]+$`);function we(e){return e.replace(Ie,r=>`${r[0].toLocaleLowerCase()}${r[r.length-1].toLocaleUpperCase()}`)}function U(e){if(!e||typeof e=="string"||typeof e=="boolean"||typeof e=="number")return e;if(Array.isArray(e)){let t=[];for(let n of e)t.push(U(n));return t}let r={};for(let[t,n]of Object.entries(e))r[t]=U(n);return r}function A(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $e(e){return e==null?!0:typeof e=="string"||Array.isArray(e)?e.length===0:A(e)?Object.keys(e).length===0:!1}function ee(e,r){if(e==null&&r.undefined)return r.undefined(e);if(typeof e=="string"&&r.string)return r.string(e);if(typeof e=="number"&&r.number)return r.number(e);if(Array.isArray(e)&&r.array)return r.array(e);if(A(e)&&r.object)return r.object(e);if(r.default)return r.default(e)}function Y(e,r=2){let t=e;for(;t.length<r;)t=`0${t}`;return t}function ve(e){return e*(Math.PI/180)}function qe(e){return e*(180/Math.PI)}function h(e,r,t){return Math.min(Math.max(e,r),t)}function L(e,r){let[t,n,o,i]=r,s=i<1?`/${V(i,5)}`:"";switch(e){case"rgb":case"rgba":return i<1?`rgba(${Math.round(t*255)}, ${Math.round(n*255)}, ${Math.round(o*255)}, ${V(i,5)})`:`rgb(${Math.round(t*255)}, ${Math.round(n*255)}, ${Math.round(o*255)})`;case"oklab":case"oklch":return`${e}(${V(t*100,6)}% ${V(n,6)} ${V(o,6)}${s})`;default:return`color(${e} ${V(t,6)} ${V(n,6)} ${V(o,6)}${s})`}}function S(e,r){let t=[...e];for(let n=0;n<r.length;n++){let o=0;for(let i=0;i<r[n].length;i++)o+=e[i]*r[n][i];t[n]=o}return t}function V(e,r=2){let t=10**r;return Math.round(e*t)/t}var Ne=[[.4123907992659593,.357584339383878,.1804807884018343],[.2126390058715102,.715168678767756,.0721923153607337],[.0193308187155918,.119194779794626,.9505321522496607]],We=[[3.240969941904522,-1.537383177570094,-.4986107602930034],[-.9692436362808793,1.8759675015077202,.0415550574071756],[.0556300796969937,-.2039769588889766,1.0569715142428782]],Ue=[[.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]],Ye=[[.4122214708,.5363325363,.0514459929],[.2119034982,.6806995451,.1073969566],[.0883024619,.2817188376,.6299787005]],Ke=[[1,.39633779217376774,.2158037580607588],[1,-.10556134232365633,-.0638541747717059],[1,-.08948418209496574,-1.2914855378640917]];function He(e,r){let t=[1/0,1/0,1/0,1/0,1/0],n=1/0,o=1/0,i=1/0;-1.88170328*e-.80936493*r>1?(t=[1.19086277,1.76576728,.59662641,.75515197,.56771245],n=4.0767416621,o=-3.3077115913,i=.2309699292):1.81444104*e-1.19445276*r>1?(t=[.73956515,-.45954404,.08285427,.1254107,.14503204],n=-1.2684380046,o=2.6097574011,i=-.3413193965):(t=[1.35733652,-.00915799,-1.1513021,-.50559606,.00692167],n=-.0041960863,o=-.7034186147,i=1.707614701);let s=t[0]+t[1]*e+t[2]*r+t[3]*e*e+t[4]*e*r,u=.3963377774*e+.2158037573*r,l=-.1055613458*e-.0638541728*r,m=-.0894841775*e-1.291485548*r;{let p=1+s*u,a=1+s*l,g=1+s*m,c=p**3,d=a**3,y=g**3,w=3*u*p**2,M=3*l*a**2,$=3*m*g**2,k=6*u**2*p,f=6*l**2*a,z=6*m**2*g,j=n*c+o*d+i*y,R=n*w+o*M+i*$,D=n*k+o*f+i*z;s=s-j*R/(R*R-.5*j*D)}return s}function Xe(e,r){let t=He(e,r),[n,o,i]=K(oe([1,t*e,t*r,1])),s=Math.cbrt(1/Math.max(n,o,i)),u=s*t;return{L:s,C:u}}function Pe(e,r,t,n,o){let i=Xe(e,r);if((t-o)*i.C-(i.L-o)*n<=0)return i.C*o/(n*i.L+i.C*(o-t));let s=i.C*(o-1)/(n*(i.L-1)+i.C*(o-t)),u=t-o,l=n,m=.3963377774*e+.2158037573*r,p=-.1055613458*e-.0638541728*r,a=-.0894841775*e-1.291485548*r,g=u+l*m,c=u+l*p,d=u+l*a,y=o*(1-s)+s*t,w=s*n,M=y+w*m,$=y+w*p,k=y+w*a,f=[[M**3,$**3,k**3],[3*g*M**2,3*c*$**2,3*d*k**2],[6*g**2*M,6*c**2*$,6*d**2*k]],z=b[0][0]*f[0][0]+b[0][1]*f[0][1]+b[0][2]*f[0][2]-1,j=b[0][0]*f[1][0]+b[0][1]*f[1][1]+b[0][2]*f[1][2],R=b[0][0]*f[2][0]+b[0][1]*f[2][1]+b[0][2]*f[2][2],D=j/(j*j-.5*z*R),C=D>=0?-z*D:1/0,W=b[1][0]*f[0][0]+b[1][1]*f[0][1]+b[1][2]*f[0][2]-1,E=b[1][0]*f[1][0]+b[1][1]*f[1][1]+b[1][2]*f[1][2],Ge=b[1][0]*f[2][0]+b[1][1]*f[2][1]+b[1][2]*f[2][2],ge=E/(E*E-.5*W*Ge),Be=ge>=0?-W*ge:1/0,be=b[2][0]*f[0][0]+b[2][1]*f[0][1]+b[2][2]*f[0][2]-1,Q=b[2][0]*f[1][0]+b[2][1]*f[1][1]+b[2][2]*f[1][2],De=b[2][0]*f[2][0]+b[2][1]*f[2][1]+b[2][2]*f[2][2],ye=Q/(Q*Q-.5*be*De),Se=ye>=0?-be*ye:1/0;return s+Math.min(C,Be,Se)}function re(e){let r=Math.abs(e);return r<=.0031308?e*12.92:1.055*Math.pow(r,1/2.4)-.055}function te(e){return Math.abs(e)<=.04045?e/12.92:((Math.abs(e)+.055)/1.055)**2.4}function ne(e){let[r,t,n,o]=e;r=Math.abs(r%360);let i=t*(1-Math.abs(2*n-1)),s=i*(1-Math.abs(r/60%2-1)),u=0,l=0,m=0;0<=r&&r<60?(u=i,l=s):60<=r&&r<120?(u=s,l=i):120<=r&&r<180?(l=i,m=s):180<=r&&r<240?(l=s,m=i):240<=r&&r<300?(u=s,m=i):300<=r&&r<360&&(u=i,m=s);let p=n-i/2;return[u+p,l+p,m+p,o]}function xe(e){let[r,t,n,o]=e;if(t+n>=1){let s=t/(t+n);return[s,s,s,o]}let i=ne([r,100,50,o]);for(let s=0;s<3;s++)i[s]*=1-t-n,i[s]+=t;return i}function Ze(e,r=2e-4){let[t,n,o,i]=e,s=Math.abs(n)<r&&Math.abs(o)<r?0:qe(Math.atan2(o,n));for(;s<0;)s+=360;for(;s>=360;)s-=360;return[t,Math.sqrt(n**2+o**2),s,i]}function Je(e){let[r,t,n,o]=e;if(r===0)return[0,0,0,o];for(;n<0;)n+=360;for(;n>=360;)n-=360;let i=ve(n);return[r,Math.cos(i)*t,Math.sin(i)*t,o]}function Qe(e){return S(e,Ue)}function K(e){let[r,t,n,o]=e,[i,s,u]=S([r**3,t**3,n**3,o],b);return[i,s,u,o]}function B(e){let[r,t,n,o]=e;return[re(r),re(t),re(n),o]}function ze(e){let[r,t,n,o]=S(e,Ye);return[Math.cbrt(r),Math.cbrt(t),Math.cbrt(n),o]}function ke(e){return S(e,Ne)}function oe(e){return S(e,Ke)}function H(e){let[r,t,n,o]=K(oe(e));if(r>1.001||r<-.001||t>1.001||t<-.001||n>1.001||n<-.001){let[i,s,u]=e,l=Math.max(1e-5,Math.sqrt(s**2+u**2)),m=h(i,0,1),p=s/l,a=u/l,g=Pe(p,a,i,l,m);return B(K(oe([m*(1-g)+g*i,p*(g*l),a*(g*l),o])))}return B([r,t,n,o])}function X(e){return H(Je(e))}function G(e){let[r,t,n,o]=e;return[te(r),te(t),te(n),o]}function P(e){return Qe(ze(G(e)))}function Z(e){return Ze(P(e))}function Ee(e){return S(e,We)}function Ve(e,r){let[t,n,o,i]=Z(e);return typeof r.lightness=="number"&&(r.mode==="relative"?t+=r.lightness:t=r.lightness),typeof r.chroma=="number"&&(r.mode==="relative"?n+=r.chroma:n=r.chroma),typeof r.hue=="number"&&(r.mode==="relative"?o+=r.hue:o=r.hue),typeof r.alpha=="number"&&(r.mode==="relative"?i+=r.alpha:i=r.alpha),X([t,n,o,i])}var er={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},Ae=er,rr=/-?[0-9.]+%?/g,tr=/^#[0-9a-f]{3,8}$/i,nr=16**6,ie=16**4,ae=16**2;function O(e){let r=or(e),t={get hex(){let[n,o,i,s]=r,u="#";return u+=Y(Math.round(h(n*255,0,255)).toString(16),2),u+=Y(Math.round(h(o*255,0,255)).toString(16),2),u+=Y(Math.round(h(i*255,0,255)).toString(16),2),r[3]<1&&(u+=Y(Math.round(s*255).toString(16),2)),u},get hexVal(){let[n,o,i,s]=r;return s<1&&console.warn(`hexVal converted a semi-transparent color (${s*100}%) to fully opaque`),n=Math.round(h(n*255,0,255)),o=Math.round(h(o*255,0,255)),i=Math.round(h(i*255,0,255)),n*ie+o*ae+i},get rgb(){return L("rgb",r)},rgbVal:r,get rgba(){return L("rgb",r)},rgbaVal:r,get linearRGB(){return L("srgb-linear",G(r))},get linearRGBVal(){return G(r)},get p3(){return L("display-p3",r)},p3Val:r,get oklab(){return L("oklab",P(r))},get oklabVal(){return P(r)},get oklch(){return L("oklch",Z(r))},get oklchVal(){return Z(r)},get xyz(){return L("xyz-d65",ke(G(r)))},get xyzVal(){return ke(G(r))},adjust(n){return O(Ve(r,n))}};return t.toString=()=>t.hex,t}function Me(e){if(e>nr)throw new Error("8-digit hex values (with transparency) aren\u2019t supported");let r=e,t=Math.floor(r/ie);r-=t*ie;let n=Math.floor(r/ae);r-=n*ae;let o=r;return[t/255,n/255,o/255,1]}function _(e,r){let t=e.match(rr);if(!t)throw new Error(`Unexpected color format: ${e}`);let n=[0,0,0,1];return t.forEach((o,i)=>{o.includes("%")?n[i]=parseFloat(o)/100:!r||r[i]===1/0||r[i]===1?n[i]=parseFloat(o):n[i]=parseFloat(o)/r[i]}),n}function or(e){let r=new Error(`Unable to parse color ${JSON.stringify(e)}`);if(e==null||e==null||typeof e=="boolean")throw r;if(Array.isArray(e)){if(e.some(s=>typeof s!="number"))throw new Error(`Color array must be numbers, received ${e}`);if(e.length<3||e.length>4)throw new Error(`Expected [R, G, B, A?], received ${e}`);let[t,n,o,i]=e;return[h(t,0,1),h(n,0,1),h(o,0,1),typeof i=="number"?h(i,0,1):1]}if(typeof e=="number")return Me(e);if(typeof e=="string"){let t=e.trim();if(!t)throw new Error("Expected color, received empty string");let n=t.toLowerCase();if(typeof Ae[n]=="number")return Me(Ae[n]);if(tr.test(n)){let s=n.replace("#",""),u=[0,0,0,1];if(s.length===6||s.length===8)for(let l=0;l<s.length/2;l++){let m=l*2,p=m+2,a=s.substring(m,p);u[l]=parseInt(a,16)/255}else if(s.length===3||s.length===4)for(let l=0;l<s.length;l++){let m=s.charAt(l);u[l]=parseInt(`${m}${m}`,16)/255}else throw new Error(`Hex value "${n}" not a valid sRGB color`);return u}let[o,i]=t.split("(");if(o==="color"){let s=i.indexOf(" ");o=i.substring(0,s),i=i.substring(s)}switch(o){case"rgb":case"rgba":case"srgb":{let[s,u,l,m]=_(i,[255,255,255,1]);return[h(s,0,1),h(u,0,1),h(l,0,1),h(m,0,1)]}case"linear-rgb":case"linear-srgb":case"rgb-linear":case"srgb-linear":{let s=_(i);return B(s)}case"hsl":case"hsla":{let[s,u,l,m]=_(i);return ne([s,h(u,0,1),h(l,0,1),h(m,0,1)])}case"hwb":case"hwba":{let[s,u,l,m]=_(i);return xe([s,h(u,0,1),h(l,0,1),h(m,0,1)])}case"p3":case"display-p3":{let[s,u,l,m]=_(i);return[h(s,0,1),h(u,0,1),h(l,0,1),h(m,0,1)]}case"oklab":return H(_(i));case"oklch":return X(_(i));case"xyz":case"xyz-d65":return B(Ee(_(i)))}}if(typeof e=="object"){let t={...e},n=1;for(let o of Object.keys(t))o==="alpha"?n=h(t[o],0,1):t[o.toLowerCase()]=t[o];if("r"in t&&"g"in t&&"b"in t)return[h(t.r,0,1),h(t.g,0,1),h(t.b,0,1),n];if("h"in t&&"s"in t&&"l"in t)return ne([t.h,h(t.s,0,1),h(t.l,0,1),n]);if("h"in t&&"w"in t&&"b"in t)return xe([t.h,h(t.w,0,1),h(t.b,0,1),n]);if("l"in t&&"a"in t&&"b"in t)return H([t.l,t.a,t.b,n]);if("l"in t&&"c"in t&&"h"in t)return X([t.l,t.c,t.h,n]);if("x"in t&&"y"in t&&"z"in t)return B(Ee([t.x,t.y,t.z,n]));throw r}throw r}function se(e,r,t=.5,n="oklab"){let o=h(t,0,1);if(t===0)return O(e);if(t===1)return O(r);let i=1-o,s=o,u={oklch:Z,oklab:P,lms:E=>G(ze(E)),linearRGB:G,sRGB:E=>E},l={oklch:X,oklab:H,lms:E=>K(B(E)),linearRGB:B,sRGB:E=>E},m=u[n],p=l[n];if(!m)throw new Error(`Unknown color space "${n}", try "oklab", "oklch", "linearRGB", or "sRGB"`);let[a,g,c,d]=O(e).rgbVal,[y,w,M,$]=O(r).rgbVal;n==="oklch"&&(a===g&&g===c||y===w&&w===M)&&(m=u.oklab,p=l.oklab);let[k,f,z,j]=m([a,g,c,d]),[R,D,C,W]=m([y,w,M,$]);return n==="oklch"&&Math.abs(C-z)>180&&(Math.max(z,C)===C?C-=360:z-=360),O(p([k*i+R*s,f*i+D*s,z*i+C*s,j*i+W*s]))}function Oe(e,r,t="oklab"){let n=h(r,-1,1);return n>=0?se(e,"black",n,t):Fe(e,-n)}function Fe(e,r,t="oklab"){let n=h(r,-1,1);return n>=0?se(e,"white",n,t):Oe(e,-n)}function J(e){return O(e).xyzVal[1]}function ir(e){return V(O(e).oklabVal[0],5)}function ar(e){return J(e)<.36?"dark":"light"}function sr(e,r){let t=J(e),n=J(r),o=Math.max(t,n),i=Math.min(t,n),s=(o+.05)/(i+.05);return{ratio:s,AA:s>=4.5,AAA:s>=7}}var je={adjust:Ve,contrastRatio:sr,darken:Oe,from:O,lighten:Fe,lightness:ir,lightOrDark:ar,luminance:J,mix:se};function F(e){if(!e)throw new Error("missing value");if(typeof e=="string"||typeof e=="number")try{return je.from(e).hex}catch{throw new Error(`invalid color "${e}"`)}throw new Error(`expected string, received ${typeof e}`)}function I(e){if(!e)throw new Error("missing value");if(typeof e=="string")return[e];if(Array.isArray(e)){if(e.every(r=>!!r&&typeof r=="string"))return e;throw new Error("expected array of strings")}throw new Error(`expected string or array of strings, received ${typeof e}`)}var lr=/^\d+(\.\d+)?(ms|s)$/;function T(e){if(typeof e=="number")return`${e}ms`;if(typeof e=="string"){if(parseFloat(e)===0)return"0ms";if(lr.test(e))return e;throw new Error(`invalid duration "${e}"`)}throw new Error(`expected string, received ${typeof e}`)}function x(e){if(typeof e=="number"){if(e===0)return"0";throw new Error("missing units")}if(typeof e=="string")return parseFloat(e)===0?"0":e;throw new Error(`expected string, received ${typeof e}`)}function v(e){if(!e)throw new Error("missing value");if(!Array.isArray(e)||e.length!==4||e.some(r=>typeof r!="number"))throw new Error(`expected [\u{1D465}1, \u{1D466}1, \u{1D465}2, \u{1D466}2], received ${e}`);return[Math.max(0,Math.min(1,e[0])),e[1],Math.max(0,Math.min(1,e[2])),e[3]]}function le(e){if(!e)throw new Error("missing value");if(typeof e=="string")return e;throw new Error(`expected string, received ${typeof e}`)}var _e=new Set(["solid","dashed","dotted","double","groove","ridge","outset","inset"]);function q(e){if(!_e.has(e))throw new Error(`Unsupported stroke type "${e}", must be one of:
- ${[..._e].join(`
- `)}`);return e}function ue(e){if(!A(e))throw new Error(`Expected object, received ${Array.isArray(e)?"array":typeof e}`);let r=e;if(!("color"in r))throw new Error('Token missing required "color" property');if(!("width"in r))throw new Error('Token missing required "width" property');if(!("style"in r))throw new Error('Token missing required "style" property');return{color:F(r.color),width:x(r.width),style:q(r.style)}}var ur=[.25,.1,.25,1];function fe(e){if(!e)throw new Error("missing value");if(typeof e!="object"||Array.isArray(e))throw new Error("invalid transition format, e");if(!Object.keys(e).length)throw new Error("At least 1 transition property is required");let r=e;return{duration:T(r.duration||"0"),delay:T(r.delay||"0"),timingFunction:v(r.timingFunction||ur)}}function ce(e){if(!e)throw new Error("missing value");if(typeof e!="object"||Array.isArray(e))throw new Error("invalid shadow");let r=e;return["offsetX","offsetX","blur","spread","color"].forEach(t=>{if(typeof r[t]=="number"&&r[t]>0)throw new Error(`${t} missing units`);if((t==="offsetX"||t==="offsetY")&&typeof r[t]!="string"&&r[t]!==0)throw new Error(`missing ${t}`)}),{offsetX:x(r.offsetX||"0"),offsetY:x(r.offsetY||"0"),blur:x(r.blur||"0"),spread:x(r.spread||"0"),color:F(r.color)}}function me(e){if(!e)throw new Error("missing value");if(!Array.isArray(e))throw new Error(`expected array of gradient stops, received ${typeof e}`);if(e.some(r=>!r||!r.color))throw new Error("all gradient stops must have color");return e.map(r=>({color:F(r.color),position:typeof r.position=="number"?Math.max(0,Math.min(1,r.position)):void 0}))}var Re=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 he(e){if(!e)throw new Error("missing value");if(typeof e!="object"||Array.isArray(e))throw new Error(`expected object, received ${Array.isArray(e)?"array":typeof e}`);if(!Object.keys(e).length)throw new Error("must specify at least 1 font property");let r={};for(let[t,n]of Object.entries(e)){let o=we(t);switch(o){case"fontName":case"fontFamily":{r.fontFamily=I(n);break}case"fontWeight":{if(typeof n=="string"){let i=Re.get(n);if(i)r.fontWeight=i;else throw new Error(`invalid font weight "${n}", use number (1-999) or any of:
- ${[...Re.values()].join(`
- `)}`)}else typeof n=="number"&&(r.fontWeight=Math.max(1,Math.min(999,n)));break}default:{r[o]=typeof n=="string"&&parseFloat(n)>=0?x(n):n;break}}}return r}var N=/^\{([^}]+)\}$/,Ce=new Set(["$description","$name","$type","$value","$extensions"]);function de(e){let r=[],t=[],n={result:{metadata:{},tokens:[]}};if(!e||typeof e!="object"||Array.isArray(e))return r.push(`Invalid schema type. Expected object, received "${Array.isArray(e)?"Array":typeof e}"`),n.errors=r,n;let o={};function i(a,g=[],c={$extensions:{requiredModes:[]}}){if(!(!a||!A(a)))for(let[d,y]of Object.entries(a)){if(!y||!A(y)){r.push(`${d}: unexpected token format "${y}"`);continue}if(d.includes(".")||d.includes("{")||d.includes("}")||d.includes("#")){r.push(`${d}: IDs can\u2019t include any of the following: .{}#`);continue}Object.keys(y).length||r.push(`${d}: groups can\u2019t be empty`);let w={_original:U(y),_group:{id:g.join(".")||".",...c||{}},id:g.concat(d).join("."),$type:y.$type||c.$type,...y};if(w.hasOwnProperty("$value")){if(d.startsWith("$")){r.push(`${d}: token ID can\u2019t start with the $ character`);continue}if($e(w.$value)){r.push(`${w.id}: missing "$value"`);continue}if(w.$extensions&&w.$extensions.mode&&!A(w.$extensions.mode)&&r.push(`${w.id}: "mode" must be an object`),c.$extensions.requiredModes.length)for(let $ of c.$extensions.requiredModes)(!w.$extensions||!w.$extensions.mode||!w.$extensions.mode[$])&&r.push(`${w.id}: missing mode "${$}" required from parent group`);o[w.id]=w}else{let $={...c},k={};for(let f of Object.keys(y))f.startsWith("$")?(f==="$extensions"?$.$extensions={...$.$extensions,...y.$extensions}:$[f]=y[f],Ce.has(f)||(n.warnings||(n.warnings=[]),n.warnings.push(`Unknown property "${f}"`))):k[f]=y[f];if(Object.values(k).every(f=>A(f)))i(k,[...g,d],$);else throw new Error(`${d}: missing $type`)}}}let s={$extensions:{requiredModes:[]}},u={};for(let a of Object.keys(e))a.startsWith("$")?(a==="$extensions"?s.$extensions={...s.$extensions,...e.$extensions}:s[a]=e[a],Ce.has(a)||(n.warnings||(n.warnings=[]),n.warnings.push(`Unknown property "${a}"`)),n.result.metadata[a]=e[a]):u[a]=e[a];if(i(u,[],s),r.length)return n.errors=r,n;let l={};for(let a of Object.values(o))if(l[a.id]=a.$value,a.$extensions&&a.$extensions.mode)for(let[g,c]of Object.entries(a.$extensions.mode||{}))l[`${a.id}#${g}`]=c;function m(a,g){return ee(g,{default(c){return c},string(c){if(!N.test(c))return c;let d=Le(c);if(!l[d])throw new Error(`${a}: can\u2019t find ${c}`);let y=l[d];if(typeof y=="string"&&N.test(y)&&a===Le(y))throw new Error(`${a}: can\u2019t reference circular alias ${c}`);return l[d]},array(c){return c.map(d=>m(a,d))},object(c){for(let d of Object.keys(c))c[d]=m(a,c[d]);return c}})}for(;pe(l);)try{for(let[a,g]of Object.entries(l))l[a]=m(a,g)}catch(a){r.push(a.message||a);break}if(r.length)return n.errors=r,n;function p(a,g){let c=o[a];if(!(!c.$extensions||!c.$extensions.mode))for(let d of Object.keys(c.$extensions.mode||{}))o[a].$extensions.mode[d]=g(l[`${a}#${d}`])}for(let[a,g]of Object.entries(o))try{switch(g.$type){case"color":o[a].$value=F(l[a]),p(a,F);break;case"dimension":o[a].$value=x(l[a]),p(a,x);break;case"font":o[a].$value=I(l[a]),p(a,I);break;case"duration":o[a].$value=T(l[a]),p(a,T);break;case"cubicBezier":o[a].$value=v(l[a]),p(a,v);break;case"link":o[a].$value=le(l[a]),p(a,le);break;case"strokeStyle":o[a].$value=q(l[a]),p(a,q);break;case"border":o[a].$value=ue(l[a]),p(a,ue);break;case"transition":o[a].$value=fe(l[a]),p(a,fe);break;case"shadow":o[a].$value=ce(l[a]),p(a,ce);break;case"gradient":o[a].$value=me(l[a]),p(a,me);break;case"typography":o[a].$value=he(l[a]),p(a,he);break;default:o[a].value=l[a],p(a,c=>c);break}}catch(c){r.push(`${a}: ${c.message||c}`)}return r.length&&(n.errors=r),t.length&&(n.warnings=t),n.result.tokens=Object.values(o),n}function pe(e){return Object.values(e).some(r=>ee(r,{default:()=>!1,string:t=>N.test(t),array:t=>t.some(n=>typeof n=="string"?N.test(n):A(n)?pe(n):!1),object:t=>pe(t)}))}function Le(e){let r=e.match(N);return r?r[1]:e}var mt={parse:de};export{mt as default,de as parse};
//# sourceMappingURL=index.min.js.map
{
"name": "@cobalt-ui/core",
"description": "CLI for using the W3C design token format",
"version": "0.7.3",
"version": "0.7.4",
"author": {

@@ -23,3 +23,3 @@ "name": "Drew Powers",

"@types/csso": "^5.0.0",
"better-color-tools": "^0.9.1",
"better-color-tools": "^0.10.0",
"svgo": "^3.0.2"

@@ -26,0 +26,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc