{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "cost-meter",
  "title": "Cost Meter",
  "description": "Run cost split by model or task and compared against an optional session budget.",
  "dependencies": [
    "@solar-icons/react@^2.2.0",
    "cn@^0.3.0"
  ],
  "registryDependencies": [
    "https://pastaui.com/r/pastaui-styles.json"
  ],
  "files": [
    {
      "path": "src/components/ai/cost-meter.tsx",
      "content": "import { DollarMinimalisticIcon as CoinsIcon } from '@solar-icons/react/linear/dollar-minimalistic'\nimport * as React from 'react'\n\nimport { cn } from 'cn'\n\ninterface CostItem {\n  cost: number\n  id: string\n  label: string\n  tokens?: number\n}\n\ninterface CostMeterProps extends React.ComponentProps<'section'> {\n  budget?: number\n  currency?: string\n  items: CostItem[]\n}\n\nconst segmentTones = [\n  'bg-sky-500',\n  'bg-violet-500',\n  'bg-amber-400',\n  'bg-emerald-500',\n  'bg-pink-500',\n]\n\nfunction CostMeter({ budget, className, currency = '$', items, ...props }: CostMeterProps) {\n  const total = items.reduce((sum, item) => sum + item.cost, 0)\n  const scale = budget && budget > total ? budget : total\n  const share = (cost: number) => (total > 0 ? (cost / total) * 100 : 0)\n  const money = (value: number) => `${currency}${value.toFixed(4)}`\n\n  return (\n    <section\n      data-slot=\"cost-meter\"\n      className={cn(\n        'rounded-[16px] bg-card p-5 font-sans text-sm font-[450] tracking-[-0.05px] text-muted-foreground shadow-card',\n        className,\n      )}\n      {...props}\n    >\n      <header className=\"flex items-start gap-3\">\n        <span className=\"flex size-9 shrink-0 items-center justify-center rounded-[10px] bg-foreground/6 text-muted-foreground\">\n          <CoinsIcon className=\"size-4\" />\n        </span>\n        <div className=\"min-w-0 flex-1\">\n          <h3 className=\"text-sm leading-5 font-medium text-muted-foreground\">Run cost</h3>\n          <p className=\"mt-1 flex flex-wrap items-baseline gap-x-1.5 tabular-nums\">\n            <span className=\"text-[22px] leading-7 font-medium tracking-[-0.02em] text-foreground\">\n              {money(total)}\n            </span>\n            {budget !== undefined && (\n              <span className=\"text-sm text-muted-foreground\">\n                of {currency}\n                {budget.toFixed(2)} budget\n              </span>\n            )}\n          </p>\n        </div>\n      </header>\n\n      {budget !== undefined && (\n        <meter\n          aria-label={`Run cost: ${money(total)} of ${currency}${budget.toFixed(2)} budget`}\n          className=\"sr-only\"\n          max={budget}\n          min={0}\n          value={Math.min(total, budget)}\n        />\n      )}\n      <div\n        aria-hidden=\"true\"\n        className=\"mt-4 flex h-1.5 overflow-hidden rounded-full bg-foreground/8\"\n      >\n        {items.map((item, index) => (\n          <span\n            className={cn(\n              'h-full shrink-0 border-r border-card last:border-r-0',\n              segmentTones[index % segmentTones.length],\n            )}\n            key={item.id}\n            style={{ width: `${scale > 0 ? (item.cost / scale) * 100 : 0}%` }}\n          />\n        ))}\n      </div>\n\n      <ul className=\"mt-5 flex flex-col gap-3\">\n        {items.map((item, index) => (\n          <li\n            className=\"grid grid-cols-[minmax(0,1fr)_auto_auto_2.5rem] items-baseline gap-x-4 tabular-nums\"\n            key={item.id}\n          >\n            <span className=\"flex min-w-0 items-center gap-2.5\">\n              <span\n                aria-hidden=\"true\"\n                className={cn(\n                  'size-2 shrink-0 rounded-full',\n                  segmentTones[index % segmentTones.length],\n                )}\n              />\n              <span className=\"truncate text-foreground/80\">{item.label}</span>\n            </span>\n            <span className=\"text-xs leading-5 text-muted-foreground/70\">\n              {item.tokens !== undefined && `${item.tokens.toLocaleString()} tokens`}\n            </span>\n            <span className=\"text-right text-foreground/80\">{money(item.cost)}</span>\n            <span className=\"text-right text-muted-foreground\">\n              {Math.round(share(item.cost))}%\n            </span>\n          </li>\n        ))}\n      </ul>\n    </section>\n  )\n}\n\nexport { CostMeter }\nexport type { CostItem, CostMeterProps }\n",
      "type": "registry:component",
      "target": "@components/ai/cost-meter.tsx"
    }
  ],
  "type": "registry:component"
}