@sugarcube-org/core 0.1.0-alpha.20 → 0.1.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,20 +1,5 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const DEFAULT_CONFIG: {
4
- readonly output: {
5
- readonly cssRoot: "src/styles";
6
- readonly components: "src/components/ui";
7
- readonly themeAttribute: "data-theme";
8
- };
9
- readonly transforms: {
10
- readonly fluid: {
11
- readonly min: 320;
12
- readonly max: 1200;
13
- };
14
- readonly colorFallbackStrategy: "native";
15
- };
16
- };
17
-
18
3
  type DirectionalVariant = "top" | "right" | "bottom" | "left" | "x" | "y" | "full" | "all";
19
4
  type PropertyUtilityConfig = {
20
5
  /** Token path pattern (e.g., "space.*", "color.primary.*"). */
@@ -147,6 +132,37 @@ interface InternalConfig {
147
132
  utilities?: UtilitiesConfig;
148
133
  }
149
134
 
135
+ /**
136
+ * Define a Sugarcube configuration with full type inference.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * // sugarcube.config.ts
141
+ * import { defineConfig } from "@sugarcube-org/cli";
142
+ *
143
+ * export default defineConfig({
144
+ * resolver: "./tokens/resolver.json",
145
+ * output: { cssRoot: "src/styles" }
146
+ * });
147
+ * ```
148
+ */
149
+ declare function defineConfig(config: SugarcubeConfig): SugarcubeConfig;
150
+
151
+ declare const DEFAULT_CONFIG: {
152
+ readonly output: {
153
+ readonly cssRoot: "src/styles";
154
+ readonly components: "src/components/ui";
155
+ readonly themeAttribute: "data-theme";
156
+ };
157
+ readonly transforms: {
158
+ readonly fluid: {
159
+ readonly min: 320;
160
+ readonly max: 1200;
161
+ };
162
+ readonly colorFallbackStrategy: "native";
163
+ };
164
+ };
165
+
150
166
  /** Returns true if the error is the "no config or resolver found" case from loadInternalConfig. */
151
167
  declare function isNoConfigError(error: unknown): boolean;
152
168
  /**
@@ -848,4 +864,4 @@ declare const userConfigSchema: z.ZodObject<{
848
864
  } | undefined;
849
865
  }>;
850
866
 
851
- export { type CSSFileOutput, type ColorFallbackStrategy, DEFAULT_CONFIG, type FluidConfig, Instrumentation, type InternalConfig, type ModifierMeta, type NormalizedConvertedTokens, PerfMonitor, type ResolvedTokens, type ResolverDiscoveryResult, type SugarcubeConfig, type TokenPipelineSource, type TokenTree, clearMatchCache, configFileExists, convertConfigToUnoRules, fillDefaults, findResolverDocument, generateCSSVariables, isNoConfigError, loadAndResolveTokens, loadInternalConfig, loadSugarcubeConfig, processAndConvertTokens, userConfigSchema, validateConfig, writeCSSUtilitiesToDisk, writeCSSVariablesToDisk };
867
+ export { type CSSFileOutput, type ColorFallbackStrategy, DEFAULT_CONFIG, type FluidConfig, Instrumentation, type InternalConfig, type ModifierMeta, type NormalizedConvertedTokens, PerfMonitor, type ResolvedTokens, type ResolverDiscoveryResult, type SugarcubeConfig, type TokenPipelineSource, type TokenTree, clearMatchCache, configFileExists, convertConfigToUnoRules, defineConfig, fillDefaults, findResolverDocument, generateCSSVariables, isNoConfigError, loadAndResolveTokens, loadInternalConfig, loadSugarcubeConfig, processAndConvertTokens, userConfigSchema, validateConfig, writeCSSUtilitiesToDisk, writeCSSVariablesToDisk };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Ze=Object.defineProperty;var s=(e,t)=>Ze(e,"name",{value:t,configurable:!0});import{existsSync as X}from"node:fs";import Qe,{readFile as x,mkdir as de,writeFile as he}from"node:fs/promises";import{pathToFileURL as et}from"node:url";import{relative as C,resolve as b,isAbsolute as w,dirname as Z}from"pathe";import{glob as tt}from"tinyglobby";import{z as l}from"zod";const A={output:{cssRoot:"src/styles",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 W3C color object`,"INVALID_COLOR"),INVALID_DIMENSION:s((e,t)=>`Invalid dimension at '${t}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:s((e,t)=>`Invalid unit at ${t}': '${e}'. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:s((e,t)=>`Invalid font family at '${t}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:s((e,t)=>`Invalid font weight at '${t}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:s((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:s((e,t)=>`Invalid unit at ${t}: "${e}". Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:s((e,t)=>`Invalid cubic bezier at ${t}: "${e}". Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_STROKE_STYLE:s((e,t)=>`Invalid stroke style at ${t}: "${e}". Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:s((e,t)=>`Invalid line cap at ${t}: "${e}". Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:s((e,t)=>`Invalid border at ${t}: "${e}". Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:s((e,t)=>`Invalid shadow at ${t}: "${e}". Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:s((e,t)=>`Invalid inset value at ${t}: "${e}". Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:s((e,t)=>`Invalid transition at ${t}: "${e}". Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:s((e,t)=>`Invalid gradient at ${t}: "${e}". Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:s((e,t)=>`Invalid gradient stop position at ${t}: "${e}". Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:s((e,t)=>`Invalid typography at ${t}: "${e}". Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:s((e,t)=>`Missing required property '${e}' at ${t}`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:s((e,t)=>`Invalid number at ${t}: "${e}". Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:s((e,t)=>`Invalid array at ${t}: "${e}". Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:s(e=>`Missing fluid configuration. Token at ${e} requires fluid viewport settings.`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:s((e,t)=>`Invalid fluid dimension at ${t}: "${e}". Fluid dimensions should have min and max values, like { "min": { "value": 16, "unit": "px" }, "max": { "value": 24, "unit": "px" } }`,"INVALID_FLUID_DIMENSION"),INVALID_VIEWPORT_CONFIG:s((e,t)=>`Invalid viewport configuration at ${t}: "${e}". Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:s((e,t,n)=>`Mismatched units at ${n}: min uses '${e}', max uses '${t}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:s(e=>`Invalid fluid value range at ${e}: min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:s((e,t,n)=>`Invalid token type at ${n}: expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:s((e,t,n)=>`Expected ${e}, received ${typeof t} at ${n}`,"INVALID_TYPE"),INVALID_ENUM_VALUE:s((e,t,n)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${n}`,"INVALID_ENUM_VALUE")},RESOLVE:{CIRCULAR_REFERENCE:s((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:s((e,t)=>`Reference not found: ${e} in ${t}. Does ${e} exist?`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:s(e=>`Type mismatch in ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:s((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE"),INVALID_VARIABLE_NAME:s((e,t)=>`Invalid CSS variable name at '${e}': ${t}`,"INVALID_VARIABLE_NAME")},CONFIG:{INVALID_JSON:s(e=>`Invalid JSON in config file: ${e}`,"INVALID_JSON"),INVALID_CONFIG:s((e,t)=>`Invalid configuration at ${e}: ${t}`,"INVALID_CONFIG"),DUPLICATE_FILENAMES:s((e,t)=>`Duplicate filename "${e}":
1
+ var Ze=Object.defineProperty;var s=(e,t)=>Ze(e,"name",{value:t,configurable:!0});import{existsSync as X}from"node:fs";import Qe,{readFile as x,mkdir as de,writeFile as he}from"node:fs/promises";import{pathToFileURL as et}from"node:url";import{relative as C,resolve as b,isAbsolute as w,dirname as Z}from"pathe";import{glob as tt}from"tinyglobby";import{z as l}from"zod";function nt(e){return e}s(nt,"defineConfig");const A={output:{cssRoot:"src/styles",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 W3C color object`,"INVALID_COLOR"),INVALID_DIMENSION:s((e,t)=>`Invalid dimension at '${t}': ${e}. Dimensions should have a numeric value and unit, like { "value": 16, "unit": "px" }`,"INVALID_DIMENSION"),INVALID_DIMENSION_UNIT:s((e,t)=>`Invalid unit at ${t}': '${e}'. Unit must be either "px" or "rem"`,"INVALID_DIMENSION_UNIT"),INVALID_FONT_FAMILY:s((e,t)=>`Invalid font family at '${t}': ${e}. Should be a string or array of strings, like "Arial" or ["Arial", "sans-serif"]`,"INVALID_FONT_FAMILY"),INVALID_FONT_WEIGHT:s((e,t)=>`Invalid font weight at '${t}': ${e}. Should be a number between 1-1000 or a keyword like "thin", "light", "normal", "bold"`,"INVALID_FONT_WEIGHT"),INVALID_DURATION:s((e,t)=>`Invalid duration at '${t}': ${e}. Should be like { "value": 300, "unit": "ms" }`,"INVALID_DURATION"),INVALID_DURATION_UNIT:s((e,t)=>`Invalid unit at ${t}: "${e}". Unit must be "ms" or "s"`,"INVALID_DURATION_UNIT"),INVALID_CUBIC_BEZIER:s((e,t)=>`Invalid cubic bezier at ${t}: "${e}". Should be an array of 4 numbers between 0 and 1`,"INVALID_CUBIC_BEZIER"),INVALID_STROKE_STYLE:s((e,t)=>`Invalid stroke style at ${t}: "${e}". Should be "solid", "dashed", "dotted", etc.`,"INVALID_STROKE_STYLE"),INVALID_STROKE_LINE_CAP:s((e,t)=>`Invalid line cap at ${t}: "${e}". Should be one of: round, butt, square`,"INVALID_STROKE_LINE_CAP"),INVALID_BORDER:s((e,t)=>`Invalid border at ${t}: "${e}". Should have color, width, and style properties`,"INVALID_BORDER"),INVALID_SHADOW:s((e,t)=>`Invalid shadow at ${t}: "${e}". Should have color, offsetX, offsetY properties (blur and spread are optional)`,"INVALID_SHADOW"),INVALID_SHADOW_INSET:s((e,t)=>`Invalid inset value at ${t}: "${e}". Should be true or false`,"INVALID_SHADOW_INSET"),INVALID_TRANSITION:s((e,t)=>`Invalid transition at ${t}: "${e}". Should have duration, delay, and timingFunction properties`,"INVALID_TRANSITION"),INVALID_GRADIENT:s((e,t)=>`Invalid gradient at ${t}: "${e}". Should be an array of color stops with position values between 0 and 1`,"INVALID_GRADIENT"),INVALID_GRADIENT_STOP_POSITION:s((e,t)=>`Invalid gradient stop position at ${t}: "${e}". Position must be between 0 and 1`,"INVALID_GRADIENT_STOP_POSITION"),INVALID_TYPOGRAPHY:s((e,t)=>`Invalid typography at ${t}: "${e}". Should have fontFamily and fontSize (fontWeight, letterSpacing, and lineHeight are optional)`,"INVALID_TYPOGRAPHY"),MISSING_REQUIRED_PROPERTY:s((e,t)=>`Missing required property '${e}' at ${t}`,"MISSING_REQUIRED_PROPERTY"),INVALID_NUMBER:s((e,t)=>`Invalid number at ${t}: "${e}". Expected a number value`,"INVALID_NUMBER"),INVALID_ARRAY:s((e,t)=>`Invalid array at ${t}: "${e}". Expected an array value`,"INVALID_ARRAY"),MISSING_FLUID_CONFIG:s(e=>`Missing fluid configuration. Token at ${e} requires fluid viewport settings.`,"MISSING_FLUID_CONFIG"),INVALID_FLUID_DIMENSION:s((e,t)=>`Invalid fluid dimension at ${t}: "${e}". Fluid dimensions should have min and max values, like { "min": { "value": 16, "unit": "px" }, "max": { "value": 24, "unit": "px" } }`,"INVALID_FLUID_DIMENSION"),INVALID_VIEWPORT_CONFIG:s((e,t)=>`Invalid viewport configuration at ${t}: "${e}". Viewport config should have min and max dimension values`,"INVALID_VIEWPORT_CONFIG"),MISMATCHED_UNITS:s((e,t,n)=>`Mismatched units at ${n}: min uses '${e}', max uses '${t}'. Both values must use the same unit`,"MISMATCHED_UNITS"),INVALID_FLUID_VALUE_RANGE:s(e=>`Invalid fluid value range at ${e}: min value must be less than max value`,"INVALID_FLUID_VALUE_RANGE"),INVALID_TOKEN_TYPE:s((e,t,n)=>`Invalid token type at ${n}: expected ${e}, got ${t}`,"INVALID_TOKEN_TYPE"),INVALID_TYPE:s((e,t,n)=>`Expected ${e}, received ${typeof t} at ${n}`,"INVALID_TYPE"),INVALID_ENUM_VALUE:s((e,t,n)=>`Expected value to be one of [${e.join(", ")}], but got ${String(t)} at ${n}`,"INVALID_ENUM_VALUE")},RESOLVE:{CIRCULAR_REFERENCE:s((e,t)=>`Circular reference detected: ${e} -> ${t}`,"CIRCULAR_REFERENCE"),REFERENCE_NOT_FOUND:s((e,t)=>`Reference not found: ${e} in ${t}. Does ${e} exist?`,"REFERENCE_NOT_FOUND"),TYPE_MISMATCH:s(e=>`Type mismatch in ${e}`,"TYPE_MISMATCH")},GENERATE:{INVALID_CSS_VALUE:s((e,t)=>`Invalid CSS value for property '${e}': ${t}`,"INVALID_CSS_VALUE"),INVALID_VARIABLE_NAME:s((e,t)=>`Invalid CSS variable name at '${e}': ${t}`,"INVALID_VARIABLE_NAME")},CONFIG:{INVALID_JSON:s(e=>`Invalid JSON in config file: ${e}`,"INVALID_JSON"),INVALID_CONFIG:s((e,t)=>`Invalid configuration at ${e}: ${t}`,"INVALID_CONFIG"),DUPLICATE_FILENAMES:s((e,t)=>`Duplicate filename "${e}":
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,27 +9,27 @@ 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 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 Q(e){const n=await tt(["**/*.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:C(process.cwd(),r)}:{found:"multiple",paths:n.map(o=>C(process.cwd(),o))}}s(Q,"findResolverDocument");function F(e){const t=e.output?.cssRoot??A.output.cssRoot,n={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??A.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??A.transforms.colorFallbackStrategy},output:{cssRoot:t,variables:e.output?.variables??`${t}/global`,utilities:e.output?.utilities??`${t}/utilities`,cube:e.output?.cube??t,themeAttribute:e.output?.themeAttribute??A.output.themeAttribute,defaultContext:e.output?.defaultContext}};return(e.output?.components!==void 0||A.output.components!==void 0)&&(n.output.components=e.output?.components??A.output.components),e.utilities&&(n.utilities=e.utilities),n}s(F,"fillDefaults");const me=l.object({min:l.number(),max:l.number()}),Ie=l.object({source:l.string(),directions:l.union([l.enum(["top","right","bottom","left","x","y","full","all"]),l.array(l.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:l.string().optional(),stripDuplicates:l.boolean().optional()}),Ee=l.union([Ie,l.array(Ie)]),nt=l.object({resolver:l.string().optional(),transforms:l.object({fluid:me.optional(),colorFallbackStrategy:l.enum(["native","polyfill"]).optional()}).optional(),output:l.object({cssRoot:l.string().optional(),variables:l.string().optional(),utilities:l.string().optional(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string().optional(),defaultContext:l.string().optional()}).optional(),utilities:l.record(l.string(),Ee).optional()}),rt=l.object({resolver:l.string().optional(),transforms:l.object({fluid:me,colorFallbackStrategy:l.enum(["native","polyfill"])}),output:l.object({cssRoot:l.string(),variables:l.string().optional(),utilities:l.string().optional(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string(),defaultContext:l.string().optional()}),utilities:l.record(l.string(),Ee).optional()});function ee(e){const t=nt.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(ee,"validateSugarcubeConfig");function te(e){const t=rt.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(te,"validateInternalConfig");function ot(e){const t=ee(e),n=F(t);return te(n)}s(ot,"validateConfig");function st(e){return e instanceof Error&&e.message===u.CONFIG.NO_CONFIG_OR_RESOLVER()}s(st,"isNoConfigError");function ne(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=b(n,`${e}${r}`);if(X(o))return o}return null}s(ne,"findConfigFile");function it(e="sugarcube.config"){return ne(e)!==null}s(it,"configFileExists");async function at(e){try{if(typeof globalThis.Bun<"u"){const i=et(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(at,"loadTSConfig");async function ye(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await at(e);const n=await Qe.readFile(e,"utf-8");return JSON.parse(n)}s(ye,"loadConfigFile");function ct(e){if(e)return b(process.cwd(),e);const t=ne();if(!t)throw new Error(u.CONFIG.FILE_NOT_FOUND("sugarcube.config.ts"));return t}s(ct,"resolveConfigPath");async function ut(e){const t=ct(e);try{const n=await ye(t);return{config:ee(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(ut,"loadSugarcubeConfig");async function ft(e){const t=e?b(process.cwd(),e):ne();if(t)try{const r=await ye(t),o=ee(r);if(!o.resolver){const c=await Q(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=F(o);return{config:te(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 Q(process.cwd());if(n.found==="one"){const r={resolver:n.path},o=F(r);return{config:te(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(ft,"loadInternalConfig");function m(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(m,"isReference$1");function lt(e){if(typeof e!="object"||e===null||!("$value"in e))return!1;const t=e.$value;return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0}s(lt,"isCompositeToken");function pt(e){return e.$type==="typography"}s(pt,"isTypographyToken");function re(e){return typeof e=="object"&&e!==null&&"$value"in e}s(re,"isTokenNode");function dt(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!re(o)){if(i&&re(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(!re(i)){n.push({path:o.$path,source:o.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,f=i,p=!!c.$type,h=!!f.$type;if(p&&h&&c.$type!==f.$type){n.push({path:c.$path,source:c.$source,message:u.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(f.$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(dt,"mergeFlattenedInto");function ht(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(ht,"looksLikeUnprefixedToken");function mt(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=[],f){if(c.join("."),c.length>0){const d=o(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{context:t.context,sourcePath:t.sourcePath}}}const p=Object.keys(a).filter(d=>!d.startsWith("$")),h=a.$type||f;for(const d of p){const I=a[d],E=[...c,d],g=E.join(".");if(ht(I)){r.push({path:g,source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX(g)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:g,source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(Xe=>!Xe.startsWith("$")).length>0){r.push({path:g,source:t,message:u.FLATTEN.INVALID_TOKEN_NESTING(g)});continue}if(lt(I)&&!I.$type&&!h){r.push({path:g,source:t,message:u.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE(g)});continue}const pe=o(E),J=E.join(".");n.tokens[pe]={...I,...I.$type||h?{$type:I.$type||h}:{},$path:J,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:J},n.pathIndex.set(J,pe)}else i(I,E,h)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(mt,"flattenTree");function It(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=mt(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),dt(t,o,n)}return{tokens:t,errors:n}}s(It,"flatten");const V=l.string().min(1,"Name cannot be empty").refine(e=>!e.startsWith("$"),"Names must not start with '$' (reserved prefix)").refine(e=>!e.includes("{"),"Names must not contain '{'").refine(e=>!e.includes("}"),"Names must not contain '}'").refine(e=>!e.includes("."),"Names must not contain '.'"),ge=l.object({$ref:l.string().min(1,"$ref cannot be empty")}).passthrough(),oe=l.union([ge,l.record(l.string(),l.unknown())]),Et=l.object({description:l.string().optional(),sources:l.array(oe),$extensions:l.record(l.string(),l.unknown()).optional()}),$e=l.record(l.string(),l.array(oe)),yt=l.object({description:l.string().optional(),contexts:$e,default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),gt=l.object({type:l.literal("set"),name:V,sources:l.array(oe),description:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}),$t=l.object({type:l.literal("modifier"),name:V,contexts:$e,description:l.string().optional(),default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),Nt=l.union([ge,gt,$t]),St=l.record(V,Et),Tt=l.record(V,yt),bt=l.object({version:l.literal("2025.10"),name:l.string().optional(),description:l.string().optional(),sets:St.optional(),modifiers:Tt.optional(),resolutionOrder:l.array(Nt),$schema:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional(),$defs:l.record(l.string(),l.unknown()).optional()});function R(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(R,"isReference");function Ne(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(Ne,"isInlineSet");function _(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(_,"isInlineModifier");async function At(e){const t=w(e)?e:b(process.cwd(),e),n=await Ot(t);if(n.error)return{document:M(),errors:[n.error]};const r=Rt(n.content);if(r.error)return{document:M(),errors:[r.error]};const o=Dt(r.data);if(o.errors.length>0)return{document:M(),errors:o.errors};const i=[];return _t(o.document,i),{document:o.document,errors:i}}s(At,"parseResolverDocument");async function Ot(e){try{return{content:await x(e,"utf-8")}}catch{return{error:{path:e,message:u.RESOLVER.FILE_NOT_FOUND(e)}}}}s(Ot,"loadFile");function Rt(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(Rt,"parseJson");function Dt(e){const t=bt.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:M(),errors:n}}return{document:t.data,errors:[]}}s(Dt,"validateSchema$1");function _t(e,t){Lt(e,t),vt(e,t),xt(e,t)}s(_t,"validateDocument");function Lt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))Se(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];_(r)&&Se(r,`resolutionOrder[${n}]`,t)}}s(Lt,"validateModifierContexts");function Se(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(Se,"checkModifierContexts");function vt(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(R(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(vt,"validateNameUniqueness");function xt(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(R(r))Ct(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(Ne(r))k(r.sources,`resolutionOrder[${n}].sources`,t);else if(_(r))for(const[o,i]of Object.entries(r.contexts))k(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))k(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))k(i,`modifiers.${n}.contexts.${o}`,t)}s(xt,"validateReferences");function k(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!R(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],f=o[c];typeof f=="string"&&(f.includes("/")||f.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:u.RESOLVER.MALFORMED_REFERENCE(c,f)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:u.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(k,"validateSourcesReferences");function Ct(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(Ct,"validateReference");function M(){return{version:"2025.10",resolutionOrder:[]}}s(M,"createEmptyDocument");function Te(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(Te,"isResolverFormat");function be(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(be,"createResolveContext");async function Ae(e,t){if(t.visitedRefs.has(e))return S({},u.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?wt(e,t):e.includes("#/")?await Vt(e,t):await Ft(e,t)}finally{t.visitedRefs.delete(e)}}s(Ae,"resolveReference");function wt(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(wt,"resolveSameDocumentRef");async function Ft(e,t){const n=w(e)?e:b(t.basePath,e),r=t.fileCache.get(n);if(r)return Te(r)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await Oe(n);return o.error?S({},o.error,n):Te(o.content)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(Ft,"resolveFileRef");async function Vt(e,t){const[n="",r=""]=e.split("#"),o=w(n)?n:b(t.basePath,n);let i=t.fileCache.get(o);if(!i){const f=await Oe(o);if(f.error)return S({},f.error,o);i=f.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=kt(i,a);return c.error?S({},u.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(Vt,"resolveFileFragmentRef");async function Oe(e){try{const t=await x(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(Oe,"loadJsonFile");function kt(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(kt,"resolveJsonPointer");async function Re(e,t){const n=[],r=[];for(const o of e){if(!R(o)){n.push(o);continue}const i=await Ae(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(Mt(i.content,o))}return{resolved:n,errors:r}}s(Re,"resolveSources");function Mt(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(Mt,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function De(e){return typeof e=="object"&&e!==null&&"$value"in e}s(De,"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(De(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!De(i);n[r]=a?j(i,o):o}return n}s(j,"deepMerge");function _e(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=jt(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(_e,"extractModifiers");function jt(e,t,n){return R(e)&&e.$ref.startsWith("#/modifiers/")?Pt(e.$ref,t,n):_(e)?Ut(e,n):null}s(jt,"extractModifierFromItem");function Pt(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(Pt,"extractReferencedModifier");function Ut(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(Ut,"extractInlineModifier");function Gt(e,t={}){const n=[],r={},o=_e(e);if(o.length===0)return Wt(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return Bt(t,i,n,r),Yt(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(Gt,"validateInputs$1");function Wt(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:u.RESOLVER.UNKNOWN_MODIFIER(n)})}s(Wt,"validateNoModifiersCase");function Bt(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(Bt,"validateProvidedInputs");function Yt(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(Yt,"applyDefaults");async function Le(e,t,n={}){const r=Gt(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=be(e,t),i=Ht();for(const a of e.resolutionOrder)await Kt(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(Le,"processResolutionOrder");function Ht(){return{tokens:{},sources:[],errors:[]}}s(Ht,"createProcessingState");async function Kt(e,t,n,r,o){if(R(e)){await qt(e,t,n,r,o);return}if(Ne(e)){await zt(e,n,o);return}_(e)&&await Jt(e,n,r,o)}s(Kt,"processItem");async function qt(e,t,n,r,o){const i=await Ae(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 P(i.content.sources,n,{type:"set",name:a});U(c,o);return}if(e.$ref.startsWith("#/modifiers/")){const c=r[a];if(!c)return;const p=i.content.contexts[c];if(!p)return;const h=await P(p,n,{type:"modifier",name:a,context:c});U(h,o)}}}s(qt,"processReference");async function zt(e,t,n){const r=await P(e.sources,t,{type:"set",name:e.name});U(r,n)}s(zt,"processInlineSet");async function Jt(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await P(i,t,{type:"modifier",name:e.name,context:o});U(a,r)}s(Jt,"processInlineModifier");async function P(e,t,n){const r=await Re(e,t);let o={};for(const i of r.resolved)o=j(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(P,"mergeSources");function U(e,t){t.errors.push(...e.errors),t.tokens=j(t.tokens,e.tokens),t.sources.push(e.source)}s(U,"applyResult");async function Xt(e,t){const n=[],r=be(e,t),o=_e(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await Le(e,t,i);n.push(...a.errors);const c=a.tokens,f=[];for(const p of o){const h=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const E=await Zt(e,t,r,p.name,I,n);Object.keys(E).length>0&&h.set(I,E)}f.push({name:p.name,defaultContext:d,contexts:h})}return{base:c,modifiers:f,errors:n}}s(Xt,"processForLayeredCSS");async function Zt(e,t,n,r,o,i){const a=Qt(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const f=await Re(c,n);i.push(...f.errors.map(E=>({path:E.path,message:E.message})));let p={};for(const E of f.resolved)p=j(p,E);const h=new Set;ve(p,"",h);const d=await Le(e,t,{[r]:o});i.push(...d.errors);const I={};for(const E of h){const g=en(d.tokens,E);g!==void 0&&tn(I,E,g)}return I}s(Zt,"processModifierContext");function Qt(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(_(n)&&n.name===t)return n}s(Qt,"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 en(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(en,"getTokenAtPath");function tn(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(tn,"setTokenAtPath");async function nn(e){const t=w(e)?e:b(process.cwd(),e),n=Z(t),r=[],o=[],i=C(process.cwd(),t),a=await At(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await Xt(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 f=[];for(const p of c.modifiers){const h=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),h.push(d));f.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:h})}return{trees:o,modifiers:f,errors:r}}s(nn,"loadFromResolver");async function rn(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:C(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(rn,"loadTreesFromMemory");function G(e,t,n,r){return typeof t=="string"&&m(t)?sn(e,t,n,r):Array.isArray(t)?t.map(o=>G(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:G(`${e}.${a}`,c,n,r)}),{}):t}s(G,"resolveValue");function xe(e,t){const n=e.slice(1,-1),r=t.pathIndex.get(n);if(!r)return;const o=t.tokens[r];if(!(!o||!("$value"in o))){if(o.$type)return o.$type;if(typeof o.$value=="string"&&m(o.$value))return xe(o.$value,t)}}s(xe,"inferTypeFromReference");function on(e){const t={},n=new Set,r=[];for(const[o,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[o]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&m(a.$value)&&(c=xe(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:G(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),f=i,p=f.$path,h=f.$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:h,message:I})}return{resolved:t,errors:r}}s(on,"resolve");function sn(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 f=n.tokens[i];throw!f||!("$path"in f)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,f.$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=G(i,a.$value,n,r);return r.delete(i),c}s(sn,"resolveReferenceChain");function T(e){return{success:!0,value:e}}s(T,"success");function $(e){return{success:!1,error:e}}s($,"error");function se(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(se,"isDTCGColorValue");function W(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(W,"validateDTCGColorValue");function an(e){const t=W(e);return t.length>0?$(t.join(", ")):T(e)}s(an,"validateDTCGColorValueResult");function cn(e){const t=an(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)),f=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`oklch(${a} ${c} ${f} / ${p})`)}return T(`oklch(${a} ${c} ${f})`)}s(cn,"formatDTCGColorToOKLCH");const un={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function y(e,t,n,r){if(m(t))return[];switch(e.type){case"object":return ln(e,t,n,r);case"union":return pn(e,t,n,r);case"array":return dn(e,t,n,r);default:return fn(e,t,n,r)}}s(y,"validateSchema");function fn(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(fn,"validateSimpleValue");function ln(e,t,n,r){if(!un.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(ln,"validateObject");function pn(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(pn,"validateUnion");function dn(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(dn,"validateArray");const B={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)=>se(e)?W(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 hn(e,t,n){return y(B.schema,e,t,n)}s(hn,"validateColor");const Y={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 mn(e,t,n){return y(Y.schema,e,t,n)}s(mn,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:Y.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 In(e,t,n){return y(N.schema,e,t,n)}s(In,"validateDimension");const En=["solid","dashed","dotted","double","groove","ridge","outset","inset"],yn=["round","butt","square"],gn={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)=>yn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Ce={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!En.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},gn]}};function $n(e,t,n){return y(Ce.schema,e,t,n)}s($n,"validateStrokeStyle");const Nn={schema:{type:"object",properties:{color:B.schema,width:N.schema,style:Ce.schema},required:["color","width","style"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Sn(e,t,n){return y(Nn.schema,e,t,n)}s(Sn,"validateBorder");const we={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 Tn(e,t,n){return y(we.schema,e,t,n)}s(Tn,"validateCubicBezier");const bn=["ms","s"],ie={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:Y.schema,unit:{type:"string",validate:s((e,t,n)=>bn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function An(e,t,n){return y(ie.schema,e,t,n)}s(An,"validateDuration");const On={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 Rn(e,t,n){return y(On.schema,e,t,n)}s(Rn,"validateFluidDimension");const Fe={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 Dn(e,t,n){return y(Fe.schema,e,t,n)}s(Dn,"validateFontFamily");const _n=["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"],Ve={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)=>_n.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function Ln(e,t,n){return y(Ve.schema,e,t,n)}s(Ln,"validateFontWeight");const vn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:B.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"]},xn={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(vn,i,`${t}[${a}]`,n))}),o},"validate")}};function Cn(e,t,n){return y(xn.schema,e,t,n)}s(Cn,"validateGradient");const ke={schema:{type:"object",properties:{color:{type:"union",oneOf:[B.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 wn(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...y(ke.schema,o,`${t}[${i}]`,n))}),r):y(ke.schema,e,t,n)}s(wn,"validateShadow");const Fn={schema:{type:"object",properties:{duration:ie.schema,delay:ie.schema,timingFunction:we.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function Vn(e,t,n){return y(Fn.schema,e,t,n)}s(Vn,"validateTransition");const kn={schema:{type:"object",properties:{fontFamily:Fe.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:Y.schema,fontWeight:Ve.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function Mn(e,t,n){return y(kn.schema,e,t,n)}s(Mn,"validateTypography");const jn={color:hn,dimension:In,fluidDimension:Rn,duration:An,cubicBezier:Tn,fontFamily:Dn,fontWeight:Ln,number:mn,strokeStyle:$n,typography:Mn,border:Sn,shadow:wn,gradient:Cn,transition:Vn};function Pn(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=jn[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(Pn,"validate");async function Un(e){const{trees:t,modifiers:n,errors:r}=await Gn(e),{tokens:o,errors:i}=It(t),a=Pn(o),{resolved:c,errors:f}=on(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:f}}}s(Un,"loadAndResolveTokens");async function Gn(e){switch(e.type){case"memory":{const t=await rn(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await nn(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(Gn,"loadTokens");function Me(e){return m(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>m(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Me,"convertStrokeStyleToken");function Wn(e){if(m(e))return{value:e};const t=m(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(m(e.color),e.color),r=typeof e.style=="string"?e.style:Me(e.style).value;return{value:`${t} ${r} ${n}`}}s(Wn,"convertBorderToken");function je(e,t="native"){return se(e)?Bn(e):T(e)}s(je,"convertColorToString");function Bn(e){switch(e.colorSpace){case"oklch":return cn(e);case"display-p3":return Yn(e);case"srgb":return Hn(e);case"hsl":return Kn(e);default:return $(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(Bn,"formatDTCGColorNative");function Yn(e){if(e.colorSpace!=="display-p3")return $(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return $("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,r]=e.components,o=e.alpha;if(t!=="none"&&(t<0||t>1))return $("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return $("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return $("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return $("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4));if(o!==void 0&&o!==1){const f=Number(o.toFixed(4));return T(`color(display-p3 ${i} ${a} ${c} / ${f})`)}return T(`color(display-p3 ${i} ${a} ${c})`)}s(Yn,"formatDTCGColorToP3");function Hn(e){if(e.colorSpace!=="srgb")return $(`Expected srgb color space, got: ${e.colorSpace}`);const t=W(e);if(t.length>0)return $(`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),f=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`rgb(${a} ${c} ${f} / ${p})`)}return T(`rgb(${a} ${c} ${f})`)}s(Hn,"formatDTCGColorToRGB");function Kn(e){if(e.colorSpace!=="hsl")return $(`Expected hsl color space, got: ${e.colorSpace}`);const t=W(e);if(t.length>0)return $(`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),f=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,E=f==="none"?"none":`${f}%`;return T(`hsl(${a} ${I} ${E} / ${d})`)}const p=c==="none"?"none":`${c}%`,h=f==="none"?"none":`${f}%`;return T(`hsl(${a} ${p} ${h})`)}s(Kn,"formatDTCGColorToHSL");function qn(e,t){if(typeof e=="string"&&m(e))return{value:e};const n=t.colorFallbackStrategy;if(se(e))return zn(e,n);const r=je(e,n);return r.success?{value:r.value}:(console.warn(`[sugarcube] Failed to convert color ${typeof e=="string"?e:"DTCG color object"}: ${r.error}`),{value:typeof e=="string"?e:"#000000"})}s(qn,"convertColorToken");function zn(e,t){const n=je(e,t);if(!n.success)return console.warn(`[sugarcube] Failed to convert DTCG color: ${n.error}`),{value:"#000000"};const r=n.value;if(t==="native")return{value:r};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:r};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:Jn(e.colorSpace),value:r}]}}s(zn,"convertDTCGColorToken");function Jn(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(Jn,"getFeatureQuery");function Xn(e){return m(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(Xn,"convertCubicBezierToken");function Zn(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Zn,"convertDimensionToken");function Qn(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Qn,"convertDurationToken");function Pe(e,t=16){return e.unit==="px"?e.value:e.value*t}s(Pe,"normalizeToPixels");function er(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=Pe(n,i),c=Pe(r,i),f=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const h=a/i,d=c/i,I=f/i,E=p/i,g=(d-h)/(E-I),le=-1*I*g+h;return{value:`clamp(${h}rem, ${le.toFixed(2)}rem + ${(g*100).toFixed(2)}vw, ${d}rem)`}}s(er,"convertFluidDimension");function tr(e,t){return m(e)?{value:e}:er(e,t)}s(tr,"convertFluidDimensionToken");function H(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(H,"quoteFont");function nr(e){return m(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>H(n)).join(", "):H(e)}}s(nr,"convertFontFamilyToken");const rr={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 Ue(e){return m(e)?{value:e}:typeof e=="number"?{value:e}:{value:rr[e.toLowerCase()]??e}}s(Ue,"convertFontWeightToken");function or(e){return m(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const r=(m(n.color),n.color),o=m(n.position)?n.position:`${n.position*100}`;return`${r} ${o}%`}).join(", ")})`}}s(or,"convertGradientToken");function sr(e){return m(e)?{value:e}:{value:e}}s(sr,"convertNumberToken");function Ge(e){const t=m(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=m(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,r=m(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,o=m(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(m(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${r} ${o} ${i}`}s(Ge,"convertSingleShadow");function ir(e){return m(e)?{value:e}:Array.isArray(e)?{value:e.map(Ge).join(", ")}:{value:Ge(e)}}s(ir,"convertShadowToken");function We(e){return e?`${e.value}${e.unit}`:"0ms"}s(We,"formatDuration");function ar(e){if(m(e))return{value:e};const t=m(e.duration)?e.duration:We(e.duration),n=m(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(m(e.delay)?e.delay:We(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(ar,"convertTransitionToken");function cr(e){if(m(e))return{"font-family":e,"font-size":e};const t={"font-family":m(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>H(n)).join(", "):H(e.fontFamily),"font-size":m(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=m(e.fontWeight)?e.fontWeight:Ue(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=m(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(m(e.lineHeight),e.lineHeight)),t}s(cr,"convertTypographyToken");const Be={duration:Qn,number:sr,cubicBezier:Xn,color:qn,dimension:Zn,fluidDimension:tr,typography:cr,border:Wn,shadow:ir,gradient:or,transition:ar,strokeStyle:Me,fontFamily:nr,fontWeight:Ue};function ur(e,t){const n=Be[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(ur,"convertSingleToken");function fr(e,t,n){const r={};for(const[o,i]of Object.entries(e)){if(!i||typeof i!="object")continue;if(!("$type"in i)){r[o]={...i.$description?{$description:i.$description}:{},...i.$extensions?{$extensions:i.$extensions}:{}};continue}if(n?.(i.$path)||!Be[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=ur(i,a)}return r}s(fr,"convertTokens");function lr(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=fr(i,t,n);return r}s(lr,"convert");function pr(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[f,p]of Object.entries(a))n[c][f]=p}return{tokens:n,defaultContext:t}}s(pr,"normalizeTokens");function dr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const f=c.context??"";n.has(f)||n.set(f,{});const p=n.get(f);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(dr,"processTrees");async function hr(e,t,n,r){const o=dr(e,t),{tokens:i}=pr(o);return lr(i,n,r?f=>r.some(p=>p.path===f||p.path.startsWith(`${f}.`)):void 0)}s(hr,"processAndConvertTokens");function mr(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(mr,"deterministicEntries");const Ye=new Map;function Ir(e){const t=Ye.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 Ye.set(e,n),n}s(Ir,"toKebabCase");function ae(e){return e.split(".").join("-")}s(ae,"formatCSSVarPath");function ce(e){return typeof e=="number"?e:typeof e!="string"?(console.warn("[sugarcube] Unexpected value type in convertReferenceToCSSVar:",e),String(e)):e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(Ir).join("-")})`)}s(ce,"convertReferenceToCSSVar");function Er(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ae(e.$path)}`,value:ce(t.value)}}s(Er,"generateSingleVariable");function yr(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ae(e.$path)}-${t}`,value:ce(n)}))}s(yr,"generateTypographyVariables");function He(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:`--${ae(e.$path)}`,value:ce(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(He,"generateFeatureVariables");function Ke(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 Q(e){const n=await tt(["**/*.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:C(process.cwd(),r)}:{found:"multiple",paths:n.map(o=>C(process.cwd(),o))}}s(Q,"findResolverDocument");function F(e){const t=e.output?.cssRoot??A.output.cssRoot,n={resolver:e.resolver,transforms:{fluid:e.transforms?.fluid??A.transforms.fluid,colorFallbackStrategy:e.transforms?.colorFallbackStrategy??A.transforms.colorFallbackStrategy},output:{cssRoot:t,variables:e.output?.variables??`${t}/global`,utilities:e.output?.utilities??`${t}/utilities`,cube:e.output?.cube??t,themeAttribute:e.output?.themeAttribute??A.output.themeAttribute,defaultContext:e.output?.defaultContext}};return(e.output?.components!==void 0||A.output.components!==void 0)&&(n.output.components=e.output?.components??A.output.components),e.utilities&&(n.utilities=e.utilities),n}s(F,"fillDefaults");const me=l.object({min:l.number(),max:l.number()}),Ie=l.object({source:l.string(),directions:l.union([l.enum(["top","right","bottom","left","x","y","full","all"]),l.array(l.enum(["top","right","bottom","left","x","y","full","all"]))]).optional(),prefix:l.string().optional(),stripDuplicates:l.boolean().optional()}),Ee=l.union([Ie,l.array(Ie)]),rt=l.object({resolver:l.string().optional(),transforms:l.object({fluid:me.optional(),colorFallbackStrategy:l.enum(["native","polyfill"]).optional()}).optional(),output:l.object({cssRoot:l.string().optional(),variables:l.string().optional(),utilities:l.string().optional(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string().optional(),defaultContext:l.string().optional()}).optional(),utilities:l.record(l.string(),Ee).optional()}),ot=l.object({resolver:l.string().optional(),transforms:l.object({fluid:me,colorFallbackStrategy:l.enum(["native","polyfill"])}),output:l.object({cssRoot:l.string(),variables:l.string().optional(),utilities:l.string().optional(),cube:l.string().optional(),components:l.string().optional(),themeAttribute:l.string(),defaultContext:l.string().optional()}),utilities:l.record(l.string(),Ee).optional()});function ee(e){const t=rt.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(ee,"validateSugarcubeConfig");function te(e){const t=ot.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(te,"validateInternalConfig");function st(e){const t=ee(e),n=F(t);return te(n)}s(st,"validateConfig");function it(e){return e instanceof Error&&e.message===u.CONFIG.NO_CONFIG_OR_RESOLVER()}s(it,"isNoConfigError");function ne(e="sugarcube.config"){const t=[".ts",".js"],n=process.cwd();for(const r of t){const o=b(n,`${e}${r}`);if(X(o))return o}return null}s(ne,"findConfigFile");function at(e="sugarcube.config"){return ne(e)!==null}s(at,"configFileExists");async function ct(e){try{if(typeof globalThis.Bun<"u"){const i=et(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(ct,"loadTSConfig");async function ye(e){if(e.endsWith(".ts")||e.endsWith(".js"))return await ct(e);const n=await Qe.readFile(e,"utf-8");return JSON.parse(n)}s(ye,"loadConfigFile");function ut(e){if(e)return b(process.cwd(),e);const t=ne();if(!t)throw new Error(u.CONFIG.FILE_NOT_FOUND("sugarcube.config.ts"));return t}s(ut,"resolveConfigPath");async function ft(e){const t=ut(e);try{const n=await ye(t);return{config:ee(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(ft,"loadSugarcubeConfig");async function lt(e){const t=e?b(process.cwd(),e):ne();if(t)try{const r=await ye(t),o=ee(r);if(!o.resolver){const c=await Q(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=F(o);return{config:te(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 Q(process.cwd());if(n.found==="one"){const r={resolver:n.path},o=F(r);return{config:te(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(lt,"loadInternalConfig");function m(e){return typeof e=="string"&&e.startsWith("{")&&e.endsWith("}")}s(m,"isReference$1");function pt(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(pt,"isCompositeToken");function dt(e){return e.$type==="typography"}s(dt,"isTypographyToken");function re(e){return typeof e=="object"&&e!==null&&"$value"in e}s(re,"isTokenNode");function ht(e,t,n){for(const[r,o]of Object.entries(t.tokens)){const i=e.tokens[r];if(!re(o)){if(i&&re(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(!re(i)){n.push({path:o.$path,source:o.$source,message:u.FLATTEN.CONFLICT_TOKEN_VS_GROUP(o.$path)});continue}const c=o,f=i,p=!!c.$type,h=!!f.$type;if(p&&h&&c.$type!==f.$type){n.push({path:c.$path,source:c.$source,message:u.FLATTEN.CONFLICT_INCOMPATIBLE_TYPES(String(f.$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(ht,"mergeFlattenedInto");function mt(e){if(typeof e!="object"||e===null||"$value"in e)return!1;const t="value"in e,n="type"in e;if(t&&n)return!0;if(t){const r=e.value;return typeof r=="string"||typeof r=="number"||Array.isArray(r)}return!1}s(mt,"looksLikeUnprefixedToken");function It(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=[],f){if(c.join("."),c.length>0){const d=o(c);n.tokens[d]={$description:a.$description,$extensions:a.$extensions,$path:c.join("."),$source:{context:t.context,sourcePath:t.sourcePath}}}const p=Object.keys(a).filter(d=>!d.startsWith("$")),h=a.$type||f;for(const d of p){const I=a[d],E=[...c,d],g=E.join(".");if(mt(I)){r.push({path:g,source:t,message:u.FLATTEN.MISSING_DOLLAR_PREFIX(g)});continue}if(d.includes(".")||d.includes("{")||d.includes("}")){r.push({path:g,source:t,message:u.FLATTEN.INVALID_TOKEN_NAME(d)});continue}if("$value"in I){if(Object.keys(I).filter(Xe=>!Xe.startsWith("$")).length>0){r.push({path:g,source:t,message:u.FLATTEN.INVALID_TOKEN_NESTING(g)});continue}if(pt(I)&&!I.$type&&!h){r.push({path:g,source:t,message:u.FLATTEN.COMPOSITE_TOKEN_MISSING_TYPE(g)});continue}const pe=o(E),J=E.join(".");n.tokens[pe]={...I,...I.$type||h?{$type:I.$type||h}:{},$path:J,$source:{context:t.context,sourcePath:t.sourcePath},$originalPath:J},n.pathIndex.set(J,pe)}else i(I,E,h)}}return s(i,"processNode"),i(e),{tokens:n,errors:r}}s(It,"flattenTree");function Et(e){const t={tokens:{},pathIndex:new Map},n=[];for(const r of e){const{tokens:o,errors:i}=It(r.tokens,{context:r.context,sourcePath:r.sourcePath});n.push(...i),ht(t,o,n)}return{tokens:t,errors:n}}s(Et,"flatten");const V=l.string().min(1,"Name cannot be empty").refine(e=>!e.startsWith("$"),"Names must not start with '$' (reserved prefix)").refine(e=>!e.includes("{"),"Names must not contain '{'").refine(e=>!e.includes("}"),"Names must not contain '}'").refine(e=>!e.includes("."),"Names must not contain '.'"),ge=l.object({$ref:l.string().min(1,"$ref cannot be empty")}).passthrough(),oe=l.union([ge,l.record(l.string(),l.unknown())]),yt=l.object({description:l.string().optional(),sources:l.array(oe),$extensions:l.record(l.string(),l.unknown()).optional()}),$e=l.record(l.string(),l.array(oe)),gt=l.object({description:l.string().optional(),contexts:$e,default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),$t=l.object({type:l.literal("set"),name:V,sources:l.array(oe),description:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}),Nt=l.object({type:l.literal("modifier"),name:V,contexts:$e,description:l.string().optional(),default:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional()}).refine(e=>Object.keys(e.contexts).length>=1,"Modifier must have at least 1 context"),St=l.union([ge,$t,Nt]),Tt=l.record(V,yt),bt=l.record(V,gt),At=l.object({version:l.literal("2025.10"),name:l.string().optional(),description:l.string().optional(),sets:Tt.optional(),modifiers:bt.optional(),resolutionOrder:l.array(St),$schema:l.string().optional(),$extensions:l.record(l.string(),l.unknown()).optional(),$defs:l.record(l.string(),l.unknown()).optional()});function R(e){return typeof e=="object"&&e!==null&&"$ref"in e&&typeof e.$ref=="string"}s(R,"isReference");function Ne(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="set"}s(Ne,"isInlineSet");function _(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="modifier"}s(_,"isInlineModifier");async function Ot(e){const t=w(e)?e:b(process.cwd(),e),n=await Rt(t);if(n.error)return{document:M(),errors:[n.error]};const r=Dt(n.content);if(r.error)return{document:M(),errors:[r.error]};const o=_t(r.data);if(o.errors.length>0)return{document:M(),errors:o.errors};const i=[];return Lt(o.document,i),{document:o.document,errors:i}}s(Ot,"parseResolverDocument");async function Rt(e){try{return{content:await x(e,"utf-8")}}catch{return{error:{path:e,message:u.RESOLVER.FILE_NOT_FOUND(e)}}}}s(Rt,"loadFile");function Dt(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(Dt,"parseJson");function _t(e){const t=At.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:M(),errors:n}}return{document:t.data,errors:[]}}s(_t,"validateSchema$1");function Lt(e,t){vt(e,t),xt(e,t),Ct(e,t)}s(Lt,"validateDocument");function vt(e,t){if(e.modifiers)for(const[n,r]of Object.entries(e.modifiers))Se(r,`modifiers.${n}`,t);for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];_(r)&&Se(r,`resolutionOrder[${n}]`,t)}}s(vt,"validateModifierContexts");function Se(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(Se,"checkModifierContexts");function xt(e,t){const n=new Set;for(let r=0;r<e.resolutionOrder.length;r++){const o=e.resolutionOrder[r];if(R(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(xt,"validateNameUniqueness");function Ct(e,t){for(let n=0;n<e.resolutionOrder.length;n++){const r=e.resolutionOrder[n];if(R(r))wt(r.$ref,`resolutionOrder[${n}].$ref`,e,t);else if(Ne(r))k(r.sources,`resolutionOrder[${n}].sources`,t);else if(_(r))for(const[o,i]of Object.entries(r.contexts))k(i,`resolutionOrder[${n}].contexts.${o}`,t)}if(e.sets)for(const[n,r]of Object.entries(e.sets))k(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))k(i,`modifiers.${n}.contexts.${o}`,t)}s(Ct,"validateReferences");function k(e,t,n){for(let r=0;r<e.length;r++){const o=e[r];if(!o)continue;if(!R(o)){const a=Object.keys(o);if(a.length===1){const c=a[0],f=o[c];typeof f=="string"&&(f.includes("/")||f.endsWith(".json"))&&n.push({path:`${t}[${r}]`,message:u.RESOLVER.MALFORMED_REFERENCE(c,f)})}continue}const i=o.$ref;i.startsWith("#/")&&(i.match(/^#\/sets\/[^/]+$/)||n.push({path:`${t}[${r}].$ref`,message:u.RESOLVER.INVALID_SOURCE_REFERENCE(i)}))}}s(k,"validateSourcesReferences");function wt(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(wt,"validateReference");function M(){return{version:"2025.10",resolutionOrder:[]}}s(M,"createEmptyDocument");function Te(e){if(typeof e!="object"||e===null)return!1;const t=e;return t.version==="2025.10"&&Array.isArray(t.resolutionOrder)}s(Te,"isResolverFormat");function be(e,t){return{document:e,basePath:t,visitedRefs:new Set,fileCache:new Map}}s(be,"createResolveContext");async function Ae(e,t){if(t.visitedRefs.has(e))return S({},u.RESOLVER.CIRCULAR_REFERENCE(e),e);t.visitedRefs.add(e);try{return e.startsWith("#/")?Ft(e,t):e.includes("#/")?await kt(e,t):await Vt(e,t)}finally{t.visitedRefs.delete(e)}}s(Ae,"resolveReference");function Ft(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(Ft,"resolveSameDocumentRef");async function Vt(e,t){const n=w(e)?e:b(t.basePath,e),r=t.fileCache.get(n);if(r)return Te(r)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):{content:r,sourcePath:n,errors:[]};const o=await Oe(n);return o.error?S({},o.error,n):Te(o.content)?S({},u.RESOLVER.RESOLVER_AS_TOKEN_SOURCE(n),n):(t.fileCache.set(n,o.content),{content:o.content,sourcePath:n,errors:[]})}s(Vt,"resolveFileRef");async function kt(e,t){const[n="",r=""]=e.split("#"),o=w(n)?n:b(t.basePath,n);let i=t.fileCache.get(o);if(!i){const f=await Oe(o);if(f.error)return S({},f.error,o);i=f.content,t.fileCache.set(o,i)}const a=r.startsWith("/")?r:`/${r}`,c=Mt(i,a);return c.error?S({},u.RESOLVER.INVALID_JSON_POINTER(a,c.error),o):{content:c.value,sourcePath:o,errors:[]}}s(kt,"resolveFileFragmentRef");async function Oe(e){try{const t=await x(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(Oe,"loadJsonFile");function Mt(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(Mt,"resolveJsonPointer");async function Re(e,t){const n=[],r=[];for(const o of e){if(!R(o)){n.push(o);continue}const i=await Ae(o.$ref,t);r.push(...i.errors),i.errors.length===0&&n.push(jt(i.content,o))}return{resolved:n,errors:r}}s(Re,"resolveSources");function jt(e,t){const{$ref:n,...r}=t;return Object.keys(r).length===0?e:{...e,...r}}s(jt,"applyExtending");function S(e,t,n="#"){return{content:e,sourcePath:n,errors:[{path:n,message:t}]}}s(S,"errorResult");function De(e){return typeof e=="object"&&e!==null&&"$value"in e}s(De,"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(De(o)){n[r]=o;continue}const i=n[r],a=i!==void 0&&typeof i=="object"&&i!==null&&typeof o=="object"&&o!==null&&!De(i);n[r]=a?j(i,o):o}return n}s(j,"deepMerge");function _e(e){const t=[],n=new Set;for(const r of e.resolutionOrder){const o=Pt(r,e,n);o&&(t.push(o),n.add(o.name))}return t}s(_e,"extractModifiers");function Pt(e,t,n){return R(e)&&e.$ref.startsWith("#/modifiers/")?Ut(e.$ref,t,n):_(e)?Gt(e,n):null}s(Pt,"extractModifierFromItem");function Ut(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(Ut,"extractReferencedModifier");function Gt(e,t){return t.has(e.name)?null:{name:e.name,contexts:Object.keys(e.contexts),default:e.default}}s(Gt,"extractInlineModifier");function Wt(e,t={}){const n=[],r={},o=_e(e);if(o.length===0)return Bt(t,n),{valid:n.length===0,errors:n,resolvedInputs:r};const i=new Map(o.map(a=>[a.name,a]));return Yt(t,i,n,r),Ht(o,r,n),{valid:n.length===0,errors:n,resolvedInputs:r}}s(Wt,"validateInputs$1");function Bt(e,t){for(const n of Object.keys(e))t.push({modifier:n,message:u.RESOLVER.UNKNOWN_MODIFIER(n)})}s(Bt,"validateNoModifiersCase");function Yt(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(Yt,"validateProvidedInputs");function Ht(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(Ht,"applyDefaults");async function Le(e,t,n={}){const r=Wt(e,n);if(!r.valid)return{tokens:{},sources:[],errors:r.errors.map(a=>({path:a.modifier||"inputs",message:a.message}))};const o=be(e,t),i=Kt();for(const a of e.resolutionOrder)await qt(a,e,o,r.resolvedInputs,i);return{tokens:i.tokens,sources:i.sources,errors:i.errors}}s(Le,"processResolutionOrder");function Kt(){return{tokens:{},sources:[],errors:[]}}s(Kt,"createProcessingState");async function qt(e,t,n,r,o){if(R(e)){await zt(e,t,n,r,o);return}if(Ne(e)){await Jt(e,n,o);return}_(e)&&await Xt(e,n,r,o)}s(qt,"processItem");async function zt(e,t,n,r,o){const i=await Ae(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 P(i.content.sources,n,{type:"set",name:a});U(c,o);return}if(e.$ref.startsWith("#/modifiers/")){const c=r[a];if(!c)return;const p=i.content.contexts[c];if(!p)return;const h=await P(p,n,{type:"modifier",name:a,context:c});U(h,o)}}}s(zt,"processReference");async function Jt(e,t,n){const r=await P(e.sources,t,{type:"set",name:e.name});U(r,n)}s(Jt,"processInlineSet");async function Xt(e,t,n,r){const o=n[e.name];if(!o)return;const i=e.contexts[o];if(!i)return;const a=await P(i,t,{type:"modifier",name:e.name,context:o});U(a,r)}s(Xt,"processInlineModifier");async function P(e,t,n){const r=await Re(e,t);let o={};for(const i of r.resolved)o=j(o,i);return{tokens:o,source:{path:"#",...n},errors:r.errors}}s(P,"mergeSources");function U(e,t){t.errors.push(...e.errors),t.tokens=j(t.tokens,e.tokens),t.sources.push(e.source)}s(U,"applyResult");async function Zt(e,t){const n=[],r=be(e,t),o=_e(e),i={};for(const p of o)p.default&&(i[p.name]=p.default);const a=await Le(e,t,i);n.push(...a.errors);const c=a.tokens,f=[];for(const p of o){const h=new Map,d=p.default??p.contexts[0]??"default";for(const I of p.contexts){if(I===d)continue;const E=await Qt(e,t,r,p.name,I,n);Object.keys(E).length>0&&h.set(I,E)}f.push({name:p.name,defaultContext:d,contexts:h})}return{base:c,modifiers:f,errors:n}}s(Zt,"processForLayeredCSS");async function Qt(e,t,n,r,o,i){const a=en(e,r);if(!a)return{};const c=a.contexts[o];if(!c||c.length===0)return{};const f=await Re(c,n);i.push(...f.errors.map(E=>({path:E.path,message:E.message})));let p={};for(const E of f.resolved)p=j(p,E);const h=new Set;ve(p,"",h);const d=await Le(e,t,{[r]:o});i.push(...d.errors);const I={};for(const E of h){const g=tn(d.tokens,E);g!==void 0&&nn(I,E,g)}return I}s(Qt,"processModifierContext");function en(e,t){if(e.modifiers?.[t])return e.modifiers[t];for(const n of e.resolutionOrder)if(_(n)&&n.name===t)return n}s(en,"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 tn(e,t){const n=t.split(".");let r=e;for(const o of n){if(r===null||typeof r!="object")return;r=r[o]}return r}s(tn,"getTokenAtPath");function nn(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(nn,"setTokenAtPath");async function rn(e){const t=w(e)?e:b(process.cwd(),e),n=Z(t),r=[],o=[],i=C(process.cwd(),t),a=await Ot(t);if(a.errors.length>0)return{trees:[],modifiers:[],errors:a.errors.map(p=>({file:p.path,message:p.message}))};const c=await Zt(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 f=[];for(const p of c.modifiers){const h=[];for(const[d,I]of p.contexts)Object.keys(I).length>0&&(o.push({context:`${p.name}:${d}`,tokens:I,sourcePath:i}),h.push(d));f.push({name:p.name,attribute:`data-${p.name}`,defaultContext:p.defaultContext,contexts:h})}return{trees:o,modifiers:f,errors:r}}s(rn,"loadFromResolver");async function on(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:C(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(on,"loadTreesFromMemory");function G(e,t,n,r){return typeof t=="string"&&m(t)?an(e,t,n,r):Array.isArray(t)?t.map(o=>G(e,o,n,r)):typeof t=="object"&&t!==null?Object.entries(t).reduce((i,[a,c])=>Object.assign(i,{[a]:G(`${e}.${a}`,c,n,r)}),{}):t}s(G,"resolveValue");function xe(e,t){const n=e.slice(1,-1),r=t.pathIndex.get(n);if(!r)return;const o=t.tokens[r];if(!(!o||!("$value"in o))){if(o.$type)return o.$type;if(typeof o.$value=="string"&&m(o.$value))return xe(o.$value,t)}}s(xe,"inferTypeFromReference");function sn(e){const t={},n=new Set,r=[];for(const[o,i]of Object.entries(e.tokens))try{if(!("$value"in i)){t[o]=i;continue}const a=i;let c=a.$type;!c&&typeof a.$value=="string"&&m(a.$value)&&(c=xe(a.$value,e)),t[o]={...a,...c?{$type:c}:{},$resolvedValue:G(a.$path,a.$value,e,n)}}catch(a){const c=a instanceof Error?a.message:String(a),f=i,p=f.$path,h=f.$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:h,message:I})}return{resolved:t,errors:r}}s(sn,"resolve");function an(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 f=n.tokens[i];throw!f||!("$path"in f)?new Error(u.RESOLVE.REFERENCE_NOT_FOUND(o,e)):new Error(u.RESOLVE.CIRCULAR_REFERENCE(e,f.$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=G(i,a.$value,n,r);return r.delete(i),c}s(an,"resolveReferenceChain");function T(e){return{success:!0,value:e}}s(T,"success");function $(e){return{success:!1,error:e}}s($,"error");function se(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(se,"isDTCGColorValue");function W(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(W,"validateDTCGColorValue");function cn(e){const t=W(e);return t.length>0?$(t.join(", ")):T(e)}s(cn,"validateDTCGColorValueResult");function un(e){const t=cn(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)),f=o==="none"?"none":Number(o.toFixed(4));if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`oklch(${a} ${c} ${f} / ${p})`)}return T(`oklch(${a} ${c} ${f})`)}s(un,"formatDTCGColorToOKLCH");const fn={isObject:s(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isObject")};function y(e,t,n,r){if(m(t))return[];switch(e.type){case"object":return pn(e,t,n,r);case"union":return dn(e,t,n,r);case"array":return hn(e,t,n,r);default:return ln(e,t,n,r)}}s(y,"validateSchema");function ln(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(ln,"validateSimpleValue");function pn(e,t,n,r){if(!fn.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(pn,"validateObject");function dn(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(dn,"validateUnion");function hn(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(hn,"validateArray");const B={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)=>se(e)?W(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 mn(e,t,n){return y(B.schema,e,t,n)}s(mn,"validateColor");const Y={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 In(e,t,n){return y(Y.schema,e,t,n)}s(In,"validateNumber");const N={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DIMENSION(e,t),"errorMessage"),properties:{value:Y.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 En(e,t,n){return y(N.schema,e,t,n)}s(En,"validateDimension");const yn=["solid","dashed","dotted","double","groove","ridge","outset","inset"],gn=["round","butt","square"],$n={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)=>gn.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_STROKE_LINE_CAP(e,t),source:n}],"validate")}},required:["dashArray","lineCap"]},Ce={schema:{type:"union",oneOf:[{type:"string",validate:s((e,t,n)=>!yn.includes(e)&&typeof e=="string"?[{path:t,message:u.VALIDATE.INVALID_STROKE_STYLE(e,t),source:n}]:[],"validate")},$n]}};function Nn(e,t,n){return y(Ce.schema,e,t,n)}s(Nn,"validateStrokeStyle");const Sn={schema:{type:"object",properties:{color:B.schema,width:N.schema,style:Ce.schema},required:["color","width","style"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_BORDER(e,t),"errorMessage")}};function Tn(e,t,n){return y(Sn.schema,e,t,n)}s(Tn,"validateBorder");const we={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 bn(e,t,n){return y(we.schema,e,t,n)}s(bn,"validateCubicBezier");const An=["ms","s"],ie={schema:{type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_DURATION(e,t),"errorMessage"),properties:{value:Y.schema,unit:{type:"string",validate:s((e,t,n)=>An.includes(e)?[]:[{path:t,message:u.VALIDATE.INVALID_DURATION_UNIT(e,t),source:n}],"validate")}},required:["value","unit"]}};function On(e,t,n){return y(ie.schema,e,t,n)}s(On,"validateDuration");const Rn={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 Dn(e,t,n){return y(Rn.schema,e,t,n)}s(Dn,"validateFluidDimension");const Fe={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 _n(e,t,n){return y(Fe.schema,e,t,n)}s(_n,"validateFontFamily");const Ln=["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"],Ve={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)=>Ln.includes(e.toLowerCase())?[]:[{path:t,message:u.VALIDATE.INVALID_FONT_WEIGHT(e,t),source:n}],"validate")}]}};function vn(e,t,n){return y(Ve.schema,e,t,n)}s(vn,"validateFontWeight");const xn={type:"object",errorMessage:s((e,t)=>u.VALIDATE.INVALID_GRADIENT(e,t),"errorMessage"),properties:{color:B.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"]},Cn={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(xn,i,`${t}[${a}]`,n))}),o},"validate")}};function wn(e,t,n){return y(Cn.schema,e,t,n)}s(wn,"validateGradient");const ke={schema:{type:"object",properties:{color:{type:"union",oneOf:[B.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 Fn(e,t,n){const r=[];return Array.isArray(e)?(e.forEach((o,i)=>{r.push(...y(ke.schema,o,`${t}[${i}]`,n))}),r):y(ke.schema,e,t,n)}s(Fn,"validateShadow");const Vn={schema:{type:"object",properties:{duration:ie.schema,delay:ie.schema,timingFunction:we.schema},required:["duration","delay","timingFunction"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TRANSITION(e,t),"errorMessage")}};function kn(e,t,n){return y(Vn.schema,e,t,n)}s(kn,"validateTransition");const Mn={schema:{type:"object",properties:{fontFamily:Fe.schema,fontSize:N.schema,letterSpacing:N.schema,lineHeight:Y.schema,fontWeight:Ve.schema},required:["fontFamily","fontSize"],errorMessage:s((e,t)=>u.VALIDATE.INVALID_TYPOGRAPHY(e,t),"errorMessage")}};function jn(e,t,n){return y(Mn.schema,e,t,n)}s(jn,"validateTypography");const Pn={color:mn,dimension:En,fluidDimension:Dn,duration:On,cubicBezier:bn,fontFamily:_n,fontWeight:vn,number:In,strokeStyle:Nn,typography:jn,border:Tn,shadow:Fn,gradient:wn,transition:kn};function Un(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=Pn[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(Un,"validate");async function Gn(e){const{trees:t,modifiers:n,errors:r}=await Wn(e),{tokens:o,errors:i}=Et(t),a=Un(o),{resolved:c,errors:f}=sn(o);return{trees:t,resolved:c,modifiers:n,errors:{load:r,flatten:i,validation:a,resolution:f}}}s(Gn,"loadAndResolveTokens");async function Wn(e){switch(e.type){case"memory":{const t=await on(e.data);return{trees:t.trees,modifiers:[],errors:t.errors}}case"resolver":{const t=await rn(e.resolverPath);return{trees:t.trees,modifiers:t.modifiers,errors:t.errors}}}}s(Wn,"loadTokens");function Me(e){return m(e)?{value:e}:typeof e=="string"?{value:e}:{value:`${e.dashArray.map(n=>m(n)?n:`${n.value}${n.unit}`).join(" ")} ${e.lineCap}`}}s(Me,"convertStrokeStyleToken");function Bn(e){if(m(e))return{value:e};const t=m(e.width)?e.width:`${e.width.value}${e.width.unit}`,n=(m(e.color),e.color),r=typeof e.style=="string"?e.style:Me(e.style).value;return{value:`${t} ${r} ${n}`}}s(Bn,"convertBorderToken");function je(e,t="native"){return se(e)?Yn(e):T(e)}s(je,"convertColorToString");function Yn(e){switch(e.colorSpace){case"oklch":return un(e);case"display-p3":return Hn(e);case"srgb":return Kn(e);case"hsl":return qn(e);default:return $(`Unsupported color space: ${e.colorSpace}. Supported color spaces: oklch, display-p3, srgb, hsl.`)}}s(Yn,"formatDTCGColorNative");function Hn(e){if(e.colorSpace!=="display-p3")return $(`Expected display-p3 color space, got: ${e.colorSpace}`);if(!Array.isArray(e.components)||e.components.length!==3)return $("Display P3 components must be an array of exactly 3 numbers [R, G, B]");const[t,n,r]=e.components,o=e.alpha;if(t!=="none"&&(t<0||t>1))return $("Display P3 Red component must be between 0 and 1 or 'none'");if(n!=="none"&&(n<0||n>1))return $("Display P3 Green component must be between 0 and 1 or 'none'");if(r!=="none"&&(r<0||r>1))return $("Display P3 Blue component must be between 0 and 1 or 'none'");if(o!==void 0&&(o<0||o>1))return $("Alpha must be between 0 and 1");const i=t==="none"?"none":Number(t.toFixed(4)),a=n==="none"?"none":Number(n.toFixed(4)),c=r==="none"?"none":Number(r.toFixed(4));if(o!==void 0&&o!==1){const f=Number(o.toFixed(4));return T(`color(display-p3 ${i} ${a} ${c} / ${f})`)}return T(`color(display-p3 ${i} ${a} ${c})`)}s(Hn,"formatDTCGColorToP3");function Kn(e){if(e.colorSpace!=="srgb")return $(`Expected srgb color space, got: ${e.colorSpace}`);const t=W(e);if(t.length>0)return $(`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),f=o==="none"?"none":Math.round(o*255);if(i!==void 0&&i!==1){const p=Number(i.toFixed(4));return T(`rgb(${a} ${c} ${f} / ${p})`)}return T(`rgb(${a} ${c} ${f})`)}s(Kn,"formatDTCGColorToRGB");function qn(e){if(e.colorSpace!=="hsl")return $(`Expected hsl color space, got: ${e.colorSpace}`);const t=W(e);if(t.length>0)return $(`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),f=o==="none"?"none":Math.round(o);if(i!==void 0&&i!==1){const d=Number(i.toFixed(4)),I=c==="none"?"none":`${c}%`,E=f==="none"?"none":`${f}%`;return T(`hsl(${a} ${I} ${E} / ${d})`)}const p=c==="none"?"none":`${c}%`,h=f==="none"?"none":`${f}%`;return T(`hsl(${a} ${p} ${h})`)}s(qn,"formatDTCGColorToHSL");function zn(e,t){if(typeof e=="string"&&m(e))return{value:e};const n=t.colorFallbackStrategy;if(se(e))return Jn(e,n);const r=je(e,n);return r.success?{value:r.value}:(console.warn(`[sugarcube] Failed to convert color ${typeof e=="string"?e:"DTCG color object"}: ${r.error}`),{value:typeof e=="string"?e:"#000000"})}s(zn,"convertColorToken");function Jn(e,t){const n=je(e,t);if(!n.success)return console.warn(`[sugarcube] Failed to convert DTCG color: ${n.error}`),{value:"#000000"};const r=n.value;if(t==="native")return{value:r};if(e.colorSpace==="srgb"||e.colorSpace==="hsl")return{value:r};if(!e.hex)throw new Error(`${e.colorSpace} colors require a 'hex' fallback when using 'polyfill' strategy. Tip: Switch to 'native' strategy if targeting modern browsers only.`);return{value:e.hex,featureValues:[{query:Xn(e.colorSpace),value:r}]}}s(Jn,"convertDTCGColorToken");function Xn(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(Xn,"getFeatureQuery");function Zn(e){return m(e)?{value:e}:{value:`cubic-bezier(${e.join(", ")})`}}s(Zn,"convertCubicBezierToken");function Qn(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(Qn,"convertDimensionToken");function er(e){return m(e)?{value:e}:{value:`${e.value}${e.unit}`}}s(er,"convertDurationToken");function Pe(e,t=16){return e.unit==="px"?e.value:e.value*t}s(Pe,"normalizeToPixels");function tr(e,t){const{min:n,max:r}=e,o=t.fluidConfig,i=16,a=Pe(n,i),c=Pe(r,i),f=o.min,p=o.max;if(a===c)return{value:`${a/i}rem`};const h=a/i,d=c/i,I=f/i,E=p/i,g=(d-h)/(E-I),le=-1*I*g+h;return{value:`clamp(${h}rem, ${le.toFixed(2)}rem + ${(g*100).toFixed(2)}vw, ${d}rem)`}}s(tr,"convertFluidDimension");function nr(e,t){return m(e)?{value:e}:tr(e,t)}s(nr,"convertFluidDimensionToken");function H(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(H,"quoteFont");function rr(e){return m(e)?{value:e}:{value:Array.isArray(e)?e.map(n=>H(n)).join(", "):H(e)}}s(rr,"convertFontFamilyToken");const or={thin:100,hairline:100,"extra-light":200,"ultra-light":200,light:300,normal:400,regular:400,book:400,medium:500,"semi-bold":600,"demi-bold":600,bold:700,"extra-bold":800,"ultra-bold":800,black:900,heavy:900,"extra-black":950,"ultra-black":950};function Ue(e){return m(e)?{value:e}:typeof e=="number"?{value:e}:{value:or[e.toLowerCase()]??e}}s(Ue,"convertFontWeightToken");function sr(e){return m(e)?{value:e}:{value:`linear-gradient(${e.map(n=>{const r=(m(n.color),n.color),o=m(n.position)?n.position:`${n.position*100}`;return`${r} ${o}%`}).join(", ")})`}}s(sr,"convertGradientToken");function ir(e){return m(e)?{value:e}:{value:e}}s(ir,"convertNumberToken");function Ge(e){const t=m(e.offsetX)?e.offsetX:`${e.offsetX.value}${e.offsetX.unit}`,n=m(e.offsetY)?e.offsetY:`${e.offsetY.value}${e.offsetY.unit}`,r=m(e.blur)?e.blur:`${e.blur.value}${e.blur.unit}`,o=m(e.spread)?e.spread:`${e.spread.value}${e.spread.unit}`,i=(m(e.color),e.color);return`${e.inset?"inset ":""}${t} ${n} ${r} ${o} ${i}`}s(Ge,"convertSingleShadow");function ar(e){return m(e)?{value:e}:Array.isArray(e)?{value:e.map(Ge).join(", ")}:{value:Ge(e)}}s(ar,"convertShadowToken");function We(e){return e?`${e.value}${e.unit}`:"0ms"}s(We,"formatDuration");function cr(e){if(m(e))return{value:e};const t=m(e.duration)?e.duration:We(e.duration),n=m(e.timingFunction)?e.timingFunction:`cubic-bezier(${e.timingFunction.join(", ")})`,r=e.delay&&(m(e.delay)?e.delay:We(e.delay));return{value:[t,n,r].filter(Boolean).join(" ")}}s(cr,"convertTransitionToken");function ur(e){if(m(e))return{"font-family":e,"font-size":e};const t={"font-family":m(e.fontFamily)?e.fontFamily:Array.isArray(e.fontFamily)?e.fontFamily.map(n=>H(n)).join(", "):H(e.fontFamily),"font-size":m(e.fontSize)?e.fontSize:`${e.fontSize.value}${e.fontSize.unit}`};return e.fontWeight&&(t["font-weight"]=m(e.fontWeight)?e.fontWeight:Ue(e.fontWeight).value),e.letterSpacing&&(t["letter-spacing"]=m(e.letterSpacing)?e.letterSpacing:`${e.letterSpacing.value}${e.letterSpacing.unit}`),e.lineHeight&&(t["line-height"]=(m(e.lineHeight),e.lineHeight)),t}s(ur,"convertTypographyToken");const Be={duration:er,number:ir,cubicBezier:Zn,color:zn,dimension:Qn,fluidDimension:nr,typography:ur,border:Bn,shadow:ar,gradient:sr,transition:cr,strokeStyle:Me,fontFamily:rr,fontWeight:Ue};function fr(e,t){const n=Be[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(fr,"convertSingleToken");function lr(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)||!Be[i.$type])continue;const a={fluidConfig:t.transforms.fluid,colorFallbackStrategy:t.transforms.colorFallbackStrategy,path:i.$path,resolvedTokens:e};r[o]=fr(i,a)}return r}s(lr,"convertTokens");function pr(e,t,n){const r={};for(const[o,i]of Object.entries(e))r[o]=lr(i,t,n);return r}s(pr,"convert");function dr(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[f,p]of Object.entries(a))n[c][f]=p}return{tokens:n,defaultContext:t}}s(dr,"normalizeTokens");function hr(e,t){const n=new Map;for(const[r,o]of Object.entries(t)){if(!("$source"in o)){for(const c of e){const f=c.context??"";n.has(f)||n.set(f,{});const p=n.get(f);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(hr,"processTrees");async function mr(e,t,n,r){const o=hr(e,t),{tokens:i}=dr(o);return pr(i,n,r?f=>r.some(p=>p.path===f||p.path.startsWith(`${f}.`)):void 0)}s(mr,"processAndConvertTokens");function Ir(e){return Object.entries(e).sort(([t],[n])=>t.localeCompare(n))}s(Ir,"deterministicEntries");const Ye=new Map;function Er(e){const t=Ye.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 Ye.set(e,n),n}s(Er,"toKebabCase");function ae(e){return e.split(".").join("-")}s(ae,"formatCSSVarPath");function ce(e){return typeof e=="number"?e:typeof e!="string"?(console.warn("[sugarcube] Unexpected value type in convertReferenceToCSSVar:",e),String(e)):e.replace(/\{([^}]+)\}/g,(t,n)=>`var(--${n.split(".").map(Er).join("-")})`)}s(ce,"convertReferenceToCSSVar");function yr(e){const t=e.$cssProperties;if("value"in t)return{name:`--${ae(e.$path)}`,value:ce(t.value)}}s(yr,"generateSingleVariable");function gr(e){return Object.entries(e.$cssProperties).filter(([t,n])=>n!==void 0).map(([t,n])=>({name:`--${ae(e.$path)}-${t}`,value:ce(n)}))}s(gr,"generateTypographyVariables");function He(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:`--${ae(e.$path)}`,value:ce(r.value)})}return Array.from(n.entries()).map(([r,o])=>({query:r,vars:o}))}s(He,"generateFeatureVariables");function Ke(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(Ke,"generateCSSBlock");function gr(e){const t=[];e.root.vars.length>0&&t.push(Ke({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const o=Ke({selector:e.root.selector,vars:n.vars}).split(`
16
+ `)}s(Ke,"generateCSSBlock");function $r(e){const t=[];e.root.vars.length>0&&t.push(Ke({selector:e.root.selector,vars:e.root.vars}));for(const n of e.features){const o=Ke({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(gr,"convertCSSVarsToString");function $r(e){if(pt(e))return{vars:yr(e),features:He(e)};const t=Er(e);return{vars:t?[t]:[],features:He(e)}}s($r,"generateVariablesForToken");function Nr(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(f=>f.name===o)?.attribute??`data-${o}`}="${i}"]`}return`[${n.output.themeAttribute}="${e}"]`}s(Nr,"buildSelector");async function Sr(e,t,n){const r=mr(e).filter(([h,d])=>h!=="$extensions"&&"$type"in d).map(([h,d])=>$r(d)),o=Nr(n.context,n.modifiers,t),i=r.flatMap(h=>h.vars),a=r.flatMap(h=>h.features||[]),c=new Map;for(const h of a){c.has(h.query)||c.set(h.query,[]);const d=c.get(h.query);d&&d.push(...h.vars)}const f=Array.from(c.entries()).map(([h,d])=>({query:h,vars:d})),p=gr({root:{selector:o,vars:i},features:f});return p.trim()?{output:[{path:"tokens.variables.gen.css",css:Tr(p)}]}:{output:[{path:"tokens.variables.gen.css",css:""}]}}s(Sr,"generateCSS");function Tr(e){return e.endsWith(`
22
+ `)}s($r,"convertCSSVarsToString");function Nr(e){if(dt(e))return{vars:gr(e),features:He(e)};const t=yr(e);return{vars:t?[t]:[],features:He(e)}}s(Nr,"generateVariablesForToken");function Sr(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(f=>f.name===o)?.attribute??`data-${o}`}="${i}"]`}return`[${n.output.themeAttribute}="${e}"]`}s(Sr,"buildSelector");async function Tr(e,t,n){const r=Ir(e).filter(([h,d])=>h!=="$extensions"&&"$type"in d).map(([h,d])=>Nr(d)),o=Sr(n.context,n.modifiers,t),i=r.flatMap(h=>h.vars),a=r.flatMap(h=>h.features||[]),c=new Map;for(const h of a){c.has(h.query)||c.set(h.query,[]);const d=c.get(h.query);d&&d.push(...h.vars)}const f=Array.from(c.entries()).map(([h,d])=>({query:h,vars:d})),p=$r({root:{selector:o,vars:i},features:f});return p.trim()?{output:[{path:"tokens.variables.gen.css",css:br(p)}]}:{output:[{path:"tokens.variables.gen.css",css:""}]}}s(Tr,"generateCSS");function br(e){return e.endsWith(`
23
23
  `)?e:`${e}
24
- `}s(Tr,"formatCSSVars");async function br(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 f=await Sr(c,t,{context:a,modifiers:n});f.output[0].css.trim()&&o.push(f.output[0].css)}return o.length===0?[]:[{path:`${r}/tokens.variables.gen.css`,css:`${o.filter(Boolean).join(`
24
+ `}s(br,"formatCSSVars");async function Ar(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 f=await Tr(c,t,{context:a,modifiers:n});f.output[0].css.trim()&&o.push(f.output[0].css)}return o.length===0?[]:[{path:`${r}/tokens.variables.gen.css`,css:`${o.filter(Boolean).join(`
25
25
  `).trim()}
26
- `}]}s(br,"generateSingleFile");async function Ar(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await br(r,t,n)}}s(Ar,"generate");async function Or(e,t,n){const{output:r}=await Ar(e,t,n);return r}s(Or,"generateCSSVariables");const L="--",O="-",Rr=["all","full"],Dr={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},_r={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function Lr(e){return Dr[e]}s(Lr,"getDirectionAbbreviation");function qe(e,t){if(t==="full"||t==="all")return e;const n=_r[t];return n?`${e}${O}${n}`:e}s(qe,"getLogicalProperty");const vr=["top","right","bottom","left","x","y","full"];function xr(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?vr:[n])}s(xr,"expandDirections");function Cr(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(Cr,"isTokenTypeValidForProperty");const ze=new WeakMap,D=new Map;function wr(){D.clear()}s(wr,"clearMatchCache");function Fr(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(Fr,"buildPathIndex");function Vr(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(Vr,"getDefaultContextTokens");function K(e,t,n){const r=`${t.source}:${t.prefix??""}:${t.property??""}:${e}`;if(D.has(r))return D.get(r)??null;const o=[t.source.replace("*",e),t.source.replace("*",e.split("-").join("."))];if(t.stripDuplicates&&t.prefix){const c=t.source.lastIndexOf(".*");if(c!==-1){const f=t.source.slice(0,c);f&&o.push(`${f}.${t.prefix}.${e}`,`${f}.${t.prefix}.${e.split("-").join(".")}`)}}const i=Vr(n);if(!i)return D.set(r,null),null;const a=Fr(i);for(const c of o){const f=a.get(c);if(f){if(t.property&&f.$type&&!Cr(f.$type,t.property))continue;const p=f.$path.split(".");return D.set(r,p),p}}return D.set(r,null),null}s(K,"findMatchingToken");function ue(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(ue,"stripDuplicatePrefix");function q(e,t=""){const n=e??"",r=n||t?O:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(q,"createUtilityPattern");function fe(e,t,n){return[q(t.prefix),o=>{const i=o[1];if(!i)return{};const a=ue(i,t),c={...t,property:e},f=K(a,c,n);return f?{[e]:`var(${L}${f.join(O)})`}:{}}]}s(fe,"createSimpleRule");function kr(e,t,n,r){if(n==="all")return fe(e,t,r);const o=Lr(n);return[q(t.prefix,o),a=>{const c=a[1];if(!c)return{};const f=ue(c,t),p={...t,property:e},h=K(f,p,r);return h?{[qe(e,n)]:`var(${L}${h.join(O)})`}:{}}]}s(kr,"createDirectionalRule");function Mr(e,t){return[q(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:f}of t){const p=ue(o,a),h={...a,property:i},d=K(p,h,f);if(d)return c?{[qe(i,c)]:`var(${L}${d.join(O)})`}:{[i]:`var(${L}${d.join(O)})`}}return{}}]}s(Mr,"createSmartRule");function jr(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[q(o),a=>{const c=a[1];if(!c)return{};const f={...t,property:e},p=K(c,f,n);return p?{[e]:`var(${L}${p.join(O)})`}:{}}]}s(jr,"createDirectTokenPathRule");function Pr(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(Pr,"validateUtilityConfig");function Ur(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(Ur,"validateInputs");function Gr(e,t){Ur(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(Pr(c,o),c.prefix){const f=c.prefix;r[f]||(r[f]=[]),r[f].push({property:o,config:c,direction:null,tokens:t})}else{const f=jr(o,c,t);n.push(f)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:f,tokens:p}=a;if(f.directions){const h=xr(f.directions);(Array.isArray(f.directions)?f.directions:[f.directions]).includes("all")&&n.push(fe(c,f,p));for(const E of h)Rr.includes(E)||n.push(kr(c,f,E,p))}else n.push(fe(c,f,p))}else n.push(Mr(o,i));return n}s(Gr,"convertConfigToUnoRules");const v=process.env.SUGARCUBE_PERF==="true";class Wr{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(!v)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(!v)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){v&&this.log("WATCHER SETUP: Adding watch pattern",{pattern:t,dir:n})}logModuleGraphStats(t,n,r){v&&this.log(`MODULE GRAPH (${r})`,{modules:t,urls:n})}startMemoryMonitor(){!v||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 Je 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 Br=process.env.DEBUG==="true";class Yr{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
26
+ `}]}s(Ar,"generateSingleFile");async function Or(e,t,n){const r={};for(const[o,i]of Object.entries(e))Object.keys(i).length>0&&(r[o]=i);return{output:await Ar(r,t,n)}}s(Or,"generate");async function Rr(e,t,n){const{output:r}=await Or(e,t,n);return r}s(Rr,"generateCSSVariables");const L="--",O="-",Dr=["all","full"],_r={top:"t",right:"r",bottom:"b",left:"l",x:"x",y:"y",full:"",all:""},Lr={top:"block-start",right:"inline-end",bottom:"block-end",left:"inline-start",x:"inline",y:"block"};function vr(e){return _r[e]}s(vr,"getDirectionAbbreviation");function qe(e,t){if(t==="full"||t==="all")return e;const n=Lr[t];return n?`${e}${O}${n}`:e}s(qe,"getLogicalProperty");const xr=["top","right","bottom","left","x","y","full"];function Cr(e){return(Array.isArray(e)?e:[e]).flatMap(n=>n==="all"?xr:[n])}s(Cr,"expandDirections");function wr(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(wr,"isTokenTypeValidForProperty");const ze=new WeakMap,D=new Map;function Fr(){D.clear()}s(Fr,"clearMatchCache");function Vr(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(Vr,"buildPathIndex");function kr(e){if(e.default)return e.default;const t=Object.keys(e);return t.length>0&&t[0]?e[t[0]]:null}s(kr,"getDefaultContextTokens");function K(e,t,n){const r=`${t.source}:${t.prefix??""}:${t.property??""}:${e}`;if(D.has(r))return D.get(r)??null;const o=[t.source.replace("*",e),t.source.replace("*",e.split("-").join("."))];if(t.stripDuplicates&&t.prefix){const c=t.source.lastIndexOf(".*");if(c!==-1){const f=t.source.slice(0,c);f&&o.push(`${f}.${t.prefix}.${e}`,`${f}.${t.prefix}.${e.split("-").join(".")}`)}}const i=kr(n);if(!i)return D.set(r,null),null;const a=Vr(i);for(const c of o){const f=a.get(c);if(f){if(t.property&&f.$type&&!wr(f.$type,t.property))continue;const p=f.$path.split(".");return D.set(r,p),p}}return D.set(r,null),null}s(K,"findMatchingToken");function ue(e,t){return t.stripDuplicates&&t.prefix&&e.startsWith(`${t.prefix}-`)?e.slice(t.prefix.length+1):e}s(ue,"stripDuplicatePrefix");function q(e,t=""){const n=e??"",r=n||t?O:"";return new RegExp(`^${n}${t}${r}(.+)$`)}s(q,"createUtilityPattern");function fe(e,t,n){return[q(t.prefix),o=>{const i=o[1];if(!i)return{};const a=ue(i,t),c={...t,property:e},f=K(a,c,n);return f?{[e]:`var(${L}${f.join(O)})`}:{}}]}s(fe,"createSimpleRule");function Mr(e,t,n,r){if(n==="all")return fe(e,t,r);const o=vr(n);return[q(t.prefix,o),a=>{const c=a[1];if(!c)return{};const f=ue(c,t),p={...t,property:e},h=K(f,p,r);return h?{[qe(e,n)]:`var(${L}${h.join(O)})`}:{}}]}s(Mr,"createDirectionalRule");function jr(e,t){return[q(e),r=>{const o=r[1];if(!o)return{};for(const{property:i,config:a,direction:c,tokens:f}of t){const p=ue(o,a),h={...a,property:i},d=K(p,h,f);if(d)return c?{[qe(i,c)]:`var(${L}${d.join(O)})`}:{[i]:`var(${L}${d.join(O)})`}}return{}}]}s(jr,"createSmartRule");function Pr(e,t,n){const r=t.source.indexOf("."),o=r!==-1?t.source.slice(0,r):t.source;return[q(o),a=>{const c=a[1];if(!c)return{};const f={...t,property:e},p=K(c,f,n);return p?{[e]:`var(${L}${p.join(O)})`}:{}}]}s(Pr,"createDirectTokenPathRule");function Ur(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(Ur,"validateUtilityConfig");function Gr(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(Gr,"validateInputs");function Wr(e,t){Gr(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(Ur(c,o),c.prefix){const f=c.prefix;r[f]||(r[f]=[]),r[f].push({property:o,config:c,direction:null,tokens:t})}else{const f=Pr(o,c,t);n.push(f)}}for(const[o,i]of Object.entries(r))if(i.length===1){const a=i[0];if(!a)continue;const{property:c,config:f,tokens:p}=a;if(f.directions){const h=Cr(f.directions);(Array.isArray(f.directions)?f.directions:[f.directions]).includes("all")&&n.push(fe(c,f,p));for(const E of h)Dr.includes(E)||n.push(Mr(c,f,E,p))}else n.push(fe(c,f,p))}else n.push(jr(o,i));return n}s(Wr,"convertConfigToUnoRules");const v=process.env.SUGARCUBE_PERF==="true";class Br{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(!v)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(!v)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){v&&this.log("WATCHER SETUP: Adding watch pattern",{pattern:t,dir:n})}logModuleGraphStats(t,n,r){v&&this.log(`MODULE GRAPH (${r})`,{modules:t,urls:n})}startMemoryMonitor(){!v||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 Je 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 Yr=process.env.DEBUG==="true";class Hr{static{s(this,"Instrumentation")}constructor(t=n=>void process.stderr.write(`${n}
28
28
  `)){this.defaultFlush=t}#n=new Je(()=>({value:0}));#t=new Je(()=>({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](){Br&&this.report()}}const Hr=`/*!
32
+ `)}[Symbol.dispose](){Yr&&this.report()}}const Kr=`/*!
33
33
  * This file was automatically generated by sugarcube.
34
34
  * You should NOT make any changes in this file as it will be overwritten.
35
35
  * To make changes, edit your design token files instead.
@@ -37,7 +37,7 @@ ${n.join(`
37
37
  * to prevent it from being checked or modified.
38
38
  */
39
39
 
40
- `,Kr=`/*!
40
+ `,qr=`/*!
41
41
  * This file was automatically generated by sugarcube.
42
42
  * You should NOT make any changes in this file as it will be overwritten.
43
43
  * To make changes, edit your utilities configuration instead.
@@ -47,4 +47,4 @@ ${n.join(`
47
47
 
48
48
  `;function z(e){return e.replace(/\r\n/g,`
49
49
  `).replace(/\r/g,`
50
- `).trim()}s(z,"normalizeContent");function qr(e){return Hr+e}s(qr,"addWarningBanner");async function zr(e){for(const t of e){const n=qr(t.css);try{await de(Z(t.path),{recursive:!0});let r=!0;if(X(t.path))try{const o=await x(t.path,"utf-8");z(o)===z(n)&&(r=!1)}catch{}r&&await he(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(zr,"writeCSSVariablesToDisk");async function Jr(e){for(const t of e){const n=Kr+t.css;try{await de(Z(t.path),{recursive:!0});let r=!0;if(X(t.path))try{const o=await x(t.path,"utf-8");z(o)===z(n)&&(r=!1)}catch{}r&&await he(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write utility CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Jr,"writeCSSUtilitiesToDisk");export{A as DEFAULT_CONFIG,Yr as Instrumentation,Wr as PerfMonitor,wr as clearMatchCache,it as configFileExists,Gr as convertConfigToUnoRules,F as fillDefaults,Q as findResolverDocument,Or as generateCSSVariables,st as isNoConfigError,Un as loadAndResolveTokens,ft as loadInternalConfig,ut as loadSugarcubeConfig,hr as processAndConvertTokens,ot as validateConfig,Jr as writeCSSUtilitiesToDisk,zr as writeCSSVariablesToDisk};
50
+ `).trim()}s(z,"normalizeContent");function zr(e){return Kr+e}s(zr,"addWarningBanner");async function Jr(e){for(const t of e){const n=zr(t.css);try{await de(Z(t.path),{recursive:!0});let r=!0;if(X(t.path))try{const o=await x(t.path,"utf-8");z(o)===z(n)&&(r=!1)}catch{}r&&await he(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Jr,"writeCSSVariablesToDisk");async function Xr(e){for(const t of e){const n=qr+t.css;try{await de(Z(t.path),{recursive:!0});let r=!0;if(X(t.path))try{const o=await x(t.path,"utf-8");z(o)===z(n)&&(r=!1)}catch{}r&&await he(t.path,n,"utf-8")}catch(r){throw new Error(`Failed to write utility CSS file ${t.path}: ${r instanceof Error?r.message:"Unknown error"}`)}}return e}s(Xr,"writeCSSUtilitiesToDisk");export{A as DEFAULT_CONFIG,Hr as Instrumentation,Br as PerfMonitor,Fr as clearMatchCache,at as configFileExists,Wr as convertConfigToUnoRules,nt as defineConfig,F as fillDefaults,Q as findResolverDocument,Rr as generateCSSVariables,it as isNoConfigError,Gn as loadAndResolveTokens,lt as loadInternalConfig,ft as loadSugarcubeConfig,mr as processAndConvertTokens,st as validateConfig,Xr as writeCSSUtilitiesToDisk,Jr as writeCSSVariablesToDisk};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sugarcube-org/core",
3
- "version": "0.1.0-alpha.20",
3
+ "version": "0.1.0-alpha.21",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": false