import * as React from "react" import { cva, type VariantProps } from "class-variance-authority" import { Slot } from "radix-ui" import { cn } from "../../lib/utils" const badgeVariants = cva( "group/badge inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-1 text-xs font-medium leading-none whitespace-nowrap transition-[color,background-color,border-color,box-shadow] duration-150 ease-out focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pe-1.5 has-data-[icon=inline-start]:ps-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", { variants: { variant: { default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80", secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80", destructive: "bg-destructive/10 text-[var(--chip-destructive)] focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:text-red-100 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20", outline: "border-border text-foreground [a]:hover:bg-interactive-hover [a]:hover:text-muted-foreground", ghost: "hover:bg-interactive-hover hover:text-muted-foreground dark:hover:bg-interactive-hover-subtle", link: "text-primary underline-offset-4 hover:underline", /** Leo / Ask prompt chips — readable on light, dark, and HC canvas backgrounds. */ prompt: [ "h-auto min-h-8 max-w-full items-stretch whitespace-normal rounded-full border-border bg-muted p-0 font-normal text-foreground shadow-sm", "[&_button]:text-foreground [&_button]:hover:text-foreground [&_span]:text-foreground", "hc:!border-foreground hc:!bg-background hc:!font-normal hc:!text-foreground hc:shadow-none hc:[&_button]:!text-foreground hc:[&_span]:!text-foreground", "forced-colors:border-[CanvasText] forced-colors:bg-[Canvas] forced-colors:text-[CanvasText] forced-colors:[&_*]:text-[CanvasText]", ].join(" "), /** Numeric count only — solid destructive fill for selection counts and bulk bars. */ count: "min-w-6 justify-center rounded-md border-transparent bg-destructive px-1.5 py-0.5 text-xs font-semibold text-destructive-foreground tabular-nums [a]:hover:bg-destructive/90", }, }, defaultVariants: { variant: "default", }, } ) function Badge({ className, variant = "default", asChild = false, ...props }: React.ComponentProps<"span"> & VariantProps & { asChild?: boolean }) { const Comp = asChild ? Slot.Root : "span" return ( ) } export interface BadgeCountProps extends Omit, "variant" | "children"> { count: number /** Caps display at `max+` (default 99). */ max?: number } /** Red count-only chip — bulk action bar, selection tallies, inline numeric emphasis. */ function BadgeCount({ count, max = 99, className, ...props }: BadgeCountProps) { const display = count > max ? `${max}+` : count return ( {display} ) } /** Uppercase Leo / AI affordance — WCAG-safe on light, dark, and HC surfaces. */ function BadgeAi({ className, ...props }: Omit, "children">) { return ( AI ) } export { Badge, BadgeCount, BadgeAi, badgeVariants }