{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sparkline",
  "type": "registry:component",
  "title": "Sparkline",
  "description": "A word-sized trend for tiles, tables and inline text.",
  "dependencies": [],
  "registryDependencies": [
    "https://chartslibraryui.com/r/core.json"
  ],
  "files": [
    {
      "path": "registry/charts/sparkline.tsx",
      "type": "registry:component",
      "target": "components/charts/sparkline.tsx",
      "content": "\"use client\";\n// sparkline.tsx · ChartslibraryUI 1.1.0 · MIT License · https://chartslibraryui.com\n\nimport { useWidth } from \"./core/frame\";\nimport { linePath, areaPath, type MaybePoint } from \"./core/path\";\nimport { linearScale } from \"./core/scale\";\nimport { formatValue, type FormatInput } from \"./core/format\";\n\nexport interface SparklineProps {\n  /** Values in order. null makes a gap. */\n  data: (number | null)[];\n  /** Height in px. Width fills the container unless `width` is set. */\n  height?: number;\n  /** Fixed width in px. Default: fills the container. */\n  width?: number;\n  /** Line colour. Default: the context grey with the last point in the accent. */\n  color?: string;\n  /** Light wash under the line. */\n  area?: boolean;\n  /** Mark the last point. Default true. */\n  endDot?: boolean;\n  /** Include zero in the range. Default false (a sparkline shows shape, not magnitude). */\n  zero?: boolean;\n  /** Used in the accessible label. */\n  label?: string;\n  /** Number format for values: \"currency\", \"percent\", \"integer\", \"compact\" or a format object. */\n  format?: FormatInput;\n  /** Extra class names on the chart's outer element. */\n  className?: string;\n}\n\n/**\n * A word-sized trend with no axes, for tiles, tables and inline text. It shows shape, not magnitude, so pair it\n * with the actual number.\n */\nexport function Sparkline({\n  data,\n  height = 28,\n  width: fixed,\n  color = \"var(--clui-ink-3)\",\n  area = false,\n  endDot = true,\n  zero = false,\n  label = \"Trend\",\n  format,\n  className,\n}: SparklineProps) {\n  const [ref, measured] = useWidth<HTMLSpanElement>(fixed, 120);\n  const width = fixed ?? measured;\n  const values = Array.isArray(data) ? data.map((v) => (typeof v === \"number\" && Number.isFinite(v) ? v : null)) : [];\n  const finite = values.filter((v): v is number => v !== null);\n  const first = finite[0];\n  const last = finite[finite.length - 1];\n  const aria = finite.length\n    ? `${label}: ${finite.length} points, from ${formatValue(first, format)} to ${formatValue(last, format)}, low ${formatValue(\n        Math.min(...finite),\n        format,\n      )}, high ${formatValue(Math.max(...finite), format)}.`\n    : `${label}: no data.`;\n\n  let content = null;\n  if (width > 0 && finite.length > 0) {\n    let lo = Math.min(...finite);\n    let hi = Math.max(...finite);\n    if (zero) {\n      lo = Math.min(0, lo);\n      hi = Math.max(0, hi);\n    }\n    if (lo === hi) {\n      lo -= 1;\n      hi += 1;\n    }\n    const pad = 3;\n    const x = linearScale([0, Math.max(1, values.length - 1)], [pad, width - pad]);\n    const y = linearScale([lo, hi], [height - pad, pad]);\n    const pts: MaybePoint[] = values.map((v, i) => (v === null ? null : [x(i), y(v)]));\n    let lastI = -1;\n    for (let i = values.length - 1; i >= 0; i--) if (values[i] !== null) { lastI = i; break; }\n    content = (\n      <svg width={width} height={height} aria-hidden style={{ display: \"block\", overflow: \"visible\" }}>\n        {area && <path d={areaPath(pts, y(Math.max(lo, Math.min(0, hi))), \"linear\")} style={{ fill: color, opacity: 0.12 }} />}\n        <path d={linePath(pts)} fill=\"none\" style={{ stroke: color }} strokeWidth={1.5} strokeLinejoin=\"round\" strokeLinecap=\"round\" />\n        {endDot && lastI >= 0 && (\n          <circle cx={x(lastI)} cy={y(values[lastI]!)} r={3} style={{ fill: \"var(--clui-s1)\", stroke: \"var(--clui-surface)\" }} strokeWidth={1.5} />\n        )}\n      </svg>\n    );\n  }\n  return (\n    <span\n      ref={ref}\n      className={[\"clui\", className].filter(Boolean).join(\" \")}\n      role=\"img\"\n      aria-label={aria}\n      style={{ display: \"block\", width: fixed ?? \"100%\", height, minWidth: 40 }}\n    >\n      {content}\n    </span>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "tier": "free",
    "category": "trend",
    "component": "Sparkline"
  }
}