{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "badge",
  "type": "registry:ui",
  "title": "Badge",
  "description": "A short status or category label in neutral, accent or outline tones.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/theme.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/ui/badge.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/ui/badge.tsx",
      "content": "import { Children, type ReactNode } from 'react';\nimport { cn } from '../lib/utils';\n\nexport type BadgeTone = 'neutral' | 'accent' | 'outline' | 'warning' | 'danger';\n\nconst tones: Record<BadgeTone, string> = {\n  neutral: 'bg-(--kh-bubble) text-kh-ink-2', // the chat kit's fill: surface-2 is the panel itself in dark, so the pill vanished (Klar Portal 10-22 22:4x)\n  accent: 'bg-kh-accent-soft text-kh-accent-ink',\n  outline: 'border border-kh-line-strong text-kh-ink-2',\n  // a high priority, a date close by: the text token carries the contrast, the tint only marks it\n  warning: 'bg-[color-mix(in_oklab,var(--kh-warning)_12%,var(--kh-surface))] text-kh-warning',\n  // urgent, overdue, failed\n  danger: 'bg-[color-mix(in_oklab,var(--kh-danger)_10%,var(--kh-surface))] text-kh-danger',\n};\n\n/** Each run of text in its own span that may shrink, so an over-long word wraps at the row's width; an icon keeps its size. */\nfunction runs(children: ReactNode): ReactNode[] {\n  const out: ReactNode[] = [];\n  let text: (string | number)[] = [];\n  const flush = () => {\n    if (text.length) out.push(<span key={`t${out.length}`} className=\"min-w-0\">{text.join('')}</span>);\n    text = [];\n  };\n  for (const c of Children.toArray(children)) {\n    if (typeof c === 'string' || typeof c === 'number') text.push(c);\n    else { flush(); out.push(c); }\n  }\n  flush();\n  return out;\n}\n\n/** Small label. Tinted background, no coloured edges.\n *  break-word, not anywhere: anywhere lets a table size its column to one letter ('leanin / g', Felix 11-04 14:3x). */\nexport function Badge({ tone = 'neutral', children, className }: { tone?: BadgeTone; children: ReactNode; className?: string }) {\n  return (\n    <span className={cn('inline-flex max-w-full shrink-0 items-center gap-1.5 whitespace-normal [overflow-wrap:break-word] rounded-kh-pill px-2.5 py-0.5 text-kh-caption font-medium', tones[tone], className)}>\n      {runs(children)}\n    </span>\n  );\n}\n"
    }
  ]
}
