{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ewc-badge",
  "title": "Ewc Badge",
  "description": "The nx-ui Ewc Badge block.",
  "dependencies": [
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "@nx-ui/utils"
  ],
  "files": [
    {
      "path": "components/blocks/domain/ewc-badge/ewc-badge.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { cva, type VariantProps } from \"class-variance-authority\"\n\nimport { cn } from \"@/lib/utils\"\n\n/**\n * EwcBadge — a compact inline chip for a European Waste Catalogue code.\n *\n * Shows the formatted code (\"17 01 01\") in mono, with a `*` suffix and a red\n * hazard dot when the entry is hazardous, plus an optional short label (a\n * material or waste-type name). Accepts any code spelling — \"170101\",\n * \"17 01 01\" or \"17 01 01*\" — and normalises it to the spaced form.\n *\n * Pass either a raw `code` string or an `entry` shaped like the ewc-selector\n * block's `EwcEntry` (only `code` and `isHazardous` are read); the hazard\n * flag falls back to a trailing asterisk on the code itself. With an\n * `onClick` the chip renders as a button with the house focus ring.\n */\n\n/** The slice of the ewc-selector `EwcEntry` contract this atom reads. */\nexport interface EwcBadgeEntry {\n  code: string\n  isHazardous?: boolean\n}\n\n/** Normalise any accepted spelling (\"170101\", \"17 01 01\", \"17 01 01*\") to the\n * spaced form (\"17 01 01\") and report the hazard flag. */\nfunction parseEwcCode(raw: string): { code: string; hazardous: boolean } {\n  const trimmed = raw.trim()\n  const hazardous = trimmed.endsWith(\"*\")\n  const digits = trimmed.replace(/[^0-9]/g, \"\")\n  const pairs = digits.match(/.{1,2}/g) ?? []\n  return { code: pairs.join(\" \"), hazardous }\n}\n\nconst ewcBadgeVariants = cva(\n  \"inline-flex w-fit max-w-full shrink-0 items-center gap-1.5 rounded-md bg-muted font-mono whitespace-nowrap tabular-nums text-muted-foreground\",\n  {\n    variants: {\n      size: {\n        sm: \"px-1.5 py-0.5 text-[10px]\",\n        md: \"px-2 py-1 text-xs\",\n      },\n    },\n    defaultVariants: {\n      size: \"sm\",\n    },\n  }\n)\n\nexport interface EwcBadgeProps extends VariantProps<typeof ewcBadgeVariants> {\n  /** The EWC code — \"170101\", \"17 01 01\" or \"17 01 01*\" (asterisk = hazardous). */\n  code?: string\n  /** An `EwcEntry`-compatible object; its hazard flag wins over the asterisk. */\n  entry?: EwcBadgeEntry\n  /** Optional short label shown after the code, e.g. a material name. */\n  label?: string\n  /** Renders the chip as a button. */\n  onClick?: () => void\n  className?: string\n}\n\nexport function EwcBadge({\n  code,\n  entry,\n  label,\n  size,\n  onClick,\n  className,\n}: EwcBadgeProps) {\n  const raw = entry?.code ?? code ?? \"\"\n  const parsed = parseEwcCode(raw)\n  const hazardous = entry?.isHazardous ?? parsed.hazardous\n  const displayCode = hazardous ? `${parsed.code}*` : parsed.code\n\n  const content = (\n    <>\n      <span className=\"truncate\">{displayCode}</span>\n      {hazardous ? (\n        <span\n          role=\"img\"\n          aria-label=\"Hazardous waste\"\n          title=\"Hazardous waste\"\n          className={cn(\n            \"shrink-0 rounded-full bg-utility-red-500\",\n            size === \"md\" ? \"size-1.5\" : \"size-1\"\n          )}\n        />\n      ) : null}\n      {label ? (\n        <span className=\"truncate font-sans text-text-tertiary\">{label}</span>\n      ) : null}\n    </>\n  )\n\n  if (onClick) {\n    return (\n      <button\n        type=\"button\"\n        data-slot=\"ewc-badge\"\n        data-hazardous={hazardous || undefined}\n        onClick={onClick}\n        className={cn(\n          ewcBadgeVariants({ size }),\n          \"cursor-pointer transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:ring-2 focus-visible:ring-ring/25 focus-visible:outline-none\",\n          className\n        )}\n      >\n        {content}\n      </button>\n    )\n  }\n\n  return (\n    <span\n      data-slot=\"ewc-badge\"\n      data-hazardous={hazardous || undefined}\n      className={cn(ewcBadgeVariants({ size }), className)}\n    >\n      {content}\n    </span>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/blocks/domain/ewc-badge/ewc-badge.tsx"
    },
    {
      "path": "components/blocks/domain/ewc-badge/index.ts",
      "content": "export {\n  EwcBadge,\n  type EwcBadgeEntry,\n  type EwcBadgeProps,\n} from \"./ewc-badge\"\n",
      "type": "registry:component",
      "target": "components/blocks/domain/ewc-badge/index.ts"
    }
  ],
  "type": "registry:block"
}