{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bar-chart",
  "type": "registry:ui",
  "title": "Bar Chart",
  "description": "Bar Chart compares categories with vertical or horizontal bars — a single series by default, or several series grouped, stacked, or stacked to 100%. Static and non-tabbable, with the data also exposed as a hidden table.",
  "author": "Skrewww",
  "dependencies": [
    "recharts"
  ],
  "registryDependencies": [
    "@skrewww/foundation"
  ],
  "docs": "Host requirements (assumed already present, not installed by this command): react, react-dom.",
  "files": [
    {
      "path": "components/ui/BarChart.tsx",
      "content": "/** @skrewww-component bar-chart */\n\"use client\";\n\nimport { Bar, BarChart as RechartsBarChart } from \"recharts\";\nimport { ChartFrame } from \"@/components/ui/internal/ChartFrame\";\nimport { cartesianParts } from \"@/components/ui/internal/cartesian-parts\";\nimport {\n  buildChartTable,\n  hasNegativeValue,\n  resolveChartSeries,\n  toPlotData,\n  type ChartDatum,\n  type ChartRow,\n  type ChartSeries,\n} from \"@/components/ui/internal/chart-data\";\nimport type { ChartLabelFormat, ChartValueFormat } from \"@/components/ui/internal/chart-format\";\n\nexport type { ChartRow, ChartSeries, ChartSeriesColor } from \"@/components/ui/internal/chart-data\";\nexport type { ChartLabelFormat, ChartValueFormat } from \"@/components/ui/internal/chart-format\";\n\nexport type BarChartDatum = ChartDatum;\n\nexport type BarChartProps = {\n  /**\n   * One row per category: `{ label, value }` for a single series, or `{ label, [series.key]: number | null }`\n   * with `series` for several. `null` means \"no data\" and draws no bar.\n   */\n  data: ChartRow[];\n  /** Accessible name for the chart — also used as the hidden data table's caption. */\n  label: string;\n  /** Fixed pixel height — width is fluid, filling the parent container. */\n  height?: number;\n  /** Series definitions. Omit for a single series read from each row's `value`. */\n  series?: ChartSeries[];\n  /** \"vertical\" draws columns (default); \"horizontal\" draws bars growing left to right. */\n  orientation?: \"vertical\" | \"horizontal\";\n  /** \"none\" groups series side by side (default); \"stacked\" stacks them; \"percent\" stacks to 100% of each category. */\n  stacking?: \"none\" | \"stacked\" | \"percent\";\n  /** Show a legend. Defaults to true when there is more than one series. */\n  legend?: boolean;\n  /** Show a hover/touch tooltip. Defaults to false. */\n  tooltip?: boolean;\n  /** Show the category axis labels. Defaults to true. */\n  showCategoryAxis?: boolean;\n  /** Show the value axis ticks. Defaults to false. */\n  showValueAxis?: boolean;\n  /** Show grid lines. Defaults to false. */\n  showGrid?: boolean;\n  /** Format for value-axis ticks, the tooltip and the hidden table. Default: the raw number. */\n  valueFormat?: ChartValueFormat;\n  /** Format for category labels (axis, tooltip, hidden table). Default: the label as given. */\n  labelFormat?: ChartLabelFormat;\n  className?: string;\n};\n\n/**\n * Built against Figma's \"Bar Chart (example)\" (Content/Charts): a single\n * semantic/action/primary fill, real proportional bar heights, category labels\n * below in semantic/text/secondary. With no extra props the output is that\n * static single-series chart — no value axis, grid, legend or tooltip. Multi-series,\n * horizontal, stacked and 100% stacked modes, the value axis, grid, legend and\n * tooltip are CH-2 additions with no Figma reference (see registry openQuestions).\n *\n * The accessible wrapper, hidden data table, legend and ResponsiveContainer live\n * in the shared `ChartFrame`; axes, grid and tooltip come from `cartesianParts`.\n * Colors are the frame-owned `--chart-series-*` custom properties.\n */\nexport function BarChart({\n  data,\n  label,\n  height = 240,\n  series,\n  orientation = \"vertical\",\n  stacking = \"none\",\n  legend,\n  tooltip = false,\n  showCategoryAxis = true,\n  showValueAxis = false,\n  showGrid = false,\n  valueFormat,\n  labelFormat,\n  className,\n}: BarChartProps) {\n  const resolved = resolveChartSeries(series);\n  const plotData = toPlotData(data, resolved);\n  const showLegend = legend ?? resolved.length > 1;\n\n  return (\n    <ChartFrame\n      label={label}\n      height={height}\n      table={buildChartTable(plotData, resolved, { valueFormat, labelFormat })}\n      legend={showLegend ? resolved.map((entry) => ({ label: entry.label, colorVar: entry.colorVar, marker: \"square\" as const })) : undefined}\n      className={className}\n    >\n      <RechartsBarChart\n        data={plotData}\n        layout={orientation === \"horizontal\" ? \"vertical\" : \"horizontal\"}\n        stackOffset={stacking === \"percent\" ? \"expand\" : stacking === \"stacked\" ? \"sign\" : \"none\"}\n      >\n        {cartesianParts({\n          layout: orientation === \"horizontal\" ? \"vertical\" : \"horizontal\",\n          series: resolved,\n          showCategoryAxis,\n          showValueAxis,\n          showGrid,\n          tooltip,\n          baseline: hasNegativeValue(plotData, resolved),\n          percent: stacking === \"percent\",\n          valueFormat,\n          labelFormat,\n          cursor: \"band\",\n        })}\n        {resolved.map((entry) => (\n          <Bar\n            key={entry.key}\n            dataKey={entry.key}\n            fill={entry.colorVar}\n            stackId={stacking === \"none\" ? undefined : \"stack\"}\n            isAnimationActive={false}\n          />\n        ))}\n      </RechartsBarChart>\n    </ChartFrame>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/BarChart.tsx"
    },
    {
      "path": "lib/cn.ts",
      "content": "export function cn(...classes: Array<string | false | null | undefined>): string {\n  return classes.filter(Boolean).join(\" \");\n}\n",
      "type": "registry:lib",
      "target": "~/lib/cn.ts"
    },
    {
      "path": "components/ui/internal/ChartFrame.tsx",
      "content": "\"use client\";\n\nimport { cloneElement, useId, type ReactElement } from \"react\";\nimport { ResponsiveContainer } from \"recharts\";\nimport { cn } from \"@/lib/cn\";\nimport type { ChartTable } from \"@/components/ui/internal/chart-data\";\nimport { ChartLegend, type ChartLegendItem } from \"@/components/ui/internal/ChartLegend\";\nimport styles from \"@/components/ui/internal/chart.module.css\";\n\nexport type ChartFrameProps = {\n  /** Accessible name for the chart — also the hidden data table's caption. */\n  label: string;\n  /** Fixed pixel height — width is fluid, filling the parent container. */\n  height: number;\n  /** Data exposed to assistive technology as a visually-hidden table. */\n  table: ChartTable;\n  /** Optional non-interactive legend rendered under the visual. */\n  legend?: readonly ChartLegendItem[];\n  className?: string;\n  /** Exactly one Recharts chart element (e.g. `<BarChart>`). */\n  children: ReactElement<{ accessibilityLayer?: boolean }>;\n};\n\n/**\n * Shared static-visualization shell for Skrewww charts (CH-1, extended in CH-2).\n *\n * Accessibility model (static charts): the wrapper is `role=\"img\"` with the\n * chart's accessible name, described by a visually-hidden data table that stays\n * exposed to assistive technology — one column per series, so series are\n * identified by name, never by color alone. The visual (plot, legend, tooltip)\n * is `aria-hidden` and must never contain a keyboard stop. Recharts 3 enables an\n * `accessibilityLayer` by default, which makes the `<svg>` `tabindex=\"0\"` with\n * `role=\"application\"` — a focusable element hidden from assistive tech. The\n * frame therefore forces `accessibilityLayer={false}` on the chart element it\n * renders, so a family chart cannot reintroduce the focus stop by omission.\n * Interactive/keyboard chart models are out of scope until a later phase.\n *\n * The frame also owns the chart-scoped custom properties (chart.module.css), so\n * they ship with every chart. Table rows are keyed by index: labels are display\n * text and are not guaranteed unique, so they must not be identity.\n */\nexport function ChartFrame({ label, height, table, legend, className, children }: ChartFrameProps) {\n  const tableId = useId();\n\n  return (\n    <div className={cn(styles.root, className)}>\n      <div role=\"img\" aria-label={label} aria-describedby={tableId}>\n        <div aria-hidden=\"true\">\n          <ResponsiveContainer width=\"100%\" height={height}>\n            {cloneElement(children, { accessibilityLayer: false })}\n          </ResponsiveContainer>\n          {legend && legend.length > 0 ? <ChartLegend items={legend} /> : null}\n        </div>\n      </div>\n      <table id={tableId} className=\"sr-only\">\n        <caption>{label}</caption>\n        <thead>\n          <tr>\n            <th scope=\"col\">{table.categoryHeader}</th>\n            {table.valueHeaders.map((header, index) => (\n              <th key={index} scope=\"col\">\n                {header}\n              </th>\n            ))}\n          </tr>\n        </thead>\n        <tbody>\n          {table.rows.map((row, rowIndex) => (\n            <tr key={rowIndex}>\n              <th scope=\"row\">{row.category}</th>\n              {row.values.map((value, valueIndex) => (\n                <td key={valueIndex}>{value === null ? \"No data\" : value}</td>\n              ))}\n            </tr>\n          ))}\n        </tbody>\n      </table>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/internal/ChartFrame.tsx"
    },
    {
      "path": "components/ui/internal/ChartLegend.tsx",
      "content": "import { cn } from \"@/lib/cn\";\nimport styles from \"@/components/ui/internal/chart.module.css\";\n\nexport type ChartLegendItem = {\n  label: string;\n  /** CSS `var()` reference for the marker color. */\n  colorVar: string;\n  /** \"square\" for area/bar fills, \"line\" for line series. */\n  marker: \"square\" | \"line\";\n};\n\n/**\n * Non-interactive chart legend (CH-2): a marker plus the series name, wrapping\n * onto new lines. It is part of the aria-hidden visual — series identity for\n * assistive technology lives in the hidden data table's column headers — and it\n * deliberately renders no buttons or focusable controls. Series toggling needs a\n * hidden-series state and keyboard/announcement contract and is deferred.\n */\nexport function ChartLegend({ items }: { items: readonly ChartLegendItem[] }) {\n  return (\n    <ul className={styles.legend}>\n      {items.map((item, index) => (\n        <li key={index} className={styles.legendItem}>\n          <span\n            aria-hidden=\"true\"\n            className={cn(styles.marker, item.marker === \"line\" ? styles.markerLine : styles.markerSquare)}\n            style={{ backgroundColor: item.colorVar }}\n          />\n          <span>{item.label}</span>\n        </li>\n      ))}\n    </ul>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/internal/ChartLegend.tsx"
    },
    {
      "path": "components/ui/internal/ChartTooltip.tsx",
      "content": "import {\n  createLabelFormatter,\n  createValueFormatter,\n  type ChartLabelFormat,\n  type ChartValueFormat,\n} from \"@/components/ui/internal/chart-format\";\nimport type { ResolvedChartSeries } from \"@/components/ui/internal/chart-data\";\nimport styles from \"@/components/ui/internal/chart.module.css\";\n\ntype TooltipPayloadEntry = { dataKey?: unknown; value?: unknown };\n\nexport type ChartTooltipProps = {\n  series: readonly ResolvedChartSeries[];\n  valueFormat?: ChartValueFormat;\n  labelFormat?: ChartLabelFormat;\n  /** Supplied by Recharts. */\n  active?: boolean;\n  label?: unknown;\n  payload?: readonly TooltipPayloadEntry[];\n};\n\n/**\n * Shared Cartesian chart tooltip (CH-2): the category label, then one row per\n * series in declared order with its name and formatted value. Series are named\n * in text, never identified by color alone, and missing values read \"No data\".\n *\n * The tooltip is pointer/touch-only supplementary information inside the\n * aria-hidden visual. Everything it shows is also present in the hidden data\n * table, so it is never the only way to reach a value, and it renders no\n * focusable content (the static-chart accessibility model is unchanged).\n * Not to be confused with the generic overlay `Tooltip` component.\n */\nexport function ChartTooltip({ series, valueFormat, labelFormat, active, label, payload }: ChartTooltipProps) {\n  if (!active || !payload || payload.length === 0) return null;\n\n  const formatLabel = createLabelFormatter(labelFormat);\n\n  return (\n    <div className={styles.tooltip}>\n      <p className={styles.tooltipTitle}>{formatLabel(String(label ?? \"\"))}</p>\n      <ul className={styles.tooltipList}>\n        {series.map((entry) => {\n          const point = payload.find((candidate) => candidate.dataKey === entry.key);\n          const value = point && typeof point.value === \"number\" && Number.isFinite(point.value) ? point.value : null;\n          const format = createValueFormatter(entry.format ?? valueFormat);\n          return (\n            <li key={entry.key} className={styles.tooltipRow}>\n              <span\n                aria-hidden=\"true\"\n                className={`${styles.marker} ${styles.markerSquare}`}\n                style={{ backgroundColor: entry.colorVar }}\n              />\n              <span className={styles.tooltipName}>{entry.label}</span>\n              <span className={styles.tooltipValue}>{value === null ? \"No data\" : format(value)}</span>\n            </li>\n          );\n        })}\n      </ul>\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/internal/ChartTooltip.tsx"
    },
    {
      "path": "components/ui/internal/cartesian-parts.tsx",
      "content": "import type { ReactElement } from \"react\";\nimport { CartesianGrid, ReferenceLine, Tooltip, XAxis, YAxis } from \"recharts\";\nimport { ChartTooltip } from \"@/components/ui/internal/ChartTooltip\";\nimport { createValueFormatter, createLabelFormatter, type ChartLabelFormat, type ChartValueFormat } from \"@/components/ui/internal/chart-format\";\nimport type { ResolvedChartSeries } from \"@/components/ui/internal/chart-data\";\n\n/** Reserved width for a value axis on the left (vertical charts). */\nexport const VALUE_AXIS_WIDTH = 48;\n/**\n * Reserved width for the category axis when bars run horizontally. Long labels\n * are NOT truncated or wrapped: a label-length policy is an open design decision,\n * so they may clip at this width.\n */\nexport const CATEGORY_AXIS_WIDTH = 88;\n\nconst AXIS_TICK = { fill: \"var(--chart-axis-text)\", fontSize: 12 };\n\nexport type CartesianPartsOptions = {\n  /** Recharts layout: \"horizontal\" = category on X (columns, lines, areas); \"vertical\" = category on Y (horizontal bars). */\n  layout: \"horizontal\" | \"vertical\";\n  series: readonly ResolvedChartSeries[];\n  showCategoryAxis: boolean;\n  showValueAxis: boolean;\n  showGrid: boolean;\n  tooltip: boolean;\n  /** Draw a baseline at zero (only meaningful when a value is negative). */\n  baseline: boolean;\n  /** 100% stacking: the value axis is a share (0–1) and ticks render as percentages. */\n  percent: boolean;\n  valueFormat?: ChartValueFormat;\n  labelFormat?: ChartLabelFormat;\n  /** Tooltip cursor treatment: a guide line (line/area) or a band (bars). */\n  cursor: \"line\" | \"band\";\n};\n\n/**\n * Shared axis / grid / baseline / tooltip elements for the Cartesian families\n * (CH-2). Returned as keyed elements so a family drops them straight into its\n * Recharts chart element. Axes are always mounted and simply `hide`den when off,\n * because Recharts derives layout from them. Only a narrow, typed option set is\n * exposed — never raw Recharts axis objects.\n */\nexport function cartesianParts(options: CartesianPartsOptions): ReactElement[] {\n  const { layout, series, showCategoryAxis, showValueAxis, showGrid, tooltip, baseline, percent, valueFormat, labelFormat, cursor } = options;\n  const formatLabel = createLabelFormatter(labelFormat);\n  const formatTick = createValueFormatter(percent ? { kind: \"percent\" } : valueFormat);\n  const vertical = layout === \"vertical\";\n\n  const categoryAxisProps = {\n    dataKey: \"label\",\n    type: \"category\" as const,\n    interval: 0 as const,\n    axisLine: false,\n    tickLine: false,\n    tick: AXIS_TICK,\n    tickFormatter: (value: string) => formatLabel(String(value)),\n    hide: !showCategoryAxis,\n  };\n  const valueAxisProps = {\n    type: \"number\" as const,\n    axisLine: false,\n    tickLine: false,\n    tick: AXIS_TICK,\n    tickFormatter: (value: number) => formatTick(value),\n    domain: percent ? ([0, 1] as [number, number]) : undefined,\n    hide: !showValueAxis,\n  };\n\n  const parts: ReactElement[] = [];\n  if (showGrid) {\n    parts.push(\n      <CartesianGrid\n        key=\"grid\"\n        stroke=\"var(--chart-grid)\"\n        horizontal={!vertical}\n        vertical={vertical}\n      />,\n    );\n  }\n  parts.push(\n    vertical ? (\n      <YAxis key=\"category-axis\" {...categoryAxisProps} width={CATEGORY_AXIS_WIDTH} />\n    ) : (\n      <XAxis key=\"category-axis\" {...categoryAxisProps} />\n    ),\n  );\n  parts.push(\n    vertical ? (\n      <XAxis key=\"value-axis\" {...valueAxisProps} />\n    ) : (\n      <YAxis key=\"value-axis\" {...valueAxisProps} width={VALUE_AXIS_WIDTH} />\n    ),\n  );\n  if (baseline) {\n    parts.push(\n      vertical ? (\n        <ReferenceLine key=\"baseline\" x={0} stroke=\"var(--chart-baseline)\" />\n      ) : (\n        <ReferenceLine key=\"baseline\" y={0} stroke=\"var(--chart-baseline)\" />\n      ),\n    );\n  }\n  if (tooltip) {\n    parts.push(\n      <Tooltip\n        key=\"tooltip\"\n        isAnimationActive={false}\n        cursor={cursor === \"band\" ? { fill: \"var(--chart-cursor)\" } : { stroke: \"var(--chart-baseline)\" }}\n        content={(props) => (\n          <ChartTooltip\n            series={series}\n            valueFormat={valueFormat}\n            labelFormat={labelFormat}\n            active={props.active}\n            label={props.label}\n            payload={props.payload}\n          />\n        )}\n      />,\n    );\n  }\n  return parts;\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/internal/cartesian-parts.tsx"
    },
    {
      "path": "components/ui/internal/chart-data.ts",
      "content": "import {\n  createLabelFormatter,\n  createValueFormatter,\n  type ChartLabelFormat,\n  type ChartValueFormat,\n} from \"@/components/ui/internal/chart-format\";\n\n/**\n * Shared Cartesian data + series foundation (CH-1/CH-2). Internal — not public\n * API; families re-export the public types (`ChartRow`, `ChartSeries`, ...).\n *\n * Data model: each row has a categorical `label` and one numeric (or null =\n * missing) value per series key. Single-series charts keep the original\n * `{ label, value }` shape — `value` is the default series key. Scatter (numeric\n * x/y points, no category) has different data semantics and is intentionally not\n * part of this contract.\n */\nexport type ChartDatum = {\n  label: string;\n  value: number;\n};\n\n/** One category row: `label` plus a number (or null for \"no data\") per series key. */\nexport type ChartRow = { label: string } & { readonly [seriesKey: string]: string | number | null };\n\n/** Categorical series color slots (`--chart-series-N`); they carry no status meaning. */\nexport const CHART_SERIES_COLORS = [\"series-1\", \"series-2\", \"series-3\", \"series-4\"] as const;\nexport type ChartSeriesColor = (typeof CHART_SERIES_COLORS)[number];\n\nexport type ChartSeries = {\n  /** Row property holding this series' value. Must be unique and must not be \"label\". */\n  key: string;\n  /** Display name used by the legend, tooltip and the hidden data table header. */\n  label: string;\n  /** Color slot; defaults to the series' position (wrapping after four). */\n  color?: ChartSeriesColor;\n  /** Value format for this series in the tooltip and data table (overrides the chart's `valueFormat`). */\n  format?: ChartValueFormat;\n};\n\nexport type ResolvedChartSeries = {\n  key: string;\n  label: string;\n  color: ChartSeriesColor;\n  /** CSS `var()` reference for SVG attributes and legend markers. */\n  colorVar: string;\n  format?: ChartValueFormat;\n};\n\nexport type ChartTable = {\n  categoryHeader: string;\n  valueHeaders: readonly string[];\n  /** A null cell means \"no data\" for that row/series. */\n  rows: readonly { category: string; values: readonly (string | number | null)[] }[];\n};\n\nexport type PlotRow = { label: string } & { [seriesKey: string]: string | number | null };\n\nconst DEFAULT_SERIES: readonly ChartSeries[] = [{ key: \"value\", label: \"Value\" }];\n\nexport function resolveChartSeries(series?: readonly ChartSeries[]): ResolvedChartSeries[] {\n  const source = series && series.length > 0 ? series : DEFAULT_SERIES;\n  const seen = new Set<string>();\n  return source.map((entry, index) => {\n    if (entry.key === \"label\") {\n      throw new Error('Chart series key must not be \"label\": it is reserved for the category label.');\n    }\n    if (seen.has(entry.key)) {\n      throw new Error(`Chart series keys must be unique; \"${entry.key}\" is repeated.`);\n    }\n    seen.add(entry.key);\n    const color = entry.color ?? CHART_SERIES_COLORS[index % CHART_SERIES_COLORS.length];\n    return { key: entry.key, label: entry.label, color, colorVar: `var(--chart-${color})`, format: entry.format };\n  });\n}\n\nfunction numberOrNull(value: unknown): number | null {\n  return typeof value === \"number\" && Number.isFinite(value) ? value : null;\n}\n\n/** Normalizes rows to exactly the series keys, with non-finite or non-numeric values as null. */\nexport function toPlotData(rows: readonly ChartRow[], series: readonly ResolvedChartSeries[]): PlotRow[] {\n  return rows.map((row) => {\n    const plotRow: PlotRow = { label: String(row.label) };\n    for (const entry of series) plotRow[entry.key] = numberOrNull(row[entry.key]);\n    return plotRow;\n  });\n}\n\nexport function hasNegativeValue(rows: readonly PlotRow[], series: readonly ResolvedChartSeries[]): boolean {\n  return rows.some((row) => series.some((entry) => (row[entry.key] as number | null) !== null && (row[entry.key] as number) < 0));\n}\n\nexport function buildChartTable(\n  rows: readonly PlotRow[],\n  series: readonly ResolvedChartSeries[],\n  options: { valueFormat?: ChartValueFormat; labelFormat?: ChartLabelFormat } = {},\n): ChartTable {\n  const formatLabel = createLabelFormatter(options.labelFormat);\n  const formatters = series.map((entry) => createValueFormatter(entry.format ?? options.valueFormat));\n  return {\n    categoryHeader: \"Label\",\n    valueHeaders: series.map((entry) => entry.label),\n    rows: rows.map((row) => ({\n      category: formatLabel(row.label),\n      values: series.map((entry, index) => {\n        const value = row[entry.key] as number | null;\n        return value === null ? null : formatters[index](value);\n      }),\n    })),\n  };\n}\n\n/** Single-series table used by tests and simple callers: header \"Label\" / \"Value\". */\nexport function singleSeriesChartTable(data: readonly ChartDatum[]): ChartTable {\n  return {\n    categoryHeader: \"Label\",\n    valueHeaders: [\"Value\"],\n    rows: data.map((datum) => ({ category: datum.label, values: [datum.value] })),\n  };\n}\n",
      "type": "registry:lib",
      "target": "~/components/ui/internal/chart-data.ts"
    },
    {
      "path": "components/ui/internal/chart-format.ts",
      "content": "/**\n * Chart formatting contract (CH-2). Internal — not public API; the public\n * surface is the `valueFormat` / `labelFormat` props and the series `format`.\n *\n * Deliberately small: a function escape hatch plus a few typed specs. Number\n * formatting defaults to the fixed `en-US` locale (overridable per spec) so\n * server and client render identical text; there is no i18n framework here.\n * Date labels are formatted in UTC from already-normalized ISO strings\n * (`YYYY`, `YYYY-MM`, `YYYY-MM-DD`) and never read the runtime time zone.\n */\ntype NumberSpec = { locale?: string; maximumFractionDigits?: number };\n\nexport type ChartValueFormat =\n  | ((value: number) => string)\n  | ({ kind: \"number\" } & NumberSpec)\n  | ({ kind: \"compact\" } & NumberSpec)\n  /** The value is a fraction: 0.25 formats as \"25%\". */\n  | ({ kind: \"percent\" } & NumberSpec)\n  | ({ kind: \"currency\"; currency: string } & NumberSpec);\n\nexport type ChartLabelFormat =\n  | ((label: string) => string)\n  | { kind: \"date\"; granularity: \"day\" | \"month\" | \"year\"; locale?: string };\n\nconst DEFAULT_LOCALE = \"en-US\";\n\nexport function createValueFormatter(format?: ChartValueFormat): (value: number) => string {\n  if (!format) return (value) => String(value);\n  if (typeof format === \"function\") return format;\n\n  const locale = format.locale ?? DEFAULT_LOCALE;\n  const digits = format.maximumFractionDigits;\n  let formatter: Intl.NumberFormat;\n  switch (format.kind) {\n    case \"number\":\n      formatter = new Intl.NumberFormat(locale, { maximumFractionDigits: digits });\n      break;\n    case \"compact\":\n      formatter = new Intl.NumberFormat(locale, { notation: \"compact\", maximumFractionDigits: digits ?? 1 });\n      break;\n    case \"percent\":\n      formatter = new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: digits ?? 0 });\n      break;\n    case \"currency\":\n      formatter = new Intl.NumberFormat(locale, {\n        style: \"currency\",\n        currency: format.currency,\n        maximumFractionDigits: digits,\n      });\n      break;\n  }\n  return (value) => formatter.format(value);\n}\n\nconst DATE_OPTIONS: Record<\"day\" | \"month\" | \"year\", Intl.DateTimeFormatOptions> = {\n  day: { month: \"short\", day: \"numeric\" },\n  month: { month: \"short\", year: \"numeric\" },\n  year: { year: \"numeric\" },\n};\n\nfunction parseIsoDate(label: string): Date | undefined {\n  const match = /^(\\d{4})(?:-(\\d{2}))?(?:-(\\d{2}))?$/.exec(label.trim());\n  if (!match) return undefined;\n  const year = Number(match[1]);\n  const month = match[2] ? Number(match[2]) - 1 : 0;\n  const day = match[3] ? Number(match[3]) : 1;\n  const date = new Date(Date.UTC(year, month, day));\n  const valid = date.getUTCFullYear() === year && date.getUTCMonth() === month && date.getUTCDate() === day;\n  return valid ? date : undefined;\n}\n\nexport function createLabelFormatter(format?: ChartLabelFormat): (label: string) => string {\n  if (!format) return (label) => label;\n  if (typeof format === \"function\") return format;\n\n  const formatter = new Intl.DateTimeFormat(format.locale ?? DEFAULT_LOCALE, {\n    ...DATE_OPTIONS[format.granularity],\n    timeZone: \"UTC\",\n  });\n  return (label) => {\n    const date = parseIsoDate(label);\n    // Not a normalized date: show the original label rather than guessing.\n    return date ? formatter.format(date) : label;\n  };\n}\n",
      "type": "registry:lib",
      "target": "~/components/ui/internal/chart-format.ts"
    },
    {
      "path": "components/ui/internal/chart.module.css",
      "content": ".root {\n  display: block;\n  width: 100%;\n}\n\n/*\n * Component-owned chart tokens (CH-1/CH-2). Declared here — not in styles/tokens.css —\n * so they are transported with every chart: the shadcn Foundation carries only\n * primitive/semantic/shape/surface tokens, so chart-specific aliases would otherwise\n * be undefined for a consumer. :where() keeps specificity at zero so a consumer's\n * `className` can override them.\n *\n * Series colors are CATEGORICAL identity slots, not status colors: no slot means\n * \"good\", \"warning\" or \"success\". Slots 1-2 use the brand action and primary text\n * colors; slots 3-4 alias existing amber/green primitives purely for hue separation\n * (each is >= 3:1 against the default white surface). The final categorical palette\n * is an open design decision — see the chart registry openQuestions.\n */\n:where(.root) {\n  --chart-series-1: var(--semantic-action-primary);\n  --chart-series-2: var(--semantic-text-primary);\n  --chart-series-3: var(--primitive-color-warning-700);\n  --chart-series-4: var(--primitive-color-success-700);\n  --chart-axis-text: var(--semantic-text-secondary);\n  --chart-grid: var(--semantic-border-default);\n  --chart-baseline: var(--semantic-border-strong);\n  --chart-marker-fill: var(--semantic-surface-default);\n  --chart-cursor: var(--semantic-surface-subtle);\n  --chart-tooltip-surface: var(--semantic-surface-default);\n  --chart-tooltip-border: var(--semantic-border-default);\n  --chart-tooltip-text: var(--semantic-text-primary);\n  --chart-tooltip-text-muted: var(--semantic-text-secondary);\n  --chart-tooltip-shadow: var(--surface-shadow-raised);\n  --chart-tooltip-radius: var(--shape-radius-control);\n}\n\n.legend {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 4px 16px;\n  margin: 12px 0 0;\n  padding: 0;\n  list-style: none;\n  font-size: 0.75rem;\n  line-height: 1.25rem;\n  color: var(--chart-axis-text);\n}\n\n.legendItem {\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  min-width: 0;\n}\n\n.marker {\n  flex: none;\n  display: inline-block;\n}\n\n.markerSquare {\n  width: 10px;\n  height: 10px;\n  border-radius: 2px;\n}\n\n.markerLine {\n  width: 14px;\n  height: 2px;\n  border-radius: 1px;\n}\n\n.tooltip {\n  min-width: 120px;\n  max-width: 240px;\n  padding: 8px 10px;\n  border: 1px solid var(--chart-tooltip-border);\n  border-radius: var(--chart-tooltip-radius);\n  background: var(--chart-tooltip-surface);\n  box-shadow: var(--chart-tooltip-shadow);\n  color: var(--chart-tooltip-text);\n  font-size: 0.75rem;\n  line-height: 1.25rem;\n}\n\n.tooltipTitle {\n  margin: 0 0 4px;\n  font-weight: 600;\n  color: var(--chart-tooltip-text);\n}\n\n.tooltipList {\n  display: grid;\n  gap: 2px;\n  margin: 0;\n  padding: 0;\n  list-style: none;\n}\n\n.tooltipRow {\n  display: flex;\n  align-items: center;\n  gap: 8px;\n}\n\n.tooltipName {\n  flex: 1 1 auto;\n  min-width: 0;\n  color: var(--chart-tooltip-text-muted);\n}\n\n.tooltipValue {\n  flex: none;\n  font-variant-numeric: tabular-nums;\n  font-weight: 600;\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/internal/chart.module.css"
    }
  ]
}
