{"version":3,"file":"queries-DL9Jp56F.mjs","names":[],"sources":["../src/tuple-key.ts","../src/value-key.ts","../src/token-graph/internal-utils.ts","../src/token-graph/walk.ts","../src/token-graph/queries.ts"],"sourcesContent":["/**\n * Branded canonical-tuple-key type. Structurally `string` so JSON\n * serialization / `Map` lookups behave identically at runtime; the\n * brand catches places that pass arbitrary strings (token paths, axis\n * names, theme display names) into a context expecting a canonical\n * tuple key.\n *\n * Internal — produced and consumed only by {@link canonicalKey} and its\n * callers; not part of the public API.\n */\ntype TupleKey = string & { readonly __brand: 'TupleKey' };\n\n/**\n * Canonical key for an axis tuple — axes sorted by name so `{A:a,B:b}`\n * and `{B:b,A:a}` produce the same lookup key.\n */\nexport function canonicalKey(tuple: Readonly<Record<string, string>>): TupleKey {\n  return Object.keys(tuple)\n    .toSorted()\n    .map((k) => `${k}:${tuple[k]}`)\n    .join('|') as TupleKey;\n}\n","/**\n * Stable comparison key for a DTCG token's `$value`. Composite tokens\n * (shadow, typography, …) compare on every sub-field; missing tokens\n * compare equal to the empty string.\n *\n * Object keys are sorted recursively so that two structurally equal\n * composite values compare as equal regardless of field insertion order\n * (e.g. when a walker reconstitutes a partial-alias composite, its\n * aliased sub-fields are appended last rather than placed in the\n * original schema order).\n *\n * Structural input type (`{$value?: unknown} | undefined`) so this\n * helper doesn't pull `@terrazzo/parser`'s `TokenNormalized` into the\n * import graph — keeps any consumer that wants only `valueKey`\n * Terrazzo-free.\n */\nexport function valueKey(token: { $value?: unknown } | undefined): string {\n  if (!token) return '';\n  return JSON.stringify(token.$value, sortedKeyReplacer);\n}\n\nfunction sortedKeyReplacer(this: unknown, _key: string, value: unknown): unknown {\n  if (value !== null && typeof value === 'object' && !Array.isArray(value)) {\n    const sorted: Record<string, unknown> = {};\n    for (const k of Object.keys(value as object).toSorted()) {\n      sorted[k] = (value as Record<string, unknown>)[k];\n    }\n    return sorted;\n  }\n  return value;\n}\n","// Internal helpers shared across token-graph modules. Not part of the /graph public surface.\nexport function isPlainObject(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n","import type { SwatchbookToken, TokenMap } from '#/types.ts';\nimport type { TokenGraph, WriteValue } from '#/token-graph/types.ts';\nimport { canonicalKey } from '#/tuple-key.ts';\nimport { isPlainObject } from '#/token-graph/internal-utils.ts';\n\nconst CYCLE_SENTINEL: unique symbol = Symbol('cycle');\n// Distinct from CYCLE_SENTINEL: marks a path that resolved to undefined\n// (dangling alias, missing node). Without it, a failed resolution would leave\n// the in-progress CYCLE_SENTINEL in the shared memo, and a later lookup would\n// misread that as a cycle and return the failed node's baseline — making\n// resolveAllAt order-dependent and inconsistent with resolveAt.\nconst FAILED: unique symbol = Symbol('failed');\n\ntype CycleMemo = Map<string, SwatchbookToken | typeof CYCLE_SENTINEL | typeof FAILED>;\n\nfunction resolveAtInternal(\n  graph: TokenGraph,\n  path: string,\n  tuple: Record<string, string>,\n  memo: CycleMemo,\n): SwatchbookToken | undefined {\n  const node = graph.nodes[path];\n  if (!node) return undefined;\n\n  const cacheKey = path + ' ' + canonicalKey(tuple);\n\n  // Fast path: constant token — no axis in tuple is non-default for this node.\n  if (node.affectedBy.length === 0) {\n    memo.set(cacheKey, node.baselineValue);\n    return node.baselineValue;\n  }\n  const hasNonDefaultAxis = node.affectedBy.some(\n    (axis) => tuple[axis] !== undefined && tuple[axis] !== graph.axisDefaults[axis],\n  );\n  if (!hasNonDefaultAxis) {\n    memo.set(cacheKey, node.baselineValue);\n    return node.baselineValue;\n  }\n\n  const cached = memo.get(cacheKey);\n  if (cached !== undefined) {\n    if (cached === CYCLE_SENTINEL) return node.baselineValue;\n    if (cached === FAILED) return undefined;\n    return cached;\n  }\n\n  memo.set(cacheKey, CYCLE_SENTINEL);\n\n  // Find the last-wins direct write across axes in project order.\n  let matchedWrite: WriteValue | undefined = undefined;\n  for (const axis of graph.axes) {\n    const ctx = tuple[axis];\n    if (ctx === undefined || ctx === graph.axisDefaults[axis]) continue;\n    const axisWrites = node.writes[axis];\n    if (!axisWrites) continue;\n    const write = axisWrites[ctx];\n    if (write !== undefined) matchedWrite = write;\n  }\n\n  let result: SwatchbookToken | undefined;\n\n  if (matchedWrite === undefined) {\n    // No direct write — resolve baseline structure.\n    if (node.baselineKind === 'literal') {\n      result = node.baselineValue;\n    } else if (node.baselineKind === 'alias') {\n      result = resolveAtInternal(graph, node.baselineAliasTarget!, tuple, memo);\n    } else {\n      result = composePartial(graph, node.baselineValue, node.baselinePartialFields!, tuple, memo);\n    }\n  } else {\n    // Direct write applies — resolve per write kind.\n    if (matchedWrite.kind === 'literal') {\n      result = matchedWrite.value;\n    } else if (matchedWrite.kind === 'alias') {\n      result = resolveAtInternal(graph, matchedWrite.target, tuple, memo);\n    } else {\n      result = composePartial(graph, matchedWrite.baseValue, matchedWrite.aliasFields, tuple, memo);\n    }\n  }\n\n  // Always overwrite the CYCLE_SENTINEL placed above — with the resolved value,\n  // or FAILED when resolution came back undefined — so the sentinel never\n  // outlives this call in the shared memo.\n  memo.set(cacheKey, result ?? FAILED);\n  return result;\n}\n\n/**\n * Resolve a single token to its leaf value at `tuple` — the foundational\n * single-token resolution primitive every other resolver in this module\n * builds on. Walks direct writes (last-wins across axes in project order),\n * alias targets, and partial-alias composition until it reaches a literal.\n * Returns `undefined` for a path not in the graph or one whose alias chain\n * fails to resolve. Cycle-safe: a self-referential chain falls back to the\n * node's baseline value rather than looping.\n */\nexport function resolveAt(\n  graph: TokenGraph,\n  path: string,\n  tuple: Record<string, string>,\n): SwatchbookToken | undefined {\n  return resolveAtInternal(graph, path, tuple, new Map());\n}\n\n/**\n * Resolve every token in the graph to its leaf value at `tuple` — the\n * project-wide counterpart to `resolveAt`, sharing one cycle-detection memo\n * across all paths. The primitive the CSS emitter, the loader's\n * `defaultTokens` snapshot, and `getVariance`'s per-context sampling all\n * build on. Paths that fail to resolve are omitted from the result rather\n * than included as `undefined`.\n */\nexport function resolveAllAt(graph: TokenGraph, tuple: Record<string, string>): TokenMap {\n  const memo: CycleMemo = new Map();\n  const result: TokenMap = {};\n  for (const path of Object.keys(graph.nodes)) {\n    const value = resolveAtInternal(graph, path, tuple, memo);\n    if (value !== undefined) result[path] = value;\n  }\n  return result;\n}\n\n/**\n * Like `resolveAt`, but stops at the first alias/partial-alias write\n * (or baseline structure) and returns the alias view instead of\n * recursing to a leaf. Returned token retains the source path's\n * structural shape — useful for emitters that need to reference\n * `aliasOf` to emit `var(--…)` references rather than literal values.\n *\n * - Literal at this tuple → returns the literal token (same as `resolveAt`).\n * - Alias at this tuple → returns a token with `aliasOf: <target>` and\n *   `$value: <target's resolved leaf at this tuple>` (preserves alias provenance).\n * - Partial-alias at this tuple → returns a token with `partialAliasOf: <fields-map>`\n *   and `$value: <composed value>` (preserves which fields are aliased).\n */\nexport function resolveAliasAt(\n  graph: TokenGraph,\n  path: string,\n  tuple: Record<string, string>,\n): SwatchbookToken | undefined {\n  const node = graph.nodes[path];\n  if (!node) return undefined;\n\n  let directWrite: WriteValue | undefined;\n  for (const axis of graph.axes) {\n    const ctx = tuple[axis];\n    if (!ctx || ctx === graph.axisDefaults[axis]) continue;\n    const w = node.writes[axis]?.[ctx];\n    if (w) directWrite = w;\n  }\n\n  if (!directWrite) {\n    if (node.baselineKind === 'literal') return node.baselineValue;\n    if (node.baselineKind === 'alias') {\n      const aliasTarget = node.baselineAliasTarget!;\n      const targetLeaf = resolveAt(graph, aliasTarget, tuple);\n      return {\n        ...node.baselineValue,\n        aliasOf: aliasTarget,\n        aliasChain: [aliasTarget],\n        $value: targetLeaf?.$value,\n      };\n    }\n    // Partial-alias baseline: preserve the original partialAliasOf structure from\n    // node.baselineValue (nested, as transformCSSValue expects), only refresh $value.\n    const composed = resolveAt(graph, path, tuple);\n    return {\n      ...node.baselineValue,\n      $value: composed?.$value,\n    };\n  }\n\n  // A direct write replaces the token's structure at this tuple, so the\n  // baseline's alias metadata must not survive the spread: Terrazzo's\n  // transforms route on aliasChain/partialAliasOf before $value, and a\n  // leaked field emits var() references to the baseline's old target.\n  const { aliasOf: _a, aliasChain: _c, partialAliasOf: _p, ...baseline } = node.baselineValue;\n\n  if (directWrite.kind === 'literal') return { ...baseline, ...directWrite.value };\n  if (directWrite.kind === 'alias') {\n    const targetLeaf = resolveAt(graph, directWrite.target, tuple);\n    return {\n      ...baseline,\n      aliasOf: directWrite.target,\n      aliasChain: [directWrite.target],\n      $value: targetLeaf?.$value,\n    };\n  }\n  const composed = resolveAt(graph, path, tuple);\n  return {\n    ...baseline,\n    ...directWrite.baseValue,\n    partialAliasOf: directWrite.aliasFields,\n    $value: composed?.$value,\n  };\n}\n\n/**\n * The full forward alias chain for `path` at `tuple` — the target paths it\n * resolves through, hop by hop, to the final literal, e.g.\n * `['color.brand', 'color.palette.blue.500']`. Each hop's immediate target is\n * whatever `resolveAliasAt` resolves at this tuple (per-tuple alias write,\n * else baseline alias), so the chain is correct in every axis context, not\n * just the default. Empty for a literal. Visited-set bounds cycles.\n */\nexport function aliasChainAt(\n  graph: TokenGraph,\n  path: string,\n  tuple: Record<string, string>,\n): string[] {\n  const chain: string[] = [];\n  const visited = new Set<string>([path]);\n  let current = path;\n  for (;;) {\n    const target = resolveAliasAt(graph, current, tuple)?.aliasOf;\n    if (target === undefined || visited.has(target)) break;\n    chain.push(target);\n    visited.add(target);\n    current = target;\n  }\n  return chain;\n}\n\nexport function resolveAliasAllAt(graph: TokenGraph, tuple: Record<string, string>): TokenMap {\n  const result: TokenMap = {};\n  for (const path of Object.keys(graph.nodes)) {\n    const value = resolveAliasAt(graph, path, tuple);\n    if (value !== undefined) result[path] = value;\n  }\n  return result;\n}\n\n/**\n * Browser display resolver: every token's resolved leaf `$value` (same as\n * `resolveAllAt`) plus correct, tuple-aware alias provenance — the full\n * forward `aliasChain` / immediate `aliasOf` (from `aliasChainAt`) and the\n * graph node's structural-union `aliasedBy` (project-scoped reverse edges,\n * stable across tuples). This is the source of truth for alias indicators;\n * `resolveAllAt` stays the pure-leaf resolver the CSS emitter and `load.ts`\n * use. Aliases keep their OWN provenance even when their target varies by\n * axis (the defect this fixes: `resolveAllAt` substitutes the target's).\n */\nexport function resolveAllWithProvenanceAt(\n  graph: TokenGraph,\n  tuple: Record<string, string>,\n): TokenMap {\n  const result: TokenMap = {};\n  for (const path of Object.keys(graph.nodes)) {\n    const view = resolveAliasAt(graph, path, tuple);\n    if (view === undefined) continue;\n    const chain = aliasChainAt(graph, path, tuple);\n    const aliasedBy = graph.nodes[path]?.aliasedBy ?? [];\n    const { aliasOf: _aliasOf, aliasChain: _aliasChain, ...rest } = view;\n    result[path] = {\n      ...rest,\n      ...(chain.length > 0 ? { aliasOf: chain[0], aliasChain: chain } : {}),\n      aliasedBy,\n    };\n  }\n  return result;\n}\n\nfunction composePartial(\n  graph: TokenGraph,\n  base: SwatchbookToken,\n  fields: Record<string, string>,\n  tuple: Record<string, string>,\n  memo: CycleMemo,\n): SwatchbookToken {\n  const result = { ...base };\n  const baseValue = base.$value;\n  let value: unknown;\n  if (Array.isArray(baseValue)) {\n    value = [...baseValue].map((v) => (isPlainObject(v) ? { ...v } : v));\n  } else if (isPlainObject(baseValue)) {\n    value = { ...baseValue };\n  } else {\n    value = baseValue;\n  }\n\n  for (const [fieldPath, targetPath] of Object.entries(fields)) {\n    const resolved = resolveAtInternal(graph, targetPath, tuple, memo);\n    if (resolved?.$value !== undefined) {\n      assignByPath(value as object, fieldPath, resolved.$value);\n    }\n  }\n\n  result.$value = value;\n  return result;\n}\n\nfunction assignByPath(obj: object, path: string, value: unknown): void {\n  const parts = path.split('.');\n  let cur: unknown = obj;\n  for (let i = 0; i < parts.length - 1; i++) {\n    const part = parts[i]!;\n    if (Array.isArray(cur)) {\n      const idx = Number(part);\n      if (!Number.isInteger(idx) || idx < 0 || idx >= cur.length) return;\n      if (Array.isArray(cur[idx])) cur[idx] = [...(cur[idx] as unknown[])];\n      else if (cur[idx] && typeof cur[idx] === 'object') cur[idx] = { ...(cur[idx] as object) };\n      cur = cur[idx];\n    } else if (cur && typeof cur === 'object') {\n      if (part === '__proto__' || part === 'constructor' || part === 'prototype') return;\n      const rec = cur as Record<string, unknown>;\n      if (Array.isArray(rec[part])) rec[part] = [...(rec[part] as unknown[])];\n      else if (rec[part] && typeof rec[part] === 'object') rec[part] = { ...(rec[part] as object) };\n      cur = rec[part];\n    } else {\n      return;\n    }\n  }\n  const finalPart = parts[parts.length - 1]!;\n  if (Array.isArray(cur)) {\n    const idx = Number(finalPart);\n    if (Number.isInteger(idx) && idx >= 0 && idx < cur.length) (cur as unknown[])[idx] = value;\n  } else if (cur && typeof cur === 'object') {\n    if (finalPart === '__proto__' || finalPart === 'constructor' || finalPart === 'prototype')\n      return;\n    Object.defineProperty(cur, finalPart, {\n      value,\n      writable: true,\n      configurable: true,\n      enumerable: true,\n    });\n  }\n}\n","import type { AxisVariancePerAxis, AxisVarianceResult } from '#/types.ts';\nimport type { TokenGraph } from '#/token-graph/types.ts';\nimport { resolveAt } from '#/token-graph/walk.ts';\nimport { valueKey } from '#/value-key.ts';\n\n/**\n * Axis names that affect `path`'s resolved value anywhere in the project —\n * a thin accessor over the graph node's precomputed `affectedBy` set.\n * Empty array (never `undefined`) for a constant token or a path not in\n * the graph.\n */\nexport function getAffectedBy(graph: TokenGraph, path: string): readonly string[] {\n  return graph.nodes[path]?.affectedBy ?? [];\n}\n\n/**\n * Every token path in the graph, sorted lexicographically. The sort order\n * is a stated contract, not an incidental side effect of `Object.keys` —\n * consumers may rely on it for stable iteration (deterministic emission\n * order, diffable snapshots) without re-sorting themselves.\n */\nexport function listPaths(graph: TokenGraph): readonly string[] {\n  return Object.keys(graph.nodes).toSorted();\n}\n\n/**\n * Compute how `path`'s resolved value varies across the project's axes.\n * For each axis, samples the token's value in every one of that axis's\n * contexts while holding every other axis at its default (`perAxis`) —\n * this isolates each axis's individual effect rather than reporting joint\n * behavior. `kind` discriminates on how many axes the resolved value\n * actually differs across: `constant` (none), `single` (exactly one), or\n * `multi` (two or more); see `AxisVarianceResult` for the per-kind fields.\n */\nexport function getVariance(graph: TokenGraph, path: string): AxisVarianceResult {\n  const node = graph.nodes[path];\n  const varying = node?.affectedBy ?? [];\n  const constantAcross = graph.axes.filter((a) => !varying.includes(a));\n\n  const perAxis: AxisVariancePerAxis = {};\n  for (const axis of graph.axes) {\n    const contexts: Record<string, string> = {};\n    for (const ctx of graph.axisContexts[axis] ?? []) {\n      const tuple: Record<string, string> = { ...graph.axisDefaults, [axis]: ctx };\n      const value = resolveAt(graph, path, tuple);\n      contexts[ctx] = valueKey(value);\n    }\n    perAxis[axis] = { varying: varying.includes(axis), contexts };\n  }\n\n  if (varying.length === 0) {\n    return {\n      path,\n      kind: 'constant',\n      varyingAxes: [],\n      constantAcrossAxes: constantAcross,\n      perAxis,\n    };\n  }\n  if (varying.length === 1) {\n    return {\n      path,\n      kind: 'single',\n      axis: varying[0]!,\n      varyingAxes: [varying[0]!],\n      constantAcrossAxes: constantAcross,\n      perAxis,\n    };\n  }\n  return {\n    path,\n    kind: 'multi',\n    varyingAxes: [varying[0]!, varying[1]!, ...varying.slice(2)],\n    constantAcrossAxes: constantAcross,\n    perAxis,\n  };\n}\n"],"mappings":";;;;;AAgBA,SAAgB,aAAa,OAAmD;AAC9E,QAAO,OAAO,KAAK,MAAM,CACtB,UAAU,CACV,KAAK,MAAM,GAAG,EAAE,GAAG,MAAM,KAAK,CAC9B,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;ACJd,SAAgB,SAAS,OAAiD;AACxE,KAAI,CAAC,MAAO,QAAO;AACnB,QAAO,KAAK,UAAU,MAAM,QAAQ,kBAAkB;;AAGxD,SAAS,kBAAiC,MAAc,OAAyB;AAC/E,KAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,EAAE;EACxE,MAAM,SAAkC,EAAE;AAC1C,OAAK,MAAM,KAAK,OAAO,KAAK,MAAgB,CAAC,UAAU,CACrD,QAAO,KAAM,MAAkC;AAEjD,SAAO;;AAET,QAAO;;;;AC5BT,SAAgB,cAAc,GA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