@sugarcube-sh/core 0.1.2 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +11 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var tt=Object.defineProperty;var s=(e,t)=>tt(e,"name",{value:t,configurable:!0});import{existsSync as Z}from"node:fs";import nt,{readFile as Q,mkdir as he,writeFile as Ie}from"node:fs/promises";import{pathToFileURL as rt}from"node:url";import{relative as F,resolve as T,isAbsolute as D,dirname as C}from"pathe";import{glob as ot}from"tinyglobby";import{resolve as Ee}from"node:path";import{z as f}from"zod";function st(e){return e}s(st,"defineConfig");const A={output:{cssRoot:"src/styles",variablesFilename:"tokens.variables.gen.css",utilitiesFilename:"utilities.gen.css",components:"src/components/ui",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},u={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 DTCG 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"),INVALID_CSS_VALUE_TYPE:s(e=>`CSS value must be a string or number, but received ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"INVALID_CSS_VALUE_TYPE")},CONVERT:{COLOR_CONVERSION_FAILED:s(e=>`Failed to convert color: ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"COLOR_CONVERSION_FAILED")},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}":
1
+ var nt=Object.defineProperty;var s=(e,t)=>nt(e,"name",{value:t,configurable:!0});import{existsSync as Q}from"node:fs";import rt,{readFile as ee,mkdir as he,writeFile as Ie}from"node:fs/promises";import{pathToFileURL as ot}from"node:url";import{relative as V,resolve as O,isAbsolute as D,dirname as w}from"pathe";import{glob as st}from"tinyglobby";import{resolve as Ee}from"node:path";import{z as f}from"zod";function it(e){return e}s(it,"defineConfig");const A={output:{cssRoot:"src/styles",variablesFilename:"tokens.variables.gen.css",utilitiesFilename:"utilities.gen.css",components:"src/components/ui",themeAttribute:"data-theme"},transforms:{fluid:{min:320,max:1200},colorFallbackStrategy:"native"}},u={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 DTCG 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"),INVALID_CSS_VALUE_TYPE:s(e=>`CSS value must be a string or number, but received ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"INVALID_CSS_VALUE_TYPE")},CONVERT:{COLOR_CONVERSION_FAILED:s(e=>`Failed to convert color: ${e}. This is a bug in sugarcube. Please report it at https://github.com/sugarcube-sh/sugarcube/issues`,"COLOR_CONVERSION_FAILED")},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}":
2
2
  ${t.map(n=>` - ${n}`).join(`
3
3
  `)}`,"DUPLICATE_FILENAMES"),FILE_NOT_FOUND:s(e=>e==="sugarcube.config.ts"?"Cannot find sugarcube config file. Please ensure you have a valid sugarcube.config.ts file in your project root.":`Cannot find sugarcube config file at "${e}". Please check the path and file permissions.`,"FILE_NOT_FOUND"),MULTIPLE_RESOLVERS_FOUND:s(e=>`Multiple resolver files found:
4
4
  ${e.map(t=>` - ${t}`).join(`
@@ -9,24 +9,24 @@ Please specify which one to use:
9
9
  2. Use --resolver flag (generate command only)`,"MULTIPLE_RESOLVERS_FOUND"),NO_CONFIG_OR_RESOLVER:s(()=>`No configuration found. Either:
10
10
  1. Run: npx @sugarcube-sh/cli init
11
11
  2. Create a .resolver.json file
12
- 3. Create a sugarcube.config.ts file`,"NO_CONFIG_OR_RESOLVER")},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")}};async function ee(e){const n=await ot(["**/*.resolver.json"],{cwd:e,onlyFiles:!0,absolute:!0,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/out/**","**/.git/**","**/.next/**","**/.nuxt/**","**/.astro/**","**/.cache/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**"]});if(n.length===0)return{found:"none"};const[r]=n;return n.length===1&&r?{found:"one",path:F(process.cwd(),r)}:{found:"multiple",paths:n.map(o=>F(process.cwd(),o))}}s(ee,"findResolverDocument");function it(e){return Z(Ee(e,"src"))?"src/styles":"styles"}s(it,"getDefaultCssRoot");function at(e){return Z(Ee(e,"src"))?"src/components/ui":"components/ui"}s(at,"getDefaultComponentsDir");function V(e,t=process.cwd()){const n=e.output?.cssRoot??it(t),r={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??A.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??A.transforms.colorFallbackStrategy},output:{cssRoot:n,variables:e.output?.variables??`${n}/global`,variablesFilename:e.output?.variablesFilename??A.output.variablesFilename,utilities:e.output?.utilities??`${n}/utilities`,utilitiesFilename:e.output?.utilitiesFilename??A.output.utilitiesFilename,cube:e.output?.cube??n,themeAttribute:e.output?.themeAttribute??A.output.themeAttribute,defaultContext:e.output?.defaultContext,layers:e.output?.layers}};return(e.output?.components!==void 0||A.output.components!==void 0)&&(r.output.components=e.output?.components??at(t)),e.utilities&&(r.utilities=e.utilities),r}s(V,"fillDefaults");const ye=f.object({min:f.number(),max:f.number()}),$e=f.object({source:f.string(),directions:f.union([f.enum(["top","right","bottom","left","x","y","full","all"]),f.array(f.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:f.string().optional(),stripDuplicates:f.boolean().optional()}),ge=f.union([$e,f.array($e)]),Ne=f.object({variables:f.string(),utilities:f.string()}),ct=f.object({resolver:f.string().optional(),transforms:f.object({fluid:ye.optional(),colorFallbackStrategy:f.enum(["native","polyfill"]).optional()}).optional(),output:f.object({cssRoot:f.string().optional(),variables:f.string().optional(),variablesFilename:f.string().optional(),utilities:f.string().optional(),utilitiesFilename:f.string().optional(),cube:f.string().optional(),components:f.string().optional(),themeAttribute:f.string().optional(),defaultContext:f.string().optional(),layers:Ne.optional()}).optional(),utilities:f.record(f.string(),ge).optional()}),ut=f.object({resolver:f.string().optional(),transforms:f.object({fluid:ye,colorFallbackStrategy:f.enum(["native","polyfill"])}),output:f.object({cssRoot:f.string(),variables:f.string().optional(),variablesFilename:f.string(),utilities:f.string().optional(),utilitiesFilename:f.string(),cube:f.string().optional(),components:f.string().optional(),themeAttribute:f.string(),defaultContext:f.string().optional(),layers:Ne.optional()}),utilities:f.record(f.string(),ge).optional()});function te(e){const t=ct.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
13
- `))}return t.data}s(te,"validateSugarcubeConfig");function ne(e){const t=ut.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
14
- `))}return t.data}s(ne,"validateInternalConfig");function ft(e){const t=te(e),n=V(t);return ne(n)}s(ft,"validateConfig");function lt(e){return e instanceof Error&&e.message===u.CONFIG.NO_CONFIG_OR_RESOLVER()}s(lt,"isNoConfigError");function re(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=T(n,`${e}${r}`);if(Z(o))return o}return null}s(re,"findConfigFile");function pt(e="sugarcube.config"){return re(e)!==null}s(pt,"configFileExists");async function dt(e){try{if(typeof globalThis.Bun<"u"){const i=rt(e).href,c=await new Function("url","return import(url)")(i);if(c&&typeof c=="object"&&"default"in c)return c.default;throw new Error(u.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}const{createJiti:n}=await import("jiti"),o=await n(import.meta.url,{interopDefault:!0}).import(e);return o&&typeof o=="object"&&"default"in o?o.default:o}catch(t){throw t instanceof Error?new Error(u.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(dt,"loadTSConfig");async function be(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await dt(e);const n=await nt.readFile(e,"utf-8");return JSON.parse(n)}s(be,"loadConfigFile");function mt(e){if(e)return T(process.cwd(),e);const t=re();if(!t)throw new Error(u.CONFIG.FILE_NOT_FOUND("sugarcube.config.ts"));return t}s(mt,"resolveConfigPath");async function ht(e){const t=mt(e);try{const n=await be(t);return{config:te(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(n.message)):n}}s(ht,"loadSugarcubeConfig");async function It(e){const t=e?T(process.cwd(),e):re();if(t)try{const r=await be(t),o=te(r);if(!o.resolver){const c=await ee(process.cwd());if(c.found==="one")o.resolver=c.path;else{if(c.found==="multiple")throw new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(c.paths));if(c.found==="none")throw new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}}const i=V(o);return{config:ne(i),configPath:t}}catch(r){throw r instanceof Error&&"code"in r&&r.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):r instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(r.message)):r}const n=await ee(process.cwd());if(n.found==="one"){const r={resolver:n.path},o=V(r);return{config:ne(o),configPath:n.path}}throw n.found==="multiple"?new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(n.paths)):new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}s(It,"loadInternalConfig");function O(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(O,"isReference$1");function oe(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(oe,"isInlineSet");function _(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(_,"isInlineModifier");async function Et(e){const t=D(e)?e:T(process.cwd(),e),n=C(t),r=await Q(t,"utf-8"),o=JSON.parse(r),i=new Set;for(const a of o.resolutionOrder)if(O(a))Se(a.$ref,n,i);else if(oe(a))w(a.sources,n,i);else if(_(a))for(const c of Object.values(a.contexts))w(c,n,i);if(o.sets)for(const a of Object.values(o.sets))w(a.sources,n,i);if(o.modifiers)for(const a of Object.values(o.modifiers))for(const c of Object.values(a.contexts))w(c,n,i);return{filePaths:[...i],resolverPath:t}}s(Et,"extractFileRefs");function w(e,t,n){for(const r of e)O(r)&&Se(r.$ref,t,n)}s(w,"extractFromSources");function Se(e,t,n){if(e.startsWith("#/"))return;const r=e.split("#")[0];if(!r)return;const o=D(r)?r:T(t,r);n.add(o)}s(Se,"addFileRef");function h(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(h,"isReference");function yt(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(yt,"isCompositeToken");function $t(e){return e.$type==="typography"}s($t,"isTypographyToken");function se(e){return typeof e=="object"&&e!==null&&"$value"in e}s(se,"isTokenNode");function gt(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!se(o)){if(i&&se(i)){const d=i;n.push({path:d.$path,source:d.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(d.$path)});continue}e.tokens[r]=o;continue}if(!i){e.tokens[r]=o;continue}if(!se(i)){n.push({path:o.$path,source:o.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,l=i,p=!!c.$type,m=!!l.$type;if(p&&m&&c.$type!==l.$type){n.push({path:c.$path,source:c.$source,message:u.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(l.$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 Nt(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(Nt,"looksLikeUnprefixedToken");function bt(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=[],l){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("$")),m=a.$type||l;for(const d of p){const I=a[d],E=[...c,d],$=E.join(".");if(Nt(I)){r.push({path:$,source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX($)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:$,source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(et=>!et.startsWith("$")).length>0){r.push({path:$,source:t,message:u.FLATTEN.INVALID_TOKEN_NESTING($)});continue}if(yt(I)&&!I.$type&&!m){r.push({path:$,source:t,message:u.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE($)});continue}const me=o(E),X=E.join(".");n.tokens[me]={...I,...I.$type||m?{$type:I.$type||m}:{},$path:X,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:X},n.pathIndex.set(X,me)}else i(I,E,m)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(bt,"flattenTree");function St(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=bt(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),gt(t,o,n)}return{tokens:t,errors:n}}s(St,"flatten");const k=f.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 '.'"),Te=f.object({$ref:f.string().min(1,"$ref cannot be empty")}).passthrough(),ie=f.union([Te,f.record(f.string(),f.unknown())]),Tt=f.object({description:f.string().optional(),sources:f.array(ie),$extensions:f.record(f.string(),f.unknown()).optional()}),Oe=f.record(f.string(),f.array(ie)),Ot=f.object({description:f.string().optional(),contexts:Oe,default:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),At=f.object({type:f.literal("set"),name:k,sources:f.array(ie),description:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional()}),Rt=f.object({type:f.literal("modifier"),name:k,contexts:Oe,description:f.string().optional(),default:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Dt=f.union([Te,At,Rt]),_t=f.record(k,Tt),Lt=f.record(k,Ot),vt=f.object({version:f.literal("2025.10"),name:f.string().optional(),description:f.string().optional(),sets:_t.optional(),modifiers:Lt.optional(),resolutionOrder:f.array(Dt),$schema:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional(),$defs:f.record(f.string(),f.unknown()).optional()});async function xt(e){const t=D(e)?e:T(process.cwd(),e),n=await Ft(t);if(n.error)return{document:P(),errors:[n.error]};const r=Ct(n.content);if(r.error)return{document:P(),errors:[r.error]};const o=Vt(r.data);if(o.errors.length>0)return{document:P(),errors:o.errors};const i=[];return wt(o.document,i),{document:o.document,errors:i}}s(xt,"parseResolverDocument");async function Ft(e){try{return{content:await Q(e,"utf-8")}}catch{return{error:{path:e,message:u.RESOLVER.FILE_NOT_FOUND(e)}}}}s(Ft,"loadFile");function Ct(e){try{return{data:JSON.parse(e)}}catch(t){const n=t instanceof Error?t.message:"Unknown error";return{error:{path:"resolver",message:u.RESOLVER.INVALID_JSON(n)}}}}s(Ct,"parseJson");function Vt(e){const t=vt.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(Vt,"validateSchema$1");function wt(e,t){kt(e,t),Mt(e,t),Pt(e,t)}s(wt,"validateDocument");function kt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))Ae(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];_(r)&&Ae(r,`resolutionOrder[${n}]`,t)}}s(kt,"validateModifierContexts");function Ae(e,t,n){const r=Object.keys(e.contexts).length;if(r===0){n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_NEEDS_CONTEXTS});return}r===1&&n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_SINGLE_CONTEXT}),e.default&&!e.contexts[e.default]&&n.push({path:`${t}.default`,message:u.RESOLVER.INVALID_DEFAULT(e.default,Object.keys(e.contexts))})}s(Ae,"checkModifierContexts");function Mt(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(O(o))continue;const i=o.name;n.has(i)&&t.push({path:`resolutionOrder[${r}].name`,message:u.RESOLVER.DUPLICATE_NAME(i)}),n.add(i)}}s(Mt,"validateNameUniqueness");function Pt(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(O(r))jt(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(oe(r))M(r.sources,`resolutionOrder[${n}].sources`,t);else if(_(r))for(const[o,i]of Object.entries(r.contexts))M(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))M(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))M(i,`modifiers.${n}.contexts.${o}`,t)}s(Pt,"validateReferences");function M(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!O(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],l=o[c];typeof l=="string"&&(l.includes("/")||l.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:u.RESOLVER.MALFORMED_REFERENCE(c,l)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:u.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(M,"validateSourcesReferences");function jt(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:u.RESOLVER.INVALID_REFERENCE(e)});return}if(i==="sets"){n.sets?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_SET(a)});return}if(i==="modifiers"){n.modifiers?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_MODIFIER(a)});return}r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)})}s(jt,"validateReference");function P(){return{version:"2025.10",resolutionOrder:[]}}s(P,"createEmptyDocument");function Re(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(Re,"isResolverFormat");function De(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(De,"createResolveContext");async function _e(e,t){if(t.visitedRefs.has(e))return b({},u.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?Ut(e,t):e.includes("#/")?await Wt(e,t):await Gt(e,t)}finally{t.visitedRefs.delete(e)}}s(_e,"resolveReference");function Ut(e,t){const n=e.slice(2),[r,o]=n.split("/");if(!r||!o||n.split("/").length!==2)return b({sources:[]},u.RESOLVER.INVALID_REFERENCE(e));if(r==="sets"){const i=t.document.sets?.[o];return i?{content:i,sourcePath:"#",errors:[]}:b({sources:[]},u.RESOLVER.UNDEFINED_SET(o))}if(r==="modifiers"){const i=t.document.modifiers?.[o];return i?{content:i,sourcePath:"#",errors:[]}:b({contexts:{}},u.RESOLVER.UNDEFINED_MODIFIER(o))}return b({sources:[]},u.RESOLVER.INVALID_REFERENCE(e))}s(Ut,"resolveSameDocumentRef");async function Gt(e,t){const n=D(e)?e:T(t.basePath,e),r=t.fileCache.get(n);if(r)return Re(r)?b({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await Le(n);return o.error?b({},o.error,n):Re(o.content)?b({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(Gt,"resolveFileRef");async function Wt(e,t){const[n="",r=""]=e.split("#"),o=D(n)?n:T(t.basePath,n);let i=t.fileCache.get(o);if(!i){const l=await Le(o);if(l.error)return b({},l.error,o);i=l.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=Bt(i,a);return c.error?b({},u.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(Wt,"resolveFileFragmentRef");async function Le(e){try{const t=await Q(e,"utf-8");return{content:JSON.parse(t)}}catch(t){if(t.code==="ENOENT")return{error:u.RESOLVER.EXTERNAL_FILE_NOT_FOUND(e)};const n=t instanceof Error?t.message:"Unknown error";return{error:u.RESOLVER.EXTERNAL_FILE_ERROR(e,n)}}}s(Le,"loadJsonFile");function Bt(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(Bt,"resolveJsonPointer");async function ve(e,t){const n=[],r=[];for(const o of e){if(!O(o)){n.push(o);continue}const i=await _e(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(Yt(i.content,o))}return{resolved:n,errors:r}}s(ve,"resolveSources");function Yt(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(Yt,"applyExtending");function b(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(b,"errorResult");function xe(e){return typeof e=="object"&&e!==null&&"$value"in e}s(xe,"isToken");function j(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(xe(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!xe(i);n[r]=a?j(i,o):o}return n}s(j,"deepMerge");function Fe(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=Ht(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(Fe,"extractModifiers");function Ht(e,t,n){return O(e)&&e.$ref.startsWith("#/modifiers/")?Kt(e.$ref,t,n):_(e)?qt(e,n):null}s(Ht,"extractModifierFromItem");function Kt(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(Kt,"extractReferencedModifier");function qt(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(qt,"extractInlineModifier");function zt(e,t={}){const n=[],r={},o=Fe(e);if(o.length===0)return Jt(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return Xt(t,i,n,r),Zt(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(zt,"validateInputs$1");function Jt(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:u.RESOLVER.UNKNOWN_MODIFIER(n)})}s(Jt,"validateNoModifiersCase");function Xt(e,t,n,r){for(const[o,i]of Object.entries(e)){const a=t.get(o);if(!a){n.push({modifier:o,message:u.RESOLVER.UNKNOWN_MODIFIER(o)});continue}if(typeof i!="string"){n.push({modifier:o,message:u.RESOLVER.INVALID_INPUT_TYPE(o)});continue}if(!a.contexts.includes(i)){n.push({modifier:o,message:u.RESOLVER.INVALID_CONTEXT(i,o,a.contexts)});continue}r[o]=i}}s(Xt,"validateProvidedInputs");function Zt(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:u.RESOLVER.MISSING_REQUIRED_INPUT(r.name)}))}s(Zt,"applyDefaults");async function Ce(e,t,n={}){const r=zt(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=De(e,t),i=Qt();for(const a of e.resolutionOrder)await en(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(Ce,"processResolutionOrder");function Qt(){return{tokens:{},sources:[],errors:[]}}s(Qt,"createProcessingState");async function en(e,t,n,r,o){if(O(e)){await tn(e,t,n,r,o);return}if(oe(e)){await nn(e,n,o);return}_(e)&&await rn(e,n,r,o)}s(en,"processItem");async function tn(e,t,n,r,o){const i=await _e(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 U(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 m=await U(p,n,{type:"modifier",name:a,context:c});G(m,o)}}}s(tn,"processReference");async function nn(e,t,n){const r=await U(e.sources,t,{type:"set",name:e.name});G(r,n)}s(nn,"processInlineSet");async function rn(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await U(i,t,{type:"modifier",name:e.name,context:o});G(a,r)}s(rn,"processInlineModifier");async function U(e,t,n){const r=await ve(e,t);let o={};for(const i of r.resolved)o=j(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(U,"mergeSources");function G(e,t){t.errors.push(...e.errors),t.tokens=j(t.tokens,e.tokens),t.sources.push(e.source)}s(G,"applyResult");async function on(e,t){const n=[],r=De(e,t),o=Fe(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await Ce(e,t,i);n.push(...a.errors);const c=a.tokens,l=[];for(const p of o){const m=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const E=await sn(e,t,r,p.name,I,n);Object.keys(E).length>0&&m.set(I,E)}l.push({name:p.name,defaultContext:d,contexts:m})}return{base:c,modifiers:l,errors:n}}s(on,"processForLayeredCSS");async function sn(e,t,n,r,o,i){const a=an(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const l=await ve(c,n);i.push(...l.errors.map(E=>({path:E.path,message:E.message})));let p={};for(const E of l.resolved)p=j(p,E);const m=new Set;Ve(p,"",m);const d=await Ce(e,t,{[r]:o});i.push(...d.errors);const I={};for(const E of m){const $=cn(d.tokens,E);$!==void 0&&un(I,E,$)}return I}s(sn,"processModifierContext");function an(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(_(n)&&n.name===t)return n}s(an,"findModifierDefinition");function Ve(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"&&Ve(o,i,n)}}s(Ve,"collectTokenPaths");function cn(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(cn,"getTokenAtPath");function un(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(un,"setTokenAtPath");async function fn(e){const t=D(e)?e:T(process.cwd(),e),n=C(t),r=[],o=[],i=F(process.cwd(),t),a=await xt(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await on(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 l=[];for(const p of c.modifiers){const m=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),m.push(d));l.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:m})}return{trees:o,modifiers:l,errors:r}}s(fn,"loadFromResolver");async function ln(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:F(process.cwd(),o)})}catch(c){c instanceof Error?c instanceof SyntaxError?n.push({file:o,message:u.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(ln,"loadTreesFromMemory");function W(e,t,n,r){return typeof t=="string"&&h(t)?dn(e,t,n,r):Array.isArray(t)?t.map(o=>W(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:W(`${e}.${a}`,c,n,r)}),{}):t}s(W,"resolveValue");function we(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"&&h(o.$value))return we(o.$value,t)}}s(we,"inferTypeFromReference");function pn(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"&&h(a.$value)&&(c=we(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:W(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),l=i,p=l.$path,m=l.$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=u.RESOLVE.TYPE_MISMATCH(p)),r.push({type:d,path:p,source:m,message:I})}return{resolved:t,errors:r}}s(pn,"resolve");function dn(e,t,n,r){const o=t.slice(1,-1),i=n.pathIndex.get(o);if(!i)throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));if(r.has(i)){const l=n.tokens[i];throw!l||!("$path"in l)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,l.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));r.add(i);const c=W(i,a.$value,n,r);return r.delete(i),c}s(dn,"resolveReferenceChain");function S(e){return{success:!0,value:e}}s(S,"success");function g(e){return{success:!1,error:e}}s(g,"error");function B(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(B,"isDTCGColorValue");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,"validateDTCGColorValue");function mn(e){const t=Y(e);return t.length>0?g(t.join(", ")):S(e)}s(mn,"validateDTCGColorValueResult");function hn(e){const t=mn(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)),l=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return S(`oklch(${a} ${c} ${l} / ${p})`)}return S(`oklch(${a} ${c} ${l})`)}s(hn,"formatDTCGColorToOKLCH");const In={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function y(e,t,n,r){if(h(t))return[];switch(e.type){case"object":return yn(e,t,n,r);case"union":return $n(e,t,n,r);case"array":return gn(e,t,n,r);default:return En(e,t,n,r)}}s(y,"validateSchema");function En(e,t,n,r){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE(e.type,t,n),source:r}]:e.validate?.(t,n,r)??[]}s(En,"validateSimpleValue");function yn(e,t,n,r){if(!In.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||u.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:u.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:r});for(const[a,c]of Object.entries(e.properties))a in i&&o.push(...y(c,i[a],`${n}.${a}`,r));return o}s(yn,"validateObject");function $n(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=y(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:u.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:r}]:o}s($n,"validateUnion");function gn(e,t,n,r){return Array.isArray(t)?e.validate?.(t,n,r)??[]:[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("array",t,n),source:r}]}s(gn,"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:u.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)=>B(e)?Y(e).map(o=>({path:t,message:`Invalid color at ${t}: ${o}`,source:n})):[{path:t,message:u.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Nn(e,t,n){return y(H.schema,e,t,n)}s(Nn,"validateColor");const K={schema:{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:u.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function bn(e,t,n){return y(K.schema,e,t,n)}s(bn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>u.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:u.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function Sn(e,t,n){return y(N.schema,e,t,n)}s(Sn,"validateDimension");const Tn=["solid","dashed","dotted","double","groove","ridge","outset","inset"],On=["round","butt","square"],An={type:"object",errorMessage:s((e,t)=>u.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(...y(N.schema,i,`${t}.${a}`,n))}),o},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>On.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},ke={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Tn.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},An]}};function Rn(e,t,n){return y(ke.schema,e,t,n)}s(Rn,"validateStrokeStyle");const Dn={schema:{type:"object",properties:{color:H.schema,width:N.schema,style:ke.schema},required:["color","width","style"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function _n(e,t,n){return y(Dn.schema,e,t,n)}s(_n,"validateBorder");const Me={schema:{type:"array",errorMessage:s((e,t)=>u.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:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function Ln(e,t,n){return y(Me.schema,e,t,n)}s(Ln,"validateCubicBezier");const vn=["ms","s"],ae={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:K.schema,unit:{type:"string",validate:s((e,t,n)=>vn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function xn(e,t,n){return y(ae.schema,e,t,n)}s(xn,"validateDuration");const Fn={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:N.schema,max:N.schema},required:["min","max"]}};function Cn(e,t,n){return y(Fn.schema,e,t,n)}s(Cn,"validateFluidDimension");const Pe={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function Vn(e,t,n){return y(Pe.schema,e,t,n)}s(Vn,"validateFontFamily");const wn=["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"],je={schema:{type:"union",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>wn.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function kn(e,t,n){return y(je.schema,e,t,n)}s(kn,"validateFontWeight");const Mn={type:"object",errorMessage:s((e,t)=>u.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:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},Pn={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{o.push(...y(Mn,i,`${t}[${a}]`,n))}),o},"validate")}};function jn(e,t,n){return y(Pn.schema,e,t,n)}s(jn,"validateGradient");const Ue={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)=>u.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function Un(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...y(Ue.schema,o,`${t}[${i}]`,n))}),r):y(Ue.schema,e,t,n)}s(Un,"validateShadow");const Gn={schema:{type:"object",properties:{duration:ae.schema,delay:ae.schema,timingFunction:Me.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Wn(e,t,n){return y(Gn.schema,e,t,n)}s(Wn,"validateTransition");const Bn={schema:{type:"object",properties:{fontFamily:Pe.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:K.schema,fontWeight:je.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Yn(e,t,n){return y(Bn.schema,e,t,n)}s(Yn,"validateTypography");const Hn={color:Nn,dimension:Sn,fluidDimension:Cn,duration:xn,cubicBezier:Ln,fontFamily:Vn,fontWeight:kn,number:bn,strokeStyle:Rn,typography:Yn,border:_n,shadow:Un,gradient:jn,transition:Wn};function Kn(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:u.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",r.$path),source:r.$source});continue}const o=Hn[r.$type];if(!o){t.push({path:r.$path,message:u.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(Kn,"validate");async function qn(e){const{trees:t,modifiers:n,errors:r}=await zn(e),{tokens:o,errors:i}=St(t),a=Kn(o),{resolved:c,errors:l}=pn(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:l}}}s(qn,"loadAndResolveTokens");async function zn(e){switch(e.type){case"memory":{const t=await ln(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await fn(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(zn,"loadTokens");function Ge(e){return h(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>h(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Ge,"convertStrokeStyleToken");function Jn(e){if(h(e))return{value:e};const t=h(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(h(e.color),e.color),r=typeof e.style=="string"?e.style:Ge(e.style).value;return{value:`${t} ${r} ${n}`}}s(Jn,"convertBorderToken");function ce(e,t="native"){return B(e)?Xn(e):S(e)}s(ce,"convertColorToString");function Xn(e){switch(e.colorSpace){case"oklch":return hn(e);case"display-p3":return Zn(e);case"srgb":return Qn(e);case"hsl":return er(e);default:return g(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(Xn,"formatDTCGColorNative");function Zn(e){if(e.colorSpace!=="display-p3")return g(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return g("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 g("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return g("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return g("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return g("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 l=Number(o.toFixed(4));return S(`color(display-p3 ${i} ${a} ${c} / ${l})`)}return S(`color(display-p3 ${i} ${a} ${c})`)}s(Zn,"formatDTCGColorToP3");function Qn(e){if(e.colorSpace!=="srgb")return g(`Expected srgb color space, got: ${e.colorSpace}`);const t=Y(e);if(t.length>0)return g(`Invalid DTCG 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),l=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return S(`rgb(${a} ${c} ${l} / ${p})`)}return S(`rgb(${a} ${c} ${l})`)}s(Qn,"formatDTCGColorToRGB");function er(e){if(e.colorSpace!=="hsl")return g(`Expected hsl color space, got: ${e.colorSpace}`);const t=Y(e);if(t.length>0)return g(`Invalid DTCG 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),l=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,E=l==="none"?"none":`${l}%`;return S(`hsl(${a} ${I} ${E} / ${d})`)}const p=c==="none"?"none":`${c}%`,m=l==="none"?"none":`${l}%`;return S(`hsl(${a} ${p} ${m})`)}s(er,"formatDTCGColorToHSL");function tr(e,t){if(typeof e=="string"&&h(e))return{value:e};const n=t.colorFallbackStrategy;if(B(e))return nr(e,n);const r=ce(e,n);if(!r.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(r.error));return{value:r.value}}s(tr,"convertColorToken");function nr(e,t){const n=ce(e,t);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));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:rr(e.colorSpace),value:r}]}}s(nr,"convertDTCGColorToken");function rr(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(rr,"getFeatureQuery");function or(e){return h(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(or,"convertCubicBezierToken");function sr(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(sr,"convertDimensionToken");function ir(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(ir,"convertDurationToken");function We(e,t=16){return e.unit==="px"?e.value:e.value*t}s(We,"normalizeToPixels");function ar(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=We(n,i),c=We(r,i),l=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const m=a/i,d=c/i,I=l/i,E=p/i,$=(d-m)/(E-I),de=-1*I*$+m;return{value:`clamp(${m}rem, ${de.toFixed(2)}rem + ${($*100).toFixed(2)}vw, ${d}rem)`}}s(ar,"convertFluidDimension");function cr(e,t){return h(e)?{value:e}:ar(e,t)}s(cr,"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 ur(e){return h(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>q(n)).join(", "):q(e)}}s(ur,"convertFontFamilyToken");const fr={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 Be(e){return h(e)?{value:e}:typeof e=="number"?{value:e}:{value:fr[e.toLowerCase()]??e}}s(Be,"convertFontWeightToken");function lr(e){return h(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const r=(h(n.color),n.color),o=h(n.position)?n.position:`${n.position*100}`;return`${r} ${o}%`}).join(", ")})`}}s(lr,"convertGradientToken");function pr(e){return h(e)?{value:e}:{value:e}}s(pr,"convertNumberToken");function dr(e,t){if(h(e))return e;if(B(e)){const n=ce(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(dr,"convertShadowColor");function Ye(e,t){const n=h(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,r=h(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=h(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,i=h(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,a=dr(e.color,t);return`${e.inset?"inset ":""}${n} ${r} ${o} ${i} ${a}`}s(Ye,"convertSingleShadow");function mr(e,t){return h(e)?{value:e}:Array.isArray(e)?{value:e.map(n=>Ye(n,t)).join(", ")}:{value:Ye(e,t)}}s(mr,"convertShadowToken");function He(e){return e?`${e.value}${e.unit}`:"0ms"}s(He,"formatDuration");function hr(e){if(h(e))return{value:e};const t=h(e.duration)?e.duration:He(e.duration),n=h(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(h(e.delay)?e.delay:He(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(hr,"convertTransitionToken");function Ir(e){if(h(e))return{"font-family":e,"font-size":e};const t={"font-family":h(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>q(n)).join(", "):q(e.fontFamily),"font-size":h(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=h(e.fontWeight)?e.fontWeight:Be(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=h(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(h(e.lineHeight),e.lineHeight)),t}s(Ir,"convertTypographyToken");const Ke={duration:ir,number:pr,cubicBezier:or,color:tr,dimension:sr,fluidDimension:cr,typography:Ir,border:Jn,shadow:mr,gradient:lr,transition:hr,strokeStyle:Ge,fontFamily:ur,fontWeight:Be};function Er(e,t){const n=Ke[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(Er,"convertSingleToken");function yr(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)||!Ke[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=Er(i,a)}return r}s(yr,"convertTokens");function $r(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=yr(i,t,n);return r}s($r,"convert");function gr(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[l,p]of Object.entries(a))n[c][l]=p}return{tokens:n,defaultContext:t}}s(gr,"normalizeTokens");function Nr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const l=c.context??"";n.has(l)||n.set(l,{});const p=n.get(l);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(Nr,"processTrees");async function br(e,t,n,r){const o=Nr(e,t),{tokens:i}=gr(o);return $r(i,n,r?l=>r.some(p=>p.path===l||p.path.startsWith(`${l}.`)):void 0)}s(br,"processAndConvertTokens");function Sr(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(Sr,"deterministicEntries");const qe=new Map;function Tr(e){const t=qe.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 qe.set(e,n),n}s(Tr,"toKebabCase");function ue(e){return e.split(".").join("-")}s(ue,"formatCSSVarPath");function fe(e){if(typeof e=="number")return e;if(typeof e!="string")throw new Error(u.GENERATE.INVALID_CSS_VALUE_TYPE(typeof e));return e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(Tr).join("-")})`)}s(fe,"convertReferenceToCSSVar");function Or(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ue(e.$path)}`,value:fe(t.value)}}s(Or,"generateSingleVariable");function Ar(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ue(e.$path)}-${t}`,value:fe(n)}))}s(Ar,"generateTypographyVariables");function ze(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:`--${ue(e.$path)}`,value:fe(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(ze,"generateFeatureVariables");function Je(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(`
12
+ 3. Create a sugarcube.config.ts file`,"NO_CONFIG_OR_RESOLVER")},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")}};async function te(e){const n=await st(["**/*.resolver.json"],{cwd:e,onlyFiles:!0,absolute:!0,ignore:["**/node_modules/**","**/dist/**","**/build/**","**/out/**","**/.git/**","**/.next/**","**/.nuxt/**","**/.astro/**","**/.cache/**","**/.turbo/**","**/.vercel/**","**/.svelte-kit/**"]});if(n.length===0)return{found:"none"};const[r]=n;return n.length===1&&r?{found:"one",path:V(process.cwd(),r)}:{found:"multiple",paths:n.map(o=>V(process.cwd(),o))}}s(te,"findResolverDocument");function at(e){return Q(Ee(e,"src"))?"src/styles":"styles"}s(at,"getDefaultCssRoot");function ct(e){return Q(Ee(e,"src"))?"src/components/ui":"components/ui"}s(ct,"getDefaultComponentsDir");function k(e,t=process.cwd()){const n=e.output?.cssRoot??at(t),r={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??A.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??A.transforms.colorFallbackStrategy},output:{cssRoot:n,variables:e.output?.variables??`${n}/global`,variablesFilename:e.output?.variablesFilename??A.output.variablesFilename,utilities:e.output?.utilities??`${n}/utilities`,utilitiesFilename:e.output?.utilitiesFilename??A.output.utilitiesFilename,cube:e.output?.cube??n,themeAttribute:e.output?.themeAttribute??A.output.themeAttribute,defaultContext:e.output?.defaultContext,layers:e.output?.layers}};return(e.output?.components!==void 0||A.output.components!==void 0)&&(r.output.components=e.output?.components??ct(t)),e.utilities&&(r.utilities=e.utilities),r}s(k,"fillDefaults");const ye=f.object({min:f.number(),max:f.number()}),$e=f.object({source:f.string(),directions:f.union([f.enum(["top","right","bottom","left","x","y","full","all"]),f.array(f.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:f.string().optional(),stripDuplicates:f.boolean().optional()}),ge=f.union([$e,f.array($e)]),Ne=f.object({variables:f.string(),utilities:f.string()}),ut=f.object({resolver:f.string().optional(),transforms:f.object({fluid:ye.optional(),colorFallbackStrategy:f.enum(["native","polyfill"]).optional()}).optional(),output:f.object({cssRoot:f.string().optional(),variables:f.string().optional(),variablesFilename:f.string().optional(),utilities:f.string().optional(),utilitiesFilename:f.string().optional(),cube:f.string().optional(),components:f.string().optional(),themeAttribute:f.string().optional(),defaultContext:f.string().optional(),layers:Ne.optional()}).optional(),utilities:f.record(f.string(),ge).optional()}),ft=f.object({resolver:f.string().optional(),transforms:f.object({fluid:ye,colorFallbackStrategy:f.enum(["native","polyfill"])}),output:f.object({cssRoot:f.string(),variables:f.string().optional(),variablesFilename:f.string(),utilities:f.string().optional(),utilitiesFilename:f.string(),cube:f.string().optional(),components:f.string().optional(),themeAttribute:f.string(),defaultContext:f.string().optional(),layers:Ne.optional()}),utilities:f.record(f.string(),ge).optional()});function ne(e){const t=ut.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
13
+ `))}return t.data}s(ne,"validateSugarcubeConfig");function re(e){const t=ft.safeParse(e);if(!t.success){const n=t.error.errors.map(r=>{const o=r.path.join(".");return u.CONFIG.INVALID_CONFIG(o||"root",r.message)});throw new Error(n.join(`
14
+ `))}return t.data}s(re,"validateInternalConfig");function lt(e){const t=ne(e),n=k(t);return re(n)}s(lt,"validateConfig");function pt(e){return e instanceof Error&&e.message===u.CONFIG.NO_CONFIG_OR_RESOLVER()}s(pt,"isNoConfigError");function oe(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=O(n,`${e}${r}`);if(Q(o))return o}return null}s(oe,"findConfigFile");function dt(e="sugarcube.config"){return oe(e)!==null}s(dt,"configFileExists");async function mt(e){try{if(typeof globalThis.Bun<"u"){const i=ot(e).href,c=await new Function("url","return import(url)")(i);if(c&&typeof c=="object"&&"default"in c)return c.default;throw new Error(u.CONFIG.INVALID_CONFIG("root","Config file must export a default object"))}const{createJiti:n}=await import("jiti"),o=await n(import.meta.url,{interopDefault:!0}).import(e);return o&&typeof o=="object"&&"default"in o?o.default:o}catch(t){throw t instanceof Error?new Error(u.CONFIG.INVALID_CONFIG("root",t.message)):t}}s(mt,"loadTSConfig");async function Se(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await mt(e);const n=await rt.readFile(e,"utf-8");return JSON.parse(n)}s(Se,"loadConfigFile");function ht(e){if(e)return O(process.cwd(),e);const t=oe();if(!t)throw new Error(u.CONFIG.FILE_NOT_FOUND("sugarcube.config.ts"));return t}s(ht,"resolveConfigPath");async function It(e){const t=ht(e);try{const n=await Se(t);return{config:ne(n),configPath:t}}catch(n){throw n instanceof Error&&"code"in n&&n.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):n instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(n.message)):n}}s(It,"loadSugarcubeConfig");async function Et(e){const t=e?O(process.cwd(),e):oe();if(t)try{const r=await Se(t),o=ne(r);if(!o.resolver){const c=await te(process.cwd());if(c.found==="one")o.resolver=c.path;else{if(c.found==="multiple")throw new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(c.paths));if(c.found==="none")throw new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}}const i=k(o);return{config:re(i),configPath:t}}catch(r){throw r instanceof Error&&"code"in r&&r.code==="ENOENT"?new Error(u.CONFIG.FILE_NOT_FOUND(t)):r instanceof SyntaxError?new Error(u.CONFIG.INVALID_JSON(r.message)):r}const n=await te(process.cwd());if(n.found==="one"){const r={resolver:n.path},o=k(r);return{config:re(o),configPath:n.path}}throw n.found==="multiple"?new Error(u.CONFIG.MULTIPLE_RESOLVERS_FOUND(n.paths)):new Error(u.CONFIG.NO_CONFIG_OR_RESOLVER())}s(Et,"loadInternalConfig");function T(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(T,"isReference$1");function se(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(se,"isInlineSet");function _(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(_,"isInlineModifier");async function yt(e){const t=D(e)?e:O(process.cwd(),e),n=w(t),r=await ee(t,"utf-8"),o=JSON.parse(r),i=new Set;for(const a of o.resolutionOrder)if(T(a))be(a.$ref,n,i);else if(se(a))M(a.sources,n,i);else if(_(a))for(const c of Object.values(a.contexts))M(c,n,i);if(o.sets)for(const a of Object.values(o.sets))M(a.sources,n,i);if(o.modifiers)for(const a of Object.values(o.modifiers))for(const c of Object.values(a.contexts))M(c,n,i);return{filePaths:[...i],resolverPath:t}}s(yt,"extractFileRefs");function M(e,t,n){for(const r of e)T(r)&&be(r.$ref,t,n)}s(M,"extractFromSources");function be(e,t,n){if(e.startsWith("#/"))return;const r=e.split("#")[0];if(!r)return;const o=D(r)?r:O(t,r);n.add(o)}s(be,"addFileRef");function h(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(h,"isReference");function $t(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($t,"isCompositeToken");function gt(e){return e.$type==="typography"}s(gt,"isTypographyToken");function ie(e){return typeof e=="object"&&e!==null&&"$value"in e}s(ie,"isTokenNode");function Nt(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:u.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:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,l=i,p=!!c.$type,m=!!l.$type;if(p&&m&&c.$type!==l.$type){n.push({path:c.$path,source:c.$source,message:u.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(l.$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(Nt,"mergeFlattenedInto");function St(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(St,"looksLikeUnprefixedToken");function bt(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=[],l){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("$")),m=a.$type||l;for(const d of p){const I=a[d],E=[...c,d],$=E.join(".");if(St(I)){r.push({path:$,source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX($)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:$,source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(tt=>!tt.startsWith("$")).length>0){r.push({path:$,source:t,message:u.FLATTEN.INVALID_TOKEN_NESTING($)});continue}if($t(I)&&!I.$type&&!m){r.push({path:$,source:t,message:u.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE($)});continue}const me=o(E),Z=E.join(".");n.tokens[me]={...I,...I.$type||m?{$type:I.$type||m}:{},$path:Z,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:Z},n.pathIndex.set(Z,me)}else i(I,E,m)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(bt,"flattenTree");function Ot(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=bt(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),Nt(t,o,n)}return{tokens:t,errors:n}}s(Ot,"flatten");const P=f.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 '.'"),Oe=f.object({$ref:f.string().min(1,"$ref cannot be empty")}).passthrough(),ae=f.union([Oe,f.record(f.string(),f.unknown())]),Tt=f.object({description:f.string().optional(),sources:f.array(ae),$extensions:f.record(f.string(),f.unknown()).optional()}),Te=f.record(f.string(),f.array(ae)),At=f.object({description:f.string().optional(),contexts:Te,default:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Rt=f.object({type:f.literal("set"),name:P,sources:f.array(ae),description:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional()}),Dt=f.object({type:f.literal("modifier"),name:P,contexts:Te,description:f.string().optional(),default:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),_t=f.union([Oe,Rt,Dt]),Lt=f.record(P,Tt),vt=f.record(P,At),xt=f.object({version:f.literal("2025.10"),name:f.string().optional(),description:f.string().optional(),sets:Lt.optional(),modifiers:vt.optional(),resolutionOrder:f.array(_t),$schema:f.string().optional(),$extensions:f.record(f.string(),f.unknown()).optional(),$defs:f.record(f.string(),f.unknown()).optional()});async function Ct(e){const t=D(e)?e:O(process.cwd(),e),n=await Ft(t);if(n.error)return{document:U(),errors:[n.error]};const r=Vt(n.content);if(r.error)return{document:U(),errors:[r.error]};const o=wt(r.data);if(o.errors.length>0)return{document:U(),errors:o.errors};const i=[];return kt(o.document,i),{document:o.document,errors:i}}s(Ct,"parseResolverDocument");async function Ft(e){try{return{content:await ee(e,"utf-8")}}catch{return{error:{path:e,message:u.RESOLVER.FILE_NOT_FOUND(e)}}}}s(Ft,"loadFile");function Vt(e){try{return{data:JSON.parse(e)}}catch(t){const n=t instanceof Error?t.message:"Unknown error";return{error:{path:"resolver",message:u.RESOLVER.INVALID_JSON(n)}}}}s(Vt,"parseJson");function wt(e){const t=xt.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:U(),errors:n}}return{document:t.data,errors:[]}}s(wt,"validateSchema$1");function kt(e,t){Mt(e,t),Pt(e,t),jt(e,t)}s(kt,"validateDocument");function Mt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))Ae(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];_(r)&&Ae(r,`resolutionOrder[${n}]`,t)}}s(Mt,"validateModifierContexts");function Ae(e,t,n){const r=Object.keys(e.contexts).length;if(r===0){n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_NEEDS_CONTEXTS});return}r===1&&n.push({path:`${t}.contexts`,message:u.RESOLVER.MODIFIER_SINGLE_CONTEXT}),e.default&&!e.contexts[e.default]&&n.push({path:`${t}.default`,message:u.RESOLVER.INVALID_DEFAULT(e.default,Object.keys(e.contexts))})}s(Ae,"checkModifierContexts");function Pt(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(T(o))continue;const i=o.name;n.has(i)&&t.push({path:`resolutionOrder[${r}].name`,message:u.RESOLVER.DUPLICATE_NAME(i)}),n.add(i)}}s(Pt,"validateNameUniqueness");function jt(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(T(r))Ut(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(se(r))j(r.sources,`resolutionOrder[${n}].sources`,t);else if(_(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(jt,"validateReferences");function j(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!T(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],l=o[c];typeof l=="string"&&(l.includes("/")||l.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:u.RESOLVER.MALFORMED_REFERENCE(c,l)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:u.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(j,"validateSourcesReferences");function Ut(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:u.RESOLVER.INVALID_REFERENCE(e)});return}if(i==="sets"){n.sets?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_SET(a)});return}if(i==="modifiers"){n.modifiers?.[a]||r.push({path:t,message:u.RESOLVER.UNDEFINED_MODIFIER(a)});return}r.push({path:t,message:u.RESOLVER.INVALID_REFERENCE(e)})}s(Ut,"validateReference");function U(){return{version:"2025.10",resolutionOrder:[]}}s(U,"createEmptyDocument");function Re(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(Re,"isResolverFormat");function De(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(De,"createResolveContext");async function _e(e,t){if(t.visitedRefs.has(e))return S({},u.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?Gt(e,t):e.includes("#/")?await Bt(e,t):await Wt(e,t)}finally{t.visitedRefs.delete(e)}}s(_e,"resolveReference");function Gt(e,t){const n=e.slice(2),[r,o]=n.split("/");if(!r||!o||n.split("/").length!==2)return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e));if(r==="sets"){const i=t.document.sets?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({sources:[]},u.RESOLVER.UNDEFINED_SET(o))}if(r==="modifiers"){const i=t.document.modifiers?.[o];return i?{content:i,sourcePath:"#",errors:[]}:S({contexts:{}},u.RESOLVER.UNDEFINED_MODIFIER(o))}return S({sources:[]},u.RESOLVER.INVALID_REFERENCE(e))}s(Gt,"resolveSameDocumentRef");async function Wt(e,t){const n=D(e)?e:O(t.basePath,e),r=t.fileCache.get(n);if(r)return Re(r)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await Le(n);return o.error?S({},o.error,n):Re(o.content)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(Wt,"resolveFileRef");async function Bt(e,t){const[n="",r=""]=e.split("#"),o=D(n)?n:O(t.basePath,n);let i=t.fileCache.get(o);if(!i){const l=await Le(o);if(l.error)return S({},l.error,o);i=l.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=Yt(i,a);return c.error?S({},u.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(Bt,"resolveFileFragmentRef");async function Le(e){try{const t=await ee(e,"utf-8");return{content:JSON.parse(t)}}catch(t){if(t.code==="ENOENT")return{error:u.RESOLVER.EXTERNAL_FILE_NOT_FOUND(e)};const n=t instanceof Error?t.message:"Unknown error";return{error:u.RESOLVER.EXTERNAL_FILE_ERROR(e,n)}}}s(Le,"loadJsonFile");function Yt(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(Yt,"resolveJsonPointer");async function ve(e,t){const n=[],r=[];for(const o of e){if(!T(o)){n.push(o);continue}const i=await _e(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(Ht(i.content,o))}return{resolved:n,errors:r}}s(ve,"resolveSources");function Ht(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(Ht,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function xe(e){return typeof e=="object"&&e!==null&&"$value"in e}s(xe,"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(xe(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!xe(i);n[r]=a?G(i,o):o}return n}s(G,"deepMerge");function Ce(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=Kt(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(Ce,"extractModifiers");function Kt(e,t,n){return T(e)&&e.$ref.startsWith("#/modifiers/")?qt(e.$ref,t,n):_(e)?zt(e,n):null}s(Kt,"extractModifierFromItem");function qt(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(qt,"extractReferencedModifier");function zt(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(zt,"extractInlineModifier");function Jt(e,t={}){const n=[],r={},o=Ce(e);if(o.length===0)return Xt(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return Zt(t,i,n,r),Qt(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(Jt,"validateInputs$1");function Xt(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:u.RESOLVER.UNKNOWN_MODIFIER(n)})}s(Xt,"validateNoModifiersCase");function Zt(e,t,n,r){for(const[o,i]of Object.entries(e)){const a=t.get(o);if(!a){n.push({modifier:o,message:u.RESOLVER.UNKNOWN_MODIFIER(o)});continue}if(typeof i!="string"){n.push({modifier:o,message:u.RESOLVER.INVALID_INPUT_TYPE(o)});continue}if(!a.contexts.includes(i)){n.push({modifier:o,message:u.RESOLVER.INVALID_CONTEXT(i,o,a.contexts)});continue}r[o]=i}}s(Zt,"validateProvidedInputs");function Qt(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:u.RESOLVER.MISSING_REQUIRED_INPUT(r.name)}))}s(Qt,"applyDefaults");async function Fe(e,t,n={}){const r=Jt(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=De(e,t),i=en();for(const a of e.resolutionOrder)await tn(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(Fe,"processResolutionOrder");function en(){return{tokens:{},sources:[],errors:[]}}s(en,"createProcessingState");async function tn(e,t,n,r,o){if(T(e)){await nn(e,t,n,r,o);return}if(se(e)){await rn(e,n,o);return}_(e)&&await on(e,n,r,o)}s(tn,"processItem");async function nn(e,t,n,r,o){const i=await _e(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});B(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 m=await W(p,n,{type:"modifier",name:a,context:c});B(m,o)}}}s(nn,"processReference");async function rn(e,t,n){const r=await W(e.sources,t,{type:"set",name:e.name});B(r,n)}s(rn,"processInlineSet");async function on(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});B(a,r)}s(on,"processInlineModifier");async function W(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(W,"mergeSources");function B(e,t){t.errors.push(...e.errors),t.tokens=G(t.tokens,e.tokens),t.sources.push(e.source)}s(B,"applyResult");async function sn(e,t){const n=[],r=De(e,t),o=Ce(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await Fe(e,t,i);n.push(...a.errors);const c=a.tokens,l=[];for(const p of o){const m=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const E=await an(e,t,r,p.name,I,n);Object.keys(E).length>0&&m.set(I,E)}l.push({name:p.name,defaultContext:d,contexts:m})}return{base:c,modifiers:l,errors:n}}s(sn,"processForLayeredCSS");async function an(e,t,n,r,o,i){const a=cn(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const l=await ve(c,n);i.push(...l.errors.map(E=>({path:E.path,message:E.message})));let p={};for(const E of l.resolved)p=G(p,E);const m=new Set;Ve(p,"",m);const d=await Fe(e,t,{[r]:o});i.push(...d.errors);const I={};for(const E of m){const $=un(d.tokens,E);$!==void 0&&fn(I,E,$)}return I}s(an,"processModifierContext");function cn(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(_(n)&&n.name===t)return n}s(cn,"findModifierDefinition");function Ve(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"&&Ve(o,i,n)}}s(Ve,"collectTokenPaths");function un(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(un,"getTokenAtPath");function fn(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(fn,"setTokenAtPath");async function ln(e){const t=D(e)?e:O(process.cwd(),e),n=w(t),r=[],o=[],i=V(process.cwd(),t),a=await Ct(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await sn(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 l=[];for(const p of c.modifiers){const m=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),m.push(d));l.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:m})}return{trees:o,modifiers:l,errors:r}}s(ln,"loadFromResolver");async function pn(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:u.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(pn,"loadTreesFromMemory");function Y(e,t,n,r){return typeof t=="string"&&h(t)?mn(e,t,n,r):Array.isArray(t)?t.map(o=>Y(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:Y(`${e}.${a}`,c,n,r)}),{}):t}s(Y,"resolveValue");function we(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"&&h(o.$value))return we(o.$value,t)}}s(we,"inferTypeFromReference");function dn(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"&&h(a.$value)&&(c=we(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:Y(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),l=i,p=l.$path,m=l.$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=u.RESOLVE.TYPE_MISMATCH(p)),r.push({type:d,path:p,source:m,message:I})}return{resolved:t,errors:r}}s(dn,"resolve");function mn(e,t,n,r){const o=t.slice(1,-1),i=n.pathIndex.get(o);if(!i)throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));if(r.has(i)){const l=n.tokens[i];throw!l||!("$path"in l)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,l.$path))}const a=n.tokens[i];if(!a||!("$value"in a))throw new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e));r.add(i);const c=Y(i,a.$value,n,r);return r.delete(i),c}s(mn,"resolveReferenceChain");function b(e){return{success:!0,value:e}}s(b,"success");function g(e){return{success:!1,error:e}}s(g,"error");function L(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(L,"isDTCGColorValue");function H(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(H,"validateDTCGColorValue");function hn(e){const t=H(e);return t.length>0?g(t.join(", ")):b(e)}s(hn,"validateDTCGColorValueResult");function In(e){const t=hn(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)),l=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return b(`oklch(${a} ${c} ${l} / ${p})`)}return b(`oklch(${a} ${c} ${l})`)}s(In,"formatDTCGColorToOKLCH");const En={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function y(e,t,n,r){if(h(t))return[];switch(e.type){case"object":return $n(e,t,n,r);case"union":return gn(e,t,n,r);case"array":return Nn(e,t,n,r);default:return yn(e,t,n,r)}}s(y,"validateSchema");function yn(e,t,n,r){return e.type!==typeof t?[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE(e.type,t,n),source:r}]:e.validate?.(t,n,r)??[]}s(yn,"validateSimpleValue");function $n(e,t,n,r){if(!En.isObject(t))return[{path:n,message:e.errorMessage?.(t,n)||u.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:u.VALIDATE.MISSING_REQUIRED_PROPERTY(a,n),source:r});for(const[a,c]of Object.entries(e.properties))a in i&&o.push(...y(c,i[a],`${n}.${a}`,r));return o}s($n,"validateObject");function gn(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=y(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:u.VALIDATE.INVALID_TYPE(e.oneOf.map(a=>a.type).join(" or "),t,n),source:r}]:o}s(gn,"validateUnion");function Nn(e,t,n,r){return Array.isArray(t)?e.validate?.(t,n,r)??[]:[{path:n,message:e.errorMessage?.(t,n)||u.VALIDATE.INVALID_TYPE("array",t,n),source:r}]}s(Nn,"validateArray");const K={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:u.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)=>L(e)?H(e).map(o=>({path:t,message:`Invalid color at ${t}: ${o}`,source:n})):[{path:t,message:u.VALIDATE.INVALID_COLOR(e,t),source:n}],"validate")}]}};function Sn(e,t,n){return y(K.schema,e,t,n)}s(Sn,"validateColor");const q={schema:{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_NUMBER(e,t),"errorMessage"),validate:s((e,t,n)=>typeof e!="number"||Number.isNaN(e)?[{path:t,message:u.VALIDATE.INVALID_NUMBER(e,t),source:n}]:[],"validate")}};function bn(e,t,n){return y(q.schema,e,t,n)}s(bn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:q.schema,unit:{type:"string",validate:s((e,t,n)=>typeof e!="string"||!["px","rem"].includes(e)?[{path:t,message:u.VALIDATE.INVALID_DIMENSION_UNIT(e,t),source:n}]:[],"validate")}},required:["value","unit"]}};function On(e,t,n){return y(N.schema,e,t,n)}s(On,"validateDimension");const Tn=["solid","dashed","dotted","double","groove","ridge","outset","inset"],An=["round","butt","square"],Rn={type:"object",errorMessage:s((e,t)=>u.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(...y(N.schema,i,`${t}.${a}`,n))}),o},"validate")},lineCap:{type:"string",validate:s((e,t,n)=>An.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},ke={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!Tn.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},Rn]}};function Dn(e,t,n){return y(ke.schema,e,t,n)}s(Dn,"validateStrokeStyle");const _n={schema:{type:"object",properties:{color:K.schema,width:N.schema,style:ke.schema},required:["color","width","style"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Ln(e,t,n){return y(_n.schema,e,t,n)}s(Ln,"validateBorder");const Me={schema:{type:"array",errorMessage:s((e,t)=>u.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:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}];const[o,,i]=r;return o<0||o>1||i<0||i>1?[{path:t,message:u.VALIDATE.INVALID_CUBIC_BEZIER(e,t),source:n}]:[]},"validate")}};function vn(e,t,n){return y(Me.schema,e,t,n)}s(vn,"validateCubicBezier");const xn=["ms","s"],ce={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:q.schema,unit:{type:"string",validate:s((e,t,n)=>xn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function Cn(e,t,n){return y(ce.schema,e,t,n)}s(Cn,"validateDuration");const Fn={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FLUID_DIMENSION(e,t),"errorMessage"),properties:{min:N.schema,max:N.schema},required:["min","max"]}};function Vn(e,t,n){return y(Fn.schema,e,t,n)}s(Vn,"validateFluidDimension");const Pe={schema:{type:"union",oneOf:[{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")},{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage"),validate:s((e,t,n)=>e.every(o=>typeof o=="string")?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_FAMILY(e,t),source:n}],"validate")}],errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_FAMILY(e,t),"errorMessage")}};function wn(e,t,n){return y(Pe.schema,e,t,n)}s(wn,"validateFontFamily");const kn=["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"],je={schema:{type:"union",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),oneOf:[{type:"number",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>e<1||e>1e3?[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}]:[],"validate")},{type:"string",errorMessage:s((e,t)=>u.VALIDATE.INVALID_FONT_WEIGHT(e,t),"errorMessage"),validate:s((e,t,n)=>kn.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Mn(e,t,n){return y(je.schema,e,t,n)}s(Mn,"validateFontWeight");const Pn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:K.schema,position:{type:"number",validate:s((e,t,n)=>e<0||e>1?[{path:t,message:u.VALIDATE.INVALID_GRADIENT_STOP_POSITION(e,t),source:n}]:[],"validate")}},required:["color","position"]},jn={schema:{type:"array",errorMessage:s((e,t)=>u.VALIDATE.INVALID_ARRAY(e,t),"errorMessage"),validate:s((e,t,n)=>{const r=e,o=[];return r.forEach((i,a)=>{o.push(...y(Pn,i,`${t}[${a}]`,n))}),o},"validate")}};function Un(e,t,n){return y(jn.schema,e,t,n)}s(Un,"validateGradient");const Ue={schema:{type:"object",properties:{color:{type:"union",oneOf:[K.schema]},offsetX:N.schema,offsetY:N.schema,blur:N.schema,spread:N.schema,inset:{type:"boolean",errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW_INSET(e,t),"errorMessage")}},required:["color","offsetX","offsetY","blur","spread"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_SHADOW(e,t),"errorMessage")}};function Gn(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...y(Ue.schema,o,`${t}[${i}]`,n))}),r):y(Ue.schema,e,t,n)}s(Gn,"validateShadow");const Wn={schema:{type:"object",properties:{duration:ce.schema,delay:ce.schema,timingFunction:Me.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Bn(e,t,n){return y(Wn.schema,e,t,n)}s(Bn,"validateTransition");const Yn={schema:{type:"object",properties:{fontFamily:Pe.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:q.schema,fontWeight:je.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Hn(e,t,n){return y(Yn.schema,e,t,n)}s(Hn,"validateTypography");const Kn={color:Sn,dimension:On,fluidDimension:Vn,duration:Cn,cubicBezier:vn,fontFamily:wn,fontWeight:Mn,number:bn,strokeStyle:Dn,typography:Hn,border:Ln,shadow:Gn,gradient:Un,transition:Bn};function qn(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:u.VALIDATE.MISSING_REQUIRED_PROPERTY("$value",r.$path),source:r.$source});continue}const o=Kn[r.$type];if(!o){t.push({path:r.$path,message:u.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(qn,"validate");async function zn(e){const{trees:t,modifiers:n,errors:r}=await Jn(e),{tokens:o,errors:i}=Ot(t),a=qn(o),{resolved:c,errors:l}=dn(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:l}}}s(zn,"loadAndResolveTokens");async function Jn(e){switch(e.type){case"memory":{const t=await pn(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await ln(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(Jn,"loadTokens");function x(e,t="native"){return L(e)?Xn(e):b(e)}s(x,"convertColorToString");function Xn(e){switch(e.colorSpace){case"oklch":return In(e);case"display-p3":return Zn(e);case"srgb":return Qn(e);case"hsl":return er(e);default:return g(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(Xn,"formatDTCGColorNative");function Zn(e){if(e.colorSpace!=="display-p3")return g(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return g("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 g("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return g("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return g("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return g("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 l=Number(o.toFixed(4));return b(`color(display-p3 ${i} ${a} ${c} / ${l})`)}return b(`color(display-p3 ${i} ${a} ${c})`)}s(Zn,"formatDTCGColorToP3");function Qn(e){if(e.colorSpace!=="srgb")return g(`Expected srgb color space, got: ${e.colorSpace}`);const t=H(e);if(t.length>0)return g(`Invalid DTCG 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),l=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return b(`rgb(${a} ${c} ${l} / ${p})`)}return b(`rgb(${a} ${c} ${l})`)}s(Qn,"formatDTCGColorToRGB");function er(e){if(e.colorSpace!=="hsl")return g(`Expected hsl color space, got: ${e.colorSpace}`);const t=H(e);if(t.length>0)return g(`Invalid DTCG 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),l=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,E=l==="none"?"none":`${l}%`;return b(`hsl(${a} ${I} ${E} / ${d})`)}const p=c==="none"?"none":`${c}%`,m=l==="none"?"none":`${l}%`;return b(`hsl(${a} ${p} ${m})`)}s(er,"formatDTCGColorToHSL");function Ge(e){return h(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>h(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Ge,"convertStrokeStyleToken");function tr(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(tr,"convertBorderColor");function nr(e,t){if(h(e))return{value:e};const n=h(e.width)?e.width:`${e.width.value}${e.width.unit}`,r=tr(e.color,t),o=typeof e.style=="string"?e.style:Ge(e.style).value;return{value:`${n} ${o} ${r}`}}s(nr,"convertBorderToken");function rr(e,t){if(typeof e=="string"&&h(e))return{value:e};const n=t.colorFallbackStrategy;if(L(e))return or(e,n);const r=x(e,n);if(!r.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(r.error));return{value:r.value}}s(rr,"convertColorToken");function or(e,t){const n=x(e,t);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));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:sr(e.colorSpace),value:r}]}}s(or,"convertDTCGColorToken");function sr(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(sr,"getFeatureQuery");function ir(e){return h(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(ir,"convertCubicBezierToken");function ar(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(ar,"convertDimensionToken");function cr(e){return h(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(cr,"convertDurationToken");function We(e,t=16){return e.unit==="px"?e.value:e.value*t}s(We,"normalizeToPixels");function ur(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=We(n,i),c=We(r,i),l=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const m=a/i,d=c/i,I=l/i,E=p/i,$=(d-m)/(E-I),de=-1*I*$+m;return{value:`clamp(${m}rem, ${de.toFixed(2)}rem + ${($*100).toFixed(2)}vw, ${d}rem)`}}s(ur,"convertFluidDimension");function fr(e,t){return h(e)?{value:e}:ur(e,t)}s(fr,"convertFluidDimensionToken");function z(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(z,"quoteFont");function lr(e){return h(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>z(n)).join(", "):z(e)}}s(lr,"convertFontFamilyToken");const pr={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 Be(e){return h(e)?{value:e}:typeof e=="number"?{value:e}:{value:pr[e.toLowerCase()]??e}}s(Be,"convertFontWeightToken");function dr(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s(dr,"convertGradientColor");function mr(e){return Math.max(0,Math.min(1,e))}s(mr,"clampPosition");function hr(e){return h(e)?`${e}%`:`${mr(e)*100}%`}s(hr,"convertGradientPosition");function Ir(e,t){const n=dr(e.color,t),r=hr(e.position);return`${n} ${r}`}s(Ir,"convertSingleStop");function Ye(e){const t=[];for(const n of e)Array.isArray(n)?t.push(...Ye(n)):t.push(n);return t}s(Ye,"flattenStops");function Er(e,t){return h(e)?{value:e}:{value:`linear-gradient(${Ye(e).map(o=>Ir(o,t)).join(", ")})`}}s(Er,"convertGradientToken");function yr(e){return h(e)?{value:e}:{value:e}}s(yr,"convertNumberToken");function $r(e,t){if(h(e))return e;if(L(e)){const n=x(e,t.colorFallbackStrategy);if(!n.success)throw new Error(u.CONVERT.COLOR_CONVERSION_FAILED(n.error));return n.value}return e}s($r,"convertShadowColor");function He(e,t){const n=h(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,r=h(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,o=h(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,i=h(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,a=$r(e.color,t);return`${e.inset?"inset ":""}${n} ${r} ${o} ${i} ${a}`}s(He,"convertSingleShadow");function gr(e,t){return h(e)?{value:e}:Array.isArray(e)?{value:e.map(n=>He(n,t)).join(", ")}:{value:He(e,t)}}s(gr,"convertShadowToken");function Ke(e){return e?`${e.value}${e.unit}`:"0ms"}s(Ke,"formatDuration");function Nr(e){if(h(e))return{value:e};const t=h(e.duration)?e.duration:Ke(e.duration),n=h(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(h(e.delay)?e.delay:Ke(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(Nr,"convertTransitionToken");function Sr(e){if(h(e))return{"font-family":e,"font-size":e};const t={"font-family":h(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>z(n)).join(", "):z(e.fontFamily),"font-size":h(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=h(e.fontWeight)?e.fontWeight:Be(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=h(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(h(e.lineHeight),e.lineHeight)),t}s(Sr,"convertTypographyToken");const qe={duration:cr,number:yr,cubicBezier:ir,color:rr,dimension:ar,fluidDimension:fr,typography:Sr,border:nr,shadow:gr,gradient:Er,transition:Nr,strokeStyle:Ge,fontFamily:lr,fontWeight:Be};function br(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(br,"convertSingleToken");function Or(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)||!qe[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=br(i,a)}return r}s(Or,"convertTokens");function Tr(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=Or(i,t,n);return r}s(Tr,"convert");function Ar(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[l,p]of Object.entries(a))n[c][l]=p}return{tokens:n,defaultContext:t}}s(Ar,"normalizeTokens");function Rr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const l=c.context??"";n.has(l)||n.set(l,{});const p=n.get(l);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(Rr,"processTrees");async function Dr(e,t,n,r){const o=Rr(e,t),{tokens:i}=Ar(o);return Tr(i,n,r?l=>r.some(p=>p.path===l||p.path.startsWith(`${l}.`)):void 0)}s(Dr,"processAndConvertTokens");function _r(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(_r,"deterministicEntries");const ze=new Map;function Lr(e){const t=ze.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 ze.set(e,n),n}s(Lr,"toKebabCase");function ue(e){return e.split(".").join("-")}s(ue,"formatCSSVarPath");function fe(e){if(typeof e=="number")return e;if(typeof e!="string")throw new Error(u.GENERATE.INVALID_CSS_VALUE_TYPE(typeof e));return e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(Lr).join("-")})`)}s(fe,"convertReferenceToCSSVar");function vr(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ue(e.$path)}`,value:fe(t.value)}}s(vr,"generateSingleVariable");function xr(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ue(e.$path)}-${t}`,value:fe(n)}))}s(xr,"generateTypographyVariables");function Je(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:`--${ue(e.$path)}`,value:fe(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(Je,"generateFeatureVariables");function Xe(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(`
15
15
  `);t.push(n)}return t.push("}"),t.join(`
16
- `)}s(Je,"generateCSSBlock");function Rr(e){const t=[];e.root.vars.length>0&&t.push(Je({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const o=Je({selector:e.root.selector,vars:n.vars}).split(`
16
+ `)}s(Xe,"generateCSSBlock");function Cr(e){const t=[];e.root.vars.length>0&&t.push(Xe({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const o=Xe({selector:e.root.selector,vars:n.vars}).split(`
17
17
  `).map(i=>` ${i}`).join(`
18
18
  `);t.push(`${n.query} {
19
19
  ${o}
20
20
  }`)}return t.filter(Boolean).join(`
21
21
 
22
- `)}s(Rr,"convertCSSVarsToString");function Dr(e){if($t(e))return{vars:Ar(e),features:ze(e)};const t=Or(e);return{vars:t?[t]:[],features:ze(e)}}s(Dr,"generateVariablesForToken");function _r(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(l=>l.name===o)?.attribute??`data-${o}`}="${i}"]`}return`[${n.output.themeAttribute}="${e}"]`}s(_r,"buildSelector");async function Lr(e,t,n){const r=Sr(e).filter(([m,d])=>m!=="$extensions"&&"$type"in d).map(([m,d])=>Dr(d)),o=_r(n.context,n.modifiers,t),i=r.flatMap(m=>m.vars),a=r.flatMap(m=>m.features||[]),c=new Map;for(const m of a){c.has(m.query)||c.set(m.query,[]);const d=c.get(m.query);d&&d.push(...m.vars)}const l=Array.from(c.entries()).map(([m,d])=>({query:m,vars:d})),p=Rr({root:{selector:o,vars:i},features:l});return p.trim()?{output:[{path:t.output.variablesFilename,css:vr(p)}]}:{output:[{path:t.output.variablesFilename,css:""}]}}s(Lr,"generateCSS");function vr(e){return e.endsWith(`
22
+ `)}s(Cr,"convertCSSVarsToString");function Fr(e){if(gt(e))return{vars:xr(e),features:Je(e)};const t=vr(e);return{vars:t?[t]:[],features:Je(e)}}s(Fr,"generateVariablesForToken");function Vr(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(l=>l.name===o)?.attribute??`data-${o}`}="${i}"]`}return`[${n.output.themeAttribute}="${e}"]`}s(Vr,"buildSelector");async function wr(e,t,n){const r=_r(e).filter(([m,d])=>m!=="$extensions"&&"$type"in d).map(([m,d])=>Fr(d)),o=Vr(n.context,n.modifiers,t),i=r.flatMap(m=>m.vars),a=r.flatMap(m=>m.features||[]),c=new Map;for(const m of a){c.has(m.query)||c.set(m.query,[]);const d=c.get(m.query);d&&d.push(...m.vars)}const l=Array.from(c.entries()).map(([m,d])=>({query:m,vars:d})),p=Cr({root:{selector:o,vars:i},features:l});return p.trim()?{output:[{path:t.output.variablesFilename,css:kr(p)}]}:{output:[{path:t.output.variablesFilename,css:""}]}}s(wr,"generateCSS");function kr(e){return e.endsWith(`
23
23
  `)?e:`${e}
24
- `}s(vr,"formatCSSVars");async function xr(e,t,n){const r=t.output.variables,o=[],i=Object.entries(e).sort(([a],[c])=>!a||a==="default"?-1:!c||c==="default"?1:a.localeCompare(c));for(const[a,c]of i){const l=await Lr(c,t,{context:a,modifiers:n});l.output[0].css.trim()&&o.push(l.output[0].css)}return o.length===0?[]:[{path:`${r}/${t.output.variablesFilename}`,css:`${o.filter(Boolean).join(`
24
+ `}s(kr,"formatCSSVars");async function Mr(e,t,n){const r=t.output.variables,o=[],i=Object.entries(e).sort(([a],[c])=>!a||a==="default"?-1:!c||c==="default"?1:a.localeCompare(c));for(const[a,c]of i){const l=await wr(c,t,{context:a,modifiers:n});l.output[0].css.trim()&&o.push(l.output[0].css)}return o.length===0?[]:[{path:`${r}/${t.output.variablesFilename}`,css:`${o.filter(Boolean).join(`
25
25
  `).trim()}
26
- `}]}s(xr,"generateSingleFile");async function Fr(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await xr(r,t,n)}}s(Fr,"generate");async function Cr(e,t,n){const{output:r}=await Fr(e,t,n);return r}s(Cr,"generateCSSVariables");const v="--",R="-",Vr=["all","full"],wr={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},kr={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function Mr(e){return wr[e]}s(Mr,"getDirectionAbbreviation");function Xe(e,t){if(t==="full"||t==="all")return e;const n=kr[t];return n?`${e}${R}${n}`:e}s(Xe,"getLogicalProperty");const Pr=["top","right","bottom","left","x","y","full"];function jr(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?Pr:[n])}s(jr,"expandDirections");function Ur(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(Ur,"isTokenTypeValidForProperty");const Ze=new WeakMap,L=new Map;function Gr(){L.clear()}s(Gr,"clearMatchCache");function Wr(e){const t=Ze.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 Ze.set(e,n),n}s(Wr,"buildPathIndex");function Br(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(Br,"getDefaultContextTokens");function z(e,t,n){const r=`${t.source}:${t.prefix??""}:${t.property??""}:${e}`;if(L.has(r))return L.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 l=t.source.slice(0,c);l&&o.push(`${l}.${t.prefix}.${e}`,`${l}.${t.prefix}.${e.split("-").join(".")}`)}}const i=Br(n);if(!i)return L.set(r,null),null;const a=Wr(i);for(const c of o){const l=a.get(c);if(l){if(t.property&&l.$type&&!Ur(l.$type,t.property))continue;const p=l.$path.split(".");return L.set(r,p),p}}return L.set(r,null),null}s(z,"findMatchingToken");function le(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(le,"stripDuplicatePrefix");function J(e,t=""){const n=e??"",r=n||t?R:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(J,"createUtilityPattern");function pe(e,t,n){return[J(t.prefix),o=>{const i=o[1];if(!i)return{};const a=le(i,t),c={...t,property:e},l=z(a,c,n);return l?{[e]:`var(${v}${l.join(R)})`}:{}}]}s(pe,"createSimpleRule");function Yr(e,t,n,r){if(n==="all")return pe(e,t,r);const o=Mr(n);return[J(t.prefix,o),a=>{const c=a[1];if(!c)return{};const l=le(c,t),p={...t,property:e},m=z(l,p,r);return m?{[Xe(e,n)]:`var(${v}${m.join(R)})`}:{}}]}s(Yr,"createDirectionalRule");function Hr(e,t){return[J(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:l}of t){const p=le(o,a),m={...a,property:i},d=z(p,m,l);if(d)return c?{[Xe(i,c)]:`var(${v}${d.join(R)})`}:{[i]:`var(${v}${d.join(R)})`}}return{}}]}s(Hr,"createSmartRule");function Kr(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[J(o),a=>{const c=a[1];if(!c)return{};const l={...t,property:e},p=z(c,l,n);return p?{[e]:`var(${v}${p.join(R)})`}:{}}]}s(Kr,"createDirectTokenPathRule");function qr(e,t){if(!e?.source||typeof e.source!="string")throw new Error(u.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(u.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(u.UTILITIES.INVALID_DIRECTIONS(t))}s(qr,"validateUtilityConfig");function zr(e,t){if(!e||typeof e!="object")throw new Error(u.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(u.UTILITIES.INVALID_TOKENS_OBJECT)}s(zr,"validateInputs");function Jr(e,t){zr(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(qr(c,o),c.prefix){const l=c.prefix;r[l]||(r[l]=[]),r[l].push({property:o,config:c,direction:null,tokens:t})}else{const l=Kr(o,c,t);n.push(l)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:l,tokens:p}=a;if(l.directions){const m=jr(l.directions);(Array.isArray(l.directions)?l.directions:[l.directions]).includes("all")&&n.push(pe(c,l,p));for(const E of m)Vr.includes(E)||n.push(Yr(c,l,E,p))}else n.push(pe(c,l,p))}else n.push(Hr(o,i));return n}s(Jr,"convertConfigToUnoRules");const x=process.env.SUGARCUBE_PERF==="true";class Xr{static{s(this,"PerfMonitor")}constructor(t=n=>void process.stderr.write(`${n}
27
- `)){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()}}class Qe 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 Zr=process.env.DEBUG==="true";class Qr{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
28
- `)){this.defaultFlush=t}#n=new Qe(()=>({value:0}));#t=new Qe(()=>({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(`
26
+ `}]}s(Mr,"generateSingleFile");async function Pr(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await Mr(r,t,n)}}s(Pr,"generate");async function jr(e,t,n){const{output:r}=await Pr(e,t,n);return r}s(jr,"generateCSSVariables");const C="--",R="-",Ur=["all","full"],Gr={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},Wr={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function Br(e){return Gr[e]}s(Br,"getDirectionAbbreviation");function Ze(e,t){if(t==="full"||t==="all")return e;const n=Wr[t];return n?`${e}${R}${n}`:e}s(Ze,"getLogicalProperty");const Yr=["top","right","bottom","left","x","y","full"];function Hr(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?Yr:[n])}s(Hr,"expandDirections");function Kr(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(Kr,"isTokenTypeValidForProperty");const Qe=new WeakMap,v=new Map;function qr(){v.clear()}s(qr,"clearMatchCache");function zr(e){const t=Qe.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 Qe.set(e,n),n}s(zr,"buildPathIndex");function Jr(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(Jr,"getDefaultContextTokens");function J(e,t,n){const r=`${t.source}:${t.prefix??""}:${t.property??""}:${e}`;if(v.has(r))return v.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 l=t.source.slice(0,c);l&&o.push(`${l}.${t.prefix}.${e}`,`${l}.${t.prefix}.${e.split("-").join(".")}`)}}const i=Jr(n);if(!i)return v.set(r,null),null;const a=zr(i);for(const c of o){const l=a.get(c);if(l){if(t.property&&l.$type&&!Kr(l.$type,t.property))continue;const p=l.$path.split(".");return v.set(r,p),p}}return v.set(r,null),null}s(J,"findMatchingToken");function le(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(le,"stripDuplicatePrefix");function X(e,t=""){const n=e??"",r=n||t?R:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(X,"createUtilityPattern");function pe(e,t,n){return[X(t.prefix),o=>{const i=o[1];if(!i)return{};const a=le(i,t),c={...t,property:e},l=J(a,c,n);return l?{[e]:`var(${C}${l.join(R)})`}:{}}]}s(pe,"createSimpleRule");function Xr(e,t,n,r){if(n==="all")return pe(e,t,r);const o=Br(n);return[X(t.prefix,o),a=>{const c=a[1];if(!c)return{};const l=le(c,t),p={...t,property:e},m=J(l,p,r);return m?{[Ze(e,n)]:`var(${C}${m.join(R)})`}:{}}]}s(Xr,"createDirectionalRule");function Zr(e,t){return[X(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:l}of t){const p=le(o,a),m={...a,property:i},d=J(p,m,l);if(d)return c?{[Ze(i,c)]:`var(${C}${d.join(R)})`}:{[i]:`var(${C}${d.join(R)})`}}return{}}]}s(Zr,"createSmartRule");function Qr(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[X(o),a=>{const c=a[1];if(!c)return{};const l={...t,property:e},p=J(c,l,n);return p?{[e]:`var(${C}${p.join(R)})`}:{}}]}s(Qr,"createDirectTokenPathRule");function eo(e,t){if(!e?.source||typeof e.source!="string")throw new Error(u.UTILITIES.MISSING_SOURCE(t));if(e.source.includes("*")&&!e.source.endsWith(".*"))throw new Error(u.UTILITIES.INVALID_SOURCE_PATTERN(t,e.source));if(e.directions&&!Array.isArray(e.directions))throw new Error(u.UTILITIES.INVALID_DIRECTIONS(t))}s(eo,"validateUtilityConfig");function to(e,t){if(!e||typeof e!="object")throw new Error(u.UTILITIES.INVALID_CONFIG_OBJECT);if(!t||typeof t!="object")throw new Error(u.UTILITIES.INVALID_TOKENS_OBJECT)}s(to,"validateInputs");function no(e,t){to(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(eo(c,o),c.prefix){const l=c.prefix;r[l]||(r[l]=[]),r[l].push({property:o,config:c,direction:null,tokens:t})}else{const l=Qr(o,c,t);n.push(l)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:l,tokens:p}=a;if(l.directions){const m=Hr(l.directions);(Array.isArray(l.directions)?l.directions:[l.directions]).includes("all")&&n.push(pe(c,l,p));for(const E of m)Ur.includes(E)||n.push(Xr(c,l,E,p))}else n.push(pe(c,l,p))}else n.push(Zr(o,i));return n}s(no,"convertConfigToUnoRules");const F=process.env.SUGARCUBE_PERF==="true";class ro{static{s(this,"PerfMonitor")}constructor(t=n=>void process.stderr.write(`${n}
27
+ `)){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(!F)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(!F)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){F&&this.log("WATCHER SETUP: Adding watch pattern",{pattern:t,dir:n})}logModuleGraphStats(t,n,r){F&&this.log(`MODULE GRAPH (${r})`,{modules:t,urls:n})}startMemoryMonitor(){!F||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()}}class et 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 oo=process.env.DEBUG==="true";class so{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
28
+ `)){this.defaultFlush=t}#n=new et(()=>({value:0}));#t=new et(()=>({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(`
29
29
  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(`
30
30
  ${n.join(`
31
31
  `)}
32
- `)}[Symbol.dispose](){Zr&&this.report()}}async function eo(e){for(const t of e)try{await he(C(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(eo,"writeCSSVariablesToDisk");async function to(e){for(const t of e)try{await he(C(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write utility CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(to,"writeCSSUtilitiesToDisk");export{A as DEFAULT_CONFIG,Qr as Instrumentation,Xr as PerfMonitor,Gr as clearMatchCache,pt as configFileExists,Jr as convertConfigToUnoRules,st as defineConfig,Et as extractFileRefs,V as fillDefaults,ee as findResolverDocument,Cr as generateCSSVariables,lt as isNoConfigError,qn as loadAndResolveTokens,It as loadInternalConfig,ht as loadSugarcubeConfig,br as processAndConvertTokens,ft as validateConfig,to as writeCSSUtilitiesToDisk,eo as writeCSSVariablesToDisk};
32
+ `)}[Symbol.dispose](){oo&&this.report()}}async function io(e){for(const t of e)try{await he(w(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(io,"writeCSSVariablesToDisk");async function ao(e){for(const t of e)try{await he(w(t.path),{recursive:!0}),await Ie(t.path,t.css,"utf-8")}catch(n){throw new Error(`Failed to write utility CSS file ${t.path}: ${n instanceof Error?n.message:"Unknown error"}`)}return e}s(ao,"writeCSSUtilitiesToDisk");export{A as DEFAULT_CONFIG,so as Instrumentation,ro as PerfMonitor,qr as clearMatchCache,dt as configFileExists,no as convertConfigToUnoRules,it as defineConfig,yt as extractFileRefs,k as fillDefaults,te as findResolverDocument,jr as generateCSSVariables,pt as isNoConfigError,zn as loadAndResolveTokens,Et as loadInternalConfig,It as loadSugarcubeConfig,Dr as processAndConvertTokens,lt as validateConfig,ao as writeCSSUtilitiesToDisk,io as writeCSSVariablesToDisk};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarcube-sh/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false