{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "avatar",
  "title": "Avatar",
  "description": "Round portrait with initials fallback.",
  "dependencies": [],
  "registryDependencies": [
    "@hjconsult/lib"
  ],
  "files": [
    {
      "path": "src/components/avatar/index.tsx",
      "content": "'use client'\n\nimport { type ComponentPropsWithoutRef, type Ref, useState } from 'react'\nimport { cn } from '../../lib'\n\nexport type AvatarSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\nconst avatarSizes: Record<AvatarSize, string> = {\n  xs: 'size-6 text-caption',\n  sm: 'size-8 text-caption',\n  md: 'size-10 text-small',\n  lg: 'size-12 text-body',\n  xl: 'size-16 text-lead',\n}\n\nexport function getInitials(name: string): string {\n  const parts = name.trim().split(/\\s+/).filter(Boolean)\n  const first = parts[0]?.[0] ?? ''\n  const last = parts.length > 1 ? (parts[parts.length - 1]?.[0] ?? '') : ''\n  return (first + last).toUpperCase()\n}\n\nexport interface AvatarProps extends ComponentPropsWithoutRef<'span'> {\n  src?: string\n  /** Person's name: used for initials and as the accessible name. */\n  name?: string\n  /** Explicit alt text for the image; defaults to `name`. */\n  alt?: string\n  size?: AvatarSize\n  ref?: Ref<HTMLSpanElement>\n}\n\n/** Round portrait with initials fallback (also shown when the image fails to load). */\nexport function Avatar({ src, name, alt, size = 'md', className, ...props }: AvatarProps) {\n  const [failed, setFailed] = useState(false)\n  const showImage = Boolean(src) && !failed\n  const classes = cn(\n    'relative inline-flex shrink-0 select-none items-center justify-center overflow-hidden rounded-full border border-line bg-surface-raised font-display font-medium text-fg-muted',\n    avatarSizes[size],\n    className,\n  )\n  if (showImage) {\n    return (\n      <span className={classes} {...props}>\n        <img\n          src={src}\n          alt={alt ?? name ?? ''}\n          className=\"size-full object-cover\"\n          onError={() => setFailed(true)}\n        />\n      </span>\n    )\n  }\n  const initials = name ? getInitials(name) : ''\n  if (name) {\n    return (\n      <span role=\"img\" aria-label={name} className={classes} {...props}>\n        <span aria-hidden=\"true\">{initials}</span>\n      </span>\n    )\n  }\n  return <span aria-hidden=\"true\" className={classes} {...props} />\n}\n",
      "type": "registry:ui",
      "target": "hj/components/avatar/index.tsx"
    }
  ],
  "cssVars": {},
  "type": "registry:ui"
}