import type { BuildHookOptions, Config, Logger, TokenTransformed } from '@terrazzo/parser'; import { generateShorthand, makeCSSVar } from '@terrazzo/token-tools/css'; import { addDeclUnique, cachedMatcher, createSubValueIdFormatter, type CSSDeclaration, type CSSPluginOptions, type CSSRule, decl, FORMAT_ID, getIndentFromPrepare, isSelfReference, PLUGIN_NAME, printRules, rule, } from './lib.js'; import generateUtilityCSS from './utility-css.js'; const P3_MQ = '@media (color-gamut: p3)'; const REC2020_MQ = '@media (color-gamut: rec2020)'; /** * Get description from metadata with fallback to token.$description * Preserves the descriptions and alias descriptions. */ function getDescription(token: any): string | undefined { return token.meta?.['plugin-css']?.description ?? token.token.$description; } export interface BuildFormatOptions { logger: Logger; include: CSSPluginOptions['include']; exclude: CSSPluginOptions['exclude']; getTransforms: BuildHookOptions['getTransforms']; modeSelectors: CSSPluginOptions['modeSelectors']; alphabetize?: Config['alphabetize']; permutations: CSSPluginOptions['permutations']; utility: CSSPluginOptions['utility']; baseSelector: string; baseScheme: CSSPluginOptions['baseScheme']; propertyDefinitions: boolean; omitTypographyShorthand: CSSPluginOptions['omitTypographyShorthand']; subValueVariableName: CSSPluginOptions['subValueVariableName']; } const TOKEN_TYPE_SYNTAX: Record = { color: '', dimension: '', duration: '