@sugarcube-org/core 0.0.1-alpha.12 → 0.0.1-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/index.d.ts +783 -547
- package/dist/index.js +16 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
var
|
|
1
|
+
var gt=Object.defineProperty;var s=(e,t)=>gt(e,"name",{value:t,configurable:!0});import{isAbsolute as C,resolve as R,dirname as ee,relative as V,join as _,basename as $t}from"pathe";import Nt,{readFile as k,mkdir as ye,writeFile as Ee}from"node:fs/promises";import{z as l}from"zod";import{existsSync as te}from"node:fs";import{pathToFileURL as St}from"node:url";import Tt from"fast-glob";const ge="_sugarcube.css",$e="global",At="utilities",Ne=".variables.gen.css",Se="tokens",bt="utilities.gen.css",Ot="src/styles",Rt="src/design-tokens",w="sugarcube.config.ts";function m(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(m,"isReference$1");function Lt(e){if(typeof e!="object"||e===null||!("$value"in e))return!1;const t=e.$value;return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}s(Lt,"isCompositeToken");function Dt(e){return e.$type==="typography"}s(Dt,"isTypographyToken");function Te(e){return typeof e=="object"&&e!==null&&"$path"in e&&"$type"in e&&"$resolvedValue"in e}s(Te,"isResolvedToken");function _t(e,t){return Te(e)&&e.$type===t}s(_t,"isResolvedTokenOfType");function vt(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(vt,"deterministicEntries");const Ae=new Map;function xt(e){const t=Ae.get(e);if(t)return t;const n=e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z])(?=[a-z])/g,"$1-$2").toLowerCase();return Ae.set(e,n),n}s(xt,"toKebabCase");function ne(e){return e.split(".").join("-")}s(ne,"formatCSSVarPath");function re(e){return typeof e=="number"?e:typeof e!="string"?(console.warn("Unexpected value type in convertReferenceToCSSVar, got:",e),String(e)):e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(xt).join("-")})`)}s(re,"convertReferenceToCSSVar");function Ft(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ne(e.$path)}`,value:re(t.value)}}s(Ft,"generateSingleVariable");function Ct(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ne(e.$path)}-${t}`,value:re(n)}))}s(Ct,"generateTypographyVariables");function be(e){if(e.$type!=="color")return[];const t=e.$cssProperties;if(!("featureValues"in t))return[];const n=new Map;for(const r of t.featureValues||[]){n.has(r.query)||n.set(r.query,[]);const o=n.get(r.query);o&&o.push({name:`--${ne(e.$path)}`,value:re(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(be,"generateFeatureVariables");function Oe(e){const t=[`${e.selector} {`];if(e.comment&&t.push(` /* ${e.comment} */`),e.vars.length>0){const n=e.vars.map(r=>` ${r.name}: ${r.value};`).join(`
|
|
2
2
|
`);t.push(n)}return t.push("}"),t.join(`
|
|
3
|
-
`)}s(Oe,"generateCSSBlock");function
|
|
3
|
+
`)}s(Oe,"generateCSSBlock");function Vt(e){const t=[];e.root.vars.length>0&&t.push(Oe({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const o=Oe({selector:e.root.selector,vars:n.vars}).split(`
|
|
4
4
|
`).map(i=>` ${i}`).join(`
|
|
5
5
|
`);t.push(`${n.query} {
|
|
6
6
|
${o}
|
|
7
7
|
}`)}return t.filter(Boolean).join(`
|
|
8
8
|
|
|
9
|
-
`)}s(
|
|
9
|
+
`)}s(Vt,"convertCSSVarsToString");function kt(e){if(Dt(e))return{vars:Ct(e),features:be(e)};const t=Ft(e);return{vars:t?[t]:[],features:be(e)}}s(kt,"generateVariablesForToken");function wt(e,t,n){if(!e||e==="default")return":root";const r=e.indexOf(":");if(r!==-1){const o=e.slice(0,r),i=e.slice(r+1);return`[${t?.find(u=>u.name===o)?.attribute??`data-${o}`}="${i}"]`}return`[${n.output.themeAttribute}="${e}"]`}s(wt,"buildSelector");async function Mt(e,t,n){const r=vt(e).filter(([h,d])=>h!=="$extensions"&&"$type"in d).map(([h,d])=>kt(d)),o=wt(n.context,n.modifiers,t),i=r.flatMap(h=>h.vars),a=r.flatMap(h=>h.features||[]),c=new Map;for(const h of a){c.has(h.query)||c.set(h.query,[]);const d=c.get(h.query);d&&d.push(...h.vars)}const u=Array.from(c.entries()).map(([h,d])=>({query:h,vars:d})),p=Vt({root:{selector:o,vars:i},features:u});return p.trim()?{output:[{path:"tokens.variables.gen.css",css:jt(p)}]}:{output:[{path:"tokens.variables.gen.css",css:""}]}}s(Mt,"generateCSS");function jt(e){return e.endsWith(`
|
|
10
10
|
`)?e:`${e}
|
|
11
|
-
`}s(
|
|
11
|
+
`}s(jt,"formatCSSVars");async function Pt(e,t,n){const o=`${t.output?.css||"src/styles"}/${$e}`,i=[],a=Object.entries(e).sort(([c],[u])=>!c||c==="default"?-1:!u||u==="default"?1:c.localeCompare(u));for(const[c,u]of a){const p=await Mt(u,t,{context:c,modifiers:n});p.output[0].css.trim()&&i.push(p.output[0].css)}return i.length===0?[]:[{path:`${o}/${Se}${Ne}`,css:`${i.filter(Boolean).join(`
|
|
12
12
|
`).trim()}
|
|
13
|
-
`}]}s(
|
|
13
|
+
`}]}s(Pt,"generateSingleFile");async function Ut(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await Pt(r,t,n)}}s(Ut,"generate");async function Wt(e,t,n){const{output:r}=await Ut(e,t,n);return r}s(Wt,"generateCSSVariables");const f={LOAD:{NO_FILES_FOUND:s(e=>`No files found matching pattern: ${e}.`,"NO_FILES_FOUND"),INVALID_JSON:s((e,t)=>`Invalid JSON in file ${e}: ${t}`,"INVALID_JSON"),GLOB_ERROR:s((e,t)=>`Error resolving glob pattern ${e}: ${t}`,"GLOB_ERROR")},FLATTEN:{INVALID_TOKEN_NAME:s(e=>`Invalid token name "${e}": Token names cannot contain dots (.), curly braces ({,}), or other special characters`,"INVALID_TOKEN_NAME"),MISSING_DOLLAR_PREFIX:s(e=>`Token at ${e} is using 'value' or 'type' without the required '$' prefix. Use '$value' and '$type' instead.`,"MISSING_DOLLAR_PREFIX"),INVALID_TOKEN_NESTING:s(e=>`Token at "${e}" cannot contain child tokens or groups. Only metadata properties (starting with $) are allowed.`,"INVALID_TOKEN_NESTING"),COMPOSITE_TOKEN_MISSING_TYPE:s(e=>`Composite token at '${e}' is missing the required "$type" property. Composite tokens (tokens with object values) must specify their type to define their structure.`,"COMPOSITE_TOKEN_MISSING_TYPE"),CONFLICT_TOKEN_VS_GROUP:s(e=>`Conflict at "${e}": token vs group. A token cannot be replaced by a group (or vice versa).`,"CONFLICT_TOKEN_VS_GROUP"),CONFLICT_INCOMPATIBLE_TYPES:s((e,t,n)=>`Type conflict at "${n}": expected ${e}, got ${t}`,"CONFLICT_INCOMPATIBLE_TYPES")},METADATA:{COLLECTION_ERROR:s(e=>`Error collecting metadata: ${e}`,"COLLECTION_ERROR"),INVALID_EXTENSIONS:s(e=>`Invalid extensions at ${e}: expected object, got ${typeof e}`,"INVALID_EXTENSIONS"),INVALID_DESCRIPTION:s(e=>`Invalid description at ${e}: expected string, got ${typeof e}`,"INVALID_DESCRIPTION")},VALIDATE:{MISSING_TYPE:s(e=>`Token at '${e}' is missing the "$type" property`,"MISSING_TYPE"),UNKNOWN_TOKEN_TYPE:s((e,t)=>`Unknown token type '${e}' at ${t}. Valid types are: color, dimension, fontFamily, fontWeight, duration, cubicBezier, strokeStyle, border, transition, shadow, gradient, typography`,"UNKNOWN_TOKEN_TYPE"),INVALID_COLOR:s((e,t)=>`Invalid color at ${t}: '${e}'. Color should be a valid hex value or W3C color object`,"INVALID_COLOR"),INVALID_DIMENSION:s((e,t)=>`Invalid dimension at '${t}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:s((e,t)=>`Invalid unit at ${t}': '${e}'. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:s((e,t)=>`Invalid font family at '${t}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:s((e,t)=>`Invalid font weight at '${t}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:s((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:s((e,t)=>`Invalid unit at ${t}: "${e}". Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:s((e,t)=>`Invalid cubic bezier at ${t}: "${e}". Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_STROKE_STYLE:s((e,t)=>`Invalid stroke style at ${t}: "${e}". Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:s((e,t)=>`Invalid line cap at ${t}: "${e}". Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:s((e,t)=>`Invalid border at ${t}: "${e}". Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:s((e,t)=>`Invalid shadow at ${t}: "${e}". Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:s((e,t)=>`Invalid inset value at ${t}: "${e}". Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:s((e,t)=>`Invalid transition at ${t}: "${e}". Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:s((e,t)=>`Invalid gradient at ${t}: "${e}". Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:s((e,t)=>`Invalid gradient stop position at ${t}: "${e}". Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:s((e,t)=>`Invalid typography at ${t}: "${e}". Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:s((e,t)=>`Missing required property '${e}' at ${t}`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:s((e,t)=>`Invalid number at ${t}: "${e}". Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:s((e,t)=>`Invalid array at ${t}: "${e}". Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:s(e=>`Missing fluid configuration. Token at ${e} requires fluid viewport settings.`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:s((e,t)=>`Invalid fluid dimension at ${t}: "${e}". Fluid dimensions should have min and max values, like { "min": { "value": 16, "unit": "px" }, "max": { "value": 24, "unit": "px" } }`,"INVALID_FLUID_DIMENSION"),INVALID_VIEWPORT_CONFIG:s((e,t)=>`Invalid viewport configuration at ${t}: "${e}". Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:s((e,t,n)=>`Mismatched units at ${n}: min uses '${e}', max uses '${t}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:s(e=>`Invalid fluid value range at ${e}: min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:s((e,t,n)=>`Invalid token type at ${n}: expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:s((e,t,n)=>`Expected ${e}, received ${typeof t} at ${n}`,"INVALID_TYPE"),INVALID_ENUM_VALUE:s((e,t,n)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${n}`,"INVALID_ENUM_VALUE")},RESOLVE:{CIRCULAR_REFERENCE:s((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:s((e,t)=>`Reference not found: ${e} in ${t}. Does ${e} exist?`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:s(e=>`Type mismatch in ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:s((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE"),INVALID_VARIABLE_NAME:s((e,t)=>`Invalid CSS variable name at '${e}': ${t}`,"INVALID_VARIABLE_NAME")},CONFIG:{INVALID_JSON:s(e=>`Invalid JSON in config file: ${e}`,"INVALID_JSON"),INVALID_CONFIG:s((e,t)=>`Invalid configuration at ${e}: ${t}`,"INVALID_CONFIG"),DUPLICATE_FILENAMES:s((e,t)=>`Duplicate filename "${e}":
|
|
14
14
|
${t.map(n=>` - ${n}`).join(`
|
|
15
|
-
`)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e===P?`Cannot find sugarcube config file. Please ensure you have a valid ${P} file in your project root.`:`Cannot find sugarcube config file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND")},UTILITIES:{RESERVED_PREFIX:s((e,t)=>`Cannot use reserved prefix "${e}" for ${t} token type. This prefix is reserved for default utility classes. Please use a custom prefix instead.`,"RESERVED_PREFIX"),DUPLICATE_CLASS_NAME:s((e,t)=>`Ambiguous utility class "${e}" would be generated from multiple token paths: ${t.join(", ")}. This would make it impossible to know which token value should be used when this class is applied in HTML. To fix this, configure one or more paths with custom prefixes to make the intent clear.`,"DUPLICATE_CLASS_NAME"),INVALID_PROPERTY_MAPPING:s(e=>`Invalid property mapping for ${e} token type. When mapping multiple properties, each mapping must include a unique prefix to avoid class name collisions.`,"INVALID_PROPERTY_MAPPING"),DUPLICATE_PREFIX:s((e,t)=>`Duplicate prefix "${e}" found in property mappings for ${t} token type. Each property mapping must have a unique prefix to avoid class name collisions.`,"DUPLICATE_PREFIX"),MISSING_SOURCE:s(e=>`Utility config for '${e}' must have a valid 'source' property`,"MISSING_SOURCE"),INVALID_SOURCE_PATTERN:s((e,t)=>`Utility config for '${e}' has invalid source pattern '${t}'. Only patterns ending with '.*' are supported (e.g., 'color.*', 'font.weight.*').`,"INVALID_SOURCE_PATTERN"),INVALID_DIRECTIONS:s(e=>`Utility config for '${e}' must have 'directions' as an array`,"INVALID_DIRECTIONS"),INVALID_CONFIG_OBJECT:"utilitiesConfig must be an object",INVALID_TOKENS_OBJECT:"tokens must be an object"},RESOLVER:{FILE_NOT_FOUND:s(e=>`Cannot read resolver file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND"),INVALID_JSON:s(e=>`Invalid JSON in resolver file: ${e}`,"INVALID_JSON"),INVALID_REFERENCE:s(e=>`Invalid reference "${e}". References must use format #/sets/<name> or #/modifiers/<name>.`,"INVALID_REFERENCE"),INVALID_SOURCE_REFERENCE:s(e=>`Invalid source reference "${e}". Sources can only reference sets (#/sets/<name>), not modifiers.`,"INVALID_SOURCE_REFERENCE"),UNDEFINED_SET:s(e=>`Reference to undefined set "${e}". Define it in the "sets" section first.`,"UNDEFINED_SET"),UNDEFINED_MODIFIER:s(e=>`Reference to undefined modifier "${e}". Define it in the "modifiers" section first.`,"UNDEFINED_MODIFIER"),CIRCULAR_REFERENCE:s(e=>`Circular reference detected at "${e}".`,"CIRCULAR_REFERENCE"),EXTERNAL_FILE_NOT_FOUND:s(e=>`Referenced file not found: ${e}`,"EXTERNAL_FILE_NOT_FOUND"),EXTERNAL_FILE_ERROR:s((e,t)=>`Failed to load "${e}": ${t}`,"EXTERNAL_FILE_ERROR"),INVALID_JSON_POINTER:s((e,t)=>`Invalid JSON pointer "${e}": ${t}`,"INVALID_JSON_POINTER"),DUPLICATE_NAME:s(e=>`Duplicate name "${e}" in resolutionOrder.`,"DUPLICATE_NAME"),MODIFIER_NEEDS_CONTEXTS:"Modifier must have at least one context defined.",MODIFIER_SINGLE_CONTEXT:"Modifier has only one context. Consider using a set instead, or add more contexts.",INVALID_DEFAULT:s((e,t)=>`Default context "${e}" is not defined. Valid contexts: ${t.join(", ")}`,"INVALID_DEFAULT"),UNKNOWN_MODIFIER:s(e=>`Unknown modifier "${e}".`,"UNKNOWN_MODIFIER"),INVALID_CONTEXT:s((e,t,n)=>`Invalid context "${e}" for modifier "${t}". Valid contexts: ${n.join(", ")}`,"INVALID_CONTEXT"),MISSING_REQUIRED_INPUT:s(e=>`Missing required input for modifier "${e}". No default value is defined.`,"MISSING_REQUIRED_INPUT"),INVALID_INPUT_TYPE:s(e=>`Input for modifier "${e}" must be a string.`,"INVALID_INPUT_TYPE"),MALFORMED_REFERENCE:s((e,t)=>`Malformed source reference: { "${e}": "${t}" }. Did you mean { "$ref": "${t}" }?`,"MALFORMED_REFERENCE"),RESOLVER_AS_TOKEN_SOURCE:s(e=>`File "${e}" is a resolver document, not a token file. Resolver documents (version: "2025.10") cannot be used as token sources. Did you mean to reference a specific token file instead?`,"RESOLVER_AS_TOKEN_SOURCE")}};function ie(e){return typeof e=="object"&&e!==null&&"$value"in e}s(ie,"isTokenNode");function wt(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!ie(o)){if(i&&ie(i)){const d=i;n.push({path:d.$path,source:d.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(d.$path)});continue}e.tokens[r]=o;continue}if(!i){e.tokens[r]=o;continue}if(!ie(i)){n.push({path:o.$path,source:o.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,u=i,p=!!c.$type,h=!!u.$type;if(p&&h&&c.$type!==u.$type){n.push({path:c.$path,source:c.$source,message:f.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(u.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[r]=o}for(const[r,o]of t.pathIndex)e.pathIndex.set(r,o)}s(wt,"mergeFlattenedInto");function Mt(e){if(typeof e!="object"||e===null||"$value"in e)return!1;const t="value"in e,n="type"in e;if(t&&n)return!0;if(t){const r=e.value;return typeof r=="string"||typeof r=="number"||Array.isArray(r)}return!1}s(Mt,"looksLikeUnprefixedToken");function Pt(e,t){const n={tokens:{},pathIndex:new Map},r=[];function o(a=[]){const c=[];return t.context&&c.push(t.context),a.length>0&&c.push(a.join(".")),c.length>0?c.join("."):""}s(o,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[o()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],u){if(c.join("."),c.length>0){const d=o(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{context:t.context,sourcePath:t.sourcePath}}}const p=Object.keys(a).filter(d=>!d.startsWith("$")),h=a.$type||u;for(const d of p){const I=a[d],y=[...c,d],g=y.join(".");if(Mt(I)){r.push({path:g,source:t,message:f.FLATTEN.MISSING_DOLLAR_PREFIX(g)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:g,source:t,message:f.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(dt=>!dt.startsWith("$")).length>0){r.push({path:g,source:t,message:f.FLATTEN.INVALID_TOKEN_NESTING(g)});continue}if(St(I)&&!I.$type&&!h){r.push({path:g,source:t,message:f.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE(g)});continue}const ye=o(y),ne=y.join(".");n.tokens[ye]={...I,...I.$type||h?{$type:I.$type||h}:{},$path:ne,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:ne},n.pathIndex.set(ne,ye)}else i(I,y,h)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(Pt,"flattenTree");function jt(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=Pt(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),wt(t,o,n)}return{tokens:t,errors:n}}s(jt,"flatten");async function Ut(e){const t=[],n=[],r=Object.entries(e);r.sort(([,o],[,i])=>{const a=!o.context,c=!i.context;return a&&!c?-1:!a&&c?1:0});for(const[o,{context:i,content:a}]of r)try{const c=JSON.parse(a);t.push({context:i,tokens:c,sourcePath:D(process.cwd(),o)})}catch(c){c instanceof Error?c instanceof SyntaxError?n.push({file:o,message:f.LOAD.INVALID_JSON(o,c.message)}):n.push({file:o,message:c.message}):n.push({file:o,message:"Unknown error"})}return{trees:t,errors:n}}s(Ut,"loadTreesFromMemory");const j=l.string().min(1,"Name cannot be empty").refine(e=>!e.startsWith("$"),"Names must not start with '$' (reserved prefix)").refine(e=>!e.includes("{"),"Names must not contain '{'").refine(e=>!e.includes("}"),"Names must not contain '}'").refine(e=>!e.includes("."),"Names must not contain '.'"),Re=l.object({$ref:l.string().min(1,"$ref cannot be empty")}).passthrough();function L(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(L,"isReference");function Le(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(Le,"isInlineSet");function x(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(x,"isInlineModifier");const ae=l.union([Re,l.record(l.string(),l.unknown())]),Wt=l.object({description:l.string().optional(),sources:l.array(ae),$extensions:l.record(l.string(),l.unknown()).optional()}),_e=l.record(l.string(),l.array(ae)),Gt=l.object({description:l.string().optional(),contexts:_e,default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Bt=l.object({type:l.literal("set"),name:j,sources:l.array(ae),description:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}),Yt=l.object({type:l.literal("modifier"),name:j,contexts:_e,description:l.string().optional(),default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Ht=l.union([Re,Bt,Yt]),Kt=l.record(j,Wt),qt=l.record(j,Gt),zt=l.object({version:l.literal("2025.10"),name:l.string().optional(),description:l.string().optional(),sets:Kt.optional(),modifiers:qt.optional(),resolutionOrder:l.array(Ht),$schema:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional(),$defs:l.record(l.string(),l.unknown()).optional()});async function Jt(e){const t=V(e)?e:R(process.cwd(),e),n=await Xt(t);if(n.error)return{document:W(),errors:[n.error]};const r=Zt(n.content);if(r.error)return{document:W(),errors:[r.error]};const o=Qt(r.data);if(o.errors.length>0)return{document:W(),errors:o.errors};const i=[];return en(o.document,i),{document:o.document,errors:i}}s(Jt,"parseResolverDocument");async function Xt(e){try{return{content:await w(e,"utf-8")}}catch{return{error:{path:e,message:f.RESOLVER.FILE_NOT_FOUND(e)}}}}s(Xt,"loadFile");function Zt(e){try{return{data:JSON.parse(e)}}catch(t){const n=t instanceof Error?t.message:"Unknown error";return{error:{path:"resolver",message:f.RESOLVER.INVALID_JSON(n)}}}}s(Zt,"parseJson");function Qt(e){const t=zt.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".")||"resolver";return{path:o,message:`Resolver error at ${o}: ${r.message}. See https://sugarcube.sh/docs/resolver`}});return{document:W(),errors:n}}return{document:t.data,errors:[]}}s(Qt,"validateSchema$1");function en(e,t){tn(e,t),nn(e,t),rn(e,t)}s(en,"validateDocument");function tn(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))De(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];x(r)&&De(r,`resolutionOrder[${n}]`,t)}}s(tn,"validateModifierContexts");function De(e,t,n){const r=Object.keys(e.contexts).length;if(r===0){n.push({path:`${t}.contexts`,message:f.RESOLVER.MODIFIER_NEEDS_CONTEXTS});return}r===1&&n.push({path:`${t}.contexts`,message:f.RESOLVER.MODIFIER_SINGLE_CONTEXT}),e.default&&!e.contexts[e.default]&&n.push({path:`${t}.default`,message:f.RESOLVER.INVALID_DEFAULT(e.default,Object.keys(e.contexts))})}s(De,"checkModifierContexts");function nn(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(L(o))continue;const i=o.name;n.has(i)&&t.push({path:`resolutionOrder[${r}].name`,message:f.RESOLVER.DUPLICATE_NAME(i)}),n.add(i)}}s(nn,"validateNameUniqueness");function rn(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(L(r))on(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(Le(r))U(r.sources,`resolutionOrder[${n}].sources`,t);else if(x(r))for(const[o,i]of Object.entries(r.contexts))U(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))U(r.sources,`sets.${n}.sources`,t);if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))for(const[o,i]of Object.entries(r.contexts))U(i,`modifiers.${n}.contexts.${o}`,t)}s(rn,"validateReferences");function U(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!L(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],u=o[c];typeof u=="string"&&(u.includes("/")||u.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:f.RESOLVER.MALFORMED_REFERENCE(c,u)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:f.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(U,"validateSourcesReferences");function on(e,t,n,r){if(!e.startsWith("#/"))return;const o=e.slice(2).split("/"),[i,a]=o;if(o.length!==2||!i||!a){r.push({path:t,message:f.RESOLVER.INVALID_REFERENCE(e)});return}if(i==="sets"){n.sets?.[a]||r.push({path:t,message:f.RESOLVER.UNDEFINED_SET(a)});return}if(i==="modifiers"){n.modifiers?.[a]||r.push({path:t,message:f.RESOLVER.UNDEFINED_MODIFIER(a)});return}r.push({path:t,message:f.RESOLVER.INVALID_REFERENCE(e)})}s(on,"validateReference");function W(){return{version:"2025.10",resolutionOrder:[]}}s(W,"createEmptyDocument");function ve(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(ve,"isResolverFormat");function xe(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(xe,"createResolveContext");async function Fe(e,t){if(t.visitedRefs.has(e))return S({},f.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?sn(e,t):e.includes("#/")?await cn(e,t):await an(e,t)}finally{t.visitedRefs.delete(e)}}s(Fe,"resolveReference");function sn(e,t){const n=e.slice(2),[r,o]=n.split("/");if(!r||!o||n.split("/").length!==2)return S({sources:[]},f.RESOLVER.INVALID_REFERENCE(e));if(r==="sets"){const i=t.document.sets?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({sources:[]},f.RESOLVER.UNDEFINED_SET(o))}if(r==="modifiers"){const i=t.document.modifiers?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({contexts:{}},f.RESOLVER.UNDEFINED_MODIFIER(o))}return S({sources:[]},f.RESOLVER.INVALID_REFERENCE(e))}s(sn,"resolveSameDocumentRef");async function an(e,t){const n=V(e)?e:R(t.basePath,e),r=t.fileCache.get(n);if(r)return ve(r)?S({},f.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await Ce(n);return o.error?S({},o.error,n):ve(o.content)?S({},f.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(an,"resolveFileRef");async function cn(e,t){const[n="",r=""]=e.split("#"),o=V(n)?n:R(t.basePath,n);let i=t.fileCache.get(o);if(!i){const u=await Ce(o);if(u.error)return S({},u.error,o);i=u.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=un(i,a);return c.error?S({},f.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(cn,"resolveFileFragmentRef");async function Ce(e){try{const t=await w(e,"utf-8");return{content:JSON.parse(t)}}catch(t){if(t.code==="ENOENT")return{error:f.RESOLVER.EXTERNAL_FILE_NOT_FOUND(e)};const n=t instanceof Error?t.message:"Unknown error";return{error:f.RESOLVER.EXTERNAL_FILE_ERROR(e,n)}}}s(Ce,"loadJsonFile");function un(e,t){if(t===""||t==="/")return{value:e};const n=t.slice(1).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const o of n){if(r===null||typeof r!="object")return{error:"cannot navigate into non-object"};if(Array.isArray(r)){const a=Number.parseInt(o,10);if(Number.isNaN(a)||a<0||a>=r.length)return{error:`invalid array index "${o}"`};r=r[a];continue}const i=r;if(!(o in i))return{error:`property "${o}" not found`};r=i[o]}return{value:r}}s(un,"resolveJsonPointer");async function Ve(e,t){const n=[],r=[];for(const o of e){if(!L(o)){n.push(o);continue}const i=await Fe(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(fn(i.content,o))}return{resolved:n,errors:r}}s(Ve,"resolveSources");function fn(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(fn,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function ke(e){return typeof e=="object"&&e!==null&&"$value"in e}s(ke,"isToken");function G(e,t){const n={...e};for(const[r,o]of Object.entries(t)){if(o===void 0)continue;if(r.startsWith("$")){n[r]=o;continue}if(ke(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!ke(i);n[r]=a?G(i,o):o}return n}s(G,"deepMerge");function we(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=ln(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(we,"extractModifiers");function ln(e,t,n){return L(e)&&e.$ref.startsWith("#/modifiers/")?pn(e.$ref,t,n):x(e)?dn(e,n):null}s(ln,"extractModifierFromItem");function pn(e,t,n){const r=e.split("/")[2];if(!r||n.has(r))return null;const o=t.modifiers?.[r];return o?{name:r,contexts:Object.keys(o.contexts),default:o.default}:null}s(pn,"extractReferencedModifier");function dn(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(dn,"extractInlineModifier");function hn(e,t={}){const n=[],r={},o=we(e);if(o.length===0)return mn(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return In(t,i,n,r),yn(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(hn,"validateInputs$1");function mn(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:f.RESOLVER.UNKNOWN_MODIFIER(n)})}s(mn,"validateNoModifiersCase");function In(e,t,n,r){for(const[o,i]of Object.entries(e)){const a=t.get(o);if(!a){n.push({modifier:o,message:f.RESOLVER.UNKNOWN_MODIFIER(o)});continue}if(typeof i!="string"){n.push({modifier:o,message:f.RESOLVER.INVALID_INPUT_TYPE(o)});continue}if(!a.contexts.includes(i)){n.push({modifier:o,message:f.RESOLVER.INVALID_CONTEXT(i,o,a.contexts)});continue}r[o]=i}}s(In,"validateProvidedInputs");function yn(e,t,n){for(const r of e)t[r.name]===void 0&&(r.default!==void 0?t[r.name]=r.default:n.push({modifier:r.name,message:f.RESOLVER.MISSING_REQUIRED_INPUT(r.name)}))}s(yn,"applyDefaults");async function Me(e,t,n={}){const r=hn(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=xe(e,t),i=En();for(const a of e.resolutionOrder)await gn(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(Me,"processResolutionOrder");function En(){return{tokens:{},sources:[],errors:[]}}s(En,"createProcessingState");async function gn(e,t,n,r,o){if(L(e)){await $n(e,t,n,r,o);return}if(Le(e)){await Nn(e,n,o);return}x(e)&&await Sn(e,n,r,o)}s(gn,"processItem");async function $n(e,t,n,r,o){const i=await Fe(e.$ref,n);if(i.errors.length>0){o.errors.push(...i.errors);return}const a=e.$ref.split("/")[2];if(a){if(e.$ref.startsWith("#/sets/")){const c=await B(i.content.sources,n,{type:"set",name:a});Y(c,o);return}if(e.$ref.startsWith("#/modifiers/")){const c=r[a];if(!c)return;const p=i.content.contexts[c];if(!p)return;const h=await B(p,n,{type:"modifier",name:a,context:c});Y(h,o)}}}s($n,"processReference");async function Nn(e,t,n){const r=await B(e.sources,t,{type:"set",name:e.name});Y(r,n)}s(Nn,"processInlineSet");async function Sn(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await B(i,t,{type:"modifier",name:e.name,context:o});Y(a,r)}s(Sn,"processInlineModifier");async function B(e,t,n){const r=await Ve(e,t);let o={};for(const i of r.resolved)o=G(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(B,"mergeSources");function Y(e,t){t.errors.push(...e.errors),t.tokens=G(t.tokens,e.tokens),t.sources.push(e.source)}s(Y,"applyResult");async function Tn(e,t){const n=[],r=xe(e,t),o=we(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await Me(e,t,i);n.push(...a.errors);const c=a.tokens,u=[];for(const p of o){const h=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const y=await An(e,t,r,p.name,I,n);Object.keys(y).length>0&&h.set(I,y)}u.push({name:p.name,defaultContext:d,contexts:h})}return{base:c,modifiers:u,errors:n}}s(Tn,"processForLayeredCSS");async function An(e,t,n,r,o,i){const a=bn(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const u=await Ve(c,n);i.push(...u.errors.map(y=>({path:y.path,message:y.message})));let p={};for(const y of u.resolved)p=G(p,y);const h=new Set;Pe(p,"",h);const d=await Me(e,t,{[r]:o});i.push(...d.errors);const I={};for(const y of h){const g=On(d.tokens,y);g!==void 0&&Rn(I,y,g)}return I}s(An,"processModifierContext");function bn(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(x(n)&&n.name===t)return n}s(bn,"findModifierDefinition");function Pe(e,t,n){for(const[r,o]of Object.entries(e)){if(r.startsWith("$"))continue;const i=t?`${t}.${r}`:r;o&&typeof o=="object"&&"$value"in o?n.add(i):o&&typeof o=="object"&&Pe(o,i,n)}}s(Pe,"collectTokenPaths");function On(e,t){const n=t.split(".");let r=e;for(const o of n){if(r===null||typeof r!="object")return;r=r[o]}return r}s(On,"getTokenAtPath");function Rn(e,t,n){const r=t.split(".");let o=e;for(let a=0;a<r.length-1;a++){const c=r[a];c&&(c in o||(o[c]={}),o=o[c])}const i=r[r.length-1];i&&(o[i]=n)}s(Rn,"setTokenAtPath");async function je(e){const t=V(e)?e:R(process.cwd(),e),n=re(t),r=[],o=[],i=D(process.cwd(),t),a=await Jt(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await Tn(a.document,n);for(const p of c.errors)r.push({file:p.path,message:p.message});Object.keys(c.base).length>0&&o.push({context:void 0,tokens:c.base,sourcePath:i});const u=[];for(const p of c.modifiers){const h=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),h.push(d));u.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:h})}return{trees:o,modifiers:u,errors:r}}s(je,"loadFromResolver");function H(e,t,n,r){return typeof t=="string"&&m(t)?_n(e,t,n,r):Array.isArray(t)?t.map(o=>H(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:H(`${e}.${a}`,c,n,r)}),{}):t}s(H,"resolveValue");function Ue(e,t){const n=e.slice(1,-1),r=t.pathIndex.get(n);if(!r)return;const o=t.tokens[r];if(!(!o||!("$value"in o))){if(o.$type)return o.$type;if(typeof o.$value=="string"&&m(o.$value))return Ue(o.$value,t)}}s(Ue,"inferTypeFromReference");function Ln(e){const t={},n=new Set,r=[];for(const[o,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[o]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&m(a.$value)&&(c=Ue(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:H(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),u=i,p=u.$path,h=u.$source;let d,I;c.includes("Circular reference detected")?(d="circular",I=c):c.includes("Reference not found")?(d="missing",I=c):(d="type-mismatch",I=f.RESOLVE.TYPE_MISMATCH(p)),r.push({type:d,path:p,source:h,message:I})}return{resolved:t,errors:r}}s(Ln,"resolve");function _n(e,t,n,r){const o=t.slice(1,-1),i=n.pathIndex.get(o);if(!i)throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(o,e));if(r.has(i)){const u=n.tokens[i];throw!u||!("$path"in u)?new Error(f.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(f.RESOLVE.CIRCULAR_REFERENCE(e,u.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(o,e));r.add(i);const c=H(i,a.$value,n,r);return r.delete(i),c}s(_n,"resolveReferenceChain");function T(e){return{success:!0,value:e}}s(T,"success");function $(e){return{success:!1,error:e}}s($,"error");function ce(e){if(typeof e!="object"||e===null)return!1;const t=e;return!(typeof t.colorSpace!="string"||!["oklch","display-p3","srgb","hsl"].includes(t.colorSpace)||!Array.isArray(t.components)||t.components.length!==3||!t.components.every(r=>typeof r=="number"||r==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(ce,"isW3CColorValue");function K(e){const t=[],n=["oklch","display-p3","srgb","hsl"];if(n.includes(e.colorSpace)||t.push(`Unsupported colorSpace: "${e.colorSpace}". Supported color spaces: ${n.join(", ")}.`),!Array.isArray(e.components)||e.components.length!==3)t.push("Components must be an array of exactly 3 numbers.");else if(e.components.forEach((r,o)=>{r!=="none"&&(typeof r!="number"||!Number.isFinite(r))&&t.push(`Component ${o} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),o!=="none"&&o<0&&t.push("OKLCH Chroma (C) must be >= 0 or 'none'."),i!=="none"&&(i<0||i>=360)&&t.push("OKLCH Hue (H) must be between 0 and 360 (exclusive) or 'none'.")}else if(e.colorSpace==="display-p3"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>1)&&t.push("Display P3 Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("Display P3 Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="srgb"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>1)&&t.push("sRGB Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("sRGB Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="hsl"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),o!=="none"&&(o<0||o>100)&&t.push("HSL Saturation must be between 0 and 100 or 'none'."),i!=="none"&&(i<0||i>100)&&t.push("HSL Lightness must be between 0 and 100 or 'none'.")}return e.alpha!==void 0&&(typeof e.alpha!="number"||!Number.isFinite(e.alpha)?t.push("Alpha must be a finite number."):(e.alpha<0||e.alpha>1)&&t.push("Alpha must be between 0 and 1.")),t}s(K,"validateW3CColorValue");function Dn(e){const t=K(e);return t.length>0?$(t.join(", ")):T(e)}s(Dn,"validateW3CColorValueResult");function vn(e){const t=Dn(e);if(!t.success)return t;const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4)),u=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`oklch(${a} ${c} ${u} / ${p})`)}return T(`oklch(${a} ${c} ${u})`)}s(vn,"formatW3CColorToOKLCH");const xn={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function E(e,t,n,r){if(m(t))return[];switch(e.type){case"object":return Cn(e,t,n,r);case"union":return Vn(e,t,n,r);case"array":return kn(e,t,n,r);default:return Fn(e,t,n,r)}}s(E,"validateSchema");function Fn(e,t,n,r){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE(e.type,t,n),source:r}]:e.validate?.(t,n,r)??[]}s(Fn,"validateSimpleValue");function Cn(e,t,n,r){if(!xn.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("object",t,n),source:r}];const o=[],i=t;if(e.required)for(const a of e.required)a in i||o.push({path:`${n}.${a}`,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:r});for(const[a,c]of Object.entries(e.properties))a in i&&o.push(...E(c,i[a],`${n}.${a}`,r));return o}s(Cn,"validateObject");function Vn(e,t,n,r){let o=[],i=Number.POSITIVE_INFINITY;for(const a of e.oneOf){if(a.type==="string"&&typeof t!="string"||a.type==="object"&&typeof t!="object")continue;const c=E(a,t,n,r);if(c.length===0)return a.validate?.(t,n,r)??[];c.length<i&&(o=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:f.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:r}]:o}s(Vn,"validateUnion");function kn(e,t,n,r){return Array.isArray(t)?e.validate?.(t,n,r)??[]:[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("array",t,n),source:r}]}s(kn,"validateArray");const q={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)?[]:[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")},{type:"object",required:["colorSpace","components"],properties:{colorSpace:{type:"string"},components:{type:"array"},alpha:{type:"number"},hex:{type:"string"}},validate:s((e,t,n)=>ce(e)?K(e).map(o=>({path:t,message:`Invalid color at ${t}: ${o}`,source:n})):[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function wn(e,t,n){return E(q.schema,e,t,n)}s(wn,"validateColor");const z={schema:{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:f.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function Mn(e,t,n){return E(z.schema,e,t,n)}s(Mn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:z.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:f.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function Pn(e,t,n){return E(N.schema,e,t,n)}s(Pn,"validateDimension");const We={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function jn(e,t,n){return E(We.schema,e,t,n)}s(jn,"validateFontFamily");const Un=["thin","hairline","extra-light","ultra-light","light","normal","regular","book","medium","semi-bold","demi-bold","bold","extra-bold","ultra-bold","black","heavy","extra-black","ultra-black"],Ge={schema:{type:"union",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>Un.includes(e.toLowerCase())?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Wn(e,t,n){return E(Ge.schema,e,t,n)}s(Wn,"validateFontWeight");const Gn=["ms","s"],ue={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:z.schema,unit:{type:"string",validate:s((e,t,n)=>Gn.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Bn(e,t,n){return E(ue.schema,e,t,n)}s(Bn,"validateDuration");const Be={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e;if(r.length!==4||!r.every(a=>typeof a=="number"))return[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Yn(e,t,n){return E(Be.schema,e,t,n)}s(Yn,"validateCubicBezier");const Hn={schema:{type:"object",properties:{fontFamily:We.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:z.schema,fontWeight:Ge.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Kn(e,t,n){return E(Hn.schema,e,t,n)}s(Kn,"validateTypography");const qn=["solid","dashed","dotted","double","groove","ridge","outset","inset"],zn=["round","butt","square"],Jn={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{typeof i!="string"&&o.push(...E(N.schema,i,`${t}.${a}`,n))}),o},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>zn.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Ye={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!qn.includes(e)&&typeof e=="string"?[{path:t,message:f.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},Jn]}};function Xn(e,t,n){return E(Ye.schema,e,t,n)}s(Xn,"validateStrokeStyle");const Zn={schema:{type:"object",properties:{color:q.schema,width:N.schema,style:Ye.schema},required:["color","width","style"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Qn(e,t,n){return E(Zn.schema,e,t,n)}s(Qn,"validateBorder");const er={schema:{type:"object",properties:{duration:ue.schema,delay:ue.schema,timingFunction:Be.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function tr(e,t,n){return E(er.schema,e,t,n)}s(tr,"validateTransition");const He={schema:{type:"object",properties:{color:{type:"union",oneOf:[q.schema]},offsetX:N.schema,offsetY:N.schema,blur:N.schema,spread:N.schema,inset:{type:"boolean",errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function nr(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...E(He.schema,o,`${t}[${i}]`,n))}),r):E(He.schema,e,t,n)}s(nr,"validateShadow");const rr={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:q.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:f.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},or={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{o.push(...E(rr,i,`${t}[${a}]`,n))}),o},"validate")}};function sr(e,t,n){return E(or.schema,e,t,n)}s(sr,"validateGradient");const ir={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:N.schema,max:N.schema},required:["min","max"]}};function ar(e,t,n){return E(ir.schema,e,t,n)}s(ar,"validateFluidDimension");const cr={color:wn,dimension:Pn,fluidDimension:ar,duration:Bn,cubicBezier:Yn,fontFamily:jn,fontWeight:Wn,number:Mn,strokeStyle:Xn,typography:Kn,border:Qn,shadow:nr,gradient:sr,transition:tr};function ur(e){const t=[];for(const[n,r]of Object.entries(e.tokens)){if(typeof r!="object"||r===null||!("$type"in r)||!("$path"in r)||r.$path.startsWith("$"))continue;if(!("$value"in r)){t.push({path:r.$path,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",r.$path),source:r.$source});continue}const o=cr[r.$type];if(!o){t.push({path:r.$path,message:f.VALIDATE.UNKNOWN_TOKEN_TYPE(r.$type,r.$path),source:r.$source});continue}const i=r;t.push(...o(i.$value,i.$path,i.$source))}return t}s(ur,"validate");async function fr(e){const{trees:t,modifiers:n,errors:r}=await lr(e),{tokens:o,errors:i}=jt(t),a=ur(o),{resolved:c,errors:u}=Ln(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:u}}}s(fr,"loadAndResolveTokens");async function lr(e){switch(e.type){case"memory":{const t=await Ut(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await je(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(lr,"loadTokens");function Ke(e){return m(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>m(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Ke,"convertStrokeStyleToken");function pr(e){if(m(e))return{value:e};const t=m(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(m(e.color),e.color),r=typeof e.style=="string"?e.style:Ke(e.style).value;return{value:`${t} ${r} ${n}`}}s(pr,"convertBorderToken");function qe(e,t="native"){return ce(e)?dr(e):T(e)}s(qe,"convertColorToString");function dr(e){switch(e.colorSpace){case"oklch":return vn(e);case"display-p3":return hr(e);case"srgb":return mr(e);case"hsl":return Ir(e);default:return $(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(dr,"formatW3CColorNative");function hr(e){if(e.colorSpace!=="display-p3")return $(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return $("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,r]=e.components,o=e.alpha;if(t!=="none"&&(t<0||t>1))return $("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return $("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return $("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return $("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4));if(o!==void 0&&o!==1){const u=Number(o.toFixed(4));return T(`color(display-p3 ${i} ${a} ${c} / ${u})`)}return T(`color(display-p3 ${i} ${a} ${c})`)}s(hr,"formatW3CColorToP3");function mr(e){if(e.colorSpace!=="srgb")return $(`Expected srgb color space, got: ${e.colorSpace}`);const t=K(e);if(t.length>0)return $(`Invalid W3C color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=r==="none"?"none":Math.round(r*255),u=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`rgb(${a} ${c} ${u} / ${p})`)}return T(`rgb(${a} ${c} ${u})`)}s(mr,"formatW3CColorToRGB");function Ir(e){if(e.colorSpace!=="hsl")return $(`Expected hsl color space, got: ${e.colorSpace}`);const t=K(e);if(t.length>0)return $(`Invalid W3C color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=r==="none"?"none":Math.round(r),u=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,y=u==="none"?"none":`${u}%`;return T(`hsl(${a} ${I} ${y} / ${d})`)}const p=c==="none"?"none":`${c}%`,h=u==="none"?"none":`${u}%`;return T(`hsl(${a} ${p} ${h})`)}s(Ir,"formatW3CColorToHSL");function yr(e,t){if(typeof e=="string"&&m(e))return{value:e};const n=t.colorFallbackStrategy;if(ce(e))return Er(e,n);const r=qe(e,n);return r.success?{value:r.value}:(console.warn(`Failed to convert color ${typeof e=="string"?e:"W3C color object"}: ${r.error}`),{value:typeof e=="string"?e:"#000000"})}s(yr,"convertColorToken");function Er(e,t){const n=qe(e,t);if(!n.success)return console.warn(`Failed to convert W3C color: ${n.error}`),{value:"#000000"};const r=n.value;if(t==="native")return{value:r};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:r};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:gr(e.colorSpace),value:r}]}}s(Er,"convertW3CColorToken");function gr(e){switch(e){case"oklch":return"@supports (color: oklch(0 0 0))";case"display-p3":return"@supports (color: color(display-p3 1 1 1))";default:throw new Error(`No feature query defined for color space: ${e}`)}}s(gr,"getFeatureQuery");function $r(e){return m(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s($r,"convertCubicBezierToken");function Nr(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Nr,"convertDimensionToken");function Sr(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Sr,"convertDurationToken");function ze(e,t=16){return e.unit==="px"?e.value:e.value*t}s(ze,"normalizeToPixels");function Tr(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=ze(n,i),c=ze(r,i),u=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const h=a/i,d=c/i,I=u/i,y=p/i,g=(d-h)/(y-I),Ie=-1*I*g+h;return{value:`clamp(${h}rem, ${Ie.toFixed(2)}rem + ${(g*100).toFixed(2)}vw, ${d}rem)`}}s(Tr,"convertFluidDimension");function Ar(e,t){return m(e)?{value:e}:Tr(e,t)}s(Ar,"convertFluidDimensionToken");function J(e){return["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"].includes(e.toLowerCase())?e:/[\s'"!@#$%^&*()=+[\]{};:|\\/,.<>?~]/.test(e)?`"${e}"`:e}s(J,"quoteFont");function br(e){return m(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>J(n)).join(", "):J(e)}}s(br,"convertFontFamilyToken");const Or={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 Je(e){return m(e)?{value:e}:typeof e=="number"?{value:e}:{value:Or[e.toLowerCase()]??e}}s(Je,"convertFontWeightToken");function Rr(e){return m(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const r=(m(n.color),n.color),o=m(n.position)?n.position:`${n.position*100}`;return`${r} ${o}%`}).join(", ")})`}}s(Rr,"convertGradientToken");function Lr(e){return m(e)?{value:e}:{value:e}}s(Lr,"convertNumberToken");function Xe(e){const t=m(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=m(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,r=m(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,o=m(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(m(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${r} ${o} ${i}`}s(Xe,"convertSingleShadow");function _r(e){return m(e)?{value:e}:Array.isArray(e)?{value:e.map(Xe).join(", ")}:{value:Xe(e)}}s(_r,"convertShadowToken");function Ze(e){return e?`${e.value}${e.unit}`:"0ms"}s(Ze,"formatDuration");function Dr(e){if(m(e))return{value:e};const t=m(e.duration)?e.duration:Ze(e.duration),n=m(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(m(e.delay)?e.delay:Ze(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(Dr,"convertTransitionToken");function vr(e){if(m(e))return{"font-family":e,"font-size":e};const t={"font-family":m(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>J(n)).join(", "):J(e.fontFamily),"font-size":m(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=m(e.fontWeight)?e.fontWeight:Je(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=m(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(m(e.lineHeight),e.lineHeight)),t}s(vr,"convertTypographyToken");const Qe={duration:Sr,number:Lr,cubicBezier:$r,color:yr,dimension:Nr,fluidDimension:Ar,typography:vr,border:pr,shadow:_r,gradient:Rr,transition:Dr,strokeStyle:Ke,fontFamily:br,fontWeight:Je};function xr(e,t){const n=Qe[e.$type];return{...e.$description?{$description:e.$description}:{},...e.$extensions?{$extensions:e.$extensions}:{},$type:e.$type,$value:e.$value,$path:e.$path,$source:e.$source,$originalPath:e.$originalPath,$resolvedValue:e.$resolvedValue,$cssProperties:n(e.$value,t)}}s(xr,"convertSingleToken");function Fr(e,t,n){const r={};for(const[o,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){r[o]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)){console.warn(`[sugarcube] Skipping invalid token: ${i.$path} (has validation error)`);continue}if(!Qe[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=xr(i,a)}return r}s(Fr,"convertTokens");function Cr(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=Fr(i,t,n);return r}s(Cr,"convert");function Vr(e,t){const n={},r=new Set;for(const o of e){const i=o.context??"default";r.add(i)}for(const o of r)n[o]={};for(const o of e){const{context:i,tokens:a}=o,c=i??"default";n[c]||(n[c]={});for(const[u,p]of Object.entries(a))n[c][u]=p}return{tokens:n,defaultContext:t}}s(Vr,"normalizeTokens");function kr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const u=c.context??"";n.has(u)||n.set(u,{});const p=n.get(u);p&&(p[r]=o)}continue}const i=o.$source.context??"";n.has(i)||n.set(i,{});const a=n.get(i);a&&(a[r]=o)}return e.map(r=>{const o=r.context??"",i=n.get(o)||{};return{context:r.context,tokens:i}})}s(kr,"processTrees");async function wr(e,t,n,r){const o=kr(e,t),{tokens:i}=Vr(o);return Cr(i,n,r?u=>r.some(p=>p.path===u||p.path.startsWith(`${u}.`)):void 0)}s(wr,"processAndConvertTokens");const X=["reset","global","compositions","blocks","utilities"];async function fe(e,t){const n=[],r=await It([A(e,"**/*.css"),A(e,"**/*.scss"),A(e,"**/*.sass"),A(e,"**/*.less")],{ignore:[A(e,M)]});for(const o of r){const i=Mr(o,e);if(i){const a=D(e,o);n.push({path:a,layer:i,relativePath:a})}}return n}s(fe,"discoverAllFiles");function Mr(e,t){const n=D(t,e);if(n.includes("global/")||n.startsWith("global/"))return mt(e).includes("reset")?"reset":"global";if(n.includes("compositions/")||n.startsWith("compositions/"))return"compositions";if(n.includes("blocks/")||n.startsWith("blocks/"))return"blocks";if(n.includes("utilities/")||n.startsWith("utilities/"))return"utilities"}s(Mr,"categorizeFile");function Pr(e){return e.sort((t,n)=>{const r=X.indexOf(t.layer),o=X.indexOf(n.layer);return r!==o?r-o:t.path.localeCompare(n.path)})}s(Pr,"sortFilesByLayer");function jr(){return`@layer ${X.join(", ")};
|
|
16
|
-
`}s(jr,"getLayerDefinitions");function et(e){const t=[];t.push(jr());const n=e.reduce((r,o)=>{const i=r[o.layer]??[];return r[o.layer]=[...i,o],r},{});for(const r of X){const o=n[r];if(!(!o||o.length===0))for(const i of o)t.push(`@import "${i.path}" layer(${i.layer});`)}return t.join(`
|
|
17
|
-
`)}s(et,"generateIndexContent");async function Ur(e,t){const n=A(e,M),r=await fe(e),o=Pr(r),i=et(o);return await k.writeFile(n,i),D(process.cwd(),n)}s(Ur,"generateIndex");async function Wr(e,t){const n=A(e,M);if(!v(n))return!0;try{const r=await k.stat(n),o=await fe(e,t);for(const i of o){const a=A(e,i.path);if(v(a)&&(await k.stat(a)).mtime>r.mtime)return!0}return!1}catch{return!0}}s(Wr,"shouldRegenerateIndex");const Gr=`/*!
|
|
15
|
+
`)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e===w?`Cannot find sugarcube config file. Please ensure you have a valid ${w} file in your project root.`:`Cannot find sugarcube config file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND")},UTILITIES:{RESERVED_PREFIX:s((e,t)=>`Cannot use reserved prefix "${e}" for ${t} token type. This prefix is reserved for default utility classes. Please use a custom prefix instead.`,"RESERVED_PREFIX"),DUPLICATE_CLASS_NAME:s((e,t)=>`Ambiguous utility class "${e}" would be generated from multiple token paths: ${t.join(", ")}. This would make it impossible to know which token value should be used when this class is applied in HTML. To fix this, configure one or more paths with custom prefixes to make the intent clear.`,"DUPLICATE_CLASS_NAME"),INVALID_PROPERTY_MAPPING:s(e=>`Invalid property mapping for ${e} token type. When mapping multiple properties, each mapping must include a unique prefix to avoid class name collisions.`,"INVALID_PROPERTY_MAPPING"),DUPLICATE_PREFIX:s((e,t)=>`Duplicate prefix "${e}" found in property mappings for ${t} token type. Each property mapping must have a unique prefix to avoid class name collisions.`,"DUPLICATE_PREFIX"),MISSING_SOURCE:s(e=>`Utility config for '${e}' must have a valid 'source' property`,"MISSING_SOURCE"),INVALID_SOURCE_PATTERN:s((e,t)=>`Utility config for '${e}' has invalid source pattern '${t}'. Only patterns ending with '.*' are supported (e.g., 'color.*', 'font.weight.*').`,"INVALID_SOURCE_PATTERN"),INVALID_DIRECTIONS:s(e=>`Utility config for '${e}' must have 'directions' as an array`,"INVALID_DIRECTIONS"),INVALID_CONFIG_OBJECT:"utilitiesConfig must be an object",INVALID_TOKENS_OBJECT:"tokens must be an object"},RESOLVER:{FILE_NOT_FOUND:s(e=>`Cannot read resolver file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND"),INVALID_JSON:s(e=>`Invalid JSON in resolver file: ${e}`,"INVALID_JSON"),INVALID_REFERENCE:s(e=>`Invalid reference "${e}". References must use format #/sets/<name> or #/modifiers/<name>.`,"INVALID_REFERENCE"),INVALID_SOURCE_REFERENCE:s(e=>`Invalid source reference "${e}". Sources can only reference sets (#/sets/<name>), not modifiers.`,"INVALID_SOURCE_REFERENCE"),UNDEFINED_SET:s(e=>`Reference to undefined set "${e}". Define it in the "sets" section first.`,"UNDEFINED_SET"),UNDEFINED_MODIFIER:s(e=>`Reference to undefined modifier "${e}". Define it in the "modifiers" section first.`,"UNDEFINED_MODIFIER"),CIRCULAR_REFERENCE:s(e=>`Circular reference detected at "${e}".`,"CIRCULAR_REFERENCE"),EXTERNAL_FILE_NOT_FOUND:s(e=>`Referenced file not found: ${e}`,"EXTERNAL_FILE_NOT_FOUND"),EXTERNAL_FILE_ERROR:s((e,t)=>`Failed to load "${e}": ${t}`,"EXTERNAL_FILE_ERROR"),INVALID_JSON_POINTER:s((e,t)=>`Invalid JSON pointer "${e}": ${t}`,"INVALID_JSON_POINTER"),DUPLICATE_NAME:s(e=>`Duplicate name "${e}" in resolutionOrder.`,"DUPLICATE_NAME"),MODIFIER_NEEDS_CONTEXTS:"Modifier must have at least one context defined.",MODIFIER_SINGLE_CONTEXT:"Modifier has only one context. Consider using a set instead, or add more contexts.",INVALID_DEFAULT:s((e,t)=>`Default context "${e}" is not defined. Valid contexts: ${t.join(", ")}`,"INVALID_DEFAULT"),UNKNOWN_MODIFIER:s(e=>`Unknown modifier "${e}".`,"UNKNOWN_MODIFIER"),INVALID_CONTEXT:s((e,t,n)=>`Invalid context "${e}" for modifier "${t}". Valid contexts: ${n.join(", ")}`,"INVALID_CONTEXT"),MISSING_REQUIRED_INPUT:s(e=>`Missing required input for modifier "${e}". No default value is defined.`,"MISSING_REQUIRED_INPUT"),INVALID_INPUT_TYPE:s(e=>`Input for modifier "${e}" must be a string.`,"INVALID_INPUT_TYPE"),MALFORMED_REFERENCE:s((e,t)=>`Malformed source reference: { "${e}": "${t}" }. Did you mean { "$ref": "${t}" }?`,"MALFORMED_REFERENCE"),RESOLVER_AS_TOKEN_SOURCE:s(e=>`File "${e}" is a resolver document, not a token file. Resolver documents (version: "2025.10") cannot be used as token sources. Did you mean to reference a specific token file instead?`,"RESOLVER_AS_TOKEN_SOURCE")}};function oe(e){return typeof e=="object"&&e!==null&&"$value"in e}s(oe,"isTokenNode");function Gt(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!oe(o)){if(i&&oe(i)){const d=i;n.push({path:d.$path,source:d.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(d.$path)});continue}e.tokens[r]=o;continue}if(!i){e.tokens[r]=o;continue}if(!oe(i)){n.push({path:o.$path,source:o.$source,message:f.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,u=i,p=!!c.$type,h=!!u.$type;if(p&&h&&c.$type!==u.$type){n.push({path:c.$path,source:c.$source,message:f.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(u.$type??"unknown"),String(c.$type??"unknown"),c.$path)});continue}e.tokens[r]=o}for(const[r,o]of t.pathIndex)e.pathIndex.set(r,o)}s(Gt,"mergeFlattenedInto");function Bt(e){if(typeof e!="object"||e===null||"$value"in e)return!1;const t="value"in e,n="type"in e;if(t&&n)return!0;if(t){const r=e.value;return typeof r=="string"||typeof r=="number"||Array.isArray(r)}return!1}s(Bt,"looksLikeUnprefixedToken");function Yt(e,t){const n={tokens:{},pathIndex:new Map},r=[];function o(a=[]){const c=[];return t.context&&c.push(t.context),a.length>0&&c.push(a.join(".")),c.length>0?c.join("."):""}s(o,"createLookupKey"),(e.$description||e.$extensions)&&(n.tokens[o()]={$description:e.$description,$extensions:e.$extensions});function i(a,c=[],u){if(c.join("."),c.length>0){const d=o(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{context:t.context,sourcePath:t.sourcePath}}}const p=Object.keys(a).filter(d=>!d.startsWith("$")),h=a.$type||u;for(const d of p){const I=a[d],y=[...c,d],g=y.join(".");if(Bt(I)){r.push({path:g,source:t,message:f.FLATTEN.MISSING_DOLLAR_PREFIX(g)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:g,source:t,message:f.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(Et=>!Et.startsWith("$")).length>0){r.push({path:g,source:t,message:f.FLATTEN.INVALID_TOKEN_NESTING(g)});continue}if(Lt(I)&&!I.$type&&!h){r.push({path:g,source:t,message:f.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE(g)});continue}const Ie=o(y),Q=y.join(".");n.tokens[Ie]={...I,...I.$type||h?{$type:I.$type||h}:{},$path:Q,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:Q},n.pathIndex.set(Q,Ie)}else i(I,y,h)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(Yt,"flattenTree");function Ht(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=Yt(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),Gt(t,o,n)}return{tokens:t,errors:n}}s(Ht,"flatten");const v=l.string().min(1,"Name cannot be empty").refine(e=>!e.startsWith("$"),"Names must not start with '$' (reserved prefix)").refine(e=>!e.includes("{"),"Names must not contain '{'").refine(e=>!e.includes("}"),"Names must not contain '}'").refine(e=>!e.includes("."),"Names must not contain '.'"),se=l.object({$ref:l.string().min(1,"$ref cannot be empty")}).passthrough(),M=l.union([se,l.record(l.string(),l.unknown())]),Re=l.object({description:l.string().optional(),sources:l.array(M),$extensions:l.record(l.string(),l.unknown()).optional()}),ie=l.record(l.string(),l.array(M)),Le=l.object({description:l.string().optional(),contexts:ie,default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),De=l.object({type:l.literal("set"),name:v,sources:l.array(M),description:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}),_e=l.object({type:l.literal("modifier"),name:v,contexts:ie,description:l.string().optional(),default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),ve=l.union([se,De,_e]),xe=l.record(v,Re),Fe=l.record(v,Le),Ce=l.object({version:l.literal("2025.10"),name:l.string().optional(),description:l.string().optional(),sets:xe.optional(),modifiers:Fe.optional(),resolutionOrder:l.array(ve),$schema:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional(),$defs:l.record(l.string(),l.unknown()).optional()});function A(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(A,"isReference");function ae(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(ae,"isInlineSet");function L(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(L,"isInlineModifier");async function Kt(e){const t=C(e)?e:R(process.cwd(),e),n=await qt(t);if(n.error)return{document:P(),errors:[n.error]};const r=zt(n.content);if(r.error)return{document:P(),errors:[r.error]};const o=Jt(r.data);if(o.errors.length>0)return{document:P(),errors:o.errors};const i=[];return Xt(o.document,i),{document:o.document,errors:i}}s(Kt,"parseResolverDocument");async function qt(e){try{return{content:await k(e,"utf-8")}}catch{return{error:{path:e,message:f.RESOLVER.FILE_NOT_FOUND(e)}}}}s(qt,"loadFile");function zt(e){try{return{data:JSON.parse(e)}}catch(t){const n=t instanceof Error?t.message:"Unknown error";return{error:{path:"resolver",message:f.RESOLVER.INVALID_JSON(n)}}}}s(zt,"parseJson");function Jt(e){const t=Ce.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".")||"resolver";return{path:o,message:`Resolver error at ${o}: ${r.message}. See https://sugarcube.sh/docs/resolver`}});return{document:P(),errors:n}}return{document:t.data,errors:[]}}s(Jt,"validateSchema$1");function Xt(e,t){Zt(e,t),Qt(e,t),en(e,t)}s(Xt,"validateDocument");function Zt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))Ve(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];L(r)&&Ve(r,`resolutionOrder[${n}]`,t)}}s(Zt,"validateModifierContexts");function Ve(e,t,n){const r=Object.keys(e.contexts).length;if(r===0){n.push({path:`${t}.contexts`,message:f.RESOLVER.MODIFIER_NEEDS_CONTEXTS});return}r===1&&n.push({path:`${t}.contexts`,message:f.RESOLVER.MODIFIER_SINGLE_CONTEXT}),e.default&&!e.contexts[e.default]&&n.push({path:`${t}.default`,message:f.RESOLVER.INVALID_DEFAULT(e.default,Object.keys(e.contexts))})}s(Ve,"checkModifierContexts");function Qt(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(A(o))continue;const i=o.name;n.has(i)&&t.push({path:`resolutionOrder[${r}].name`,message:f.RESOLVER.DUPLICATE_NAME(i)}),n.add(i)}}s(Qt,"validateNameUniqueness");function en(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(A(r))tn(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(ae(r))j(r.sources,`resolutionOrder[${n}].sources`,t);else if(L(r))for(const[o,i]of Object.entries(r.contexts))j(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))j(r.sources,`sets.${n}.sources`,t);if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))for(const[o,i]of Object.entries(r.contexts))j(i,`modifiers.${n}.contexts.${o}`,t)}s(en,"validateReferences");function j(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!A(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],u=o[c];typeof u=="string"&&(u.includes("/")||u.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:f.RESOLVER.MALFORMED_REFERENCE(c,u)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:f.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(j,"validateSourcesReferences");function tn(e,t,n,r){if(!e.startsWith("#/"))return;const o=e.slice(2).split("/"),[i,a]=o;if(o.length!==2||!i||!a){r.push({path:t,message:f.RESOLVER.INVALID_REFERENCE(e)});return}if(i==="sets"){n.sets?.[a]||r.push({path:t,message:f.RESOLVER.UNDEFINED_SET(a)});return}if(i==="modifiers"){n.modifiers?.[a]||r.push({path:t,message:f.RESOLVER.UNDEFINED_MODIFIER(a)});return}r.push({path:t,message:f.RESOLVER.INVALID_REFERENCE(e)})}s(tn,"validateReference");function P(){return{version:"2025.10",resolutionOrder:[]}}s(P,"createEmptyDocument");function ke(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(ke,"isResolverFormat");function we(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(we,"createResolveContext");async function Me(e,t){if(t.visitedRefs.has(e))return S({},f.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?nn(e,t):e.includes("#/")?await on(e,t):await rn(e,t)}finally{t.visitedRefs.delete(e)}}s(Me,"resolveReference");function nn(e,t){const n=e.slice(2),[r,o]=n.split("/");if(!r||!o||n.split("/").length!==2)return S({sources:[]},f.RESOLVER.INVALID_REFERENCE(e));if(r==="sets"){const i=t.document.sets?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({sources:[]},f.RESOLVER.UNDEFINED_SET(o))}if(r==="modifiers"){const i=t.document.modifiers?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({contexts:{}},f.RESOLVER.UNDEFINED_MODIFIER(o))}return S({sources:[]},f.RESOLVER.INVALID_REFERENCE(e))}s(nn,"resolveSameDocumentRef");async function rn(e,t){const n=C(e)?e:R(t.basePath,e),r=t.fileCache.get(n);if(r)return ke(r)?S({},f.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await je(n);return o.error?S({},o.error,n):ke(o.content)?S({},f.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(rn,"resolveFileRef");async function on(e,t){const[n="",r=""]=e.split("#"),o=C(n)?n:R(t.basePath,n);let i=t.fileCache.get(o);if(!i){const u=await je(o);if(u.error)return S({},u.error,o);i=u.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=sn(i,a);return c.error?S({},f.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(on,"resolveFileFragmentRef");async function je(e){try{const t=await k(e,"utf-8");return{content:JSON.parse(t)}}catch(t){if(t.code==="ENOENT")return{error:f.RESOLVER.EXTERNAL_FILE_NOT_FOUND(e)};const n=t instanceof Error?t.message:"Unknown error";return{error:f.RESOLVER.EXTERNAL_FILE_ERROR(e,n)}}}s(je,"loadJsonFile");function sn(e,t){if(t===""||t==="/")return{value:e};const n=t.slice(1).split("/").map(o=>o.replace(/~1/g,"/").replace(/~0/g,"~"));let r=e;for(const o of n){if(r===null||typeof r!="object")return{error:"cannot navigate into non-object"};if(Array.isArray(r)){const a=Number.parseInt(o,10);if(Number.isNaN(a)||a<0||a>=r.length)return{error:`invalid array index "${o}"`};r=r[a];continue}const i=r;if(!(o in i))return{error:`property "${o}" not found`};r=i[o]}return{value:r}}s(sn,"resolveJsonPointer");async function Pe(e,t){const n=[],r=[];for(const o of e){if(!A(o)){n.push(o);continue}const i=await Me(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(an(i.content,o))}return{resolved:n,errors:r}}s(Pe,"resolveSources");function an(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(an,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function Ue(e){return typeof e=="object"&&e!==null&&"$value"in e}s(Ue,"isToken");function U(e,t){const n={...e};for(const[r,o]of Object.entries(t)){if(o===void 0)continue;if(r.startsWith("$")){n[r]=o;continue}if(Ue(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!Ue(i);n[r]=a?U(i,o):o}return n}s(U,"deepMerge");function We(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=cn(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(We,"extractModifiers");function cn(e,t,n){return A(e)&&e.$ref.startsWith("#/modifiers/")?un(e.$ref,t,n):L(e)?fn(e,n):null}s(cn,"extractModifierFromItem");function un(e,t,n){const r=e.split("/")[2];if(!r||n.has(r))return null;const o=t.modifiers?.[r];return o?{name:r,contexts:Object.keys(o.contexts),default:o.default}:null}s(un,"extractReferencedModifier");function fn(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(fn,"extractInlineModifier");function ln(e,t={}){const n=[],r={},o=We(e);if(o.length===0)return pn(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return dn(t,i,n,r),hn(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(ln,"validateInputs$1");function pn(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:f.RESOLVER.UNKNOWN_MODIFIER(n)})}s(pn,"validateNoModifiersCase");function dn(e,t,n,r){for(const[o,i]of Object.entries(e)){const a=t.get(o);if(!a){n.push({modifier:o,message:f.RESOLVER.UNKNOWN_MODIFIER(o)});continue}if(typeof i!="string"){n.push({modifier:o,message:f.RESOLVER.INVALID_INPUT_TYPE(o)});continue}if(!a.contexts.includes(i)){n.push({modifier:o,message:f.RESOLVER.INVALID_CONTEXT(i,o,a.contexts)});continue}r[o]=i}}s(dn,"validateProvidedInputs");function hn(e,t,n){for(const r of e)t[r.name]===void 0&&(r.default!==void 0?t[r.name]=r.default:n.push({modifier:r.name,message:f.RESOLVER.MISSING_REQUIRED_INPUT(r.name)}))}s(hn,"applyDefaults");async function Ge(e,t,n={}){const r=ln(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=we(e,t),i=mn();for(const a of e.resolutionOrder)await In(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(Ge,"processResolutionOrder");function mn(){return{tokens:{},sources:[],errors:[]}}s(mn,"createProcessingState");async function In(e,t,n,r,o){if(A(e)){await yn(e,t,n,r,o);return}if(ae(e)){await En(e,n,o);return}L(e)&&await gn(e,n,r,o)}s(In,"processItem");async function yn(e,t,n,r,o){const i=await Me(e.$ref,n);if(i.errors.length>0){o.errors.push(...i.errors);return}const a=e.$ref.split("/")[2];if(a){if(e.$ref.startsWith("#/sets/")){const c=await W(i.content.sources,n,{type:"set",name:a});G(c,o);return}if(e.$ref.startsWith("#/modifiers/")){const c=r[a];if(!c)return;const p=i.content.contexts[c];if(!p)return;const h=await W(p,n,{type:"modifier",name:a,context:c});G(h,o)}}}s(yn,"processReference");async function En(e,t,n){const r=await W(e.sources,t,{type:"set",name:e.name});G(r,n)}s(En,"processInlineSet");async function gn(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await W(i,t,{type:"modifier",name:e.name,context:o});G(a,r)}s(gn,"processInlineModifier");async function W(e,t,n){const r=await Pe(e,t);let o={};for(const i of r.resolved)o=U(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(W,"mergeSources");function G(e,t){t.errors.push(...e.errors),t.tokens=U(t.tokens,e.tokens),t.sources.push(e.source)}s(G,"applyResult");async function $n(e,t){const n=[],r=we(e,t),o=We(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await Ge(e,t,i);n.push(...a.errors);const c=a.tokens,u=[];for(const p of o){const h=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const y=await Nn(e,t,r,p.name,I,n);Object.keys(y).length>0&&h.set(I,y)}u.push({name:p.name,defaultContext:d,contexts:h})}return{base:c,modifiers:u,errors:n}}s($n,"processForLayeredCSS");async function Nn(e,t,n,r,o,i){const a=Sn(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const u=await Pe(c,n);i.push(...u.errors.map(y=>({path:y.path,message:y.message})));let p={};for(const y of u.resolved)p=U(p,y);const h=new Set;Be(p,"",h);const d=await Ge(e,t,{[r]:o});i.push(...d.errors);const I={};for(const y of h){const g=Tn(d.tokens,y);g!==void 0&&An(I,y,g)}return I}s(Nn,"processModifierContext");function Sn(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(L(n)&&n.name===t)return n}s(Sn,"findModifierDefinition");function Be(e,t,n){for(const[r,o]of Object.entries(e)){if(r.startsWith("$"))continue;const i=t?`${t}.${r}`:r;o&&typeof o=="object"&&"$value"in o?n.add(i):o&&typeof o=="object"&&Be(o,i,n)}}s(Be,"collectTokenPaths");function Tn(e,t){const n=t.split(".");let r=e;for(const o of n){if(r===null||typeof r!="object")return;r=r[o]}return r}s(Tn,"getTokenAtPath");function An(e,t,n){const r=t.split(".");let o=e;for(let a=0;a<r.length-1;a++){const c=r[a];c&&(c in o||(o[c]={}),o=o[c])}const i=r[r.length-1];i&&(o[i]=n)}s(An,"setTokenAtPath");async function Ye(e){const t=C(e)?e:R(process.cwd(),e),n=ee(t),r=[],o=[],i=V(process.cwd(),t),a=await Kt(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await $n(a.document,n);for(const p of c.errors)r.push({file:p.path,message:p.message});Object.keys(c.base).length>0&&o.push({context:void 0,tokens:c.base,sourcePath:i});const u=[];for(const p of c.modifiers){const h=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),h.push(d));u.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:h})}return{trees:o,modifiers:u,errors:r}}s(Ye,"loadFromResolver");async function bn(e){const t=[],n=[],r=Object.entries(e);r.sort(([,o],[,i])=>{const a=!o.context,c=!i.context;return a&&!c?-1:!a&&c?1:0});for(const[o,{context:i,content:a}]of r)try{const c=JSON.parse(a);t.push({context:i,tokens:c,sourcePath:V(process.cwd(),o)})}catch(c){c instanceof Error?c instanceof SyntaxError?n.push({file:o,message:f.LOAD.INVALID_JSON(o,c.message)}):n.push({file:o,message:c.message}):n.push({file:o,message:"Unknown error"})}return{trees:t,errors:n}}s(bn,"loadTreesFromMemory");function B(e,t,n,r){return typeof t=="string"&&m(t)?Rn(e,t,n,r):Array.isArray(t)?t.map(o=>B(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:B(`${e}.${a}`,c,n,r)}),{}):t}s(B,"resolveValue");function He(e,t){const n=e.slice(1,-1),r=t.pathIndex.get(n);if(!r)return;const o=t.tokens[r];if(!(!o||!("$value"in o))){if(o.$type)return o.$type;if(typeof o.$value=="string"&&m(o.$value))return He(o.$value,t)}}s(He,"inferTypeFromReference");function On(e){const t={},n=new Set,r=[];for(const[o,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[o]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&m(a.$value)&&(c=He(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:B(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),u=i,p=u.$path,h=u.$source;let d,I;c.includes("Circular reference detected")?(d="circular",I=c):c.includes("Reference not found")?(d="missing",I=c):(d="type-mismatch",I=f.RESOLVE.TYPE_MISMATCH(p)),r.push({type:d,path:p,source:h,message:I})}return{resolved:t,errors:r}}s(On,"resolve");function Rn(e,t,n,r){const o=t.slice(1,-1),i=n.pathIndex.get(o);if(!i)throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(o,e));if(r.has(i)){const u=n.tokens[i];throw!u||!("$path"in u)?new Error(f.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(f.RESOLVE.CIRCULAR_REFERENCE(e,u.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(f.RESOLVE.REFERENCE_NOT_FOUND(o,e));r.add(i);const c=B(i,a.$value,n,r);return r.delete(i),c}s(Rn,"resolveReferenceChain");function T(e){return{success:!0,value:e}}s(T,"success");function $(e){return{success:!1,error:e}}s($,"error");function ce(e){if(typeof e!="object"||e===null)return!1;const t=e;return!(typeof t.colorSpace!="string"||!["oklch","display-p3","srgb","hsl"].includes(t.colorSpace)||!Array.isArray(t.components)||t.components.length!==3||!t.components.every(r=>typeof r=="number"||r==="none")||t.alpha!==void 0&&typeof t.alpha!="number"||t.hex!==void 0&&typeof t.hex!="string")}s(ce,"isW3CColorValue");function Y(e){const t=[],n=["oklch","display-p3","srgb","hsl"];if(n.includes(e.colorSpace)||t.push(`Unsupported colorSpace: "${e.colorSpace}". Supported color spaces: ${n.join(", ")}.`),!Array.isArray(e.components)||e.components.length!==3)t.push("Components must be an array of exactly 3 numbers.");else if(e.components.forEach((r,o)=>{r!=="none"&&(typeof r!="number"||!Number.isFinite(r))&&t.push(`Component ${o} must be a finite number or "none".`)}),e.colorSpace==="oklch"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("OKLCH Lightness (L) must be between 0 and 1 or 'none'."),o!=="none"&&o<0&&t.push("OKLCH Chroma (C) must be >= 0 or 'none'."),i!=="none"&&(i<0||i>=360)&&t.push("OKLCH Hue (H) must be between 0 and 360 (exclusive) or 'none'.")}else if(e.colorSpace==="display-p3"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("Display P3 Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>1)&&t.push("Display P3 Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("Display P3 Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="srgb"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>1)&&t.push("sRGB Red component must be between 0 and 1 or 'none'."),o!=="none"&&(o<0||o>1)&&t.push("sRGB Green component must be between 0 and 1 or 'none'."),i!=="none"&&(i<0||i>1)&&t.push("sRGB Blue component must be between 0 and 1 or 'none'.")}else if(e.colorSpace==="hsl"){const[r,o,i]=e.components;r!=="none"&&(r<0||r>=360)&&t.push("HSL Hue must be between 0 and 360 (exclusive) or 'none'."),o!=="none"&&(o<0||o>100)&&t.push("HSL Saturation must be between 0 and 100 or 'none'."),i!=="none"&&(i<0||i>100)&&t.push("HSL Lightness must be between 0 and 100 or 'none'.")}return e.alpha!==void 0&&(typeof e.alpha!="number"||!Number.isFinite(e.alpha)?t.push("Alpha must be a finite number."):(e.alpha<0||e.alpha>1)&&t.push("Alpha must be between 0 and 1.")),t}s(Y,"validateW3CColorValue");function Ln(e){const t=Y(e);return t.length>0?$(t.join(", ")):T(e)}s(Ln,"validateW3CColorValueResult");function Dn(e){const t=Ln(e);if(!t.success)return t;const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4)),u=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`oklch(${a} ${c} ${u} / ${p})`)}return T(`oklch(${a} ${c} ${u})`)}s(Dn,"formatW3CColorToOKLCH");const _n={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function E(e,t,n,r){if(m(t))return[];switch(e.type){case"object":return xn(e,t,n,r);case"union":return Fn(e,t,n,r);case"array":return Cn(e,t,n,r);default:return vn(e,t,n,r)}}s(E,"validateSchema");function vn(e,t,n,r){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE(e.type,t,n),source:r}]:e.validate?.(t,n,r)??[]}s(vn,"validateSimpleValue");function xn(e,t,n,r){if(!_n.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("object",t,n),source:r}];const o=[],i=t;if(e.required)for(const a of e.required)a in i||o.push({path:`${n}.${a}`,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:r});for(const[a,c]of Object.entries(e.properties))a in i&&o.push(...E(c,i[a],`${n}.${a}`,r));return o}s(xn,"validateObject");function Fn(e,t,n,r){let o=[],i=Number.POSITIVE_INFINITY;for(const a of e.oneOf){if(a.type==="string"&&typeof t!="string"||a.type==="object"&&typeof t!="object")continue;const c=E(a,t,n,r);if(c.length===0)return a.validate?.(t,n,r)??[];c.length<i&&(o=c,i=c.length)}return i===Number.POSITIVE_INFINITY?[{path:n,message:f.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:r}]:o}s(Fn,"validateUnion");function Cn(e,t,n,r){return Array.isArray(t)?e.validate?.(t,n,r)??[]:[{path:n,message:e.errorMessage?.(t,n)||f.VALIDATE.INVALID_TYPE("array",t,n),source:r}]}s(Cn,"validateArray");const H={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/.test(e)?[]:[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")},{type:"object",required:["colorSpace","components"],properties:{colorSpace:{type:"string"},components:{type:"array"},alpha:{type:"number"},hex:{type:"string"}},validate:s((e,t,n)=>ce(e)?Y(e).map(o=>({path:t,message:`Invalid color at ${t}: ${o}`,source:n})):[{path:t,message:f.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Vn(e,t,n){return E(H.schema,e,t,n)}s(Vn,"validateColor");const K={schema:{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:f.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function kn(e,t,n){return E(K.schema,e,t,n)}s(kn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:K.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:f.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function wn(e,t,n){return E(N.schema,e,t,n)}s(wn,"validateDimension");const Ke={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function Mn(e,t,n){return E(Ke.schema,e,t,n)}s(Mn,"validateFontFamily");const jn=["thin","hairline","extra-light","ultra-light","light","normal","regular","book","medium","semi-bold","demi-bold","bold","extra-bold","ultra-bold","black","heavy","extra-black","ultra-black"],qe={schema:{type:"union",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>jn.includes(e.toLowerCase())?[]:[{path:t,message:f.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Pn(e,t,n){return E(qe.schema,e,t,n)}s(Pn,"validateFontWeight");const Un=["ms","s"],ue={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:K.schema,unit:{type:"string",validate:s((e,t,n)=>Un.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Wn(e,t,n){return E(ue.schema,e,t,n)}s(Wn,"validateDuration");const ze={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e;if(r.length!==4||!r.every(a=>typeof a=="number"))return[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:f.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Gn(e,t,n){return E(ze.schema,e,t,n)}s(Gn,"validateCubicBezier");const Bn={schema:{type:"object",properties:{fontFamily:Ke.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:K.schema,fontWeight:qe.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Yn(e,t,n){return E(Bn.schema,e,t,n)}s(Yn,"validateTypography");const Hn=["solid","dashed","dotted","double","groove","ridge","outset","inset"],Kn=["round","butt","square"],qn={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_STROKE_STYLE(e,t),"errorMessage"),properties:{dashArray:{type:"array",validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{typeof i!="string"&&o.push(...E(N.schema,i,`${t}.${a}`,n))}),o},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>Kn.includes(e)?[]:[{path:t,message:f.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Je={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Hn.includes(e)&&typeof e=="string"?[{path:t,message:f.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},qn]}};function zn(e,t,n){return E(Je.schema,e,t,n)}s(zn,"validateStrokeStyle");const Jn={schema:{type:"object",properties:{color:H.schema,width:N.schema,style:Je.schema},required:["color","width","style"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Xn(e,t,n){return E(Jn.schema,e,t,n)}s(Xn,"validateBorder");const Zn={schema:{type:"object",properties:{duration:ue.schema,delay:ue.schema,timingFunction:ze.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Qn(e,t,n){return E(Zn.schema,e,t,n)}s(Qn,"validateTransition");const Xe={schema:{type:"object",properties:{color:{type:"union",oneOf:[H.schema]},offsetX:N.schema,offsetY:N.schema,blur:N.schema,spread:N.schema,inset:{type:"boolean",errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>f.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function er(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...E(Xe.schema,o,`${t}[${i}]`,n))}),r):E(Xe.schema,e,t,n)}s(er,"validateShadow");const tr={type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:H.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:f.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},nr={schema:{type:"array",errorMessage:s((e,t)=>f.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{o.push(...E(tr,i,`${t}[${a}]`,n))}),o},"validate")}};function rr(e,t,n){return E(nr.schema,e,t,n)}s(rr,"validateGradient");const or={schema:{type:"object",errorMessage:s((e,t)=>f.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:N.schema,max:N.schema},required:["min","max"]}};function sr(e,t,n){return E(or.schema,e,t,n)}s(sr,"validateFluidDimension");const ir={color:Vn,dimension:wn,fluidDimension:sr,duration:Wn,cubicBezier:Gn,fontFamily:Mn,fontWeight:Pn,number:kn,strokeStyle:zn,typography:Yn,border:Xn,shadow:er,gradient:rr,transition:Qn};function ar(e){const t=[];for(const[n,r]of Object.entries(e.tokens)){if(typeof r!="object"||r===null||!("$type"in r)||!("$path"in r)||r.$path.startsWith("$"))continue;if(!("$value"in r)){t.push({path:r.$path,message:f.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",r.$path),source:r.$source});continue}const o=ir[r.$type];if(!o){t.push({path:r.$path,message:f.VALIDATE.UNKNOWN_TOKEN_TYPE(r.$type,r.$path),source:r.$source});continue}const i=r;t.push(...o(i.$value,i.$path,i.$source))}return t}s(ar,"validate");async function cr(e){const{trees:t,modifiers:n,errors:r}=await ur(e),{tokens:o,errors:i}=Ht(t),a=ar(o),{resolved:c,errors:u}=On(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:u}}}s(cr,"loadAndResolveTokens");async function ur(e){switch(e.type){case"memory":{const t=await bn(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await Ye(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(ur,"loadTokens");function Ze(e){return m(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>m(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Ze,"convertStrokeStyleToken");function fr(e){if(m(e))return{value:e};const t=m(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(m(e.color),e.color),r=typeof e.style=="string"?e.style:Ze(e.style).value;return{value:`${t} ${r} ${n}`}}s(fr,"convertBorderToken");function Qe(e,t="native"){return ce(e)?lr(e):T(e)}s(Qe,"convertColorToString");function lr(e){switch(e.colorSpace){case"oklch":return Dn(e);case"display-p3":return pr(e);case"srgb":return dr(e);case"hsl":return hr(e);default:return $(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(lr,"formatW3CColorNative");function pr(e){if(e.colorSpace!=="display-p3")return $(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return $("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,r]=e.components,o=e.alpha;if(t!=="none"&&(t<0||t>1))return $("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return $("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return $("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return $("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4));if(o!==void 0&&o!==1){const u=Number(o.toFixed(4));return T(`color(display-p3 ${i} ${a} ${c} / ${u})`)}return T(`color(display-p3 ${i} ${a} ${c})`)}s(pr,"formatW3CColorToP3");function dr(e){if(e.colorSpace!=="srgb")return $(`Expected srgb color space, got: ${e.colorSpace}`);const t=Y(e);if(t.length>0)return $(`Invalid W3C color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Math.round(n*255),c=r==="none"?"none":Math.round(r*255),u=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`rgb(${a} ${c} ${u} / ${p})`)}return T(`rgb(${a} ${c} ${u})`)}s(dr,"formatW3CColorToRGB");function hr(e){if(e.colorSpace!=="hsl")return $(`Expected hsl color space, got: ${e.colorSpace}`);const t=Y(e);if(t.length>0)return $(`Invalid W3C color value: ${t.join(", ")}`);const[n,r,o]=e.components,i=e.alpha,a=n==="none"?"none":Number(n.toFixed(1)),c=r==="none"?"none":Math.round(r),u=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,y=u==="none"?"none":`${u}%`;return T(`hsl(${a} ${I} ${y} / ${d})`)}const p=c==="none"?"none":`${c}%`,h=u==="none"?"none":`${u}%`;return T(`hsl(${a} ${p} ${h})`)}s(hr,"formatW3CColorToHSL");function mr(e,t){if(typeof e=="string"&&m(e))return{value:e};const n=t.colorFallbackStrategy;if(ce(e))return Ir(e,n);const r=Qe(e,n);return r.success?{value:r.value}:(console.warn(`Failed to convert color ${typeof e=="string"?e:"W3C color object"}: ${r.error}`),{value:typeof e=="string"?e:"#000000"})}s(mr,"convertColorToken");function Ir(e,t){const n=Qe(e,t);if(!n.success)return console.warn(`Failed to convert W3C color: ${n.error}`),{value:"#000000"};const r=n.value;if(t==="native")return{value:r};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:r};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:yr(e.colorSpace),value:r}]}}s(Ir,"convertW3CColorToken");function yr(e){switch(e){case"oklch":return"@supports (color: oklch(0 0 0))";case"display-p3":return"@supports (color: color(display-p3 1 1 1))";default:throw new Error(`No feature query defined for color space: ${e}`)}}s(yr,"getFeatureQuery");function Er(e){return m(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(Er,"convertCubicBezierToken");function gr(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(gr,"convertDimensionToken");function $r(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s($r,"convertDurationToken");function et(e,t=16){return e.unit==="px"?e.value:e.value*t}s(et,"normalizeToPixels");function Nr(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=et(n,i),c=et(r,i),u=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const h=a/i,d=c/i,I=u/i,y=p/i,g=(d-h)/(y-I),me=-1*I*g+h;return{value:`clamp(${h}rem, ${me.toFixed(2)}rem + ${(g*100).toFixed(2)}vw, ${d}rem)`}}s(Nr,"convertFluidDimension");function Sr(e,t){return m(e)?{value:e}:Nr(e,t)}s(Sr,"convertFluidDimensionToken");function q(e){return["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"].includes(e.toLowerCase())?e:/[\s'"!@#$%^&*()=+[\]{};:|\\/,.<>?~]/.test(e)?`"${e}"`:e}s(q,"quoteFont");function Tr(e){return m(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>q(n)).join(", "):q(e)}}s(Tr,"convertFontFamilyToken");const Ar={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 tt(e){return m(e)?{value:e}:typeof e=="number"?{value:e}:{value:Ar[e.toLowerCase()]??e}}s(tt,"convertFontWeightToken");function br(e){return m(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const r=(m(n.color),n.color),o=m(n.position)?n.position:`${n.position*100}`;return`${r} ${o}%`}).join(", ")})`}}s(br,"convertGradientToken");function Or(e){return m(e)?{value:e}:{value:e}}s(Or,"convertNumberToken");function nt(e){const t=m(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=m(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,r=m(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,o=m(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(m(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${r} ${o} ${i}`}s(nt,"convertSingleShadow");function Rr(e){return m(e)?{value:e}:Array.isArray(e)?{value:e.map(nt).join(", ")}:{value:nt(e)}}s(Rr,"convertShadowToken");function rt(e){return e?`${e.value}${e.unit}`:"0ms"}s(rt,"formatDuration");function Lr(e){if(m(e))return{value:e};const t=m(e.duration)?e.duration:rt(e.duration),n=m(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(m(e.delay)?e.delay:rt(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(Lr,"convertTransitionToken");function Dr(e){if(m(e))return{"font-family":e,"font-size":e};const t={"font-family":m(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>q(n)).join(", "):q(e.fontFamily),"font-size":m(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=m(e.fontWeight)?e.fontWeight:tt(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=m(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(m(e.lineHeight),e.lineHeight)),t}s(Dr,"convertTypographyToken");const ot={duration:$r,number:Or,cubicBezier:Er,color:mr,dimension:gr,fluidDimension:Sr,typography:Dr,border:fr,shadow:Rr,gradient:br,transition:Lr,strokeStyle:Ze,fontFamily:Tr,fontWeight:tt};function _r(e,t){const n=ot[e.$type];return{...e.$description?{$description:e.$description}:{},...e.$extensions?{$extensions:e.$extensions}:{},$type:e.$type,$value:e.$value,$path:e.$path,$source:e.$source,$originalPath:e.$originalPath,$resolvedValue:e.$resolvedValue,$cssProperties:n(e.$value,t)}}s(_r,"convertSingleToken");function vr(e,t,n){const r={};for(const[o,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){r[o]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)){console.warn(`[sugarcube] Skipping invalid token: ${i.$path} (has validation error)`);continue}if(!ot[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=_r(i,a)}return r}s(vr,"convertTokens");function xr(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=vr(i,t,n);return r}s(xr,"convert");function Fr(e,t){const n={},r=new Set;for(const o of e){const i=o.context??"default";r.add(i)}for(const o of r)n[o]={};for(const o of e){const{context:i,tokens:a}=o,c=i??"default";n[c]||(n[c]={});for(const[u,p]of Object.entries(a))n[c][u]=p}return{tokens:n,defaultContext:t}}s(Fr,"normalizeTokens");function Cr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const u=c.context??"";n.has(u)||n.set(u,{});const p=n.get(u);p&&(p[r]=o)}continue}const i=o.$source.context??"";n.has(i)||n.set(i,{});const a=n.get(i);a&&(a[r]=o)}return e.map(r=>{const o=r.context??"",i=n.get(o)||{};return{context:r.context,tokens:i}})}s(Cr,"processTrees");async function Vr(e,t,n,r){const o=Cr(e,t),{tokens:i}=Fr(o);return xr(i,n,r?u=>r.some(p=>p.path===u||p.path.startsWith(`${u}.`)):void 0)}s(Vr,"processAndConvertTokens");const kr=`/*!
|
|
18
16
|
* This file was automatically generated by sugarcube.
|
|
19
17
|
* You should NOT make any changes in this file as it will be overwritten.
|
|
20
18
|
* To make changes, edit your design token files instead.
|
|
@@ -22,7 +20,7 @@ ${t.map(n=>` - ${n}`).join(`
|
|
|
22
20
|
* to prevent it from being checked or modified.
|
|
23
21
|
*/
|
|
24
22
|
|
|
25
|
-
`,
|
|
23
|
+
`,wr=`/*!
|
|
26
24
|
* This file was automatically generated by sugarcube.
|
|
27
25
|
* You should NOT make any changes in this file as it will be overwritten.
|
|
28
26
|
* To make changes, edit your utilities configuration instead.
|
|
@@ -30,14 +28,16 @@ ${t.map(n=>` - ${n}`).join(`
|
|
|
30
28
|
* to prevent it from being checked or modified.
|
|
31
29
|
*/
|
|
32
30
|
|
|
33
|
-
`;function
|
|
31
|
+
`;function z(e){return e.replace(/\r\n/g,`
|
|
34
32
|
`).replace(/\r/g,`
|
|
35
|
-
`).trim()}s(
|
|
36
|
-
`))}return t.data}s(
|
|
37
|
-
`))}return t.data}s(
|
|
38
|
-
`
|
|
33
|
+
`).trim()}s(z,"normalizeContent");function Mr(e){return kr+e}s(Mr,"addWarningBanner");async function jr(e){for(const t of e){const n=Mr(t.css);try{await ye(ee(t.path),{recursive:!0});let r=!0;if(te(t.path))try{const o=await k(t.path,"utf-8");z(o)===z(n)&&(r=!1)}catch{}r&&await Ee(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(jr,"writeCSSVariablesToDisk");async function Pr(e){for(const t of e){const n=wr+t.css;try{await ye(ee(t.path),{recursive:!0});let r=!0;if(te(t.path))try{const o=await k(t.path,"utf-8");z(o)===z(n)&&(r=!1)}catch{}r&&await Ee(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write utility CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Pr,"writeCSSUtilitiesToDisk");const b={output:{css:"src/styles",components:"src/components/ui",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},Ur="default",Wr="default";function fe(e){const t={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??b.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??b.transforms.colorFallbackStrategy},output:{css:e.output?.css??b.output.css,themeAttribute:e.output?.themeAttribute??b.output.themeAttribute,defaultContext:e.output?.defaultContext}};return(e.output?.components!==void 0||b.output.components!==void 0)&&(t.output.components=e.output?.components??b.output.components),e.utilities&&(t.utilities=e.utilities),t}s(fe,"fillDefaults");const st=l.object({min:l.number(),max:l.number()}),it=l.object({source:l.string(),directions:l.union([l.enum(["top","right","bottom","left","x","y","full","all"]),l.array(l.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:l.string().optional(),stripDuplicates:l.boolean().optional()}),at=l.union([it,l.array(it)]),ct=l.object({resolver:l.string().optional(),transforms:l.object({fluid:st.optional(),colorFallbackStrategy:l.enum(["native","polyfill"]).optional()}).optional(),output:l.object({css:l.string().optional(),components:l.string().optional(),themeAttribute:l.string().optional(),defaultContext:l.string().optional()}).optional(),utilities:l.record(l.string(),at).optional()}),ut=l.object({resolver:l.string().optional(),transforms:l.object({fluid:st,colorFallbackStrategy:l.enum(["native","polyfill"])}),output:l.object({css:l.string(),components:l.string().optional(),themeAttribute:l.string(),defaultContext:l.string().optional()}),utilities:l.record(l.string(),at).optional()});function J(e){const t=ct.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return f.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
|
|
34
|
+
`))}return t.data}s(J,"validateSugarcubeConfig");function le(e){const t=ut.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return f.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
|
|
35
|
+
`))}return t.data}s(le,"validateInternalConfig");function ft(e){const t=J(e),n=fe(t);return le(n)}s(ft,"validateConfig");function Gr(e){try{const t=JSON.parse(e);return ft(t)}catch(t){throw t instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(t.message)):t}}s(Gr,"parseAndValidateConfig");function pe(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=R(n,`${e}${r}`);if(te(o))return o}return null}s(pe,"findConfigFile");function Br(e="sugarcube.config"){return pe(e)!==null}s(Br,"configFileExists");async function lt(e){try{typeof globalThis.Bun<"u"||await import("tsx");const n=St(e).href,o=await new Function("url","return import(url)")(n);if(o&&typeof o=="object"&&"default"in o)return o.default;throw new Error(f.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}catch(t){throw t instanceof Error?new Error(f.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(lt,"loadTSConfig");async function pt(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await lt(e);const n=await Nt.readFile(e,"utf-8");return JSON.parse(n)}s(pt,"loadConfigFile");function dt(e){if(e)return R(process.cwd(),e);const t=pe();if(!t)throw new Error(f.CONFIG.FILE_NOT_FOUND(w));return t}s(dt,"resolveConfigPath");async function Yr(e){const t=dt(e);try{const n=await pt(t);return{config:J(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Yr,"loadSugarcubeConfig");async function Hr(e){const t=dt(e);try{const n=await pt(t),r=J(n),o=fe(r);return{config:le(o),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(f.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(f.CONFIG.INVALID_JSON(n.message)):n}}s(Hr,"loadInternalConfig");const ht=["reset","global","compositions","blocks","utilities"];async function Kr(e,t){const n=[],r=await Tt([_(e,"**/*.css"),_(e,"**/*.scss"),_(e,"**/*.sass"),_(e,"**/*.less")],{ignore:[_(e,ge)]});for(const o of r){const i=qr(o,e);if(i){const a=V(e,o);n.push({path:a,layer:i,relativePath:a})}}return n}s(Kr,"discoverAllFiles");function qr(e,t){const n=V(t,e);if(n.includes("global/")||n.startsWith("global/"))return $t(e).includes("reset")?"reset":"global";if(n.includes("compositions/")||n.startsWith("compositions/"))return"compositions";if(n.includes("blocks/")||n.startsWith("blocks/"))return"blocks";if(n.includes("utilities/")||n.startsWith("utilities/"))return"utilities"}s(qr,"categorizeFile");function zr(){return`@layer ${ht.join(", ")};
|
|
36
|
+
`}s(zr,"getLayerDefinitions");function Jr(e){const t=[];t.push(zr());const n=e.reduce((r,o)=>{const i=r[o.layer]??[];return r[o.layer]=[...i,o],r},{});for(const r of ht){const o=n[r];if(!(!o||o.length===0))for(const i of o)t.push(`@import "${i.path}" layer(${i.layer});`)}return t.join(`
|
|
37
|
+
`)}s(Jr,"generateIndexContent");class mt extends Map{static{s(this,"DefaultMap")}constructor(t){super(),this.factory=t}get(t){let n=super.get(t);return n===void 0&&(n=this.factory(t,this),this.set(t,n)),n}}const Xr=process.env.DEBUG==="true";class Zr{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
|
|
38
|
+
`)){this.defaultFlush=t}#n=new mt(()=>({value:0}));#t=new mt(()=>({value:0n}));#e=[];hit(t){this.#n.get(t).value++}start(t){const n=this.#e.map(o=>o.label).join("//"),r=`${n}${n.length===0?"":"//"}${t}`;this.#n.get(r).value++,this.#t.get(r),this.#e.push({id:r,label:t,namespace:n,value:process.hrtime.bigint()})}end(t){const n=process.hrtime.bigint();if(this.#e.length===0)throw new Error("Timer stack is empty");const r=this.#e.length-1,o=this.#e[r];if(!o)throw new Error("Timer stack is corrupted");if(o.label!==t)throw new Error(`Mismatched timer label: ${t}`);const i=this.#e.pop();if(!i)throw new Error("Timer stack is empty");const a=n-i.value;this.#t.get(i.id).value+=a}report(t=this.defaultFlush){const n=[];let r=!1;for(let o=this.#e.length-1;o>=0;o--){const i=this.#e[o];i&&this.end(i.label)}for(const[o,{value:i}]of this.#n.entries()){if(this.#t.has(o))continue;n.length===0&&(r=!0,n.push("Hits:"));const a=o.split("//").length;n.push(`${" ".repeat(a)}${o} \xD7 ${i}`)}if(this.#t.size>0){r&&n.push(`
|
|
39
39
|
Timers:`);for(const[o,{value:i}]of this.#t){const a=o.split("//").length,c=`${(Number(i)/1e6).toFixed(2)}ms`;n.push(`${" ".repeat(a-1)}${o.split("//").pop()} [${c}] ${this.#n.get(o).value===1?"":`\xD7 ${this.#n.get(o).value}`}`.trimEnd())}}t(`
|
|
40
40
|
${n.join(`
|
|
41
41
|
`)}
|
|
42
|
-
`)}[Symbol.dispose](){
|
|
43
|
-
`)){this.defaultFlush=t}#n=0;#t=0;#e=Date.now();#r=null;#o=0;#s(){return Math.round(process.memoryUsage().heapUsed/1024/1024)}#i(){return new Date().toISOString().split("T")[1]?.slice(0,-1)??""}log(t,n){if(!
|
|
42
|
+
`)}[Symbol.dispose](){Xr&&this.report()}}const x=process.env.SUGARCUBE_PERF==="1";class Qr{static{s(this,"PerfMonitor")}constructor(t=n=>void process.stderr.write(`${n}
|
|
43
|
+
`)){this.defaultFlush=t}#n=0;#t=0;#e=Date.now();#r=null;#o=0;#s(){return Math.round(process.memoryUsage().heapUsed/1024/1024)}#i(){return new Date().toISOString().split("T")[1]?.slice(0,-1)??""}log(t,n){if(!x)return;const r=this.#i(),o=this.#s(),i=o-this.#n;this.#n=o,this.defaultFlush(`[perf ${r}] ${t} ${n?JSON.stringify(n):""} | heap: ${o}MB (${i>=0?"+":""}${i}MB)`)}trackWatcherEvent(t,n){if(!x)return;this.#t++;const r=Date.now(),o=t.split("/").slice(-3).join("/");this.log(`WATCHER EVENT #${this.#t}: ${o}`),r-this.#e>1e4&&(this.log("WATCHER STATS (last 10s)",{events:this.#t,moduleGraphSize:n}),this.#t=0,this.#e=r)}logWatcherSetup(t,n){x&&this.log("WATCHER SETUP: Adding watch pattern",{pattern:t,dir:n})}logModuleGraphStats(t,n,r){x&&this.log(`MODULE GRAPH (${r})`,{modules:t,urls:n})}startMemoryMonitor(){!x||this.#r||(this.log("PERF MONITORING ENABLED - Starting memory monitor"),this.#o=this.#s(),this.#r=setInterval(()=>{const t=this.#s(),n=t-this.#o;Math.abs(n)>5&&(this.log("MEMORY CHANGE",{from:this.#o,to:t,delta:n}),this.#o=t)},5e3))}stopMemoryMonitor(){this.#r&&(clearInterval(this.#r),this.#r=null)}[Symbol.dispose](){this.stopMemoryMonitor()}}const F="--",O="-",eo=["all","full"],to={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},no={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function ro(e){return to[e]}s(ro,"getDirectionAbbreviation");function It(e,t){if(t==="full"||t==="all")return e;const n=no[t];return n?`${e}${O}${n}`:e}s(It,"getLogicalProperty");const oo=["top","right","bottom","left","x","y","full"];function so(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?oo:[n])}s(so,"expandDirections");function io(e,t){const r={color:["color"],"background-color":["color"],"border-color":["color"],"font-size":["dimension","fluidDimension"],"font-weight":["fontWeight"],"line-height":["number"],"border-radius":["dimension","fluidDimension"],"border-width":["dimension","fluidDimension"],padding:["dimension","fluidDimension"],margin:["dimension","fluidDimension"],width:["dimension","fluidDimension"],height:["dimension","fluidDimension"],gap:["dimension","fluidDimension"],"font-family":["fontFamily"],"transition-duration":["duration"],"transition-timing-function":["cubicBezier"],"border-style":["strokeStyle"],"box-shadow":["shadow"],"text-shadow":["shadow"],"background-image":["gradient"],opacity:["number"]}[t];return r?r.includes(e):!0}s(io,"isTokenTypeValidForProperty");const yt=new WeakMap,D=new Map;function ao(){D.clear()}s(ao,"clearMatchCache");function co(e){const t=yt.get(e);if(t)return t;const n=new Map;for(const r of Object.values(e)){if(!("$path"in r))continue;const o=r;n.set(o.$path,o)}return yt.set(e,n),n}s(co,"buildPathIndex");function uo(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(uo,"getDefaultContextTokens");function X(e,t,n){const r=`${t.source}:${t.prefix??""}:${t.property??""}:${e}`;if(D.has(r))return D.get(r)??null;const o=[t.source.replace("*",e),t.source.replace("*",e.split("-").join("."))];if(t.stripDuplicates&&t.prefix){const c=t.source.lastIndexOf(".*");if(c!==-1){const u=t.source.slice(0,c);u&&o.push(`${u}.${t.prefix}.${e}`,`${u}.${t.prefix}.${e.split("-").join(".")}`)}}const i=uo(n);if(!i)return D.set(r,null),null;const a=co(i);for(const c of o){const u=a.get(c);if(u){if(t.property&&u.$type&&!io(u.$type,t.property))continue;const p=u.$path.split(".");return D.set(r,p),p}}return D.set(r,null),null}s(X,"findMatchingToken");function de(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(de,"stripDuplicatePrefix");function Z(e,t=""){const n=e??"",r=n||t?O:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(Z,"createUtilityPattern");function he(e,t,n){return[Z(t.prefix),o=>{const i=o[1];if(!i)return{};const a=de(i,t),c={...t,property:e},u=X(a,c,n);return u?{[e]:`var(${F}${u.join(O)})`}:{}}]}s(he,"createSimpleRule");function fo(e,t,n,r){if(n==="all")return he(e,t,r);const o=ro(n);return[Z(t.prefix,o),a=>{const c=a[1];if(!c)return{};const u=de(c,t),p={...t,property:e},h=X(u,p,r);return h?{[It(e,n)]:`var(${F}${h.join(O)})`}:{}}]}s(fo,"createDirectionalRule");function lo(e,t){return[Z(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:u}of t){const p=de(o,a),h={...a,property:i},d=X(p,h,u);if(d)return c?{[It(i,c)]:`var(${F}${d.join(O)})`}:{[i]:`var(${F}${d.join(O)})`}}return{}}]}s(lo,"createSmartRule");function po(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[Z(o),a=>{const c=a[1];if(!c)return{};const u={...t,property:e},p=X(c,u,n);return p?{[e]:`var(${F}${p.join(O)})`}:{}}]}s(po,"createDirectTokenPathRule");function ho(e,t){if(!e?.source||typeof e.source!="string")throw new Error(f.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(f.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(f.UTILITIES.INVALID_DIRECTIONS(t))}s(ho,"validateUtilityConfig");function mo(e,t){if(!e||typeof e!="object")throw new Error(f.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(f.UTILITIES.INVALID_TOKENS_OBJECT)}s(mo,"validateInputs");function Io(e,t){mo(e,t);const n=[],r={};for(const[o,i]of Object.entries(e)){const a=Array.isArray(i)?i:[i];for(const c of a)if(ho(c,o),c.prefix){const u=c.prefix;r[u]||(r[u]=[]),r[u].push({property:o,config:c,direction:null,tokens:t})}else{const u=po(o,c,t);n.push(u)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:u,tokens:p}=a;if(u.directions){const h=so(u.directions);(Array.isArray(u.directions)?u.directions:[u.directions]).includes("all")&&n.push(he(c,u,p));for(const y of h)eo.includes(y)||n.push(fo(c,u,y,p))}else n.push(he(c,u,p))}else n.push(lo(o,i));return n}s(Io,"convertConfigToUnoRules");export{Ur as DEFAULT_COLLECTION,b as DEFAULT_CONFIG,Wr as DEFAULT_CONTEXT,Rt as DEFAULT_DESIGN_TOKENS_PATH,Ot as DEFAULT_STYLES_PATH,bt as DEFAULT_UTILITIES_FILENAME,Se as DEFAULT_VARIABLES_FILENAME,f as ErrorMessages,$e as GLOBAL_DIR,Zr as Instrumentation,Qr as PerfMonitor,w as SUGARCUBE_CONFIG_FILE,ge as SUGARCUBE_FILE,At as UTILITIES_DIR,Ne as VARIABLES_FILE_SUFFIX,ao as clearMatchCache,Br as configFileExists,Io as convertConfigToUnoRules,Kr as discoverAllFiles,fe as fillDefaults,pe as findConfigFile,Wt as generateCSSVariables,Jr as generateIndexContent,_e as inlineModifierSchema,De as inlineSetSchema,ut as internalConfigSchema,L as isInlineModifier,ae as isInlineSet,A as isReference,Te as isResolvedToken,_t as isResolvedTokenOfType,cr as loadAndResolveTokens,Ye as loadFromResolver,Hr as loadInternalConfig,Yr as loadSugarcubeConfig,lt as loadTSConfig,ie as modifierContextsSchema,Le as modifierDefinitionSchema,Fe as modifiersMapSchema,v as nameSchema,Gr as parseAndValidateConfig,Vr as processAndConvertTokens,se as referenceObjectSchema,ve as resolutionOrderItemSchema,Ce as resolverDocumentSchema,Re as setDefinitionSchema,xe as setsMapSchema,M as sourceSchema,ct as userConfigSchema,ft as validateConfig,le as validateInternalConfig,J as validateSugarcubeConfig,Pr as writeCSSUtilitiesToDisk,jr as writeCSSVariablesToDisk};
|