{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ink/notification-center",
  "title": "Notification Center",
  "description": "Persistent queue-based notification panel with useNotifications hook",
  "dependencies": [
    "ink"
  ],
  "registryDependencies": [
    "https://termcn.dev/r/ink/interaction.json",
    "https://termcn.dev/r/ink/terminal-style.json",
    "https://termcn.dev/r/ink/use-notifications.json",
    "https://termcn.dev/r/ink/use-theme.json",
    "https://termcn.dev/r/ink/use-unicode.json"
  ],
  "files": [
    {
      "path": "registry/ui/notification-center.tsx",
      "content": "import { useIsScreenReaderEnabled, Box, Text } from \"ink\";\nimport React, { useEffect } from \"react\";\n\nimport { useInteraction } from \"@/hooks/use-interaction\";\nimport type { InteractionProps } from \"@/hooks/use-interaction\";\nimport {\n  useNotificationsProvider,\n  NotificationsContext,\n} from \"@/hooks/use-notifications\";\nimport type { NotificationVariant } from \"@/hooks/use-notifications\";\nimport { useTheme } from \"@/hooks/use-theme\";\nimport { useUnicode } from \"@/hooks/use-unicode\";\nimport { resolveBorderStyle } from \"@/lib/terminal-style\";\n\nexport interface NotificationCenterProps extends InteractionProps {\n  maxVisible?: number;\n  width?: number;\n  \"aria-label\"?: string;\n}\n\nconst variantIcon = (v: NotificationVariant, unicode: boolean): string => {\n  switch (v) {\n    case \"success\": {\n      return unicode ? \"✓\" : \"v\";\n    }\n    case \"warning\": {\n      return \"!\";\n    }\n    case \"error\": {\n      return unicode ? \"✗\" : \"x\";\n    }\n    default: {\n      return \"i\";\n    }\n  }\n};\n\nconst variantColor = (\n  v: NotificationVariant,\n  colors: { success: string; warning: string; error: string; info: string }\n): string => {\n  switch (v) {\n    case \"success\": {\n      return colors.success;\n    }\n    case \"warning\": {\n      return colors.warning;\n    }\n    case \"error\": {\n      return colors.error;\n    }\n    default: {\n      return colors.info;\n    }\n  }\n};\n\nexport const NotificationCenter = ({\n  maxVisible = 5,\n  width = 40,\n  id,\n  autoFocus,\n  isActive = true,\n  disabled,\n  \"aria-label\": ariaLabel = \"Notifications\",\n}: NotificationCenterProps) => {\n  const unicode = useUnicode();\n  const ctx = useNotificationsProvider();\n  const theme = useTheme();\n  const isScreenReaderEnabled = useIsScreenReaderEnabled();\n  const { notifications, dismiss, clear } = ctx;\n\n  const visible = notifications.slice(-maxVisible);\n  const unread = notifications.filter((n) => !n.read).length;\n\n  useEffect(() => {\n    const timers: ReturnType<typeof setTimeout>[] = [];\n    for (const n of notifications) {\n      if (!n.persistent) {\n        const dur = n.duration ?? 5000;\n        const elapsed = Date.now() - n.timestamp;\n        const remaining = dur - elapsed;\n        if (remaining <= 0) {\n          dismiss(n.id);\n        } else {\n          timers.push(setTimeout(() => dismiss(n.id), remaining));\n        }\n      }\n    }\n    return () => {\n      for (const timer of timers) {\n        clearTimeout(timer);\n      }\n    };\n  }, [notifications, dismiss]);\n\n  const { isFocused } = useInteraction(\n    (_input, key) => {\n      if (key.escape) {\n        clear();\n      }\n    },\n    { autoFocus, disabled, id, isActive: isActive && visible.length > 0 }\n  );\n\n  if (visible.length === 0) {\n    return null;\n  }\n\n  return (\n    <NotificationsContext.Provider value={ctx}>\n      <Box\n        flexDirection=\"column\"\n        width={width}\n        aria-role=\"list\"\n        aria-state={{ disabled: disabled || undefined }}\n      >\n        <Text\n          aria-label={`${ariaLabel}. ${visible.length} visible, ${unread} unread.${isFocused ? \" Focused; Escape clears all.\" : \"\"}`}\n        >\n          {\"\"}\n        </Text>\n        <Box\n          flexDirection=\"row\"\n          justifyContent=\"space-between\"\n          marginBottom={0}\n        >\n          <Text bold color={theme.colors.primary}>\n            Notifications {unread > 0 ? `[${unread} unread]` : \"\"}\n          </Text>\n          <Text aria-hidden color={theme.colors.mutedForeground} dimColor>\n            Esc: clear\n          </Text>\n        </Box>\n        {visible.map((n) => {\n          const color = variantColor(n.variant, theme.colors);\n          const icon = variantIcon(n.variant, unicode);\n          return (\n            <Box\n              key={n.id}\n              flexDirection=\"column\"\n              borderStyle={resolveBorderStyle(\n                isScreenReaderEnabled ? undefined : \"single\",\n                unicode\n              )}\n              borderColor={color}\n              padding={0}\n              paddingLeft={1}\n              paddingRight={1}\n              marginTop={0}\n              width={width}\n              aria-role=\"listitem\"\n            >\n              <Text\n                aria-label={`${n.variant} notification: ${n.title}${n.body ? `. ${n.body}` : \"\"}${n.read ? \". Read.\" : \". Unread.\"}`}\n              >\n                {\"\"}\n              </Text>\n              <Box flexDirection=\"row\" gap={1}>\n                <Text aria-hidden color={color} bold>\n                  {icon}\n                </Text>\n                <Text\n                  bold\n                  color={\n                    n.read\n                      ? theme.colors.mutedForeground\n                      : theme.colors.foreground\n                  }\n                >\n                  {n.title}\n                </Text>\n              </Box>\n              {n.body && (\n                <Text color={theme.colors.mutedForeground} dimColor>\n                  {n.body}\n                </Text>\n              )}\n            </Box>\n          );\n        })}\n      </Box>\n    </NotificationsContext.Provider>\n  );\n};\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/ui/notification-badge.tsx",
      "content": "import { Text } from \"ink\";\n\nimport { useTheme } from \"@/hooks/use-theme\";\n\nexport interface NotificationBadgeProps {\n  count: number;\n  color?: string;\n  \"aria-label\"?: string;\n}\n\nexport const NotificationBadge = ({\n  count,\n  color,\n  \"aria-label\": ariaLabel,\n}: NotificationBadgeProps) => {\n  const theme = useTheme();\n  if (count === 0) {\n    return null;\n  }\n  const resolvedColor = color ?? theme.colors.error;\n  return (\n    <Text\n      aria-label={ariaLabel ?? `${count} notifications`}\n      color={resolvedColor}\n    >\n      [{count}]\n    </Text>\n  );\n};\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "overlays"
  ],
  "type": "registry:block"
}