{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "kpi-card",
  "type": "registry:component",
  "title": "KPI card",
  "description": "Keep the current value, comparison period, and direction together in one compact summary.",
  "categories": [
    "metrics"
  ],
  "dependencies": [
    "@tabler/icons-react",
    "recharts-analytics@npm:recharts@3.10.1"
  ],
  "registryDependencies": [
    "card",
    "tooltip"
  ],
  "files": [
    {
      "path": "src/registry/overtrue/kpi-card.tsx",
      "type": "registry:component",
      "target": "components/overtrue/kpi-card.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { type NumberFormat } from \"./metric-format\";\nimport {\n  Card,\n  CardAction,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle,\n} from \"./analytics-card\";\nimport { DeltaBadge, getDeltaDirection } from \"./delta-badge\";\nimport { Sparkline } from \"./trend-sparkline\";\nimport { MetricValue } from \"./metric-value\";\n\nexport interface KpiCardProps extends Omit<\n  React.ComponentProps<typeof Card>,\n  \"children\"\n> {\n  /** Metric name, e.g. \"Revenue\". */\n  label: string;\n  /** Current value. Numbers are formatted with `format`; strings render as-is. */\n  value: number | string;\n  /** Fractional change vs. the previous period, e.g. 0.124 for +12.4%. */\n  delta?: number;\n  /** Context for the delta, e.g. \"vs. last 30 days\". */\n  deltaLabel?: string;\n  /** Series for the sparkline. Rendered when it has two or more points. */\n  sparkline?: number[];\n  /** @deprecated Use sparkline. Retained for existing consumers. */\n  trend?: number[];\n  format?: NumberFormat;\n  /** ISO 4217 code, used when `format` is \"currency\". */\n  currency?: string;\n  /** Caps the decimals shown, e.g. 0 for whole dollars. */\n  maximumFractionDigits?: number;\n  /** Treat a decrease as good and an increase as bad (churn, latency, errors). */\n  invertDelta?: boolean;\n  /** Optional icon shown before the label. */\n  icon?: React.ReactNode;\n  children?: React.ReactNode;\n}\n\nfunction KpiCard({\n  label,\n  value,\n  delta,\n  deltaLabel,\n  sparkline,\n  trend,\n  format = \"number\",\n  currency,\n  maximumFractionDigits,\n  invertDelta = false,\n  icon,\n  className,\n  children,\n  ...props\n}: KpiCardProps) {\n  const series = sparkline ?? trend;\n  const direction = getDeltaDirection(delta);\n  const isPositive =\n    direction === \"flat\" ? null : (direction === \"up\") !== invertDelta;\n  const trendColor =\n    isPositive === true\n      ? \"var(--color-emerald-500)\"\n      : isPositive === false\n        ? \"var(--color-rose-500)\"\n        : \"var(--color-primary)\";\n\n  return (\n    <Card\n      data-slot=\"kpi-card\"\n      data-direction={direction}\n      className={cn(\n        \"min-w-0 gap-4 rounded-2xl border border-border/70 bg-card py-5 text-card-foreground shadow-[0_1px_2px_rgb(0_0_0/0.04),0_8px_24px_-12px_rgb(0_0_0/0.10)] dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.05),0_1px_2px_rgb(0_0_0/0.5)]\",\n        className,\n      )}\n      {...props}\n    >\n      <CardHeader className=\"gap-y-2 px-5\">\n        <CardDescription className=\"row-start-1 flex min-h-5 min-w-0 items-center gap-1.5 text-[13px] font-medium [&>svg]:size-4 [&>svg]:shrink-0\">\n          {icon}\n          {label}\n        </CardDescription>\n        <CardTitle className=\"col-span-2 row-start-2 text-[1.75rem] leading-8 font-semibold tracking-[-0.035em] tabular-nums\">\n          <MetricValue\n            value={value}\n            format={format}\n            currency={currency}\n            maximumFractionDigits={maximumFractionDigits}\n          />\n        </CardTitle>\n        {delta !== undefined ? (\n          <CardAction className=\"row-span-1\">\n            <DeltaBadge delta={delta} invert={invertDelta} variant=\"soft\" />\n          </CardAction>\n        ) : null}\n      </CardHeader>\n      {series && series.length > 1 ? (\n        <CardContent className=\"px-5\">\n          <Sparkline data={series} color={trendColor} className=\"h-11\" />\n        </CardContent>\n      ) : null}\n      {deltaLabel || children ? (\n        <CardContent className=\"flex min-w-0 items-center gap-2 px-5 text-xs text-muted-foreground\">\n          {deltaLabel ? <span>{deltaLabel}</span> : null}\n          {children}\n        </CardContent>\n      ) : null}\n    </Card>\n  );\n}\n\nexport { KpiCard };\n"
    },
    {
      "path": "src/registry/overtrue/metric-format.tsx",
      "type": "registry:component",
      "target": "components/overtrue/metric-format.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\nexport type NumberFormat = \"number\" | \"compact\" | \"currency\" | \"percent\";\n\nexport interface FormatNumberOptions {\n  format?: NumberFormat;\n  /** ISO 4217 code, used when format is \"currency\". Defaults to USD. */\n  currency?: string;\n  locale?: string;\n  maximumFractionDigits?: number;\n  /** Abbreviate large values, e.g. \"$158K\" instead of \"$158,143\". */\n  compact?: boolean;\n}\n\nconst formatterCache = new Map<string, Intl.NumberFormat>();\n\nfunction getFormatter(locale: string, options: Intl.NumberFormatOptions) {\n  const key = locale + JSON.stringify(options);\n  let formatter = formatterCache.get(key);\n  if (!formatter) {\n    formatter = new Intl.NumberFormat(locale, options);\n    formatterCache.set(key, formatter);\n  }\n  return formatter;\n}\n\n/**\n * Format a metric value for display.\n *\n * formatNumber(1234567)                          -> \"1,234,567\"\n * formatNumber(1234567, { format: \"compact\" })   -> \"1.2M\"\n * formatNumber(48.2, { format: \"currency\" })     -> \"$48.20\"\n * formatNumber(158143, { format: \"currency\", compact: true }) -> \"$158K\"\n * formatNumber(0.124, { format: \"percent\" })     -> \"12.4%\"\n */\nexport function formatNumber(\n  value: number,\n  {\n    format = \"number\",\n    currency = \"USD\",\n    locale = \"en-US\",\n    maximumFractionDigits,\n    compact = false,\n  }: FormatNumberOptions = {},\n): string {\n  if (!Number.isFinite(value)) return \"—\";\n\n  // Compact values keep three significant digits: $158K, $1.23M, 41.2K.\n  const compactOptions: Intl.NumberFormatOptions = compact\n    ? maximumFractionDigits === undefined\n      ? { notation: \"compact\", maximumSignificantDigits: 3 }\n      : { notation: \"compact\", maximumFractionDigits }\n    : {};\n  switch (format) {\n    case \"compact\":\n      return getFormatter(locale, {\n        notation: \"compact\",\n        maximumFractionDigits: maximumFractionDigits ?? 1,\n      }).format(value);\n    case \"currency\":\n      return getFormatter(locale, {\n        style: \"currency\",\n        currency,\n        maximumFractionDigits: maximumFractionDigits ?? 2,\n        ...compactOptions,\n      }).format(value);\n    case \"percent\":\n      return getFormatter(locale, {\n        style: \"percent\",\n        maximumFractionDigits: maximumFractionDigits ?? 1,\n      }).format(value);\n    default:\n      return getFormatter(locale, {\n        maximumFractionDigits: maximumFractionDigits ?? 0,\n        ...compactOptions,\n      }).format(value);\n  }\n}\n\n/**\n * Format a fractional change as a signed percentage.\n *\n * formatDelta(0.124)  -> \"+12.4%\"\n * formatDelta(-0.03)  -> \"-3.0%\"\n * formatDelta(0)      -> \"0.0%\"\n */\nexport function formatDelta(delta: number, locale = \"en-US\"): string {\n  if (!Number.isFinite(delta)) return \"—\";\n  return getFormatter(locale, {\n    style: \"percent\",\n    signDisplay: \"exceptZero\",\n    maximumFractionDigits: 1,\n    minimumFractionDigits: 1,\n  }).format(delta);\n}\n\n/**\n * Fractional change between two values. Returns 0 when there is no baseline.\n */\nexport function computeDelta(current: number, previous: number): number {\n  if (!previous) return 0;\n  return (current - previous) / Math.abs(previous);\n}\n"
    },
    {
      "path": "src/registry/overtrue/analytics-card.tsx",
      "type": "registry:component",
      "target": "components/overtrue/analytics-card.tsx",
      "content": "\"use client\";\nimport type { ComponentProps } from \"react\";\nimport { Card as BaseCard } from \"@/components/ui/card\";\nimport { cn } from \"@/lib/utils\";\n\n// Card sections for analytics compositions; isolated from legacy workspace card spacing.\nexport function Card({ className, ...props }: ComponentProps<typeof BaseCard>) {\n  return (\n    <BaseCard\n      className={cn(\"flex flex-col gap-6 py-6\", className)}\n      {...props}\n    />\n  );\n}\nexport function CardHeader({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-header\"\n      className={cn(\n        \"relative grid grid-cols-1 gap-x-4 gap-y-1.5 px-6 has-[[data-slot=card-action]]:grid-cols-[minmax(0,1fr)_auto]\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\nexport function CardTitle({ className, ...props }: ComponentProps<\"h3\">) {\n  return (\n    <h3\n      className={cn(\n        \"col-start-1 row-start-1 m-0 min-w-0 font-semibold leading-6 text-card-foreground\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\nexport function CardDescription({ className, ...props }: ComponentProps<\"p\">) {\n  return (\n    <p\n      className={cn(\n        \"col-start-1 row-start-2 m-0 min-w-0 text-sm leading-5 text-muted-foreground\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\nexport function CardAction({ className, ...props }: ComponentProps<\"div\">) {\n  return (\n    <div\n      data-slot=\"card-action\"\n      className={cn(\n        \"col-start-2 row-span-2 row-start-1 self-start justify-self-end\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\nexport function CardContent({ className, ...props }: ComponentProps<\"div\">) {\n  return <div className={cn(\"px-6\", className)} {...props} />;\n}\nexport function CardFooter({ className, ...props }: ComponentProps<\"div\">) {\n  return <div className={cn(\"flex items-center px-6\", className)} {...props} />;\n}\n"
    },
    {
      "path": "src/registry/overtrue/delta-badge.tsx",
      "type": "registry:component",
      "target": "components/overtrue/delta-badge.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\nimport * as React from \"react\";\nimport {\n  IconArrowDownRight as ArrowDownRight,\n  IconArrowUpRight as ArrowUpRight,\n  IconMinus as Minus,\n} from \"@tabler/icons-react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { formatDelta } from \"./metric-format\";\n\nexport type DeltaDirection = \"up\" | \"down\" | \"flat\";\n\nexport function getDeltaDirection(delta: number | undefined): DeltaDirection {\n  if (delta === undefined || delta === 0 || !Number.isFinite(delta))\n    return \"flat\";\n  return delta > 0 ? \"up\" : \"down\";\n}\n\nconst directionIcon: Record<DeltaDirection, React.ElementType> = {\n  up: ArrowUpRight,\n  down: ArrowDownRight,\n  flat: Minus,\n};\n\ntype Tone = \"positive\" | \"negative\" | \"neutral\";\n\nconst toneText: Record<Tone, string> = {\n  positive: \"text-emerald-700 dark:text-emerald-400\",\n  negative: \"text-rose-700 dark:text-rose-400\",\n  neutral: \"text-muted-foreground\",\n};\n\nconst toneSoft: Record<Tone, string> = {\n  positive: \"bg-emerald-500/10 dark:bg-emerald-400/10\",\n  negative: \"bg-rose-500/10 dark:bg-rose-400/10\",\n  neutral: \"bg-muted dark:bg-muted/70\",\n};\n\nconst toneOutline: Record<Tone, string> = {\n  positive:\n    \"bg-emerald-500/[0.06] ring-emerald-600/20 dark:bg-emerald-400/[0.07] dark:ring-emerald-400/25\",\n  negative:\n    \"bg-rose-500/[0.06] ring-rose-600/20 dark:bg-rose-400/[0.07] dark:ring-rose-400/25\",\n  neutral: \"bg-muted/40 ring-border\",\n};\n\nexport interface DeltaBadgeProps extends React.ComponentProps<\"span\"> {\n  /** Fractional change, e.g. 0.124 for +12.4%. */\n  delta: number;\n  /** Treat a decrease as good and an increase as bad (churn, latency, errors). */\n  invert?: boolean;\n  variant?: \"outline\" | \"soft\" | \"text\";\n  showIcon?: boolean;\n}\n\n/** A change chip: the arrow shows direction, the color shows whether it helps. */\nfunction DeltaBadge({\n  delta,\n  invert = false,\n  variant = \"outline\",\n  showIcon = true,\n  className,\n  children,\n  ...props\n}: DeltaBadgeProps) {\n  const direction = getDeltaDirection(delta);\n  const positive =\n    direction === \"flat\" ? null : (direction === \"up\") !== invert;\n  const tone: Tone =\n    positive === true\n      ? \"positive\"\n      : positive === false\n        ? \"negative\"\n        : \"neutral\";\n  const Icon = directionIcon[direction];\n  const pill = variant !== \"text\";\n\n  return (\n    <span\n      data-slot=\"delta-badge\"\n      data-direction={direction}\n      data-positive={positive}\n      data-variant={variant}\n      className={cn(\n        \"inline-flex shrink-0 items-center gap-0.5 text-xs leading-none font-medium tracking-[-0.01em] whitespace-nowrap tabular-nums\",\n        pill && \"h-5 rounded-full\",\n        pill && (showIcon ? \"pr-1.5 pl-1\" : \"px-1.5\"),\n        variant === \"outline\" && [\"ring-1 ring-inset\", toneOutline[tone]],\n        variant === \"soft\" && toneSoft[tone],\n        toneText[tone],\n        className,\n      )}\n      {...props}\n    >\n      {showIcon ? (\n        <Icon\n          data-slot=\"delta-badge-icon\"\n          className=\"size-3 shrink-0\"\n          stroke={2.5}\n          aria-hidden=\"true\"\n        />\n      ) : null}\n      {children ?? formatDelta(delta)}\n    </span>\n  );\n}\n\nexport { DeltaBadge };\n"
    },
    {
      "path": "src/registry/overtrue/trend-sparkline.tsx",
      "type": "registry:component",
      "target": "components/overtrue/trend-sparkline.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\nimport {\n  Area,\n  AreaChart,\n  AreaRevealShape,\n  Line,\n  LineChart,\n  ResponsiveContainer,\n  Tooltip,\n  YAxis,\n  type AreaRevealShapeProps,\n  type TooltipContentProps,\n} from \"recharts-analytics\";\n\nimport { cn } from \"@/lib/utils\";\n\nexport interface SparklineProps extends React.ComponentProps<\"div\"> {\n  /** Series to plot, oldest first. */\n  data: number[];\n  variant?: \"area\" | \"line\";\n  /** Area fill: a plain gradient, or a dot grid that fades out toward the line. */\n  fill?: \"gradient\" | \"dots\";\n  /** Any CSS color. Defaults to the theme primary. */\n  color?: string;\n  curve?: \"monotone\" | \"linear\" | \"step\";\n  strokeWidth?: number;\n  /** Animate after hydration and when data changes. Respects reduced motion. */\n  animate?: boolean;\n  animationDuration?: number;\n  /** Mark the most recent value with a haloed point. */\n  endpoint?: boolean;\n  /** Show a hover and keyboard readout of each value. */\n  tooltip?: boolean;\n  /** Formats values in the readout. */\n  valueFormatter?: (value: number, index: number) => string;\n}\n\nconst reducedMotionQuery = \"(prefers-reduced-motion: reduce)\";\n\nfunction subscribeToReducedMotion(onChange: () => void) {\n  const query = window.matchMedia(reducedMotionQuery);\n  query.addEventListener(\"change\", onChange);\n  return () => query.removeEventListener(\"change\", onChange);\n}\n\nfunction getReducedMotionSnapshot() {\n  return window.matchMedia(reducedMotionQuery).matches;\n}\n\nfunction getReducedMotionServerSnapshot() {\n  return true;\n}\n\nconst defaultFormatter = (value: number) =>\n  value.toLocaleString(\"en-US\", { maximumFractionDigits: 2 });\n\n/** Area shape that masks the fill to a dot grid while keeping the stroke solid. */\nfunction DotGridAreaShape({\n  maskId,\n  ...props\n}: AreaRevealShapeProps & { maskId: string }) {\n  return (\n    <>\n      <g mask={`url(#${maskId})`}>\n        <AreaRevealShape {...props} stroke=\"none\" />\n      </g>\n      <AreaRevealShape {...props} id={undefined} fill=\"none\" />\n    </>\n  );\n}\n\n/** A solid point with a soft halo, used for the latest value and the hovered one. */\nfunction HaloDot({\n  cx,\n  cy,\n  color,\n  className,\n  style,\n}: {\n  cx?: number;\n  cy?: number;\n  color: string;\n  className?: string;\n  style?: React.CSSProperties;\n}) {\n  if (cx == null || cy == null) return null;\n  return (\n    <g className={className} style={style}>\n      <circle cx={cx} cy={cy} r={5.25} fill={color} fillOpacity={0.18} />\n      <circle\n        cx={cx}\n        cy={cy}\n        r={2.75}\n        fill={color}\n        stroke=\"var(--color-card)\"\n        strokeWidth={1.5}\n      />\n    </g>\n  );\n}\n\nfunction SparklineTooltip({\n  active,\n  payload,\n  color,\n  format,\n}: Pick<Partial<TooltipContentProps>, \"active\" | \"payload\"> & {\n  color: string;\n  format: (value: number, index: number) => string;\n}) {\n  const entry = payload?.[0];\n  if (!active || !entry || typeof entry.value !== \"number\") return null;\n  const index = (entry.payload as { i: number } | undefined)?.i ?? 0;\n  return (\n    <div\n      data-slot=\"sparkline-tooltip\"\n      className=\"flex items-center gap-2 rounded-xl border border-border/70 bg-popover/90 px-2.5 py-1.5 text-xs text-popover-foreground shadow-xl backdrop-blur-md\"\n    >\n      <span\n        aria-hidden=\"true\"\n        className=\"size-2 shrink-0 rounded-full\"\n        style={{ backgroundColor: color }}\n      />\n      <span className=\"font-medium tabular-nums\">\n        {format(entry.value, index)}\n      </span>\n    </div>\n  );\n}\n\nfunction Sparkline({\n  data,\n  variant = \"area\",\n  fill = \"gradient\",\n  color = \"var(--color-primary)\",\n  curve = \"monotone\",\n  strokeWidth = 2,\n  animate = true,\n  animationDuration = 700,\n  endpoint = true,\n  tooltip = false,\n  valueFormatter = defaultFormatter,\n  className,\n  style,\n  ...props\n}: SparklineProps) {\n  const id = React.useId();\n  const reducedMotion = React.useSyncExternalStore(\n    subscribeToReducedMotion,\n    getReducedMotionSnapshot,\n    getReducedMotionServerSnapshot,\n  );\n  const animationActive = animate && !reducedMotion;\n  const dots = variant === \"area\" && fill === \"dots\";\n  const points = React.useMemo(() => data.map((y, i) => ({ i, y })), [data]);\n  const margin = { top: 2, right: 0, bottom: 0, left: 0 };\n  // Scale to the data, not to zero, so the shape of the trend reads at any size.\n  const domain = React.useMemo((): [number, number] => {\n    const values = data.filter(Number.isFinite);\n    if (!values.length) return [0, 1];\n    const low = Math.min(...values);\n    const high = Math.max(...values);\n    const pad = high === low ? Math.abs(high) * 0.1 || 1 : (high - low) * 0.12;\n    return [low - pad * 1.5, high + pad];\n  }, [data]);\n  const axis = <YAxis hide domain={domain} />;\n  const last = points.length - 1;\n  const dot = endpoint\n    ? (dotProps: { cx?: number; cy?: number; index: number }) =>\n        dotProps.index === last ? (\n          <HaloDot\n            key=\"endpoint\"\n            cx={dotProps.cx}\n            cy={dotProps.cy}\n            color={color}\n            className={cn(\n              \"transition-opacity duration-300 ease-out\",\n              animationActive && \"starting:opacity-0\",\n            )}\n            style={\n              animationActive\n                ? { transitionDelay: `${animationDuration}ms` }\n                : undefined\n            }\n          />\n        ) : null\n    : false;\n  const activeDot = tooltip\n    ? (dotProps: { cx?: number; cy?: number }) => (\n        <HaloDot cx={dotProps.cx} cy={dotProps.cy} color={color} />\n      )\n    : false;\n  const readout = tooltip ? (\n    <Tooltip\n      cursor={{\n        stroke: \"color-mix(in oklab, var(--color-foreground) 25%, transparent)\",\n        strokeWidth: 1,\n      }}\n      isAnimationActive={false}\n      allowEscapeViewBox={{ x: true, y: true }}\n      offset={12}\n      wrapperStyle={{ outline: \"none\", zIndex: 10 }}\n      content={(contentProps) => (\n        <SparklineTooltip\n          active={contentProps.active}\n          payload={contentProps.payload}\n          color={color}\n          format={valueFormatter}\n        />\n      )}\n    />\n  ) : null;\n\n  return (\n    <div\n      data-slot=\"sparkline\"\n      data-variant={variant}\n      aria-hidden={tooltip ? undefined : true}\n      className={cn(\n        \"h-10 w-full [&_.recharts-surface]:overflow-visible\",\n        // In dark mode the line glows in its own color.\n        \"dark:[&_:is(.recharts-area-curve,.recharts-line-curve)]:[filter:drop-shadow(0_0_6px_color-mix(in_oklab,var(--sparkline-color)_50%,transparent))]\",\n        className,\n      )}\n      style={{ ...style, [\"--sparkline-color\" as string]: color }}\n      {...props}\n    >\n      <ResponsiveContainer width=\"100%\" height=\"100%\">\n        {variant === \"line\" ? (\n          <LineChart data={points} margin={margin} accessibilityLayer={tooltip}>\n            {axis}\n            {readout}\n            <Line\n              type={curve}\n              dataKey=\"y\"\n              stroke={color}\n              strokeWidth={strokeWidth}\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              dot={dot}\n              activeDot={activeDot}\n              isAnimationActive={animationActive}\n              animationDuration={animationDuration}\n              animationEasing=\"ease-out\"\n            />\n          </LineChart>\n        ) : (\n          <AreaChart data={points} margin={margin} accessibilityLayer={tooltip}>\n            <defs>\n              <linearGradient id={id} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n                <stop\n                  offset=\"0%\"\n                  stopColor={color}\n                  stopOpacity={dots ? 0.08 : 0.32}\n                />\n                <stop\n                  offset=\"100%\"\n                  stopColor={color}\n                  stopOpacity={dots ? 0.9 : 0}\n                />\n              </linearGradient>\n              {dots ? (\n                <>\n                  <pattern\n                    id={`${id}-dots`}\n                    patternUnits=\"userSpaceOnUse\"\n                    width={4}\n                    height={4}\n                  >\n                    <circle cx={2} cy={2} r={0.9} fill=\"#fff\" />\n                  </pattern>\n                  <mask\n                    id={`${id}-mask`}\n                    maskUnits=\"userSpaceOnUse\"\n                    x={0}\n                    y={0}\n                    width=\"100%\"\n                    height=\"100%\"\n                  >\n                    <rect\n                      width=\"100%\"\n                      height=\"100%\"\n                      fill={`url(#${id}-dots)`}\n                    />\n                  </mask>\n                </>\n              ) : null}\n            </defs>\n            {axis}\n            {readout}\n            <Area\n              type={curve}\n              dataKey=\"y\"\n              stroke={color}\n              strokeWidth={strokeWidth}\n              strokeLinecap=\"round\"\n              strokeLinejoin=\"round\"\n              fill={`url(#${id})`}\n              fillOpacity={dots ? 1 : undefined}\n              dot={dot}\n              activeDot={activeDot}\n              isAnimationActive={animationActive}\n              animationDuration={animationDuration}\n              animationEasing=\"ease-out\"\n              shape={\n                dots\n                  ? (shapeProps: AreaRevealShapeProps) => (\n                      <DotGridAreaShape {...shapeProps} maskId={`${id}-mask`} />\n                    )\n                  : undefined\n              }\n            />\n          </AreaChart>\n        )}\n      </ResponsiveContainer>\n    </div>\n  );\n}\n\nexport { Sparkline };\n"
    },
    {
      "path": "src/registry/overtrue/metric-value.tsx",
      "type": "registry:component",
      "target": "components/overtrue/metric-value.tsx",
      "content": "/** Adapted from dashboardcn (MIT), copyright 2026 dashboardcn contributors.\n * Source: https://github.com/NoahGdev/dashboardcn/tree/b1ffacbca0f7a0be60135c8665b9e8c267205c48\n *\n * MIT License\n *\n * Copyright (c) 2026 dashboardcn contributors\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n *\n * ---\n *\n * Portions of this project are derived from shadcn/ui and shadcn/registry-template\n * (https://github.com/shadcn-ui/ui), Copyright (c) 2023 shadcn, licensed under the\n * MIT License. The notice above applies to those portions as well.\n */\n\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { formatNumber, type NumberFormat } from \"./metric-format\";\nimport {\n  Tooltip,\n  TooltipContent,\n  TooltipProvider,\n  TooltipTrigger,\n} from \"@/components/ui/tooltip\";\n\n/** Values at or above this are abbreviated by default. */\nexport const DEFAULT_COMPACT_FROM = 100_000;\n\nexport interface MetricValueProps extends Omit<\n  React.ComponentProps<\"span\">,\n  \"children\"\n> {\n  /** Strings render as-is. */\n  value: number | string;\n  format?: NumberFormat;\n  currency?: string;\n  maximumFractionDigits?: number;\n  /** Values at or above this are abbreviated (e.g. $158K) with the full value in a tooltip. Set to Infinity to always show the full value. */\n  compactFrom?: number;\n  /** Text after the number, e.g. a unit. */\n  suffix?: React.ReactNode;\n}\n\n// Units and currency symbols sit quieter than the digits they qualify, in\n// whatever color the figure has. They never drop below 12px, and a currency\n// symbol rises toward the cap height only once the figure is large.\nconst quiet = \"font-medium tracking-normal text-current/55\";\nconst unitSize = \"text-[length:max(0.6em,0.75rem)]\";\nconst symbolSize =\n  \"mr-[0.04em] text-[length:max(0.62em,0.75rem)] align-[calc((1em_-_0.75rem)*1.1)]\";\n\n/**\n * Split \"$1,234.5\", \"-€12\", \"12.4%\" or \"2.4 days\" into a quiet symbol, the\n * digits, and a quiet unit. Magnitude letters (K, M, B) stay with the digits.\n * Anything else, such as \"Q3 2026\", renders untouched.\n */\nfunction typeset(text: string) {\n  const match =\n    /^([+\\-\\u2212]?)([^\\d\\s+\\-\\u2212]{0,3})(\\d(?:[\\d.,\\u202f\\u00a0]*\\d)?[KkMBT]?)(%|\\s+\\S.*)?$/.exec(\n      text,\n    );\n  if (!match || /[a-z]/i.test(match[2].replace(/[A-Z]{1,2}(?=\\$)/, \"\")))\n    return text;\n  const [, sign, symbol, digits, unit] = match;\n  return (\n    <>\n      {sign}\n      {symbol ? (\n        <span data-slot=\"metric-value-affix\" className={cn(quiet, symbolSize)}>\n          {symbol}\n        </span>\n      ) : null}\n      {digits}\n      {unit ? (\n        <span data-slot=\"metric-value-unit\" className={cn(quiet, unitSize)}>\n          {unit}\n        </span>\n      ) : null}\n    </>\n  );\n}\n\nfunction Unit({ children }: { children: React.ReactNode }) {\n  if (children === null || children === undefined || children === false)\n    return null;\n  return (\n    <span data-slot=\"metric-value-unit\" className={cn(quiet, unitSize)}>\n      {children}\n    </span>\n  );\n}\n\n/** A formatted number. Large values are abbreviated and reveal the full value on hover. */\nfunction MetricValue({\n  value,\n  format,\n  currency,\n  maximumFractionDigits,\n  compactFrom = DEFAULT_COMPACT_FROM,\n  suffix,\n  className,\n  ...props\n}: MetricValueProps) {\n  const classes = cn(\"tabular-nums tracking-[-0.02em]\", className);\n\n  if (typeof value !== \"number\") {\n    return (\n      <span data-slot=\"metric-value\" className={classes} {...props}>\n        {typeset(value)}\n        <Unit>{suffix}</Unit>\n      </span>\n    );\n  }\n\n  const full = formatNumber(value, { format, currency, maximumFractionDigits });\n  const abbreviate = format !== \"percent\" && Math.abs(value) >= compactFrom;\n  if (!abbreviate) {\n    return (\n      <span data-slot=\"metric-value\" className={classes} {...props}>\n        {typeset(full)}\n        <Unit>{suffix}</Unit>\n      </span>\n    );\n  }\n\n  return (\n    <TooltipProvider>\n      <Tooltip>\n        <TooltipTrigger asChild>\n          <span\n            data-slot=\"metric-value\"\n            data-compact=\"\"\n            className={cn(\n              classes,\n              \"cursor-default decoration-current/30 decoration-dotted underline-offset-[0.18em] hover:underline\",\n            )}\n            {...props}\n          >\n            {typeset(formatNumber(value, { format, currency, compact: true }))}\n            <Unit>{suffix}</Unit>\n          </span>\n        </TooltipTrigger>\n        <TooltipContent className=\"font-medium tabular-nums\">\n          {full}\n          {suffix}\n        </TooltipContent>\n      </Tooltip>\n    </TooltipProvider>\n  );\n}\n\nexport { MetricValue };\n"
    }
  ],
  "docs": "Documentation: https://ui.overtrue.xyz/components/kpi-card. Requires an initialized shadcn/ui project with Tailwind CSS v4."
}
