@homebound/truss 2.0.8 → 2.0.10
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/build/index.js +6 -0
- package/build/index.js.map +1 -1
- package/build/plugin/index.js +28 -1
- package/build/plugin/index.js.map +1 -1
- package/build/runtime.js +5 -0
- package/build/runtime.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/transform.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/ast-utils.ts","../../src/plugin/emit-stylex.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts","../../src/plugin/css-ts-utils.ts","../../src/plugin/rewrite-css-ts-imports.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\";\nimport { resolve, dirname, isAbsolute } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport { transformTruss } from \"./transform\";\nimport { transformCssTs } from \"./transform-css\";\nimport { rewriteCssTsImports } from \"./rewrite-css-ts-imports\";\n\nexport interface TrussPluginOptions {\n /** Path to the Css.json mapping file used for transforming files (relative to project root or absolute). */\n mapping: string;\n /** Packages in `node_modules` that should also be transformed, all other `node_modules` files are skipped. */\n externalPackages?: string[];\n}\n\nexport interface TrussVitePlugin {\n name: string;\n enforce?: \"pre\" | \"post\";\n configResolved?: (config: { root: string; command?: string; mode?: string }) => void;\n buildStart?: () => void;\n resolveId?: (source: string, importer: string | undefined) => string | null;\n load?: (id: string) => string | null;\n transform?: (code: string, id: string) => { code: string; map: any } | null;\n}\n\n/** Prefix for virtual CSS module IDs generated from .css.ts files. */\nconst VIRTUAL_CSS_PREFIX = \"\\0truss-css:\";\nconst CSS_TS_QUERY = \"?truss-css\";\n\n/**\n * Vite plugin that transforms `Css.*.$` expressions from truss's CssBuilder DSL\n * into file-local `stylex.create()` + `stylex.props()` calls.\n *\n * Also supports `.css.ts` files: a `.css.ts` file with\n * `export const css = { \".selector\": Css.blue.$ }` can keep other runtime exports,\n * while imports are supplemented with a virtual CSS side-effect module.\n *\n * Must be placed BEFORE the StyleX unplugin in the plugins array so that\n * StyleX's babel plugin can process the generated `stylex.create()` calls.\n */\nexport function trussPlugin(opts: TrussPluginOptions): TrussVitePlugin {\n let mapping: TrussMapping | null = null;\n let projectRoot: string;\n let debug = false;\n const externalPackages = opts.externalPackages ?? [];\n\n function mappingPath(): string {\n return resolve(projectRoot || process.cwd(), opts.mapping);\n }\n\n // Some tooling can call `transform` before `buildStart`; this keeps behavior\n // resilient without requiring hook ordering assumptions.\n function ensureMapping(): TrussMapping {\n if (!mapping) {\n mapping = loadMapping(mappingPath());\n }\n return mapping;\n }\n\n return {\n name: \"truss-stylex\",\n enforce: \"pre\",\n\n configResolved(config: { root: string; command?: string; mode?: string }) {\n projectRoot = config.root;\n debug = config.command === \"serve\" || config.mode === \"development\" || config.mode === \"test\";\n },\n\n buildStart() {\n ensureMapping();\n },\n\n resolveId(source: string, importer: string | undefined) {\n if (!source.endsWith(CSS_TS_QUERY)) return null;\n\n const absolutePath = resolveImportPath(source.slice(0, -CSS_TS_QUERY.length), importer, projectRoot);\n\n // Only handle it if the .css.ts file actually exists\n if (!existsSync(absolutePath)) return null;\n\n // Return a virtual CSS module ID that maps back to the source .css.ts file.\n // Strip the trailing `.ts` so the ID ends in `.css` — this tells Vite to\n // route the loaded content through its CSS pipeline.\n return VIRTUAL_CSS_PREFIX + absolutePath.slice(0, -3);\n },\n\n load(id: string) {\n if (!id.startsWith(VIRTUAL_CSS_PREFIX)) return null;\n\n // Re-add `.ts` to recover the original source file path\n const sourcePath = id.slice(VIRTUAL_CSS_PREFIX.length) + \".ts\";\n const sourceCode = readFileSync(sourcePath, \"utf8\");\n return transformCssTs(sourceCode, sourcePath, ensureMapping());\n },\n\n transform(code: string, id: string) {\n // Only process JS/TS/JSX/TSX files\n if (!/\\.[cm]?[jt]sx?(\\?|$)/.test(id)) return null;\n\n const rewrittenImports = rewriteCssTsImports(code, id);\n const rewrittenCode = rewrittenImports.code;\n const hasCssDsl = rewrittenCode.includes(\"Css\");\n if (!hasCssDsl && !rewrittenImports.changed) return null;\n\n const fileId = stripQueryAndHash(id);\n if (isNodeModulesFile(fileId) && !isWhitelistedExternalPackageFile(fileId, externalPackages)) {\n return null;\n }\n\n if (fileId.endsWith(\".css.ts\")) {\n // Keep `.css.ts` modules as normal TS so named exports like class-name\n // constants still work at runtime; only return code when we injected the\n // companion `?truss-css` side-effect import.\n return rewrittenImports.changed ? { code: rewrittenCode, map: null } : null;\n }\n\n if (!hasCssDsl) {\n // Some non-`.css.ts` modules only need the import rewrite and do not have\n // any `Css.*.$` expressions for the main Truss transform to process.\n return { code: rewrittenCode, map: null };\n }\n\n // For regular JS/TS modules that still use the DSL, run the full Truss\n // transform after the import rewrite so both behaviors compose.\n const result = transformTruss(rewrittenCode, fileId, ensureMapping(), { debug });\n if (!result) {\n if (!rewrittenImports.changed) return null;\n return { code: rewrittenCode, map: null };\n }\n return { code: result.code, map: result.map };\n },\n };\n}\n\nfunction resolveImportPath(source: string, importer: string | undefined, projectRoot: string | undefined): string {\n if (isAbsolute(source)) {\n return source;\n }\n\n if (importer) {\n return resolve(dirname(importer), source);\n }\n\n return resolve(projectRoot || process.cwd(), source);\n}\n\n/** Strip Vite query/hash suffixes from an id. */\nfunction stripQueryAndHash(id: string): string {\n const queryIndex = id.indexOf(\"?\");\n const hashIndex = id.indexOf(\"#\");\n\n let end = id.length;\n if (queryIndex >= 0) end = Math.min(end, queryIndex);\n if (hashIndex >= 0) end = Math.min(end, hashIndex);\n\n const cleanId = id.slice(0, end);\n // Vite can prefix absolute paths with `/@fs/`.\n if (cleanId.startsWith(\"/@fs/\")) {\n return cleanId.slice(4);\n }\n return cleanId;\n}\n\nfunction isNodeModulesFile(filePath: string): boolean {\n return normalizePath(filePath).includes(\"/node_modules/\");\n}\n\nfunction isWhitelistedExternalPackageFile(filePath: string, externalPackages: string[]): boolean {\n const normalizedPath = normalizePath(filePath);\n return externalPackages.some(function (pkg) {\n return normalizedPath.includes(`/node_modules/${pkg}/`);\n });\n}\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n\n/** Load a truss mapping file synchronously (for tests). */\nexport function loadMapping(path: string): TrussMapping {\n const raw = readFileSync(path, \"utf8\");\n return JSON.parse(raw);\n}\n\nexport type { TrussMapping, TrussMappingEntry } from \"./types\";\n","import { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { basename } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport {\n collectTopLevelBindings,\n reservePreferredName,\n findCssImportBinding,\n removeCssImport,\n findStylexNamespaceImport,\n insertStylexNamespaceImport,\n findNamedImportBinding,\n upsertNamedImports,\n extractChain,\n} from \"./ast-utils\";\nimport {\n collectCreateData,\n buildCreateProperties,\n buildMaybeIncDeclaration,\n buildCreateDeclaration,\n buildRuntimeLookupDeclaration,\n} from \"./emit-stylex\";\nimport { rewriteExpressionSites, type ExpressionSite } from \"./rewrite-sites\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface TransformResult {\n code: string;\n map?: unknown;\n}\n\nexport interface TransformTrussOptions {\n debug?: boolean;\n}\n\n/**\n * The core transform function. Given a source file's code and the truss mapping,\n * finds all `Css.*.$` expressions and rewrites them into file-local\n * `stylex.create()` + `stylex.props()` calls.\n *\n * Returns null if the file doesn't use Css.\n */\nexport function transformTruss(\n code: string,\n filename: string,\n mapping: TrussMapping,\n options: TransformTrussOptions = {},\n): TransformResult | null {\n // Fast bail: skip files that don't reference Css\n if (!code.includes(\"Css\")) return null;\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n // Step 1: Find the Css import binding name\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) return null;\n\n // Step 2: Collect all Css expression sites\n const sites: ExpressionSite[] = [];\n /** Error messages with source location info, to be emitted as console.error calls. */\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n\n traverse(ast, {\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!t.isIdentifier(path.node.property, { name: \"$\" })) return;\n if (path.node.computed) return;\n\n const chain = extractChain(path.node.object, cssBindingName);\n if (!chain) return;\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n const resolvedChain = resolveFullChain(chain, mapping);\n sites.push({ path, resolvedChain });\n\n // Collect any errors from this chain with source location\n const line = path.node.loc?.start.line ?? null;\n for (const err of resolvedChain.errors) {\n errorMessages.push({ message: err, line });\n }\n },\n });\n\n if (sites.length === 0) return null;\n\n // Step 3: Collect stylex.create entries and helper needs\n const { createEntries, runtimeLookups, needsMaybeInc } = collectCreateData(sites.map((s) => s.resolvedChain));\n\n // Reserve local names we might inject at the top level\n // We do this up front so helper/style variable names are deterministic and\n // cannot collide with user code in the same module.\n const usedTopLevelNames = collectTopLevelBindings(ast);\n const existingStylexNamespace = findStylexNamespaceImport(ast);\n const stylexNamespaceName = existingStylexNamespace ?? reservePreferredName(usedTopLevelNames, \"stylex\");\n const createVarName = reservePreferredName(usedTopLevelNames, \"css\", \"css_\");\n const maybeIncHelperName = needsMaybeInc ? reservePreferredName(usedTopLevelNames, \"__maybeInc\") : null;\n const existingMergePropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"mergeProps\");\n const mergePropsHelperName = existingMergePropsHelperName ?? reservePreferredName(usedTopLevelNames, \"mergeProps\");\n const needsMergePropsHelper = { current: false };\n const existingAsStyleArrayHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"asStyleArray\");\n const asStyleArrayHelperName =\n existingAsStyleArrayHelperName ?? reservePreferredName(usedTopLevelNames, \"asStyleArray\");\n const needsAsStyleArrayHelper = { current: false };\n const existingTrussPropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"trussProps\");\n const trussPropsHelperName = existingTrussPropsHelperName ?? reservePreferredName(usedTopLevelNames, \"trussProps\");\n const needsTrussPropsHelper = { current: false };\n const existingTrussDebugInfoName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"TrussDebugInfo\");\n const trussDebugInfoName = existingTrussDebugInfoName ?? reservePreferredName(usedTopLevelNames, \"TrussDebugInfo\");\n const needsTrussDebugInfo = { current: false };\n const runtimeLookupNames = new Map<string, string>();\n for (const [lookupKey] of runtimeLookups) {\n runtimeLookupNames.set(lookupKey, reservePreferredName(usedTopLevelNames, `__${lookupKey}`));\n }\n\n const createProperties = buildCreateProperties(createEntries, stylexNamespaceName);\n\n // Step 4: Rewrite Css sites in-place\n rewriteExpressionSites({\n ast,\n sites,\n cssBindingName,\n filename: basename(filename),\n debug: options.debug ?? false,\n createVarName,\n stylexNamespaceName,\n maybeIncHelperName,\n mergePropsHelperName,\n needsMergePropsHelper,\n trussPropsHelperName,\n needsTrussPropsHelper,\n trussDebugInfoName,\n needsTrussDebugInfo,\n asStyleArrayHelperName,\n needsAsStyleArrayHelper,\n skippedCssPropMessages: errorMessages,\n runtimeLookupNames,\n });\n\n // Step 5: Remove Css import now that all usages were rewritten\n removeCssImport(ast, cssBindingName);\n\n // Step 6: Ensure namespace stylex import exists\n if (!findStylexNamespaceImport(ast)) {\n insertStylexNamespaceImport(ast, stylexNamespaceName);\n }\n if (\n needsMergePropsHelper.current ||\n needsAsStyleArrayHelper.current ||\n needsTrussPropsHelper.current ||\n needsTrussDebugInfo.current\n ) {\n const runtimeImports: Array<{ importedName: string; localName: string }> = [];\n if (needsMergePropsHelper.current) {\n runtimeImports.push({ importedName: \"mergeProps\", localName: mergePropsHelperName });\n }\n if (needsAsStyleArrayHelper.current) {\n runtimeImports.push({ importedName: \"asStyleArray\", localName: asStyleArrayHelperName });\n }\n if (needsTrussPropsHelper.current) {\n runtimeImports.push({ importedName: \"trussProps\", localName: trussPropsHelperName });\n }\n if (needsTrussDebugInfo.current) {\n runtimeImports.push({ importedName: \"TrussDebugInfo\", localName: trussDebugInfoName });\n }\n upsertNamedImports(ast, \"@homebound/truss/runtime\", runtimeImports);\n }\n\n // Step 7: Hoist marker declarations that are referenced in stylex.create entries.\n // stylex.create uses computed keys like `[stylex.when.ancestor(\":hover\", row)]`\n // which reference marker variables — these must be declared before stylex.create.\n const markerVarNames = collectReferencedMarkerNames(createEntries);\n const hoistedMarkerDecls = hoistMarkerDeclarations(ast, markerVarNames);\n\n // Step 8: Insert helper declarations after imports\n const declarationsToInsert: t.Statement[] = [];\n if (maybeIncHelperName) {\n declarationsToInsert.push(buildMaybeIncDeclaration(maybeIncHelperName, mapping.increment));\n }\n // Hoisted marker declarations go before stylex.create so they're in scope\n declarationsToInsert.push(...hoistedMarkerDecls);\n if (createProperties.length > 0) {\n declarationsToInsert.push(buildCreateDeclaration(createVarName, stylexNamespaceName, createProperties));\n for (const [lookupKey, lookup] of runtimeLookups) {\n const lookupName = runtimeLookupNames.get(lookupKey);\n if (!lookupName) continue;\n declarationsToInsert.push(buildRuntimeLookupDeclaration(lookupName, createVarName, lookup));\n }\n }\n\n // Step 8: Emit console.error calls for any unsupported patterns\n for (const { message, line } of errorMessages) {\n const location = line !== null ? `${filename}:${line}` : filename;\n const logMessage = `${message} (${location})`;\n const consoleError = t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier(\"console\"), t.identifier(\"error\")), [\n t.stringLiteral(logMessage),\n ]),\n );\n declarationsToInsert.push(consoleError);\n }\n\n if (declarationsToInsert.length > 0) {\n const insertIndex = ast.program.body.findIndex(function (node) {\n return !t.isImportDeclaration(node);\n });\n ast.program.body.splice(insertIndex === -1 ? ast.program.body.length : insertIndex, 0, ...declarationsToInsert);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n\n return { code: output.code, map: output.map };\n}\n\n/**\n * Collect the names of marker variables referenced in `whenPseudo.markerNode`\n * across all stylex.create entries. These need to be hoisted above stylex.create.\n */\nfunction collectReferencedMarkerNames(\n createEntries: Map<string, { whenPseudo?: { markerNode?: t.Node } }>,\n): Set<string> {\n const names = new Set<string>();\n for (const [, entry] of createEntries) {\n if (entry.whenPseudo?.markerNode && entry.whenPseudo.markerNode.type === \"Identifier\") {\n names.add(entry.whenPseudo.markerNode.name);\n }\n }\n return names;\n}\n\n/**\n * Find top-level variable declarations for the given names, remove them from\n * their original position in the AST, and return them for reinsertion above\n * the stylex.create call.\n *\n * This handles `const row = stylex.defineMarker()` being declared after code\n * that uses it in a Css.when() chain — the stylex.create computed key\n * `[stylex.when.ancestor(\":hover\", row)]` needs `row` to be in scope.\n */\nfunction hoistMarkerDeclarations(ast: t.File, names: Set<string>): t.Statement[] {\n if (names.size === 0) return [];\n const hoisted: t.Statement[] = [];\n const remaining = new Set(names);\n\n for (let i = ast.program.body.length - 1; i >= 0; i--) {\n if (remaining.size === 0) break;\n const node = ast.program.body[i];\n\n if (!t.isVariableDeclaration(node)) continue;\n\n // Check if any declarator in this statement matches a marker name\n const matchingDeclarators: t.VariableDeclarator[] = [];\n const otherDeclarators: t.VariableDeclarator[] = [];\n for (const decl of node.declarations) {\n if (t.isIdentifier(decl.id) && remaining.has(decl.id.name)) {\n matchingDeclarators.push(decl);\n remaining.delete(decl.id.name);\n } else {\n otherDeclarators.push(decl);\n }\n }\n\n if (matchingDeclarators.length === 0) continue;\n\n if (otherDeclarators.length === 0) {\n // Entire statement is marker declarations — remove it\n ast.program.body.splice(i, 1);\n hoisted.push(node);\n } else {\n // Split: keep non-marker declarators in place, hoist the marker ones\n node.declarations = otherDeclarators;\n hoisted.push(t.variableDeclaration(node.kind, matchingDeclarators));\n }\n }\n\n // Reverse so they appear in original source order\n hoisted.reverse();\n return hoisted;\n}\n","import type * as t from \"@babel/types\";\nimport type { TrussMapping, TrussMappingEntry, ResolvedSegment, MarkerSegment } from \"./types\";\n\n/**\n * A resolved chain that may contain conditional (if/else) sections.\n *\n * I.e. `ChainNode` from ast-utils.ts is just the raw AST chain from `Css` to `.$`, which may contain if/else\n * nodes; this `ResolvedChain` is the post-processed result where each if/else has been split into separate segments.\n *\n * The `parts` array contains unconditional segments and conditional groups.\n * The `markers` array contains marker directives (Css.marker.$, Css.markerOf(\"x\").$).\n */\nexport interface ResolvedChain {\n parts: ResolvedChainPart[];\n /** Marker directives to attach to the element (not CSS styles). */\n markers: MarkerSegment[];\n /** Error messages from unsupported patterns found in this chain. */\n errors: string[];\n}\n\nexport type ResolvedChainPart =\n | { type: \"unconditional\"; segments: ResolvedSegment[] }\n | { type: \"conditional\"; conditionNode: any; thenSegments: ResolvedSegment[]; elseSegments: ResolvedSegment[] };\n\n/**\n * High-level chain resolver that handles if/else by splitting into parts.\n *\n * ## Chain semantics\n *\n * A `Css.*.$` chain is read left-to-right. Each segment is either a style\n * abbreviation (getter or call) or a modifier that changes the context for\n * subsequent styles. The modifiers and their precedence:\n *\n * - **`if(bool)`** / **`else`** — Boolean conditional. Splits the chain into\n * then/else branches at the AST level. Subsequent styles go into the active\n * branch. A new `if` starts a new conditional.\n *\n * - **`if(mediaQuery)`** — String overload. Sets the media query context\n * (same as `ifSm`, `ifMd` etc.) for subsequent styles. Does NOT create\n * a boolean branch.\n *\n * - **`ifSm`**, **`ifMd`**, **`ifLg`**, etc. — Breakpoint getters. Set the\n * media query context. Stacks with pseudo-classes: `ifSm.onHover.blue.$`\n * produces `{ color: { default: null, \":hover\": { default: null, \"@media...\": value } } }`.\n *\n * - **`onHover`**, **`onFocus`**, etc. — Pseudo-class getters. Set the\n * pseudo-class context. Stacks with media queries (see above). A new\n * pseudo-class replaces the previous one.\n *\n * - **`element(\"::placeholder\")`** — Pseudo-element. Sets the pseudo-element\n * context. Wraps subsequent defs in a top-level namespace key:\n * `{ \"::placeholder\": { color: value } }`. Stacks with pseudo-classes\n * and media queries inside the pseudo-element.\n *\n * - **`when(\"ancestor\", \":hover\")`** — StyleX `when` API. Resets both media\n * query and pseudo-class contexts. Uses `stylex.when.<relationship>()`\n * computed keys.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * Contexts accumulate left-to-right until explicitly replaced. A media query\n * set by `ifSm` persists through `onHover` (they stack). A new `if(bool)`\n * resets all contexts for its branches.\n */\nexport function resolveFullChain(chain: ChainNode[], mapping: TrussMapping): ResolvedChain {\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n\n // Pre-scan for marker nodes and strip them from the chain\n const filteredChain: ChainNode[] = [];\n /** Errors found during marker scanning — attached to the chain result */\n const scanErrors: string[] = [];\n for (let j = 0; j < chain.length; j++) {\n const node = chain[j];\n if (node.type === \"getter\" && node.name === \"marker\") {\n markers.push({ type: \"marker\" });\n } else if (node.type === \"call\" && node.name === \"markerOf\") {\n if (node.args.length !== 1) {\n scanErrors.push(\"[truss] Unsupported pattern: markerOf() requires exactly one argument (a marker variable)\");\n } else {\n markers.push({ type: \"marker\", markerNode: node.args[0] });\n }\n } else {\n filteredChain.push(node);\n }\n }\n\n // Split chain at if/else boundaries\n let i = 0;\n let currentNodes: ChainNode[] = [];\n\n while (i < filteredChain.length) {\n const node = filteredChain[i];\n if (node.type === \"if\") {\n // if(stringLiteral) → media query pseudo, not a boolean conditional\n if (node.conditionNode.type === \"StringLiteral\") {\n const mediaQuery: string = (node.conditionNode as any).value;\n // Inject a synthetic \"media query pseudo\" into the current unconditional nodes.\n // This works by creating a synthetic call node that resolveChain's pseudo handling\n // can recognize — but it's simpler to just inject it as a special marker.\n currentNodes.push({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({\n type: \"unconditional\",\n segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)),\n });\n currentNodes = [];\n }\n // Collect \"then\" nodes until \"else\" or end\n const thenNodes: ChainNode[] = [];\n const elseNodes: ChainNode[] = [];\n i++;\n let inElse = false;\n while (i < filteredChain.length) {\n if (filteredChain[i].type === \"else\") {\n inElse = true;\n i++;\n continue;\n }\n if (filteredChain[i].type === \"if\") {\n // Nested if — break out and let the outer loop handle it\n break;\n }\n if (inElse) {\n elseNodes.push(filteredChain[i]);\n } else {\n thenNodes.push(filteredChain[i]);\n }\n i++;\n }\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: mergeOverlappingConditions(resolveChain(thenNodes, mapping)),\n elseSegments: mergeOverlappingConditions(resolveChain(elseNodes, mapping)),\n });\n } else {\n currentNodes.push(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({ type: \"unconditional\", segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)) });\n }\n\n // Collect error messages from all resolved segments\n const segmentErrors: string[] = [];\n for (const part of parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error) {\n segmentErrors.push(seg.error);\n }\n }\n }\n\n return { parts, markers, errors: [...scanErrors, ...segmentErrors] };\n}\n\n/**\n * Walks a Css member-expression chain (the AST between `Css` and `.$`) and\n * resolves each segment into CSS property definitions using the truss mapping.\n *\n * Returns an array of ResolvedSegment, or throws if a pattern is unsupported.\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(chain: ChainNode[], mapping: TrussMapping): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n // Track media query and pseudo-class separately so they can stack.\n // e.g. Css.ifSm.onHover.blue.$ → both mediaQuery and pseudoClass are set\n let currentMediaQuery: string | null = null;\n let currentPseudoClass: string | null = null;\n let currentPseudoElement: string | null = null;\n let currentWhenPseudo: { pseudo: string; markerNode?: any; relationship?: string } | null = null;\n\n for (const node of chain) {\n try {\n // Synthetic media query node injected by resolveFullChain for if(\"@media...\")\n if ((node as any).type === \"__mediaQuery\") {\n currentMediaQuery = (node as any).mediaQuery;\n currentWhenPseudo = null;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n currentMediaQuery = mapping.breakpoints[abbr];\n currentWhenPseudo = null;\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n const resolved = resolveEntry(\n abbr,\n entry,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(...resolved);\n } else if (node.type === \"call\") {\n const abbr = node.name;\n\n // Container query call: ifContainer({ gt, lt, name? })\n if (abbr === \"ifContainer\") {\n currentMediaQuery = containerSelectorFromCall(node);\n currentWhenPseudo = null;\n continue;\n }\n\n // add(prop, value) — arbitrary CSS property\n if (abbr === \"add\") {\n const seg = resolveAddCall(node, mapping, currentMediaQuery, currentPseudoClass, currentPseudoElement);\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(...resolved);\n continue;\n }\n\n // Pseudo-element: element(\"::placeholder\") etc.\n if (abbr === \"element\") {\n if (node.args.length !== 1 || node.args[0].type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(\n `element() requires exactly one string literal argument (e.g. \"::placeholder\")`,\n );\n }\n currentPseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(relationship, pseudo) or when(relationship, marker, pseudo)\n if (abbr === \"when\") {\n const resolved = resolveWhenCall(node);\n currentPseudoClass = null;\n currentMediaQuery = null;\n currentWhenPseudo = resolved;\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(\"ancestor\", \":hover\") for relationship pseudos`,\n );\n }\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n if (entry.kind === \"dynamic\") {\n const seg = resolveDynamicCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else {\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" is ${entry.kind}, cannot be called as a function`);\n }\n }\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n segments.push({ key: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/** Build the stylex.create key suffix from mediaQuery, pseudoClass, and/or pseudoElement. */\nexport function conditionKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoName(pseudoElement));\n if (mediaQuery) parts.push(pseudoName(mediaQuery, breakpoints));\n if (pseudoClass) parts.push(pseudoName(pseudoClass));\n return parts.join(\"_\");\n}\n\n/** Resolve `typography(key)` into either direct segments or a runtime lookup-backed segment. */\nfunction resolveTypographyCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`typography() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n if (argAst.type === \"StringLiteral\") {\n return resolveTypographyEntry(argAst.value, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n const typography = mapping.typography ?? [];\n if (typography.length === 0) {\n throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const lookupKey = suffix ? `typography__${suffix}` : \"typography\";\n const segmentsByName: Record<string, ResolvedSegment[]> = {};\n\n for (const name of typography) {\n segmentsByName[name] = resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n return [\n {\n key: lookupKey,\n defs: {},\n typographyLookup: {\n lookupKey,\n argNode: argAst,\n segmentsByName,\n },\n },\n ];\n}\n\n/** Resolve a single typography abbreviation name within the current condition context. */\nfunction resolveTypographyEntry(\n name: string,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (!(mapping.typography ?? []).includes(name)) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const entry = mapping.abbreviations[name];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const resolved = resolveEntry(name, entry, mapping, mediaQuery, pseudoClass, pseudoElement, null);\n for (const segment of resolved) {\n if (segment.dynamicProps || segment.whenPseudo) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/**\n * Wrap raw CSS defs with condition nesting for StyleX.\n *\n * - mediaQuery only: `{ prop: { default: null, \"@media...\": value } }`\n * - pseudoClass only: `{ prop: { default: null, \":hover\": value } }`\n * - both (stacked): `{ prop: { default: null, \":hover\": { default: null, \"@media...\": value } } }`\n */\nfunction wrapDefsWithConditions(\n defs: Record<string, unknown>,\n mediaQuery: string | null,\n pseudoClass: string | null,\n): Record<string, unknown> {\n if (!mediaQuery && !pseudoClass) return defs;\n const result: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(defs)) {\n if (pseudoClass && mediaQuery) {\n result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };\n } else if (pseudoClass) {\n result[prop] = { default: null, [pseudoClass]: value };\n } else {\n result[prop] = { default: null, [mediaQuery!]: value };\n }\n }\n return result;\n}\n\n/** Resolve a static or alias entry (from a getter access). */\nfunction resolveEntry(\n abbr: string,\n entry: TrussMappingEntry,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment[] {\n switch (entry.kind) {\n case \"static\": {\n if (whenPseudo) {\n const suffix = whenPseudoKeyName(whenPseudo);\n const key = `${abbr}__${suffix}`;\n return [{ key, defs: entry.defs, whenPseudo }];\n }\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n const defs = pseudoElement\n ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) }\n : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);\n return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];\n }\n case \"alias\": {\n const result: ResolvedSegment[] = [];\n for (const chainAbbr of entry.chain) {\n const subEntry = mapping.abbreviations[chainAbbr];\n if (!subEntry) {\n throw new UnsupportedPatternError(`Alias \"${abbr}\" references unknown abbreviation \"${chainAbbr}\"`);\n }\n result.push(...resolveEntry(chainAbbr, subEntry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo));\n }\n return result;\n }\n case \"dynamic\":\n case \"delegate\":\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" requires arguments — use ${abbr}() not .${abbr}`);\n default:\n throw new UnsupportedPatternError(`Unhandled entry kind for \"${abbr}\"`);\n }\n}\n\n/** Resolve a dynamic (parameterized) call like mt(2) or mt(x). */\nfunction resolveDynamicCall(\n abbr: string,\n entry: { kind: \"dynamic\"; props: string[]; incremented: boolean; extraDefs?: Record<string, unknown> },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluateLiteral(argAst, entry.incremented, mapping.increment);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) {\n Object.assign(defs, entry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n dynamicProps: entry.props,\n incremented: entry.incremented,\n dynamicExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/** Resolve a delegate call like mtPx(12). */\nfunction resolveDelegateCall(\n abbr: string,\n entry: { kind: \"delegate\"; target: string },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n const targetEntry = mapping.abbreviations[entry.target];\n if (!targetEntry || targetEntry.kind !== \"dynamic\") {\n throw new UnsupportedPatternError(`Delegate \"${abbr}\" targets \"${entry.target}\" which is not a dynamic entry`);\n }\n\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluatePxLiteral(argAst);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) {\n Object.assign(defs, targetEntry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${entry.target}__${suffix}` : entry.target;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: targetEntry.props,\n incremented: false,\n appendPx: true,\n dynamicExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/**\n * Resolve an `add(...)` call.\n *\n * Supported overloads:\n * - `add(cssProp)` to inline an existing CssProp array into the chain output\n * - `add(\"propName\", value)` for an arbitrary CSS property/value pair\n */\nfunction resolveAddCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length === 1) {\n const styleArg = node.args[0];\n if (styleArg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`add() does not support spread arguments`);\n }\n if (styleArg.type === \"ObjectExpression\") {\n throw new UnsupportedPatternError(\n `add(cssProp) does not accept object literals -- pass an existing CssProp expression instead`,\n );\n }\n return {\n key: \"__composed_css_prop\",\n defs: {},\n styleArrayArg: styleArg,\n };\n }\n\n if (node.args.length !== 2) {\n throw new UnsupportedPatternError(\n `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. ` +\n `Supported overloads are add(cssProp) and add(\"propName\", value)`,\n );\n }\n\n const propArg = node.args[0];\n if (propArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`add() first argument must be a string literal property name`);\n }\n const propName: string = (propArg as any).value;\n\n const valueArg = node.args[1];\n // Try to evaluate the value as a literal\n const literalValue = tryEvaluateAddLiteral(valueArg);\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = suffix ? `add_${propName}__${keySuffix}__${suffix}` : `add_${propName}__${keySuffix}`;\n const defs: Record<string, unknown> = { [propName]: literalValue };\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `add_${propName}__${suffix}` : `add_${propName}`;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: [propName],\n incremented: false,\n argNode: valueArg,\n };\n }\n}\n\n/** Try to evaluate a literal for add() — strings, numbers, and template literals with no expressions. */\nfunction tryEvaluateAddLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"StringLiteral\") {\n return (node as any).value;\n }\n if (node.type === \"NumericLiteral\") {\n return String((node as any).value);\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return String(-(node.argument as any).value);\n }\n return null;\n}\n\nconst WHEN_RELATIONSHIPS = new Set([\"ancestor\", \"descendant\", \"anySibling\", \"siblingBefore\", \"siblingAfter\"]);\n\n/**\n * Resolve a `when(relationship, pseudo)` or `when(relationship, marker, pseudo)` call.\n *\n * - 2 args: `when(\"ancestor\", \":hover\")` — both must be string literals\n * - 3 args: `when(\"ancestor\", marker, \":hover\")` — 1st and 3rd must be string literals, 2nd is a marker variable\n */\nfunction resolveWhenCall(node: CallChainNode): { pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length < 2 || node.args.length > 3) {\n throw new UnsupportedPatternError(\n `when() expects 2 or 3 arguments (relationship, [marker], pseudo), got ${node.args.length}`,\n );\n }\n\n const relationshipArg = node.args[0];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() first argument must be a string literal relationship`);\n }\n const relationship: string = (relationshipArg as any).value;\n if (!WHEN_RELATIONSHIPS.has(relationship)) {\n throw new UnsupportedPatternError(\n `when() relationship must be one of: ${[...WHEN_RELATIONSHIPS].join(\", \")} -- got \"${relationship}\"`,\n );\n }\n\n if (node.args.length === 2) {\n // when(\"ancestor\", \":hover\")\n const pseudoArg = node.args[1];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, relationship };\n } else {\n // when(\"ancestor\", marker, \":hover\")\n const markerNode = node.args[1];\n const pseudoArg = node.args[2];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector (3rd argument) must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, markerNode, relationship };\n }\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n};\n\nfunction isPseudoMethod(name: string): boolean {\n return name in PSEUDO_METHODS;\n}\n\nfunction pseudoSelector(name: string): string {\n return PSEUDO_METHODS[name];\n}\n\n/**\n * Generate the stylex.create key suffix for when/ancestor pseudo segments.\n * e.g. { pseudo: \":hover\" } → \"ancestorHover\"\n * e.g. { pseudo: \":hover\", relationship: \"descendant\" } → \"descendantHover\"\n * e.g. { pseudo: \":hover\", markerNode: Identifier(\"row\") } → \"ancestorHover_row\"\n */\nfunction whenPseudoKeyName(ap: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = ap.relationship ?? \"ancestor\";\n const pn = pseudoName(ap.pseudo);\n const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;\n if (!ap.markerNode) return base;\n // Use the identifier name for readable keys; fall back to a generic suffix for complex expressions\n const suffix = ap.markerNode.type === \"Identifier\" ? ap.markerNode.name : \"marker\";\n return `${base}_${suffix}`;\n}\n\n/**\n * Post-process resolved segments to merge entries that target the same CSS\n * properties into a single `stylex.create` entry with stacked conditions.\n *\n * For example, `Css.black.ifSm.white.onHover.blue.$` produces three segments:\n * 1. `black` → `{ color: \"#353535\" }` (base)\n * 2. `white__sm` → `{ color: { default: null, \"@media...\": \"#fcfcfa\" } }` (media-only)\n * 3. `blue__sm_hover` → `{ color: { default: null, \":hover\": { default: null, \"@media...\": \"#526675\" } } }` (media+pseudo)\n *\n * All three set `color`, so they merge into one entry:\n * `{ color: { default: \"#353535\", \"@media...\": \"#fcfcfa\", \":hover\": { default: null, \"@media...\": \"#526675\" } } }`\n */\nexport function mergeOverlappingConditions(segments: ResolvedSegment[]): ResolvedSegment[] {\n // Index: for each CSS property, which segments set it?\n // Only static segments (no dynamicProps, no styleArrayArg, no whenPseudo, no error) participate in merging.\n const propToIndices = new Map<string, number[]>();\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n if (seg.dynamicProps || seg.styleArrayArg || seg.whenPseudo || seg.error) continue;\n for (const prop of Object.keys(seg.defs)) {\n if (!propToIndices.has(prop)) propToIndices.set(prop, []);\n propToIndices.get(prop)!.push(i);\n }\n }\n\n // Find properties where a base (no-condition) segment overlaps with conditional segments.\n // Two base segments setting the same property is NOT a merge — the later one just overrides.\n const mergeableProps = new Set<string>();\n for (const [prop, indices] of propToIndices) {\n if (indices.length < 2) continue;\n const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);\n const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));\n if (hasBase && hasConditional) {\n mergeableProps.add(prop);\n }\n }\n\n if (mergeableProps.size === 0) return segments;\n\n // For each mergeable property, deep-merge all contributing segments into one defs object.\n // Track which segment indices have properties consumed by the merge.\n const consumedProps = new Map<number, Set<string>>(); // segIndex → consumed prop names\n const mergedPropDefs = new Map<string, { defs: Record<string, unknown>; key: string }>();\n\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n let merged: Record<string, unknown> = {};\n const keyParts: string[] = [];\n\n for (const idx of indices) {\n const seg = segments[idx];\n const value = seg.defs[prop];\n keyParts.push(seg.key);\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n // Base value → default\n merged.default = value;\n } else if (typeof value === \"object\" && value !== null) {\n // Conditional value — merge all keys (may include default: null which base will override)\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"default\" && v === null && merged.default !== undefined) {\n // Don't let a conditional's `default: null` clobber the base value\n continue;\n }\n merged[k] = v;\n }\n }\n\n // Mark this property as consumed from this segment\n if (!consumedProps.has(idx)) consumedProps.set(idx, new Set());\n consumedProps.get(idx)!.add(prop);\n }\n\n // If the merged object has only a `default` key, it's just a raw value (no conditions)\n const finalValue = Object.keys(merged).length === 1 && \"default\" in merged ? merged.default : merged;\n const mergedKey = [...new Set(keyParts)].join(\"_\");\n mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });\n }\n\n // Group mergeable props that share the exact same set of contributing segments\n // so they become one stylex.create entry.\n const groupByIndices = new Map<string, { props: string[]; key: string }>();\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n const groupKey = indices.join(\",\");\n if (!groupByIndices.has(groupKey)) {\n groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop)!.key });\n }\n groupByIndices.get(groupKey)!.props.push(prop);\n }\n\n // Build merged segments\n const mergedSegments: ResolvedSegment[] = [];\n for (const [, group] of groupByIndices) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n mergedSegments.push({ key: group.key, defs });\n }\n\n // Rebuild result: emit non-consumed segments (or segments with remaining non-consumed props),\n // then emit merged segments at the position of the first consumed segment.\n const result: ResolvedSegment[] = [];\n const mergedEmitted = new Set<string>();\n\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const consumed = consumedProps.get(i);\n\n if (!consumed) {\n // Not involved in any merge\n result.push(seg);\n continue;\n }\n\n // Emit any non-consumed properties from this segment\n const remainingDefs: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (!consumed.has(prop)) {\n remainingDefs[prop] = value;\n }\n }\n if (Object.keys(remainingDefs).length > 0) {\n result.push({ ...seg, defs: remainingDefs });\n }\n\n // Emit the merged segment(s) at the position of the first segment that contributed\n const indices = [...propToIndices.entries()]\n .filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop))\n .map(([, idxs]) => idxs.join(\",\"));\n\n for (const groupKey of new Set(indices)) {\n if (!mergedEmitted.has(groupKey)) {\n const group = groupByIndices.get(groupKey);\n if (group) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n result.push({ key: group.key, defs });\n mergedEmitted.add(groupKey);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Convert a pseudo/media selector into a short key suffix.\n * \":hover\" → \"hover\", \":focus-visible\" → \"focus_visible\"\n * \"@media screen and (max-width:599px)\" → \"sm\" (using breakpoints reverse map)\n * \"@container (min-width: 601px)\" → \"container_min_width_601px\"\n */\nexport function pseudoName(pseudo: string, breakpoints?: Record<string, string>): string {\n if (pseudo.startsWith(\"@media\") && breakpoints) {\n // Reverse lookup: find the breakpoint getter name (e.g. \"ifSm\") and strip \"if\" prefix\n for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {\n if (mediaQuery === pseudo) {\n // \"ifSm\" → \"sm\", \"ifSmOrMd\" → \"smOrMd\", \"ifMdAndUp\" → \"mdAndUp\"\n return getterName.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase());\n }\n }\n // Fallback: create a compact name from the media query\n return pseudo\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n if (pseudo.startsWith(\"@container\")) {\n return pseudo\n .replace(/^@container\\s*/, \"container \")\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n return pseudo.replace(/^:+/, \"\").replace(/-/g, \"_\");\n}\n\n/**\n * Try to evaluate a literal AST node to a string value.\n * For incremented entries, also evaluates `maybeInc(literal)`.\n */\nfunction tryEvaluateLiteral(\n node: t.Expression | t.SpreadElement,\n incremented: boolean,\n increment: number,\n): string | null {\n if (node.type === \"NumericLiteral\") {\n if (incremented) {\n return `${node.value * increment}px`;\n }\n return String(node.value);\n }\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n const val = -node.argument.value;\n if (incremented) {\n return `${val * increment}px`;\n }\n return String(val);\n }\n return null;\n}\n\n/** Try to evaluate a Px delegate argument (always a number → `${n}px`). */\nfunction tryEvaluatePxLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"NumericLiteral\") {\n return `${node.value}px`;\n }\n return null;\n}\n\n/** Resolve ifContainer({ gt, lt, name? }) to a StyleX pseudo key. */\nfunction containerSelectorFromCall(node: CallChainNode): string {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`ifContainer() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (!arg || arg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(\"ifContainer() expects an object literal argument\");\n }\n\n let lt: number | undefined;\n let gt: number | undefined;\n let name: string | undefined;\n\n for (const prop of arg.properties) {\n if (prop.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(\"ifContainer() does not support spread properties\");\n }\n if (prop.type !== \"ObjectProperty\" || prop.computed) {\n throw new UnsupportedPatternError(\"ifContainer() expects plain object properties\");\n }\n\n const key = objectPropertyName(prop.key);\n if (!key) {\n throw new UnsupportedPatternError(\"ifContainer() only supports identifier/string keys\");\n }\n\n const valueNode = prop.value as t.Expression | t.SpreadElement;\n\n if (key === \"lt\") {\n lt = numericLiteralValue(valueNode, \"ifContainer().lt must be a numeric literal\");\n continue;\n }\n if (key === \"gt\") {\n gt = numericLiteralValue(valueNode, \"ifContainer().gt must be a numeric literal\");\n continue;\n }\n if (key === \"name\") {\n name = stringLiteralValue(valueNode, \"ifContainer().name must be a string literal\");\n continue;\n }\n\n throw new UnsupportedPatternError(`ifContainer() does not support property \"${key}\"`);\n }\n\n if (lt === undefined && gt === undefined) {\n throw new UnsupportedPatternError('ifContainer() requires at least one of \"lt\" or \"gt\"');\n }\n\n const parts: string[] = [];\n if (gt !== undefined) {\n parts.push(`(min-width: ${gt + 1}px)`);\n }\n if (lt !== undefined) {\n parts.push(`(max-width: ${lt}px)`);\n }\n\n const query = parts.join(\" and \");\n const namePrefix = name ? `${name} ` : \"\";\n return `@container ${namePrefix}${query}`;\n}\n\nfunction objectPropertyName(node: t.Expression | t.Identifier | t.PrivateName): string | null {\n if (node.type === \"Identifier\") return node.name;\n if (node.type === \"StringLiteral\") return node.value;\n return null;\n}\n\nfunction numericLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): number {\n if (node.type === \"NumericLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return -node.argument.value;\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\nfunction stringLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): string {\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"TemplateLiteral\" && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? \"\";\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\n// ── Chain node types (parsed from AST) ────────────────────────────────\n\nexport interface GetterChainNode {\n type: \"getter\";\n name: string;\n}\n\nexport interface CallChainNode {\n type: \"call\";\n name: string;\n args: (t.Expression | t.SpreadElement)[];\n}\n\nexport interface IfChainNode {\n type: \"if\";\n conditionNode: t.Expression | t.SpreadElement;\n}\n\nexport interface ElseChainNode {\n type: \"else\";\n}\n\nexport type ChainNode = GetterChainNode | CallChainNode | IfChainNode | ElseChainNode;\n\nexport class UnsupportedPatternError extends Error {\n constructor(message: string) {\n super(`[truss] Unsupported pattern: ${message}`);\n this.name = \"UnsupportedPatternError\";\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ChainNode } from \"./resolve-chain\";\n\n/**\n * Collect module-scope bindings so generated declarations can avoid collisions.\n *\n * We only care about top-level names because the transform injects declarations\n * at the module root, not inside nested blocks.\n */\nexport function collectTopLevelBindings(ast: t.File): Set<string> {\n const used = new Set<string>();\n\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node)) {\n for (const spec of node.specifiers) {\n used.add(spec.local.name);\n }\n continue;\n }\n\n if (t.isVariableDeclaration(node)) {\n for (const decl of node.declarations) {\n collectPatternBindings(decl.id, used);\n }\n continue;\n }\n\n if (t.isFunctionDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isClassDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration) {\n const decl = node.declaration;\n if (t.isVariableDeclaration(decl)) {\n for (const varDecl of decl.declarations) {\n collectPatternBindings(varDecl.id, used);\n }\n } else if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n continue;\n }\n\n if (t.isExportDefaultDeclaration(node)) {\n const decl = node.declaration;\n if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n }\n }\n\n return used;\n}\n\n/**\n * Recursively collect names introduced by binding patterns.\n *\n * This handles destructuring (`const { a } = ...`, `const [x] = ...`) so we do\n * not accidentally generate a helper that shadows an existing binding.\n */\nfunction collectPatternBindings(pattern: t.LVal | t.VoidPattern, used: Set<string>): void {\n if (t.isVoidPattern(pattern)) {\n return;\n }\n\n if (t.isIdentifier(pattern)) {\n used.add(pattern.name);\n return;\n }\n\n if (t.isAssignmentPattern(pattern)) {\n collectPatternBindings(pattern.left, used);\n return;\n }\n\n if (t.isRestElement(pattern)) {\n collectPatternBindings(pattern.argument as t.LVal, used);\n return;\n }\n\n if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isObjectProperty(prop)) {\n collectPatternBindings(prop.value as t.LVal, used);\n } else if (t.isRestElement(prop)) {\n collectPatternBindings(prop.argument as t.LVal, used);\n }\n }\n return;\n }\n\n if (t.isArrayPattern(pattern)) {\n for (const el of pattern.elements) {\n if (!el) continue;\n if (t.isIdentifier(el) || t.isAssignmentPattern(el) || t.isObjectPattern(el) || t.isArrayPattern(el)) {\n collectPatternBindings(el, used);\n } else if (t.isRestElement(el)) {\n collectPatternBindings(el.argument as t.LVal, used);\n }\n }\n }\n}\n\n/**\n * Reserve a stable, collision-free identifier.\n *\n * Preference order:\n * 1) preferred\n * 2) secondary (if provided)\n * 3) numbered suffixes based on secondary/preferred\n */\nexport function reservePreferredName(used: Set<string>, preferred: string, secondary?: string): string {\n if (!used.has(preferred)) {\n used.add(preferred);\n return preferred;\n }\n\n if (secondary && !used.has(secondary)) {\n used.add(secondary);\n return secondary;\n }\n\n const base = secondary ?? preferred;\n let i = 1;\n // Numbered fallback keeps generated names deterministic across runs.\n let candidate = `${base}_${i}`;\n while (used.has(candidate)) {\n i++;\n candidate = `${base}_${i}`;\n }\n used.add(candidate);\n return candidate;\n}\n\n/**\n * Find the local binding name for `Css` from import declarations.\n */\nexport function findCssImportBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: \"Css\" })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/**\n * Remove the Css import specifier. If it was the only specifier, remove the whole import.\n */\nexport function removeCssImport(ast: t.File, cssBinding: string): void {\n for (let i = 0; i < ast.program.body.length; i++) {\n const node = ast.program.body[i];\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((s) => t.isImportSpecifier(s) && s.local.name === cssBinding);\n if (cssSpecIndex === -1) continue;\n\n if (node.specifiers.length === 1) {\n ast.program.body.splice(i, 1);\n } else {\n node.specifiers.splice(cssSpecIndex, 1);\n }\n return;\n }\n}\n\n/**\n * Find an existing namespace import for `@stylexjs/stylex`, if present.\n *\n * Reusing an existing namespace avoids duplicate imports and ensures generated\n * calls use the same local alias as handwritten code (e.g. `sx`).\n */\nexport function findStylexNamespaceImport(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (node.source.value !== \"@stylexjs/stylex\") continue;\n\n for (const spec of node.specifiers) {\n if (t.isImportNamespaceSpecifier(spec)) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Return the index of the last import declaration in the module. */\nexport function findLastImportIndex(ast: t.File): number {\n let lastImportIndex = -1;\n for (let i = 0; i < ast.program.body.length; i++) {\n if (t.isImportDeclaration(ast.program.body[i])) {\n lastImportIndex = i;\n }\n }\n return lastImportIndex;\n}\n\n/**\n * Insert `import * as <localName> from \"@stylexjs/stylex\"` after existing imports.\n */\nexport function insertStylexNamespaceImport(ast: t.File, localName: string): void {\n const stylexImport = t.importDeclaration(\n [t.importNamespaceSpecifier(t.identifier(localName))],\n t.stringLiteral(\"@stylexjs/stylex\"),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, stylexImport);\n}\n\nexport function findNamedImportBinding(ast: t.File, source: string, importedName: string): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: importedName })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\nexport function upsertNamedImports(\n ast: t.File,\n source: string,\n imports: Array<{ importedName: string; localName: string }>,\n): void {\n if (imports.length === 0) return;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n\n for (const entry of imports) {\n const exists = node.specifiers.some(function (spec) {\n return t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: entry.importedName });\n });\n if (exists) continue;\n\n node.specifiers.push(t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName)));\n }\n return;\n }\n\n const importDecl = t.importDeclaration(\n imports.map(function (entry) {\n return t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName));\n }),\n t.stringLiteral(source),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, importDecl);\n}\n\n/**\n * Extract a `Css` method/property chain from an expression.\n *\n * Example: `Css.if(cond).df.else.db.$` ->\n * `[{type:\"if\"}, {type:\"getter\", name:\"df\"}, {type:\"else\"}, {type:\"getter\", name:\"db\"}]`\n *\n * Returns `null` when the expression is not rooted at the Css import binding,\n * which lets the caller ignore unrelated member expressions cheaply.\n */\nexport function extractChain(node: t.Expression, cssBinding: string): ChainNode[] | null {\n const chain: ChainNode[] = [];\n let current: t.Expression = node;\n\n while (true) {\n if (t.isIdentifier(current, { name: cssBinding })) {\n chain.reverse();\n return chain;\n }\n\n if (t.isMemberExpression(current) && !current.computed && t.isIdentifier(current.property)) {\n const name = current.property.name;\n if (name === \"else\") {\n chain.push({ type: \"else\" });\n } else {\n chain.push({ type: \"getter\", name });\n }\n current = current.object as t.Expression;\n continue;\n }\n\n if (\n t.isCallExpression(current) &&\n t.isMemberExpression(current.callee) &&\n !current.callee.computed &&\n t.isIdentifier(current.callee.property)\n ) {\n const name = current.callee.property.name;\n\n if (name === \"if\") {\n chain.push({\n type: \"if\",\n conditionNode: current.arguments[0] as t.Expression,\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n chain.push({\n type: \"call\",\n name,\n args: current.arguments as (t.Expression | t.SpreadElement)[],\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n return null;\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment } from \"./types\";\n\nexport interface CreateEntrySpec {\n /**\n * The property name in the generated `stylex.create({...})` object, built from\n * the Truss abbreviation, optionally suffixed with the resolved value and/or pseudo,\n * i.e. `\"df\"`, `\"mt__16px\"`, `\"black__hover\"`. Also used as the dedup key across the file.\n */\n key: string;\n /**\n * Static CSS property-value map for this entry. Usually a single property,\n * i.e. `{ display: \"flex\" }` for `\"df\"`, but shorthand abbreviations expand to multiple,\n * i.e. `{ borderStyle: \"solid\", borderWidth: \"1px\" }` for `\"ba\"`.\n */\n defs?: Record<string, unknown>;\n /**\n * For dynamic entries where the value is a runtime variable (not a literal),\n * i.e. `{ props: [\"marginTop\"], pseudo: null }` for `Css.mt(x).$`,\n * or `{ props: [\"color\"], pseudo: \":hover\" }` for `Css.onHover.color(x).$`.\n *\n * Becomes `stylex.create({ mt: v => ({ marginTop: v }) })`\n */\n dynamic?: {\n props: string[];\n extraDefs?: Record<string, unknown>;\n mediaQuery?: string | null;\n pseudoClass?: string | null;\n pseudoElement?: string | null;\n };\n /** If set, this entry uses stylex.when.<relationship>() as the computed property key */\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string };\n}\n\nexport interface CollectedCreateData {\n createEntries: Map<string, CreateEntrySpec>;\n runtimeLookups: Map<string, RuntimeLookupSpec>;\n needsMaybeInc: boolean;\n}\n\nexport interface RuntimeLookupSpec {\n lookupKey: string;\n refsByName: Record<string, string[]>;\n}\n\n/**\n * Aggregate per-site resolved chains into file-level emission data.\n *\n * Why this exists: we emit one `stylex.create(...)` per source file, so all\n * style segments across all transformed sites must be deduplicated first.\n */\nexport function collectCreateData(chains: ResolvedChain[]): CollectedCreateData {\n const createEntries = new Map<string, CreateEntrySpec>();\n const runtimeLookups = new Map<string, RuntimeLookupSpec>();\n let needsMaybeInc = false;\n\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n\n for (const seg of segs) {\n // Skip error segments — they have no CSS data to emit\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n collectTypographyLookup(createEntries, runtimeLookups, seg);\n continue;\n }\n\n if (seg.styleArrayArg) {\n continue;\n }\n\n if (seg.dynamicProps) {\n if (!createEntries.has(seg.key)) {\n // Keyed dedupe guarantees a stable single entry for repeated usage.\n createEntries.set(seg.key, {\n key: seg.key,\n dynamic: {\n props: seg.dynamicProps,\n extraDefs: seg.dynamicExtraDefs,\n mediaQuery: seg.mediaQuery,\n pseudoClass: seg.pseudoClass,\n pseudoElement: seg.pseudoElement,\n },\n });\n }\n } else {\n if (!createEntries.has(seg.key)) {\n createEntries.set(seg.key, {\n key: seg.key,\n defs: seg.defs,\n whenPseudo: seg.whenPseudo,\n });\n }\n }\n\n if (seg.incremented && seg.dynamicProps) {\n needsMaybeInc = true;\n }\n }\n }\n }\n\n return { createEntries, runtimeLookups, needsMaybeInc };\n}\n\nfunction collectTypographyLookup(\n createEntries: Map<string, CreateEntrySpec>,\n runtimeLookups: Map<string, RuntimeLookupSpec>,\n seg: ResolvedSegment,\n): void {\n const lookup = seg.typographyLookup;\n if (!lookup) return;\n\n if (!runtimeLookups.has(lookup.lookupKey)) {\n runtimeLookups.set(lookup.lookupKey, {\n lookupKey: lookup.lookupKey,\n refsByName: Object.fromEntries(\n Object.entries(lookup.segmentsByName).map(function ([name, segments]) {\n return [\n name,\n segments.map(function (segment) {\n return segment.key;\n }),\n ];\n }),\n ),\n });\n }\n\n for (const segments of Object.values(lookup.segmentsByName)) {\n for (const segment of segments) {\n if (createEntries.has(segment.key)) continue;\n createEntries.set(segment.key, {\n key: segment.key,\n defs: segment.defs,\n whenPseudo: segment.whenPseudo,\n });\n }\n }\n}\n\n/**\n * Build the object literal properties passed to `stylex.create`.\n *\n * Handles static entries, dynamic entries (`v => ({ ... })`), and\n * ancestor-pseudo entries that use `stylex.when.ancestor(...)` keys.\n */\nexport function buildCreateProperties(\n createEntries: Map<string, CreateEntrySpec>,\n stylexNamespaceName: string,\n): t.ObjectProperty[] {\n const createProperties: t.ObjectProperty[] = [];\n\n for (const [, entry] of createEntries) {\n if (entry.dynamic) {\n const paramId = t.identifier(\"v\");\n const bodyProps: t.ObjectProperty[] = [];\n const { mediaQuery, pseudoClass } = entry.dynamic;\n\n for (const prop of entry.dynamic.props) {\n if (pseudoClass && mediaQuery) {\n // Stacked: { default: null, \":hover\": { default: null, \"@media...\": v } }\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), paramId),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), paramId),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), paramId));\n }\n }\n\n if (entry.dynamic.extraDefs) {\n for (const [prop, value] of Object.entries(entry.dynamic.extraDefs)) {\n if (pseudoClass && mediaQuery) {\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), valueToAst(value)),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), valueToAst(value)),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), valueToAst(value)));\n }\n }\n }\n\n let bodyExpr: t.Expression = t.objectExpression(bodyProps);\n if (entry.dynamic.pseudoElement) {\n // Wrap: { '::placeholder': { ...bodyProps } }\n bodyExpr = t.objectExpression([t.objectProperty(t.stringLiteral(entry.dynamic.pseudoElement), bodyExpr)]);\n }\n const arrowFn = t.arrowFunctionExpression([paramId], bodyExpr);\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), arrowFn));\n continue;\n }\n\n if (entry.whenPseudo && entry.defs) {\n const ap = entry.whenPseudo;\n const props: t.ObjectProperty[] = [];\n\n for (const [prop, value] of Object.entries(entry.defs)) {\n // `when.ancestor(...)` must remain a computed key expression so StyleX\n // can generate marker-aware selectors.\n const whenCallArgs: t.Expression[] = [t.stringLiteral(ap.pseudo)];\n if (ap.markerNode) {\n whenCallArgs.push(ap.markerNode);\n }\n\n const relationship = ap.relationship ?? \"ancestor\";\n const whenCall = t.callExpression(\n t.memberExpression(\n t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"when\")),\n t.identifier(relationship),\n ),\n whenCallArgs,\n );\n\n props.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(whenCall, valueToAst(value), true),\n ]),\n ),\n );\n }\n\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), t.objectExpression(props)));\n continue;\n }\n\n if (entry.defs) {\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), defsToAst(entry.defs)));\n }\n }\n\n return createProperties;\n}\n\n/**\n * Build the per-file increment helper used by dynamic incremented calls.\n *\n * The helper is only emitted when needed to keep transformed files minimal.\n */\nexport function buildMaybeIncDeclaration(helperName: string, increment: number): t.VariableDeclaration {\n const incParam = t.identifier(\"inc\");\n const body = t.blockStatement([\n t.returnStatement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", incParam), t.stringLiteral(\"string\")),\n incParam,\n t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [t.binaryExpression(\"*\", incParam, t.numericLiteral(increment))],\n ),\n ),\n ),\n ]);\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(helperName), t.arrowFunctionExpression([incParam], body)),\n ]);\n}\n\n/** Build the per-file helper used to merge explicit `className` with `stylex.props()`. */\nexport function buildMergePropsDeclaration(helperName: string, stylexNamespaceName: string): t.FunctionDeclaration {\n const explicitClassNameParam = t.identifier(\"explicitClassName\");\n const stylesRestParam = t.restElement(t.identifier(\"styles\"));\n const sxId = t.identifier(\"sx\");\n\n return t.functionDeclaration(\n t.identifier(helperName),\n [explicitClassNameParam, stylesRestParam],\n t.blockStatement([\n t.variableDeclaration(\"const\", [\n t.variableDeclarator(\n sxId,\n t.callExpression(t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"props\")), [\n t.spreadElement(t.identifier(\"styles\")),\n ]),\n ),\n ]),\n t.returnStatement(\n t.objectExpression([\n t.spreadElement(sxId),\n t.objectProperty(\n t.identifier(\"className\"),\n t.callExpression(\n t.memberExpression(\n t.binaryExpression(\n \"+\",\n t.binaryExpression(\"+\", explicitClassNameParam, t.stringLiteral(\" \")),\n t.logicalExpression(\"||\", t.memberExpression(sxId, t.identifier(\"className\")), t.stringLiteral(\"\")),\n ),\n t.identifier(\"trim\"),\n ),\n [],\n ),\n ),\n ]),\n ),\n ]),\n );\n}\n\n/** Build `const <createVarName> = <stylexNs>.create({...})`. */\nexport function buildCreateDeclaration(\n createVarName: string,\n stylexNamespaceName: string,\n createProperties: t.ObjectProperty[],\n): t.VariableDeclaration {\n const createCall = t.callExpression(t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"create\")), [\n t.objectExpression(createProperties),\n ]);\n return t.variableDeclaration(\"const\", [t.variableDeclarator(t.identifier(createVarName), createCall)]);\n}\n\nexport function buildRuntimeLookupDeclaration(\n lookupName: string,\n createVarName: string,\n lookup: RuntimeLookupSpec,\n): t.VariableDeclaration {\n const properties: t.ObjectProperty[] = [];\n\n for (const [name, refs] of Object.entries(lookup.refsByName)) {\n const values = refs.map(function (refKey) {\n return t.memberExpression(t.identifier(createVarName), t.identifier(refKey));\n });\n properties.push(t.objectProperty(toPropertyKey(name), t.arrayExpression(values)));\n }\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(lookupName), t.objectExpression(properties)),\n ]);\n}\n\n/** Convert style definitions to an AST object, recursively. */\nfunction defsToAst(defs: Record<string, unknown>): t.ObjectExpression {\n const properties: t.ObjectProperty[] = [];\n\n for (const [key, value] of Object.entries(defs)) {\n const keyNode = toPropertyKey(key);\n\n if (value === null) {\n properties.push(t.objectProperty(keyNode, t.nullLiteral()));\n } else if (typeof value === \"string\") {\n properties.push(t.objectProperty(keyNode, t.stringLiteral(value)));\n } else if (typeof value === \"number\") {\n properties.push(t.objectProperty(keyNode, t.numericLiteral(value)));\n } else if (typeof value === \"object\") {\n properties.push(t.objectProperty(keyNode, defsToAst(value as Record<string, unknown>)));\n }\n }\n\n return t.objectExpression(properties);\n}\n\n/** Convert a primitive/object style value into an AST expression node. */\nfunction valueToAst(value: unknown): t.Expression {\n if (value === null) return t.nullLiteral();\n if (typeof value === \"string\") return t.stringLiteral(value);\n if (typeof value === \"number\") return t.numericLiteral(value);\n if (typeof value === \"object\") return defsToAst(value as Record<string, unknown>);\n return t.stringLiteral(String(value));\n}\n\n/** Use identifier keys when legal, otherwise string literal keys. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n","import _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport type { ResolvedSegment } from \"./types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\n\nexport interface ExpressionSite {\n path: NodePath<t.MemberExpression>;\n resolvedChain: ResolvedChain;\n}\n\nexport interface RewriteSitesOptions {\n ast: t.File;\n sites: ExpressionSite[];\n cssBindingName: string;\n filename: string;\n debug: boolean;\n createVarName: string;\n stylexNamespaceName: string;\n maybeIncHelperName: string | null;\n mergePropsHelperName: string;\n needsMergePropsHelper: { current: boolean };\n trussPropsHelperName: string;\n needsTrussPropsHelper: { current: boolean };\n trussDebugInfoName: string;\n needsTrussDebugInfo: { current: boolean };\n asStyleArrayHelperName: string;\n needsAsStyleArrayHelper: { current: boolean };\n skippedCssPropMessages: Array<{ message: string; line: number | null }>;\n runtimeLookupNames: Map<string, string>;\n}\n\n/** Format a property key for diagnostics. */\nfunction formatDroppedPropertyKey(prop: t.ObjectMember | t.SpreadElement): string {\n if (t.isObjectProperty(prop)) {\n if (t.isIdentifier(prop.key)) return prop.key.name;\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n }\n return formatNodeSnippet(prop);\n}\n\n/**\n * Rewrite collected `Css...$` expression sites into StyleX runtime calls.\n *\n * Why this is split out: the transform has two distinct concerns—\"what to\n * emit\" (`stylex.create`) and \"where to rewrite usage sites\" (`stylex.props`).\n * Keeping site rewrites isolated makes behavior easier to reason about.\n */\nexport function rewriteExpressionSites(options: RewriteSitesOptions): void {\n for (const site of options.sites) {\n const propsArgs = buildPropsArgsFromChain(site.resolvedChain, options);\n const cssAttrPath = getCssAttributePath(site.path);\n\n if (cssAttrPath) {\n cssAttrPath.replaceWith(\n t.jsxSpreadAttribute(\n buildCssSpreadExpression(\n cssAttrPath,\n propsArgs,\n site.path.node.loc?.start.line ?? null,\n options.mergePropsHelperName,\n options.needsMergePropsHelper,\n options,\n ),\n ),\n );\n continue;\n }\n\n site.path.replaceWith(buildStyleArrayExpression(propsArgs, site.path.node.loc?.start.line ?? null, options));\n }\n\n rewriteCssSpreadCalls(\n options.ast,\n options.cssBindingName,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n );\n rewriteStyleObjectExpressions(\n options.ast,\n options.skippedCssPropMessages,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n );\n normalizeMixedStyleTernaries(options.ast);\n\n // Second pass: lower any style-array-like `css={...}` expression to `stylex.props(...)`.\n rewriteCssAttributeExpressions(\n options.ast,\n options.filename,\n options.debug,\n options.stylexNamespaceName,\n options.mergePropsHelperName,\n options.needsMergePropsHelper,\n options.trussPropsHelperName,\n options.needsTrussPropsHelper,\n options.trussDebugInfoName,\n options.needsTrussDebugInfo,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n options.skippedCssPropMessages,\n );\n}\n\n/**\n * Return the enclosing `css={...}` JSX attribute path for a transformed site,\n * or null when the site is in a non-`css` expression context.\n */\nfunction getCssAttributePath(path: NodePath<t.MemberExpression>): NodePath<t.JSXAttribute> | null {\n const parentPath = path.parentPath;\n if (!parentPath || !parentPath.isJSXExpressionContainer()) return null;\n\n const attrPath = parentPath.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return null;\n if (!t.isJSXIdentifier(attrPath.node.name, { name: \"css\" })) return null;\n\n return attrPath;\n}\n\n/**\n * Build arguments for `stylex.props(...)` from a resolved chain.\n *\n * Conditional segments are converted to ternaries (or spread ternaries when a\n * branch has multiple refs) so branch structure is preserved in emitted code.\n */\nfunction buildPropsArgsFromChain(\n chain: ResolvedChain,\n options: RewriteSitesOptions,\n): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const marker of chain.markers) {\n if (marker.markerNode) {\n args.push(marker.markerNode);\n } else {\n args.push(\n t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"defaultMarker\")),\n [],\n ),\n );\n }\n }\n\n for (const part of chain.parts) {\n if (part.type === \"unconditional\") {\n args.push(...buildPropsArgs(part.segments, options));\n continue;\n }\n\n const thenArgs = buildPropsArgs(part.thenSegments, options);\n const elseArgs = buildPropsArgs(part.elseSegments, options);\n\n if (\n thenArgs.length === 1 &&\n elseArgs.length === 1 &&\n !t.isSpreadElement(thenArgs[0]) &&\n !t.isSpreadElement(elseArgs[0])\n ) {\n args.push(t.conditionalExpression(part.conditionNode, thenArgs[0], elseArgs[0]));\n } else if (thenArgs.length > 0 || elseArgs.length > 0) {\n args.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.arrayExpression(thenArgs), t.arrayExpression(elseArgs)),\n ),\n );\n }\n }\n\n return args;\n}\n\n/** Convert resolved segments to style refs and dynamic invocations. */\nfunction buildPropsArgs(segments: ResolvedSegment[], options: RewriteSitesOptions): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const seg of segments) {\n // Skip error segments — they are logged via console.error at the top of the file\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n const lookupName = options.runtimeLookupNames.get(seg.typographyLookup.lookupKey);\n if (!lookupName) {\n continue;\n }\n const lookupAccess = t.memberExpression(\n t.identifier(lookupName),\n seg.typographyLookup.argNode as t.Expression,\n true,\n );\n args.push(t.spreadElement(t.logicalExpression(\"??\", lookupAccess, t.arrayExpression([]))));\n continue;\n }\n\n if (seg.styleArrayArg) {\n args.push(\n t.spreadElement(\n buildUnknownSpreadFallback(\n seg.styleArrayArg as t.Expression,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n ),\n ),\n );\n continue;\n }\n\n const ref = t.memberExpression(t.identifier(options.createVarName), t.identifier(seg.key));\n\n if (seg.dynamicProps && seg.argNode) {\n let argExpr: t.Expression;\n if (seg.incremented && options.maybeIncHelperName) {\n argExpr = t.callExpression(t.identifier(options.maybeIncHelperName), [seg.argNode]);\n } else if (seg.incremented) {\n argExpr = seg.argNode as t.Expression;\n } else if (seg.appendPx) {\n argExpr = t.binaryExpression(\n \"+\",\n t.callExpression(t.identifier(\"String\"), [seg.argNode]),\n t.stringLiteral(\"px\"),\n );\n } else {\n argExpr = t.callExpression(t.identifier(\"String\"), [seg.argNode]);\n }\n args.push(t.callExpression(ref, [argExpr]));\n } else {\n args.push(ref);\n }\n }\n\n return args;\n}\n\n/** Rewrite style-array-like `css={...}` expressions to `...stylex.props(...)`. */\nfunction rewriteCssAttributeExpressions(\n ast: t.File,\n filename: string,\n debug: boolean,\n stylexNamespaceName: string,\n mergePropsHelperName: string,\n needsMergePropsHelper: { current: boolean },\n trussPropsHelperName: string,\n needsTrussPropsHelper: { current: boolean },\n trussDebugInfoName: string,\n needsTrussDebugInfo: { current: boolean },\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n skippedCssPropMessages: Array<{ message: string; line: number | null }>,\n): void {\n traverse(ast, {\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n const value = path.node.value;\n if (!t.isJSXExpressionContainer(value)) return;\n if (!t.isExpression(value.expression)) return;\n\n const propsArgs = lowerCssExpressionToPropsArgs(\n value.expression,\n path,\n asStyleArrayHelperName,\n needsAsStyleArrayHelper,\n );\n if (!propsArgs) {\n skippedCssPropMessages.push({\n message: explainSkippedCssRewrite(value.expression, path),\n line: path.node.loc?.start.line ?? null,\n });\n return;\n }\n\n path.replaceWith(\n t.jsxSpreadAttribute(\n buildCssSpreadExpression(\n path,\n propsArgs,\n path.node.loc?.start.line ?? null,\n mergePropsHelperName,\n needsMergePropsHelper,\n {\n filename,\n debug,\n stylexNamespaceName,\n trussPropsHelperName,\n needsTrussPropsHelper,\n trussDebugInfoName,\n needsTrussDebugInfo,\n },\n ),\n ),\n );\n },\n });\n}\n\n/** Emit a style array and optionally prepend a Truss debug sentinel. */\nfunction buildStyleArrayExpression(\n propsArgs: (t.Expression | t.SpreadElement)[],\n line: number | null,\n options: RewriteSitesOptions,\n): t.ArrayExpression {\n const elements: Array<t.Expression | t.SpreadElement> = buildDebugElements(line, options);\n elements.push(...propsArgs);\n return t.arrayExpression(elements);\n}\n\n/** Emit `stylex.props(...)` or `trussProps(stylex, ...)` depending on debug mode. */\nfunction buildPropsCall(\n propsArgs: (t.Expression | t.SpreadElement)[],\n line: number | null,\n options: Pick<\n RewriteSitesOptions,\n | \"debug\"\n | \"stylexNamespaceName\"\n | \"trussPropsHelperName\"\n | \"needsTrussPropsHelper\"\n | \"trussDebugInfoName\"\n | \"needsTrussDebugInfo\"\n | \"filename\"\n >,\n): t.CallExpression {\n if (!options.debug) {\n return t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"props\")),\n propsArgs,\n );\n }\n\n options.needsTrussPropsHelper.current = true;\n const args: Array<t.Expression | t.SpreadElement> = buildDebugElements(line, options);\n args.push(...propsArgs);\n return t.callExpression(t.identifier(options.trussPropsHelperName), [\n t.identifier(options.stylexNamespaceName),\n ...args,\n ]);\n}\n\n/** Build the `new TrussDebugInfo(\"File.tsx:line\")` expression for a site. */\nfunction buildDebugElements(\n line: number | null,\n options: Pick<RewriteSitesOptions, \"debug\" | \"trussDebugInfoName\" | \"needsTrussDebugInfo\" | \"filename\">,\n): Array<t.Expression | t.SpreadElement> {\n if (!options.debug || line === null) {\n return [];\n }\n\n options.needsTrussDebugInfo.current = true;\n return [t.newExpression(t.identifier(options.trussDebugInfoName), [t.stringLiteral(`${options.filename}:${line}`)])];\n}\n\n/** Lower a rewriteable JSX `css={...}` expression into `stylex.props(...)` args. */\nfunction lowerCssExpressionToPropsArgs(\n expr: t.Expression,\n path: NodePath<t.JSXAttribute>,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): (t.Expression | t.SpreadElement)[] | null {\n return (\n buildStyleObjectPropsArgs(expr, path, asStyleArrayHelperName, needsAsStyleArrayHelper) ??\n buildStyleArrayLikePropsArgsFromExpression(expr, path)\n );\n}\n\n/** Explain why a remaining `css={...}` expression could not be lowered. */\nfunction explainSkippedCssRewrite(expr: t.Expression, path: NodePath<t.JSXAttribute>): string {\n if (t.isObjectExpression(expr)) {\n for (const prop of expr.properties) {\n if (!t.isSpreadElement(prop)) {\n return `[truss] Unsupported pattern: Could not rewrite css prop: object contains a non-spread property (${formatNodeSnippet(expr)})`;\n }\n\n const normalizedArg = normalizeStyleExpression(prop.argument);\n if (!normalizedArg) {\n return `[truss] Unsupported pattern: Could not rewrite css prop: spread argument is not style-array-like (${formatNodeSnippet(prop.argument)})`;\n }\n }\n\n return `[truss] Unsupported pattern: Could not rewrite css prop: object spread composition was not recognized (${formatNodeSnippet(expr)})`;\n }\n\n return `[truss] Unsupported pattern: Could not rewrite css prop: expression is not style-array-like (${formatNodeSnippet(expr)})`;\n}\n\n/** Generate a compact code snippet for diagnostics. */\nfunction formatNodeSnippet(node: t.Node): string {\n return generate(node, { compact: true, comments: true }).code;\n}\n\n/** Merge existing `className` attr into a rewritten `stylex.props(...)` spread. */\nfunction buildCssSpreadExpression(\n path: NodePath<t.JSXAttribute>,\n propsArgs: (t.Expression | t.SpreadElement)[],\n line: number | null,\n mergePropsHelperName: string,\n needsMergePropsHelper: { current: boolean },\n options: Pick<\n RewriteSitesOptions,\n | \"debug\"\n | \"stylexNamespaceName\"\n | \"trussPropsHelperName\"\n | \"needsTrussPropsHelper\"\n | \"trussDebugInfoName\"\n | \"needsTrussDebugInfo\"\n | \"filename\"\n >,\n): t.Expression {\n const existingClassNameExpr = removeExistingClassNameAttribute(path);\n if (!existingClassNameExpr) return buildPropsCall(propsArgs, line, options);\n\n needsMergePropsHelper.current = true;\n const args: Array<t.Expression | t.SpreadElement> = buildDebugElements(line, options);\n args.push(...propsArgs);\n return t.callExpression(t.identifier(mergePropsHelperName), [\n t.identifier(options.stylexNamespaceName),\n existingClassNameExpr,\n ...args,\n ]);\n}\n\n/** Remove sibling `className` and return its expression so rewrites can preserve it. */\nfunction removeExistingClassNameAttribute(path: NodePath<t.JSXAttribute>): t.Expression | null {\n const openingElement = path.parentPath;\n if (!openingElement || !openingElement.isJSXOpeningElement()) return null;\n\n const attrs = openingElement.node.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name, { name: \"className\" })) continue;\n\n let classNameExpr: t.Expression | null = null;\n if (t.isStringLiteral(attr.value)) {\n classNameExpr = attr.value;\n } else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {\n classNameExpr = attr.value.expression;\n }\n\n attrs.splice(i, 1);\n return classNameExpr;\n }\n\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Object spread → style array rewriting\n// ---------------------------------------------------------------------------\n\n/**\n * Convert `css={{ ...a, ...Css.df.$ }}`-style objects directly to props args.\n *\n * For css prop objects: if the object is all spreads, either flatten known style\n * arrays or wrap unknown spreads in `asStyleArray()`.\n */\nfunction buildStyleObjectPropsArgs(\n expr: t.Expression,\n path: NodePath,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): (t.Expression | t.SpreadElement)[] | null {\n if (!t.isObjectExpression(expr) || expr.properties.length === 0) return null;\n\n // Objects with non-spread properties can't be lowered to props args\n const allSpreads = expr.properties.every(function (prop) {\n return t.isSpreadElement(prop);\n });\n if (!allSpreads) return null;\n\n // If any spread touches a Css-derived array, flatten with knowledge of style arrays\n if (hasStyleArraySpread(expr, path)) {\n const result = flattenStyleObject(expr, path, asStyleArrayHelperName, needsAsStyleArrayHelper);\n return result.elements.filter(Boolean) as (t.Expression | t.SpreadElement)[];\n }\n\n // All spreads but none touch Css → wrap each in asStyleArray as fallback\n return expr.properties.map(function (prop) {\n const spread = prop as t.SpreadElement;\n return t.spreadElement(\n buildUnknownSpreadFallback(spread.argument, asStyleArrayHelperName, needsAsStyleArrayHelper), // I.e. `css={{ ...css }}` or `css={{ ...xss }}`\n );\n });\n}\n\n/** Normalize and lower a style-array-like expression into props args. */\nfunction buildStyleArrayLikePropsArgsFromExpression(\n expr: t.Expression,\n path: NodePath,\n): (t.Expression | t.SpreadElement)[] | null {\n const normalizedExpr = normalizeStyleExpression(expr);\n if (!normalizedExpr) return null;\n return buildStyleArrayLikePropsArgs(normalizedExpr, path);\n}\n\n/** Convert a style-array-like expression into `stylex.props(...)` arguments. */\nfunction buildStyleArrayLikePropsArgs(expr: t.Expression, path: NodePath): (t.Expression | t.SpreadElement)[] | null {\n if (t.isArrayExpression(expr)) {\n const propsArgs: (t.Expression | t.SpreadElement)[] = [];\n\n for (const el of expr.elements) {\n if (!el) continue;\n\n if (t.isSpreadElement(el)) {\n const normalizedArg = normalizeStyleExpression(el.argument); // I.e. `...[css.df]`, `...base`, or `...(cond ? styles.hover : {})`\n if (!normalizedArg) {\n propsArgs.push(t.spreadElement(el.argument));\n continue;\n }\n\n if (t.isArrayExpression(normalizedArg)) {\n const nestedArgs = buildStyleArrayLikePropsArgs(normalizedArg, path);\n if (nestedArgs) {\n propsArgs.push(...nestedArgs);\n continue;\n }\n }\n propsArgs.push(t.spreadElement(buildSafeSpreadArgument(normalizedArg)));\n continue;\n }\n\n propsArgs.push(el);\n }\n\n return propsArgs;\n }\n\n if (\n t.isIdentifier(expr) ||\n t.isMemberExpression(expr) ||\n t.isConditionalExpression(expr) ||\n t.isLogicalExpression(expr) ||\n t.isCallExpression(expr)\n ) {\n return [t.spreadElement(buildSafeSpreadArgument(expr))];\n }\n\n return null;\n}\n\n/**\n * Rewrite object spread composition like `{ ...[css.df], ...(cond ? [css.a] : {}) }`\n * into style ref arrays so later JSX css rewrites can flatten them safely.\n */\nfunction rewriteStyleObjectExpressions(\n ast: t.File,\n messages: Array<{ message: string; line: number | null }>,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): void {\n traverse(ast, {\n ObjectExpression(path: NodePath<t.ObjectExpression>) {\n if (!hasStyleArraySpread(path.node, path)) return;\n\n const result = flattenStyleObject(path.node, path, asStyleArrayHelperName, needsAsStyleArrayHelper);\n if (result.droppedPropertyKeys.length > 0) {\n messages.push({\n message: `[truss] Unsupported pattern: Dropped non-spread properties from style composition object (${result.droppedPropertyKeys.join(\", \")})`,\n line: path.node.loc?.start.line ?? null,\n });\n }\n path.replaceWith(t.arrayExpression(result.elements));\n },\n });\n}\n\n/**\n * Normalize ternaries and logicals that mix `{}` with style arrays.\n *\n * After Css rewriting, `cond ? {} : Css.pt3.$` becomes `cond ? {} : [css.pt3]`.\n * If `{}` is left as-is, spreading the result into an array fails at runtime\n * (\"not iterable\"). This pass rewrites `{}` → `[]` in branches that coexist\n * with style arrays so both sides are consistently iterable.\n */\nfunction normalizeMixedStyleTernaries(ast: t.File): void {\n traverse(ast, {\n ConditionalExpression(path: NodePath<t.ConditionalExpression>) {\n const consequentHasArray = expressionContainsArray(path.node.consequent, path);\n const alternateHasArray = expressionContainsArray(path.node.alternate, path);\n // Only act when one branch has an array and the other is `{}`\n if (consequentHasArray && isEmptyObjectExpression(path.node.alternate)) {\n path.node.alternate = t.arrayExpression([]);\n } else if (alternateHasArray && isEmptyObjectExpression(path.node.consequent)) {\n path.node.consequent = t.arrayExpression([]);\n }\n },\n LogicalExpression(path: NodePath<t.LogicalExpression>) {\n if (path.node.operator !== \"||\" && path.node.operator !== \"??\") return;\n // I.e. `styles || {}` where styles is a style array\n if (expressionContainsArray(path.node.left, path) && isEmptyObjectExpression(path.node.right)) {\n path.node.right = t.arrayExpression([]);\n }\n },\n });\n}\n\n/**\n * Lower `Css.spread({ ... })` marker calls into plain style arrays.\n *\n * `Css.spread(...)` is an explicit user annotation that says \"this object is\n * style composition\" — so we skip the `hasStyleArraySpread` detection gate\n * and always rewrite.\n */\nfunction rewriteCssSpreadCalls(\n ast: t.File,\n cssBindingName: string,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): void {\n traverse(ast, {\n CallExpression(path: NodePath<t.CallExpression>) {\n if (!isCssSpreadCall(path.node, cssBindingName)) return;\n\n const arg = path.node.arguments[0];\n if (!arg || t.isSpreadElement(arg) || !t.isExpression(arg) || path.node.arguments.length !== 1) return;\n\n const styleObject = unwrapStyleObjectExpression(arg);\n if (!styleObject) return;\n\n const result = flattenStyleObject(styleObject, path, asStyleArrayHelperName, needsAsStyleArrayHelper);\n path.replaceWith(t.arrayExpression(result.elements));\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Core: flatten a style composition object into an array of style refs\n// ---------------------------------------------------------------------------\n\n/**\n * Convert a style composition object `{ ...a, ...b }` into a flat array `[...a, ...b]`.\n *\n * Each spread argument is normalized (&&→ternary, {}→[], nested objects→arrays).\n * Known style arrays are flattened; unknown expressions are wrapped in `asStyleArray()`.\n */\nfunction flattenStyleObject(\n expr: t.ObjectExpression,\n path: NodePath,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): { elements: (t.Expression | t.SpreadElement | null)[]; droppedPropertyKeys: string[] } {\n const elements: (t.Expression | t.SpreadElement | null)[] = [];\n const droppedPropertyKeys: string[] = [];\n\n for (const prop of expr.properties) {\n if (!t.isSpreadElement(prop)) {\n droppedPropertyKeys.push(formatDroppedPropertyKey(prop)); // I.e. `{ ...Css.black.$, foo: true }`\n continue;\n }\n\n const normalized = normalizeStyleExpression(prop.argument);\n if (!normalized) {\n // Truly unrecognizable → asStyleArray fallback\n elements.push(\n t.spreadElement(buildUnknownSpreadFallback(prop.argument, asStyleArrayHelperName, needsAsStyleArrayHelper)),\n );\n continue;\n }\n\n if (t.isArrayExpression(normalized)) {\n elements.push(...normalized.elements); // I.e. `...[css.df, css.aic]` → `css.df, css.aic`\n } else if (expressionContainsArray(normalized, path)) {\n elements.push(t.spreadElement(buildSafeSpreadArgument(normalized))); // I.e. `...(cond ? [css.df] : [])`\n } else {\n elements.push(\n t.spreadElement(buildUnknownSpreadFallback(normalized, asStyleArrayHelperName, needsAsStyleArrayHelper)), // I.e. `...borderBottomStyles`\n );\n }\n }\n\n return { elements, droppedPropertyKeys };\n}\n\n// ---------------------------------------------------------------------------\n// Detection: does an object expression \"touch\" Css-derived style arrays?\n// ---------------------------------------------------------------------------\n\n/**\n * Check whether any spread in an object contains an array expression.\n *\n * This works as a reliable proxy for \"touches Css expressions\" because the earlier Css rewriting pass converts\n * `Css.foo.$` chains into array literals like `[css.df, css.aic]`.\n *\n * Spreading an array into an object literal is semantically nonsensical in user-written code (i.e. `{ ...[a, b] }`\n * produces `{ 0: a, 1: b }`), so any object spread containing an array literal must have been produced by our Css\n * rewriting — making it safe to rewrite the whole object into a style array.\n */\nfunction hasStyleArraySpread(expr: t.ObjectExpression, path: NodePath): boolean {\n return expr.properties.some(function (prop) {\n return t.isSpreadElement(prop) && expressionContainsArray(prop.argument, path);\n });\n}\n\n/**\n * Recursively check whether an expression contains an array expression,\n * following simple variable bindings, member accesses, and function returns.\n */\nfunction expressionContainsArray(expr: t.Expression, path: NodePath): boolean {\n if (t.isArrayExpression(expr)) return true;\n\n if (t.isConditionalExpression(expr)) {\n return expressionContainsArray(expr.consequent, path) || expressionContainsArray(expr.alternate, path);\n }\n\n if (t.isLogicalExpression(expr)) {\n return expressionContainsArray(expr.left, path) || expressionContainsArray(expr.right, path);\n }\n\n if (t.isObjectExpression(expr)) {\n return expr.properties.some(function (p) {\n return t.isSpreadElement(p) && expressionContainsArray(p.argument, path);\n });\n }\n\n // Follow variable bindings: `const base = [css.df]; { ...base }`\n if (t.isIdentifier(expr)) {\n const binding = path.scope.getBinding(expr.name);\n if (binding?.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init) return expressionContainsArray(init, binding.path as unknown as NodePath);\n }\n return false;\n }\n\n // Follow member access: `styles.wrapper` where `const styles = { wrapper: [css.df] }`\n if (t.isMemberExpression(expr) && t.isIdentifier(expr.object)) {\n const binding = path.scope.getBinding(expr.object.name);\n if (binding?.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init && t.isObjectExpression(init)) {\n const propName = getStaticMemberPropertyName(expr, path);\n if (propName) {\n for (const prop of init.properties) {\n if (!t.isObjectProperty(prop) || prop.computed) continue;\n if (!isMatchingPropertyName(prop.key, propName)) continue;\n if (t.isExpression(prop.value)) {\n return expressionContainsArray(prop.value, binding.path as unknown as NodePath);\n }\n }\n }\n }\n }\n return false;\n }\n\n // Follow local function returns: `getStyles()` where `function getStyles() { return [css.df]; }`\n if (t.isCallExpression(expr)) {\n const returnExpr = getCallReturnExpression(expr, path);\n return returnExpr ? expressionContainsArray(returnExpr, path) : false;\n }\n\n return false;\n}\n\n// ---------------------------------------------------------------------------\n// Normalization: convert style expressions into canonical array-like form\n// ---------------------------------------------------------------------------\n\n/**\n * Normalize a style expression so conditional branches use arrays instead of objects.\n *\n * Converts `&&` to ternary with `[]` fallback, `{}` to `[]`, and accepts\n * identifiers/members/calls as-is (they're assumed to be style arrays in context).\n */\nfunction normalizeStyleExpression(expr: t.Expression): t.Expression | null {\n if (t.isArrayExpression(expr)) return expr; // I.e. `[css.df]`\n\n if (isEmptyObjectExpression(expr)) return t.arrayExpression([]); // I.e. `{}`\n\n if (t.isLogicalExpression(expr) && expr.operator === \"&&\") {\n const consequent = normalizeStyleExpression(expr.right);\n if (!consequent) return null;\n return t.conditionalExpression(expr.left, consequent, t.arrayExpression([])); // I.e. `active && [css.blue]`\n }\n\n if (t.isLogicalExpression(expr) && (expr.operator === \"||\" || expr.operator === \"??\")) {\n const left = normalizeStyleExpression(expr.left);\n const right = normalizeStyleBranch(expr.right);\n if (!left || !right) return null;\n return t.logicalExpression(expr.operator, left, right); // I.e. `hover || base`\n }\n\n if (t.isConditionalExpression(expr)) {\n const consequent = normalizeStyleBranch(expr.consequent);\n const alternate = normalizeStyleBranch(expr.alternate);\n if (!consequent || !alternate) return null;\n return t.conditionalExpression(expr.test, consequent, alternate); // I.e. `cond ? [css.blue] : {}`\n }\n\n // Identifiers, member expressions, and calls are accepted as style arrays\n if (t.isIdentifier(expr) || t.isMemberExpression(expr) || t.isCallExpression(expr)) {\n return expr; // I.e. `baseStyles`, `styles.wrapper`, `getStyles()`\n }\n\n return null;\n}\n\n/** Normalize a branch in a conditional style expression. */\nfunction normalizeStyleBranch(expr: t.Expression): t.Expression | null {\n if (isEmptyObjectExpression(expr)) return t.arrayExpression([]); // I.e. `cond ? [css.blue] : {}`\n\n if (t.isObjectExpression(expr)) {\n // Nested style objects in branches: `cond ? { ...Css.bb.$ } : {}`\n if (expr.properties.length === 0) return t.arrayExpression([]);\n const allSpreads = expr.properties.every(function (p) {\n return t.isSpreadElement(p);\n });\n if (!allSpreads) return null;\n // Build a simple inline array from the spreads\n const elements: (t.Expression | t.SpreadElement | null)[] = [];\n for (const prop of expr.properties) {\n const spread = prop as t.SpreadElement;\n const normalized = normalizeStyleExpression(spread.argument);\n if (!normalized) return null;\n if (t.isArrayExpression(normalized)) {\n elements.push(...normalized.elements);\n } else {\n elements.push(t.spreadElement(buildSafeSpreadArgument(normalized)));\n }\n }\n return t.arrayExpression(elements);\n }\n\n return normalizeStyleExpression(expr);\n}\n\n// ---------------------------------------------------------------------------\n// Utility helpers\n// ---------------------------------------------------------------------------\n\n/** Match the legacy `Css.spread(...)` marker helper. */\nfunction isCssSpreadCall(expr: t.CallExpression, cssBindingName: string): boolean {\n return (\n t.isMemberExpression(expr.callee) &&\n !expr.callee.computed &&\n t.isIdentifier(expr.callee.object, { name: cssBindingName }) &&\n t.isIdentifier(expr.callee.property, { name: \"spread\" })\n );\n}\n\n/** Unwrap TS wrappers so `Css.spread({ ... } as const)` is still recognized. */\nfunction unwrapStyleObjectExpression(expr: t.Expression): t.ObjectExpression | null {\n if (t.isObjectExpression(expr)) return expr;\n if (t.isTSAsExpression(expr) || t.isTSSatisfiesExpression(expr) || t.isTSNonNullExpression(expr)) {\n return unwrapStyleObjectExpression(expr.expression);\n }\n return null;\n}\n\n/** Match static object property names. */\nfunction isMatchingPropertyName(key: t.Expression | t.Identifier | t.PrivateName, name: string): boolean {\n return (t.isIdentifier(key) && key.name === name) || (t.isStringLiteral(key) && key.value === name);\n}\n\n/** Check for `{}` fallback branches that should become `[]`. */\nfunction isEmptyObjectExpression(expr: t.Expression): boolean {\n return t.isObjectExpression(expr) && expr.properties.length === 0;\n}\n\n/** Convert unknown spread values into safe iterable fallbacks via `asStyleArray(...)`. */\nfunction buildUnknownSpreadFallback(\n expr: t.Expression,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): t.Expression {\n needsAsStyleArrayHelper.current = true;\n return t.callExpression(t.identifier(asStyleArrayHelperName), [expr]); // I.e. `asStyleArray(xss)`\n}\n\n/** Parenthesize spread arguments that need grouping in emitted code. */\nfunction buildSafeSpreadArgument(expr: t.Expression): t.Expression {\n return t.isConditionalExpression(expr) || t.isLogicalExpression(expr) ? t.parenthesizedExpression(expr) : expr;\n}\n\n/** Resolve static property names for `styles.wrapper` or `styles[\"wrapper\"]`. */\nfunction getStaticMemberPropertyName(expr: t.MemberExpression, path: NodePath): string | null {\n if (!expr.computed && t.isIdentifier(expr.property)) {\n return expr.property.name;\n }\n\n if (t.isStringLiteral(expr.property)) {\n return expr.property.value;\n }\n\n if (t.isIdentifier(expr.property)) {\n const binding = path.scope.getBinding(expr.property.name);\n if (!binding?.path.isVariableDeclarator()) return null;\n const init = binding.path.node.init;\n return t.isStringLiteral(init) ? init.value : null;\n }\n\n return null;\n}\n\n/** Resolve the return expression of a call, checking local functions and callback args. */\nfunction getCallReturnExpression(expr: t.CallExpression, path: NodePath): t.Expression | null {\n const localReturnExpr = getLocalFunctionReturnExpression(expr, path);\n if (localReturnExpr) return localReturnExpr;\n\n const firstArg = expr.arguments[0];\n if (\n firstArg &&\n !t.isSpreadElement(firstArg) &&\n (t.isArrowFunctionExpression(firstArg) || t.isFunctionExpression(firstArg))\n ) {\n return getFunctionLikeReturnExpression(firstArg); // I.e. `useMemo(() => ({ ...baseStyles }), deps)`\n }\n\n return null;\n}\n\n/** Resolve a local function call's return expression. */\nfunction getLocalFunctionReturnExpression(expr: t.CallExpression, path: NodePath): t.Expression | null {\n if (!t.isIdentifier(expr.callee)) return null;\n\n const binding = path.scope.getBinding(expr.callee.name);\n if (!binding) return null;\n\n if (binding.path.isFunctionDeclaration()) {\n return getFunctionLikeReturnExpression(binding.path.node);\n }\n\n if (binding.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init && (t.isArrowFunctionExpression(init) || t.isFunctionExpression(init))) {\n return getFunctionLikeReturnExpression(init);\n }\n }\n\n return null;\n}\n\n/** Extract a single returned expression from a function-like node. */\nfunction getFunctionLikeReturnExpression(\n fn: t.FunctionDeclaration | t.FunctionExpression | t.ArrowFunctionExpression,\n): t.Expression | null {\n if (t.isExpression(fn.body)) {\n return fn.body;\n }\n\n if (fn.body.body.length !== 1) return null;\n const stmt = fn.body.body[0];\n return t.isReturnStatement(stmt) && stmt.argument && t.isExpression(stmt.argument) ? stmt.argument : null;\n}\n","import { parse } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport { extractChain, findCssImportBinding } from \"./ast-utils\";\nimport { collectStaticStringBindings, resolveStaticString } from \"./css-ts-utils\";\n\n/**\n * Transform a `.css.ts` file into a plain CSS string.\n *\n * The file is expected to have the shape:\n * ```ts\n * import { Css } from \"./Css\";\n * export const css = {\n * \".some-selector\": Css.df.blue.$,\n * \".other > .selector\": Css.mt(2).black.$,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is a `Css.*.$` chain.\n * The chains are resolved via the truss mapping into concrete CSS declarations.\n *\n * Returns the generated CSS string.\n */\nexport function transformCssTs(code: string, filename: string, mapping: TrussMapping): string {\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) {\n return `/* [truss] ${filename}: no Css import found */\\n`;\n }\n\n // Find the `export const css = { ... }` expression\n const cssExport = findNamedCssExportObject(ast);\n if (!cssExport) {\n return `/* [truss] ${filename}: expected \\`export const css = { ... }\\` with an object literal */\\n`;\n }\n\n const rules: string[] = [];\n const stringBindings = collectStaticStringBindings(ast);\n\n for (const prop of cssExport.properties) {\n if (t.isSpreadElement(prop)) {\n rules.push(`/* [truss] unsupported: spread elements in css.ts export */`);\n continue;\n }\n\n if (!t.isObjectProperty(prop)) {\n rules.push(`/* [truss] unsupported: non-property in css.ts export */`);\n continue;\n }\n\n // Key must be a string literal (the CSS selector)\n const selector = objectPropertyStringKey(prop, stringBindings);\n if (selector === null) {\n rules.push(`/* [truss] unsupported: non-string-literal key in css.ts export */`);\n continue;\n }\n\n // Value must be a Css.*.$ expression\n const valueNode = prop.value;\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n const cssResult = resolveCssExpression(valueNode, cssBindingName, mapping, filename);\n if (\"error\" in cssResult) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — ${cssResult.error} */`);\n continue;\n }\n\n rules.push(formatCssRule(selector, cssResult.declarations));\n }\n\n return rules.join(\"\\n\\n\") + \"\\n\";\n}\n\n/** Find the object expression in `export const css = { ... }`. */\nfunction findNamedCssExportObject(ast: t.File): t.ObjectExpression | null {\n for (const node of ast.program.body) {\n if (!t.isExportNamedDeclaration(node) || !node.declaration) continue;\n if (!t.isVariableDeclaration(node.declaration)) continue;\n\n for (const declarator of node.declaration.declarations) {\n if (!t.isIdentifier(declarator.id, { name: \"css\" })) continue;\n const value = unwrapObjectExpression(declarator.init);\n if (value) return value;\n }\n }\n return null;\n}\n\nfunction unwrapObjectExpression(node: t.Expression | null | undefined): t.ObjectExpression | null {\n if (!node) return null;\n if (t.isObjectExpression(node)) return node;\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node)) return unwrapObjectExpression(node.expression);\n return null;\n}\n\n/** Extract a static string key from an ObjectProperty. */\nfunction objectPropertyStringKey(prop: t.ObjectProperty, stringBindings: Map<string, string>): string | null {\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n // Allow unquoted identifiers as keys too (e.g. `body: Css.df.$`)\n if (t.isIdentifier(prop.key) && !prop.computed) return prop.key.name;\n if (prop.computed) return resolveStaticString(prop.key, stringBindings);\n return null;\n}\n\ninterface CssResolution {\n declarations: Array<{ property: string; value: string }>;\n error?: undefined;\n}\ninterface CssError {\n declarations?: undefined;\n error: string;\n}\n\n/**\n * Resolve a `Css.*.$` expression node to CSS declarations.\n *\n * Validates that the chain only uses static/literal patterns (no variable args,\n * no if/else conditionals, no pseudo/media modifiers).\n */\nfunction resolveCssExpression(\n node: t.Expression,\n cssBindingName: string,\n mapping: TrussMapping,\n filename: string,\n): CssResolution | CssError {\n // The expression must end with `.$`\n if (!t.isMemberExpression(node) || node.computed || !t.isIdentifier(node.property, { name: \"$\" })) {\n return { error: \"value must be a Css.*.$ expression\" };\n }\n\n const chain = extractChain(node.object, cssBindingName);\n if (!chain) {\n return { error: \"could not extract Css chain from expression\" };\n }\n\n // Validate: no if/else nodes\n for (const n of chain) {\n if (n.type === \"if\") return { error: \"if() conditionals are not supported in .css.ts files\" };\n if (n.type === \"else\") return { error: \"else is not supported in .css.ts files\" };\n }\n\n const resolved = resolveFullChain(chain, mapping);\n\n // Check for errors from resolution\n if (resolved.errors.length > 0) {\n return { error: resolved.errors[0] };\n }\n\n // Validate: no conditionals came back\n for (const part of resolved.parts) {\n if (part.type === \"conditional\") {\n return { error: \"conditional chains are not supported in .css.ts files\" };\n }\n }\n\n // Collect all declarations from all unconditional parts\n const declarations: Array<{ property: string; value: string }> = [];\n\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") continue;\n for (const seg of part.segments) {\n if (seg.error) {\n return { error: seg.error };\n }\n\n // Reject segments that require runtime (dynamic with variable args)\n if (seg.dynamicProps && !seg.argResolved) {\n return { error: `dynamic value with variable argument is not supported in .css.ts files` };\n }\n if (seg.typographyLookup) {\n return { error: `typography() with a runtime key is not supported in .css.ts files` };\n }\n if (seg.styleArrayArg) {\n return { error: `add(cssProp) is not supported in .css.ts files` };\n }\n\n // Reject segments with media query / pseudo-class / pseudo-element / when modifiers\n if (seg.mediaQuery) {\n return { error: `media query modifiers (ifSm, ifMd, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoClass) {\n return { error: `pseudo-class modifiers (onHover, onFocus, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoElement) {\n return { error: `pseudo-element modifiers are not supported in .css.ts files` };\n }\n if (seg.whenPseudo) {\n return { error: `when() modifiers are not supported in .css.ts files` };\n }\n\n // Extract CSS property/value pairs from defs\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (typeof value === \"string\" || typeof value === \"number\") {\n declarations.push({ property: camelToKebab(prop), value: String(value) });\n } else {\n // Nested condition objects (shouldn't happen after our validation, but defensive)\n return { error: `unexpected nested value for property \"${prop}\"` };\n }\n }\n }\n }\n\n return { declarations };\n}\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function camelToKebab(s: string): string {\n // Handle vendor prefixes like WebkitTransform → -webkit-transform\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** Format a CSS rule block. */\nfunction formatCssRule(selector: string, declarations: Array<{ property: string; value: string }>): string {\n if (declarations.length === 0) {\n return `${selector} {}`;\n }\n const body = declarations.map((d) => ` ${d.property}: ${d.value};`).join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n","import * as t from \"@babel/types\";\n\n/** Resolve module-scope string constants so .css.ts selectors can reuse them. */\nexport function collectStaticStringBindings(ast: t.File): Map<string, string> {\n const bindings = new Map<string, string>();\n let changed = true;\n\n while (changed) {\n changed = false;\n\n for (const node of ast.program.body) {\n const declaration = getTopLevelVariableDeclaration(node);\n if (!declaration) continue;\n\n for (const declarator of declaration.declarations) {\n if (!t.isIdentifier(declarator.id) || !declarator.init) continue;\n if (bindings.has(declarator.id.name)) continue;\n\n const value = resolveStaticString(declarator.init, bindings);\n if (value === null) continue;\n\n bindings.set(declarator.id.name, value);\n changed = true;\n }\n }\n }\n\n return bindings;\n}\n\n/** Resolve a static string expression from a literal, template, or identifier. */\nexport function resolveStaticString(node: t.Node | null | undefined, bindings: Map<string, string>): string | null {\n if (!node) return null;\n\n if (t.isStringLiteral(node)) return node.value;\n\n if (t.isTemplateLiteral(node)) {\n let value = \"\";\n for (let i = 0; i < node.quasis.length; i++) {\n value += node.quasis[i].value.cooked ?? \"\";\n if (i >= node.expressions.length) continue;\n\n const expressionValue = resolveStaticString(node.expressions[i], bindings);\n if (expressionValue === null) return null;\n value += expressionValue;\n }\n return value;\n }\n\n if (t.isIdentifier(node)) {\n return bindings.get(node.name) ?? null;\n }\n\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node) || t.isTSNonNullExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isParenthesizedExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isBinaryExpression(node, { operator: \"+\" })) {\n const left = resolveStaticString(node.left, bindings);\n const right = resolveStaticString(node.right, bindings);\n if (left === null || right === null) return null;\n return left + right;\n }\n\n return null;\n}\n\nfunction getTopLevelVariableDeclaration(node: t.Statement): t.VariableDeclaration | null {\n if (t.isVariableDeclaration(node)) {\n return node;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration && t.isVariableDeclaration(node.declaration)) {\n return node.declaration;\n }\n\n return null;\n}\n","import { parse } from \"@babel/parser\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { findLastImportIndex } from \"./ast-utils\";\n\n// Babel generator is published as CJS, so normalize default interop before using it.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface RewriteCssTsImportsResult {\n code: string;\n changed: boolean;\n}\n\n/**\n * Rewrite `.css.ts` imports so runtime imports stay pointed at the real module,\n * while a separate `?truss-css` side-effect import is added for generated CSS.\n *\n * I.e. `import { foo } from \"./App.css.ts\"` becomes:\n * - `import { foo } from \"./App.css.ts\"`\n * - `import \"./App.css.ts?truss-css\"`\n *\n * Pure side-effect imports are rewritten directly to the virtual CSS import.\n */\nexport function rewriteCssTsImports(code: string, filename: string): RewriteCssTsImportsResult {\n if (!code.includes(\".css.ts\")) {\n return { code, changed: false };\n }\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const existingCssSideEffects = new Set<string>();\n const neededCssSideEffects = new Set<string>();\n let changed = false;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (typeof node.source.value !== \"string\") continue;\n if (!node.source.value.endsWith(\".css.ts\")) continue;\n\n if (node.specifiers.length === 0) {\n node.source = t.stringLiteral(toVirtualCssSpecifier(node.source.value));\n existingCssSideEffects.add(node.source.value);\n changed = true;\n continue;\n }\n\n neededCssSideEffects.add(toVirtualCssSpecifier(node.source.value));\n }\n\n const sideEffectImports: t.ImportDeclaration[] = [];\n for (const source of neededCssSideEffects) {\n if (existingCssSideEffects.has(source)) continue;\n sideEffectImports.push(t.importDeclaration([], t.stringLiteral(source)));\n changed = true;\n }\n\n if (!changed) {\n return { code, changed: false };\n }\n\n if (sideEffectImports.length > 0) {\n const insertIndex = findLastImportIndex(ast) + 1;\n ast.program.body.splice(insertIndex, 0, ...sideEffectImports);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n return { code: output.code, changed: true };\n}\n\nfunction toVirtualCssSpecifier(source: string): string {\n return `${source}?truss-css`;\n}\n"],"mappings":";AAAA,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,SAAS,kBAAkB;;;ACD7C,SAAS,aAAa;AACtB,OAAOA,gBAAe;AAEtB,OAAOC,gBAAe;AACtB,YAAYC,QAAO;AACnB,SAAS,gBAAgB;;;AC4DlB,SAAS,iBAAiB,OAAoB,SAAsC;AACzF,QAAM,QAA6B,CAAC;AACpC,QAAM,UAA2B,CAAC;AAGlC,QAAM,gBAA6B,CAAC;AAEpC,QAAM,aAAuB,CAAC;AAC9B,WAAS,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACrC,UAAM,OAAO,MAAM,CAAC;AACpB,QAAI,KAAK,SAAS,YAAY,KAAK,SAAS,UAAU;AACpD,cAAQ,KAAK,EAAE,MAAM,SAAS,CAAC;AAAA,IACjC,WAAW,KAAK,SAAS,UAAU,KAAK,SAAS,YAAY;AAC3D,UAAI,KAAK,KAAK,WAAW,GAAG;AAC1B,mBAAW,KAAK,2FAA2F;AAAA,MAC7G,OAAO;AACL,gBAAQ,KAAK,EAAE,MAAM,UAAU,YAAY,KAAK,KAAK,CAAC,EAAE,CAAC;AAAA,MAC3D;AAAA,IACF,OAAO;AACL,oBAAc,KAAK,IAAI;AAAA,IACzB;AAAA,EACF;AAGA,MAAI,IAAI;AACR,MAAI,eAA4B,CAAC;AAEjC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,SAAO,QAAQ,eAAe,QAAQ,IAAI,GAAG,MAAM;AACrD;AAGA,SAAS,kBAAkB,IAAoB;AAC7C,QAAM,aAAa,GAAG,QAAQ,GAAG;AACjC,QAAM,YAAY,GAAG,QAAQ,GAAG;AAEhC,MAAI,MAAM,GAAG;AACb,MAAI,cAAc,EAAG,OAAM,KAAK,IAAI,KAAK,UAAU;AACnD,MAAI,aAAa,EAAG,OAAM,KAAK,IAAI,KAAK,SAAS;AAEjD,QAAM,UAAU,GAAG,MAAM,GAAG,GAAG;AAE/B,MAAI,QAAQ,WAAW,OAAO,GAAG;AAC/B,WAAO,QAAQ,MAAM,CAAC;AAAA,EACxB;AACA,SAAO;AACT;AAEA,SAAS,kBAAkB,UAA2B;AACpD,SAAO,cAAc,QAAQ,EAAE,SAAS,gBAAgB;AAC1D;AAEA,SAAS,iCAAiC,UAAkB,kBAAqC;AAC/F,QAAM,iBAAiB,cAAc,QAAQ;AAC7C,SAAO,iBAAiB,KAAK,SAAU,KAAK;AAC1C,WAAO,eAAe,SAAS,iBAAiB,GAAG,GAAG;AAAA,EACxD,CAAC;AACH;AAEA,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,OAAO,GAAG;AAChC;AAGO,SAAS,YAAY,MAA4B;AACtD,QAAM,MAAM,aAAa,MAAM,MAAM;AACrC,SAAO,KAAK,MAAM,GAAG;AACvB;","names":["_traverse","_generate","t","suffix","key","t","t","traverse","_traverse","generate","_generate","parse","t","t","parse","parse","_generate","t","generate","_generate","parse"]}
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/transform.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/ast-utils.ts","../../src/plugin/emit-stylex.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts","../../src/plugin/css-ts-utils.ts","../../src/plugin/rewrite-css-ts-imports.ts"],"sourcesContent":["import { readFileSync, existsSync } from \"fs\";\nimport { resolve, dirname, isAbsolute } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport { transformTruss } from \"./transform\";\nimport { transformCssTs } from \"./transform-css\";\nimport { rewriteCssTsImports } from \"./rewrite-css-ts-imports\";\n\nexport interface TrussPluginOptions {\n /** Path to the Css.json mapping file used for transforming files (relative to project root or absolute). */\n mapping: string;\n /** Packages in `node_modules` that should also be transformed, all other `node_modules` files are skipped. */\n externalPackages?: string[];\n}\n\nexport interface TrussVitePlugin {\n name: string;\n enforce?: \"pre\" | \"post\";\n configResolved?: (config: { root: string; command?: string; mode?: string }) => void;\n buildStart?: () => void;\n resolveId?: (source: string, importer: string | undefined) => string | null;\n load?: (id: string) => string | null;\n transform?: (code: string, id: string) => { code: string; map: any } | null;\n}\n\n/** Prefix for virtual CSS module IDs generated from .css.ts files. */\nconst VIRTUAL_CSS_PREFIX = \"\\0truss-css:\";\nconst CSS_TS_QUERY = \"?truss-css\";\n\n/**\n * Vite plugin that transforms `Css.*.$` expressions from truss's CssBuilder DSL\n * into file-local `stylex.create()` + `stylex.props()` calls.\n *\n * Also supports `.css.ts` files: a `.css.ts` file with\n * `export const css = { \".selector\": Css.blue.$ }` can keep other runtime exports,\n * while imports are supplemented with a virtual CSS side-effect module.\n *\n * Must be placed BEFORE the StyleX unplugin in the plugins array so that\n * StyleX's babel plugin can process the generated `stylex.create()` calls.\n */\nexport function trussPlugin(opts: TrussPluginOptions): TrussVitePlugin {\n let mapping: TrussMapping | null = null;\n let projectRoot: string;\n let debug = false;\n const externalPackages = opts.externalPackages ?? [];\n\n function mappingPath(): string {\n return resolve(projectRoot || process.cwd(), opts.mapping);\n }\n\n // Some tooling can call `transform` before `buildStart`; this keeps behavior\n // resilient without requiring hook ordering assumptions.\n function ensureMapping(): TrussMapping {\n if (!mapping) {\n mapping = loadMapping(mappingPath());\n }\n return mapping;\n }\n\n return {\n name: \"truss-stylex\",\n enforce: \"pre\",\n\n configResolved(config: { root: string; command?: string; mode?: string }) {\n projectRoot = config.root;\n debug = config.command === \"serve\" || config.mode === \"development\" || config.mode === \"test\";\n },\n\n buildStart() {\n ensureMapping();\n },\n\n resolveId(source: string, importer: string | undefined) {\n if (!source.endsWith(CSS_TS_QUERY)) return null;\n\n const absolutePath = resolveImportPath(source.slice(0, -CSS_TS_QUERY.length), importer, projectRoot);\n\n // Only handle it if the .css.ts file actually exists\n if (!existsSync(absolutePath)) return null;\n\n // Return a virtual CSS module ID that maps back to the source .css.ts file.\n // Strip the trailing `.ts` so the ID ends in `.css` — this tells Vite to\n // route the loaded content through its CSS pipeline.\n return VIRTUAL_CSS_PREFIX + absolutePath.slice(0, -3);\n },\n\n load(id: string) {\n if (!id.startsWith(VIRTUAL_CSS_PREFIX)) return null;\n\n // Re-add `.ts` to recover the original source file path\n const sourcePath = id.slice(VIRTUAL_CSS_PREFIX.length) + \".ts\";\n const sourceCode = readFileSync(sourcePath, \"utf8\");\n return transformCssTs(sourceCode, sourcePath, ensureMapping());\n },\n\n transform(code: string, id: string) {\n // Only process JS/TS/JSX/TSX files\n if (!/\\.[cm]?[jt]sx?(\\?|$)/.test(id)) return null;\n\n const rewrittenImports = rewriteCssTsImports(code, id);\n const rewrittenCode = rewrittenImports.code;\n const hasCssDsl = rewrittenCode.includes(\"Css\");\n if (!hasCssDsl && !rewrittenImports.changed) return null;\n\n const fileId = stripQueryAndHash(id);\n if (isNodeModulesFile(fileId) && !isWhitelistedExternalPackageFile(fileId, externalPackages)) {\n return null;\n }\n\n if (fileId.endsWith(\".css.ts\")) {\n // Keep `.css.ts` modules as normal TS so named exports like class-name\n // constants still work at runtime; only return code when we injected the\n // companion `?truss-css` side-effect import.\n return rewrittenImports.changed ? { code: rewrittenCode, map: null } : null;\n }\n\n if (!hasCssDsl) {\n // Some non-`.css.ts` modules only need the import rewrite and do not have\n // any `Css.*.$` expressions for the main Truss transform to process.\n return { code: rewrittenCode, map: null };\n }\n\n // For regular JS/TS modules that still use the DSL, run the full Truss\n // transform after the import rewrite so both behaviors compose.\n const result = transformTruss(rewrittenCode, fileId, ensureMapping(), { debug });\n if (!result) {\n if (!rewrittenImports.changed) return null;\n return { code: rewrittenCode, map: null };\n }\n return { code: result.code, map: result.map };\n },\n };\n}\n\nfunction resolveImportPath(source: string, importer: string | undefined, projectRoot: string | undefined): string {\n if (isAbsolute(source)) {\n return source;\n }\n\n if (importer) {\n return resolve(dirname(importer), source);\n }\n\n return resolve(projectRoot || process.cwd(), source);\n}\n\n/** Strip Vite query/hash suffixes from an id. */\nfunction stripQueryAndHash(id: string): string {\n const queryIndex = id.indexOf(\"?\");\n const hashIndex = id.indexOf(\"#\");\n\n let end = id.length;\n if (queryIndex >= 0) end = Math.min(end, queryIndex);\n if (hashIndex >= 0) end = Math.min(end, hashIndex);\n\n const cleanId = id.slice(0, end);\n // Vite can prefix absolute paths with `/@fs/`.\n if (cleanId.startsWith(\"/@fs/\")) {\n return cleanId.slice(4);\n }\n return cleanId;\n}\n\nfunction isNodeModulesFile(filePath: string): boolean {\n return normalizePath(filePath).includes(\"/node_modules/\");\n}\n\nfunction isWhitelistedExternalPackageFile(filePath: string, externalPackages: string[]): boolean {\n const normalizedPath = normalizePath(filePath);\n return externalPackages.some(function (pkg) {\n return normalizedPath.includes(`/node_modules/${pkg}/`);\n });\n}\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n\n/** Load a truss mapping file synchronously (for tests). */\nexport function loadMapping(path: string): TrussMapping {\n const raw = readFileSync(path, \"utf8\");\n return JSON.parse(raw);\n}\n\nexport type { TrussMapping, TrussMappingEntry } from \"./types\";\n","import { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { basename } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport {\n collectTopLevelBindings,\n reservePreferredName,\n findCssImportBinding,\n removeCssImport,\n findStylexNamespaceImport,\n insertStylexNamespaceImport,\n findNamedImportBinding,\n upsertNamedImports,\n extractChain,\n} from \"./ast-utils\";\nimport {\n collectCreateData,\n buildCreateProperties,\n buildMaybeIncDeclaration,\n buildCreateDeclaration,\n buildRuntimeLookupDeclaration,\n} from \"./emit-stylex\";\nimport { rewriteExpressionSites, type ExpressionSite } from \"./rewrite-sites\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface TransformResult {\n code: string;\n map?: unknown;\n}\n\nexport interface TransformTrussOptions {\n debug?: boolean;\n}\n\n/**\n * The core transform function. Given a source file's code and the truss mapping,\n * finds all `Css.*.$` expressions and rewrites them into file-local\n * `stylex.create()` + `stylex.props()` calls.\n *\n * Returns null if the file doesn't use Css.\n */\nexport function transformTruss(\n code: string,\n filename: string,\n mapping: TrussMapping,\n options: TransformTrussOptions = {},\n): TransformResult | null {\n // Fast bail: skip files that don't reference Css\n if (!code.includes(\"Css\")) return null;\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n // Step 1: Find the Css import binding name\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) return null;\n\n // Step 2: Collect all Css expression sites\n const sites: ExpressionSite[] = [];\n /** Error messages with source location info, to be emitted as console.error calls. */\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n\n traverse(ast, {\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!t.isIdentifier(path.node.property, { name: \"$\" })) return;\n if (path.node.computed) return;\n\n const chain = extractChain(path.node.object, cssBindingName);\n if (!chain) return;\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n const resolvedChain = resolveFullChain(chain, mapping);\n sites.push({ path, resolvedChain });\n\n // Collect any errors from this chain with source location\n const line = path.node.loc?.start.line ?? null;\n for (const err of resolvedChain.errors) {\n errorMessages.push({ message: err, line });\n }\n },\n });\n\n if (sites.length === 0) return null;\n\n // Step 3: Collect stylex.create entries and helper needs\n const { createEntries, runtimeLookups, needsMaybeInc } = collectCreateData(sites.map((s) => s.resolvedChain));\n\n // Reserve local names we might inject at the top level\n // We do this up front so helper/style variable names are deterministic and\n // cannot collide with user code in the same module.\n const usedTopLevelNames = collectTopLevelBindings(ast);\n const existingStylexNamespace = findStylexNamespaceImport(ast);\n const stylexNamespaceName = existingStylexNamespace ?? reservePreferredName(usedTopLevelNames, \"stylex\");\n const createVarName = reservePreferredName(usedTopLevelNames, \"css\", \"css_\");\n const maybeIncHelperName = needsMaybeInc ? reservePreferredName(usedTopLevelNames, \"__maybeInc\") : null;\n const existingMergePropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"mergeProps\");\n const mergePropsHelperName = existingMergePropsHelperName ?? reservePreferredName(usedTopLevelNames, \"mergeProps\");\n const needsMergePropsHelper = { current: false };\n const existingAsStyleArrayHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"asStyleArray\");\n const asStyleArrayHelperName =\n existingAsStyleArrayHelperName ?? reservePreferredName(usedTopLevelNames, \"asStyleArray\");\n const needsAsStyleArrayHelper = { current: false };\n const existingTrussPropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"trussProps\");\n const trussPropsHelperName = existingTrussPropsHelperName ?? reservePreferredName(usedTopLevelNames, \"trussProps\");\n const needsTrussPropsHelper = { current: false };\n const existingTrussDebugInfoName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"TrussDebugInfo\");\n const trussDebugInfoName = existingTrussDebugInfoName ?? reservePreferredName(usedTopLevelNames, \"TrussDebugInfo\");\n const needsTrussDebugInfo = { current: false };\n const runtimeLookupNames = new Map<string, string>();\n for (const [lookupKey] of runtimeLookups) {\n runtimeLookupNames.set(lookupKey, reservePreferredName(usedTopLevelNames, `__${lookupKey}`));\n }\n\n const createProperties = buildCreateProperties(createEntries, stylexNamespaceName);\n\n // Step 4: Rewrite Css sites in-place\n rewriteExpressionSites({\n ast,\n sites,\n cssBindingName,\n filename: basename(filename),\n debug: options.debug ?? false,\n createVarName,\n stylexNamespaceName,\n maybeIncHelperName,\n mergePropsHelperName,\n needsMergePropsHelper,\n trussPropsHelperName,\n needsTrussPropsHelper,\n trussDebugInfoName,\n needsTrussDebugInfo,\n asStyleArrayHelperName,\n needsAsStyleArrayHelper,\n skippedCssPropMessages: errorMessages,\n runtimeLookupNames,\n });\n\n // Step 5: Remove Css import now that all usages were rewritten\n removeCssImport(ast, cssBindingName);\n\n // Step 6: Ensure namespace stylex import exists\n if (!findStylexNamespaceImport(ast)) {\n insertStylexNamespaceImport(ast, stylexNamespaceName);\n }\n if (\n needsMergePropsHelper.current ||\n needsAsStyleArrayHelper.current ||\n needsTrussPropsHelper.current ||\n needsTrussDebugInfo.current\n ) {\n const runtimeImports: Array<{ importedName: string; localName: string }> = [];\n if (needsMergePropsHelper.current) {\n runtimeImports.push({ importedName: \"mergeProps\", localName: mergePropsHelperName });\n }\n if (needsAsStyleArrayHelper.current) {\n runtimeImports.push({ importedName: \"asStyleArray\", localName: asStyleArrayHelperName });\n }\n if (needsTrussPropsHelper.current) {\n runtimeImports.push({ importedName: \"trussProps\", localName: trussPropsHelperName });\n }\n if (needsTrussDebugInfo.current) {\n runtimeImports.push({ importedName: \"TrussDebugInfo\", localName: trussDebugInfoName });\n }\n upsertNamedImports(ast, \"@homebound/truss/runtime\", runtimeImports);\n }\n\n // Step 7: Hoist marker declarations that are referenced in stylex.create entries.\n // stylex.create uses computed keys like `[stylex.when.ancestor(\":hover\", row)]`\n // which reference marker variables — these must be declared before stylex.create.\n const markerVarNames = collectReferencedMarkerNames(createEntries);\n const hoistedMarkerDecls = hoistMarkerDeclarations(ast, markerVarNames);\n\n // Step 8: Insert helper declarations after imports\n const declarationsToInsert: t.Statement[] = [];\n if (maybeIncHelperName) {\n declarationsToInsert.push(buildMaybeIncDeclaration(maybeIncHelperName, mapping.increment));\n }\n // Hoisted marker declarations go before stylex.create so they're in scope\n declarationsToInsert.push(...hoistedMarkerDecls);\n if (createProperties.length > 0) {\n declarationsToInsert.push(buildCreateDeclaration(createVarName, stylexNamespaceName, createProperties));\n for (const [lookupKey, lookup] of runtimeLookups) {\n const lookupName = runtimeLookupNames.get(lookupKey);\n if (!lookupName) continue;\n declarationsToInsert.push(buildRuntimeLookupDeclaration(lookupName, createVarName, lookup));\n }\n }\n\n // Step 8: Emit console.error calls for any unsupported patterns\n for (const { message, line } of errorMessages) {\n const location = line !== null ? `${filename}:${line}` : filename;\n const logMessage = `${message} (${location})`;\n const consoleError = t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier(\"console\"), t.identifier(\"error\")), [\n t.stringLiteral(logMessage),\n ]),\n );\n declarationsToInsert.push(consoleError);\n }\n\n if (declarationsToInsert.length > 0) {\n const insertIndex = ast.program.body.findIndex(function (node) {\n return !t.isImportDeclaration(node);\n });\n ast.program.body.splice(insertIndex === -1 ? ast.program.body.length : insertIndex, 0, ...declarationsToInsert);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n\n return { code: output.code, map: output.map };\n}\n\n/**\n * Collect the names of marker variables referenced in `whenPseudo.markerNode`\n * across all stylex.create entries. These need to be hoisted above stylex.create.\n */\nfunction collectReferencedMarkerNames(\n createEntries: Map<string, { whenPseudo?: { markerNode?: t.Node } }>,\n): Set<string> {\n const names = new Set<string>();\n for (const [, entry] of createEntries) {\n if (entry.whenPseudo?.markerNode && entry.whenPseudo.markerNode.type === \"Identifier\") {\n names.add(entry.whenPseudo.markerNode.name);\n }\n }\n return names;\n}\n\n/**\n * Find top-level variable declarations for the given names, remove them from\n * their original position in the AST, and return them for reinsertion above\n * the stylex.create call.\n *\n * This handles `const row = stylex.defineMarker()` being declared after code\n * that uses it in a Css.when() chain — the stylex.create computed key\n * `[stylex.when.ancestor(\":hover\", row)]` needs `row` to be in scope.\n */\nfunction hoistMarkerDeclarations(ast: t.File, names: Set<string>): t.Statement[] {\n if (names.size === 0) return [];\n const hoisted: t.Statement[] = [];\n const remaining = new Set(names);\n\n for (let i = ast.program.body.length - 1; i >= 0; i--) {\n if (remaining.size === 0) break;\n const node = ast.program.body[i];\n\n if (!t.isVariableDeclaration(node)) continue;\n\n // Check if any declarator in this statement matches a marker name\n const matchingDeclarators: t.VariableDeclarator[] = [];\n const otherDeclarators: t.VariableDeclarator[] = [];\n for (const decl of node.declarations) {\n if (t.isIdentifier(decl.id) && remaining.has(decl.id.name)) {\n matchingDeclarators.push(decl);\n remaining.delete(decl.id.name);\n } else {\n otherDeclarators.push(decl);\n }\n }\n\n if (matchingDeclarators.length === 0) continue;\n\n if (otherDeclarators.length === 0) {\n // Entire statement is marker declarations — remove it\n ast.program.body.splice(i, 1);\n hoisted.push(node);\n } else {\n // Split: keep non-marker declarators in place, hoist the marker ones\n node.declarations = otherDeclarators;\n hoisted.push(t.variableDeclaration(node.kind, matchingDeclarators));\n }\n }\n\n // Reverse so they appear in original source order\n hoisted.reverse();\n return hoisted;\n}\n","import type * as t from \"@babel/types\";\nimport type { TrussMapping, TrussMappingEntry, ResolvedSegment, MarkerSegment } from \"./types\";\n\n/**\n * A resolved chain that may contain conditional (if/else) sections.\n *\n * I.e. `ChainNode` from ast-utils.ts is just the raw AST chain from `Css` to `.$`, which may contain if/else\n * nodes; this `ResolvedChain` is the post-processed result where each if/else has been split into separate segments.\n *\n * The `parts` array contains unconditional segments and conditional groups.\n * The `markers` array contains marker directives (Css.marker.$, Css.markerOf(\"x\").$).\n */\nexport interface ResolvedChain {\n parts: ResolvedChainPart[];\n /** Marker directives to attach to the element (not CSS styles). */\n markers: MarkerSegment[];\n /** Error messages from unsupported patterns found in this chain. */\n errors: string[];\n}\n\nexport type ResolvedChainPart =\n | { type: \"unconditional\"; segments: ResolvedSegment[] }\n | { type: \"conditional\"; conditionNode: any; thenSegments: ResolvedSegment[]; elseSegments: ResolvedSegment[] };\n\n/**\n * High-level chain resolver that handles if/else by splitting into parts.\n *\n * ## Chain semantics\n *\n * A `Css.*.$` chain is read left-to-right. Each segment is either a style\n * abbreviation (getter or call) or a modifier that changes the context for\n * subsequent styles. The modifiers and their precedence:\n *\n * - **`if(bool)`** / **`else`** — Boolean conditional. Splits the chain into\n * then/else branches at the AST level. Subsequent styles go into the active\n * branch. A new `if` starts a new conditional.\n *\n * - **`if(mediaQuery)`** — String overload. Sets the media query context\n * (same as `ifSm`, `ifMd` etc.) for subsequent styles. Does NOT create\n * a boolean branch.\n *\n * - **`ifSm`**, **`ifMd`**, **`ifLg`**, etc. — Breakpoint getters. Set the\n * media query context. Stacks with pseudo-classes: `ifSm.onHover.blue.$`\n * produces `{ color: { default: null, \":hover\": { default: null, \"@media...\": value } } }`.\n *\n * - **`onHover`**, **`onFocus`**, etc. — Pseudo-class getters. Set the\n * pseudo-class context. Stacks with media queries (see above). A new\n * pseudo-class replaces the previous one.\n *\n * - **`element(\"::placeholder\")`** — Pseudo-element. Sets the pseudo-element\n * context. Wraps subsequent defs in a top-level namespace key:\n * `{ \"::placeholder\": { color: value } }`. Stacks with pseudo-classes\n * and media queries inside the pseudo-element.\n *\n * - **`when(\"ancestor\", \":hover\")`** — StyleX `when` API. Resets both media\n * query and pseudo-class contexts. Uses `stylex.when.<relationship>()`\n * computed keys.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * Contexts accumulate left-to-right until explicitly replaced. A media query\n * set by `ifSm` persists through `onHover` (they stack). A new `if(bool)`\n * resets all contexts for its branches.\n */\nexport function resolveFullChain(chain: ChainNode[], mapping: TrussMapping): ResolvedChain {\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n\n // Pre-scan for marker nodes and strip them from the chain\n const filteredChain: ChainNode[] = [];\n /** Errors found during marker scanning — attached to the chain result */\n const scanErrors: string[] = [];\n for (let j = 0; j < chain.length; j++) {\n const node = chain[j];\n if (node.type === \"getter\" && node.name === \"marker\") {\n markers.push({ type: \"marker\" });\n } else if (node.type === \"call\" && node.name === \"markerOf\") {\n if (node.args.length !== 1) {\n scanErrors.push(\"[truss] Unsupported pattern: markerOf() requires exactly one argument (a marker variable)\");\n } else {\n markers.push({ type: \"marker\", markerNode: node.args[0] });\n }\n } else {\n filteredChain.push(node);\n }\n }\n\n // Split chain at if/else boundaries\n let i = 0;\n let currentNodes: ChainNode[] = [];\n\n while (i < filteredChain.length) {\n const node = filteredChain[i];\n if (node.type === \"if\") {\n // if(stringLiteral) → media query pseudo, not a boolean conditional\n if (node.conditionNode.type === \"StringLiteral\") {\n const mediaQuery: string = (node.conditionNode as any).value;\n // Inject a synthetic \"media query pseudo\" into the current unconditional nodes.\n // This works by creating a synthetic call node that resolveChain's pseudo handling\n // can recognize — but it's simpler to just inject it as a special marker.\n currentNodes.push({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({\n type: \"unconditional\",\n segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)),\n });\n currentNodes = [];\n }\n // Collect \"then\" nodes until \"else\" or end\n const thenNodes: ChainNode[] = [];\n const elseNodes: ChainNode[] = [];\n i++;\n let inElse = false;\n while (i < filteredChain.length) {\n if (filteredChain[i].type === \"else\") {\n inElse = true;\n i++;\n continue;\n }\n if (filteredChain[i].type === \"if\") {\n // Nested if — break out and let the outer loop handle it\n break;\n }\n if (inElse) {\n elseNodes.push(filteredChain[i]);\n } else {\n thenNodes.push(filteredChain[i]);\n }\n i++;\n }\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: mergeOverlappingConditions(resolveChain(thenNodes, mapping)),\n elseSegments: mergeOverlappingConditions(resolveChain(elseNodes, mapping)),\n });\n } else {\n currentNodes.push(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n if (currentNodes.length > 0) {\n parts.push({ type: \"unconditional\", segments: mergeOverlappingConditions(resolveChain(currentNodes, mapping)) });\n }\n\n // Collect error messages from all resolved segments\n const segmentErrors: string[] = [];\n for (const part of parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error) {\n segmentErrors.push(seg.error);\n }\n }\n }\n\n return { parts, markers, errors: [...scanErrors, ...segmentErrors] };\n}\n\n/**\n * Walks a Css member-expression chain (the AST between `Css` and `.$`) and\n * resolves each segment into CSS property definitions using the truss mapping.\n *\n * Returns an array of ResolvedSegment, or throws if a pattern is unsupported.\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(chain: ChainNode[], mapping: TrussMapping): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n // Track media query and pseudo-class separately so they can stack.\n // e.g. Css.ifSm.onHover.blue.$ → both mediaQuery and pseudoClass are set\n let currentMediaQuery: string | null = null;\n let currentPseudoClass: string | null = null;\n let currentPseudoElement: string | null = null;\n let currentWhenPseudo: { pseudo: string; markerNode?: any; relationship?: string } | null = null;\n\n for (const node of chain) {\n try {\n // Synthetic media query node injected by resolveFullChain for if(\"@media...\")\n if ((node as any).type === \"__mediaQuery\") {\n currentMediaQuery = (node as any).mediaQuery;\n currentWhenPseudo = null;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n currentMediaQuery = mapping.breakpoints[abbr];\n currentWhenPseudo = null;\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n const resolved = resolveEntry(\n abbr,\n entry,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(...resolved);\n } else if (node.type === \"call\") {\n const abbr = node.name;\n\n // Container query call: ifContainer({ gt, lt, name? })\n if (abbr === \"ifContainer\") {\n currentMediaQuery = containerSelectorFromCall(node);\n currentWhenPseudo = null;\n continue;\n }\n\n // add(prop, value) — arbitrary CSS property\n if (abbr === \"add\") {\n const seg = resolveAddCall(node, mapping, currentMediaQuery, currentPseudoClass, currentPseudoElement);\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(...resolved);\n continue;\n }\n\n // Pseudo-element: element(\"::placeholder\") etc.\n if (abbr === \"element\") {\n if (node.args.length !== 1 || node.args[0].type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(\n `element() requires exactly one string literal argument (e.g. \"::placeholder\")`,\n );\n }\n currentPseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(relationship, pseudo) or when(relationship, marker, pseudo)\n if (abbr === \"when\") {\n const resolved = resolveWhenCall(node);\n currentPseudoClass = null;\n currentMediaQuery = null;\n currentWhenPseudo = resolved;\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(\"ancestor\", \":hover\") for relationship pseudos`,\n );\n }\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n if (entry.kind === \"dynamic\") {\n const seg = resolveDynamicCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(seg);\n } else {\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" is ${entry.kind}, cannot be called as a function`);\n }\n }\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n segments.push({ key: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/** Build the stylex.create key suffix from mediaQuery, pseudoClass, and/or pseudoElement. */\nexport function conditionKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoName(pseudoElement));\n if (mediaQuery) parts.push(pseudoName(mediaQuery, breakpoints));\n if (pseudoClass) parts.push(pseudoName(pseudoClass));\n return parts.join(\"_\");\n}\n\n/** Resolve `typography(key)` into either direct segments or a runtime lookup-backed segment. */\nfunction resolveTypographyCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`typography() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n if (argAst.type === \"StringLiteral\") {\n return resolveTypographyEntry(argAst.value, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n const typography = mapping.typography ?? [];\n if (typography.length === 0) {\n throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const lookupKey = suffix ? `typography__${suffix}` : \"typography\";\n const segmentsByName: Record<string, ResolvedSegment[]> = {};\n\n for (const name of typography) {\n segmentsByName[name] = resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n return [\n {\n key: lookupKey,\n defs: {},\n typographyLookup: {\n lookupKey,\n argNode: argAst,\n segmentsByName,\n },\n },\n ];\n}\n\n/** Resolve a single typography abbreviation name within the current condition context. */\nfunction resolveTypographyEntry(\n name: string,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (!(mapping.typography ?? []).includes(name)) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const entry = mapping.abbreviations[name];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const resolved = resolveEntry(name, entry, mapping, mediaQuery, pseudoClass, pseudoElement, null);\n for (const segment of resolved) {\n if (segment.dynamicProps || segment.whenPseudo) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/**\n * Wrap raw CSS defs with condition nesting for StyleX.\n *\n * - mediaQuery only: `{ prop: { default: null, \"@media...\": value } }`\n * - pseudoClass only: `{ prop: { default: null, \":hover\": value } }`\n * - both (stacked): `{ prop: { default: null, \":hover\": { default: null, \"@media...\": value } } }`\n */\nfunction wrapDefsWithConditions(\n defs: Record<string, unknown>,\n mediaQuery: string | null,\n pseudoClass: string | null,\n): Record<string, unknown> {\n if (!mediaQuery && !pseudoClass) return defs;\n const result: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(defs)) {\n if (pseudoClass && mediaQuery) {\n result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };\n } else if (pseudoClass) {\n result[prop] = { default: null, [pseudoClass]: value };\n } else {\n result[prop] = { default: null, [mediaQuery!]: value };\n }\n }\n return result;\n}\n\n/** Resolve a static or alias entry (from a getter access). */\nfunction resolveEntry(\n abbr: string,\n entry: TrussMappingEntry,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment[] {\n switch (entry.kind) {\n case \"static\": {\n if (whenPseudo) {\n const suffix = whenPseudoKeyName(whenPseudo);\n const key = `${abbr}__${suffix}`;\n return [{ key, defs: entry.defs, whenPseudo }];\n }\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n const defs = pseudoElement\n ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) }\n : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);\n return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];\n }\n case \"alias\": {\n const result: ResolvedSegment[] = [];\n for (const chainAbbr of entry.chain) {\n const subEntry = mapping.abbreviations[chainAbbr];\n if (!subEntry) {\n throw new UnsupportedPatternError(`Alias \"${abbr}\" references unknown abbreviation \"${chainAbbr}\"`);\n }\n result.push(...resolveEntry(chainAbbr, subEntry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo));\n }\n return result;\n }\n case \"dynamic\":\n case \"delegate\":\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" requires arguments — use ${abbr}() not .${abbr}`);\n default:\n throw new UnsupportedPatternError(`Unhandled entry kind for \"${abbr}\"`);\n }\n}\n\n/** Resolve a dynamic (parameterized) call like mt(2) or mt(x). */\nfunction resolveDynamicCall(\n abbr: string,\n entry: { kind: \"dynamic\"; props: string[]; incremented: boolean; extraDefs?: Record<string, unknown> },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluateLiteral(argAst, entry.incremented, mapping.increment);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) {\n Object.assign(defs, entry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n dynamicProps: entry.props,\n incremented: entry.incremented,\n dynamicExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/** Resolve a delegate call like mtPx(12). */\nfunction resolveDelegateCall(\n abbr: string,\n entry: { kind: \"delegate\"; target: string },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n const targetEntry = mapping.abbreviations[entry.target];\n if (!targetEntry || targetEntry.kind !== \"dynamic\") {\n throw new UnsupportedPatternError(`Delegate \"${abbr}\" targets \"${entry.target}\" which is not a dynamic entry`);\n }\n\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluatePxLiteral(argAst);\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) {\n Object.assign(defs, targetEntry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${entry.target}__${suffix}` : entry.target;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: targetEntry.props,\n incremented: false,\n appendPx: true,\n dynamicExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/**\n * Resolve an `add(...)` call.\n *\n * Supported overloads:\n * - `add(cssProp)` to inline an existing CssProp array into the chain output\n * - `add(\"propName\", value)` for an arbitrary CSS property/value pair\n */\nfunction resolveAddCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment {\n if (node.args.length === 1) {\n const styleArg = node.args[0];\n if (styleArg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`add() does not support spread arguments`);\n }\n if (styleArg.type === \"ObjectExpression\") {\n throw new UnsupportedPatternError(\n `add(cssProp) does not accept object literals -- pass an existing CssProp expression instead`,\n );\n }\n return {\n key: \"__composed_css_prop\",\n defs: {},\n styleArrayArg: styleArg,\n };\n }\n\n if (node.args.length !== 2) {\n throw new UnsupportedPatternError(\n `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. ` +\n `Supported overloads are add(cssProp) and add(\"propName\", value)`,\n );\n }\n\n const propArg = node.args[0];\n if (propArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`add() first argument must be a string literal property name`);\n }\n const propName: string = (propArg as any).value;\n\n const valueArg = node.args[1];\n // Try to evaluate the value as a literal\n const literalValue = tryEvaluateAddLiteral(valueArg);\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = suffix ? `add_${propName}__${keySuffix}__${suffix}` : `add_${propName}__${keySuffix}`;\n const defs: Record<string, unknown> = { [propName]: literalValue };\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `add_${propName}__${suffix}` : `add_${propName}`;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n dynamicProps: [propName],\n incremented: false,\n argNode: valueArg,\n };\n }\n}\n\n/** Try to evaluate a literal for add() — strings, numbers, and template literals with no expressions. */\nfunction tryEvaluateAddLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"StringLiteral\") {\n return (node as any).value;\n }\n if (node.type === \"NumericLiteral\") {\n return String((node as any).value);\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return String(-(node.argument as any).value);\n }\n return null;\n}\n\nconst WHEN_RELATIONSHIPS = new Set([\"ancestor\", \"descendant\", \"anySibling\", \"siblingBefore\", \"siblingAfter\"]);\n\n/**\n * Resolve a `when(relationship, pseudo)` or `when(relationship, marker, pseudo)` call.\n *\n * - 2 args: `when(\"ancestor\", \":hover\")` — both must be string literals\n * - 3 args: `when(\"ancestor\", marker, \":hover\")` — 1st and 3rd must be string literals, 2nd is a marker variable\n */\nfunction resolveWhenCall(node: CallChainNode): { pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length < 2 || node.args.length > 3) {\n throw new UnsupportedPatternError(\n `when() expects 2 or 3 arguments (relationship, [marker], pseudo), got ${node.args.length}`,\n );\n }\n\n const relationshipArg = node.args[0];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() first argument must be a string literal relationship`);\n }\n const relationship: string = (relationshipArg as any).value;\n if (!WHEN_RELATIONSHIPS.has(relationship)) {\n throw new UnsupportedPatternError(\n `when() relationship must be one of: ${[...WHEN_RELATIONSHIPS].join(\", \")} -- got \"${relationship}\"`,\n );\n }\n\n if (node.args.length === 2) {\n // when(\"ancestor\", \":hover\")\n const pseudoArg = node.args[1];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, relationship };\n } else {\n // when(\"ancestor\", marker, \":hover\")\n const markerNode = node.args[1];\n const pseudoArg = node.args[2];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector (3rd argument) must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, markerNode, relationship };\n }\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n};\n\nfunction isPseudoMethod(name: string): boolean {\n return name in PSEUDO_METHODS;\n}\n\nfunction pseudoSelector(name: string): string {\n return PSEUDO_METHODS[name];\n}\n\n/**\n * Generate the stylex.create key suffix for when/ancestor pseudo segments.\n * e.g. { pseudo: \":hover\" } → \"ancestorHover\"\n * e.g. { pseudo: \":hover\", relationship: \"descendant\" } → \"descendantHover\"\n * e.g. { pseudo: \":hover\", markerNode: Identifier(\"row\") } → \"ancestorHover_row\"\n */\nfunction whenPseudoKeyName(ap: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = ap.relationship ?? \"ancestor\";\n const pn = pseudoName(ap.pseudo);\n const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;\n if (!ap.markerNode) return base;\n // Use the identifier name for readable keys; fall back to a generic suffix for complex expressions\n const suffix = ap.markerNode.type === \"Identifier\" ? ap.markerNode.name : \"marker\";\n return `${base}_${suffix}`;\n}\n\n/**\n * Post-process resolved segments to merge entries that target the same CSS\n * properties into a single `stylex.create` entry with stacked conditions.\n *\n * For example, `Css.black.ifSm.white.onHover.blue.$` produces three segments:\n * 1. `black` → `{ color: \"#353535\" }` (base)\n * 2. `white__sm` → `{ color: { default: null, \"@media...\": \"#fcfcfa\" } }` (media-only)\n * 3. `blue__sm_hover` → `{ color: { default: null, \":hover\": { default: null, \"@media...\": \"#526675\" } } }` (media+pseudo)\n *\n * All three set `color`, so they merge into one entry:\n * `{ color: { default: \"#353535\", \"@media...\": \"#fcfcfa\", \":hover\": { default: null, \"@media...\": \"#526675\" } } }`\n */\nexport function mergeOverlappingConditions(segments: ResolvedSegment[]): ResolvedSegment[] {\n // Index: for each CSS property, which segments set it?\n // Only static segments (no dynamicProps, no styleArrayArg, no whenPseudo, no error) participate in merging.\n const propToIndices = new Map<string, number[]>();\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n if (seg.dynamicProps || seg.styleArrayArg || seg.whenPseudo || seg.error) continue;\n for (const prop of Object.keys(seg.defs)) {\n if (!propToIndices.has(prop)) propToIndices.set(prop, []);\n propToIndices.get(prop)!.push(i);\n }\n }\n\n // Find properties where a base (no-condition) segment overlaps with conditional segments.\n // Two base segments setting the same property is NOT a merge — the later one just overrides.\n const mergeableProps = new Set<string>();\n for (const [prop, indices] of propToIndices) {\n if (indices.length < 2) continue;\n const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);\n const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));\n if (hasBase && hasConditional) {\n mergeableProps.add(prop);\n }\n }\n\n if (mergeableProps.size === 0) return segments;\n\n // For each mergeable property, deep-merge all contributing segments into one defs object.\n // Track which segment indices have properties consumed by the merge.\n const consumedProps = new Map<number, Set<string>>(); // segIndex → consumed prop names\n const mergedPropDefs = new Map<string, { defs: Record<string, unknown>; key: string }>();\n\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n let merged: Record<string, unknown> = {};\n const keyParts: string[] = [];\n\n for (const idx of indices) {\n const seg = segments[idx];\n const value = seg.defs[prop];\n keyParts.push(seg.key);\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n // Base value → default\n merged.default = value;\n } else if (typeof value === \"object\" && value !== null) {\n // Conditional value — merge all keys (may include default: null which base will override)\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"default\" && v === null && merged.default !== undefined) {\n // Don't let a conditional's `default: null` clobber the base value\n continue;\n }\n merged[k] = v;\n }\n }\n\n // Mark this property as consumed from this segment\n if (!consumedProps.has(idx)) consumedProps.set(idx, new Set());\n consumedProps.get(idx)!.add(prop);\n }\n\n // If the merged object has only a `default` key, it's just a raw value (no conditions)\n const finalValue = Object.keys(merged).length === 1 && \"default\" in merged ? merged.default : merged;\n const mergedKey = [...new Set(keyParts)].join(\"_\");\n mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });\n }\n\n // Group mergeable props that share the exact same set of contributing segments\n // so they become one stylex.create entry.\n const groupByIndices = new Map<string, { props: string[]; key: string }>();\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n const groupKey = indices.join(\",\");\n if (!groupByIndices.has(groupKey)) {\n groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop)!.key });\n }\n groupByIndices.get(groupKey)!.props.push(prop);\n }\n\n // Build merged segments\n const mergedSegments: ResolvedSegment[] = [];\n for (const [, group] of groupByIndices) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n mergedSegments.push({ key: group.key, defs });\n }\n\n // Rebuild result: emit non-consumed segments (or segments with remaining non-consumed props),\n // then emit merged segments at the position of the first consumed segment.\n const result: ResolvedSegment[] = [];\n const mergedEmitted = new Set<string>();\n\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const consumed = consumedProps.get(i);\n\n if (!consumed) {\n // Not involved in any merge\n result.push(seg);\n continue;\n }\n\n // Emit any non-consumed properties from this segment\n const remainingDefs: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (!consumed.has(prop)) {\n remainingDefs[prop] = value;\n }\n }\n if (Object.keys(remainingDefs).length > 0) {\n result.push({ ...seg, defs: remainingDefs });\n }\n\n // Emit the merged segment(s) at the position of the first segment that contributed\n const indices = [...propToIndices.entries()]\n .filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop))\n .map(([, idxs]) => idxs.join(\",\"));\n\n for (const groupKey of new Set(indices)) {\n if (!mergedEmitted.has(groupKey)) {\n const group = groupByIndices.get(groupKey);\n if (group) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n result.push({ key: group.key, defs });\n mergedEmitted.add(groupKey);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Convert a pseudo/media selector into a short key suffix.\n * \":hover\" → \"hover\", \":focus-visible\" → \"focus_visible\"\n * \"@media screen and (max-width:599px)\" → \"sm\" (using breakpoints reverse map)\n * \"@container (min-width: 601px)\" → \"container_min_width_601px\"\n */\nexport function pseudoName(pseudo: string, breakpoints?: Record<string, string>): string {\n if (pseudo.startsWith(\"@media\") && breakpoints) {\n // Reverse lookup: find the breakpoint getter name (e.g. \"ifSm\") and strip \"if\" prefix\n for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {\n if (mediaQuery === pseudo) {\n // \"ifSm\" → \"sm\", \"ifSmOrMd\" → \"smOrMd\", \"ifMdAndUp\" → \"mdAndUp\"\n return getterName.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase());\n }\n }\n // Fallback: create a compact name from the media query\n return pseudo\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n if (pseudo.startsWith(\"@container\")) {\n return pseudo\n .replace(/^@container\\s*/, \"container \")\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n return pseudo.replace(/^:+/, \"\").replace(/-/g, \"_\");\n}\n\n/**\n * Try to evaluate a literal AST node to a string value.\n * For incremented entries, also evaluates `maybeInc(literal)`.\n */\nfunction tryEvaluateLiteral(\n node: t.Expression | t.SpreadElement,\n incremented: boolean,\n increment: number,\n): string | null {\n if (node.type === \"NumericLiteral\") {\n if (incremented) {\n return `${node.value * increment}px`;\n }\n return String(node.value);\n }\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n const val = -node.argument.value;\n if (incremented) {\n return `${val * increment}px`;\n }\n return String(val);\n }\n return null;\n}\n\n/** Try to evaluate a Px delegate argument (always a number → `${n}px`). */\nfunction tryEvaluatePxLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"NumericLiteral\") {\n return `${node.value}px`;\n }\n return null;\n}\n\n/** Resolve ifContainer({ gt, lt, name? }) to a StyleX pseudo key. */\nfunction containerSelectorFromCall(node: CallChainNode): string {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`ifContainer() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (!arg || arg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(\"ifContainer() expects an object literal argument\");\n }\n\n let lt: number | undefined;\n let gt: number | undefined;\n let name: string | undefined;\n\n for (const prop of arg.properties) {\n if (prop.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(\"ifContainer() does not support spread properties\");\n }\n if (prop.type !== \"ObjectProperty\" || prop.computed) {\n throw new UnsupportedPatternError(\"ifContainer() expects plain object properties\");\n }\n\n const key = objectPropertyName(prop.key);\n if (!key) {\n throw new UnsupportedPatternError(\"ifContainer() only supports identifier/string keys\");\n }\n\n const valueNode = prop.value as t.Expression | t.SpreadElement;\n\n if (key === \"lt\") {\n lt = numericLiteralValue(valueNode, \"ifContainer().lt must be a numeric literal\");\n continue;\n }\n if (key === \"gt\") {\n gt = numericLiteralValue(valueNode, \"ifContainer().gt must be a numeric literal\");\n continue;\n }\n if (key === \"name\") {\n name = stringLiteralValue(valueNode, \"ifContainer().name must be a string literal\");\n continue;\n }\n\n throw new UnsupportedPatternError(`ifContainer() does not support property \"${key}\"`);\n }\n\n if (lt === undefined && gt === undefined) {\n throw new UnsupportedPatternError('ifContainer() requires at least one of \"lt\" or \"gt\"');\n }\n\n const parts: string[] = [];\n if (gt !== undefined) {\n parts.push(`(min-width: ${gt + 1}px)`);\n }\n if (lt !== undefined) {\n parts.push(`(max-width: ${lt}px)`);\n }\n\n const query = parts.join(\" and \");\n const namePrefix = name ? `${name} ` : \"\";\n return `@container ${namePrefix}${query}`;\n}\n\nfunction objectPropertyName(node: t.Expression | t.Identifier | t.PrivateName): string | null {\n if (node.type === \"Identifier\") return node.name;\n if (node.type === \"StringLiteral\") return node.value;\n return null;\n}\n\nfunction numericLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): number {\n if (node.type === \"NumericLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return -node.argument.value;\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\nfunction stringLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): string {\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"TemplateLiteral\" && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? \"\";\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\n// ── Chain node types (parsed from AST) ────────────────────────────────\n\nexport interface GetterChainNode {\n type: \"getter\";\n name: string;\n}\n\nexport interface CallChainNode {\n type: \"call\";\n name: string;\n args: (t.Expression | t.SpreadElement)[];\n}\n\nexport interface IfChainNode {\n type: \"if\";\n conditionNode: t.Expression | t.SpreadElement;\n}\n\nexport interface ElseChainNode {\n type: \"else\";\n}\n\nexport type ChainNode = GetterChainNode | CallChainNode | IfChainNode | ElseChainNode;\n\nexport class UnsupportedPatternError extends Error {\n constructor(message: string) {\n super(`[truss] Unsupported pattern: ${message}`);\n this.name = \"UnsupportedPatternError\";\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ChainNode } from \"./resolve-chain\";\n\n/**\n * Collect module-scope bindings so generated declarations can avoid collisions.\n *\n * We only care about top-level names because the transform injects declarations\n * at the module root, not inside nested blocks.\n */\nexport function collectTopLevelBindings(ast: t.File): Set<string> {\n const used = new Set<string>();\n\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node)) {\n for (const spec of node.specifiers) {\n used.add(spec.local.name);\n }\n continue;\n }\n\n if (t.isVariableDeclaration(node)) {\n for (const decl of node.declarations) {\n collectPatternBindings(decl.id, used);\n }\n continue;\n }\n\n if (t.isFunctionDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isClassDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration) {\n const decl = node.declaration;\n if (t.isVariableDeclaration(decl)) {\n for (const varDecl of decl.declarations) {\n collectPatternBindings(varDecl.id, used);\n }\n } else if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n continue;\n }\n\n if (t.isExportDefaultDeclaration(node)) {\n const decl = node.declaration;\n if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n }\n }\n\n return used;\n}\n\n/**\n * Recursively collect names introduced by binding patterns.\n *\n * This handles destructuring (`const { a } = ...`, `const [x] = ...`) so we do\n * not accidentally generate a helper that shadows an existing binding.\n */\nfunction collectPatternBindings(pattern: t.LVal | t.VoidPattern, used: Set<string>): void {\n if (t.isVoidPattern(pattern)) {\n return;\n }\n\n if (t.isIdentifier(pattern)) {\n used.add(pattern.name);\n return;\n }\n\n if (t.isAssignmentPattern(pattern)) {\n collectPatternBindings(pattern.left, used);\n return;\n }\n\n if (t.isRestElement(pattern)) {\n collectPatternBindings(pattern.argument as t.LVal, used);\n return;\n }\n\n if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isObjectProperty(prop)) {\n collectPatternBindings(prop.value as t.LVal, used);\n } else if (t.isRestElement(prop)) {\n collectPatternBindings(prop.argument as t.LVal, used);\n }\n }\n return;\n }\n\n if (t.isArrayPattern(pattern)) {\n for (const el of pattern.elements) {\n if (!el) continue;\n if (t.isIdentifier(el) || t.isAssignmentPattern(el) || t.isObjectPattern(el) || t.isArrayPattern(el)) {\n collectPatternBindings(el, used);\n } else if (t.isRestElement(el)) {\n collectPatternBindings(el.argument as t.LVal, used);\n }\n }\n }\n}\n\n/**\n * Reserve a stable, collision-free identifier.\n *\n * Preference order:\n * 1) preferred\n * 2) secondary (if provided)\n * 3) numbered suffixes based on secondary/preferred\n */\nexport function reservePreferredName(used: Set<string>, preferred: string, secondary?: string): string {\n if (!used.has(preferred)) {\n used.add(preferred);\n return preferred;\n }\n\n if (secondary && !used.has(secondary)) {\n used.add(secondary);\n return secondary;\n }\n\n const base = secondary ?? preferred;\n let i = 1;\n // Numbered fallback keeps generated names deterministic across runs.\n let candidate = `${base}_${i}`;\n while (used.has(candidate)) {\n i++;\n candidate = `${base}_${i}`;\n }\n used.add(candidate);\n return candidate;\n}\n\n/**\n * Find the local binding name for `Css` from import declarations.\n */\nexport function findCssImportBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: \"Css\" })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/**\n * Remove the Css import specifier. If it was the only specifier, remove the whole import.\n */\nexport function removeCssImport(ast: t.File, cssBinding: string): void {\n for (let i = 0; i < ast.program.body.length; i++) {\n const node = ast.program.body[i];\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((s) => t.isImportSpecifier(s) && s.local.name === cssBinding);\n if (cssSpecIndex === -1) continue;\n\n if (node.specifiers.length === 1) {\n ast.program.body.splice(i, 1);\n } else {\n node.specifiers.splice(cssSpecIndex, 1);\n }\n return;\n }\n}\n\n/**\n * Find an existing namespace import for `@stylexjs/stylex`, if present.\n *\n * Reusing an existing namespace avoids duplicate imports and ensures generated\n * calls use the same local alias as handwritten code (e.g. `sx`).\n */\nexport function findStylexNamespaceImport(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (node.source.value !== \"@stylexjs/stylex\") continue;\n\n for (const spec of node.specifiers) {\n if (t.isImportNamespaceSpecifier(spec)) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Return the index of the last import declaration in the module. */\nexport function findLastImportIndex(ast: t.File): number {\n let lastImportIndex = -1;\n for (let i = 0; i < ast.program.body.length; i++) {\n if (t.isImportDeclaration(ast.program.body[i])) {\n lastImportIndex = i;\n }\n }\n return lastImportIndex;\n}\n\n/**\n * Insert `import * as <localName> from \"@stylexjs/stylex\"` after existing imports.\n */\nexport function insertStylexNamespaceImport(ast: t.File, localName: string): void {\n const stylexImport = t.importDeclaration(\n [t.importNamespaceSpecifier(t.identifier(localName))],\n t.stringLiteral(\"@stylexjs/stylex\"),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, stylexImport);\n}\n\nexport function findNamedImportBinding(ast: t.File, source: string, importedName: string): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: importedName })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\nexport function upsertNamedImports(\n ast: t.File,\n source: string,\n imports: Array<{ importedName: string; localName: string }>,\n): void {\n if (imports.length === 0) return;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n\n for (const entry of imports) {\n const exists = node.specifiers.some(function (spec) {\n return t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: entry.importedName });\n });\n if (exists) continue;\n\n node.specifiers.push(t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName)));\n }\n return;\n }\n\n const importDecl = t.importDeclaration(\n imports.map(function (entry) {\n return t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName));\n }),\n t.stringLiteral(source),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, importDecl);\n}\n\n/**\n * Extract a `Css` method/property chain from an expression.\n *\n * Example: `Css.if(cond).df.else.db.$` ->\n * `[{type:\"if\"}, {type:\"getter\", name:\"df\"}, {type:\"else\"}, {type:\"getter\", name:\"db\"}]`\n *\n * Returns `null` when the expression is not rooted at the Css import binding,\n * which lets the caller ignore unrelated member expressions cheaply.\n */\nexport function extractChain(node: t.Expression, cssBinding: string): ChainNode[] | null {\n const chain: ChainNode[] = [];\n let current: t.Expression = node;\n\n while (true) {\n if (t.isIdentifier(current, { name: cssBinding })) {\n chain.reverse();\n return chain;\n }\n\n if (t.isMemberExpression(current) && !current.computed && t.isIdentifier(current.property)) {\n const name = current.property.name;\n if (name === \"else\") {\n chain.push({ type: \"else\" });\n } else {\n chain.push({ type: \"getter\", name });\n }\n current = current.object as t.Expression;\n continue;\n }\n\n if (\n t.isCallExpression(current) &&\n t.isMemberExpression(current.callee) &&\n !current.callee.computed &&\n t.isIdentifier(current.callee.property)\n ) {\n const name = current.callee.property.name;\n\n if (name === \"if\") {\n chain.push({\n type: \"if\",\n conditionNode: current.arguments[0] as t.Expression,\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n chain.push({\n type: \"call\",\n name,\n args: current.arguments as (t.Expression | t.SpreadElement)[],\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n return null;\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment } from \"./types\";\n\nexport interface CreateEntrySpec {\n /**\n * The property name in the generated `stylex.create({...})` object, built from\n * the Truss abbreviation, optionally suffixed with the resolved value and/or pseudo,\n * i.e. `\"df\"`, `\"mt__16px\"`, `\"black__hover\"`. Also used as the dedup key across the file.\n */\n key: string;\n /**\n * Static CSS property-value map for this entry. Usually a single property,\n * i.e. `{ display: \"flex\" }` for `\"df\"`, but shorthand abbreviations expand to multiple,\n * i.e. `{ borderStyle: \"solid\", borderWidth: \"1px\" }` for `\"ba\"`.\n */\n defs?: Record<string, unknown>;\n /**\n * For dynamic entries where the value is a runtime variable (not a literal),\n * i.e. `{ props: [\"marginTop\"], pseudo: null }` for `Css.mt(x).$`,\n * or `{ props: [\"color\"], pseudo: \":hover\" }` for `Css.onHover.color(x).$`.\n *\n * Becomes `stylex.create({ mt: v => ({ marginTop: v }) })`\n */\n dynamic?: {\n props: string[];\n extraDefs?: Record<string, unknown>;\n mediaQuery?: string | null;\n pseudoClass?: string | null;\n pseudoElement?: string | null;\n };\n /** If set, this entry uses stylex.when.<relationship>() as the computed property key */\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string };\n}\n\nexport interface CollectedCreateData {\n createEntries: Map<string, CreateEntrySpec>;\n runtimeLookups: Map<string, RuntimeLookupSpec>;\n needsMaybeInc: boolean;\n}\n\nexport interface RuntimeLookupSpec {\n lookupKey: string;\n refsByName: Record<string, string[]>;\n}\n\n/**\n * Aggregate per-site resolved chains into file-level emission data.\n *\n * Why this exists: we emit one `stylex.create(...)` per source file, so all\n * style segments across all transformed sites must be deduplicated first.\n */\nexport function collectCreateData(chains: ResolvedChain[]): CollectedCreateData {\n const createEntries = new Map<string, CreateEntrySpec>();\n const runtimeLookups = new Map<string, RuntimeLookupSpec>();\n let needsMaybeInc = false;\n\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n\n for (const seg of segs) {\n // Skip error segments — they have no CSS data to emit\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n collectTypographyLookup(createEntries, runtimeLookups, seg);\n continue;\n }\n\n if (seg.styleArrayArg) {\n continue;\n }\n\n if (seg.dynamicProps) {\n if (!createEntries.has(seg.key)) {\n // Keyed dedupe guarantees a stable single entry for repeated usage.\n createEntries.set(seg.key, {\n key: seg.key,\n dynamic: {\n props: seg.dynamicProps,\n extraDefs: seg.dynamicExtraDefs,\n mediaQuery: seg.mediaQuery,\n pseudoClass: seg.pseudoClass,\n pseudoElement: seg.pseudoElement,\n },\n });\n }\n } else {\n if (!createEntries.has(seg.key)) {\n createEntries.set(seg.key, {\n key: seg.key,\n defs: seg.defs,\n whenPseudo: seg.whenPseudo,\n });\n }\n }\n\n if (seg.incremented && seg.dynamicProps) {\n needsMaybeInc = true;\n }\n }\n }\n }\n\n return { createEntries, runtimeLookups, needsMaybeInc };\n}\n\nfunction collectTypographyLookup(\n createEntries: Map<string, CreateEntrySpec>,\n runtimeLookups: Map<string, RuntimeLookupSpec>,\n seg: ResolvedSegment,\n): void {\n const lookup = seg.typographyLookup;\n if (!lookup) return;\n\n if (!runtimeLookups.has(lookup.lookupKey)) {\n runtimeLookups.set(lookup.lookupKey, {\n lookupKey: lookup.lookupKey,\n refsByName: Object.fromEntries(\n Object.entries(lookup.segmentsByName).map(function ([name, segments]) {\n return [\n name,\n segments.map(function (segment) {\n return segment.key;\n }),\n ];\n }),\n ),\n });\n }\n\n for (const segments of Object.values(lookup.segmentsByName)) {\n for (const segment of segments) {\n if (createEntries.has(segment.key)) continue;\n createEntries.set(segment.key, {\n key: segment.key,\n defs: segment.defs,\n whenPseudo: segment.whenPseudo,\n });\n }\n }\n}\n\n/**\n * Build the object literal properties passed to `stylex.create`.\n *\n * Handles static entries, dynamic entries (`v => ({ ... })`), and\n * ancestor-pseudo entries that use `stylex.when.ancestor(...)` keys.\n */\nexport function buildCreateProperties(\n createEntries: Map<string, CreateEntrySpec>,\n stylexNamespaceName: string,\n): t.ObjectProperty[] {\n const createProperties: t.ObjectProperty[] = [];\n\n for (const [, entry] of createEntries) {\n if (entry.dynamic) {\n const paramId = t.identifier(\"v\");\n const bodyProps: t.ObjectProperty[] = [];\n const { mediaQuery, pseudoClass } = entry.dynamic;\n\n for (const prop of entry.dynamic.props) {\n if (pseudoClass && mediaQuery) {\n // Stacked: { default: null, \":hover\": { default: null, \"@media...\": v } }\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), paramId),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), paramId),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), paramId));\n }\n }\n\n if (entry.dynamic.extraDefs) {\n for (const [prop, value] of Object.entries(entry.dynamic.extraDefs)) {\n if (pseudoClass && mediaQuery) {\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(\n t.stringLiteral(pseudoClass),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(mediaQuery), valueToAst(value)),\n ]),\n ),\n ]),\n ),\n );\n } else if (pseudoClass || mediaQuery) {\n const condition = (pseudoClass || mediaQuery)!;\n bodyProps.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(t.stringLiteral(condition), valueToAst(value)),\n ]),\n ),\n );\n } else {\n bodyProps.push(t.objectProperty(toPropertyKey(prop), valueToAst(value)));\n }\n }\n }\n\n let bodyExpr: t.Expression = t.objectExpression(bodyProps);\n if (entry.dynamic.pseudoElement) {\n // Wrap: { '::placeholder': { ...bodyProps } }\n bodyExpr = t.objectExpression([t.objectProperty(t.stringLiteral(entry.dynamic.pseudoElement), bodyExpr)]);\n }\n const arrowFn = t.arrowFunctionExpression([paramId], bodyExpr);\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), arrowFn));\n continue;\n }\n\n if (entry.whenPseudo && entry.defs) {\n const ap = entry.whenPseudo;\n const props: t.ObjectProperty[] = [];\n\n for (const [prop, value] of Object.entries(entry.defs)) {\n // `when.ancestor(...)` must remain a computed key expression so StyleX\n // can generate marker-aware selectors.\n const whenCallArgs: t.Expression[] = [t.stringLiteral(ap.pseudo)];\n if (ap.markerNode) {\n whenCallArgs.push(ap.markerNode);\n }\n\n const relationship = ap.relationship ?? \"ancestor\";\n const whenCall = t.callExpression(\n t.memberExpression(\n t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"when\")),\n t.identifier(relationship),\n ),\n whenCallArgs,\n );\n\n props.push(\n t.objectProperty(\n toPropertyKey(prop),\n t.objectExpression([\n t.objectProperty(t.identifier(\"default\"), t.nullLiteral()),\n t.objectProperty(whenCall, valueToAst(value), true),\n ]),\n ),\n );\n }\n\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), t.objectExpression(props)));\n continue;\n }\n\n if (entry.defs) {\n createProperties.push(t.objectProperty(toPropertyKey(entry.key), defsToAst(entry.defs)));\n }\n }\n\n return createProperties;\n}\n\n/**\n * Build the per-file increment helper used by dynamic incremented calls.\n *\n * The helper is only emitted when needed to keep transformed files minimal.\n */\nexport function buildMaybeIncDeclaration(helperName: string, increment: number): t.VariableDeclaration {\n const incParam = t.identifier(\"inc\");\n const body = t.blockStatement([\n t.returnStatement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", incParam), t.stringLiteral(\"string\")),\n incParam,\n t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [t.binaryExpression(\"*\", incParam, t.numericLiteral(increment))],\n ),\n ),\n ),\n ]);\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(helperName), t.arrowFunctionExpression([incParam], body)),\n ]);\n}\n\n/** Build the per-file helper used to merge explicit `className` with `stylex.props()`. */\nexport function buildMergePropsDeclaration(helperName: string, stylexNamespaceName: string): t.FunctionDeclaration {\n const explicitClassNameParam = t.identifier(\"explicitClassName\");\n const stylesRestParam = t.restElement(t.identifier(\"styles\"));\n const sxId = t.identifier(\"sx\");\n\n return t.functionDeclaration(\n t.identifier(helperName),\n [explicitClassNameParam, stylesRestParam],\n t.blockStatement([\n t.variableDeclaration(\"const\", [\n t.variableDeclarator(\n sxId,\n t.callExpression(t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"props\")), [\n t.spreadElement(t.identifier(\"styles\")),\n ]),\n ),\n ]),\n t.returnStatement(\n t.objectExpression([\n t.spreadElement(sxId),\n t.objectProperty(\n t.identifier(\"className\"),\n t.callExpression(\n t.memberExpression(\n t.binaryExpression(\n \"+\",\n t.binaryExpression(\"+\", explicitClassNameParam, t.stringLiteral(\" \")),\n t.logicalExpression(\"||\", t.memberExpression(sxId, t.identifier(\"className\")), t.stringLiteral(\"\")),\n ),\n t.identifier(\"trim\"),\n ),\n [],\n ),\n ),\n ]),\n ),\n ]),\n );\n}\n\n/** Build `const <createVarName> = <stylexNs>.create({...})`. */\nexport function buildCreateDeclaration(\n createVarName: string,\n stylexNamespaceName: string,\n createProperties: t.ObjectProperty[],\n): t.VariableDeclaration {\n const createCall = t.callExpression(t.memberExpression(t.identifier(stylexNamespaceName), t.identifier(\"create\")), [\n t.objectExpression(createProperties),\n ]);\n return t.variableDeclaration(\"const\", [t.variableDeclarator(t.identifier(createVarName), createCall)]);\n}\n\nexport function buildRuntimeLookupDeclaration(\n lookupName: string,\n createVarName: string,\n lookup: RuntimeLookupSpec,\n): t.VariableDeclaration {\n const properties: t.ObjectProperty[] = [];\n\n for (const [name, refs] of Object.entries(lookup.refsByName)) {\n const values = refs.map(function (refKey) {\n return t.memberExpression(t.identifier(createVarName), t.identifier(refKey));\n });\n properties.push(t.objectProperty(toPropertyKey(name), t.arrayExpression(values)));\n }\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(lookupName), t.objectExpression(properties)),\n ]);\n}\n\n/** Convert style definitions to an AST object, recursively. */\nfunction defsToAst(defs: Record<string, unknown>): t.ObjectExpression {\n const properties: t.ObjectProperty[] = [];\n\n for (const [key, value] of Object.entries(defs)) {\n const keyNode = toPropertyKey(key);\n\n if (value === null) {\n properties.push(t.objectProperty(keyNode, t.nullLiteral()));\n } else if (typeof value === \"string\") {\n properties.push(t.objectProperty(keyNode, t.stringLiteral(value)));\n } else if (typeof value === \"number\") {\n properties.push(t.objectProperty(keyNode, t.numericLiteral(value)));\n } else if (typeof value === \"object\") {\n properties.push(t.objectProperty(keyNode, defsToAst(value as Record<string, unknown>)));\n }\n }\n\n return t.objectExpression(properties);\n}\n\n/** Convert a primitive/object style value into an AST expression node. */\nfunction valueToAst(value: unknown): t.Expression {\n if (value === null) return t.nullLiteral();\n if (typeof value === \"string\") return t.stringLiteral(value);\n if (typeof value === \"number\") return t.numericLiteral(value);\n if (typeof value === \"object\") return defsToAst(value as Record<string, unknown>);\n return t.stringLiteral(String(value));\n}\n\n/** Use identifier keys when legal, otherwise string literal keys. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n","import _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport type { ResolvedSegment } from \"./types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\n\nexport interface ExpressionSite {\n path: NodePath<t.MemberExpression>;\n resolvedChain: ResolvedChain;\n}\n\nexport interface RewriteSitesOptions {\n ast: t.File;\n sites: ExpressionSite[];\n cssBindingName: string;\n filename: string;\n debug: boolean;\n createVarName: string;\n stylexNamespaceName: string;\n maybeIncHelperName: string | null;\n mergePropsHelperName: string;\n needsMergePropsHelper: { current: boolean };\n trussPropsHelperName: string;\n needsTrussPropsHelper: { current: boolean };\n trussDebugInfoName: string;\n needsTrussDebugInfo: { current: boolean };\n asStyleArrayHelperName: string;\n needsAsStyleArrayHelper: { current: boolean };\n skippedCssPropMessages: Array<{ message: string; line: number | null }>;\n runtimeLookupNames: Map<string, string>;\n}\n\n/** Format a property key for diagnostics. */\nfunction formatDroppedPropertyKey(prop: t.ObjectMember | t.SpreadElement): string {\n if (t.isObjectProperty(prop)) {\n if (t.isIdentifier(prop.key)) return prop.key.name;\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n }\n return formatNodeSnippet(prop);\n}\n\n/**\n * Rewrite collected `Css...$` expression sites into StyleX runtime calls.\n *\n * Why this is split out: the transform has two distinct concerns—\"what to\n * emit\" (`stylex.create`) and \"where to rewrite usage sites\" (`stylex.props`).\n * Keeping site rewrites isolated makes behavior easier to reason about.\n */\nexport function rewriteExpressionSites(options: RewriteSitesOptions): void {\n for (const site of options.sites) {\n const propsArgs = buildPropsArgsFromChain(site.resolvedChain, options);\n const cssAttrPath = getCssAttributePath(site.path);\n\n if (cssAttrPath) {\n cssAttrPath.replaceWith(\n t.jsxSpreadAttribute(\n buildCssSpreadExpression(\n cssAttrPath,\n propsArgs,\n site.path.node.loc?.start.line ?? null,\n options.mergePropsHelperName,\n options.needsMergePropsHelper,\n options,\n ),\n ),\n );\n continue;\n }\n\n site.path.replaceWith(buildStyleArrayExpression(propsArgs, site.path.node.loc?.start.line ?? null, options));\n }\n\n rewriteCssPropsCalls(options);\n rewriteCssSpreadCalls(\n options.ast,\n options.cssBindingName,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n );\n rewriteStyleObjectExpressions(\n options.ast,\n options.skippedCssPropMessages,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n );\n normalizeMixedStyleTernaries(options.ast);\n\n // Second pass: lower any style-array-like `css={...}` expression to `stylex.props(...)`.\n rewriteCssAttributeExpressions(\n options.ast,\n options.filename,\n options.debug,\n options.stylexNamespaceName,\n options.mergePropsHelperName,\n options.needsMergePropsHelper,\n options.trussPropsHelperName,\n options.needsTrussPropsHelper,\n options.trussDebugInfoName,\n options.needsTrussDebugInfo,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n options.skippedCssPropMessages,\n );\n}\n\n/**\n * Return the enclosing `css={...}` JSX attribute path for a transformed site,\n * or null when the site is in a non-`css` expression context.\n */\nfunction getCssAttributePath(path: NodePath<t.MemberExpression>): NodePath<t.JSXAttribute> | null {\n const parentPath = path.parentPath;\n if (!parentPath || !parentPath.isJSXExpressionContainer()) return null;\n\n const attrPath = parentPath.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return null;\n if (!t.isJSXIdentifier(attrPath.node.name, { name: \"css\" })) return null;\n\n return attrPath;\n}\n\n/**\n * Build arguments for `stylex.props(...)` from a resolved chain.\n *\n * Conditional segments are converted to ternaries (or spread ternaries when a\n * branch has multiple refs) so branch structure is preserved in emitted code.\n */\nfunction buildPropsArgsFromChain(\n chain: ResolvedChain,\n options: RewriteSitesOptions,\n): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const marker of chain.markers) {\n if (marker.markerNode) {\n args.push(marker.markerNode);\n } else {\n args.push(\n t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"defaultMarker\")),\n [],\n ),\n );\n }\n }\n\n for (const part of chain.parts) {\n if (part.type === \"unconditional\") {\n args.push(...buildPropsArgs(part.segments, options));\n continue;\n }\n\n const thenArgs = buildPropsArgs(part.thenSegments, options);\n const elseArgs = buildPropsArgs(part.elseSegments, options);\n\n if (\n thenArgs.length === 1 &&\n elseArgs.length === 1 &&\n !t.isSpreadElement(thenArgs[0]) &&\n !t.isSpreadElement(elseArgs[0])\n ) {\n args.push(t.conditionalExpression(part.conditionNode, thenArgs[0], elseArgs[0]));\n } else if (thenArgs.length > 0 || elseArgs.length > 0) {\n args.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.arrayExpression(thenArgs), t.arrayExpression(elseArgs)),\n ),\n );\n }\n }\n\n return args;\n}\n\n/** Convert resolved segments to style refs and dynamic invocations. */\nfunction buildPropsArgs(segments: ResolvedSegment[], options: RewriteSitesOptions): (t.Expression | t.SpreadElement)[] {\n const args: (t.Expression | t.SpreadElement)[] = [];\n\n for (const seg of segments) {\n // Skip error segments — they are logged via console.error at the top of the file\n if (seg.error) continue;\n\n if (seg.typographyLookup) {\n const lookupName = options.runtimeLookupNames.get(seg.typographyLookup.lookupKey);\n if (!lookupName) {\n continue;\n }\n const lookupAccess = t.memberExpression(\n t.identifier(lookupName),\n seg.typographyLookup.argNode as t.Expression,\n true,\n );\n args.push(t.spreadElement(t.logicalExpression(\"??\", lookupAccess, t.arrayExpression([]))));\n continue;\n }\n\n if (seg.styleArrayArg) {\n args.push(\n t.spreadElement(\n buildUnknownSpreadFallback(\n seg.styleArrayArg as t.Expression,\n options.asStyleArrayHelperName,\n options.needsAsStyleArrayHelper,\n ),\n ),\n );\n continue;\n }\n\n const ref = t.memberExpression(t.identifier(options.createVarName), t.identifier(seg.key));\n\n if (seg.dynamicProps && seg.argNode) {\n let argExpr: t.Expression;\n if (seg.incremented && options.maybeIncHelperName) {\n argExpr = t.callExpression(t.identifier(options.maybeIncHelperName), [seg.argNode]);\n } else if (seg.incremented) {\n argExpr = seg.argNode as t.Expression;\n } else if (seg.appendPx) {\n argExpr = t.binaryExpression(\n \"+\",\n t.callExpression(t.identifier(\"String\"), [seg.argNode]),\n t.stringLiteral(\"px\"),\n );\n } else {\n argExpr = t.callExpression(t.identifier(\"String\"), [seg.argNode]);\n }\n args.push(t.callExpression(ref, [argExpr]));\n } else {\n args.push(ref);\n }\n }\n\n return args;\n}\n\n/** Rewrite style-array-like `css={...}` expressions to `...stylex.props(...)`. */\nfunction rewriteCssAttributeExpressions(\n ast: t.File,\n filename: string,\n debug: boolean,\n stylexNamespaceName: string,\n mergePropsHelperName: string,\n needsMergePropsHelper: { current: boolean },\n trussPropsHelperName: string,\n needsTrussPropsHelper: { current: boolean },\n trussDebugInfoName: string,\n needsTrussDebugInfo: { current: boolean },\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n skippedCssPropMessages: Array<{ message: string; line: number | null }>,\n): void {\n traverse(ast, {\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n const value = path.node.value;\n if (!t.isJSXExpressionContainer(value)) return;\n if (!t.isExpression(value.expression)) return;\n\n const propsArgs = lowerCssExpressionToPropsArgs(\n value.expression,\n path,\n asStyleArrayHelperName,\n needsAsStyleArrayHelper,\n );\n if (!propsArgs) {\n skippedCssPropMessages.push({\n message: explainSkippedCssRewrite(value.expression, path),\n line: path.node.loc?.start.line ?? null,\n });\n return;\n }\n\n path.replaceWith(\n t.jsxSpreadAttribute(\n buildCssSpreadExpression(\n path,\n propsArgs,\n path.node.loc?.start.line ?? null,\n mergePropsHelperName,\n needsMergePropsHelper,\n {\n filename,\n debug,\n stylexNamespaceName,\n trussPropsHelperName,\n needsTrussPropsHelper,\n trussDebugInfoName,\n needsTrussDebugInfo,\n },\n ),\n ),\n );\n },\n });\n}\n\n/** Emit a style array and optionally prepend a Truss debug sentinel. */\nfunction buildStyleArrayExpression(\n propsArgs: (t.Expression | t.SpreadElement)[],\n line: number | null,\n options: RewriteSitesOptions,\n): t.ArrayExpression {\n const elements: Array<t.Expression | t.SpreadElement> = buildDebugElements(line, options);\n elements.push(...propsArgs);\n return t.arrayExpression(elements);\n}\n\n/** Emit `stylex.props(...)` or `trussProps(stylex, ...)` depending on debug mode. */\nfunction buildPropsCall(\n propsArgs: (t.Expression | t.SpreadElement)[],\n line: number | null,\n options: Pick<\n RewriteSitesOptions,\n | \"debug\"\n | \"stylexNamespaceName\"\n | \"trussPropsHelperName\"\n | \"needsTrussPropsHelper\"\n | \"trussDebugInfoName\"\n | \"needsTrussDebugInfo\"\n | \"filename\"\n >,\n): t.CallExpression {\n if (!options.debug) {\n return t.callExpression(\n t.memberExpression(t.identifier(options.stylexNamespaceName), t.identifier(\"props\")),\n propsArgs,\n );\n }\n\n options.needsTrussPropsHelper.current = true;\n const args: Array<t.Expression | t.SpreadElement> = buildDebugElements(line, options);\n args.push(...propsArgs);\n return t.callExpression(t.identifier(options.trussPropsHelperName), [\n t.identifier(options.stylexNamespaceName),\n ...args,\n ]);\n}\n\n/** Build the `new TrussDebugInfo(\"File.tsx:line\")` expression for a site. */\nfunction buildDebugElements(\n line: number | null,\n options: Pick<RewriteSitesOptions, \"debug\" | \"trussDebugInfoName\" | \"needsTrussDebugInfo\" | \"filename\">,\n): Array<t.Expression | t.SpreadElement> {\n if (!options.debug || line === null) {\n return [];\n }\n\n options.needsTrussDebugInfo.current = true;\n return [t.newExpression(t.identifier(options.trussDebugInfoName), [t.stringLiteral(`${options.filename}:${line}`)])];\n}\n\n/** Lower a rewriteable JSX `css={...}` expression into `stylex.props(...)` args. */\nfunction lowerCssExpressionToPropsArgs(\n expr: t.Expression,\n path: NodePath<t.JSXAttribute>,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): (t.Expression | t.SpreadElement)[] | null {\n return (\n buildStyleObjectPropsArgs(expr, path, asStyleArrayHelperName, needsAsStyleArrayHelper) ??\n buildStyleArrayLikePropsArgsFromExpression(expr, path)\n );\n}\n\n/** Explain why a remaining `css={...}` expression could not be lowered. */\nfunction explainSkippedCssRewrite(expr: t.Expression, path: NodePath<t.JSXAttribute>): string {\n if (t.isObjectExpression(expr)) {\n for (const prop of expr.properties) {\n if (!t.isSpreadElement(prop)) {\n return `[truss] Unsupported pattern: Could not rewrite css prop: object contains a non-spread property (${formatNodeSnippet(expr)})`;\n }\n\n const normalizedArg = normalizeStyleExpression(prop.argument);\n if (!normalizedArg) {\n return `[truss] Unsupported pattern: Could not rewrite css prop: spread argument is not style-array-like (${formatNodeSnippet(prop.argument)})`;\n }\n }\n\n return `[truss] Unsupported pattern: Could not rewrite css prop: object spread composition was not recognized (${formatNodeSnippet(expr)})`;\n }\n\n return `[truss] Unsupported pattern: Could not rewrite css prop: expression is not style-array-like (${formatNodeSnippet(expr)})`;\n}\n\n/** Generate a compact code snippet for diagnostics. */\nfunction formatNodeSnippet(node: t.Node): string {\n return generate(node, { compact: true, comments: true }).code;\n}\n\n/** Merge existing `className` attr into a rewritten `stylex.props(...)` spread. */\nfunction buildCssSpreadExpression(\n path: NodePath<t.JSXAttribute>,\n propsArgs: (t.Expression | t.SpreadElement)[],\n line: number | null,\n mergePropsHelperName: string,\n needsMergePropsHelper: { current: boolean },\n options: Pick<\n RewriteSitesOptions,\n | \"debug\"\n | \"stylexNamespaceName\"\n | \"trussPropsHelperName\"\n | \"needsTrussPropsHelper\"\n | \"trussDebugInfoName\"\n | \"needsTrussDebugInfo\"\n | \"filename\"\n >,\n): t.Expression {\n const existingClassNameExpr = removeExistingClassNameAttribute(path);\n if (!existingClassNameExpr) return buildPropsCall(propsArgs, line, options);\n\n needsMergePropsHelper.current = true;\n const args: Array<t.Expression | t.SpreadElement> = buildDebugElements(line, options);\n args.push(...propsArgs);\n return t.callExpression(t.identifier(mergePropsHelperName), [\n t.identifier(options.stylexNamespaceName),\n existingClassNameExpr,\n ...args,\n ]);\n}\n\n/** Remove sibling `className` and return its expression so rewrites can preserve it. */\nfunction removeExistingClassNameAttribute(path: NodePath<t.JSXAttribute>): t.Expression | null {\n const openingElement = path.parentPath;\n if (!openingElement || !openingElement.isJSXOpeningElement()) return null;\n\n const attrs = openingElement.node.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name, { name: \"className\" })) continue;\n\n let classNameExpr: t.Expression | null = null;\n if (t.isStringLiteral(attr.value)) {\n classNameExpr = attr.value;\n } else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {\n classNameExpr = attr.value.expression;\n }\n\n attrs.splice(i, 1);\n return classNameExpr;\n }\n\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Object spread → style array rewriting\n// ---------------------------------------------------------------------------\n\n/**\n * Convert `css={{ ...a, ...Css.df.$ }}`-style objects directly to props args.\n *\n * For css prop objects: if the object is all spreads, either flatten known style\n * arrays or wrap unknown spreads in `asStyleArray()`.\n */\nfunction buildStyleObjectPropsArgs(\n expr: t.Expression,\n path: NodePath,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): (t.Expression | t.SpreadElement)[] | null {\n if (!t.isObjectExpression(expr) || expr.properties.length === 0) return null;\n\n // Objects with non-spread properties can't be lowered to props args\n const allSpreads = expr.properties.every(function (prop) {\n return t.isSpreadElement(prop);\n });\n if (!allSpreads) return null;\n\n // If any spread touches a Css-derived array, flatten with knowledge of style arrays\n if (hasStyleArraySpread(expr, path)) {\n const result = flattenStyleObject(expr, path, asStyleArrayHelperName, needsAsStyleArrayHelper);\n return result.elements.filter(Boolean) as (t.Expression | t.SpreadElement)[];\n }\n\n // All spreads but none touch Css → wrap each in asStyleArray as fallback\n return expr.properties.map(function (prop) {\n const spread = prop as t.SpreadElement;\n return t.spreadElement(\n buildUnknownSpreadFallback(spread.argument, asStyleArrayHelperName, needsAsStyleArrayHelper), // I.e. `css={{ ...css }}` or `css={{ ...xss }}`\n );\n });\n}\n\n/** Normalize and lower a style-array-like expression into props args. */\nfunction buildStyleArrayLikePropsArgsFromExpression(\n expr: t.Expression,\n path: NodePath,\n): (t.Expression | t.SpreadElement)[] | null {\n const normalizedExpr = normalizeStyleExpression(expr);\n if (!normalizedExpr) return null;\n return buildStyleArrayLikePropsArgs(normalizedExpr, path);\n}\n\n/** Convert a style-array-like expression into `stylex.props(...)` arguments. */\nfunction buildStyleArrayLikePropsArgs(expr: t.Expression, path: NodePath): (t.Expression | t.SpreadElement)[] | null {\n if (t.isArrayExpression(expr)) {\n const propsArgs: (t.Expression | t.SpreadElement)[] = [];\n\n for (const el of expr.elements) {\n if (!el) continue;\n\n if (t.isSpreadElement(el)) {\n const normalizedArg = normalizeStyleExpression(el.argument); // I.e. `...[css.df]`, `...base`, or `...(cond ? styles.hover : {})`\n if (!normalizedArg) {\n propsArgs.push(t.spreadElement(el.argument));\n continue;\n }\n\n if (t.isArrayExpression(normalizedArg)) {\n const nestedArgs = buildStyleArrayLikePropsArgs(normalizedArg, path);\n if (nestedArgs) {\n propsArgs.push(...nestedArgs);\n continue;\n }\n }\n propsArgs.push(t.spreadElement(buildSafeSpreadArgument(normalizedArg)));\n continue;\n }\n\n propsArgs.push(el);\n }\n\n return propsArgs;\n }\n\n if (\n t.isIdentifier(expr) ||\n t.isMemberExpression(expr) ||\n t.isConditionalExpression(expr) ||\n t.isLogicalExpression(expr) ||\n t.isCallExpression(expr)\n ) {\n return [t.spreadElement(buildSafeSpreadArgument(expr))];\n }\n\n return null;\n}\n\n/**\n * Rewrite object spread composition like `{ ...[css.df], ...(cond ? [css.a] : {}) }`\n * into style ref arrays so later JSX css rewrites can flatten them safely.\n */\nfunction rewriteStyleObjectExpressions(\n ast: t.File,\n messages: Array<{ message: string; line: number | null }>,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): void {\n traverse(ast, {\n ObjectExpression(path: NodePath<t.ObjectExpression>) {\n if (!hasStyleArraySpread(path.node, path)) return;\n\n const result = flattenStyleObject(path.node, path, asStyleArrayHelperName, needsAsStyleArrayHelper);\n if (result.droppedPropertyKeys.length > 0) {\n messages.push({\n message: `[truss] Unsupported pattern: Dropped non-spread properties from style composition object (${result.droppedPropertyKeys.join(\", \")})`,\n line: path.node.loc?.start.line ?? null,\n });\n }\n path.replaceWith(t.arrayExpression(result.elements));\n },\n });\n}\n\n/**\n * Normalize ternaries and logicals that mix `{}` with style arrays.\n *\n * After Css rewriting, `cond ? {} : Css.pt3.$` becomes `cond ? {} : [css.pt3]`.\n * If `{}` is left as-is, spreading the result into an array fails at runtime\n * (\"not iterable\"). This pass rewrites `{}` → `[]` in branches that coexist\n * with style arrays so both sides are consistently iterable.\n */\nfunction normalizeMixedStyleTernaries(ast: t.File): void {\n traverse(ast, {\n ConditionalExpression(path: NodePath<t.ConditionalExpression>) {\n const consequentHasArray = expressionContainsArray(path.node.consequent, path);\n const alternateHasArray = expressionContainsArray(path.node.alternate, path);\n // Only act when one branch has an array and the other is `{}`\n if (consequentHasArray && isEmptyObjectExpression(path.node.alternate)) {\n path.node.alternate = t.arrayExpression([]);\n } else if (alternateHasArray && isEmptyObjectExpression(path.node.consequent)) {\n path.node.consequent = t.arrayExpression([]);\n }\n },\n LogicalExpression(path: NodePath<t.LogicalExpression>) {\n if (path.node.operator !== \"||\" && path.node.operator !== \"??\") return;\n // I.e. `styles || {}` where styles is a style array\n if (expressionContainsArray(path.node.left, path) && isEmptyObjectExpression(path.node.right)) {\n path.node.right = t.arrayExpression([]);\n }\n },\n });\n}\n\n/**\n * Lower `Css.spread({ ... })` marker calls into plain style arrays.\n *\n * `Css.spread(...)` is an explicit user annotation that says \"this object is\n * style composition\" — so we skip the `hasStyleArraySpread` detection gate\n * and always rewrite.\n */\nfunction rewriteCssSpreadCalls(\n ast: t.File,\n cssBindingName: string,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): void {\n traverse(ast, {\n CallExpression(path: NodePath<t.CallExpression>) {\n if (!isCssSpreadCall(path.node, cssBindingName)) return;\n\n const arg = path.node.arguments[0];\n if (!arg || t.isSpreadElement(arg) || !t.isExpression(arg) || path.node.arguments.length !== 1) return;\n\n const styleObject = unwrapStyleObjectExpression(arg);\n if (!styleObject) return;\n\n const result = flattenStyleObject(styleObject, path, asStyleArrayHelperName, needsAsStyleArrayHelper);\n path.replaceWith(t.arrayExpression(result.elements));\n },\n });\n}\n\n/**\n * Rewrite `Css.props(expr)` into `stylex.props(...expr)` (or `trussProps(stylex, ...expr)` in debug mode).\n *\n * This lets users pass style arrays through plain objects (e.g. for `{...attrs}` spreading)\n * without relying on the `css=` prop that the build plugin normally rewrites.\n */\nfunction rewriteCssPropsCalls(options: RewriteSitesOptions): void {\n traverse(options.ast, {\n CallExpression(path: NodePath<t.CallExpression>) {\n if (!isCssPropsCall(path.node, options.cssBindingName)) return;\n\n const arg = path.node.arguments[0];\n if (!arg || t.isSpreadElement(arg) || !t.isExpression(arg) || path.node.arguments.length !== 1) return;\n\n // `Css.props(expr)` → `buildPropsCall([...expr])`\n const propsArgs: (t.Expression | t.SpreadElement)[] = [t.spreadElement(arg)];\n const line = path.node.loc?.start.line ?? null;\n path.replaceWith(buildPropsCall(propsArgs, line, options));\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Core: flatten a style composition object into an array of style refs\n// ---------------------------------------------------------------------------\n\n/**\n * Convert a style composition object `{ ...a, ...b }` into a flat array `[...a, ...b]`.\n *\n * Each spread argument is normalized (&&→ternary, {}→[], nested objects→arrays).\n * Known style arrays are flattened; unknown expressions are wrapped in `asStyleArray()`.\n */\nfunction flattenStyleObject(\n expr: t.ObjectExpression,\n path: NodePath,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): { elements: (t.Expression | t.SpreadElement | null)[]; droppedPropertyKeys: string[] } {\n const elements: (t.Expression | t.SpreadElement | null)[] = [];\n const droppedPropertyKeys: string[] = [];\n\n for (const prop of expr.properties) {\n if (!t.isSpreadElement(prop)) {\n droppedPropertyKeys.push(formatDroppedPropertyKey(prop)); // I.e. `{ ...Css.black.$, foo: true }`\n continue;\n }\n\n const normalized = normalizeStyleExpression(prop.argument);\n if (!normalized) {\n // Truly unrecognizable → asStyleArray fallback\n elements.push(\n t.spreadElement(buildUnknownSpreadFallback(prop.argument, asStyleArrayHelperName, needsAsStyleArrayHelper)),\n );\n continue;\n }\n\n if (t.isArrayExpression(normalized)) {\n elements.push(...normalized.elements); // I.e. `...[css.df, css.aic]` → `css.df, css.aic`\n } else if (isProvablyArray(normalized)) {\n elements.push(t.spreadElement(buildSafeSpreadArgument(normalized))); // I.e. `...(cond ? [css.df] : [])`\n } else {\n elements.push(\n t.spreadElement(buildUnknownSpreadFallback(normalized, asStyleArrayHelperName, needsAsStyleArrayHelper)), // I.e. `...borderBottomStyles`\n );\n }\n }\n\n return { elements, droppedPropertyKeys };\n}\n\n// ---------------------------------------------------------------------------\n// Detection: does an object expression \"touch\" Css-derived style arrays?\n// ---------------------------------------------------------------------------\n\n/**\n * Check whether any spread in an object contains an array expression.\n *\n * This works as a reliable proxy for \"touches Css expressions\" because the earlier Css rewriting pass converts\n * `Css.foo.$` chains into array literals like `[css.df, css.aic]`.\n *\n * Spreading an array into an object literal is semantically nonsensical in user-written code (i.e. `{ ...[a, b] }`\n * produces `{ 0: a, 1: b }`), so any object spread containing an array literal must have been produced by our Css\n * rewriting — making it safe to rewrite the whole object into a style array.\n */\nfunction hasStyleArraySpread(expr: t.ObjectExpression, path: NodePath): boolean {\n return expr.properties.some(function (prop) {\n return t.isSpreadElement(prop) && expressionContainsArray(prop.argument, path);\n });\n}\n\n/**\n * Recursively check whether an expression contains an array expression,\n * following simple variable bindings, member accesses, and function returns.\n */\nfunction expressionContainsArray(expr: t.Expression, path: NodePath): boolean {\n if (t.isArrayExpression(expr)) return true;\n\n if (t.isConditionalExpression(expr)) {\n return expressionContainsArray(expr.consequent, path) || expressionContainsArray(expr.alternate, path);\n }\n\n if (t.isLogicalExpression(expr)) {\n return expressionContainsArray(expr.left, path) || expressionContainsArray(expr.right, path);\n }\n\n if (t.isObjectExpression(expr)) {\n return expr.properties.some(function (p) {\n return t.isSpreadElement(p) && expressionContainsArray(p.argument, path);\n });\n }\n\n // Follow variable bindings: `const base = [css.df]; { ...base }`\n if (t.isIdentifier(expr)) {\n const binding = path.scope.getBinding(expr.name);\n if (binding?.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init) return expressionContainsArray(init, binding.path as unknown as NodePath);\n }\n return false;\n }\n\n // Follow member access: `styles.wrapper` where `const styles = { wrapper: [css.df] }`\n if (t.isMemberExpression(expr) && t.isIdentifier(expr.object)) {\n const binding = path.scope.getBinding(expr.object.name);\n if (binding?.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init && t.isObjectExpression(init)) {\n const propName = getStaticMemberPropertyName(expr, path);\n if (propName) {\n for (const prop of init.properties) {\n if (!t.isObjectProperty(prop) || prop.computed) continue;\n if (!isMatchingPropertyName(prop.key, propName)) continue;\n if (t.isExpression(prop.value)) {\n return expressionContainsArray(prop.value, binding.path as unknown as NodePath);\n }\n }\n }\n }\n }\n return false;\n }\n\n // Follow local function returns: `getStyles()` where `function getStyles() { return [css.df]; }`\n if (t.isCallExpression(expr)) {\n const returnExpr = getCallReturnExpression(expr, path);\n return returnExpr ? expressionContainsArray(returnExpr, path) : false;\n }\n\n return false;\n}\n\n// ---------------------------------------------------------------------------\n// Normalization: convert style expressions into canonical array-like form\n// ---------------------------------------------------------------------------\n\n/**\n * Normalize a style expression so conditional branches use arrays instead of objects.\n *\n * Converts `&&` to ternary with `[]` fallback, `{}` to `[]`, and accepts\n * identifiers/members/calls as-is (they're assumed to be style arrays in context).\n */\nfunction normalizeStyleExpression(expr: t.Expression): t.Expression | null {\n if (t.isArrayExpression(expr)) return expr; // I.e. `[css.df]`\n\n if (isEmptyObjectExpression(expr)) return t.arrayExpression([]); // I.e. `{}`\n\n if (t.isLogicalExpression(expr) && expr.operator === \"&&\") {\n const consequent = normalizeStyleExpression(expr.right);\n if (!consequent) return null;\n return t.conditionalExpression(expr.left, consequent, t.arrayExpression([])); // I.e. `active && [css.blue]`\n }\n\n if (t.isLogicalExpression(expr) && (expr.operator === \"||\" || expr.operator === \"??\")) {\n const left = normalizeStyleExpression(expr.left);\n const right = normalizeStyleBranch(expr.right);\n if (!left || !right) return null;\n return t.logicalExpression(expr.operator, left, right); // I.e. `hover || base`\n }\n\n if (t.isConditionalExpression(expr)) {\n const consequent = normalizeStyleBranch(expr.consequent);\n const alternate = normalizeStyleBranch(expr.alternate);\n if (!consequent || !alternate) return null;\n return t.conditionalExpression(expr.test, consequent, alternate); // I.e. `cond ? [css.blue] : {}`\n }\n\n // Identifiers, member expressions, and calls are accepted as style arrays\n if (t.isIdentifier(expr) || t.isMemberExpression(expr) || t.isCallExpression(expr)) {\n return expr; // I.e. `baseStyles`, `styles.wrapper`, `getStyles()`\n }\n\n return null;\n}\n\n/** Normalize a branch in a conditional style expression. */\nfunction normalizeStyleBranch(expr: t.Expression): t.Expression | null {\n if (isEmptyObjectExpression(expr)) return t.arrayExpression([]); // I.e. `cond ? [css.blue] : {}`\n\n if (t.isObjectExpression(expr)) {\n // Nested style objects in branches: `cond ? { ...Css.bb.$ } : {}`\n if (expr.properties.length === 0) return t.arrayExpression([]);\n const allSpreads = expr.properties.every(function (p) {\n return t.isSpreadElement(p);\n });\n if (!allSpreads) return null;\n // Build a simple inline array from the spreads\n const elements: (t.Expression | t.SpreadElement | null)[] = [];\n for (const prop of expr.properties) {\n const spread = prop as t.SpreadElement;\n const normalized = normalizeStyleExpression(spread.argument);\n if (!normalized) return null;\n if (t.isArrayExpression(normalized)) {\n elements.push(...normalized.elements);\n } else {\n elements.push(t.spreadElement(buildSafeSpreadArgument(normalized)));\n }\n }\n return t.arrayExpression(elements);\n }\n\n return normalizeStyleExpression(expr);\n}\n\n// ---------------------------------------------------------------------------\n// Utility helpers\n// ---------------------------------------------------------------------------\n\n/** Match `Css.props(...)` calls. */\nfunction isCssPropsCall(expr: t.CallExpression, cssBindingName: string): boolean {\n return (\n t.isMemberExpression(expr.callee) &&\n !expr.callee.computed &&\n t.isIdentifier(expr.callee.object, { name: cssBindingName }) &&\n t.isIdentifier(expr.callee.property, { name: \"props\" })\n );\n}\n\n/** Match the legacy `Css.spread(...)` marker helper. */\nfunction isCssSpreadCall(expr: t.CallExpression, cssBindingName: string): boolean {\n return (\n t.isMemberExpression(expr.callee) &&\n !expr.callee.computed &&\n t.isIdentifier(expr.callee.object, { name: cssBindingName }) &&\n t.isIdentifier(expr.callee.property, { name: \"spread\" })\n );\n}\n\n/** Unwrap TS wrappers so `Css.spread({ ... } as const)` is still recognized. */\nfunction unwrapStyleObjectExpression(expr: t.Expression): t.ObjectExpression | null {\n if (t.isObjectExpression(expr)) return expr;\n if (t.isTSAsExpression(expr) || t.isTSSatisfiesExpression(expr) || t.isTSNonNullExpression(expr)) {\n return unwrapStyleObjectExpression(expr.expression);\n }\n return null;\n}\n\n/** Match static object property names. */\nfunction isMatchingPropertyName(key: t.Expression | t.Identifier | t.PrivateName, name: string): boolean {\n return (t.isIdentifier(key) && key.name === name) || (t.isStringLiteral(key) && key.value === name);\n}\n\n/** Check for `{}` fallback branches that should become `[]`. */\nfunction isEmptyObjectExpression(expr: t.Expression): boolean {\n return t.isObjectExpression(expr) && expr.properties.length === 0;\n}\n\n/**\n * Check whether an expression is structurally guaranteed to evaluate to an array.\n *\n * Unlike `expressionContainsArray` (which follows bindings), this is a pure\n * structural check on the AST — no scope resolution. Used to decide whether a\n * spread can be emitted directly (`...expr`) or needs `asStyleArray` wrapping.\n */\nfunction isProvablyArray(expr: t.Expression): boolean {\n if (t.isArrayExpression(expr)) return true;\n if (t.isParenthesizedExpression(expr)) return isProvablyArray(expr.expression);\n if (t.isConditionalExpression(expr)) {\n return isProvablyArray(expr.consequent) && isProvablyArray(expr.alternate);\n }\n if (t.isLogicalExpression(expr)) {\n return isProvablyArray(expr.left) && isProvablyArray(expr.right);\n }\n return false;\n}\n\n/** Convert unknown spread values into safe iterable fallbacks via `asStyleArray(...)`. */\nfunction buildUnknownSpreadFallback(\n expr: t.Expression,\n asStyleArrayHelperName: string,\n needsAsStyleArrayHelper: { current: boolean },\n): t.Expression {\n needsAsStyleArrayHelper.current = true;\n return t.callExpression(t.identifier(asStyleArrayHelperName), [expr]); // I.e. `asStyleArray(xss)`\n}\n\n/** Parenthesize spread arguments that need grouping in emitted code. */\nfunction buildSafeSpreadArgument(expr: t.Expression): t.Expression {\n return t.isConditionalExpression(expr) || t.isLogicalExpression(expr) ? t.parenthesizedExpression(expr) : expr;\n}\n\n/** Resolve static property names for `styles.wrapper` or `styles[\"wrapper\"]`. */\nfunction getStaticMemberPropertyName(expr: t.MemberExpression, path: NodePath): string | null {\n if (!expr.computed && t.isIdentifier(expr.property)) {\n return expr.property.name;\n }\n\n if (t.isStringLiteral(expr.property)) {\n return expr.property.value;\n }\n\n if (t.isIdentifier(expr.property)) {\n const binding = path.scope.getBinding(expr.property.name);\n if (!binding?.path.isVariableDeclarator()) return null;\n const init = binding.path.node.init;\n return t.isStringLiteral(init) ? init.value : null;\n }\n\n return null;\n}\n\n/** Resolve the return expression of a call, checking local functions and callback args. */\nfunction getCallReturnExpression(expr: t.CallExpression, path: NodePath): t.Expression | null {\n const localReturnExpr = getLocalFunctionReturnExpression(expr, path);\n if (localReturnExpr) return localReturnExpr;\n\n const firstArg = expr.arguments[0];\n if (\n firstArg &&\n !t.isSpreadElement(firstArg) &&\n (t.isArrowFunctionExpression(firstArg) || t.isFunctionExpression(firstArg))\n ) {\n return getFunctionLikeReturnExpression(firstArg); // I.e. `useMemo(() => ({ ...baseStyles }), deps)`\n }\n\n return null;\n}\n\n/** Resolve a local function call's return expression. */\nfunction getLocalFunctionReturnExpression(expr: t.CallExpression, path: NodePath): t.Expression | null {\n if (!t.isIdentifier(expr.callee)) return null;\n\n const binding = path.scope.getBinding(expr.callee.name);\n if (!binding) return null;\n\n if (binding.path.isFunctionDeclaration()) {\n return getFunctionLikeReturnExpression(binding.path.node);\n }\n\n if (binding.path.isVariableDeclarator()) {\n const init = binding.path.node.init;\n if (init && (t.isArrowFunctionExpression(init) || t.isFunctionExpression(init))) {\n return getFunctionLikeReturnExpression(init);\n }\n }\n\n return null;\n}\n\n/** Extract a single returned expression from a function-like node. */\nfunction getFunctionLikeReturnExpression(\n fn: t.FunctionDeclaration | t.FunctionExpression | t.ArrowFunctionExpression,\n): t.Expression | null {\n if (t.isExpression(fn.body)) {\n return fn.body;\n }\n\n if (fn.body.body.length !== 1) return null;\n const stmt = fn.body.body[0];\n return t.isReturnStatement(stmt) && stmt.argument && t.isExpression(stmt.argument) ? stmt.argument : null;\n}\n","import { parse } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport { extractChain, findCssImportBinding } from \"./ast-utils\";\nimport { collectStaticStringBindings, resolveStaticString } from \"./css-ts-utils\";\n\n/**\n * Transform a `.css.ts` file into a plain CSS string.\n *\n * The file is expected to have the shape:\n * ```ts\n * import { Css } from \"./Css\";\n * export const css = {\n * \".some-selector\": Css.df.blue.$,\n * \".other > .selector\": Css.mt(2).black.$,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is a `Css.*.$` chain.\n * The chains are resolved via the truss mapping into concrete CSS declarations.\n *\n * Returns the generated CSS string.\n */\nexport function transformCssTs(code: string, filename: string, mapping: TrussMapping): string {\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) {\n return `/* [truss] ${filename}: no Css import found */\\n`;\n }\n\n // Find the `export const css = { ... }` expression\n const cssExport = findNamedCssExportObject(ast);\n if (!cssExport) {\n return `/* [truss] ${filename}: expected \\`export const css = { ... }\\` with an object literal */\\n`;\n }\n\n const rules: string[] = [];\n const stringBindings = collectStaticStringBindings(ast);\n\n for (const prop of cssExport.properties) {\n if (t.isSpreadElement(prop)) {\n rules.push(`/* [truss] unsupported: spread elements in css.ts export */`);\n continue;\n }\n\n if (!t.isObjectProperty(prop)) {\n rules.push(`/* [truss] unsupported: non-property in css.ts export */`);\n continue;\n }\n\n // Key must be a string literal (the CSS selector)\n const selector = objectPropertyStringKey(prop, stringBindings);\n if (selector === null) {\n rules.push(`/* [truss] unsupported: non-string-literal key in css.ts export */`);\n continue;\n }\n\n // Value must be a Css.*.$ expression\n const valueNode = prop.value;\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n const cssResult = resolveCssExpression(valueNode, cssBindingName, mapping, filename);\n if (\"error\" in cssResult) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — ${cssResult.error} */`);\n continue;\n }\n\n rules.push(formatCssRule(selector, cssResult.declarations));\n }\n\n return rules.join(\"\\n\\n\") + \"\\n\";\n}\n\n/** Find the object expression in `export const css = { ... }`. */\nfunction findNamedCssExportObject(ast: t.File): t.ObjectExpression | null {\n for (const node of ast.program.body) {\n if (!t.isExportNamedDeclaration(node) || !node.declaration) continue;\n if (!t.isVariableDeclaration(node.declaration)) continue;\n\n for (const declarator of node.declaration.declarations) {\n if (!t.isIdentifier(declarator.id, { name: \"css\" })) continue;\n const value = unwrapObjectExpression(declarator.init);\n if (value) return value;\n }\n }\n return null;\n}\n\nfunction unwrapObjectExpression(node: t.Expression | null | undefined): t.ObjectExpression | null {\n if (!node) return null;\n if (t.isObjectExpression(node)) return node;\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node)) return unwrapObjectExpression(node.expression);\n return null;\n}\n\n/** Extract a static string key from an ObjectProperty. */\nfunction objectPropertyStringKey(prop: t.ObjectProperty, stringBindings: Map<string, string>): string | null {\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n // Allow unquoted identifiers as keys too (e.g. `body: Css.df.$`)\n if (t.isIdentifier(prop.key) && !prop.computed) return prop.key.name;\n if (prop.computed) return resolveStaticString(prop.key, stringBindings);\n return null;\n}\n\ninterface CssResolution {\n declarations: Array<{ property: string; value: string }>;\n error?: undefined;\n}\ninterface CssError {\n declarations?: undefined;\n error: string;\n}\n\n/**\n * Resolve a `Css.*.$` expression node to CSS declarations.\n *\n * Validates that the chain only uses static/literal patterns (no variable args,\n * no if/else conditionals, no pseudo/media modifiers).\n */\nfunction resolveCssExpression(\n node: t.Expression,\n cssBindingName: string,\n mapping: TrussMapping,\n filename: string,\n): CssResolution | CssError {\n // The expression must end with `.$`\n if (!t.isMemberExpression(node) || node.computed || !t.isIdentifier(node.property, { name: \"$\" })) {\n return { error: \"value must be a Css.*.$ expression\" };\n }\n\n const chain = extractChain(node.object, cssBindingName);\n if (!chain) {\n return { error: \"could not extract Css chain from expression\" };\n }\n\n // Validate: no if/else nodes\n for (const n of chain) {\n if (n.type === \"if\") return { error: \"if() conditionals are not supported in .css.ts files\" };\n if (n.type === \"else\") return { error: \"else is not supported in .css.ts files\" };\n }\n\n const resolved = resolveFullChain(chain, mapping);\n\n // Check for errors from resolution\n if (resolved.errors.length > 0) {\n return { error: resolved.errors[0] };\n }\n\n // Validate: no conditionals came back\n for (const part of resolved.parts) {\n if (part.type === \"conditional\") {\n return { error: \"conditional chains are not supported in .css.ts files\" };\n }\n }\n\n // Collect all declarations from all unconditional parts\n const declarations: Array<{ property: string; value: string }> = [];\n\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") continue;\n for (const seg of part.segments) {\n if (seg.error) {\n return { error: seg.error };\n }\n\n // Reject segments that require runtime (dynamic with variable args)\n if (seg.dynamicProps && !seg.argResolved) {\n return { error: `dynamic value with variable argument is not supported in .css.ts files` };\n }\n if (seg.typographyLookup) {\n return { error: `typography() with a runtime key is not supported in .css.ts files` };\n }\n if (seg.styleArrayArg) {\n return { error: `add(cssProp) is not supported in .css.ts files` };\n }\n\n // Reject segments with media query / pseudo-class / pseudo-element / when modifiers\n if (seg.mediaQuery) {\n return { error: `media query modifiers (ifSm, ifMd, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoClass) {\n return { error: `pseudo-class modifiers (onHover, onFocus, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoElement) {\n return { error: `pseudo-element modifiers are not supported in .css.ts files` };\n }\n if (seg.whenPseudo) {\n return { error: `when() modifiers are not supported in .css.ts files` };\n }\n\n // Extract CSS property/value pairs from defs\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (typeof value === \"string\" || typeof value === \"number\") {\n declarations.push({ property: camelToKebab(prop), value: String(value) });\n } else {\n // Nested condition objects (shouldn't happen after our validation, but defensive)\n return { error: `unexpected nested value for property \"${prop}\"` };\n }\n }\n }\n }\n\n return { declarations };\n}\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function camelToKebab(s: string): string {\n // Handle vendor prefixes like WebkitTransform → -webkit-transform\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** Format a CSS rule block. */\nfunction formatCssRule(selector: string, declarations: Array<{ property: string; value: string }>): string {\n if (declarations.length === 0) {\n return `${selector} {}`;\n }\n const body = declarations.map((d) => ` ${d.property}: ${d.value};`).join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n","import * as t from \"@babel/types\";\n\n/** Resolve module-scope string constants so .css.ts selectors can reuse them. */\nexport function collectStaticStringBindings(ast: t.File): Map<string, string> {\n const bindings = new Map<string, string>();\n let changed = true;\n\n while (changed) {\n changed = false;\n\n for (const node of ast.program.body) {\n const declaration = getTopLevelVariableDeclaration(node);\n if (!declaration) continue;\n\n for (const declarator of declaration.declarations) {\n if (!t.isIdentifier(declarator.id) || !declarator.init) continue;\n if (bindings.has(declarator.id.name)) continue;\n\n const value = resolveStaticString(declarator.init, bindings);\n if (value === null) continue;\n\n bindings.set(declarator.id.name, value);\n changed = true;\n }\n }\n }\n\n return bindings;\n}\n\n/** Resolve a static string expression from a literal, template, or identifier. */\nexport function resolveStaticString(node: t.Node | null | undefined, bindings: Map<string, string>): string | null {\n if (!node) return null;\n\n if (t.isStringLiteral(node)) return node.value;\n\n if (t.isTemplateLiteral(node)) {\n let value = \"\";\n for (let i = 0; i < node.quasis.length; i++) {\n value += node.quasis[i].value.cooked ?? \"\";\n if (i >= node.expressions.length) continue;\n\n const expressionValue = resolveStaticString(node.expressions[i], bindings);\n if (expressionValue === null) return null;\n value += expressionValue;\n }\n return value;\n }\n\n if (t.isIdentifier(node)) {\n return bindings.get(node.name) ?? null;\n }\n\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node) || t.isTSNonNullExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isParenthesizedExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isBinaryExpression(node, { operator: \"+\" })) {\n const left = resolveStaticString(node.left, bindings);\n const right = resolveStaticString(node.right, bindings);\n if (left === null || right === null) return null;\n return left + right;\n }\n\n return null;\n}\n\nfunction getTopLevelVariableDeclaration(node: t.Statement): t.VariableDeclaration | null {\n if (t.isVariableDeclaration(node)) {\n return node;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration && t.isVariableDeclaration(node.declaration)) {\n return node.declaration;\n }\n\n return null;\n}\n","import { parse } from \"@babel/parser\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { findLastImportIndex } from \"./ast-utils\";\n\n// Babel generator is published as CJS, so normalize default interop before using it.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface RewriteCssTsImportsResult {\n code: string;\n changed: boolean;\n}\n\n/**\n * Rewrite `.css.ts` imports so runtime imports stay pointed at the real module,\n * while a separate `?truss-css` side-effect import is added for generated CSS.\n *\n * I.e. `import { foo } from \"./App.css.ts\"` becomes:\n * - `import { foo } from \"./App.css.ts\"`\n * - `import \"./App.css.ts?truss-css\"`\n *\n * Pure side-effect imports are rewritten directly to the virtual CSS import.\n */\nexport function rewriteCssTsImports(code: string, filename: string): RewriteCssTsImportsResult {\n if (!code.includes(\".css.ts\")) {\n return { code, changed: false };\n }\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const existingCssSideEffects = new Set<string>();\n const neededCssSideEffects = new Set<string>();\n let changed = false;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (typeof node.source.value !== \"string\") continue;\n if (!node.source.value.endsWith(\".css.ts\")) continue;\n\n if (node.specifiers.length === 0) {\n node.source = t.stringLiteral(toVirtualCssSpecifier(node.source.value));\n existingCssSideEffects.add(node.source.value);\n changed = true;\n continue;\n }\n\n neededCssSideEffects.add(toVirtualCssSpecifier(node.source.value));\n }\n\n const sideEffectImports: t.ImportDeclaration[] = [];\n for (const source of neededCssSideEffects) {\n if (existingCssSideEffects.has(source)) continue;\n sideEffectImports.push(t.importDeclaration([], t.stringLiteral(source)));\n changed = true;\n }\n\n if (!changed) {\n return { code, changed: false };\n }\n\n if (sideEffectImports.length > 0) {\n const insertIndex = findLastImportIndex(ast) + 1;\n ast.program.body.splice(insertIndex, 0, ...sideEffectImports);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n return { code: output.code, changed: true };\n}\n\nfunction toVirtualCssSpecifier(source: string): string {\n return `${source}?truss-css`;\n}\n"],"mappings":";AAAA,SAAS,cAAc,kBAAkB;AACzC,SAAS,SAAS,SAAS,kBAAkB;;;ACD7C,SAAS,aAAa;AACtB,OAAOA,gBAAe;AAEtB,OAAOC,gBAAe;AACtB,YAAYC,QAAO;AACnB,SAAS,gBAAgB;;;AC4DlB,SAAS,iBAAiB,OAAoB,SAAsC;AACzF,QAAM,QAA6B,CAAC;AACpC,QAAM,UAA2B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_traverse","_generate","t","suffix","key","t","t","traverse","_traverse","generate","_generate","parse","t","t","parse","parse","_generate","t","generate","_generate","parse"]}
|