{"version":3,"file":"server.cjs","names":["readRules","escapingMap","namespaces","toScene"],"sources":["../src/server/css.ts","../src/server/presentation.ts","../src/server/selectors.ts","../src/server/values.ts","../src/server/cascade.ts","../src/server/applyStyles.ts","../src/server/string.ts","../src/server/renderForHydration.ts"],"sourcesContent":["/**\n * The CSS reader of `applyStyles()`: style rules with their declarations,\n * from stylesheets as chart styles write them. Not a full CSS parser: what\n * it can't read it skips, and it never throws.\n */\n\n/** The color scheme `@media (prefers-color-scheme)` and `light-dark()` use. */\nexport type ColorScheme = 'light' | 'dark';\n\n/** One declaration of a rule or of a `style` attribute. */\nexport interface Declaration {\n  /** Lower case, except custom properties (`--ct-color`), which keep it. */\n  readonly property: string;\n  /** The value without `!important`, trimmed. */\n  readonly value: string;\n  readonly important: boolean;\n}\n\n/**\n * Why `computeStyles()` left a part of a stylesheet out: `at-rule`,\n * `selector`, `nested`, `shorthand` or `value` (see `SkippedStyle`).\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n */\nexport type SkipReason =\n  | 'at-rule'\n  | 'selector'\n  | 'nested'\n  | 'shorthand'\n  | 'value';\n\n/** Reports a part of a stylesheet that was left out, with its text. */\nexport type Report = (reason: SkipReason, text: string) => void;\n\n/** A style rule, read in place from whatever block it was in. */\nexport interface StyleRule {\n  /** The selector list as written, e.g. `.ct-series-a .ct-line, .ct-bar`. */\n  readonly selectors: string;\n  readonly declarations: readonly Declaration[];\n}\n\n/** Where a string that starts at `start` ends: after its closing quote, or at a newline. */\nfunction stringEnd(text: string, start: number): number {\n  const quote = text[start];\n  let i = start + 1;\n  while (i < text.length && text[i] !== quote && text[i] !== '\\n') {\n    i += text[i] === '\\\\' ? 2 : 1;\n  }\n  return text[i] === quote ? i + 1 : i;\n}\n\n/** The text without comments; comment markers inside strings stay. */\nexport function withoutComments(text: string): string {\n  let out = '';\n  let i = 0;\n  while (i < text.length) {\n    const char = text[i];\n    if (char === '\"' || char === \"'\") {\n      const end = stringEnd(text, i);\n      out += text.slice(i, end);\n      i = end;\n    } else if (char === '/' && text[i + 1] === '*') {\n      const end = text.indexOf('*/', i + 2);\n      i = end < 0 ? text.length : end + 2;\n      out += ' ';\n    } else {\n      out += char;\n      i++;\n    }\n  }\n  return out;\n}\n\n/**\n * The index of the first of `chars` at the top level from `start` on:\n * outside strings, parentheses and brackets. `end` if there's none.\n */\nexport function topLevel(\n  text: string,\n  chars: string,\n  start = 0,\n  end = text.length\n): number {\n  let depth = 0;\n  let i = start;\n  while (i < end) {\n    const char = text[i];\n    if (char === '\"' || char === \"'\") {\n      i = stringEnd(text, i);\n      continue;\n    }\n    if (char === '\\\\') {\n      i += 2;\n      continue;\n    }\n    if (depth === 0 && chars.includes(char)) {\n      return i;\n    }\n    if (char === '(' || char === '[') {\n      depth++;\n    } else if ((char === ')' || char === ']') && depth > 0) {\n      depth--;\n    }\n    i++;\n  }\n  return end;\n}\n\n/** The index of the `}` that closes the block opened just before `start`. */\nfunction blockEnd(text: string, start: number, end: number): number {\n  let depth = 1;\n  let i = start;\n  while (i < end) {\n    i = topLevel(text, '{}', i, end);\n    if (i >= end) {\n      break;\n    }\n    depth += text[i] === '{' ? 1 : -1;\n    if (depth === 0) {\n      return i;\n    }\n    i++;\n  }\n  return end;\n}\n\n/** Splits at a character on the top level, e.g. a selector list at `,`. */\nexport function splitTopLevel(text: string, separator: string): string[] {\n  const parts: string[] = [];\n  let start = 0;\n  for (;;) {\n    const index = topLevel(text, separator, start);\n    parts.push(text.slice(start, index));\n    if (index >= text.length) {\n      return parts;\n    }\n    start = index + 1;\n  }\n}\n\nfunction declaration(text: string): Declaration | undefined {\n  const colon = text.indexOf(':');\n  if (colon <= 0) {\n    return undefined;\n  }\n  const name = text.slice(0, colon).trim();\n  let value = text.slice(colon + 1).trim();\n  const important = /!\\s*important$/i.test(value);\n  if (important) {\n    value = value.replace(/!\\s*important$/i, '').trim();\n  }\n  const custom = name.startsWith('--');\n  if (!/^-?[\\w-]+$/.test(name) || (!custom && !value)) {\n    return undefined;\n  }\n  return { property: custom ? name : name.toLowerCase(), value, important };\n}\n\n/**\n * The declarations of a block or a `style` attribute, in order. Nested\n * rules are skipped.\n */\nexport function readDeclarations(\n  text: string,\n  start = 0,\n  end = text.length,\n  report?: Report\n): Declaration[] {\n  const declarations: Declaration[] = [];\n  let i = start;\n  while (i < end) {\n    const index = topLevel(text, ';{', i, end);\n    if (text[index] === '{' && index < end) {\n      // A nested rule, with its selector: skipped.\n      report?.('nested', text.slice(i, index).trim());\n      i = blockEnd(text, index + 1, end) + 1;\n      continue;\n    }\n    const read = declaration(text.slice(i, index));\n    if (read) {\n      declarations.push(read);\n    }\n    i = index + 1;\n  }\n  return declarations;\n}\n\n/**\n * Whether the rules of an at-rule apply: `@media` with one\n * `prefers-color-scheme` condition when it's the scheme (`other-scheme`\n * when it's the other one, which isn't reported), `@supports`\n * unless its condition starts with `not` (a current browser has what chart\n * styles test for), and `@layer` blocks, read in place. Other at-rules are\n * skipped.\n */\nfunction applies(\n  prelude: string,\n  scheme: ColorScheme\n): boolean | 'other-scheme' {\n  const [, name = '', condition = ''] =\n    /^@([\\w-]+)\\s*([\\s\\S]*)$/.exec(prelude) ?? [];\n  switch (name.toLowerCase()) {\n    case 'media': {\n      const query = /^\\(\\s*prefers-color-scheme\\s*:\\s*(light|dark)\\s*\\)$/i.exec(\n        condition\n      );\n      return query\n        ? query[1].toLowerCase() === scheme || 'other-scheme'\n        : false;\n    }\n    case 'supports':\n      return !/^not\\b/i.test(condition);\n    case 'layer':\n      return true;\n    default:\n      return false;\n  }\n}\n\nfunction readRules(\n  text: string,\n  start: number,\n  end: number,\n  scheme: ColorScheme,\n  rules: StyleRule[],\n  report?: Report\n) {\n  let i = start;\n  while (i < end) {\n    const index = topLevel(text, '{;}', i, end);\n    const prelude = text.slice(i, index).trim();\n    if (index >= end || text[index] !== '{') {\n      // A statement (`@import …;`, `@layer a, b;`) or a stray character.\n      // Only `@import` would have added rules.\n      if (/^@import\\b/i.test(prelude)) {\n        report?.('at-rule', prelude);\n      }\n      i = index + 1;\n      continue;\n    }\n    const close = blockEnd(text, index + 1, end);\n    if (prelude.startsWith('@')) {\n      const read = applies(prelude, scheme);\n      if (read === true) {\n        readRules(text, index + 1, close, scheme, rules, report);\n      } else if (!read) {\n        report?.('at-rule', prelude);\n      }\n    } else if (prelude) {\n      rules.push({\n        selectors: prelude,\n        declarations: readDeclarations(text, index + 1, close, report)\n      });\n    }\n    i = close + 1;\n  }\n}\n\n/**\n * Reads the style rules of a stylesheet, in order, for a color scheme:\n * rules in `@media (prefers-color-scheme: …)` only when it matches, rules\n * in `@supports` and `@layer` blocks in place (ignoring layer order), and\n * none from other at-rules or nested rules.\n */\nexport function readStylesheet(\n  css: string,\n  scheme: ColorScheme,\n  report?: Report\n): StyleRule[] {\n  const text = withoutComments(css);\n  const rules: StyleRule[] = [];\n  readRules(text, 0, text.length, scheme, rules, report);\n  return rules;\n}\n","/**\n * The CSS properties SVG has presentation attributes for, without the\n * geometry properties (`x`, `r`, `d`), which only some elements take.\n * `renderForHydration()` and `applyStyles()` write these as attributes.\n * Pure, so an import of `renderToString()` alone drops it.\n */\nconst PRESENTATION = /* @__PURE__ */ new Set([\n  'alignment-baseline',\n  'baseline-shift',\n  'clip-path',\n  'clip-rule',\n  'color',\n  'color-interpolation',\n  'color-interpolation-filters',\n  'cursor',\n  'direction',\n  'display',\n  'dominant-baseline',\n  'fill',\n  'fill-opacity',\n  'fill-rule',\n  'filter',\n  'flood-color',\n  'flood-opacity',\n  'font-family',\n  'font-size',\n  'font-size-adjust',\n  'font-stretch',\n  'font-style',\n  'font-variant',\n  'font-weight',\n  'image-rendering',\n  'letter-spacing',\n  'lighting-color',\n  'marker-end',\n  'marker-mid',\n  'marker-start',\n  'mask',\n  'opacity',\n  'overflow',\n  'paint-order',\n  'pointer-events',\n  'shape-rendering',\n  'stop-color',\n  'stop-opacity',\n  'stroke',\n  'stroke-dasharray',\n  'stroke-dashoffset',\n  'stroke-linecap',\n  'stroke-linejoin',\n  'stroke-miterlimit',\n  'stroke-opacity',\n  'stroke-width',\n  'text-anchor',\n  'text-decoration',\n  'text-rendering',\n  'unicode-bidi',\n  'vector-effect',\n  'visibility',\n  'word-spacing',\n  'writing-mode'\n]);\n\n/** Whether a CSS property has an SVG presentation attribute of its name. */\nexport const isPresentation = (property: string) => PRESENTATION.has(property);\n","/**\n * Selector matching of `applyStyles()` against the scene tree: type,\n * class, `*` and attribute selectors (presence, `=`, `~=`), `:not()`,\n * `:is()` and `:where()`, descendant and child combinators. A selector\n * with anything else (`:hover`, `::before`, `#id`, `+`) matches nothing.\n */\nimport type { SceneNode } from '../index';\nimport { splitTopLevel, topLevel, type Report } from './css';\n\ntype Simple =\n  | { readonly kind: 'type'; readonly name: string }\n  | { readonly kind: 'class'; readonly name: string }\n  | {\n      readonly kind: 'attribute';\n      readonly name: string;\n      readonly operator?: '=' | '~=';\n      readonly value?: string;\n    }\n  | {\n      readonly kind: 'not' | 'is';\n      readonly selectors: readonly Selector[];\n    }\n  /** `:root`: the page's root element, the `html` above the scene. */\n  | { readonly kind: 'root' };\n\n/** A complex selector, read right to left. */\nexport interface Selector {\n  /** The compound selectors, the subject (rightmost) first. */\n  readonly compounds: readonly (readonly Simple[])[];\n  /** `combinators[i]` joins `compounds[i]` to `compounds[i + 1]`. */\n  readonly combinators: readonly ('descendant' | 'child')[];\n  /** Classes and attributes times 1000, plus types. */\n  readonly specificity: number;\n}\n\nconst CLASS = 1000;\nconst IDENT = /^-?(?:[\\w-]|\\\\[0-9a-fA-F]{1,6}\\s?|\\\\[\\s\\S]|[\\u0080-\\uffff])+/;\n\n/** An identifier with its escapes resolved. */\nconst unescaped = (ident: string) =>\n  ident.replace(/\\\\(?:([0-9a-fA-F]{1,6})\\s?|([\\s\\S]))/g, (_, hex, char) =>\n    hex ? String.fromCodePoint(parseInt(hex, 16)) : char\n  );\n\n/** Reads an attribute selector's inside, `name` or `name=\"value\"`. */\nfunction attribute(text: string): Simple | undefined {\n  const match =\n    /^\\s*([\\w-]+)\\s*(?:(~?=)\\s*(?:\"((?:[^\"\\\\]|\\\\.)*)\"|'((?:[^'\\\\]|\\\\.)*)'|(-?[\\w-]+))\\s*)?$/.exec(\n      text\n    );\n  if (!match) {\n    return undefined;\n  }\n  const [, name, operator, double, single, ident] = match;\n  return operator\n    ? {\n        kind: 'attribute',\n        name,\n        operator: operator as '=' | '~=',\n        value: unescaped(double ?? single ?? ident)\n      }\n    : { kind: 'attribute', name };\n}\n\nconst highest = (selectors: readonly Selector[]) =>\n  Math.max(0, ...selectors.map(selector => selector.specificity));\n\n/**\n * Reads one complex selector, e.g. `.ct-series-a > .ct-line`.\n * `undefined` if it uses anything this matcher doesn't support.\n */\nexport function parseSelector(text: string): Selector | undefined {\n  const compounds: Simple[][] = [];\n  const combinators: ('descendant' | 'child')[] = [];\n  let current: Simple[] = [];\n  // Whether the current compound has begun; `*` adds no simple selector.\n  let started = false;\n  let specificity = 0;\n  let pending: 'descendant' | 'child' | undefined;\n  let i = 0;\n  const source = text.trim();\n  while (i < source.length) {\n    const char = source[i];\n    if (/\\s/.test(char) || char === '>') {\n      if (!started) {\n        return undefined;\n      }\n      pending = char === '>' || pending === 'child' ? 'child' : 'descendant';\n      i++;\n      continue;\n    }\n    if (pending) {\n      compounds.push(current);\n      combinators.push(pending);\n      current = [];\n      started = false;\n      pending = undefined;\n    }\n    const rest = source.slice(i);\n    const first = !started;\n    started = true;\n    if (char === '*') {\n      if (!first) {\n        return undefined;\n      }\n      i++;\n    } else if (char === '.') {\n      const ident = IDENT.exec(rest.slice(1))?.[0];\n      if (!ident) {\n        return undefined;\n      }\n      current.push({ kind: 'class', name: unescaped(ident) });\n      specificity += CLASS;\n      i += 1 + ident.length;\n    } else if (char === '[') {\n      const close = topLevel(source, ']', i + 1);\n      const simple = attribute(source.slice(i + 1, close));\n      if (!simple || close >= source.length) {\n        return undefined;\n      }\n      current.push(simple);\n      specificity += CLASS;\n      i = close + 1;\n    } else if (/^:root(?![\\w(-])/i.test(rest)) {\n      current.push({ kind: 'root' });\n      specificity += CLASS;\n      i += 5;\n    } else if (char === ':') {\n      const name = /^:([\\w-]+)\\(/.exec(rest)?.[1].toLowerCase();\n      if (name !== 'not' && name !== 'is' && name !== 'where') {\n        return undefined;\n      }\n      const open = i + name.length + 2;\n      const close = topLevel(source, ')', open);\n      if (close >= source.length) {\n        return undefined;\n      }\n      const parts = splitTopLevel(source.slice(open, close), ',').map(\n        parseSelector\n      );\n      const selectors = parts.filter(\n        (selector): selector is Selector => selector !== undefined\n      );\n      // :not() can't tell what an unsupported selector would exclude;\n      // :is() and :where() forgive them, as in a browser.\n      if (\n        name === 'not' ? selectors.length < parts.length : !selectors.length\n      ) {\n        return undefined;\n      }\n      current.push({ kind: name === 'not' ? 'not' : 'is', selectors });\n      specificity += name === 'where' ? 0 : highest(selectors);\n      i = close + 1;\n    } else {\n      const ident = IDENT.exec(rest)?.[0];\n      if (!ident || !first) {\n        return undefined;\n      }\n      current.push({ kind: 'type', name: unescaped(ident) });\n      specificity += 1;\n      i += ident.length;\n    }\n  }\n  if (pending || !started) {\n    return undefined;\n  }\n  compounds.push(current);\n  return {\n    compounds: compounds.reverse(),\n    combinators: combinators.reverse(),\n    specificity\n  };\n}\n\nfunction matchesSimple(\n  simple: Simple,\n  path: readonly SceneNode[],\n  index: number\n): boolean {\n  const element = path[index];\n  switch (simple.kind) {\n    case 'type':\n      return element.name === simple.name;\n    case 'class':\n      return element.classes.includes(simple.name);\n    case 'attribute': {\n      const raw =\n        simple.name === 'class'\n          ? element.classes.length\n            ? element.classes.join(' ')\n            : undefined\n          : element.attrs[simple.name];\n      if (raw === undefined) {\n        return false;\n      }\n      const value = String(raw);\n      if (simple.operator === '=') {\n        return value === simple.value;\n      }\n      if (simple.operator === '~=') {\n        return value.split(/\\s+/).includes(simple.value ?? '');\n      }\n      return true;\n    }\n    case 'not':\n      return !simple.selectors.some(selector =>\n        matchesAt(selector, path, index)\n      );\n    case 'is':\n      return simple.selectors.some(selector =>\n        matchesAt(selector, path, index)\n      );\n    case 'root':\n      return index === 0;\n  }\n}\n\nfunction matchesFrom(\n  selector: Selector,\n  part: number,\n  path: readonly SceneNode[],\n  index: number\n): boolean {\n  if (!selector.compounds[part].every(s => matchesSimple(s, path, index))) {\n    return false;\n  }\n  if (part === selector.compounds.length - 1) {\n    return true;\n  }\n  if (selector.combinators[part] === 'child') {\n    return index > 0 && matchesFrom(selector, part + 1, path, index - 1);\n  }\n  for (let ancestor = index - 1; ancestor >= 0; ancestor--) {\n    if (matchesFrom(selector, part + 1, path, ancestor)) {\n      return true;\n    }\n  }\n  return false;\n}\n\n/** Whether a selector matches `path[index]`, with its ancestors before it. */\nconst matchesAt = (\n  selector: Selector,\n  path: readonly SceneNode[],\n  index: number\n) => matchesFrom(selector, 0, path, index);\n\n/**\n * Whether a selector matches the last node of `path`, a node with its\n * ancestors, the outermost first (the page's `html` in `computeStyles()`).\n */\nexport const matches = (selector: Selector, path: readonly SceneNode[]) =>\n  matchesAt(selector, path, path.length - 1);\n\n/**\n * Pseudo-elements (`::before`, and `:before`-style ones): content SVG\n * elements don't have, so their rules style nothing in a scene.\n */\nconst PSEUDO_ELEMENT = /::|:(?:before|after|first-line|first-letter)(?![\\w-])/i;\n\n/**\n * Reads a selector list, e.g. a rule's `.a, .b > .c`. Selectors it can't\n * match are left out, and reported, except pseudo-elements, which can't\n * apply to a scene at all.\n */\nexport function parseSelectorList(text: string, report?: Report): Selector[] {\n  const selectors: Selector[] = [];\n  for (const part of splitTopLevel(text, ',')) {\n    const selector = parseSelector(part);\n    if (selector) {\n      selectors.push(selector);\n    } else if (!PSEUDO_ELEMENT.test(part)) {\n      report?.('selector', part.trim());\n    }\n  }\n  return selectors;\n}\n","/**\n * Value resolution of `applyStyles()`: `var()` with fallbacks, and\n * `light-dark()` by color scheme, so a value needs no CSS support.\n */\nimport { splitTopLevel, topLevel, type ColorScheme } from './css';\n\n/** What a custom property in a cycle resolves to: invalid, fallbacks too. */\nexport const CYCLE = Symbol('cycle');\n\n/** A custom property's resolved value, `undefined` if it isn't set. */\nexport type Lookup = (name: string) => string | typeof CYCLE | undefined;\n\n/**\n * Replaces each call of a CSS function in a value, e.g. every `var(…)`.\n * `replace` gets the text between the parentheses and returns the\n * replacement, or `undefined` or `CYCLE` to make the whole value fail.\n */\nfunction replaceCalls(\n  value: string,\n  name: string,\n  replace: (args: string) => string | typeof CYCLE | undefined\n): string | typeof CYCLE | undefined {\n  const pattern = new RegExp(`(?<![\\\\w-])${name}\\\\(`, 'gi');\n  let out = '';\n  let from = 0;\n  for (;;) {\n    pattern.lastIndex = from;\n    const match = pattern.exec(value);\n    if (!match) {\n      return out + value.slice(from);\n    }\n    const open = match.index + match[0].length;\n    const close = topLevel(value, ')', open);\n    if (close >= value.length) {\n      return undefined;\n    }\n    const replaced = replace(value.slice(open, close));\n    if (typeof replaced !== 'string') {\n      return replaced;\n    }\n    out += value.slice(from, match.index) + replaced;\n    from = close + 1;\n  }\n}\n\n/**\n * The value with every `var()` replaced by the custom property's value or\n * the `var()` fallback. `undefined` if one has neither, `CYCLE` if one is\n * in a cycle.\n */\nexport function substitute(\n  value: string,\n  lookup: Lookup\n): string | typeof CYCLE | undefined {\n  return replaceCalls(value, 'var', args => {\n    const comma = topLevel(args, ',');\n    const name = args.slice(0, comma).trim();\n    const found = lookup(name);\n    if (found !== undefined) {\n      return found;\n    }\n    return comma < args.length\n      ? substitute(args.slice(comma + 1).trim(), lookup)\n      : undefined;\n  });\n}\n\n/**\n * The value with every `light-dark(light, dark)` replaced by the value\n * for the scheme. `undefined` if one doesn't have two values.\n */\nexport function lightDark(\n  value: string,\n  scheme: ColorScheme\n): string | undefined {\n  const resolved = replaceCalls(value, 'light-dark', args => {\n    const parts = splitTopLevel(args, ',');\n    if (parts.length !== 2) {\n      return undefined;\n    }\n    return lightDark(parts[scheme === 'light' ? 0 : 1].trim(), scheme);\n  });\n  return typeof resolved === 'string' ? resolved : undefined;\n}\n","/**\n * The cascade of `computeStyles()`: which declaration wins per element and\n * property, and the computed custom properties each element inherits.\n */\nimport type { SceneNode } from '../index';\nimport {\n  readDeclarations,\n  readStylesheet,\n  type ColorScheme,\n  type Declaration,\n  type Report\n} from './css';\nimport { isPresentation } from './presentation';\nimport { matches, parseSelectorList, type Selector } from './selectors';\nimport { CYCLE, lightDark, substitute } from './values';\n\ninterface Rule {\n  readonly selectors: readonly Selector[];\n  readonly declarations: readonly Declaration[];\n  /** The rule's place across all stylesheets. */\n  readonly order: number;\n}\n\n/** Room for the declarations of one rule in the order of candidates. */\nconst PER_RULE = 1e4;\n\n/** A declaration that applies to an element, with what ranks it. */\ninterface Candidate extends Declaration {\n  /** The declaration as read, the same for every element it applies to. */\n  readonly source: Declaration;\n  /** From the element's own `style` attribute. */\n  readonly inline: boolean;\n  readonly specificity: number;\n  readonly order: number;\n}\n\n/** `!important` first, then the `style` attribute, specificity, order. */\nconst wins = (a: Candidate, b: Candidate) =>\n  a.important !== b.important\n    ? a.important\n    : a.inline !== b.inline\n      ? a.inline\n      : a.specificity !== b.specificity\n        ? a.specificity > b.specificity\n        : a.order > b.order;\n\n/** The style rules of the stylesheets, in order, with parsed selectors. */\nexport function readRules(\n  sheets: readonly string[],\n  scheme: ColorScheme,\n  report?: Report\n): Rule[] {\n  return sheets\n    .flatMap(css => readStylesheet(css, scheme, report))\n    .map((rule, order) => {\n      for (const { property, value } of rule.declarations) {\n        // Not expanded into its longhands, which are presentation properties.\n        if (property === 'font') {\n          report?.('shorthand', `${property}: ${value}`);\n        }\n      }\n      return {\n        selectors: parseSelectorList(rule.selectors, report),\n        declarations: rule.declarations,\n        order\n      };\n    })\n    .filter(rule => rule.selectors.length && rule.declarations.length);\n}\n\n/** The winning declaration per property for the last node of `path`. */\nfunction cascade(\n  rules: readonly Rule[],\n  path: readonly SceneNode[],\n  style: readonly Declaration[]\n): Map<string, Candidate> {\n  const winners = new Map<string, Candidate>();\n  const offer = (candidate: Candidate) => {\n    const current = winners.get(candidate.property);\n    if (!current || wins(candidate, current)) {\n      winners.set(candidate.property, candidate);\n    }\n  };\n  for (const rule of rules) {\n    const matching = rule.selectors.filter(selector => matches(selector, path));\n    if (matching.length) {\n      const specificity = Math.max(...matching.map(s => s.specificity));\n      rule.declarations.forEach((declaration, index) =>\n        offer({\n          ...declaration,\n          source: declaration,\n          inline: false,\n          specificity,\n          order: rule.order * PER_RULE + index\n        })\n      );\n    }\n  }\n  style.forEach((declaration, index) =>\n    offer({\n      ...declaration,\n      source: declaration,\n      inline: true,\n      specificity: 0,\n      order: index\n    })\n  );\n  return winners;\n}\n\n/**\n * The element's custom properties: the inherited ones, overridden by the\n * ones it declares, resolved. A property in a cycle, or with a `var()` that\n * can't be resolved, isn't set, as in a browser.\n */\nfunction customProperties(\n  winners: ReadonlyMap<string, Candidate>,\n  inherited: ReadonlyMap<string, string>\n): Map<string, string> {\n  const own = new Map(\n    [...winners].filter(([property]) => property.startsWith('--'))\n  );\n  if (!own.size) {\n    return new Map(inherited);\n  }\n  const resolved = new Map<string, string | typeof CYCLE | undefined>();\n  const resolving = new Set<string>();\n  const lookup = (name: string): string | typeof CYCLE | undefined => {\n    const declared = own.get(name);\n    if (!declared) {\n      return inherited.get(name);\n    }\n    if (resolved.has(name)) {\n      return resolved.get(name);\n    }\n    if (resolving.has(name)) {\n      return CYCLE;\n    }\n    resolving.add(name);\n    const value = substitute(declared.value, lookup);\n    resolving.delete(name);\n    resolved.set(name, value);\n    return value;\n  };\n  const computed = new Map(inherited);\n  for (const name of own.keys()) {\n    const value = lookup(name);\n    if (typeof value === 'string') {\n      computed.set(name, value);\n    } else {\n      computed.delete(name);\n    }\n  }\n  return computed;\n}\n\n/** A property's value without `var()` and `light-dark()`, if it resolves. */\nfunction resolve(\n  value: string,\n  custom: ReadonlyMap<string, string>,\n  scheme: ColorScheme\n): string | undefined {\n  const substituted = substitute(value, name => custom.get(name));\n  const plain =\n    typeof substituted === 'string'\n      ? lightDark(substituted, scheme)?.trim()\n      : undefined;\n  return plain && !/(?<![\\w-])(?:var|light-dark)\\(/i.test(plain)\n    ? plain\n    : undefined;\n}\n\n/**\n * Properties that inherit: the ones the page's `html` and `body` pass on\n * to the scene's root.\n */\nconst INHERITED = /* @__PURE__ */ new Set([\n  'color',\n  'cursor',\n  'direction',\n  'dominant-baseline',\n  'fill',\n  'fill-opacity',\n  'fill-rule',\n  'font-family',\n  'font-size',\n  'font-size-adjust',\n  'font-stretch',\n  'font-style',\n  'font-variant',\n  'font-weight',\n  'letter-spacing',\n  'paint-order',\n  'pointer-events',\n  'shape-rendering',\n  'stroke',\n  'stroke-dasharray',\n  'stroke-dashoffset',\n  'stroke-linecap',\n  'stroke-linejoin',\n  'stroke-miterlimit',\n  'stroke-opacity',\n  'stroke-width',\n  'text-anchor',\n  'text-rendering',\n  'visibility',\n  'word-spacing',\n  'writing-mode'\n]);\n\n/** The values of the presentation properties an element gets. */\nexport type Values = Readonly<Record<string, string>>;\n\n/**\n * The presentation values of every SVG element of the scene, matched below\n * a page's `html` and `body`: their custom properties are inherited, and\n * their inherited properties reach the root. Elements inside a\n * `foreignObject` get none.\n */\nexport function computeValues(\n  scene: SceneNode,\n  rules: readonly Rule[],\n  scheme: ColorScheme,\n  report?: Report\n): WeakMap<SceneNode, Values> {\n  const out = new WeakMap<SceneNode, Values>();\n  const reported = new Set<Declaration>();\n  const valueOf = (\n    candidate: Candidate,\n    custom: ReadonlyMap<string, string>\n  ) => {\n    const value = resolve(candidate.value, custom, scheme);\n    // Once per declaration, not per element it applies to.\n    if (value === undefined && report && !reported.has(candidate.source)) {\n      reported.add(candidate.source);\n      report('value', `${candidate.property}: ${candidate.value}`);\n    }\n    return value;\n  };\n\n  // The page around the scene.\n  const page: SceneNode[] = [];\n  const passed = new Map<string, string>();\n  let custom = new Map<string, string>();\n  // Only matched, never rendered: what selectors read of an element.\n  const element = (name: string) =>\n    ({ name, attrs: {}, classes: [], children: [] }) as unknown as SceneNode;\n  for (const pageElement of [element('html'), element('body')]) {\n    page.push(pageElement);\n    const winners = cascade(rules, page, []);\n    custom = customProperties(winners, custom);\n    for (const [property, winner] of winners) {\n      if (INHERITED.has(property)) {\n        const value = valueOf(winner, custom);\n        if (value !== undefined) {\n          passed.set(property, value);\n        }\n      }\n    }\n  }\n\n  const walk = (\n    current: SceneNode,\n    ancestors: readonly SceneNode[],\n    inherited: ReadonlyMap<string, string>\n  ) => {\n    const path = [...ancestors, current];\n    const style =\n      current.attrs.style === undefined\n        ? []\n        : readDeclarations(String(current.attrs.style));\n    const winners = cascade(rules, path, style);\n    const own = customProperties(winners, inherited);\n    const values: Record<string, string> = {};\n    for (const [property, winner] of winners) {\n      if (isPresentation(property)) {\n        const value = valueOf(winner, own);\n        if (value !== undefined) {\n          values[property] = value;\n        }\n      }\n    }\n    if (current === scene) {\n      for (const [property, value] of passed) {\n        values[property] ??= value;\n      }\n    }\n    if (Object.keys(values).length) {\n      out.set(current, values);\n    }\n    if (current.name !== 'foreignObject') {\n      current.children.forEach(child => walk(child, path, own));\n    }\n  };\n  walk(scene, page, custom);\n  return out;\n}\n","import type { AttrValue, SceneNode } from '../index';\nimport { computeValues, readRules } from './cascade';\nimport { readDeclarations, type SkipReason } from './css';\nimport { isPresentation } from './presentation';\n\n/**\n * The styles of a scene's elements: for a scene node, the values of the CSS\n * properties it gets (property to value, e.g. `{ stroke: '#d70206' }`), or\n * nothing. {@link computeStyles} makes one with Chartist's own CSS engine;\n * another engine can make one too, for {@link applyStyles}.\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n */\nexport type ComputedStyles = (\n  node: SceneNode\n) => Readonly<Record<string, string>> | undefined;\n\n/**\n * A part of a stylesheet that {@link computeStyles} left out, as `onSkip`\n * gets it: its text and why. `at-rule` for an at-rule other than\n * `@media (prefers-color-scheme)`, `@supports` and `@layer`; `selector` for\n * a selector it can't match; `nested` for a nested rule; `shorthand` for\n * `font`; `value` for a declaration whose value doesn't resolve on an\n * element (a `var()` without a value or fallback there).\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n */\nexport interface SkippedStyle {\n  /** The part as written: an at-rule's prelude, a selector, a declaration. */\n  readonly text: string;\n  /** Why it was left out. */\n  readonly reason: SkipReason;\n}\n\n/**\n * Options of {@link computeStyles}.\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n */\nexport interface ComputeStylesOptions {\n  /**\n   * The color scheme to style for: which value of `light-dark()` and which\n   * `@media (prefers-color-scheme)` rules apply.\n   */\n  readonly colorScheme?: 'light' | 'dark';\n  /**\n   * Called once for each part of the stylesheets that was left out, so a\n   * rule that doesn't apply says why. Rules for the other color scheme\n   * and pseudo-elements (`::before`), which style nothing in SVG, aren't\n   * reported.\n   */\n  readonly onSkip?: (skipped: SkippedStyle) => void;\n}\n\n/**\n * Options of {@link applyStyles} when it gets CSS: those of\n * {@link computeStyles}.\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n */\nexport type ApplyStylesOptions = ComputeStylesOptions;\n\n/**\n * Computes the styles a scene's SVG elements get from CSS, with Chartist's\n * own CSS engine: a small one, made for chart styles. Pass the result to\n * {@link applyStyles}.\n *\n * It matches rules as a browser does, per element, with the scene below a\n * page's `html` and `body` (so `:root`, `html` and `body` rules apply, and\n * their custom properties reach the chart): type, class and attribute\n * selectors, `:root`, `:not()`, `:is()` and `:where()`, and the descendant\n * and child combinators, ranked by `!important`, the element's own `style`,\n * specificity and order. Custom properties are resolved per element, and\n * `light-dark()` by `colorScheme`. Rules in `@media (prefers-color-scheme)`\n * apply for their scheme, and `@supports` and `@layer` blocks are read in\n * place.\n *\n * What it doesn't support it leaves out, and reports to `onSkip`: other\n * at-rules, sibling and structural selectors (`+`, `~`, `:nth-child()`),\n * ids and other pseudo-classes, nested rules and the `font` shorthand.\n * `calc()` and relative units such as `rem` are passed on as written. For\n * full CSS, compute the styles with a browser and pass those to\n * `applyStyles()`. Only the values of properties SVG has presentation\n * attributes for are computed; elements inside a `foreignObject` (HTML\n * labels) get none.\n *\n * Pass only stylesheets your application controls: CSS values, `url()`\n * included, end up in the markup.\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n * @param scene A scene, usually from `toScene()`\n * @param css A stylesheet's text, or several, applied in order as if the\n *   later ones came later in the page\n * @param options The color scheme (`light` by default), and `onSkip`\n * @returns The values each node gets\n * @example\n * ```ts\n * import { lineChartConfig } from 'chartist';\n * import { applyStyles, computeStyles, toScene } from 'chartist/server';\n *\n * const css = '.ct-line { stroke: teal; } .ct-series:nth-child(2) { stroke: red; }';\n * const scene = toScene(lineChartConfig({ series: [[5, 2, 4]] }), {\n *   width: 600,\n *   height: 300\n * });\n *\n * const styles = computeStyles(scene, css, {\n *   // `.ct-series:nth-child(2)`: selector\n *   onSkip: ({ text, reason }) => console.warn(`${text}: ${reason}`)\n * });\n * export const styled = applyStyles(scene, styles);\n * ```\n */\nexport function computeStyles(\n  scene: SceneNode,\n  css: string | readonly string[],\n  options: ComputeStylesOptions = {}\n): ComputedStyles {\n  const scheme = options.colorScheme ?? 'light';\n  const { onSkip } = options;\n  const report =\n    onSkip &&\n    ((reason: SkipReason, text: string) => {\n      onSkip({ text, reason });\n    });\n  const sheets = typeof css === 'string' ? [css] : css;\n  const values = computeValues(\n    scene,\n    readRules(sheets, scheme, report),\n    scheme,\n    report\n  );\n  return current => values.get(current);\n}\n\n/** The node with its styles as attributes, and its children the same. */\nfunction written(current: SceneNode, styles: ComputedStyles): SceneNode {\n  const style =\n    current.attrs.style === undefined\n      ? []\n      : readDeclarations(String(current.attrs.style));\n  const attrs: Record<string, AttrValue | undefined> = {};\n  // Declarations of the `style` attribute with another value than `styles`.\n  const replaced = new Set<string>();\n  for (const [property, value] of Object.entries(styles(current) ?? {})) {\n    if (!isPresentation(property)) {\n      continue;\n    }\n    const inline = style.findLast(\n      declaration => declaration.property === property\n    );\n    if (inline?.value === value) {\n      continue;\n    }\n    attrs[property] = value;\n    if (inline) {\n      replaced.add(property);\n    }\n  }\n  if (replaced.size) {\n    const kept = style.filter(\n      declaration => !replaced.has(declaration.property)\n    );\n    attrs.style = kept.length\n      ? kept\n          .map(\n            ({ property, value, important }) =>\n              `${property}: ${value}${important ? ' !important' : ''};`\n          )\n          .join(' ')\n      : undefined;\n  }\n  let next = Object.keys(attrs).length ? current.attr(attrs) : current;\n\n  if (current.name !== 'foreignObject' && current.children.length) {\n    const children = current.children.map(child => written(child, styles));\n    if (children.some((child, index) => child !== current.children[index])) {\n      next = children.reduce(\n        (parent, child) => parent.append(child),\n        next.empty()\n      );\n      if (current.content !== undefined) {\n        next = next.text(current.content);\n      }\n    }\n  }\n  return next;\n}\n\n/**\n * Writes styles into a scene as SVG presentation attributes, so its markup\n * draws the same in tools that read SVG on its own: rasterizers that make\n * PNGs, PDF libraries, email. Every SVG element gets its values as\n * attributes such as `stroke=\"#d70206\"`; values of properties SVG has no\n * attribute for are left out. Its classes stay, so a page can still style\n * the markup, and elements inside a `foreignObject` (HTML labels) are left\n * as they are: use SVG labels for images.\n *\n * Give it CSS, which {@link computeStyles} computes with Chartist's own,\n * small CSS engine, or the styles another engine computed, such as a\n * headless browser's `getComputedStyle()` for each element.\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n * @param scene A scene, usually from `toScene()`; it isn't changed\n * @param styles The values per node from {@link computeStyles} or another\n *   engine, or the CSS for `computeStyles()`: a stylesheet's text or\n *   several, applied in order\n * @param options With CSS: the options of `computeStyles()`\n * @returns A copy of the scene with the styles as attributes\n * @example\n * ```ts\n * import { readFileSync } from 'node:fs';\n * import { createRequire } from 'node:module';\n * import { lineChartConfig } from 'chartist';\n * import { applyStyles, renderToString, toScene } from 'chartist/server';\n *\n * const css = readFileSync(\n *   createRequire(import.meta.url).resolve('chartist/styles.css'),\n *   'utf8'\n * );\n * const scene = toScene(\n *   lineChartConfig({ labels: ['Mon', 'Tue', 'Wed'], series: [[5, 2, 4]] }),\n *   { width: 600, height: 300 }\n * );\n *\n * // SVG for a rasterizer: the colors and widths as attributes.\n * export const svg = renderToString(applyStyles(scene, css));\n * ```\n */\nexport function applyStyles(\n  scene: SceneNode,\n  styles: ComputedStyles | string | readonly string[],\n  options: ApplyStylesOptions = {}\n): SceneNode {\n  return written(\n    scene,\n    typeof styles === 'function'\n      ? styles\n      : computeStyles(scene, styles, options)\n  );\n}\n","import { escapingMap, namespaces, type SceneNode } from '../index';\n\nconst escape = (value: string | number) =>\n  String(value).replace(/[&<>\"']/g, char => escapingMap[char]);\n\n// The XML Name production, which the DOM checks in createElementNS and\n// setAttribute. Names can't be escaped, so an invalid one throws there and\n// here, instead of writing markup that a plugin built from data.\nconst nameStart =\n  'A-Z_:a-z\\\\u00C0-\\\\u00D6\\\\u00D8-\\\\u00F6\\\\u00F8-\\\\u02FF\\\\u0370-\\\\u037D' +\n  '\\\\u037F-\\\\u1FFF\\\\u200C\\\\u200D\\\\u2070-\\\\u218F\\\\u2C00-\\\\u2FEF' +\n  '\\\\u3001-\\\\uD7FF\\\\uF900-\\\\uFDCF\\\\uFDF0-\\\\uFFFD';\nconst xmlName = new RegExp(\n  `^[${nameStart}][${nameStart}\\\\-.0-9\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F\\\\u2040]*$`\n);\n\nfunction checked(name: string, kind: 'element' | 'attribute') {\n  if (!xmlName.test(name)) {\n    throw new Error(`Chartist: \"${name}\" is not a valid ${kind} name`);\n  }\n  return name;\n}\n\ntype Position = 'root' | 'html-root' | 'other';\n\nfunction attributes(current: SceneNode, position: Position) {\n  const parts: string[] = [];\n  if (position === 'root') {\n    parts.push(`xmlns=\"${namespaces.svg}\"`, `xmlns:ct=\"${namespaces.ct}\"`);\n  } else if (position === 'html-root') {\n    // HTML inside a foreignObject; any other xmlns value is replaced.\n    parts.push(`xmlns=\"${namespaces.xhtml}\"`);\n  }\n  if (current.classes.length) {\n    parts.push(`class=\"${escape(current.classes.join(' '))}\"`);\n  }\n  for (const [name, value] of Object.entries(current.attrs)) {\n    if (name !== 'xmlns') {\n      parts.push(`${checked(name, 'attribute')}=\"${escape(value)}\"`);\n    }\n  }\n  return parts.length ? ` ${parts.join(' ')}` : '';\n}\n\nfunction serialize(\n  current: SceneNode,\n  position: Position,\n  html = false\n): string {\n  const open = `<${checked(current.name, 'element')}${attributes(current, position)}`;\n  const inner = html || current.name === 'foreignObject';\n  const childPosition: Position =\n    current.name === 'foreignObject' ? 'html-root' : 'other';\n  const content =\n    (current.content === undefined ? '' : escape(current.content)) +\n    current.children\n      .map(child => serialize(child, childPosition, inner))\n      .join('');\n  // The HTML parser ignores `/>` on HTML elements, so an empty one (a\n  // label) would stay open and take in what follows: close them all.\n  return content || html ? `${open}>${content}</${current.name}>` : `${open}/>`;\n}\n\n/**\n * Serializes a scene to standalone SVG markup. Needs no DOM, so it works in\n * Node.js and in server bundles.\n *\n * The root gets the SVG and `ct:` namespaces, and attribute values and\n * text are escaped. The markup has the chart's classes but no styles: load\n * `chartist/styles.css` where it's shown, or add a `style` element to the\n * scene.\n *\n * @experimental New in `chartist/server` with 2.1: the server API may still\n *   change in a 2.x minor before it becomes stable.\n * @param scene A scene, usually from `toScene()`\n * @returns The SVG markup, e.g. `<svg xmlns=\"…\" …>…</svg>`\n * @example\n * ```ts\n * import { lineChartConfig } from 'chartist';\n * import { renderToString, toScene } from 'chartist/server';\n *\n * export function weekChart(values: number[]): string {\n *   const scene = toScene(\n *     lineChartConfig({\n *       labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n *       series: [values]\n *     }),\n *     { width: 600, height: 300 }\n *   );\n *   return renderToString(scene);\n * }\n * ```\n */\nexport function renderToString(scene: SceneNode): string {\n  return serialize(scene, 'root');\n}\n","import {\n  toScene,\n  type AttrValue,\n  type ChartConfig,\n  type LabelMode,\n  type SceneNode,\n  type SceneSize\n} from '../index';\nimport { isPresentation } from './presentation';\nimport { renderToString } from './string';\n\n/**\n * The root attribute the browser reads the layout from. `chart()` (which\n * removes it) and `liveDomRenderer()` (which reads it) name it in the core;\n * the hydration tests fail if the names drift apart.\n */\nconst MARKER = 'data-ct-hydrate';\n\n/** What the root records for the browser to build the same scene again. */\ninterface HydrationMarker {\n  /** The marker's version; others aren't taken over. */\n  readonly v: 1;\n  /** The layout size in px. */\n  readonly width: number;\n  readonly height: number;\n  /** The label mode the scene was laid out with. */\n  readonly labels: LabelMode;\n  /** `estimate` for the built-in estimate, `custom` for a `measureText`. */\n  readonly text: 'estimate' | 'custom';\n  /** Whether the root got a `viewBox` that only scales until hydration. */\n  readonly scale: boolean;\n}\n\n/**\n * The declarations of a style that an SVG element can carry as presentation\n * attributes; px lengths become user units.\n */\nfunction presentationAttributes(style: string): Record<string, AttrValue> {\n  const attrs: Record<string, AttrValue> = {};\n  for (const declaration of style.split(';')) {\n    const separator = declaration.indexOf(':');\n    const name = declaration.slice(0, separator).trim().toLowerCase();\n    const value = declaration.slice(separator + 1).trim();\n    if (separator > 0 && isPresentation(name) && !/!important/i.test(value)) {\n      attrs[name] = value.replace(/^(-?(?:\\d+\\.?\\d*|\\.\\d+))px$/, '$1');\n    }\n  }\n  return attrs;\n}\n\n/**\n * The scene without `style` attributes: on SVG elements, declarations SVG\n * has presentation attributes for become those; the rest, and the styles of\n * HTML elements, come from the stylesheet and the root's size attributes,\n * or are applied when the browser takes the markup over.\n */\nfunction withoutStyles(current: SceneNode, html: boolean): SceneNode {\n  const style = current.attrs.style;\n  const inner = html || current.name === 'foreignObject';\n  const children = current.children.map(child => withoutStyles(child, inner));\n  const changed = children.some(\n    (child, index) => child !== current.children[index]\n  );\n  let next =\n    style === undefined\n      ? current\n      : current.attr({\n          style: undefined,\n          ...(html ? {} : presentationAttributes(String(style)))\n        });\n  if (changed) {\n    next = children.reduce(\n      (parent, child) => parent.append(child),\n      next.empty()\n    );\n    if (current.content !== undefined) {\n      next = next.text(current.content);\n    }\n  }\n  return next;\n}\n\n/**\n * Renders a chart to markup that `chart()` and the presets take over in the\n * browser (hydration), instead of drawing a new chart. Needs no DOM, so it\n * works in Node.js and in server bundles; put the markup into the chart's\n * container once, and create the chart there with `liveDomRenderer()` from\n * `chartist/live` as its renderer, which keeps the server's elements.\n *\n * It lays the chart out as {@link toScene} does, at the given size. The root\n * gets the size `chart()` gives it (`100%` unless the config sets one) and,\n * unless the config sets a `viewBox`, a `viewBox` of the layout size, so\n * the drawing scales into its container until the browser lays it out at\n * the real size. Its `data-ct-hydrate` attribute records what the browser\n * needs to build the same scene again: the size, the label mode, whether\n * text was estimated and whether the `viewBox` only scales. Labels are HTML\n * unless `size.labels` or the config says otherwise, as `chart()` draws them.\n *\n * The markup has no `style` attributes, so it passes a Content Security\n * Policy of `style-src 'self'`, and it needs Chartist's stylesheet in the\n * page. Styles that SVG has attributes for (a label's `overflow`, a donut's\n * `stroke-width`) are written as those; the others, such as styles a `scene`\n * listener adds, are applied when the browser takes the markup over. For a\n * self-contained SVG image, with its styles inline (files, email, a static\n * chart), use `toScene()` and {@link renderToString} instead.\n *\n * @experimental New with 2.1: the server API may still change in a 2.x\n *   minor before it becomes stable.\n * @param config The chart, as the browser creates it: data, axes, layers,\n *   plugins and listeners\n * @param size The size to lay out at, in px, and how to measure text; use\n *   the estimate (no `measureText`), which the browser replays\n * @returns The SVG markup, its root marked with `data-ct-hydrate`\n * @example\n * ```ts\n * import { lineChartConfig } from 'chartist';\n * import { renderForHydration } from 'chartist/server';\n *\n * const data = {\n *   labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],\n *   series: [[12, 9, 7, 8, 5]]\n * };\n *\n * // On the server, in the chart's container:\n * export const markup = renderForHydration(lineChartConfig(data), {\n *   width: 600,\n *   height: 300\n * });\n *\n * // In the browser, the chart keeps the server's elements:\n * // lineChart('#chart', data, { renderer: liveDomRenderer() });\n * ```\n */\nexport function renderForHydration(\n  config: ChartConfig,\n  size: SceneSize\n): string {\n  const labels = size.labels ?? 'html';\n  const marker: HydrationMarker = {\n    v: 1,\n    width: size.width,\n    height: size.height,\n    labels,\n    text: size.measureText ? 'custom' : 'estimate',\n    scale: !config.viewBox\n  };\n  const scene = toScene(config, { ...size, labels });\n  return renderToString(\n    withoutStyles(scene, false).attr({\n      // The root size chart() draws, so both sides draw the same root.\n      width: config.width ?? '100%',\n      height: config.height ?? '100%',\n      ...(marker.scale\n        ? { viewBox: `0 0 ${marker.width} ${marker.height}` }\n        : {}),\n      [MARKER]: JSON.stringify(marker)\n    })\n  );\n}\n"],"mappings":";;;;AA2CA,SAAS,UAAU,MAAc,OAAuB;CACtD,MAAM,QAAQ,KAAK;CACnB,IAAI,IAAI,QAAQ;CAChB,OAAO,IAAI,KAAK,UAAU,KAAK,OAAO,SAAS,KAAK,OAAO,MACzD,KAAK,KAAK,OAAO,OAAO,IAAI;CAE9B,OAAO,KAAK,OAAO,QAAQ,IAAI,IAAI;AACrC;;AAGA,SAAgB,gBAAgB,MAAsB;CACpD,IAAI,MAAM;CACV,IAAI,IAAI;CACR,OAAO,IAAI,KAAK,QAAQ;EACtB,MAAM,OAAO,KAAK;EAClB,IAAI,SAAS,QAAO,SAAS,KAAK;GAChC,MAAM,MAAM,UAAU,MAAM,CAAC;GAC7B,OAAO,KAAK,MAAM,GAAG,GAAG;GACxB,IAAI;EACN,OAAO,IAAI,SAAS,OAAO,KAAK,IAAI,OAAO,KAAK;GAC9C,MAAM,MAAM,KAAK,QAAQ,MAAM,IAAI,CAAC;GACpC,IAAI,MAAM,IAAI,KAAK,SAAS,MAAM;GAClC,OAAO;EACT,OAAO;GACL,OAAO;GACP;EACF;CACF;CACA,OAAO;AACT;;;;;AAMA,SAAgB,SACd,MACA,OACA,QAAQ,GACR,MAAM,KAAK,QACH;CACR,IAAI,QAAQ;CACZ,IAAI,IAAI;CACR,OAAO,IAAI,KAAK;EACd,MAAM,OAAO,KAAK;EAClB,IAAI,SAAS,QAAO,SAAS,KAAK;GAChC,IAAI,UAAU,MAAM,CAAC;GACrB;EACF;EACA,IAAI,SAAS,MAAM;GACjB,KAAK;GACL;EACF;EACA,IAAI,UAAU,KAAK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